⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multiboot.texi

📁 i386的bootloader源码grub
💻 TEXI
📖 第 1 页 / 共 4 页
字号:
        +-------------------+12      | boot_device       |    (present if flags[1] is set)        +-------------------+16      | cmdline           |    (present if flags[2] is set)        +-------------------+20      | mods_count        |    (present if flags[3] is set)24      | mods_addr         |    (present if flags[3] is set)        +-------------------+28 - 40 | syms              |    (present if flags[4] or        |                   |                flags[5] is set)        +-------------------+44      | mmap_length       |    (present if flags[6] is set)48      | mmap_addr         |    (present if flags[6] is set)        +-------------------+52      | drives_length     |    (present if flags[7] is set)56      | drives_addr       |    (present if flags[7] is set)        +-------------------+60      | config_table      |    (present if flags[8] is set)        +-------------------+64      | boot_loader_name  |    (present if flags[9] is set)        +-------------------+68      | apm_table         |    (present if flags[10] is set)        +-------------------+72      | vbe_control_info  |    (present if flags[11] is set)76      | vbe_mode_info     |80      | vbe_mode          |82      | vbe_interface_seg |84      | vbe_interface_off |86      | vbe_interface_len |        +-------------------+@end group@end exampleThe first longword indicates the presence and validity of other fieldsin the Multiboot information structure. All as-yet-undefined bits mustbe set to zero by the boot loader. Any set bits that the operatingsystem does not understand should be ignored. Thus, the @samp{flags}field also functions as a version indicator, allowing the Multibootinformation structure to be expanded in the future without breakinganything.If bit 0 in the @samp{flags} word is set, then the @samp{mem_*} fieldsare valid. @samp{mem_lower} and @samp{mem_upper} indicate the amount oflower and upper memory, respectively, in kilobytes. Lower memory startsat address 0, and upper memory starts at address 1 megabyte. The maximumpossible value for lower memory is 640 kilobytes. The value returned forupper memory is maximally the address of the first upper memory holeminus 1 megabyte. It is not guaranteed to be this value.If bit 1 in the @samp{flags} word is set, then the @samp{boot_device}field is valid, and indicates which @sc{bios} disk device the bootloader loaded the OS image from. If the OS image was not loaded from a@sc{bios} disk, then this field must not be present (bit 3 must beclear). The operating system may use this field as a hint fordetermining its own @dfn{root} device, but is not required to. The@samp{boot_device} field is laid out in four one-byte subfields asfollows:@example@group+-------+-------+-------+-------+| drive | part1 | part2 | part3 |+-------+-------+-------+-------+@end group@end exampleThe first byte contains the @sc{bios} drive number as understood by the@sc{bios} INT 0x13 low-level disk interface: e.g. 0x00 for the firstfloppy disk or 0x80 for the first hard disk.The three remaining bytes specify the boot partition. @samp{part1}specifies the @dfn{top-level} partition number, @samp{part2} specifies a@dfn{sub-partition} in the top-level partition, etc. Partition numbersalways start from zero. Unused partition bytes must be set to 0xFF. Forexample, if the disk is partitioned using a simple one-level DOSpartitioning scheme, then @samp{part1} contains the DOS partitionnumber, and @samp{part2} and @samp{part3} are both 0xFF. As anotherexample, if a disk is partitioned first into DOS partitions, and thenone of those DOS partitions is subdivided into several BSD partitionsusing BSD's @dfn{disklabel} strategy, then @samp{part1} contains the DOSpartition number, @samp{part2} contains the BSD sub-partition withinthat DOS partition, and @samp{part3} is 0xFF.DOS extended partitions are indicated as partition numbers starting from4 and increasing, rather than as nested sub-partitions, even though theunderlying disk layout of extended partitions is hierarchical innature. For example, if the boot loader boots from the second extendedpartition on a disk partitioned in conventional DOS style, then@samp{part1} will be 5, and @samp{part2} and @samp{part3} will both be0xFF.If bit 2 of the @samp{flags} longword is set, the @samp{cmdline} fieldis valid, and contains the physical address of the command line tobe passed to the kernel. The command line is a normal C-stylezero-terminated string.If bit 3 of the @samp{flags} is set, then the @samp{mods} fieldsindicate to the kernel what boot modules were loaded along with thekernel image, and where they can be found. @samp{mods_count} containsthe number of modules loaded; @samp{mods_addr} contains the physicaladdress of the first module structure. @samp{mods_count} may be zero,indicating no boot modules were loaded, even if bit 1 of @samp{flags} isset. Each module structure is formatted as follows:@example@group        +-------------------+0       | mod_start         |4       | mod_end           |        +-------------------+8       | string            |        +-------------------+12      | reserved (0)      |        +-------------------+@end group@end exampleThe first two fields contain the start and end addresses of the bootmodule itself. The @samp{string} field provides an arbitrary string tobe associated with that particular boot module; it is a zero-terminatedASCII string, just like the kernel command line. The @samp{string} fieldmay be 0 if there is no string associated with the module. Typically thestring might be a command line (e.g. if the operating system treats bootmodules as executable programs), or a pathname (e.g. if the operatingsystem treats boot modules as files in a file system), but its exact useis specific to the operating system. The @samp{reserved} field must beset to 0 by the boot loader and ignored by the operating system.@strong{Caution:} Bits 4 & 5 are mutually exclusive.If bit 4 in the @samp{flags} word is set, then the following fields inthe Multiboot information structure starting at byte 28 are valid:@example@group        +-------------------+28      | tabsize           |32      | strsize           |36      | addr              |40      | reserved (0)      |        +-------------------+@end group@end exampleThese indicate where the symbol table from an a.out kernel image can befound. @samp{addr} is the physical address of the size (4-byte unsignedlong) of an array of a.out format @dfn{nlist} structures, followedimmediately by the array itself, then the size (4-byte unsigned long) ofa set of zero-terminated @sc{ascii} strings (plus sizeof(unsigned long) inthis case), and finally the set of strings itself. @samp{tabsize} isequal to its size parameter (found at the beginning of the symbolsection), and @samp{strsize} is equal to its size parameter (found atthe beginning of the string section) of the following string table towhich the symbol table refers. Note that @samp{tabsize} may be 0,indicating no symbols, even if bit 4 in the @samp{flags} word is set.If bit 5 in the @samp{flags} word is set, then the following fields inthe Multiboot information structure starting at byte 28 are valid:@example@group        +-------------------+28      | num               |32      | size              |36      | addr              |40      | shndx             |        +-------------------+@end group@end exampleThese indicate where the section header table from an ELF kernel is, thesize of each entry, number of entries, and the string table used as theindex of names. They correspond to the @samp{shdr_*} entries(@samp{shdr_num}, etc.) in the Executable and Linkable Format (@sc{elf})specification in the program header. All sections are loaded, and thephysical address fields of the @sc{elf} section header then refer to wherethe sections are in memory (refer to the i386 @sc{elf} documentation fordetails as to how to read the section header(s)). Note that@samp{shdr_num} may be 0, indicating no symbols, even if bit 5 in the@samp{flags} word is set.If bit 6 in the @samp{flags} word is set, then the @samp{mmap_*} fieldsare valid, and indicate the address and length of a buffer containing amemory map of the machine provided by the @sc{bios}. @samp{mmap_addr} isthe address, and @samp{mmap_length} is the total size of the buffer. Thebuffer consists of one or more of the following size/structure pairs(@samp{size} is really used for skipping to the next pair):@example@group        +-------------------+-4      | size              |        +-------------------+0       | base_addr_low     |4       | base_addr_high    |8       | length_low        |12      | length_high       |16      | type              |        +-------------------+@end group@end examplewhere @samp{size} is the size of the associated structure in bytes, whichcan be greater than the minimum of 20 bytes. @samp{base_addr_low} is thelower 32 bits of the starting address, and @samp{base_addr_high} is theupper 32 bits, for a total of a 64-bit starting address. @samp{length_low}is the lower 32 bits of the size of the memory region in bytes, and@samp{length_high} is the upper 32 bits, for a total of a 64-bitlength. @samp{type} is the variety of address range represented, where avalue of 1 indicates available @sc{ram}, and all other values currentlyindicated a reserved area.The map provided is guaranteed to list all standard @sc{ram} that shouldbe available for normal use.If bit 7 in the @samp{flags} is set, then the @samp{drives_*} fieldsare valid, and indicate the address of the physical address of the firstdrive structure and the size of drive structures. @samp{drives_addr}is the address, and @samp{drives_length} is the total size of drivestructures. Note that @samp{drives_length} may be zero. Each drivestructure is formatted as follows:@example@group        +-------------------+0       | size              |        +-------------------+4       | drive_number      |        +-------------------+5       | drive_mode        |        +-------------------+6       | drive_cylinders   |8       | drive_heads       |9       | drive_sectors     |        +-------------------+10 - xx | drive_ports       |        +-------------------+@end group@end exampleThe @samp{size} field specifies the size of this structure. The sizevaries, depending on the number of ports. Note that the size may not beequal to (10 + 2 * the number of ports), because of an alignment.The @samp{drive_number} field contains the BIOS drive number. The@samp{drive_mode} field represents the access mode used by the bootloader. Currently, the following modes are defined:@table @samp@item 0CHS mode (traditional cylinder/head/sector addressing mode).@item 1LBA mode (Logical Block Addressing mode).@end tableThe three fields, @samp{drive_cylinders}, @samp{drive_heads} and@samp{drive_sectors}, indicate the geometry of the drive detected by the@sc{bios}. @samp{drive_cylinders} contains the number of thecylinders. @samp{drive_heads} contains the number of theheads. @samp{drive_sectors} contains the number of the sectors pertrack.The @samp{drive_ports} field contains the array of the I/O ports usedfor the drive in the @sc{bios} code. The array consists of zero or moreunsigned two-bytes integers, and is terminated with zero. Note that thearray may contain any number of I/O ports that are not related to thedrive actually (such as @sc{dma} controller's ports).If bit 8 in the @samp{flags} is set, then the @samp{config_table} fieldis valid, and indicates the address of the @sc{rom} configuration tablereturned by the @dfn{GET CONFIGURATION} @sc{bios} call. If the @sc{bios}call fails, then the size of the table must be @emph{zero}.If bit 9 in the @samp{flags} is set, the @samp{boot_loader_name} fieldis valid, and contains the physical address of the name of a bootloader booting the kernel. The name is a normal C-style zero-terminatedstring.If bit 10 in the @samp{flags} is set, the @samp{apm_table} field isvalid, and contains the physical address of an @sc{apm} table defined asbelow:@example@group        +----------------------+0       | version              |2       | cseg                 |4       | offset               |8       | cseg_16              |10      | dseg                 |12      | flags                |14      | cseg_len             |16      | cseg_16_len          |18      | dseg_len             |        +----------------------+@end group@end exampleThe fields @samp{version}, @samp{cseg}, @samp{offset}, @samp{cseg_16},@samp{dseg}, @samp{flags}, @samp{cseg_len}, @samp{cseg_16_len},@samp{dseg_len} indicate the version number, the protected mode 32-bitcode segment, the offset of the entry point, the protected mode 16-bitcode segment, the protected mode 16-bit data segment, the flags, thelength of the protected mode 32-bit code segment, the length of theprotected mode 16-bit code segment, and the length of the protected mode16-bit data segment, respectively. Only the field @samp{offset} is 4bytes, and the others are 2 bytes. See@uref{http://www.microsoft.com/hwdev/busbios/amp_12.htm, Advanced Power

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -