歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 成功從Linux 2.6.17.4移植到Linux 2.6.38.8版本

成功從Linux 2.6.17.4移植到Linux 2.6.38.8版本

日期:2017/3/1 10:32:16   编辑:Linux編程

只要移植linux2.6.38.8成功之後,再移植到linux3.0會容易得多,因為linux3.0以上跟linux2.6.38和linux2.6.39差別不大,不過不同的地方是linux3.0之後的lookup_machine_type函數有變化,好像是放到C代碼裡面去了,還沒有來得及仔細閱讀代碼呢, 在移植到linux2.6.38.8版本前,還是先來介紹下,linux2.6.38.8版本的新特征:

* 合並自動進程分組。
* 改善 VFS虛擬文件系統可擴展性, 提升文件夾緩存擴展性。
* BTRFS 文件系統增加 LZO 壓縮,支持創建只讀快照。
* 透明化內存 Huge Pages 使用過程,實現按需自動調用。
* 多 CPU 條件下對網絡傳出數據實現自動負載均衡。
* B.A.T.M.A.N. (Better Approach To Mobile Adhoc Networking) Mesh 協議:去中心化分布式無線 Adhoc 模式 ,特別適用於自然災害等緊急情況下的網絡接入共享。
* AMD Fusion 系列 APU 內置 GPU 的開源驅動

一:machine_desc結構體 跟以前的版本變化不大,不過細節上還是有些變化,首先是machine_desc結構體跟以前少了phys_io和io_pg_offst,在arch\arm\inclue\mach\arch.h見下說明: [cpp]
  1. struct machine_desc {
  2. unsigned int nr; /* architecture number */
  3. const char *name; /* architecture name */
  4. unsigned long boot_params; /* tagged list */
  5. unsigned int nr_irqs; /* number of IRQs */
  6. unsigned int video_start; /* start of video RAM */
  7. unsigned int video_end; /* end of video RAM */
  8. unsigned int reserve_lp0 :1; /* never has lp0 */
  9. unsigned int reserve_lp1 :1; /* never has lp1 */
  10. unsigned int reserve_lp2 :1; /* never has lp2 */
  11. unsigned int soft_reboot :1; /* soft reboot */
  12. void (*fixup)(struct machine_desc *,
  13. struct tag *, char **,
  14. struct meminfo *);
  15. void (*reserve)(void);/* reserve mem blocks */
  16. void (*map_io)(void);/* IO mapping function */
  17. void (*init_early)(void);
  18. void (*init_irq)(void);
  19. struct sys_timer *timer; /* system tick timer */
  20. void (*init_machine)(void);
  21. #ifdef CONFIG_MULTI_IRQ_HANDLER
  22. void (*handle_irq)(struct pt_regs *);
  23. #endif
  24. };
  25. /*
  26. * Current machine - only accessible during boot.
  27. */
  28. extern struct machine_desc *machine_desc;
  29. /*
  30. * Set of macros to define architecture features. This is built into
  31. * a table by the linker.
  32. */
  33. #define MACHINE_START(_type,_name) \
  34. static const struct machine_desc __mach_desc_##_type \
  35. __used \
  36. __attribute__((__section__(".arch.info.init"))) = { \
  37. .nr = MACH_TYPE_##_type, \
  38. .name = _name,
  39. #define MACHINE_END \
  40. };

這樣的話,MACHINE_START宏定義與MACHINE_END宏定義的位置,需要改變下:

MACHINE_START(W90P950EVB, "W90P950EVB")
.boot_params = 0x100,
.map_io = nuc950evb_map_io,
.init_irq = nuc900_init_irq,
.init_machine = nuc950evb_init,
.timer = &nuc900_timer,
MACHINE_END
將phys_io和io_pg_offst拿掉,但請注意,boot_params 參數不可更改,因為這個是和內核的起始地址有關的,如果此地址有變化則Makefile.boot文件也需要更改。

二:lookup_machine_type子程序

這個也是需要修改的一個地方,如果你是采用UBOOT的話,這個也是需要匹配的,至於UBOOT怎麼跟linux內核如何匹配,可以到網絡上搜索。當然也可以修改lookup_machine_type函數,見下:

__lookup_machine_type:
#ifdef CONFIG_ARCH_S3C2410 //此處需要和內核的mach-types文件中的一致
mov r1, #0x708
add r1, r1, #0x42
add r1, r1, #0x04
#endif
adr r3, __lookup_machine_type_data
ldmia r3, {r4, r5, r6}
sub r3, r3, r4 @ get offset between virt&phys
add r5, r5, r3 @ convert virt addresses to
add r6, r6, r3 @ physical address space
1: ldr r3, [r5, #MACHINFO_TYPE] @ get machine type
teq r3, r1 @ matches loader number?
beq 2f @ found
add r5, r5, #SIZEOF_MACHINE_DESC @ next machine_desc
cmp r5, r6
blo 1b
mov r5, #0 @ unknown machine
2: mov pc, lr
ENDPROC(__lookup_machine_type)

MACHINFO_TYPE是在arch\arm\kernel\asm-offsets.c定義,如下所示:

DEFINE(SIZEOF_MACHINE_DESC, sizeof(struct machine_desc));
DEFINE(MACHINFO_TYPE, offsetof(struct machine_desc, nr));
DEFINE(MACHINFO_NAME, offsetof(struct machine_desc, name));

Copyright © Linux教程網 All Rights Reserved