星期六, 5月 12, 2007

Linux 移植 (S3C2410)

V1.0

copyright@2006

email: mesmerli@hotmail.com

目錄結構:

  • rootfs
  • linux
    • include
      • asm-arm
        • arch-creator-s3c2410
          • vmalloc.h
          • uncompress.h.org
          • uncompress.h
          • timex.h
          • time.h
          • system.h
          • s3c2410ASM.h
          • s3c2410_ts.h
          • s3c2410_org.h
          • s3c2410.h
          • power.h
          • memory.h
          • keyboard.h
          • irqs.h
          • irq.h
          • io.h
          • hardware.h
          • dma.h
    • fs
      • binfmt_elf.c
    • drivers
      • net
        • Makefile
        • Config.in
    • arch
      • arm
        • mach-creator-s3c2410
          • Sleep.S
          • power_func.c
          • power.c
          • pcipool.h
          • pcipool.c
          • mm.c (映射I/O位址)
          • Makefile
          • leds.c
          • kapmd.c
          • irq.c (設定中斷向量)
          • dma.c
          • arch.c (設定實體記憶體位址)
          • apm.c
        • kernel
          • irq.c (matched)
        • def-configs
          • create-2410-ramdisk (Make XConfig 用的設定檔)
        • boot
          • compressed
            • head-s3c2410.S (啟動程式碼)
        • Makefikle
        • config.in
    • Makefile
    • .config
  • ext2

跨平台編譯

/usr/src/creator/s3c2410/linux/Makefile

對 ARM 指令集的編譯要使用 arm-linux-gcc

記憶體位址設定

/usr/src/creator/s3c2410/linux/arch/arm/Makefile

VA 0xC0000000 (3GB) 以上為 Kernel Space,對應到 PA 0x30000000 的 SDRAM

VA Virtual Address

PA Physical Address


arch/arm/vmlinux-armv.ld

linker ld 的腳本


TEXTADDR Kernel 在 VA 的執行位址
ZTEXTADDR 解壓縮程式在 RAM 的位置 (PA)
ZRELADDR 解壓縮後的 Kernel 在 RAM 的位置 (PA)


PHYS_OFFSET SDRAM 的位址

設定 RAM 的大小 與 週邊暫存器在 VA 的對應位址

arch
  • arm
    • mach-creator-s3c2410
      • arch.c

static void __init
fixup_s3c2410(struct machine_desc *desc, struct param_struct *params,
char **cmdline, struct meminfo *mi)
{
/*********
* nGCS6 0 (SDRAM Bank 1) has one memory bank at start address 0x30000000
* Memory Size 64Mbye and
* becasue nCCS7 (SDRAM Bank 2) has a flexible start address ,
* we don't need bank[].node if we would use 128Mbyte Memory
*
*/
mi->bank[0].start = PA_SDRAM_BASE;
mi->bank[0].size = S3C2410_MEM_SIZE;
mi->bank[0].node = 0;
mi->nr_banks = 1;

#ifdef CONFIG_BLK_DEV_RAM
ROOT_DEV = MKDEV(RAMDISK_MAJOR,0);

#ifdef CONFIG_BLK_DEV_RAM_SIZE
setup_ramdisk( 1, 0, 0, CONFIG_BLK_DEV_RAM_SIZE);
#else
setup_ramdisk( 1, 0, 0, BLK_DEV_RAM_SIZE);
#endif

#ifdef CONFIG_BLK_DEV_INITRD
setup_initrd( __phys_to_virt(RAMDISK_DN_ADDR), ZIP_RAMDISK_SIZE);
#endif

#endif
}

static void __init s3c2410_map_io(void)
{
HWs3c2410_map_io();
}


MACHINE_START(S3C2410, "create ARM920T-S3C2410")
MAINTAINER("microtime")
BOOT_MEM(PA_SDRAM_BASE,PA_UART_BASE,VA_UART_BASE)
FIXUP(fixup_s3c2410)
MAPIO(s3c2410_map_io)
INITIRQ(s3c2410_init_irq)
MACHINE_END

/usr/src/creator/s3c2410/linux/include/asm-arm/arch-s3c2410/s3c2410.h
實際定義週邊暫存器基底位址的地方


arch
  • arm
    • mach-creator-s3c241
      • mm.c

static struct map_desc standard_io_desc[] __initdata = {
/* virtual physical length domain r w c b */
{ VA_MEM_CTR_BASE,PA_MEM_CTR_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_USB_BASE ,PA_USB_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_INT_BASE ,PA_INT_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_DMA_BASE ,PA_DMA_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_CKPO_BASE ,PA_CKPO_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_LCD_BASE ,PA_LCD_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_NAND_BASE ,PA_NAND_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_UART_BASE ,PA_UART_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_TIMER_BASE ,PA_TIMER_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_UD_BASE ,PA_UD_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_WD_BASE ,PA_WD_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_IIC_BASE ,PA_IIC_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_IIS_BASE ,PA_IIS_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_IO_PORT_BASE,PA_IO_PORT_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_RTC_BASE ,PA_RTC_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_ADC_BASE ,PA_ADC_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_SPI_BASE ,PA_SPI_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_SD_BASE ,PA_SD_BASE ,SZ_1M ,DOMAIN_IO, 0,1,0,0},
{ VA_CS8900A_BASE,PA_CS8900A_BASE ,SZ_32M ,DOMAIN_IO, 0,1,0,0},

LAST_DESC
};


extern void __init HWs3c2410_map_io(void)
{
iotable_init(standard_io_desc);
}

啟動程式碼設定

中斷系統設定

arch
  • arm
    • mach-creator-s3c241
      • irq.c

s3c2410_init_irq(void) {
int irq;

request_resource(&iomem_resource, &irq_resource);
request_resource(&iomem_resource, &eint_resource);

/* disable all IRQs */
rINTMSK = 0xffffffff;
rINTSUBMSK = 0x7ff;
rEINTMSK = 0x00fffff0;

/* all IRQs are IRQ, not FIQ
0 : IRQ mode
1 : FIQ mode
*/
rINTMOD = 0x00000000;

/* clear Source/Interrupt Pending Register */
rSRCPND = 0xffffffff;
rINTPND = 0xffffffff;
rSUBSRCPND = 0x7ff;
rEINTPND = 0x00fffff0;

/* Define irq handler */
for (irq=0; irq < NORMAL_IRQ_OFFSET; irq++) {
irq_desc[irq].valid = 1;
irq_desc[irq].probe_ok = 1;
irq_desc[irq].mask_ack = s3c2410_mask_ack_irq;
irq_desc[irq].mask = s3c2410_mask_irq;
irq_desc[irq].unmask = s3c2410_unmask_irq;
}

irq_desc[IRQ_RESERVED6].valid = 0;
irq_desc[IRQ_RESERVED24].valid = 0;

irq_desc[IRQ_EINT4_7].valid = 0;
irq_desc[IRQ_EINT8_23].valid = 0;

irq_desc[IRQ_EINT0].valid = 0;
irq_desc[IRQ_EINT1].valid = 0;
irq_desc[IRQ_EINT2].valid = 0;
irq_desc[IRQ_EINT3].valid = 0;

for (irq=NORMAL_IRQ_OFFSET; irq < EXT_IRQ_OFFSET; irq++) {
irq_desc[irq].valid = 0;
irq_desc[irq].probe_ok = 1;
irq_desc[irq].mask_ack = EINT4_23mask_ack_irq;
irq_desc[irq].mask = EINT4_23mask_irq;
irq_desc[irq].unmask = EINT4_23unmask_irq;
}

for (irq=EXT_IRQ_OFFSET; irq < SUB_IRQ_OFFSET; irq++) {
irq_desc[irq].valid = 1;
irq_desc[irq].probe_ok = 1;
irq_desc[irq].mask_ack = SUB_mask_ack_irq;
irq_desc[irq].mask = SUB_mask_irq;
irq_desc[irq].unmask = SUB_unmask_irq;
}
}

Make xconfig 選單設定

drivers
  • net
    • Config.in

if [ "$CONFIG_ARCH_CAMELOT" = "y" ]; then
tristate ' Altera Ether00 support' CONFIG_ETHER00
fi

if [ "$CONFIG_NET_PCI" = "y" ]; then
dep_tristate ' AMD PCnet32 PCI support' CONFIG_PCNET32 $CONFIG_PCI
dep_tristate ' Adaptec Starfire support (EXPERIMENTAL)' CONFIG_ADAPTEC_STARFIRE $CONFIG_PCI $CONFIG_EXPERIMENTAL
if [ "$CONFIG_ISA" = "y" -o "$CONFIG_EISA" = "y" ]; then
dep_tristate ' Ansel Communications EISA 3200 support (EXPERIMENTAL)' CONFIG_AC3200 $CONFIG_EXPERIMENTAL
fi

dep_tristate ' Apricot Xen-II on board Ethernet' CONFIG_APRICOT $CONFIG_ISA
dep_tristate ' CS89x0 support' CONFIG_CS89x0 $CONFIG_ISA
dep_tristate ' CERF CS89x0 support' CONFIG_CERF_CS8900A $CONFIG_ISA
dep_tristate ' DECchip Tulip (dc21x4x) PCI support' CONFIG_TULIP $CONFIG_PCI


drivers
  • net
    • Makefile

obj-$(CONFIG_CS89x0) += cs89x0.o
obj-$(CONFIG_CERF_CS8900A) += cs8900a.o
obj-$(CONFIG_MACSONIC) += macsonic.o
obj-$(CONFIG_MACMACE) += macmace.o
obj-$(CONFIG_MAC89x0) += mac89x0.o
obj-$(CONFIG_TUN) += tun.o
obj-$(CONFIG_ETHER00) +=ether00.o
obj-$(CONFIG_DL2K) += dl2k.o

使用 Domingo 除錯核心

0 意見: