{"id":294091,"date":"2024-11-01T20:04:54","date_gmt":"2024-11-01T12:04:54","guid":{"rendered":"https:\/\/lrxjmw.cn\/ljxypqdzmygd.html"},"modified":"2024-11-01T20:04:54","modified_gmt":"2024-11-01T12:04:54","slug":"ljxypqdzmygd","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ljxypqdzmygd.html","title":{"rendered":"linux vm \u89e3\u6790\u786c\u76d8\u542f\u52a8\u4e2d MBR \u4e0e GRUB \u7684\u5173\u7cfb\u53ca 16 \u4f4d\u5b9e\u6a21\u5f0f\u4ee3\u7801\u7684\u4f5c\u7528"},"content":{"rendered":"
\n
......<\/code><\/pre>\n<\/p>\n\u4e0a\u9762\u63d0\u53ca\u8fc7\uff0c\u786c\u789f\u4e2dMBR\u662f\u7531GRUB\u5199\u5165\u7684boot.img\uff0c\u56e0\u800c\u8fd9\u513f\u7684linux\/arch\/x86\/boot\/head.S\u4e2d\u7684bootsector\u5bf9\u4e8e\u786c\u789f\u542f\u52a8\u662f\u65e0\u7528\u7684\u3002GRUB\u5c06vmlinuz\u7684setup.bin\u90e8\u4efd\u8bfb\u5230\u663e\u5b58\u5730\u57400x90000\u5904\uff0c\u4e4b\u540e\u8df3\u8f6c\u52300x90200\u5f00\u59cb\u6267\u884c\uff0c\u6b63\u597d\u8df3\u8fc7\u4e86\u4e0a\u9762512\u5b57\u8282\u7684bootsector\uff0c\u4ece_start\u5f00\u59cb\u3002<\/p>\n
16\u4f4d\u7684main\u51fd\u6570<\/p>\n
\u6211\u4eec\u4e00\u822c\u7528C\u7f16\u8bd1\u5668\u7f16\u8bd1\u7684\u4ee3\u7801\uff0c\u662f32\u4f4d\u4fdd\u62a4\u6a21\u5f0f\u4e0b\u7684\u6216\u5219\u662f64\u4f4d\u957f\u6a21\u5f0f\u7684\uff0c\u5374\u6781\u5c11\u7f16\u8bd1\u621016\u4f4d\u5b9e\u6a21\u5f0f\u4e0b\u7684\uff0c\u867d\u7136setup.bin\u5927\u90e8\u4efd\u4ee3\u7801\u90fd\u662f16\u4f4d\u5b9e\u6a21\u5f0f\u4e0b\u7684\u3002\u4ece\u4e0a\u9762\u7684\u4ee3\u7801\u91cc\uff0c\u6211\u4eec\u5c31\u80fd\u770b\u89c1\u5728linux\/arch\/x86\/boot\/head.S\u4e2d\u8c03\u7528\u4e86main\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u5728linux\/arch\/x86\/boot\/main.c\u6587\u4ef6\u4e2d\uff0c\u4ee3\u7801\u5982\u4e0b<\/p>\n
\u91cc\u9762\u90a3\u4e9b\u51fd\u6570\u90fd\u5728linux\/arch\/x86\/boot\/\u76ee\u5f55\u5bf9\u5e94\u7684\u6587\u4ef6\u4e2d\uff0c\u90fd\u662f\u8c03\u7528BIOS\u4e2d\u65ad\u5b8c\u6210\u7684\uff0c\u5177\u4f53\u7ec6\u8282\uff0c\u4f60\u53ef\u4ee5\u81ea\u884c\u67e5\u770b\u3002\u6211\u8fd9\u513f\u5217\u4e3e\u7684\u4ee3\u7801\u53ea\u662f\u5e2e\u52a9\u4f60\u7406\u6e05\u6d41\u7a0b\uff0c\u6211\u4eec\u7ee7\u7eed\u77a7\u77a7go_to_protected_mode()\u51fd\u6570\uff0c\u5728linux\/arch\/x86\/boot\/pm.c\u4e2d\uff0c\u4ee3\u7801\u5982\u4e0b\u3002<\/p>\n
protected_mode_jump\u662f\u4e2a\u6c47\u7f16\u51fd\u6570\uff0c\u5728linux\/arch\/x86\/boot\/pmjump.S\u6587\u4ef6\u4e2d\u5373\u8df3\u8f6c\u5230boot_params.hdr.code32_start\u4e2d\u7684\u5730\u5740\u3002\u8fd9\u4e2a\u5730\u5740\u5728linux\/arch\/x86\/boot\/head.S\u6587\u4ef6\u4e2d\u8bbe\u4e3a0x100000\uff0c\u5982\u4e0b\u6240\u793a<\/p>\n
\u987b\u8981\u6ce8\u610f\u7684\u662f\uff0cGRUB\u4f1a\u628avmlinuz\u4e2d\u7684vmlinux.bin\u90e8\u4efd\uff0c\u7f6e\u4e8e1MB\u5f00\u59cb\u7684\u663e\u5b58\u7a7a\u95f4\u4e2d\u3002\u901a\u8fc7\u8fd9\u4e00\u8df3\u8f6c\uff0c\u5373\u5c06\u6b65\u5165vmlinux.bin\u4e2d\u3002<\/p>\n
startup_32\u51fd\u6570<\/p>\n
startup_32\u4e2d\u987b\u8981\u91cd\u65b0\u52a0\u8f7d\u6bb5\u63cf\u8ff0\u7b26\uff0c\u7136\u540e\u4f30\u7b97vmlinux.bin\u6587\u4ef6\u7684\u7f16\u8bd1\u751f\u6210\u7684\u5730\u5740\u548c\u5b9e\u9645\u52a0\u8f7d\u5730\u5740\u7684\u504f\u659c\uff0c\u4e4b\u540e\u91cd\u65b0\u8bbe\u7f6e\u5185\u6838\u6808linux\u670d\u52a1\u5668\u4ee3\u7ef4\uff0c\u6d4b\u91cfCPU\u662f\u5426\u652f\u6301\u957f\u6a21\u5f0f\uff0c\u63a5\u7740\u518d\u5ea6\u4f30\u7b97vmlinux.bin\u52a0\u8f7d\u5730\u5740\u7684\u504f\u659c\uff0c\u6765\u786e\u5b9a\u5bf9\u5176\u4e2dvmlinux.bin.gz\u89e3\u538b\u7f29\u7684\u5730\u5740\u3002\u5047\u5982CPU\u652f\u6301\u957f\u6a21\u5f0f\u7684\u8bdd\uff0c\u5c31\u8981\u8bbe\u7f6e64\u4f4d\u7684\u5168\u5c40\u63cf\u8ff0\u8868\uff0c\u5f00\u542fCPU\u7684PAE\u5316\u5b66\u5730\u5740\u6269\u5c55\u7279\u70b9\u3002\u518d\u8bbe\u7f6e\u6700\u521d\u7684MMU\u9875\u8868\uff0c\u6700\u540e\u5f00\u542f\u5206\u9875\u5e76\u6b65\u5165\u957f\u6a21\u5f0f\uff0c\u8df3\u8f6c\u5230startup_64\uff0c\u4ee3\u7801\u5982\u4e0b\u3002<\/p>\n
startup_64\u51fd\u6570\u5982\u4eca\uff0c\u6211\u4eec\u603b\u7b97\u5f00\u542f\u4e86CPU\u957f\u6a21\u5f0f\uff0c\u4ecestartup_64\u5f00\u59cb\u771f\u6b63\u6b65\u5165\u4e8664\u4f4d\u7684\u65f6\u4ee3\uff0c\u53ef\u559c\u53ef\u8d3a\u3002startup_64\u51fd\u6570\u540c\u6837\u4e5f\u662f\u5728linux\/arch\/x86\/boot\/compressed\/head64.S\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u3002startup_64\u51fd\u6570\u4e2d\uff0c\u521d\u59cb\u5316\u957f\u6a21\u5f0f\u4e0b\u6570\u636e\u6bb5\u5bc4\u5b58\u5668\uff0c\u786e\u5b9a\u6700\u7ec8\u89e3\u538b\u7f29\u5730\u5740\uff0c\u4e4b\u540e\u62f7\u8d1d\u538b\u7f29vmlinux.bin\u5230\u8be5\u5730\u5740\uff0c\u8df3\u8f6c\u5230decompress_kernel\u5730\u5740\u5904\uff0c\u5f00\u59cb\u89e3\u538bvmlinux.bin.gz\uff0c<\/p>\n
\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u6700\u540e\u5230\u4e86extract_kernel\u51fd\u6570\uff0c\u5b83\u5c31\u662f\u89e3\u538b\u5185\u6838\u7684\u51fd\u6570\uff0c\u4e0b\u8fb9\u6211\u4eec\u5c31\u6765\u7814\u7a76\u5b83\u3002<\/p>\n
extract_kernel\u51fd\u6570<\/p>\n