4.2 GoldFish体系结构移植

GoldFish处理器是ARM体系结构的一种“机器”,这种“机器”的代码在arch/arm/mach-goldfish/目录中,相关的头文件在arch/arm/mach-goldfish/include/mach目录中。

arch/arm/mach-goldfish/目录中的Kconfig是GoldFish的主配置文件,内容如下所示:

    if ARCH_GOLDFISH
    menu "Goldfish Options"
    config MACH_GOLDFISH
        bool "Goldfish (Virtual Platform)"
        select CPU_ARM926T
    config MACH_GOLDFISH_ARMV7
        bool "Goldfish ARMv7 (Virtual Platform)"
        select CPU_V7
            select VFP
            select VFPv3
            select NEON
    endmenu
    endif

当ARCH_GOLDFISH宏被使能的时候,可以选择两种GoldFish处理器,一种由MACH_GOLDFISH表示,一种由宏MACH_GOLDFISH_ARMV7表示。前者是一种ARMV5E体系结构的ARM926处理器,后者是ARMV7体系结构的处理器(即Cortex A),使能了VFP和NEON等特性。在一般情况下,使用MACH_GOLDFISH即可。

arch/arm/mach-goldfish/目录中Makefile的内容如下所示:

    obj-y                      := pdev_bus.o timer.o switch.o audio.o pm.o
    obj-$(CONFIG_MACH_GOLDFISH)     += board-goldfish.o
    obj-$(CONFIG_MACH_GOLDFISH_ARMV7)   += board-goldfish.o

arch/arm/mach-goldfish/board-goldfish.c是GoldFIsh机器实现的核心文件,机器类型的定义如下所示:

    MACHINE_START(GOLDFISH, "Goldfish")
        .phys_io = IO_START,
        .io_pg_offst  = ((IO_BASE) >> 18) & 0xfffc,
        .boot_params  = 0x00000100,
        .map_io        = goldfish_map_io,
        .init_irq     = goldfish_init_irq,
        .init_machine= goldfish_init,
        .timer         = &goldfish_timer,
    MACHINE_END

在MACHINE_START和MACHINE_END之间的内容为机器的信息。这里实现的结构是arch/arm/include/asm/mach/arch.h中定义的struct machine_desc。这里赋值了定时器、物理IO等内容,以及初始化机器、初始化irq、IO映射等函数指针。