Chinaunix首页 | 论坛 | 博客
  • 博客访问: 22004
  • 博文数量: 10
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 140
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-05 00:47
文章分类

全部博文(10)

文章存档

2015年(1)

2014年(9)

我的朋友

分类: 虚拟化

2014-12-23 11:36:55

上次是因为fdt或者atags传的不对,后来内核编译成支持fdt的,也把fdt传进去了,但和kernel里编译的machine_desc对应不上。fdt的用法必须要看了。不过现在没去看这个,直接把kernel里的machine_desc直接给过去了,因为这个kernel里只有一个arndale的machine_desc。

  1.  877 void __init setup_arch(char **cmdline_p)
  2.  878 {
  3.  879 struct machine_desc *mdesc;
  4.  880
  5.  881 unwind_init();
  6.  882
  7.  883 setup_processor();
  8.  884 // uty: test
  9.  885 //mdesc = setup_machine_fdt(__atags_pointer);
  10.  886 //if (!mdesc)
  11.  887 // mdesc = setup_machine_tags(machine_arch_type);
  12.  888 mdesc = __arch_info_begin;
  13.  889 machine_desc = mdesc;
  14.  890 machine_name = mdesc->name;
888行,直接赋值machine_desc。
这部分就跑过去了,还没看到什么问题,不知道因为启用了fdt,kernel后面还会不会出和这个有关的问题。
后面跑没多远,又停了,加了些输出。
跑到这里

  1. (XEN) 3... 2... 1...
  2. (XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen)
  3. (XEN) Freed 264kB init memory.
  4. (XEN) DOM0: Uncompressing Linux... done, booting the kernel.
  5. (XEN) DOM0: <6>Initializing cgroup subsys cpu
  6. (XEN) DOM0: <5>Linux version 3.0.31-g3370a7c-dirty (uty@localhost.localdomain) (gcc version 4.6.x-google 20120106 (prerelease) (GCC) ) #12
  7. (XEN) DOM0: SMP PREEMPT Wed Dec 17 09:32:10 CST 2014
  8. (XEN) DOM0: CPU: ARMv7 Processor [410fc0f4] revision 4 (ARMv7), cr=10c5387d
  9. (XEN) DOM0: CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
  10. (XEN) DOM0: Memory policy: ECC disabled, Data cache writealloc
  11. (XEN) DOM0: uty: build_mem_type_table end
  12. (XEN) DOM0: uty: build_mem_type_table end
  13. (XEN) DOM0: uty: prepare_page_table end
  14. (XEN) DOM0: uty: prepare_page_table end
  15. (XEN) DOM0: uty: map_lowmem end
  16. (XEN) DOM0: uty: map_lowmem end
出错在 arch\arm\mm\mmu.c devicemaps_init(mdesc);
确实,这里跑不过去是正常的。。

  1. 922 /*
  2. 923 * Set up device the mappings. Since we clear out the page tables for all
  3. 924 * mappings above VMALLOC_END, we will remove any debug device mappings.
  4. 925 * This means you have to be careful how you debug this function, or any
  5. 926 * called function. This means you can't use any function or debugging
  6. 927 * method which may touch any device, otherwise the kernel _will_ crash.
  7. 928 */
  8. 929 static void __init devicemaps_init(struct machine_desc *mdesc)
  9. 930 {
  10. 931 struct map_desc map;
  11. 932 unsigned long addr;
  12. 933
  13. 934 /*
  14. 935 * Allocate the vector page early.
  15. 936 */
  16. 937 vectors_page = early_alloc(PAGE_SIZE);
  17. 938
  18. 939 for (addr = VMALLOC_END; addr; addr += PMD_SIZE)
  19. 940 pmd_clear(pmd_off_k(addr));
  20. 941
  21. 942 /*
  22. 943 * Map the kernel if it is XIP.
  23. 944 * It is always first in the modulearea.
  24. 945 */
  25. 946 #ifdef CONFIG_XIP_KERNEL
  26. 947 map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
  27. 948 map.virtual = MODULES_VADDR;
  28. 949 map.length = ((unsigned long)_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK;
  29. 950 map.type = MT_ROM;
  30. 951 create_mapping(&map);
  31. 952 #endif
  32. 953
  33. 954 /*
  34. 955 * Map the cache flushing regions.
  35. 956 */
  36. 957 #ifdef FLUSH_BASE
  37. 958 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
  38. 959 map.virtual = FLUSH_BASE;
  39. 960 map.length = SZ_1M;
  40. 961 map.type = MT_CACHECLEAN;
  41. 962 create_mapping(&map);
  42. 963 #endif
  43. 964 #ifdef FLUSH_BASE_MINICACHE
  44. 965 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
  45. 966 map.virtual = FLUSH_BASE_MINICACHE;
  46. 967 map.length = SZ_1M;
  47. 968 map.type = MT_MINICLEAN;
  48. 969 create_mapping(&map);
  49. 970 #endif
  50. 971
  51. 972 /*
  52. 973 * Create a mapping for the machine vectors at the high-vectors
  53. 974 * location (0xffff0000). If we aren't using high-vectors, also
  54. 975 * create a mapping at the low-vectors virtual address.
  55. 976 */
  56. 977 map.pfn = __phys_to_pfn(virt_to_phys(vectors_page));
  57. 978 map.virtual = 0xffff0000;
  58. 979 map.length = PAGE_SIZE;
  59. 980 map.type = MT_HIGH_VECTORS;
  60. 981 create_mapping(&map);
  61. 982
  62. 983 if (!vectors_high()) {
  63. 984 map.virtual = 0;
  64. 985 map.type = MT_LOW_VECTORS;
  65. 986 create_mapping(&map);
  66. 987 }
  67. 988
  68. 989 /*
  69. 990 * Ask the machine support to map in the statically mapped devices.
  70. 991 */
  71. 992 if (mdesc->map_io)
  72. 993 mdesc->map_io();
  73. 994
  74. 995 /*
  75. 996 * Finally flush the caches and tlb to ensure that we're in a
  76. 997 * consistent state wrt the writebuffer. This also ensures that
  77. 998 * any write-allocated cache lines in the vector page are written
  78. 999 * back. After this point, we can start to touch devices again.
  79. 1000 */
  80. 1001 local_flush_tlb_all();
  81. 1002 flush_cache_all();
  82. 1003 }
chinaunix贴代码怎么烂成这样。。。
这个函数是初始化所有IO地址的。开头的注释说的挺郁闷,不能调式什么的,因为一上来就把VMALLOC_END后的也表全删了。不过printk应该还能用,因为create_mapping里就用了,奇怪create_mapping里不会用到任何io吗?early_print应该可以用,因为是直接用物理地址的。试试就知道了。
这里面还调用了machine_desc->map_io()。因为xen是对内存布局作了修改的,本来是通过修改fdt再传给linux。比如内存已经不是0x40000000开始了,而是从0x80000000开始的512MB,并且这个地址的确定也是xen动态生成的。

  1. 1648 static void __init arndale_fixup(struct machine_desc *desc,
  2. 1649 struct tag *tags, char **cmdline,
  3. 1650 struct meminfo *mi)
  4. 1651 {
  5. 1652 mi->bank[0].start = 0x40000000;
  6. 1653 mi->bank[0].size = 1024 * SZ_1M;
  7. 1654
  8. 1655 mi->bank[1].start = 0x80000000;
  9. 1656 mi->bank[1].size = 1023 * SZ_1M;
  10. 1657
  11. 1658 mi->nr_banks = 2;
  12. 1659 }
这里就需要改,因为0x40000000不在是内存,而linux不知道,再访问这里就会出错。
而map_io里,也要看看xen改了哪里,哪里不能碰。至少uart是不能初始化了,因为xen没有把uart的物理地址映射到dom0里。

  1. 1285 static void __init arndale_map_io(void)
  2. 1286 {
  3. 1287 clk_xxti.rate = 24000000;
  4. 1288 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
  5. 1289 s3c24xx_init_clocks(24000000);
  6. 1290 s3c24xx_init_uarts(arndale_uartcfgs, ARRAY_SIZE(arndale_uartcfgs));
  7. 1291 exynos_reserve_mem();
  8. 1292 }
s5p_init_io(NULL, 0, S5P_VA_CHIPID); 里面初始化minimal的io,这部分在arch/arm/plat-s5p/cpu.c里

  1. 99 /* minimal IO mapping */
  2. 100
  3. 101 static struct map_desc s5p_iodesc[] __initdata = {
  4. 102 {
  5. 103 .virtual = (unsigned long)S5P_VA_CHIPID,
  6. 104 .pfn = __phys_to_pfn(S5P_PA_CHIPID),
  7. 105 .length = SZ_4K,
  8. 106 .type = MT_DEVICE,
  9. 107 }, {
  10. 108 .virtual = (unsigned long)S3C_VA_SYS,
  11. 109 .pfn = __phys_to_pfn(S5P_PA_SYSCON),
  12. 110 .length = SZ_64K,
  13. 111 .type = MT_DEVICE,
  14. 112 }, {
  15. 113 .virtual = (unsigned long)S3C_VA_TIMER,
  16. 114 .pfn = __phys_to_pfn(S5P_PA_TIMER),
  17. 115 .length = SZ_16K,
  18. 116 .type = MT_DEVICE,
  19. 117 }, {
  20. 118 .virtual = (unsigned long)S3C_VA_WATCHDOG,
  21. 119 .pfn = __phys_to_pfn(S3C_PA_WDT),
  22. 120 .length = SZ_4K,
  23. 121 .type = MT_DEVICE,
  24. 122 }, {
  25. 123 .virtual = (unsigned long)S5P_VA_SROMC,
  26. 124 .pfn = __phys_to_pfn(S5P_PA_SROMC),
  27. 125 .length = SZ_4K,
  28. 126 .type = MT_DEVICE,
  29. 127 },
  30. 128 };
  31. 129
  32. 130 /* read cpu identification code */
  33. 131
  34. 132 void __init s5p_init_io(struct map_desc *mach_desc,
  35. 133 int size, void __iomem *cpuid_addr)
  36. 134 {
  37. 135 /* initialize the io descriptors we need for initialization */
  38. 136 iotable_init(s5p_iodesc, ARRAY_SIZE(s5p_iodesc));
  39. 137 if (mach_desc)
  40. 138 iotable_init(mach_desc, size);
  41. 139
  42. 140 /* detect cpu id and rev. */
  43. 141 s5p_init_cpu(cpuid_addr);
  44. 142
  45. 143 s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
  46. 144 }

下面就该看每个io物理地址都是干什么用的,xen都改了哪些,地址空间该怎样映射了。
3.15的kernel里用的是fdt,所以arch\arm\mach-exynos目录下变化非常大,因为描述设备的代码都被fdt配置文件替换了。所以,我想如果在arndale的fdt里能正确的描述LCD,并且kernel对应的驱动也存在,应该能把屏幕驱动起来。

哎,糊里糊涂的点错了,幸亏草稿箱里还有,要不可不想再敲一遍。。。



阅读(479) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~