小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Linux內(nèi)核x86架構(gòu)引導(dǎo)協(xié)議6(翻譯)

 just_person 2012-05-08

簡(jiǎn)單的引導(dǎo)示例

在示例中,我們假設(shè)有實(shí)模式內(nèi)存段布局:

 

    當(dāng)加載內(nèi)核實(shí)模式部分到0x90000后,該內(nèi)存段中的內(nèi)容為:

 

       0x0000-0x7fff              內(nèi)核實(shí)模式部分

       0x8000-0xdfff              堆棧

       0xe000-0xffff        內(nèi)核命令行

 

    當(dāng)加載內(nèi)核實(shí)模式部分到0x90000或者引導(dǎo)協(xié)議為2.01及之前的版本:

 

       0x0000-0x7fff              內(nèi)核實(shí)模式部分

       0x8000-0x97ff              堆棧

       0x9800-0x9fff              內(nèi)核命令行

 

內(nèi)核加載程序應(yīng)該對(duì)數(shù)據(jù)頭做以下檢查:

 

       unsigned long base_ptr;  /* base address for real-mode segment */

 

       if ( setup_sects == 0 ) {

              setup_sects = 4;

       }

 

       if ( protocol >= 0x0200 ) {

              type_of_loader = <type code>;

              if ( loading_initrd ) {

                     ramdisk_image = <initrd_address>;

                     ramdisk_size = <initrd_size>;

              }

 

              if ( protocol >= 0x0202 && loadflags & 0x01 )

                     heap_end = 0xe000;

              else

                     heap_end = 0x9800;

 

              if ( protocol >= 0x0201 ) {

                     heap_end_ptr = heap_end - 0x200;

                     loadflags |= 0x80; /* CAN_USE_HEAP */

              }

 

              if ( protocol >= 0x0202 ) {

                     cmd_line_ptr = base_ptr + heap_end;

                     strcpy(cmd_line_ptr, cmdline);

              } else {

                     cmd_line_magic     = 0xA33F;

                     cmd_line_offset = heap_end;

                     setup_move_size = heap_end + strlen(cmdline)+1;

                     strcpy(base_ptr+cmd_line_offset, cmdline);

              }

       } else {

              /* Very old kernel */

 

              heap_end = 0x9800;

 

              cmd_line_magic     = 0xA33F;

              cmd_line_offset = heap_end;

 

              /* A very old kernel MUST have its real-mode code

                 loaded at 0x90000 */

 

              if ( base_ptr != 0x90000 ) {

                     /* Copy the real-mode kernel */

                     memcpy(0x90000, base_ptr, (setup_sects+1)*512);

                     base_ptr = 0x90000;             /* Relocated */

              }

 

              strcpy(0x90000+cmd_line_offset, cmdline);

 

              /* It is recommended to clear memory up to the 32K mark */

              memset(0x90000 + (setup_sects+1)*512, 0,

                     (64-(setup_sects+1))*512);

       }

加載內(nèi)核的其余部分

內(nèi)核的32位(非實(shí)模式)部分處于內(nèi)核文件的(setup_sects+1)*512偏移處(再次提醒一下,如果setup_sects == 0,其真實(shí)值是4)。如果是Image/zImage類(lèi)型的內(nèi)核,它需要被加載到0x10000處。如果是bzImage類(lèi)型的內(nèi)核則需要加載到0x100000

       如果引導(dǎo)一些大于等于2.00并且loadflagsLOAD_HIGH位置位的話(huà),那么內(nèi)核肯定是bzImage類(lèi)型的。也就是說(shuō),代碼可以寫(xiě)成:

       is_bzImage = (protocol >= 0x0200) && (loadflags & 0x01);

       load_address = is_bzImage ? 0x100000 : 0x10000;

 

Note that Image/zImage kernels can be up to 512K in size, and thus use

the entire 0x10000-0x90000 range of memory.  This means it is pretty

much a requirement for these kernels to load the real-mode part at

0x90000.  bzImage kernels allow much more flexibility.

需要特別留意的幾個(gè)命令行選項(xiàng)

If the command line provided by the boot loader is entered by the

user, the user may expect the following command line options to work.

They should normally not be deleted from the kernel command line even

though not all of them are actually meaningful to the kernel.  Boot

loader authors who need additional command line options for the boot

loader itself should get them registered in

Documentation/kernel-parameters.txt to make sure they will not

conflict with actual kernel options now or in the future.

 

  vga=<mode>

       <mode> here is either an integer (in C notation, either

       decimal, octal, or hexadecimal) or one of the strings

       "normal" (meaning 0xFFFF), "ext" (meaning 0xFFFE) or "ask"

       (meaning 0xFFFD).  This value should be entered into the

       vid_mode field, as it is used by the kernel before the command

       line is parsed.

 

  mem=<size>

       <size> is an integer in C notation optionally followed by

       (case insensitive) K, M, G, T, P or E (meaning << 10, << 20,

       << 30, << 40, << 50 or << 60).  This specifies the end of

       memory to the kernel. This affects the possible placement of

       an initrd, since an initrd should be placed near end of

       memory.  Note that this is an option to *both* the kernel and

       the bootloader!

 

  initrd=<file>

       An initrd should be loaded.  The meaning of <file> is

       obviously bootloader-dependent, and some boot loaders

       (e.g. LILO) do not have such a command.

 

In addition, some boot loaders add the following options to the

user-specified command line:

 

  BOOT_IMAGE=<file>

       The boot image which was loaded.  Again, the meaning of <file>

       is obviously bootloader-dependent.

 

  auto

       The kernel was booted without explicit user intervention.

 

If these options are added by the boot loader, it is highly

recommended that they are located *first*, before the user-specified

or configuration-specified command line.  Otherwise, "init=/bin/sh"

gets confused by the "auto" option.

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀(guān)點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多