asmlinkage int printk(const char *fmt, ...)
748 {
749 va_list args;
750 int r;
751 #ifdef CONFIG_DEBUG_LL
752 extern void printascii(const char*);
753 char buff[512];
754 #endif
755 #ifdef CONFIG_KGDB_KDB
756 if (unlikely(kdb_trap_printk)) {
757 va_start(args, fmt);
758 r = vkdb_printf(fmt, args);
759 va_end(args);
760 return r;
761 }
762 #endif
763 va_start(args, fmt);
764 r = vprintk(fmt, args);
765 #ifdef CONFIG_DEBUG_LL
766 vsprintf(buff,fmt,args);
767 #endif
768 va_end(args);
769 #ifdef CONFIG_DEBUG_LL
770 printascii(buff);
771 #endif
772 return r;
773 }
分配给printascii的缓冲区尽量大点,避免缓冲区溢出,缓冲区溢出会打印停顿在溢出的打印那边,通常打印的数据比较大。
3.汇编语言结束后进入asmlinkage void __init start_kernel(void) 函数,该函数在init/main.c当中,内核c语言的入口函数,实现初始化内核
4。修改时钟在 static void __init smdk2440_map_io(void)添加:
代码如下:
static void __init smdk2440_map_io(void)
220 {
221 s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
222 #ifdef CONFIG_S3C2440_XTAL_12000000
223 s3c24xx_init_clocks(12000000);
224 #else
225 s3c24xx_init_clocks(16934400);
226 #endif
227
228 s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
229 }
我用的时钟是12000000,内核默认给的是16934400,添加一个宏变量修改就ok了
5.nand移植
系统在arch/arm/plat-samsung/devs.c 下定义了s3c2410-nand平台设备
#ifdef CONFIG_S3C_DEV_NAND
955 static struct resource s3c_nand_resource[] = {
956 [0] = DEFINE_RES_MEM(S3C_PA_NAND, SZ_1M),
957 };
958
959 struct platform_device s3c_device_nand = {
960 .name = "s3c2410-nand",
961 .id = -1,
962 .num_resources = ARRAY_SIZE(s3c_nand_resource),
963 .resource = s3c_nand_resource,
964 };
只需打开CONFIG_S3C_DEV_NAND宏即可,
平台私有数据配置:
/* nand flash:add by pan*/
87 static int chip0_map[] = { 0 };
88 static struct mtd_partition bit_default_nand_part[] __initdata= {
89 [0] = {
90 .name = "bootloader",
91 .size = 0x00060000,
92 .offset = 0x00000000,
93 },
94 [1] = {
95 .name = "kernel",
96 .size = 0x00200000,
97 .offset = 0x00060000,
98 },
99 [2] = {
100 .name = "root",
101 .size = 0x03d9c000,
102 .offset = 0x00260000,
103 },
104
105 };
/* the bit has 1 selectable slots for nand-flash, the three
108 * on-board chip areas, as well as the external SmartMedia
109 * slot.
110 *
111 * Note, there is no current hot-plug support for the SmartMedia
112 * socket.
113 */
114
115 static struct s3c2410_nand_set bit_nand_sets[] __initdata = {
116 [0] = {
117 .name = "chip0",
118 .nr_chips = 1,
119 .nr_map = chip0_map,
120 .nr_partitions = ARRAY_SIZE(bit_default_nand_part),
121 .partitions = bit_default_nand_part,
122 },
123 };
124
125
126 static struct s3c2410_platform_nand bit_nand_info = {
127 .tacls = 0,
128 .twrph0 = 30,
129 .twrph1 = 0,
130 .nr_sets = ARRAY_SIZE(bit_nand_sets),
131 .sets = bit_nand_sets,
132 };
smdk2440_machine_init(void)中添加
static void __init s3c_nand_set_platdata(&bit_nand_info);
6.cs8900网卡移植
arch/arm/plat-samsung/include/plat/map-s3c.h中定义
#define S3C24XX_VA_CS8900 0xE0000000
36 #define S3C2410_PA_CS8900 (0x19000000)
37 #define S3C24XX_SZ_CS8900 SZ_1M
38 #define S3C24XX_PA_CS8900 S3C2410_PA_CS8900
在static struct map_desc smdk2440_iodesc[] __initdata = { } 结构中添加
, {
80 .virtual = (u32)S3C24XX_VA_CS8900,
81 .pfn = __phys_to_pfn(S3C24XX_PA_CS8900),
82 .length = SZ_1M,
83 .type = MT_DEVICE,
84 }
在void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)函数中实现虚拟地址到物理地址的映射,修改drivers/net/ethernet/cirrus/cs89x0.c
文件,
添加在文件开头
#elif defined(CONFIG_ARCH_UTU2440)
186 static unsigned int netcard_portlist [] __initdata = { S3C24XX_VA_CS8900 + DEFAULTIOBASE, 0 };
187
188 static unsigned int cs8900_irq_map[] = { IRQ_EINT9, 0, 0, 0 };
struct net_device * __init cs89x0_probe(int unit)中修改:
在 io = dev->base_addr;
338 irq = dev->irq;后添加
#if CONFIG_ARCH_UTU2440
340 __raw_writel((__raw_readl(S3C2410_GPGCON)&~(0x3<<2))|(0x2<<2),S3C2410_GPGCON);
341 __raw_writel((__raw_readl(S3C2410_EXTINT1)&~(0x7<<4))|(0x4<<4),S3C2410_EXTINT1);
342
343 #endif
设置GPIO状态
static int __init
531 cs89x0_probe1(struct net_device *dev, unsigned long ioaddr, int modular)
中修改:
reset_chip(dev);后面添加
#ifdef CONFIG_ARCH_UTU2440
633 dev->dev_addr[0] = 0x00;
634 dev->dev_addr[1] = 0x11;
635 dev->dev_addr[2] = 0x3e;
636 dev->dev_addr[3] = 0x26;
637 dev->dev_addr[4] = 0x0a;
638 dev->dev_addr[5] = 0x5b;
639 #endif
设置mac地址必须和uboot设置的mac地址相同
static int
1232 net_open(struct net_device *dev)中修改:
在如下#if #endif 中添加CONFIG_ARCH_UTU2440宏
#if !defined(CONFIG_ARCH_UTU2440)&&!defined(CS89x0_NONISA_IRQ) && !defined(CONFIG_CS89x0_PLATFORM)
1269 if (((1 << dev->irq) & lp->irq_map) == 0) {
1270 printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n",
1271 dev->name, dev->irq, lp->irq_map);
1272 ret = -EAGAIN;
1273 goto bad_out;
1274 }
1275 #endif
在 if (!result) {
1357 printk(KERN_ERR "%s: EEPROM is configured for unavailable media\n", dev->name);
前添加#if defined CONFIG_ARCH_UTU2440
1354 result=A_CNF_10B_T;
1355 #endif
这样网卡移植就ok了