ENTRY(stext)\nsetmodePSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode@ and irqs disabled\nmrcp15, 0, r9, c0, c0 @ \u83b7\u5f97\u5904\u7406\u5668ID\uff0c\u5e76\u5b58\u50a8\u5728r9\u5bc4\u5b58\u5668\u4e2d\nbl__lookup_processor_type @ \u7ed3\u679c\u8fd4\u56de\uff1a\u63cf\u8ff0\u5904\u7406\u5668\u7ed3\u6784\u4f53\u7684\u5730\u5740 r5=procinfo \uff0c\u5904\u7406\u5668ID\u53f7 r9=cpuid\nmovsr10, r5 @ invalid processor (r5=0)?\u5224\u65ad\u5185\u6838\u662f\u5426\u652f\u6301\u8be5\u5904\u7406\u5668\nbeq__error_p @ yes, error 'p'\nbl__lookup_machine_type @\u7ed3\u679c\u8fd4\u56de\uff1a\u63cf\u8ff0\u673a\u5668\uff08\u5f00\u53d1\u677f\uff09\u7684\u7ed3\u6784\u4f53\u5730\u5740 r5=machinfo\nmovsr8, r5 @ invalid machine (r5=0)?\u5224\u65ad\u5185\u6838\u662f\u5426\u652f\u6301\u8be5\u673a\u5668\uff08\u5f00\u53d1\u677f\uff09\nbeq__error_a @ yes, error 'a'\nbl__vet_atags @\u68c0\u67e5uboot\u7ed9\u5185\u6838\u7684\u4f20\u53c2ATAGS\u683c\u5f0f\u662f\u5426\u6b63\u786e\n\nbl__create_page_tables @\u5efa\u7acb\u865a\u62df\u5730\u5740\u6620\u5c04\u9875\u8868\nldrr13, __switch_data @ address to jump to after\n<\/code><\/pre>\n<\/p>\n\uff081\uff09\u5173\u95edIRQ\u3001FIQ\u4e2d\u65ad\uff0c\u8fdb\u5165SVC\u6a21\u5f0f\u3002\u8c03\u7528setmode\u5b8f\u5b9e\u73b0\uff1b<\/p>\n
\uff082\uff09\u6821\u9a8c\u5904\u7406\u5668ID\uff0c\u68c0\u9a8c\u5185\u6838\u662f\u5426\u652f\u6301\u8be5\u5904\u7406\u5668\uff1b<\/p>\n
\u82e5\u4e0d\u652f\u6301\uff0c\u5219\u505c\u6b62\u542f\u52a8\u5185\u6838\u3002\u8c03\u7528__lookup_processor_type\u51fd\u6570\u5b9e\u73b0\uff1b<\/p>\n
\uff083\uff09\u6821\u9a8c\u673a\u5668\u7801linux\u5220\u9664\u547d\u4ee4\uff0c\u68c0\u9a8c\u5185\u6838\u662f\u5426\u652f\u6301\u8be5\u673a\u5668\uff1b<\/p>\n
\u82e5\u4e0d\u652f\u6301\uff0c\u5219\u505c\u6b62\u542f\u52a8\u5185\u6838\u3002\u8c03\u7528__lookup_machine_type\u51fd\u6570\u5b9e\u73b0\uff1b<\/p>\n
\uff084\uff09\u68c0\u67e5uboot\u5411\u5185\u6838\u4f20\u53c2ATAGS\u683c\u5f0f\u662f\u5426\u6b63\u786e\uff0c\u8c03\u7528__vet_atars\u51fd\u6570\u5b9e\u73b0\uff1b<\/p>\n
\uff085\uff09\u5efa\u7acb\u865a\u62df\u5730\u5740\u6620\u5c04\u9875\u8868\u3002\u6b64\u5904\u6784\u5efa\u7684\u9875\u8868\u4e3a\u7c97\u9875\u8868\uff0c\u5728\u5185\u6838\u542f\u52a8\u524d\u671f\u4f7f\u7528\u3002Linux\u5bf9\u5185\u5b58\u7ba1\u7406\u6709\u66f4\u7cbe\u7ec6\u7684\u8981\u6c42\uff0c\u968f\u540e\u4f1a\u91cd\u65b0\u6784\u5efa\u66f4\u7cbe\u7ec6\u7684\u9875\u8868\u3002\u8c03\u7528__create_page_tables\u51fd\u6570\u5b9e\u73b0\u3002<\/p>\n
\uff086\uff09\u8df3\u8f6c\u6267\u884c__switch_data\u51fd\u6570\uff0c\u5176\u4e2d\u8c03\u7528__mmap_switched\u5b8c\u6210\u6700\u540e\u7684\u6253\u7b97\u5de5\u4f5c\u3002<\/p>\n
\n
1\uff09\u590d\u5236\u6570\u636e\u6bb5\u3001\u6e05\u9664bss\u6bb5\uff0c\u76ee\u7684\u662f\u6784\u5efaC\u8bed\u8a00\u8fd0\u884c\u73af\u5883\uff1b\n 2\uff09\u4fdd\u5b58\u5904\u7406\u5668ID\u53f7\u3001\u673a\u5668\u7801\u3001uboot\u5411\u5185\u6838\u4f20\u53c2\u5730\u5740\uff1b\n<\/p>\n 3\uff09b start_kernel\u8df3\u8f6c\u81f3\u5185\u6838\u521d\u59cb\u5316\u9636\u6bb5\u3002\n<\/pre>\n<\/p>\n
\n
__switch_data:\n.long__mmap_switched\n..........................................................\n__mmap_switched:\nadrr3, __switch_data + 4\nldmiar3!, {r4, r5, r6, r7}\ncmpr4, r5@ Copy data segment if needed\n1:cmpner5, r6\nldrnefp, [r4], #4\nstrnefp, [r5], #4\nbne1b\n<\/p>\nmovfp, #0@ Clear BSS (and zero fp)\n1:cmpr6, r7\nstrccfp, [r6],#4\nbcc1b\n ARM(ldmiar3, {r4, r5, r6, r7, sp})\n THUMB(ldmiar3, {r4, r5, r6, r7})\n THUMB(ldrsp, [r3, #16])\nstrr9, [r4]@ Save processor ID\nstrr1, [r5]@ Save machine type\nstrr2, [r6]@ Save atags pointer\nbicr4, r0, #CR_A@ Clear 'A' bit\nstmiar7, {r0, r4}@ Save control register values\nbstart_kernel\nENDPROC(__mmap_switched)\n
<\/p>\n<\/code><\/pre>\n<\/p>\n
3. Linux\u5185\u6838\u521d\u59cb\u5316\u9636\u6bb5<\/p>\n
\u6b64\u9636\u6bb5\u4ecestart_kernel\u51fd\u6570\u5f00\u59cb\u3002start_kernel\u51fd\u6570\u662f\u6240\u6709Linux\u5e73\u53f0\u6b65\u5165\u7cfb\u7edf\u5185\u6838\u521d\u59cb\u5316\u7684\u5165\u53e3\u51fd\u6570\u3002\u5b83\u7684\u4e3b\u8981\u5de5\u4f5c\u662f\u5b8c\u6210\u5269\u4f59\u4e0e\u786c\u4ef6\u5e73\u53f0\u76f8\u5173\u7684\u521d\u59cb\u5316\u5de5\u4f5c\uff0c\u5728\u8fdb\u884c\u4e00\u7cfb\u5217\u4e0e\u5185\u6838\u76f8\u5173\u7684\u521d\u59cb\u5316\u4ee5\u540e\uff0c\u8c03\u7528\u7b2c\u4e00\u4e2a\u7528\u6237\u8fdb\u7a0binit\u5e76\u7b49\u5f85\u5176\u6267\u884c\u3002\u81f3\u6b64\uff0c\u6574\u4e2a\u5185\u6838\u542f\u52a8\u5b8c\u6210\u3002<\/p>\n
3.1 start_kernel\u51fd\u6570\u7684\u4e3b\u8981\u5de5\u4f5c<\/p>\n
start_kernel\u51fd\u6570\u4e3b\u8981\u5b8c\u6210\u5185\u6838\u76f8\u5173\u7684\u521d\u59cb\u5316\u5de5\u4f5c\u3002\u5177\u4f53\u5305\u62ec\u4ee5\u4e0b\u90e8\u4efd\uff1a<\/p>\n
\uff081\uff09\u5185\u6838\u6784\u67b6 \u3001\u901a\u7528\u914d\u7f6e\u76f8\u5173\u521d\u59cb\u5316<\/p>\n
\uff082\uff09 \u5185\u5b58\u7ba1\u7406\u76f8\u5173\u521d\u59cb\u5316<\/p>\n
\uff083\uff09\u8fdb\u7a0b\u7ba1\u7406\u76f8\u5173\u521d\u59cb\u5316<\/p>\n
\uff084\uff09\u8fdb\u7a0b\u8c03\u5ea6\u76f8\u5173\u521d\u59cb\u5316<\/p>\n
\uff085\uff09\u7f51\u7edc\u5b50\u7cfb\u7edf\u7ba1\u7406<\/p>\n
\uff086\uff09\u865a\u62df\u6587\u4ef6\u7cfb\u7edf<\/p>\n
\uff087\uff09\u6587\u4ef6\u7cfb\u7edf<\/p>\n
3.2 start_kernel\u51fd\u6570\u6d41\u4e2d\u7684\u5173\u952e\u51fd\u6570<\/p>\n
<\/p>\n
\uff081\uff09setup_arch(&command_line)\u51fd\u6570<\/p>\n
\u5185\u6838\u6784\u67b6\u76f8\u5173\u7684\u521d\u59cb\u5316\u51fd\u6570\uff0c\u662f\u5341\u5206\u91cd\u8981\u7684\u4e00\u4e2a\u521d\u59cb\u5316\u6b65\u9aa4\u3002\u5176\u4e2d\uff0c\u5305\u542b\u4e86\u5904\u7406\u5668\u76f8\u5173\u53c2\u6570\u7684\u521d\u59cb\u5316\u3001\u5185\u6838\u542f\u52a8\u53c2\u6570\uff08tagged list\uff09\u7684\u83b7\u53d6\u548c\u524d\u671f\u5904\u7406\u3001\u5185\u5b58\u5b50\u7cfb\u7edf\u7684\u521d\u671f\u521d\u59cb\u5316\u3002<\/p>\n
command_line\u5b9e\u8d28\u662fuboot\u5411\u5185\u6838\u4f20\u9012\u7684\u547d\u4ee4\u884c\u542f\u52a8\u53c2\u6570\uff0c\u5373uboot\u4e2d\u73af\u5883\u53d8\u91cfbootargs\u7684\u503c\u3002\u82e5uboot\u4e2dbootargs\u7684\u503c\u4e3a\u7a7alinux \u5185\u6838\u542f\u52a8<\/strong>\uff0ccommand_line = default_command_line\uff0c\u5373\u4e3a\u5185\u6838\u4e2d\u7684\u9ed8\u8ba4\u547d\u4ee4\u884c\u53c2\u6570\uff0c\u5176\u503c\u5728.config\u6587\u4ef6\u4e2d\u914d\u7f6e\uff0c\u5bf9\u5e94CONFIG_CMDLINE\u914d\u7f6e\u9879\u3002<\/p>\n\uff082\uff09setup_command_line\u3001parse_early_param\u4ee5\u53caparse_args\u51fd\u6570<\/p>\n
\u8fd9\u4e9b\u51fd\u6570\u90fd\u662f\u5728\u5b8c\u6210\u547d\u4ee4\u884c\u53c2\u6570\u7684\u89e3\u6790\u3001\u4fdd\u5b58\u3002\u8b6c\u5982\uff0ccmdline = console=ttySAC2,115200 root=\/dev\/mmcblk0p2 rw init=\/linuxrc rootfstype=ext3\uff1b\u89e3\u6790\u4e3a\u4e00\u4e0b\u56db\u4e2a\u53c2\u6570\uff1a<\/p>\n
console=ttySAC2,115200 \/\/\u6307\u5b9a\u63a7\u5236\u53f0\u7684\u5e76\u53e3\u8bbe\u5907\u53f7\uff0c\u53ca\u5176\u7801\u7387<\/p>\n
root=\/dev\/mmcblk0p2 rw \/\/\u6307\u5b9a\u6839\u6587\u4ef6\u7cfb\u7edfrootfs\u7684\u8def\u5f84<\/p>\n
init=\/linuxrc \/\/\u6307\u5b9a\u7b2c\u4e00\u4e2a\u7528\u6237\u8fdb\u7a0binit\u7684\u8def\u5f84<\/p>\n
rootfstype=ext3 \/\/\u6307\u5b9a\u6839\u6587\u4ef6\u7cfb\u7edfrootfs\u7684\u7c7b\u578b<\/p>\n
\uff083\uff09sched_init\u51fd\u6570<\/p>\n
\u521d\u59cb\u5316\u8fdb\u7a0b\u8c03\u5ea6\u5668\uff0c\u521b\u5efa\u8fd0\u884c\u961f\u5217\u7ea2\u8054linux\u8bba\u575b\uff0c\u8bbe\u7f6e\u5f53\u524d\u4efb\u52a1\u7684\u7a7a\u7ebf\u7a0b\u3002<\/p>\n
\uff084\uff09rest_init\u51fd\u6570<\/p>\n
rest_init\u51fd\u6570\u7684\u4e3b\u8981\u5de5\u4f5c\u5982\u4e0b\uff1a<\/p>\n
\n
1\uff09\u8c03\u7528kernel_thread\u51fd\u6570\u542f\u52a8\u4e862\u4e2a\u5185\u6838\u7ebf\u7a0b\uff0c\u5206\u522b\u662f\uff1akernel_init\u548ckthreadd\u3002\nkernel_init\u7ebf\u7a0b\u4e2d\u8c03\u7528prepare_namespace\u51fd\u6570\u6302\u8f7d\u6839\u6587\u4ef6\u7cfb\u7edfrootfs\uff1b\u7136\u540e\u8c03\u7528init_post\u51fd\u6570\uff0c\u6267\u884c\u6839\u6587\u4ef6\u7cfb\u7edfrootfs\u4e0b\u7684\u7b2c\u4e00\u4e2a\u7528\u6237\u8fdb\u7a0binit\u3002\u7528\u6237\u8fdb\u7a0b\u67094\u4e2a\u5907\u9009\u65b9\u6848\uff0c\u82e5command_line\u4e2dinit\u7684\u8def\u5f84\u9519\u8bef\uff0c\u5219\u4f1a\u6267\u884c\u5907\u7528\u65b9\u6848\u3002\u7b2c\u4e00\u5907\u7528\uff1a\/sbin\/init\uff0c\u7b2c\u4e8c\u5907\u7528\uff1a\/etc\/init\uff0c\u7b2c\u4e09\u5907\u7528\uff1a\/bin\/init\uff0c\u7b2c\u56db\u5907\u7528\uff1a\/bin\/sh\u3002\n2\uff09\u8c03\u7528schedule\u51fd\u6570\u5f00\u542f\u5185\u6838\u8c03\u5ea6\u7cfb\u7edf\uff1b\n3\uff09\u8c03\u7528cpu_idle\u51fd\u6570\uff0c\u542f\u52a8\u7a7a\u95f2\u8fdb\u7a0bidle\uff0c\u5b8c\u6210\u5185\u6838\u542f\u52a8\u3002<\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"start_kernel\u51fd\u6570\u662f\u6240\u6709Linux\u5e73\u53f0\u8fdb\u5165\u7cfb\u7edf\u5185\u6838\u521d\u59cb\u5316\u7684\u5165\u53e3\u51fd\u6570\u3002\u5b83\u7684\u4e3b\u8981\u5de5\u4f5c\u662f\u5b8c\u6210\u5269\u4f59\u4e0e\u786c\u4ef6\u5e73\u53f0\u76f8\u5173\u7684\u521d\u59cb\u5316\u5de5\u4f5c\uff0c\u5728\u8fdb\u884c\u4e00\u7cfb\u5217\u4e0e\u5185\u6838\u76f8\u5173\u7684\u521d\u59cb\u5316\u4e4b\u540e\uff0c\u8c03\u7528\u7b2c\u4e00\u4e2a\u7528\u6237\u8fdb\u7a0binit\u5e76\u7b49\u5f85\u5176\u6267\u884c\u3002\u5185\u6838\u67b6\u6784\u76f8\u5173\u7684\u521d\u59cb\u5316\u51fd\u6570\uff0c\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u4e2a\u521d\u59cb\u5316\u6b65\u9aa4\u3002<\/p>\n","protected":false},"author":1,"featured_media":294447,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[4357,4355,1421,4358,4356],"class_list":["post-294446","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-dhs-2","tag-uyd","tag-ncgl","tag-nhcsh","tag-nhqd-2"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/294446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=294446"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/294446\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/294447"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=294446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=294446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=294446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}