1*1b8adde7SWilliam KucharskiThis is ../../docs/multiboot.info, produced by makeinfo version 4.7
2*1b8adde7SWilliam Kucharskifrom ../../docs/multiboot.texi.
37c478bd9Sstevel@tonic-gate
47c478bd9Sstevel@tonic-gateINFO-DIR-SECTION Kernel
57c478bd9Sstevel@tonic-gateSTART-INFO-DIR-ENTRY
67c478bd9Sstevel@tonic-gate* Multiboot Specification: (multiboot).		Multiboot Specification.
77c478bd9Sstevel@tonic-gateEND-INFO-DIR-ENTRY
87c478bd9Sstevel@tonic-gate
97c478bd9Sstevel@tonic-gate   Copyright (C) 1995, 96 Bryan Ford <baford@cs.utah.edu> Copyright (C)
107c478bd9Sstevel@tonic-gate1995, 96 Erich Stefan Boleyn <erich@uruk.org> Copyright (C) 1999, 2000,
117c478bd9Sstevel@tonic-gate2001, 2002 Free Software Foundation, Inc.
127c478bd9Sstevel@tonic-gate
137c478bd9Sstevel@tonic-gate   Permission is granted to make and distribute verbatim copies of this
147c478bd9Sstevel@tonic-gatemanual provided the copyright notice and this permission notice are
157c478bd9Sstevel@tonic-gatepreserved on all copies.
167c478bd9Sstevel@tonic-gate
177c478bd9Sstevel@tonic-gate   Permission is granted to copy and distribute modified versions of
187c478bd9Sstevel@tonic-gatethis manual under the conditions for verbatim copying, provided also
197c478bd9Sstevel@tonic-gatethat the entire resulting derived work is distributed under the terms
207c478bd9Sstevel@tonic-gateof a permission notice identical to this one.
217c478bd9Sstevel@tonic-gate
227c478bd9Sstevel@tonic-gate   Permission is granted to copy and distribute translations of this
237c478bd9Sstevel@tonic-gatemanual into another language, under the above conditions for modified
247c478bd9Sstevel@tonic-gateversions.
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Top,  Next: Overview,  Up: (dir)
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gateMultiboot Specification
307c478bd9Sstevel@tonic-gate***********************
317c478bd9Sstevel@tonic-gate
32*1b8adde7SWilliam KucharskiThis file documents Multiboot Specification, the proposal for the boot
33*1b8adde7SWilliam Kucharskisequence standard. This edition documents version 0.6.93.
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate* Menu:
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gate* Overview::
387c478bd9Sstevel@tonic-gate* Terminology::
397c478bd9Sstevel@tonic-gate* Specification::
407c478bd9Sstevel@tonic-gate* Examples::
417c478bd9Sstevel@tonic-gate* History::
427c478bd9Sstevel@tonic-gate* Index::
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Overview,  Next: Terminology,  Prev: Top,  Up: Top
467c478bd9Sstevel@tonic-gate
47*1b8adde7SWilliam Kucharski1 Introduction to Multiboot Specification
48*1b8adde7SWilliam Kucharski*****************************************
497c478bd9Sstevel@tonic-gate
50*1b8adde7SWilliam KucharskiThis chapter describes some rough information on the Multiboot
517c478bd9Sstevel@tonic-gateSpecification. Note that this is not a part of the specification itself.
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate* Menu:
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate* Motivation::
567c478bd9Sstevel@tonic-gate* Architecture::
577c478bd9Sstevel@tonic-gate* Operating systems::
587c478bd9Sstevel@tonic-gate* Boot sources::
597c478bd9Sstevel@tonic-gate* Boot-time configuration::
607c478bd9Sstevel@tonic-gate* Convenience to operating systems::
617c478bd9Sstevel@tonic-gate* Boot modules::
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Motivation,  Next: Architecture,  Up: Overview
657c478bd9Sstevel@tonic-gate
66*1b8adde7SWilliam Kucharski1.1 The background of Multiboot Specification
67*1b8adde7SWilliam Kucharski=============================================
687c478bd9Sstevel@tonic-gate
69*1b8adde7SWilliam KucharskiEvery operating system ever created tends to have its own boot loader.
70*1b8adde7SWilliam KucharskiInstalling a new operating system on a machine generally involves
71*1b8adde7SWilliam Kucharskiinstalling a whole new set of boot mechanisms, each with completely
72*1b8adde7SWilliam Kucharskidifferent install-time and boot-time user interfaces. Getting multiple
73*1b8adde7SWilliam Kucharskioperating systems to coexist reliably on one machine through typical
74*1b8adde7SWilliam Kucharski"chaining" mechanisms can be a nightmare. There is little or no choice
75*1b8adde7SWilliam Kucharskiof boot loaders for a particular operating system -- if the one that
76*1b8adde7SWilliam Kucharskicomes with the operating system doesn't do exactly what you want, or
77*1b8adde7SWilliam Kucharskidoesn't work on your machine, you're screwed.
787c478bd9Sstevel@tonic-gate
797c478bd9Sstevel@tonic-gate   While we may not be able to fix this problem in existing commercial
807c478bd9Sstevel@tonic-gateoperating systems, it shouldn't be too difficult for a few people in the
817c478bd9Sstevel@tonic-gatefree operating system communities to put their heads together and solve
827c478bd9Sstevel@tonic-gatethis problem for the popular free operating systems. That's what this
837c478bd9Sstevel@tonic-gatespecification aims for. Basically, it specifies an interface between a
847c478bd9Sstevel@tonic-gateboot loader and a operating system, such that any complying boot loader
857c478bd9Sstevel@tonic-gateshould be able to load any complying operating system. This
867c478bd9Sstevel@tonic-gatespecification does _not_ specify how boot loaders should work -- only
877c478bd9Sstevel@tonic-gatehow they must interface with the operating system being loaded.
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate
907c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Architecture,  Next: Operating systems,  Prev: Motivation,  Up: Overview
917c478bd9Sstevel@tonic-gate
92*1b8adde7SWilliam Kucharski1.2 The target architecture
93*1b8adde7SWilliam Kucharski===========================
947c478bd9Sstevel@tonic-gate
95*1b8adde7SWilliam KucharskiThis specification is primarily targeted at PC, since they are the most
96*1b8adde7SWilliam Kucharskicommon and have the largest variety of operating systems and boot
977c478bd9Sstevel@tonic-gateloaders. However, to the extent that certain other architectures may
987c478bd9Sstevel@tonic-gateneed a boot specification and do not have one already, a variation of
997c478bd9Sstevel@tonic-gatethis specification, stripped of the x86-specific details, could be
1007c478bd9Sstevel@tonic-gateadopted for them as well.
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Operating systems,  Next: Boot sources,  Prev: Architecture,  Up: Overview
1047c478bd9Sstevel@tonic-gate
105*1b8adde7SWilliam Kucharski1.3 The target operating systems
106*1b8adde7SWilliam Kucharski================================
1077c478bd9Sstevel@tonic-gate
108*1b8adde7SWilliam KucharskiThis specification is targeted toward free 32-bit operating systems
1097c478bd9Sstevel@tonic-gatethat can be fairly easily modified to support the specification without
1107c478bd9Sstevel@tonic-gategoing through lots of bureaucratic rigmarole. The particular free
1117c478bd9Sstevel@tonic-gateoperating systems that this specification is being primarily designed
1127c478bd9Sstevel@tonic-gatefor are Linux, FreeBSD, NetBSD, Mach, and VSTa. It is hoped that other
1137c478bd9Sstevel@tonic-gateemerging free operating systems will adopt it from the start, and thus
1147c478bd9Sstevel@tonic-gateimmediately be able to take advantage of existing boot loaders. It would
1157c478bd9Sstevel@tonic-gatebe nice if commercial operating system vendors eventually adopted this
1167c478bd9Sstevel@tonic-gatespecification as well, but that's probably a pipe dream.
1177c478bd9Sstevel@tonic-gate
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Boot sources,  Next: Boot-time configuration,  Prev: Operating systems,  Up: Overview
1207c478bd9Sstevel@tonic-gate
121*1b8adde7SWilliam Kucharski1.4 Boot sources
122*1b8adde7SWilliam Kucharski================
1237c478bd9Sstevel@tonic-gate
124*1b8adde7SWilliam KucharskiIt should be possible to write compliant boot loaders that load the OS
125*1b8adde7SWilliam Kucharskiimage from a variety of sources, including floppy disk, hard disk, and
126*1b8adde7SWilliam Kucharskiacross a network.
1277c478bd9Sstevel@tonic-gate
1287c478bd9Sstevel@tonic-gate   Disk-based boot loaders may use a variety of techniques to find the
1297c478bd9Sstevel@tonic-gaterelevant OS image and boot module data on disk, such as by
1307c478bd9Sstevel@tonic-gateinterpretation of specific file systems (e.g. the BSD/Mach boot loader),
1317c478bd9Sstevel@tonic-gateusing precalculated "block lists" (e.g. LILO), loading from a special
1327c478bd9Sstevel@tonic-gate"boot partition" (e.g. OS/2), or even loading from within another
1337c478bd9Sstevel@tonic-gateoperating system (e.g. the VSTa boot code, which loads from DOS).
1347c478bd9Sstevel@tonic-gateSimilarly, network-based boot loaders could use a variety of network
1357c478bd9Sstevel@tonic-gatehardware and protocols.
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gate   It is hoped that boot loaders will be created that support multiple
1387c478bd9Sstevel@tonic-gateloading mechanisms, increasing their portability, robustness, and
1397c478bd9Sstevel@tonic-gateuser-friendliness.
1407c478bd9Sstevel@tonic-gate
1417c478bd9Sstevel@tonic-gate
1427c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Boot-time configuration,  Next: Convenience to operating systems,  Prev: Boot sources,  Up: Overview
1437c478bd9Sstevel@tonic-gate
144*1b8adde7SWilliam Kucharski1.5 Configure an operating system at boot-time
145*1b8adde7SWilliam Kucharski==============================================
1467c478bd9Sstevel@tonic-gate
147*1b8adde7SWilliam KucharskiIt is often necessary for one reason or another for the user to be able
148*1b8adde7SWilliam Kucharskito provide some configuration information to an operating system
1497c478bd9Sstevel@tonic-gatedynamically at boot time. While this specification should not dictate
1507c478bd9Sstevel@tonic-gatehow this configuration information is obtained by the boot loader, it
1517c478bd9Sstevel@tonic-gateshould provide a standard means for the boot loader to pass such
1527c478bd9Sstevel@tonic-gateinformation to the operating system.
1537c478bd9Sstevel@tonic-gate
1547c478bd9Sstevel@tonic-gate
1557c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Convenience to operating systems,  Next: Boot modules,  Prev: Boot-time configuration,  Up: Overview
1567c478bd9Sstevel@tonic-gate
157*1b8adde7SWilliam Kucharski1.6 How to make OS development easier
158*1b8adde7SWilliam Kucharski=====================================
1597c478bd9Sstevel@tonic-gate
160*1b8adde7SWilliam KucharskiOS images should be easy to generate. Ideally, an OS image should simply
161*1b8adde7SWilliam Kucharskibe an ordinary 32-bit executable file in whatever file format the
1627c478bd9Sstevel@tonic-gateoperating system normally uses. It should be possible to `nm' or
1637c478bd9Sstevel@tonic-gatedisassemble OS images just like normal executables. Specialized tools
1647c478bd9Sstevel@tonic-gateshould not be required to create OS images in a _special_ file format.
1657c478bd9Sstevel@tonic-gateIf this means shifting some work from the operating system to a boot
1667c478bd9Sstevel@tonic-gateloader, that is probably appropriate, because all the memory consumed
1677c478bd9Sstevel@tonic-gateby the boot loader will typically be made available again after the
1687c478bd9Sstevel@tonic-gateboot process is created, whereas every bit of code in the OS image
1697c478bd9Sstevel@tonic-gatetypically has to remain in memory forever. The operating system should
1707c478bd9Sstevel@tonic-gatenot have to worry about getting into 32-bit mode initially, because mode
1717c478bd9Sstevel@tonic-gateswitching code generally needs to be in the boot loader anyway in order
1727c478bd9Sstevel@tonic-gateto load operating system data above the 1MB boundary, and forcing the
1737c478bd9Sstevel@tonic-gateoperating system to do this makes creation of OS images much more
1747c478bd9Sstevel@tonic-gatedifficult.
1757c478bd9Sstevel@tonic-gate
1767c478bd9Sstevel@tonic-gate   Unfortunately, there is a horrendous variety of executable file
1777c478bd9Sstevel@tonic-gateformats even among free Unix-like PC-based operating systems --
1787c478bd9Sstevel@tonic-gategenerally a different format for each operating system. Most of the
1797c478bd9Sstevel@tonic-gaterelevant free operating systems use some variant of a.out format, but
1807c478bd9Sstevel@tonic-gatesome are moving to ELF. It is highly desirable for boot loaders not to
1817c478bd9Sstevel@tonic-gatehave to be able to interpret all the different types of executable file
1827c478bd9Sstevel@tonic-gateformats in existence in order to load the OS image -- otherwise the
1837c478bd9Sstevel@tonic-gateboot loader effectively becomes operating system specific again.
1847c478bd9Sstevel@tonic-gate
1857c478bd9Sstevel@tonic-gate   This specification adopts a compromise solution to this problem.
1867c478bd9Sstevel@tonic-gateMultiboot-compliant OS images always contain a magic "Multiboot header"
1877c478bd9Sstevel@tonic-gate(*note OS image format::), which allows the boot loader to load the
1887c478bd9Sstevel@tonic-gateimage without having to understand numerous a.out variants or other
1897c478bd9Sstevel@tonic-gateexecutable formats. This magic header does not need to be at the very
1907c478bd9Sstevel@tonic-gatebeginning of the executable file, so kernel images can still conform to
1917c478bd9Sstevel@tonic-gatethe local a.out format variant in addition to being Multiboot-compliant.
1927c478bd9Sstevel@tonic-gate
1937c478bd9Sstevel@tonic-gate
1947c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Boot modules,  Prev: Convenience to operating systems,  Up: Overview
1957c478bd9Sstevel@tonic-gate
196*1b8adde7SWilliam Kucharski1.7 Boot modules
197*1b8adde7SWilliam Kucharski================
1987c478bd9Sstevel@tonic-gate
199*1b8adde7SWilliam KucharskiMany modern operating system kernels, such as those of VSTa and Mach, do
200*1b8adde7SWilliam Kucharskinot by themselves contain enough mechanism to get the system fully
201*1b8adde7SWilliam Kucharskioperational: they require the presence of additional software modules at
202*1b8adde7SWilliam Kucharskiboot time in order to access devices, mount file systems, etc. While
203*1b8adde7SWilliam Kucharskithese additional modules could be embedded in the main OS image along
204*1b8adde7SWilliam Kucharskiwith the kernel itself, and the resulting image be split apart manually
205*1b8adde7SWilliam Kucharskiby the operating system when it receives control, it is often more
206*1b8adde7SWilliam Kucharskiflexible, more space-efficient, and more convenient to the operating
207*1b8adde7SWilliam Kucharskisystem and user if the boot loader can load these additional modules
208*1b8adde7SWilliam Kucharskiindependently in the first place.
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate   Thus, this specification should provide a standard method for a boot
2117c478bd9Sstevel@tonic-gateloader to indicate to the operating system what auxiliary boot modules
2127c478bd9Sstevel@tonic-gatewere loaded, and where they can be found. Boot loaders don't have to
2137c478bd9Sstevel@tonic-gatesupport multiple boot modules, but they are strongly encouraged to,
2147c478bd9Sstevel@tonic-gatebecause some operating systems will be unable to boot without them.
2157c478bd9Sstevel@tonic-gate
2167c478bd9Sstevel@tonic-gate
2177c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Terminology,  Next: Specification,  Prev: Overview,  Up: Top
2187c478bd9Sstevel@tonic-gate
219*1b8adde7SWilliam Kucharski2 The definitions of terms used through the specification
220*1b8adde7SWilliam Kucharski*********************************************************
2217c478bd9Sstevel@tonic-gate
2227c478bd9Sstevel@tonic-gate"must"
2237c478bd9Sstevel@tonic-gate     We use the term "must", when any boot loader or OS image needs to
2247c478bd9Sstevel@tonic-gate     follow a rule -- otherwise, the boot loader or OS image is _not_
2257c478bd9Sstevel@tonic-gate     Multiboot-compliant.
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gate"should"
2287c478bd9Sstevel@tonic-gate     We use the term "should", when any boot loader or OS image is
2297c478bd9Sstevel@tonic-gate     recommended to follow a rule, but it doesn't need to follow the
2307c478bd9Sstevel@tonic-gate     rule.
2317c478bd9Sstevel@tonic-gate
2327c478bd9Sstevel@tonic-gate"may"
2337c478bd9Sstevel@tonic-gate     We use the term "may", when any boot loader or OS image is allowed
2347c478bd9Sstevel@tonic-gate     to follow a rule.
2357c478bd9Sstevel@tonic-gate
2367c478bd9Sstevel@tonic-gate"boot loader"
2377c478bd9Sstevel@tonic-gate     Whatever program or set of programs loads the image of the final
2387c478bd9Sstevel@tonic-gate     operating system to be run on the machine. The boot loader may
2397c478bd9Sstevel@tonic-gate     itself consist of several stages, but that is an implementation
2407c478bd9Sstevel@tonic-gate     detail not relevant to this specification. Only the _final_ stage
2417c478bd9Sstevel@tonic-gate     of the boot loader -- the stage that eventually transfers control
2427c478bd9Sstevel@tonic-gate     to an operating system -- must follow the rules specified in this
2437c478bd9Sstevel@tonic-gate     document in order to be "Multiboot-compliant"; earlier boot loader
2447c478bd9Sstevel@tonic-gate     stages may be designed in whatever way is most convenient.
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate"OS image"
2477c478bd9Sstevel@tonic-gate     The initial binary image that a boot loader loads into memory and
2487c478bd9Sstevel@tonic-gate     transfers control to start an operating system. The OS image is
2497c478bd9Sstevel@tonic-gate     typically an executable containing the operating system kernel.
2507c478bd9Sstevel@tonic-gate
2517c478bd9Sstevel@tonic-gate"boot module"
2527c478bd9Sstevel@tonic-gate     Other auxiliary files that a boot loader loads into memory along
2537c478bd9Sstevel@tonic-gate     with an OS image, but does not interpret in any way other than
2547c478bd9Sstevel@tonic-gate     passing their locations to the operating system when it is invoked.
2557c478bd9Sstevel@tonic-gate
2567c478bd9Sstevel@tonic-gate"Multiboot-compliant"
2577c478bd9Sstevel@tonic-gate     A boot loader or an OS image which follows the rules defined as
2587c478bd9Sstevel@tonic-gate     "must" is Multiboot-compliant. When this specification specifies a
2597c478bd9Sstevel@tonic-gate     rule as "should" or "may", a Multiboot-complaint boot loader/OS
2607c478bd9Sstevel@tonic-gate     image doesn't need to follow the rule.
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gate"u8"
2637c478bd9Sstevel@tonic-gate     The type of unsigned 8-bit data.
2647c478bd9Sstevel@tonic-gate
2657c478bd9Sstevel@tonic-gate"u16"
2667c478bd9Sstevel@tonic-gate     The type of unsigned 16-bit data. Because the target architecture
2677c478bd9Sstevel@tonic-gate     is little-endian, u16 is coded in little-endian.
2687c478bd9Sstevel@tonic-gate
2697c478bd9Sstevel@tonic-gate"u32"
2707c478bd9Sstevel@tonic-gate     The type of unsigned 32-bit data. Because the target architecture
2717c478bd9Sstevel@tonic-gate     is little-endian, u32 is coded in little-endian.
2727c478bd9Sstevel@tonic-gate
2737c478bd9Sstevel@tonic-gate"u64"
2747c478bd9Sstevel@tonic-gate     The type of unsigned 64-bit data. Because the target architecture
2757c478bd9Sstevel@tonic-gate     is little-endian, u64 is coded in little-endian.
2767c478bd9Sstevel@tonic-gate
2777c478bd9Sstevel@tonic-gate
2787c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Specification,  Next: Examples,  Prev: Terminology,  Up: Top
2797c478bd9Sstevel@tonic-gate
280*1b8adde7SWilliam Kucharski3 The exact definitions of Multiboot Specification
281*1b8adde7SWilliam Kucharski**************************************************
2827c478bd9Sstevel@tonic-gate
283*1b8adde7SWilliam KucharskiThere are three main aspects of a boot loader/OS image interface:
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate  1. The format of an OS image as seen by a boot loader.
2867c478bd9Sstevel@tonic-gate
2877c478bd9Sstevel@tonic-gate  2. The state of a machine when a boot loader starts an operating
2887c478bd9Sstevel@tonic-gate     system.
2897c478bd9Sstevel@tonic-gate
2907c478bd9Sstevel@tonic-gate  3. The format of information passed by a boot loader to an operating
2917c478bd9Sstevel@tonic-gate     system.
2927c478bd9Sstevel@tonic-gate
2937c478bd9Sstevel@tonic-gate* Menu:
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gate* OS image format::
2967c478bd9Sstevel@tonic-gate* Machine state::
2977c478bd9Sstevel@tonic-gate* Boot information format::
2987c478bd9Sstevel@tonic-gate
2997c478bd9Sstevel@tonic-gate
3007c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: OS image format,  Next: Machine state,  Up: Specification
3017c478bd9Sstevel@tonic-gate
302*1b8adde7SWilliam Kucharski3.1 OS image format
303*1b8adde7SWilliam Kucharski===================
3047c478bd9Sstevel@tonic-gate
305*1b8adde7SWilliam KucharskiAn OS image may be an ordinary 32-bit executable file in the standard
3067c478bd9Sstevel@tonic-gateformat for that particular operating system, except that it may be
3077c478bd9Sstevel@tonic-gatelinked at a non-default load address to avoid loading on top of the
3087c478bd9Sstevel@tonic-gatePC's I/O region or other reserved areas, and of course it should not
3097c478bd9Sstevel@tonic-gateuse shared libraries or other fancy features.
3107c478bd9Sstevel@tonic-gate
3117c478bd9Sstevel@tonic-gate   An OS image must contain an additional header called "Multiboot
3127c478bd9Sstevel@tonic-gateheader", besides the headers of the format used by the OS image. The
3137c478bd9Sstevel@tonic-gateMultiboot header must be contained completely within the first 8192
3147c478bd9Sstevel@tonic-gatebytes of the OS image, and must be longword (32-bit) aligned. In
3157c478bd9Sstevel@tonic-gategeneral, it should come _as early as possible_, and may be embedded in
3167c478bd9Sstevel@tonic-gatethe beginning of the text segment after the _real_ executable header.
3177c478bd9Sstevel@tonic-gate
3187c478bd9Sstevel@tonic-gate* Menu:
3197c478bd9Sstevel@tonic-gate
3207c478bd9Sstevel@tonic-gate* Header layout::               The layout of Multiboot header
3217c478bd9Sstevel@tonic-gate* Header magic fields::         The magic fields of Multiboot header
3227c478bd9Sstevel@tonic-gate* Header address fields::
3237c478bd9Sstevel@tonic-gate* Header graphics fields::
3247c478bd9Sstevel@tonic-gate
3257c478bd9Sstevel@tonic-gate
3267c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Header layout,  Next: Header magic fields,  Up: OS image format
3277c478bd9Sstevel@tonic-gate
328*1b8adde7SWilliam Kucharski3.1.1 The layout of Multiboot header
329*1b8adde7SWilliam Kucharski------------------------------------
3307c478bd9Sstevel@tonic-gate
331*1b8adde7SWilliam KucharskiThe layout of the Multiboot header must be as follows:
3327c478bd9Sstevel@tonic-gate
3337c478bd9Sstevel@tonic-gateOffset  Type    Field Name     Note
3347c478bd9Sstevel@tonic-gate0       u32     magic          required
3357c478bd9Sstevel@tonic-gate4       u32     flags          required
3367c478bd9Sstevel@tonic-gate8       u32     checksum       required
3377c478bd9Sstevel@tonic-gate12      u32     header_addr    if flags[16] is set
3387c478bd9Sstevel@tonic-gate16      u32     load_addr      if flags[16] is set
3397c478bd9Sstevel@tonic-gate20      u32     load_end_addr  if flags[16] is set
3407c478bd9Sstevel@tonic-gate24      u32     bss_end_addr   if flags[16] is set
3417c478bd9Sstevel@tonic-gate28      u32     entry_addr     if flags[16] is set
3427c478bd9Sstevel@tonic-gate32      u32     mode_type      if flags[2] is set
3437c478bd9Sstevel@tonic-gate36      u32     width          if flags[2] is set
3447c478bd9Sstevel@tonic-gate40      u32     height         if flags[2] is set
3457c478bd9Sstevel@tonic-gate44      u32     depth          if flags[2] is set
3467c478bd9Sstevel@tonic-gate
3477c478bd9Sstevel@tonic-gate   The fields `magic', `flags' and `checksum' are defined in *Note
3487c478bd9Sstevel@tonic-gateHeader magic fields::, the fields `header_addr', `load_addr',
3497c478bd9Sstevel@tonic-gate`load_end_addr', `bss_end_addr' and `entry_addr' are defined in *Note
3507c478bd9Sstevel@tonic-gateHeader address fields::, and the fields `mode_type', `width', `height'
3517c478bd9Sstevel@tonic-gateand `depth' are defind in *Note Header graphics fields::.
3527c478bd9Sstevel@tonic-gate
3537c478bd9Sstevel@tonic-gate
3547c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Header magic fields,  Next: Header address fields,  Prev: Header layout,  Up: OS image format
3557c478bd9Sstevel@tonic-gate
356*1b8adde7SWilliam Kucharski3.1.2 The magic fields of Multiboot header
357*1b8adde7SWilliam Kucharski------------------------------------------
3587c478bd9Sstevel@tonic-gate
3597c478bd9Sstevel@tonic-gate`magic'
3607c478bd9Sstevel@tonic-gate     The field `magic' is the magic number identifying the header,
3617c478bd9Sstevel@tonic-gate     which must be the hexadecimal value `0x1BADB002'.
3627c478bd9Sstevel@tonic-gate
3637c478bd9Sstevel@tonic-gate`flags'
3647c478bd9Sstevel@tonic-gate     The field `flags' specifies features that the OS image requests or
3657c478bd9Sstevel@tonic-gate     requires of an boot loader. Bits 0-15 indicate requirements; if the
3667c478bd9Sstevel@tonic-gate     boot loader sees any of these bits set but doesn't understand the
3677c478bd9Sstevel@tonic-gate     flag or can't fulfill the requirements it indicates for some
3687c478bd9Sstevel@tonic-gate     reason, it must notify the user and fail to load the OS image.
3697c478bd9Sstevel@tonic-gate     Bits 16-31 indicate optional features; if any bits in this range
3707c478bd9Sstevel@tonic-gate     are set but the boot loader doesn't understand them, it may simply
3717c478bd9Sstevel@tonic-gate     ignore them and proceed as usual. Naturally, all as-yet-undefined
3727c478bd9Sstevel@tonic-gate     bits in the `flags' word must be set to zero in OS images. This
3737c478bd9Sstevel@tonic-gate     way, the `flags' fields serves for version control as well as
3747c478bd9Sstevel@tonic-gate     simple feature selection.
3757c478bd9Sstevel@tonic-gate
3767c478bd9Sstevel@tonic-gate     If bit 0 in the `flags' word is set, then all boot modules loaded
3777c478bd9Sstevel@tonic-gate     along with the operating system must be aligned on page (4KB)
3787c478bd9Sstevel@tonic-gate     boundaries. Some operating systems expect to be able to map the
3797c478bd9Sstevel@tonic-gate     pages containing boot modules directly into a paged address space
3807c478bd9Sstevel@tonic-gate     during startup, and thus need the boot modules to be page-aligned.
3817c478bd9Sstevel@tonic-gate
3827c478bd9Sstevel@tonic-gate     If bit 1 in the `flags' word is set, then information on available
3837c478bd9Sstevel@tonic-gate     memory via at least the `mem_*' fields of the Multiboot information
3847c478bd9Sstevel@tonic-gate     structure (*note Boot information format::) must be included. If
3857c478bd9Sstevel@tonic-gate     the boot loader is capable of passing a memory map (the `mmap_*'
3867c478bd9Sstevel@tonic-gate     fields) and one exists, then it may be included as well.
3877c478bd9Sstevel@tonic-gate
3887c478bd9Sstevel@tonic-gate     If bit 2 in the `flags' word is set, information about the video
3897c478bd9Sstevel@tonic-gate     mode table (*note Boot information format::) must be available to
3907c478bd9Sstevel@tonic-gate     the kernel.
3917c478bd9Sstevel@tonic-gate
3927c478bd9Sstevel@tonic-gate     If bit 16 in the `flags' word is set, then the fields at offsets
3937c478bd9Sstevel@tonic-gate     8-24 in the Multiboot header are valid, and the boot loader should
3947c478bd9Sstevel@tonic-gate     use them instead of the fields in the actual executable header to
3957c478bd9Sstevel@tonic-gate     calculate where to load the OS image. This information does not
3967c478bd9Sstevel@tonic-gate     need to be provided if the kernel image is in ELF format, but it
3977c478bd9Sstevel@tonic-gate     _must_ be provided if the images is in a.out format or in some
3987c478bd9Sstevel@tonic-gate     other format. Compliant boot loaders must be able to load images
3997c478bd9Sstevel@tonic-gate     that either are in ELF format or contain the load address
4007c478bd9Sstevel@tonic-gate     information embedded in the Multiboot header; they may also
4017c478bd9Sstevel@tonic-gate     directly support other executable formats, such as particular
4027c478bd9Sstevel@tonic-gate     a.out variants, but are not required to.
4037c478bd9Sstevel@tonic-gate
4047c478bd9Sstevel@tonic-gate`checksum'
4057c478bd9Sstevel@tonic-gate     The field `checksum' is a 32-bit unsigned value which, when added
4067c478bd9Sstevel@tonic-gate     to the other magic fields (i.e. `magic' and `flags'), must have a
4077c478bd9Sstevel@tonic-gate     32-bit unsigned sum of zero.
4087c478bd9Sstevel@tonic-gate
4097c478bd9Sstevel@tonic-gate
4107c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Header address fields,  Next: Header graphics fields,  Prev: Header magic fields,  Up: OS image format
4117c478bd9Sstevel@tonic-gate
412*1b8adde7SWilliam Kucharski3.1.3 The address fields of Multiboot header
413*1b8adde7SWilliam Kucharski--------------------------------------------
4147c478bd9Sstevel@tonic-gate
415*1b8adde7SWilliam KucharskiAll of the address fields enabled by flag bit 16 are physical addresses.
416*1b8adde7SWilliam KucharskiThe meaning of each is as follows:
4177c478bd9Sstevel@tonic-gate
4187c478bd9Sstevel@tonic-gate`header_addr'
4197c478bd9Sstevel@tonic-gate     Contains the address corresponding to the beginning of the
4207c478bd9Sstevel@tonic-gate     Multiboot header -- the physical memory location at which the
4217c478bd9Sstevel@tonic-gate     magic value is supposed to be loaded. This field serves to
4227c478bd9Sstevel@tonic-gate     "synchronize" the mapping between OS image offsets and physical
4237c478bd9Sstevel@tonic-gate     memory addresses.
4247c478bd9Sstevel@tonic-gate
4257c478bd9Sstevel@tonic-gate`load_addr'
4267c478bd9Sstevel@tonic-gate     Contains the physical address of the beginning of the text
4277c478bd9Sstevel@tonic-gate     segment. The offset in the OS image file at which to start loading
4287c478bd9Sstevel@tonic-gate     is defined by the offset at which the header was found, minus
4297c478bd9Sstevel@tonic-gate     (header_addr - load_addr). load_addr must be less than or equal to
4307c478bd9Sstevel@tonic-gate     header_addr.
4317c478bd9Sstevel@tonic-gate
4327c478bd9Sstevel@tonic-gate`load_end_addr'
4337c478bd9Sstevel@tonic-gate     Contains the physical address of the end of the data segment.
4347c478bd9Sstevel@tonic-gate     (load_end_addr - load_addr) specifies how much data to load.  This
4357c478bd9Sstevel@tonic-gate     implies that the text and data segments must be consecutive in the
4367c478bd9Sstevel@tonic-gate     OS image; this is true for existing a.out executable formats.  If
4377c478bd9Sstevel@tonic-gate     this field is zero, the boot loader assumes that the text and data
4387c478bd9Sstevel@tonic-gate     segments occupy the whole OS image file.
4397c478bd9Sstevel@tonic-gate
4407c478bd9Sstevel@tonic-gate`bss_end_addr'
4417c478bd9Sstevel@tonic-gate     Contains the physical address of the end of the bss segment. The
4427c478bd9Sstevel@tonic-gate     boot loader initializes this area to zero, and reserves the memory
4437c478bd9Sstevel@tonic-gate     it occupies to avoid placing boot modules and other data relevant
4447c478bd9Sstevel@tonic-gate     to the operating system in that area. If this field is zero, the
4457c478bd9Sstevel@tonic-gate     boot loader assumes that no bss segment is present.
4467c478bd9Sstevel@tonic-gate
4477c478bd9Sstevel@tonic-gate`entry_addr'
4487c478bd9Sstevel@tonic-gate     The physical address to which the boot loader should jump in order
4497c478bd9Sstevel@tonic-gate     to start running the operating system.
4507c478bd9Sstevel@tonic-gate
4517c478bd9Sstevel@tonic-gate
4527c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Header graphics fields,  Prev: Header address fields,  Up: OS image format
4537c478bd9Sstevel@tonic-gate
454*1b8adde7SWilliam Kucharski3.1.4 The graphics fields of Multiboot header
455*1b8adde7SWilliam Kucharski---------------------------------------------
4567c478bd9Sstevel@tonic-gate
457*1b8adde7SWilliam KucharskiAll of the graphics fields are enabled by flag bit 2. They specify the
458*1b8adde7SWilliam Kucharskipreferred graphics mode. Note that that is only a _recommended_ mode by
459*1b8adde7SWilliam Kucharskithe OS image. If the mode exists, the boot loader should set it, when
460*1b8adde7SWilliam Kucharskithe user doesn't specify a mode explicitly. Otherwise, the boot loader
461*1b8adde7SWilliam Kucharskishould fall back to a similar mode, if available.
4627c478bd9Sstevel@tonic-gate
4637c478bd9Sstevel@tonic-gate   The meaning of each is as follows:
4647c478bd9Sstevel@tonic-gate
4657c478bd9Sstevel@tonic-gate`mode_type'
4667c478bd9Sstevel@tonic-gate     Contains `0' for linear graphics mode or `1' for EGA-standard text
4677c478bd9Sstevel@tonic-gate     mode. Everything else is reserved for future expansion. Note that
4687c478bd9Sstevel@tonic-gate     the boot loader may set a text mode, even if this field contains
4697c478bd9Sstevel@tonic-gate     `0'.
4707c478bd9Sstevel@tonic-gate
4717c478bd9Sstevel@tonic-gate`width'
4727c478bd9Sstevel@tonic-gate     Contains the number of the columns. This is specified in pixels in
4737c478bd9Sstevel@tonic-gate     a graphics mode, and in characters in a text mode. The value zero
4747c478bd9Sstevel@tonic-gate     indicates that the OS image has no preference.
4757c478bd9Sstevel@tonic-gate
4767c478bd9Sstevel@tonic-gate`height'
4777c478bd9Sstevel@tonic-gate     Contains the number of the lines. This is specified in pixels in a
4787c478bd9Sstevel@tonic-gate     graphics mode, and in characters in a text mode. The value zero
4797c478bd9Sstevel@tonic-gate     indicates that the OS image has no preference.
4807c478bd9Sstevel@tonic-gate
4817c478bd9Sstevel@tonic-gate`depth'
4827c478bd9Sstevel@tonic-gate     Contains the number of bits per pixel in a graphics mode, and zero
4837c478bd9Sstevel@tonic-gate     in a text mode. The value zero indicates that the OS image has no
4847c478bd9Sstevel@tonic-gate     preference.
4857c478bd9Sstevel@tonic-gate
4867c478bd9Sstevel@tonic-gate
4877c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Machine state,  Next: Boot information format,  Prev: OS image format,  Up: Specification
4887c478bd9Sstevel@tonic-gate
489*1b8adde7SWilliam Kucharski3.2 Machine state
490*1b8adde7SWilliam Kucharski=================
4917c478bd9Sstevel@tonic-gate
492*1b8adde7SWilliam KucharskiWhen the boot loader invokes the 32-bit operating system, the machine
4937c478bd9Sstevel@tonic-gatemust have the following state:
4947c478bd9Sstevel@tonic-gate
4957c478bd9Sstevel@tonic-gate`EAX'
4967c478bd9Sstevel@tonic-gate     Must contain the magic value `0x2BADB002'; the presence of this
4977c478bd9Sstevel@tonic-gate     value indicates to the operating system that it was loaded by a
4987c478bd9Sstevel@tonic-gate     Multiboot-compliant boot loader (e.g. as opposed to another type of
4997c478bd9Sstevel@tonic-gate     boot loader that the operating system can also be loaded from).
5007c478bd9Sstevel@tonic-gate
5017c478bd9Sstevel@tonic-gate`EBX'
5027c478bd9Sstevel@tonic-gate     Must contain the 32-bit physical address of the Multiboot
5037c478bd9Sstevel@tonic-gate     information structure provided by the boot loader (*note Boot
5047c478bd9Sstevel@tonic-gate     information format::).
5057c478bd9Sstevel@tonic-gate
5067c478bd9Sstevel@tonic-gate`CS'
5077c478bd9Sstevel@tonic-gate     Must be a 32-bit read/execute code segment with an offset of `0'
5087c478bd9Sstevel@tonic-gate     and a limit of `0xFFFFFFFF'. The exact value is undefined.
5097c478bd9Sstevel@tonic-gate
5107c478bd9Sstevel@tonic-gate`DS'
5117c478bd9Sstevel@tonic-gate`ES'
5127c478bd9Sstevel@tonic-gate`FS'
5137c478bd9Sstevel@tonic-gate`GS'
5147c478bd9Sstevel@tonic-gate`SS'
5157c478bd9Sstevel@tonic-gate     Must be a 32-bit read/write data segment with an offset of `0' and
5167c478bd9Sstevel@tonic-gate     a limit of `0xFFFFFFFF'. The exact values are all undefined.
5177c478bd9Sstevel@tonic-gate
5187c478bd9Sstevel@tonic-gate`A20 gate'
5197c478bd9Sstevel@tonic-gate     Must be enabled.
5207c478bd9Sstevel@tonic-gate
5217c478bd9Sstevel@tonic-gate`CR0'
5227c478bd9Sstevel@tonic-gate     Bit 31 (PG) must be cleared. Bit 0 (PE) must be set. Other bits are
5237c478bd9Sstevel@tonic-gate     all undefined.
5247c478bd9Sstevel@tonic-gate
5257c478bd9Sstevel@tonic-gate`EFLAGS'
5267c478bd9Sstevel@tonic-gate     Bit 17 (VM) must be cleared. Bit 9 (IF) must be cleared. Other bits
5277c478bd9Sstevel@tonic-gate     are all undefined.
5287c478bd9Sstevel@tonic-gate
5297c478bd9Sstevel@tonic-gate   All other processor registers and flag bits are undefined. This
5307c478bd9Sstevel@tonic-gateincludes, in particular:
5317c478bd9Sstevel@tonic-gate
5327c478bd9Sstevel@tonic-gate`ESP'
5337c478bd9Sstevel@tonic-gate     The OS image must create its own stack as soon as it needs one.
5347c478bd9Sstevel@tonic-gate
5357c478bd9Sstevel@tonic-gate`GDTR'
5367c478bd9Sstevel@tonic-gate     Even though the segment registers are set up as described above,
5377c478bd9Sstevel@tonic-gate     the `GDTR' may be invalid, so the OS image must not load any
5387c478bd9Sstevel@tonic-gate     segment registers (even just reloading the same values!) until it
5397c478bd9Sstevel@tonic-gate     sets up its own `GDT'.
5407c478bd9Sstevel@tonic-gate
5417c478bd9Sstevel@tonic-gate`IDTR'
5427c478bd9Sstevel@tonic-gate     The OS image must leave interrupts disabled until it sets up its
5437c478bd9Sstevel@tonic-gate     own `IDT'.
5447c478bd9Sstevel@tonic-gate
5457c478bd9Sstevel@tonic-gate   However, other machine state should be left by the boot loader in
5467c478bd9Sstevel@tonic-gate"normal working order", i.e. as initialized by the BIOS (or DOS, if
5477c478bd9Sstevel@tonic-gatethat's what the boot loader runs from). In other words, the operating
5487c478bd9Sstevel@tonic-gatesystem should be able to make BIOS calls and such after being loaded,
5497c478bd9Sstevel@tonic-gateas long as it does not overwrite the BIOS data structures before doing
5507c478bd9Sstevel@tonic-gateso. Also, the boot loader must leave the PIC programmed with the normal
5517c478bd9Sstevel@tonic-gateBIOS/DOS values, even if it changed them during the switch to 32-bit
5527c478bd9Sstevel@tonic-gatemode.
5537c478bd9Sstevel@tonic-gate
5547c478bd9Sstevel@tonic-gate
5557c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Boot information format,  Prev: Machine state,  Up: Specification
5567c478bd9Sstevel@tonic-gate
557*1b8adde7SWilliam Kucharski3.3 Boot information format
558*1b8adde7SWilliam Kucharski===========================
5597c478bd9Sstevel@tonic-gate
560*1b8adde7SWilliam KucharskiFIXME: Split this chapter like the chapter "OS image format".
5617c478bd9Sstevel@tonic-gate
5627c478bd9Sstevel@tonic-gate   Upon entry to the operating system, the `EBX' register contains the
5637c478bd9Sstevel@tonic-gatephysical address of a "Multiboot information" data structure, through
5647c478bd9Sstevel@tonic-gatewhich the boot loader communicates vital information to the operating
5657c478bd9Sstevel@tonic-gatesystem. The operating system can use or ignore any parts of the
5667c478bd9Sstevel@tonic-gatestructure as it chooses; all information passed by the boot loader is
5677c478bd9Sstevel@tonic-gateadvisory only.
5687c478bd9Sstevel@tonic-gate
5697c478bd9Sstevel@tonic-gate   The Multiboot information structure and its related substructures
5707c478bd9Sstevel@tonic-gatemay be placed anywhere in memory by the boot loader (with the exception
5717c478bd9Sstevel@tonic-gateof the memory reserved for the kernel and boot modules, of course). It
5727c478bd9Sstevel@tonic-gateis the operating system's responsibility to avoid overwriting this
5737c478bd9Sstevel@tonic-gatememory until it is done using it.
5747c478bd9Sstevel@tonic-gate
5757c478bd9Sstevel@tonic-gate   The format of the Multiboot information structure (as defined so far)
5767c478bd9Sstevel@tonic-gatefollows:
5777c478bd9Sstevel@tonic-gate
5787c478bd9Sstevel@tonic-gate             +-------------------+
5797c478bd9Sstevel@tonic-gate     0       | flags             |    (required)
5807c478bd9Sstevel@tonic-gate             +-------------------+
5817c478bd9Sstevel@tonic-gate     4       | mem_lower         |    (present if flags[0] is set)
5827c478bd9Sstevel@tonic-gate     8       | mem_upper         |    (present if flags[0] is set)
5837c478bd9Sstevel@tonic-gate             +-------------------+
5847c478bd9Sstevel@tonic-gate     12      | boot_device       |    (present if flags[1] is set)
5857c478bd9Sstevel@tonic-gate             +-------------------+
5867c478bd9Sstevel@tonic-gate     16      | cmdline           |    (present if flags[2] is set)
5877c478bd9Sstevel@tonic-gate             +-------------------+
5887c478bd9Sstevel@tonic-gate     20      | mods_count        |    (present if flags[3] is set)
5897c478bd9Sstevel@tonic-gate     24      | mods_addr         |    (present if flags[3] is set)
5907c478bd9Sstevel@tonic-gate             +-------------------+
5917c478bd9Sstevel@tonic-gate     28 - 40 | syms              |    (present if flags[4] or
5927c478bd9Sstevel@tonic-gate             |                   |                flags[5] is set)
5937c478bd9Sstevel@tonic-gate             +-------------------+
5947c478bd9Sstevel@tonic-gate     44      | mmap_length       |    (present if flags[6] is set)
5957c478bd9Sstevel@tonic-gate     48      | mmap_addr         |    (present if flags[6] is set)
5967c478bd9Sstevel@tonic-gate             +-------------------+
5977c478bd9Sstevel@tonic-gate     52      | drives_length     |    (present if flags[7] is set)
5987c478bd9Sstevel@tonic-gate     56      | drives_addr       |    (present if flags[7] is set)
5997c478bd9Sstevel@tonic-gate             +-------------------+
6007c478bd9Sstevel@tonic-gate     60      | config_table      |    (present if flags[8] is set)
6017c478bd9Sstevel@tonic-gate             +-------------------+
6027c478bd9Sstevel@tonic-gate     64      | boot_loader_name  |    (present if flags[9] is set)
6037c478bd9Sstevel@tonic-gate             +-------------------+
6047c478bd9Sstevel@tonic-gate     68      | apm_table         |    (present if flags[10] is set)
6057c478bd9Sstevel@tonic-gate             +-------------------+
6067c478bd9Sstevel@tonic-gate     72      | vbe_control_info  |    (present if flags[11] is set)
6077c478bd9Sstevel@tonic-gate     76      | vbe_mode_info     |
6087c478bd9Sstevel@tonic-gate     80      | vbe_mode          |
6097c478bd9Sstevel@tonic-gate     82      | vbe_interface_seg |
6107c478bd9Sstevel@tonic-gate     84      | vbe_interface_off |
6117c478bd9Sstevel@tonic-gate     86      | vbe_interface_len |
6127c478bd9Sstevel@tonic-gate             +-------------------+
6137c478bd9Sstevel@tonic-gate
6147c478bd9Sstevel@tonic-gate   The first longword indicates the presence and validity of other
6157c478bd9Sstevel@tonic-gatefields in the Multiboot information structure. All as-yet-undefined
6167c478bd9Sstevel@tonic-gatebits must be set to zero by the boot loader. Any set bits that the
6177c478bd9Sstevel@tonic-gateoperating system does not understand should be ignored. Thus, the
6187c478bd9Sstevel@tonic-gate`flags' field also functions as a version indicator, allowing the
6197c478bd9Sstevel@tonic-gateMultiboot information structure to be expanded in the future without
6207c478bd9Sstevel@tonic-gatebreaking anything.
6217c478bd9Sstevel@tonic-gate
6227c478bd9Sstevel@tonic-gate   If bit 0 in the `flags' word is set, then the `mem_*' fields are
6237c478bd9Sstevel@tonic-gatevalid. `mem_lower' and `mem_upper' indicate the amount of lower and
6247c478bd9Sstevel@tonic-gateupper memory, respectively, in kilobytes. Lower memory starts at
6257c478bd9Sstevel@tonic-gateaddress 0, and upper memory starts at address 1 megabyte. The maximum
6267c478bd9Sstevel@tonic-gatepossible value for lower memory is 640 kilobytes. The value returned for
6277c478bd9Sstevel@tonic-gateupper memory is maximally the address of the first upper memory hole
6287c478bd9Sstevel@tonic-gateminus 1 megabyte. It is not guaranteed to be this value.
6297c478bd9Sstevel@tonic-gate
6307c478bd9Sstevel@tonic-gate   If bit 1 in the `flags' word is set, then the `boot_device' field is
6317c478bd9Sstevel@tonic-gatevalid, and indicates which BIOS disk device the boot loader loaded the
6327c478bd9Sstevel@tonic-gateOS image from. If the OS image was not loaded from a BIOS disk, then
6337c478bd9Sstevel@tonic-gatethis field must not be present (bit 3 must be clear). The operating
6347c478bd9Sstevel@tonic-gatesystem may use this field as a hint for determining its own "root"
6357c478bd9Sstevel@tonic-gatedevice, but is not required to. The `boot_device' field is laid out in
6367c478bd9Sstevel@tonic-gatefour one-byte subfields as follows:
6377c478bd9Sstevel@tonic-gate
6387c478bd9Sstevel@tonic-gate     +-------+-------+-------+-------+
6397c478bd9Sstevel@tonic-gate     | drive | part1 | part2 | part3 |
6407c478bd9Sstevel@tonic-gate     +-------+-------+-------+-------+
6417c478bd9Sstevel@tonic-gate
6427c478bd9Sstevel@tonic-gate   The first byte contains the BIOS drive number as understood by the
6437c478bd9Sstevel@tonic-gateBIOS INT 0x13 low-level disk interface: e.g. 0x00 for the first floppy
6447c478bd9Sstevel@tonic-gatedisk or 0x80 for the first hard disk.
6457c478bd9Sstevel@tonic-gate
6467c478bd9Sstevel@tonic-gate   The three remaining bytes specify the boot partition. `part1'
6477c478bd9Sstevel@tonic-gatespecifies the "top-level" partition number, `part2' specifies a
6487c478bd9Sstevel@tonic-gate"sub-partition" in the top-level partition, etc. Partition numbers
6497c478bd9Sstevel@tonic-gatealways start from zero. Unused partition bytes must be set to 0xFF. For
6507c478bd9Sstevel@tonic-gateexample, if the disk is partitioned using a simple one-level DOS
6517c478bd9Sstevel@tonic-gatepartitioning scheme, then `part1' contains the DOS partition number,
6527c478bd9Sstevel@tonic-gateand `part2' and `part3' are both 0xFF. As another example, if a disk is
6537c478bd9Sstevel@tonic-gatepartitioned first into DOS partitions, and then one of those DOS
6547c478bd9Sstevel@tonic-gatepartitions is subdivided into several BSD partitions using BSD's
6557c478bd9Sstevel@tonic-gate"disklabel" strategy, then `part1' contains the DOS partition number,
6567c478bd9Sstevel@tonic-gate`part2' contains the BSD sub-partition within that DOS partition, and
6577c478bd9Sstevel@tonic-gate`part3' is 0xFF.
6587c478bd9Sstevel@tonic-gate
6597c478bd9Sstevel@tonic-gate   DOS extended partitions are indicated as partition numbers starting
6607c478bd9Sstevel@tonic-gatefrom 4 and increasing, rather than as nested sub-partitions, even
6617c478bd9Sstevel@tonic-gatethough the underlying disk layout of extended partitions is
6627c478bd9Sstevel@tonic-gatehierarchical in nature. For example, if the boot loader boots from the
6637c478bd9Sstevel@tonic-gatesecond extended partition on a disk partitioned in conventional DOS
6647c478bd9Sstevel@tonic-gatestyle, then `part1' will be 5, and `part2' and `part3' will both be
6657c478bd9Sstevel@tonic-gate0xFF.
6667c478bd9Sstevel@tonic-gate
6677c478bd9Sstevel@tonic-gate   If bit 2 of the `flags' longword is set, the `cmdline' field is
6687c478bd9Sstevel@tonic-gatevalid, and contains the physical address of the command line to be
6697c478bd9Sstevel@tonic-gatepassed to the kernel. The command line is a normal C-style
6707c478bd9Sstevel@tonic-gatezero-terminated string.
6717c478bd9Sstevel@tonic-gate
6727c478bd9Sstevel@tonic-gate   If bit 3 of the `flags' is set, then the `mods' fields indicate to
6737c478bd9Sstevel@tonic-gatethe kernel what boot modules were loaded along with the kernel image,
6747c478bd9Sstevel@tonic-gateand where they can be found. `mods_count' contains the number of
6757c478bd9Sstevel@tonic-gatemodules loaded; `mods_addr' contains the physical address of the first
6767c478bd9Sstevel@tonic-gatemodule structure. `mods_count' may be zero, indicating no boot modules
6777c478bd9Sstevel@tonic-gatewere loaded, even if bit 1 of `flags' is set. Each module structure is
6787c478bd9Sstevel@tonic-gateformatted as follows:
6797c478bd9Sstevel@tonic-gate
6807c478bd9Sstevel@tonic-gate             +-------------------+
6817c478bd9Sstevel@tonic-gate     0       | mod_start         |
6827c478bd9Sstevel@tonic-gate     4       | mod_end           |
6837c478bd9Sstevel@tonic-gate             +-------------------+
6847c478bd9Sstevel@tonic-gate     8       | string            |
6857c478bd9Sstevel@tonic-gate             +-------------------+
6867c478bd9Sstevel@tonic-gate     12      | reserved (0)      |
6877c478bd9Sstevel@tonic-gate             +-------------------+
6887c478bd9Sstevel@tonic-gate
6897c478bd9Sstevel@tonic-gate   The first two fields contain the start and end addresses of the boot
6907c478bd9Sstevel@tonic-gatemodule itself. The `string' field provides an arbitrary string to be
6917c478bd9Sstevel@tonic-gateassociated with that particular boot module; it is a zero-terminated
6927c478bd9Sstevel@tonic-gateASCII string, just like the kernel command line. The `string' field may
6937c478bd9Sstevel@tonic-gatebe 0 if there is no string associated with the module. Typically the
6947c478bd9Sstevel@tonic-gatestring might be a command line (e.g. if the operating system treats boot
6957c478bd9Sstevel@tonic-gatemodules as executable programs), or a pathname (e.g. if the operating
6967c478bd9Sstevel@tonic-gatesystem treats boot modules as files in a file system), but its exact use
6977c478bd9Sstevel@tonic-gateis specific to the operating system. The `reserved' field must be set
6987c478bd9Sstevel@tonic-gateto 0 by the boot loader and ignored by the operating system.
6997c478bd9Sstevel@tonic-gate
7007c478bd9Sstevel@tonic-gate   *Caution:* Bits 4 & 5 are mutually exclusive.
7017c478bd9Sstevel@tonic-gate
7027c478bd9Sstevel@tonic-gate   If bit 4 in the `flags' word is set, then the following fields in
7037c478bd9Sstevel@tonic-gatethe Multiboot information structure starting at byte 28 are valid:
7047c478bd9Sstevel@tonic-gate
7057c478bd9Sstevel@tonic-gate             +-------------------+
7067c478bd9Sstevel@tonic-gate     28      | tabsize           |
7077c478bd9Sstevel@tonic-gate     32      | strsize           |
7087c478bd9Sstevel@tonic-gate     36      | addr              |
7097c478bd9Sstevel@tonic-gate     40      | reserved (0)      |
7107c478bd9Sstevel@tonic-gate             +-------------------+
7117c478bd9Sstevel@tonic-gate
7127c478bd9Sstevel@tonic-gate   These indicate where the symbol table from an a.out kernel image can
7137c478bd9Sstevel@tonic-gatebe found. `addr' is the physical address of the size (4-byte unsigned
7147c478bd9Sstevel@tonic-gatelong) of an array of a.out format "nlist" structures, followed
7157c478bd9Sstevel@tonic-gateimmediately by the array itself, then the size (4-byte unsigned long) of
7167c478bd9Sstevel@tonic-gatea set of zero-terminated ASCII strings (plus sizeof(unsigned long) in
7177c478bd9Sstevel@tonic-gatethis case), and finally the set of strings itself. `tabsize' is equal
7187c478bd9Sstevel@tonic-gateto its size parameter (found at the beginning of the symbol section),
7197c478bd9Sstevel@tonic-gateand `strsize' is equal to its size parameter (found at the beginning of
7207c478bd9Sstevel@tonic-gatethe string section) of the following string table to which the symbol
7217c478bd9Sstevel@tonic-gatetable refers. Note that `tabsize' may be 0, indicating no symbols, even
7227c478bd9Sstevel@tonic-gateif bit 4 in the `flags' word is set.
7237c478bd9Sstevel@tonic-gate
7247c478bd9Sstevel@tonic-gate   If bit 5 in the `flags' word is set, then the following fields in
7257c478bd9Sstevel@tonic-gatethe Multiboot information structure starting at byte 28 are valid:
7267c478bd9Sstevel@tonic-gate
7277c478bd9Sstevel@tonic-gate             +-------------------+
7287c478bd9Sstevel@tonic-gate     28      | num               |
7297c478bd9Sstevel@tonic-gate     32      | size              |
7307c478bd9Sstevel@tonic-gate     36      | addr              |
7317c478bd9Sstevel@tonic-gate     40      | shndx             |
7327c478bd9Sstevel@tonic-gate             +-------------------+
7337c478bd9Sstevel@tonic-gate
7347c478bd9Sstevel@tonic-gate   These indicate where the section header table from an ELF kernel is,
7357c478bd9Sstevel@tonic-gatethe size of each entry, number of entries, and the string table used as
7367c478bd9Sstevel@tonic-gatethe index of names. They correspond to the `shdr_*' entries
7377c478bd9Sstevel@tonic-gate(`shdr_num', etc.) in the Executable and Linkable Format (ELF)
7387c478bd9Sstevel@tonic-gatespecification in the program header. All sections are loaded, and the
7397c478bd9Sstevel@tonic-gatephysical address fields of the ELF section header then refer to where
7407c478bd9Sstevel@tonic-gatethe sections are in memory (refer to the i386 ELF documentation for
7417c478bd9Sstevel@tonic-gatedetails as to how to read the section header(s)). Note that `shdr_num'
7427c478bd9Sstevel@tonic-gatemay be 0, indicating no symbols, even if bit 5 in the `flags' word is
7437c478bd9Sstevel@tonic-gateset.
7447c478bd9Sstevel@tonic-gate
7457c478bd9Sstevel@tonic-gate   If bit 6 in the `flags' word is set, then the `mmap_*' fields are
7467c478bd9Sstevel@tonic-gatevalid, and indicate the address and length of a buffer containing a
7477c478bd9Sstevel@tonic-gatememory map of the machine provided by the BIOS. `mmap_addr' is the
7487c478bd9Sstevel@tonic-gateaddress, and `mmap_length' is the total size of the buffer. The buffer
7497c478bd9Sstevel@tonic-gateconsists of one or more of the following size/structure pairs (`size'
7507c478bd9Sstevel@tonic-gateis really used for skipping to the next pair):
7517c478bd9Sstevel@tonic-gate
7527c478bd9Sstevel@tonic-gate             +-------------------+
7537c478bd9Sstevel@tonic-gate     -4      | size              |
7547c478bd9Sstevel@tonic-gate             +-------------------+
7557c478bd9Sstevel@tonic-gate     0       | base_addr_low     |
7567c478bd9Sstevel@tonic-gate     4       | base_addr_high    |
7577c478bd9Sstevel@tonic-gate     8       | length_low        |
7587c478bd9Sstevel@tonic-gate     12      | length_high       |
7597c478bd9Sstevel@tonic-gate     16      | type              |
7607c478bd9Sstevel@tonic-gate             +-------------------+
7617c478bd9Sstevel@tonic-gate
7627c478bd9Sstevel@tonic-gate   where `size' is the size of the associated structure in bytes, which
7637c478bd9Sstevel@tonic-gatecan be greater than the minimum of 20 bytes. `base_addr_low' is the
7647c478bd9Sstevel@tonic-gatelower 32 bits of the starting address, and `base_addr_high' is the
7657c478bd9Sstevel@tonic-gateupper 32 bits, for a total of a 64-bit starting address. `length_low'
7667c478bd9Sstevel@tonic-gateis the lower 32 bits of the size of the memory region in bytes, and
7677c478bd9Sstevel@tonic-gate`length_high' is the upper 32 bits, for a total of a 64-bit length.
7687c478bd9Sstevel@tonic-gate`type' is the variety of address range represented, where a value of 1
7697c478bd9Sstevel@tonic-gateindicates available RAM, and all other values currently indicated a
7707c478bd9Sstevel@tonic-gatereserved area.
7717c478bd9Sstevel@tonic-gate
7727c478bd9Sstevel@tonic-gate   The map provided is guaranteed to list all standard RAM that should
7737c478bd9Sstevel@tonic-gatebe available for normal use.
7747c478bd9Sstevel@tonic-gate
7757c478bd9Sstevel@tonic-gate   If bit 7 in the `flags' is set, then the `drives_*' fields are
7767c478bd9Sstevel@tonic-gatevalid, and indicate the address of the physical address of the first
7777c478bd9Sstevel@tonic-gatedrive structure and the size of drive structures. `drives_addr' is the
7787c478bd9Sstevel@tonic-gateaddress, and `drives_length' is the total size of drive structures.
7797c478bd9Sstevel@tonic-gateNote that `drives_length' may be zero. Each drive structure is
7807c478bd9Sstevel@tonic-gateformatted as follows:
7817c478bd9Sstevel@tonic-gate
7827c478bd9Sstevel@tonic-gate             +-------------------+
7837c478bd9Sstevel@tonic-gate     0       | size              |
7847c478bd9Sstevel@tonic-gate             +-------------------+
7857c478bd9Sstevel@tonic-gate     4       | drive_number      |
7867c478bd9Sstevel@tonic-gate             +-------------------+
7877c478bd9Sstevel@tonic-gate     5       | drive_mode        |
7887c478bd9Sstevel@tonic-gate             +-------------------+
7897c478bd9Sstevel@tonic-gate     6       | drive_cylinders   |
7907c478bd9Sstevel@tonic-gate     8       | drive_heads       |
7917c478bd9Sstevel@tonic-gate     9       | drive_sectors     |
7927c478bd9Sstevel@tonic-gate             +-------------------+
7937c478bd9Sstevel@tonic-gate     10 - xx | drive_ports       |
7947c478bd9Sstevel@tonic-gate             +-------------------+
7957c478bd9Sstevel@tonic-gate
7967c478bd9Sstevel@tonic-gate   The `size' field specifies the size of this structure. The size
7977c478bd9Sstevel@tonic-gatevaries, depending on the number of ports. Note that the size may not be
7987c478bd9Sstevel@tonic-gateequal to (10 + 2 * the number of ports), because of an alignment.
7997c478bd9Sstevel@tonic-gate
8007c478bd9Sstevel@tonic-gate   The `drive_number' field contains the BIOS drive number. The
8017c478bd9Sstevel@tonic-gate`drive_mode' field represents the access mode used by the boot loader.
8027c478bd9Sstevel@tonic-gateCurrently, the following modes are defined:
8037c478bd9Sstevel@tonic-gate
8047c478bd9Sstevel@tonic-gate`0'
8057c478bd9Sstevel@tonic-gate     CHS mode (traditional cylinder/head/sector addressing mode).
8067c478bd9Sstevel@tonic-gate
8077c478bd9Sstevel@tonic-gate`1'
8087c478bd9Sstevel@tonic-gate     LBA mode (Logical Block Addressing mode).
8097c478bd9Sstevel@tonic-gate
8107c478bd9Sstevel@tonic-gate   The three fields, `drive_cylinders', `drive_heads' and
8117c478bd9Sstevel@tonic-gate`drive_sectors', indicate the geometry of the drive detected by the
8127c478bd9Sstevel@tonic-gateBIOS. `drive_cylinders' contains the number of the cylinders.
8137c478bd9Sstevel@tonic-gate`drive_heads' contains the number of the heads. `drive_sectors'
8147c478bd9Sstevel@tonic-gatecontains the number of the sectors per track.
8157c478bd9Sstevel@tonic-gate
8167c478bd9Sstevel@tonic-gate   The `drive_ports' field contains the array of the I/O ports used for
8177c478bd9Sstevel@tonic-gatethe drive in the BIOS code. The array consists of zero or more unsigned
8187c478bd9Sstevel@tonic-gatetwo-bytes integers, and is terminated with zero. Note that the array
8197c478bd9Sstevel@tonic-gatemay contain any number of I/O ports that are not related to the drive
8207c478bd9Sstevel@tonic-gateactually (such as DMA controller's ports).
8217c478bd9Sstevel@tonic-gate
8227c478bd9Sstevel@tonic-gate   If bit 8 in the `flags' is set, then the `config_table' field is
8237c478bd9Sstevel@tonic-gatevalid, and indicates the address of the ROM configuration table
8247c478bd9Sstevel@tonic-gatereturned by the "GET CONFIGURATION" BIOS call. If the BIOS call fails,
8257c478bd9Sstevel@tonic-gatethen the size of the table must be _zero_.
8267c478bd9Sstevel@tonic-gate
8277c478bd9Sstevel@tonic-gate   If bit 9 in the `flags' is set, the `boot_loader_name' field is
8287c478bd9Sstevel@tonic-gatevalid, and contains the physical address of the name of a boot loader
8297c478bd9Sstevel@tonic-gatebooting the kernel. The name is a normal C-style zero-terminated string.
8307c478bd9Sstevel@tonic-gate
8317c478bd9Sstevel@tonic-gate   If bit 10 in the `flags' is set, the `apm_table' field is valid, and
8327c478bd9Sstevel@tonic-gatecontains the physical address of an APM table defined as below:
8337c478bd9Sstevel@tonic-gate
8347c478bd9Sstevel@tonic-gate             +----------------------+
8357c478bd9Sstevel@tonic-gate     0       | version              |
8367c478bd9Sstevel@tonic-gate     2       | cseg                 |
8377c478bd9Sstevel@tonic-gate     4       | offset               |
8387c478bd9Sstevel@tonic-gate     8       | cseg_16              |
8397c478bd9Sstevel@tonic-gate     10      | dseg                 |
8407c478bd9Sstevel@tonic-gate     12      | flags                |
8417c478bd9Sstevel@tonic-gate     14      | cseg_len             |
8427c478bd9Sstevel@tonic-gate     16      | cseg_16_len          |
8437c478bd9Sstevel@tonic-gate     18      | dseg_len             |
8447c478bd9Sstevel@tonic-gate             +----------------------+
8457c478bd9Sstevel@tonic-gate
8467c478bd9Sstevel@tonic-gate   The fields `version', `cseg', `offset', `cseg_16', `dseg', `flags',
8477c478bd9Sstevel@tonic-gate`cseg_len', `cseg_16_len', `dseg_len' indicate the version number, the
8487c478bd9Sstevel@tonic-gateprotected mode 32-bit code segment, the offset of the entry point, the
8497c478bd9Sstevel@tonic-gateprotected mode 16-bit code segment, the protected mode 16-bit data
8507c478bd9Sstevel@tonic-gatesegment, the flags, the length of the protected mode 32-bit code
8517c478bd9Sstevel@tonic-gatesegment, the length of the protected mode 16-bit code segment, and the
8527c478bd9Sstevel@tonic-gatelength of the protected mode 16-bit data segment, respectively. Only
8537c478bd9Sstevel@tonic-gatethe field `offset' is 4 bytes, and the others are 2 bytes. See Advanced
8547c478bd9Sstevel@tonic-gatePower Management (APM) BIOS Interface Specification
8557c478bd9Sstevel@tonic-gate(http://www.microsoft.com/hwdev/busbios/amp_12.htm), for more
8567c478bd9Sstevel@tonic-gateinformation.
8577c478bd9Sstevel@tonic-gate
8587c478bd9Sstevel@tonic-gate   If bit 11 in the `flags' is set, the graphics table is available.
8597c478bd9Sstevel@tonic-gateThis must only be done if the kernel has indicated in the `Multiboot
8607c478bd9Sstevel@tonic-gateHeader' that it accepts a graphics mode.
8617c478bd9Sstevel@tonic-gate
8627c478bd9Sstevel@tonic-gate   The fields `vbe_control_info' and `vbe_mode_info' contain the
8637c478bd9Sstevel@tonic-gatephysical addresses of VBE control information returned by the VBE
8647c478bd9Sstevel@tonic-gateFunction 00h and VBE mode information returned by the VBE Function 01h,
8657c478bd9Sstevel@tonic-gaterespectively.
8667c478bd9Sstevel@tonic-gate
8677c478bd9Sstevel@tonic-gate   The field `vbe_mode' indicates current video mode in the format
8687c478bd9Sstevel@tonic-gatespecified in VBE 3.0.
8697c478bd9Sstevel@tonic-gate
8707c478bd9Sstevel@tonic-gate   The rest fields `vbe_interface_seg', `vbe_interface_off', and
8717c478bd9Sstevel@tonic-gate`vbe_interface_len' contain the table of a protected mode interface
8727c478bd9Sstevel@tonic-gatedefined in VBE 2.0+. If this information is not available, those fields
8737c478bd9Sstevel@tonic-gatecontain zero. Note that VBE 3.0 defines another protected mode
8747c478bd9Sstevel@tonic-gateinterface which is incompatible with the old one. If you want to use
8757c478bd9Sstevel@tonic-gatethe new protected mode interface, you will have to find the table
8767c478bd9Sstevel@tonic-gateyourself.
8777c478bd9Sstevel@tonic-gate
8787c478bd9Sstevel@tonic-gate   The fields for the graphics table are designed for VBE, but
8797c478bd9Sstevel@tonic-gateMultiboot boot loaders may simulate VBE on non-VBE modes, as if they
8807c478bd9Sstevel@tonic-gatewere VBE modes.
8817c478bd9Sstevel@tonic-gate
8827c478bd9Sstevel@tonic-gate
8837c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Examples,  Next: History,  Prev: Specification,  Up: Top
8847c478bd9Sstevel@tonic-gate
885*1b8adde7SWilliam Kucharski4 Examples
886*1b8adde7SWilliam Kucharski**********
8877c478bd9Sstevel@tonic-gate
888*1b8adde7SWilliam Kucharski*Caution:* The following items are not part of the specification
8897c478bd9Sstevel@tonic-gatedocument, but are included for prospective operating system and boot
8907c478bd9Sstevel@tonic-gateloader writers.
8917c478bd9Sstevel@tonic-gate
8927c478bd9Sstevel@tonic-gate* Menu:
8937c478bd9Sstevel@tonic-gate
8947c478bd9Sstevel@tonic-gate* Notes on PC::
8957c478bd9Sstevel@tonic-gate* BIOS device mapping techniques::
8967c478bd9Sstevel@tonic-gate* Example OS code::
8977c478bd9Sstevel@tonic-gate* Example boot loader code::
8987c478bd9Sstevel@tonic-gate
8997c478bd9Sstevel@tonic-gate
9007c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Notes on PC,  Next: BIOS device mapping techniques,  Up: Examples
9017c478bd9Sstevel@tonic-gate
902*1b8adde7SWilliam Kucharski4.1 Notes on PC
903*1b8adde7SWilliam Kucharski===============
9047c478bd9Sstevel@tonic-gate
905*1b8adde7SWilliam KucharskiIn reference to bit 0 of the `flags' parameter in the Multiboot
9067c478bd9Sstevel@tonic-gateinformation structure, if the bootloader in question uses older BIOS
9077c478bd9Sstevel@tonic-gateinterfaces, or the newest ones are not available (see description about
9087c478bd9Sstevel@tonic-gatebit 6), then a maximum of either 15 or 63 megabytes of memory may be
9097c478bd9Sstevel@tonic-gatereported. It is _highly_ recommended that boot loaders perform a
9107c478bd9Sstevel@tonic-gatethorough memory probe.
9117c478bd9Sstevel@tonic-gate
9127c478bd9Sstevel@tonic-gate   In reference to bit 1 of the `flags' parameter in the Multiboot
9137c478bd9Sstevel@tonic-gateinformation structure, it is recognized that determination of which
9147c478bd9Sstevel@tonic-gateBIOS drive maps to which device driver in an operating system is
9157c478bd9Sstevel@tonic-gatenon-trivial, at best. Many kludges have been made to various operating
9167c478bd9Sstevel@tonic-gatesystems instead of solving this problem, most of them breaking under
9177c478bd9Sstevel@tonic-gatemany conditions. To encourage the use of general-purpose solutions to
9187c478bd9Sstevel@tonic-gatethis problem, there are 2 BIOS device mapping techniques (*note BIOS
9197c478bd9Sstevel@tonic-gatedevice mapping techniques::).
9207c478bd9Sstevel@tonic-gate
9217c478bd9Sstevel@tonic-gate   In reference to bit 6 of the `flags' parameter in the Multiboot
9227c478bd9Sstevel@tonic-gateinformation structure, it is important to note that the data structure
9237c478bd9Sstevel@tonic-gateused there (starting with `BaseAddrLow') is the data returned by the
9247c478bd9Sstevel@tonic-gateINT 15h, AX=E820h -- Query System Address Map call. See *Note Query
9257c478bd9Sstevel@tonic-gateSystem Address Map: (grub.info)Query System Address Map, for more
9267c478bd9Sstevel@tonic-gateinformation. The interface here is meant to allow a boot loader to work
9277c478bd9Sstevel@tonic-gateunmodified with any reasonable extensions of the BIOS interface,
9287c478bd9Sstevel@tonic-gatepassing along any extra data to be interpreted by the operating system
9297c478bd9Sstevel@tonic-gateas desired.
9307c478bd9Sstevel@tonic-gate
9317c478bd9Sstevel@tonic-gate
9327c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: BIOS device mapping techniques,  Next: Example OS code,  Prev: Notes on PC,  Up: Examples
9337c478bd9Sstevel@tonic-gate
934*1b8adde7SWilliam Kucharski4.2 BIOS device mapping techniques
935*1b8adde7SWilliam Kucharski==================================
9367c478bd9Sstevel@tonic-gate
937*1b8adde7SWilliam KucharskiBoth of these techniques should be usable from any PC operating system,
938*1b8adde7SWilliam Kucharskiand neither require any special support in the drivers themselves. This
939*1b8adde7SWilliam Kucharskisection will be flushed out into detailed explanations, particularly for
940*1b8adde7SWilliam Kucharskithe I/O restriction technique.
9417c478bd9Sstevel@tonic-gate
9427c478bd9Sstevel@tonic-gate   The general rule is that the data comparison technique is the quick
9437c478bd9Sstevel@tonic-gateand dirty solution. It works most of the time, but doesn't cover all the
9447c478bd9Sstevel@tonic-gatebases, and is relatively simple.
9457c478bd9Sstevel@tonic-gate
9467c478bd9Sstevel@tonic-gate   The I/O restriction technique is much more complex, but it has
9477c478bd9Sstevel@tonic-gatepotential to solve the problem under all conditions, plus allow access
9487c478bd9Sstevel@tonic-gateof the remaining BIOS devices when not all of them have operating system
9497c478bd9Sstevel@tonic-gatedrivers.
9507c478bd9Sstevel@tonic-gate
9517c478bd9Sstevel@tonic-gate* Menu:
9527c478bd9Sstevel@tonic-gate
9537c478bd9Sstevel@tonic-gate* Data comparison technique::
9547c478bd9Sstevel@tonic-gate* I/O restriction technique::
9557c478bd9Sstevel@tonic-gate
9567c478bd9Sstevel@tonic-gate
9577c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Data comparison technique,  Next: I/O restriction technique,  Up: BIOS device mapping techniques
9587c478bd9Sstevel@tonic-gate
959*1b8adde7SWilliam Kucharski4.2.1 Data comparison technique
960*1b8adde7SWilliam Kucharski-------------------------------
9617c478bd9Sstevel@tonic-gate
962*1b8adde7SWilliam KucharskiBefore activating _any_ of the device drivers, gather enough data from
963*1b8adde7SWilliam Kucharskisimilar sectors on each of the disks such that each one can be uniquely
964*1b8adde7SWilliam Kucharskiidentified.
9657c478bd9Sstevel@tonic-gate
9667c478bd9Sstevel@tonic-gate   After activating the device drivers, compare data from the drives
9677c478bd9Sstevel@tonic-gateusing the operating system drivers. This should hopefully be sufficient
9687c478bd9Sstevel@tonic-gateto provide such a mapping.
9697c478bd9Sstevel@tonic-gate
9707c478bd9Sstevel@tonic-gate   Problems:
9717c478bd9Sstevel@tonic-gate
9727c478bd9Sstevel@tonic-gate  1. The data on some BIOS devices might be identical (so the part
9737c478bd9Sstevel@tonic-gate     reading the drives from the BIOS should have some mechanism to give
9747c478bd9Sstevel@tonic-gate     up).
9757c478bd9Sstevel@tonic-gate
9767c478bd9Sstevel@tonic-gate  2. There might be extra drives not accessible from the BIOS which are
9777c478bd9Sstevel@tonic-gate     identical to some drive used by the BIOS (so it should be capable
9787c478bd9Sstevel@tonic-gate     of giving up there as well).
9797c478bd9Sstevel@tonic-gate
9807c478bd9Sstevel@tonic-gate
9817c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: I/O restriction technique,  Prev: Data comparison technique,  Up: BIOS device mapping techniques
9827c478bd9Sstevel@tonic-gate
983*1b8adde7SWilliam Kucharski4.2.2 I/O restriction technique
984*1b8adde7SWilliam Kucharski-------------------------------
9857c478bd9Sstevel@tonic-gate
986*1b8adde7SWilliam KucharskiThis first step may be unnecessary, but first create copy-on-write
9877c478bd9Sstevel@tonic-gatemappings for the device drivers writing into PC RAM. Keep the original
9887c478bd9Sstevel@tonic-gatecopies for the "clean BIOS virtual machine" to be created later.
9897c478bd9Sstevel@tonic-gate
9907c478bd9Sstevel@tonic-gate   For each device driver brought online, determine which BIOS devices
9917c478bd9Sstevel@tonic-gatebecome inaccessible by:
9927c478bd9Sstevel@tonic-gate
9937c478bd9Sstevel@tonic-gate  1. Create a "clean BIOS virtual machine".
9947c478bd9Sstevel@tonic-gate
9957c478bd9Sstevel@tonic-gate  2. Set the I/O permission map for the I/O area claimed by the device
9967c478bd9Sstevel@tonic-gate     driver to no permissions (neither read nor write).
9977c478bd9Sstevel@tonic-gate
9987c478bd9Sstevel@tonic-gate  3. Access each device.
9997c478bd9Sstevel@tonic-gate
10007c478bd9Sstevel@tonic-gate  4. Record which devices succeed, and those which try to access the
10017c478bd9Sstevel@tonic-gate     "restricted" I/O areas (hopefully, this will be an "xor"
10027c478bd9Sstevel@tonic-gate     situation).
10037c478bd9Sstevel@tonic-gate
10047c478bd9Sstevel@tonic-gate   For each device driver, given how many of the BIOS devices were
10057c478bd9Sstevel@tonic-gatesubsumed by it (there should be no gaps in this list), it should be easy
10067c478bd9Sstevel@tonic-gateto determine which devices on the controller these are.
10077c478bd9Sstevel@tonic-gate
10087c478bd9Sstevel@tonic-gate   In general, you have at most 2 disks from each controller given BIOS
10097c478bd9Sstevel@tonic-gatenumbers, but they pretty much always count from the lowest logically
10107c478bd9Sstevel@tonic-gatenumbered devices on the controller.
10117c478bd9Sstevel@tonic-gate
10127c478bd9Sstevel@tonic-gate
10137c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Example OS code,  Next: Example boot loader code,  Prev: BIOS device mapping techniques,  Up: Examples
10147c478bd9Sstevel@tonic-gate
1015*1b8adde7SWilliam Kucharski4.3 Example OS code
1016*1b8adde7SWilliam Kucharski===================
10177c478bd9Sstevel@tonic-gate
1018*1b8adde7SWilliam KucharskiIn this distribution, the example Multiboot kernel `kernel' is
10197c478bd9Sstevel@tonic-gateincluded. The kernel just prints out the Multiboot information structure
10207c478bd9Sstevel@tonic-gateon the screen, so you can make use of the kernel to test a
10217c478bd9Sstevel@tonic-gateMultiboot-compliant boot loader and for reference to how to implement a
10227c478bd9Sstevel@tonic-gateMultiboot kernel. The source files can be found under the directory
10237c478bd9Sstevel@tonic-gate`docs' in the GRUB distribution.
10247c478bd9Sstevel@tonic-gate
10257c478bd9Sstevel@tonic-gate   The kernel `kernel' consists of only three files: `boot.S',
10267c478bd9Sstevel@tonic-gate`kernel.c' and `multiboot.h'. The assembly source `boot.S' is written
10277c478bd9Sstevel@tonic-gatein GAS (*note GNU assembler: (as.info)Top.), and contains the Multiboot
10287c478bd9Sstevel@tonic-gateinformation structure to comply with the specification. When a
10297c478bd9Sstevel@tonic-gateMultiboot-compliant boot loader loads and execute it, it initialize the
10307c478bd9Sstevel@tonic-gatestack pointer and `EFLAGS', and then call the function `cmain' defined
10317c478bd9Sstevel@tonic-gatein `kernel.c'. If `cmain' returns to the callee, then it shows a
10327c478bd9Sstevel@tonic-gatemessage to inform the user of the halt state and stops forever until
10337c478bd9Sstevel@tonic-gateyou push the reset key. The file `kernel.c' contains the function
10347c478bd9Sstevel@tonic-gate`cmain', which checks if the magic number passed by the boot loader is
10357c478bd9Sstevel@tonic-gatevalid and so on, and some functions to print messages on the screen.
10367c478bd9Sstevel@tonic-gateThe file `multiboot.h' defines some macros, such as the magic number
10377c478bd9Sstevel@tonic-gatefor the Multiboot header, the Multiboot header structure and the
10387c478bd9Sstevel@tonic-gateMultiboot information structure.
10397c478bd9Sstevel@tonic-gate
10407c478bd9Sstevel@tonic-gate* Menu:
10417c478bd9Sstevel@tonic-gate
10427c478bd9Sstevel@tonic-gate* multiboot.h::
10437c478bd9Sstevel@tonic-gate* boot.S::
10447c478bd9Sstevel@tonic-gate* kernel.c::
10457c478bd9Sstevel@tonic-gate* Other Multiboot kernels::
10467c478bd9Sstevel@tonic-gate
10477c478bd9Sstevel@tonic-gate
10487c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: multiboot.h,  Next: boot.S,  Up: Example OS code
10497c478bd9Sstevel@tonic-gate
1050*1b8adde7SWilliam Kucharski4.3.1 multiboot.h
1051*1b8adde7SWilliam Kucharski-----------------
10527c478bd9Sstevel@tonic-gate
1053*1b8adde7SWilliam KucharskiThis is the source code in the file `multiboot.h':
10547c478bd9Sstevel@tonic-gate
10557c478bd9Sstevel@tonic-gate     /* multiboot.h - the header for Multiboot */
10567c478bd9Sstevel@tonic-gate     /* Copyright (C) 1999, 2001  Free Software Foundation, Inc.
1057*1b8adde7SWilliam Kucharski
10587c478bd9Sstevel@tonic-gate        This program is free software; you can redistribute it and/or modify
10597c478bd9Sstevel@tonic-gate        it under the terms of the GNU General Public License as published by
10607c478bd9Sstevel@tonic-gate        the Free Software Foundation; either version 2 of the License, or
10617c478bd9Sstevel@tonic-gate        (at your option) any later version.
1062*1b8adde7SWilliam Kucharski
10637c478bd9Sstevel@tonic-gate        This program is distributed in the hope that it will be useful,
10647c478bd9Sstevel@tonic-gate        but WITHOUT ANY WARRANTY; without even the implied warranty of
10657c478bd9Sstevel@tonic-gate        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10667c478bd9Sstevel@tonic-gate        GNU General Public License for more details.
1067*1b8adde7SWilliam Kucharski
10687c478bd9Sstevel@tonic-gate        You should have received a copy of the GNU General Public License
10697c478bd9Sstevel@tonic-gate        along with this program; if not, write to the Free Software
10707c478bd9Sstevel@tonic-gate        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
1071*1b8adde7SWilliam Kucharski
10727c478bd9Sstevel@tonic-gate     /* Macros. */
1073*1b8adde7SWilliam Kucharski
10747c478bd9Sstevel@tonic-gate     /* The magic number for the Multiboot header. */
10757c478bd9Sstevel@tonic-gate     #define MULTIBOOT_HEADER_MAGIC          0x1BADB002
1076*1b8adde7SWilliam Kucharski
10777c478bd9Sstevel@tonic-gate     /* The flags for the Multiboot header. */
10787c478bd9Sstevel@tonic-gate     #ifdef __ELF__
10797c478bd9Sstevel@tonic-gate     # define MULTIBOOT_HEADER_FLAGS         0x00000003
10807c478bd9Sstevel@tonic-gate     #else
10817c478bd9Sstevel@tonic-gate     # define MULTIBOOT_HEADER_FLAGS         0x00010003
10827c478bd9Sstevel@tonic-gate     #endif
1083*1b8adde7SWilliam Kucharski
10847c478bd9Sstevel@tonic-gate     /* The magic number passed by a Multiboot-compliant boot loader. */
10857c478bd9Sstevel@tonic-gate     #define MULTIBOOT_BOOTLOADER_MAGIC      0x2BADB002
1086*1b8adde7SWilliam Kucharski
10877c478bd9Sstevel@tonic-gate     /* The size of our stack (16KB). */
10887c478bd9Sstevel@tonic-gate     #define STACK_SIZE                      0x4000
1089*1b8adde7SWilliam Kucharski
10907c478bd9Sstevel@tonic-gate     /* C symbol format. HAVE_ASM_USCORE is defined by configure. */
10917c478bd9Sstevel@tonic-gate     #ifdef HAVE_ASM_USCORE
10927c478bd9Sstevel@tonic-gate     # define EXT_C(sym)                     _ ## sym
10937c478bd9Sstevel@tonic-gate     #else
10947c478bd9Sstevel@tonic-gate     # define EXT_C(sym)                     sym
10957c478bd9Sstevel@tonic-gate     #endif
1096*1b8adde7SWilliam Kucharski
10977c478bd9Sstevel@tonic-gate     #ifndef ASM
10987c478bd9Sstevel@tonic-gate     /* Do not include here in boot.S. */
1099*1b8adde7SWilliam Kucharski
11007c478bd9Sstevel@tonic-gate     /* Types. */
1101*1b8adde7SWilliam Kucharski
11027c478bd9Sstevel@tonic-gate     /* The Multiboot header. */
11037c478bd9Sstevel@tonic-gate     typedef struct multiboot_header
11047c478bd9Sstevel@tonic-gate     {
11057c478bd9Sstevel@tonic-gate       unsigned long magic;
11067c478bd9Sstevel@tonic-gate       unsigned long flags;
11077c478bd9Sstevel@tonic-gate       unsigned long checksum;
11087c478bd9Sstevel@tonic-gate       unsigned long header_addr;
11097c478bd9Sstevel@tonic-gate       unsigned long load_addr;
11107c478bd9Sstevel@tonic-gate       unsigned long load_end_addr;
11117c478bd9Sstevel@tonic-gate       unsigned long bss_end_addr;
11127c478bd9Sstevel@tonic-gate       unsigned long entry_addr;
11137c478bd9Sstevel@tonic-gate     } multiboot_header_t;
1114*1b8adde7SWilliam Kucharski
11157c478bd9Sstevel@tonic-gate     /* The symbol table for a.out. */
11167c478bd9Sstevel@tonic-gate     typedef struct aout_symbol_table
11177c478bd9Sstevel@tonic-gate     {
11187c478bd9Sstevel@tonic-gate       unsigned long tabsize;
11197c478bd9Sstevel@tonic-gate       unsigned long strsize;
11207c478bd9Sstevel@tonic-gate       unsigned long addr;
11217c478bd9Sstevel@tonic-gate       unsigned long reserved;
11227c478bd9Sstevel@tonic-gate     } aout_symbol_table_t;
1123*1b8adde7SWilliam Kucharski
11247c478bd9Sstevel@tonic-gate     /* The section header table for ELF. */
11257c478bd9Sstevel@tonic-gate     typedef struct elf_section_header_table
11267c478bd9Sstevel@tonic-gate     {
11277c478bd9Sstevel@tonic-gate       unsigned long num;
11287c478bd9Sstevel@tonic-gate       unsigned long size;
11297c478bd9Sstevel@tonic-gate       unsigned long addr;
11307c478bd9Sstevel@tonic-gate       unsigned long shndx;
11317c478bd9Sstevel@tonic-gate     } elf_section_header_table_t;
1132*1b8adde7SWilliam Kucharski
11337c478bd9Sstevel@tonic-gate     /* The Multiboot information. */
11347c478bd9Sstevel@tonic-gate     typedef struct multiboot_info
11357c478bd9Sstevel@tonic-gate     {
11367c478bd9Sstevel@tonic-gate       unsigned long flags;
11377c478bd9Sstevel@tonic-gate       unsigned long mem_lower;
11387c478bd9Sstevel@tonic-gate       unsigned long mem_upper;
11397c478bd9Sstevel@tonic-gate       unsigned long boot_device;
11407c478bd9Sstevel@tonic-gate       unsigned long cmdline;
11417c478bd9Sstevel@tonic-gate       unsigned long mods_count;
11427c478bd9Sstevel@tonic-gate       unsigned long mods_addr;
11437c478bd9Sstevel@tonic-gate       union
11447c478bd9Sstevel@tonic-gate       {
11457c478bd9Sstevel@tonic-gate         aout_symbol_table_t aout_sym;
11467c478bd9Sstevel@tonic-gate         elf_section_header_table_t elf_sec;
11477c478bd9Sstevel@tonic-gate       } u;
11487c478bd9Sstevel@tonic-gate       unsigned long mmap_length;
11497c478bd9Sstevel@tonic-gate       unsigned long mmap_addr;
11507c478bd9Sstevel@tonic-gate     } multiboot_info_t;
1151*1b8adde7SWilliam Kucharski
11527c478bd9Sstevel@tonic-gate     /* The module structure. */
11537c478bd9Sstevel@tonic-gate     typedef struct module
11547c478bd9Sstevel@tonic-gate     {
11557c478bd9Sstevel@tonic-gate       unsigned long mod_start;
11567c478bd9Sstevel@tonic-gate       unsigned long mod_end;
11577c478bd9Sstevel@tonic-gate       unsigned long string;
11587c478bd9Sstevel@tonic-gate       unsigned long reserved;
11597c478bd9Sstevel@tonic-gate     } module_t;
1160*1b8adde7SWilliam Kucharski
11617c478bd9Sstevel@tonic-gate     /* The memory map. Be careful that the offset 0 is base_addr_low
11627c478bd9Sstevel@tonic-gate        but no size. */
11637c478bd9Sstevel@tonic-gate     typedef struct memory_map
11647c478bd9Sstevel@tonic-gate     {
11657c478bd9Sstevel@tonic-gate       unsigned long size;
11667c478bd9Sstevel@tonic-gate       unsigned long base_addr_low;
11677c478bd9Sstevel@tonic-gate       unsigned long base_addr_high;
11687c478bd9Sstevel@tonic-gate       unsigned long length_low;
11697c478bd9Sstevel@tonic-gate       unsigned long length_high;
11707c478bd9Sstevel@tonic-gate       unsigned long type;
11717c478bd9Sstevel@tonic-gate     } memory_map_t;
1172*1b8adde7SWilliam Kucharski
11737c478bd9Sstevel@tonic-gate     #endif /* ! ASM */
11747c478bd9Sstevel@tonic-gate
11757c478bd9Sstevel@tonic-gate
11767c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: boot.S,  Next: kernel.c,  Prev: multiboot.h,  Up: Example OS code
11777c478bd9Sstevel@tonic-gate
1178*1b8adde7SWilliam Kucharski4.3.2 boot.S
1179*1b8adde7SWilliam Kucharski------------
11807c478bd9Sstevel@tonic-gate
1181*1b8adde7SWilliam KucharskiIn the file `boot.S':
11827c478bd9Sstevel@tonic-gate
11837c478bd9Sstevel@tonic-gate     /* boot.S - bootstrap the kernel */
11847c478bd9Sstevel@tonic-gate     /* Copyright (C) 1999, 2001  Free Software Foundation, Inc.
1185*1b8adde7SWilliam Kucharski
11867c478bd9Sstevel@tonic-gate        This program is free software; you can redistribute it and/or modify
11877c478bd9Sstevel@tonic-gate        it under the terms of the GNU General Public License as published by
11887c478bd9Sstevel@tonic-gate        the Free Software Foundation; either version 2 of the License, or
11897c478bd9Sstevel@tonic-gate        (at your option) any later version.
1190*1b8adde7SWilliam Kucharski
11917c478bd9Sstevel@tonic-gate        This program is distributed in the hope that it will be useful,
11927c478bd9Sstevel@tonic-gate        but WITHOUT ANY WARRANTY; without even the implied warranty of
11937c478bd9Sstevel@tonic-gate        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11947c478bd9Sstevel@tonic-gate        GNU General Public License for more details.
1195*1b8adde7SWilliam Kucharski
11967c478bd9Sstevel@tonic-gate        You should have received a copy of the GNU General Public License
11977c478bd9Sstevel@tonic-gate        along with this program; if not, write to the Free Software
11987c478bd9Sstevel@tonic-gate        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
1199*1b8adde7SWilliam Kucharski
12007c478bd9Sstevel@tonic-gate     #define ASM     1
12017c478bd9Sstevel@tonic-gate     #include <multiboot.h>
1202*1b8adde7SWilliam Kucharski
12037c478bd9Sstevel@tonic-gate             .text
1204*1b8adde7SWilliam Kucharski
12057c478bd9Sstevel@tonic-gate             .globl  start, _start
12067c478bd9Sstevel@tonic-gate     start:
12077c478bd9Sstevel@tonic-gate     _start:
12087c478bd9Sstevel@tonic-gate             jmp     multiboot_entry
1209*1b8adde7SWilliam Kucharski
12107c478bd9Sstevel@tonic-gate             /* Align 32 bits boundary. */
12117c478bd9Sstevel@tonic-gate             .align  4
1212*1b8adde7SWilliam Kucharski
12137c478bd9Sstevel@tonic-gate             /* Multiboot header. */
12147c478bd9Sstevel@tonic-gate     multiboot_header:
12157c478bd9Sstevel@tonic-gate             /* magic */
12167c478bd9Sstevel@tonic-gate             .long   MULTIBOOT_HEADER_MAGIC
12177c478bd9Sstevel@tonic-gate             /* flags */
12187c478bd9Sstevel@tonic-gate             .long   MULTIBOOT_HEADER_FLAGS
12197c478bd9Sstevel@tonic-gate             /* checksum */
12207c478bd9Sstevel@tonic-gate             .long   -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
12217c478bd9Sstevel@tonic-gate     #ifndef __ELF__
12227c478bd9Sstevel@tonic-gate             /* header_addr */
12237c478bd9Sstevel@tonic-gate             .long   multiboot_header
12247c478bd9Sstevel@tonic-gate             /* load_addr */
12257c478bd9Sstevel@tonic-gate             .long   _start
12267c478bd9Sstevel@tonic-gate             /* load_end_addr */
12277c478bd9Sstevel@tonic-gate             .long   _edata
12287c478bd9Sstevel@tonic-gate             /* bss_end_addr */
12297c478bd9Sstevel@tonic-gate             .long   _end
12307c478bd9Sstevel@tonic-gate             /* entry_addr */
12317c478bd9Sstevel@tonic-gate             .long   multiboot_entry
12327c478bd9Sstevel@tonic-gate     #endif /* ! __ELF__ */
1233*1b8adde7SWilliam Kucharski
12347c478bd9Sstevel@tonic-gate     multiboot_entry:
12357c478bd9Sstevel@tonic-gate             /* Initialize the stack pointer. */
12367c478bd9Sstevel@tonic-gate             movl    $(stack + STACK_SIZE), %esp
1237*1b8adde7SWilliam Kucharski
12387c478bd9Sstevel@tonic-gate             /* Reset EFLAGS. */
12397c478bd9Sstevel@tonic-gate             pushl   $0
12407c478bd9Sstevel@tonic-gate             popf
1241*1b8adde7SWilliam Kucharski
12427c478bd9Sstevel@tonic-gate             /* Push the pointer to the Multiboot information structure. */
12437c478bd9Sstevel@tonic-gate             pushl   %ebx
12447c478bd9Sstevel@tonic-gate             /* Push the magic value. */
12457c478bd9Sstevel@tonic-gate             pushl   %eax
1246*1b8adde7SWilliam Kucharski
12477c478bd9Sstevel@tonic-gate             /* Now enter the C main function... */
12487c478bd9Sstevel@tonic-gate             call    EXT_C(cmain)
1249*1b8adde7SWilliam Kucharski
12507c478bd9Sstevel@tonic-gate             /* Halt. */
12517c478bd9Sstevel@tonic-gate             pushl   $halt_message
12527c478bd9Sstevel@tonic-gate             call    EXT_C(printf)
1253*1b8adde7SWilliam Kucharski
12547c478bd9Sstevel@tonic-gate     loop:   hlt
12557c478bd9Sstevel@tonic-gate             jmp     loop
1256*1b8adde7SWilliam Kucharski
12577c478bd9Sstevel@tonic-gate     halt_message:
12587c478bd9Sstevel@tonic-gate             .asciz  "Halted."
1259*1b8adde7SWilliam Kucharski
12607c478bd9Sstevel@tonic-gate             /* Our stack area. */
12617c478bd9Sstevel@tonic-gate             .comm   stack, STACK_SIZE
12627c478bd9Sstevel@tonic-gate
12637c478bd9Sstevel@tonic-gate
12647c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: kernel.c,  Next: Other Multiboot kernels,  Prev: boot.S,  Up: Example OS code
12657c478bd9Sstevel@tonic-gate
1266*1b8adde7SWilliam Kucharski4.3.3 kernel.c
1267*1b8adde7SWilliam Kucharski--------------
12687c478bd9Sstevel@tonic-gate
1269*1b8adde7SWilliam KucharskiAnd, in the file `kernel.c':
12707c478bd9Sstevel@tonic-gate
12717c478bd9Sstevel@tonic-gate     /* kernel.c - the C part of the kernel */
12727c478bd9Sstevel@tonic-gate     /* Copyright (C) 1999  Free Software Foundation, Inc.
1273*1b8adde7SWilliam Kucharski
12747c478bd9Sstevel@tonic-gate        This program is free software; you can redistribute it and/or modify
12757c478bd9Sstevel@tonic-gate        it under the terms of the GNU General Public License as published by
12767c478bd9Sstevel@tonic-gate        the Free Software Foundation; either version 2 of the License, or
12777c478bd9Sstevel@tonic-gate        (at your option) any later version.
1278*1b8adde7SWilliam Kucharski
12797c478bd9Sstevel@tonic-gate        This program is distributed in the hope that it will be useful,
12807c478bd9Sstevel@tonic-gate        but WITHOUT ANY WARRANTY; without even the implied warranty of
12817c478bd9Sstevel@tonic-gate        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12827c478bd9Sstevel@tonic-gate        GNU General Public License for more details.
1283*1b8adde7SWilliam Kucharski
12847c478bd9Sstevel@tonic-gate        You should have received a copy of the GNU General Public License
12857c478bd9Sstevel@tonic-gate        along with this program; if not, write to the Free Software
12867c478bd9Sstevel@tonic-gate        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
1287*1b8adde7SWilliam Kucharski
12887c478bd9Sstevel@tonic-gate     #include <multiboot.h>
1289*1b8adde7SWilliam Kucharski
12907c478bd9Sstevel@tonic-gate     /* Macros. */
1291*1b8adde7SWilliam Kucharski
12927c478bd9Sstevel@tonic-gate     /* Check if the bit BIT in FLAGS is set. */
12937c478bd9Sstevel@tonic-gate     #define CHECK_FLAG(flags,bit)   ((flags) & (1 << (bit)))
1294*1b8adde7SWilliam Kucharski
12957c478bd9Sstevel@tonic-gate     /* Some screen stuff. */
12967c478bd9Sstevel@tonic-gate     /* The number of columns. */
12977c478bd9Sstevel@tonic-gate     #define COLUMNS                 80
12987c478bd9Sstevel@tonic-gate     /* The number of lines. */
12997c478bd9Sstevel@tonic-gate     #define LINES                   24
13007c478bd9Sstevel@tonic-gate     /* The attribute of an character. */
13017c478bd9Sstevel@tonic-gate     #define ATTRIBUTE               7
13027c478bd9Sstevel@tonic-gate     /* The video memory address. */
13037c478bd9Sstevel@tonic-gate     #define VIDEO                   0xB8000
1304*1b8adde7SWilliam Kucharski
13057c478bd9Sstevel@tonic-gate     /* Variables. */
13067c478bd9Sstevel@tonic-gate     /* Save the X position. */
13077c478bd9Sstevel@tonic-gate     static int xpos;
13087c478bd9Sstevel@tonic-gate     /* Save the Y position. */
13097c478bd9Sstevel@tonic-gate     static int ypos;
13107c478bd9Sstevel@tonic-gate     /* Point to the video memory. */
13117c478bd9Sstevel@tonic-gate     static volatile unsigned char *video;
1312*1b8adde7SWilliam Kucharski
13137c478bd9Sstevel@tonic-gate     /* Forward declarations. */
13147c478bd9Sstevel@tonic-gate     void cmain (unsigned long magic, unsigned long addr);
13157c478bd9Sstevel@tonic-gate     static void cls (void);
13167c478bd9Sstevel@tonic-gate     static void itoa (char *buf, int base, int d);
13177c478bd9Sstevel@tonic-gate     static void putchar (int c);
13187c478bd9Sstevel@tonic-gate     void printf (const char *format, ...);
1319*1b8adde7SWilliam Kucharski
13207c478bd9Sstevel@tonic-gate     /* Check if MAGIC is valid and print the Multiboot information structure
13217c478bd9Sstevel@tonic-gate        pointed by ADDR. */
13227c478bd9Sstevel@tonic-gate     void
13237c478bd9Sstevel@tonic-gate     cmain (unsigned long magic, unsigned long addr)
13247c478bd9Sstevel@tonic-gate     {
13257c478bd9Sstevel@tonic-gate       multiboot_info_t *mbi;
1326*1b8adde7SWilliam Kucharski
13277c478bd9Sstevel@tonic-gate       /* Clear the screen. */
13287c478bd9Sstevel@tonic-gate       cls ();
1329*1b8adde7SWilliam Kucharski
13307c478bd9Sstevel@tonic-gate       /* Am I booted by a Multiboot-compliant boot loader? */
13317c478bd9Sstevel@tonic-gate       if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
13327c478bd9Sstevel@tonic-gate         {
13337c478bd9Sstevel@tonic-gate           printf ("Invalid magic number: 0x%x\n", (unsigned) magic);
13347c478bd9Sstevel@tonic-gate           return;
13357c478bd9Sstevel@tonic-gate         }
1336*1b8adde7SWilliam Kucharski
13377c478bd9Sstevel@tonic-gate       /* Set MBI to the address of the Multiboot information structure. */
13387c478bd9Sstevel@tonic-gate       mbi = (multiboot_info_t *) addr;
1339*1b8adde7SWilliam Kucharski
13407c478bd9Sstevel@tonic-gate       /* Print out the flags. */
13417c478bd9Sstevel@tonic-gate       printf ("flags = 0x%x\n", (unsigned) mbi->flags);
1342*1b8adde7SWilliam Kucharski
13437c478bd9Sstevel@tonic-gate       /* Are mem_* valid? */
13447c478bd9Sstevel@tonic-gate       if (CHECK_FLAG (mbi->flags, 0))
13457c478bd9Sstevel@tonic-gate         printf ("mem_lower = %uKB, mem_upper = %uKB\n",
13467c478bd9Sstevel@tonic-gate                 (unsigned) mbi->mem_lower, (unsigned) mbi->mem_upper);
1347*1b8adde7SWilliam Kucharski
13487c478bd9Sstevel@tonic-gate       /* Is boot_device valid? */
13497c478bd9Sstevel@tonic-gate       if (CHECK_FLAG (mbi->flags, 1))
13507c478bd9Sstevel@tonic-gate         printf ("boot_device = 0x%x\n", (unsigned) mbi->boot_device);
1351*1b8adde7SWilliam Kucharski
13527c478bd9Sstevel@tonic-gate       /* Is the command line passed? */
13537c478bd9Sstevel@tonic-gate       if (CHECK_FLAG (mbi->flags, 2))
13547c478bd9Sstevel@tonic-gate         printf ("cmdline = %s\n", (char *) mbi->cmdline);
1355*1b8adde7SWilliam Kucharski
13567c478bd9Sstevel@tonic-gate       /* Are mods_* valid? */
13577c478bd9Sstevel@tonic-gate       if (CHECK_FLAG (mbi->flags, 3))
13587c478bd9Sstevel@tonic-gate         {
13597c478bd9Sstevel@tonic-gate           module_t *mod;
13607c478bd9Sstevel@tonic-gate           int i;
1361*1b8adde7SWilliam Kucharski
13627c478bd9Sstevel@tonic-gate           printf ("mods_count = %d, mods_addr = 0x%x\n",
13637c478bd9Sstevel@tonic-gate                   (int) mbi->mods_count, (int) mbi->mods_addr);
13647c478bd9Sstevel@tonic-gate           for (i = 0, mod = (module_t *) mbi->mods_addr;
13657c478bd9Sstevel@tonic-gate                i < mbi->mods_count;
13667c478bd9Sstevel@tonic-gate                i++, mod++)
13677c478bd9Sstevel@tonic-gate             printf (" mod_start = 0x%x, mod_end = 0x%x, string = %s\n",
13687c478bd9Sstevel@tonic-gate                     (unsigned) mod->mod_start,
13697c478bd9Sstevel@tonic-gate                     (unsigned) mod->mod_end,
13707c478bd9Sstevel@tonic-gate                     (char *) mod->string);
13717c478bd9Sstevel@tonic-gate         }
1372*1b8adde7SWilliam Kucharski
13737c478bd9Sstevel@tonic-gate       /* Bits 4 and 5 are mutually exclusive! */
13747c478bd9Sstevel@tonic-gate       if (CHECK_FLAG (mbi->flags, 4) && CHECK_FLAG (mbi->flags, 5))
13757c478bd9Sstevel@tonic-gate         {
13767c478bd9Sstevel@tonic-gate           printf ("Both bits 4 and 5 are set.\n");
13777c478bd9Sstevel@tonic-gate           return;
13787c478bd9Sstevel@tonic-gate         }
1379*1b8adde7SWilliam Kucharski
13807c478bd9Sstevel@tonic-gate       /* Is the symbol table of a.out valid? */
13817c478bd9Sstevel@tonic-gate       if (CHECK_FLAG (mbi->flags, 4))
13827c478bd9Sstevel@tonic-gate         {
13837c478bd9Sstevel@tonic-gate           aout_symbol_table_t *aout_sym = &(mbi->u.aout_sym);
1384*1b8adde7SWilliam Kucharski
13857c478bd9Sstevel@tonic-gate           printf ("aout_symbol_table: tabsize = 0x%0x, "
13867c478bd9Sstevel@tonic-gate                   "strsize = 0x%x, addr = 0x%x\n",
13877c478bd9Sstevel@tonic-gate                   (unsigned) aout_sym->tabsize,
13887c478bd9Sstevel@tonic-gate                   (unsigned) aout_sym->strsize,
13897c478bd9Sstevel@tonic-gate                   (unsigned) aout_sym->addr);
13907c478bd9Sstevel@tonic-gate         }
1391*1b8adde7SWilliam Kucharski
13927c478bd9Sstevel@tonic-gate       /* Is the section header table of ELF valid? */
13937c478bd9Sstevel@tonic-gate       if (CHECK_FLAG (mbi->flags, 5))
13947c478bd9Sstevel@tonic-gate         {
13957c478bd9Sstevel@tonic-gate           elf_section_header_table_t *elf_sec = &(mbi->u.elf_sec);
1396*1b8adde7SWilliam Kucharski
13977c478bd9Sstevel@tonic-gate           printf ("elf_sec: num = %u, size = 0x%x,"
13987c478bd9Sstevel@tonic-gate                   " addr = 0x%x, shndx = 0x%x\n",
13997c478bd9Sstevel@tonic-gate                   (unsigned) elf_sec->num, (unsigned) elf_sec->size,
14007c478bd9Sstevel@tonic-gate                   (unsigned) elf_sec->addr, (unsigned) elf_sec->shndx);
14017c478bd9Sstevel@tonic-gate         }
1402*1b8adde7SWilliam Kucharski
14037c478bd9Sstevel@tonic-gate       /* Are mmap_* valid? */
14047c478bd9Sstevel@tonic-gate       if (CHECK_FLAG (mbi->flags, 6))
14057c478bd9Sstevel@tonic-gate         {
14067c478bd9Sstevel@tonic-gate           memory_map_t *mmap;
1407*1b8adde7SWilliam Kucharski
14087c478bd9Sstevel@tonic-gate           printf ("mmap_addr = 0x%x, mmap_length = 0x%x\n",
14097c478bd9Sstevel@tonic-gate                   (unsigned) mbi->mmap_addr, (unsigned) mbi->mmap_length);
14107c478bd9Sstevel@tonic-gate           for (mmap = (memory_map_t *) mbi->mmap_addr;
14117c478bd9Sstevel@tonic-gate                (unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
14127c478bd9Sstevel@tonic-gate                mmap = (memory_map_t *) ((unsigned long) mmap
14137c478bd9Sstevel@tonic-gate                                         + mmap->size + sizeof (mmap->size)))
14147c478bd9Sstevel@tonic-gate             printf (" size = 0x%x, base_addr = 0x%x%x,"
14157c478bd9Sstevel@tonic-gate                     " length = 0x%x%x, type = 0x%x\n",
14167c478bd9Sstevel@tonic-gate                     (unsigned) mmap->size,
14177c478bd9Sstevel@tonic-gate                     (unsigned) mmap->base_addr_high,
14187c478bd9Sstevel@tonic-gate                     (unsigned) mmap->base_addr_low,
14197c478bd9Sstevel@tonic-gate                     (unsigned) mmap->length_high,
14207c478bd9Sstevel@tonic-gate                     (unsigned) mmap->length_low,
14217c478bd9Sstevel@tonic-gate                     (unsigned) mmap->type);
14227c478bd9Sstevel@tonic-gate         }
14237c478bd9Sstevel@tonic-gate     }
1424*1b8adde7SWilliam Kucharski
14257c478bd9Sstevel@tonic-gate     /* Clear the screen and initialize VIDEO, XPOS and YPOS. */
14267c478bd9Sstevel@tonic-gate     static void
14277c478bd9Sstevel@tonic-gate     cls (void)
14287c478bd9Sstevel@tonic-gate     {
14297c478bd9Sstevel@tonic-gate       int i;
1430*1b8adde7SWilliam Kucharski
14317c478bd9Sstevel@tonic-gate       video = (unsigned char *) VIDEO;
1432*1b8adde7SWilliam Kucharski
14337c478bd9Sstevel@tonic-gate       for (i = 0; i < COLUMNS * LINES * 2; i++)
14347c478bd9Sstevel@tonic-gate         *(video + i) = 0;
1435*1b8adde7SWilliam Kucharski
14367c478bd9Sstevel@tonic-gate       xpos = 0;
14377c478bd9Sstevel@tonic-gate       ypos = 0;
14387c478bd9Sstevel@tonic-gate     }
1439*1b8adde7SWilliam Kucharski
14407c478bd9Sstevel@tonic-gate     /* Convert the integer D to a string and save the string in BUF. If
14417c478bd9Sstevel@tonic-gate        BASE is equal to 'd', interpret that D is decimal, and if BASE is
14427c478bd9Sstevel@tonic-gate        equal to 'x', interpret that D is hexadecimal. */
14437c478bd9Sstevel@tonic-gate     static void
14447c478bd9Sstevel@tonic-gate     itoa (char *buf, int base, int d)
14457c478bd9Sstevel@tonic-gate     {
14467c478bd9Sstevel@tonic-gate       char *p = buf;
14477c478bd9Sstevel@tonic-gate       char *p1, *p2;
14487c478bd9Sstevel@tonic-gate       unsigned long ud = d;
14497c478bd9Sstevel@tonic-gate       int divisor = 10;
1450*1b8adde7SWilliam Kucharski
14517c478bd9Sstevel@tonic-gate       /* If %d is specified and D is minus, put `-' in the head. */
14527c478bd9Sstevel@tonic-gate       if (base == 'd' && d < 0)
14537c478bd9Sstevel@tonic-gate         {
14547c478bd9Sstevel@tonic-gate           *p++ = '-';
14557c478bd9Sstevel@tonic-gate           buf++;
14567c478bd9Sstevel@tonic-gate           ud = -d;
14577c478bd9Sstevel@tonic-gate         }
14587c478bd9Sstevel@tonic-gate       else if (base == 'x')
14597c478bd9Sstevel@tonic-gate         divisor = 16;
1460*1b8adde7SWilliam Kucharski
14617c478bd9Sstevel@tonic-gate       /* Divide UD by DIVISOR until UD == 0. */
14627c478bd9Sstevel@tonic-gate       do
14637c478bd9Sstevel@tonic-gate         {
14647c478bd9Sstevel@tonic-gate           int remainder = ud % divisor;
1465*1b8adde7SWilliam Kucharski
14667c478bd9Sstevel@tonic-gate           *p++ = (remainder < 10) ? remainder + '0' : remainder + 'a' - 10;
14677c478bd9Sstevel@tonic-gate         }
14687c478bd9Sstevel@tonic-gate       while (ud /= divisor);
1469*1b8adde7SWilliam Kucharski
14707c478bd9Sstevel@tonic-gate       /* Terminate BUF. */
14717c478bd9Sstevel@tonic-gate       *p = 0;
1472*1b8adde7SWilliam Kucharski
14737c478bd9Sstevel@tonic-gate       /* Reverse BUF. */
14747c478bd9Sstevel@tonic-gate       p1 = buf;
14757c478bd9Sstevel@tonic-gate       p2 = p - 1;
14767c478bd9Sstevel@tonic-gate       while (p1 < p2)
14777c478bd9Sstevel@tonic-gate         {
14787c478bd9Sstevel@tonic-gate           char tmp = *p1;
14797c478bd9Sstevel@tonic-gate           *p1 = *p2;
14807c478bd9Sstevel@tonic-gate           *p2 = tmp;
14817c478bd9Sstevel@tonic-gate           p1++;
14827c478bd9Sstevel@tonic-gate           p2--;
14837c478bd9Sstevel@tonic-gate         }
14847c478bd9Sstevel@tonic-gate     }
1485*1b8adde7SWilliam Kucharski
14867c478bd9Sstevel@tonic-gate     /* Put the character C on the screen. */
14877c478bd9Sstevel@tonic-gate     static void
14887c478bd9Sstevel@tonic-gate     putchar (int c)
14897c478bd9Sstevel@tonic-gate     {
14907c478bd9Sstevel@tonic-gate       if (c == '\n' || c == '\r')
14917c478bd9Sstevel@tonic-gate         {
14927c478bd9Sstevel@tonic-gate         newline:
14937c478bd9Sstevel@tonic-gate           xpos = 0;
14947c478bd9Sstevel@tonic-gate           ypos++;
14957c478bd9Sstevel@tonic-gate           if (ypos >= LINES)
14967c478bd9Sstevel@tonic-gate             ypos = 0;
14977c478bd9Sstevel@tonic-gate           return;
14987c478bd9Sstevel@tonic-gate         }
1499*1b8adde7SWilliam Kucharski
15007c478bd9Sstevel@tonic-gate       *(video + (xpos + ypos * COLUMNS) * 2) = c & 0xFF;
15017c478bd9Sstevel@tonic-gate       *(video + (xpos + ypos * COLUMNS) * 2 + 1) = ATTRIBUTE;
1502*1b8adde7SWilliam Kucharski
15037c478bd9Sstevel@tonic-gate       xpos++;
15047c478bd9Sstevel@tonic-gate       if (xpos >= COLUMNS)
15057c478bd9Sstevel@tonic-gate         goto newline;
15067c478bd9Sstevel@tonic-gate     }
1507*1b8adde7SWilliam Kucharski
15087c478bd9Sstevel@tonic-gate     /* Format a string and print it on the screen, just like the libc
15097c478bd9Sstevel@tonic-gate        function printf. */
15107c478bd9Sstevel@tonic-gate     void
15117c478bd9Sstevel@tonic-gate     printf (const char *format, ...)
15127c478bd9Sstevel@tonic-gate     {
15137c478bd9Sstevel@tonic-gate       char **arg = (char **) &format;
15147c478bd9Sstevel@tonic-gate       int c;
15157c478bd9Sstevel@tonic-gate       char buf[20];
1516*1b8adde7SWilliam Kucharski
15177c478bd9Sstevel@tonic-gate       arg++;
1518*1b8adde7SWilliam Kucharski
15197c478bd9Sstevel@tonic-gate       while ((c = *format++) != 0)
15207c478bd9Sstevel@tonic-gate         {
15217c478bd9Sstevel@tonic-gate           if (c != '%')
15227c478bd9Sstevel@tonic-gate             putchar (c);
15237c478bd9Sstevel@tonic-gate           else
15247c478bd9Sstevel@tonic-gate             {
15257c478bd9Sstevel@tonic-gate               char *p;
1526*1b8adde7SWilliam Kucharski
15277c478bd9Sstevel@tonic-gate               c = *format++;
15287c478bd9Sstevel@tonic-gate               switch (c)
15297c478bd9Sstevel@tonic-gate                 {
15307c478bd9Sstevel@tonic-gate                 case 'd':
15317c478bd9Sstevel@tonic-gate                 case 'u':
15327c478bd9Sstevel@tonic-gate                 case 'x':
15337c478bd9Sstevel@tonic-gate                   itoa (buf, c, *((int *) arg++));
15347c478bd9Sstevel@tonic-gate                   p = buf;
15357c478bd9Sstevel@tonic-gate                   goto string;
15367c478bd9Sstevel@tonic-gate                   break;
1537*1b8adde7SWilliam Kucharski
15387c478bd9Sstevel@tonic-gate                 case 's':
15397c478bd9Sstevel@tonic-gate                   p = *arg++;
15407c478bd9Sstevel@tonic-gate                   if (! p)
15417c478bd9Sstevel@tonic-gate                     p = "(null)";
1542*1b8adde7SWilliam Kucharski
15437c478bd9Sstevel@tonic-gate                 string:
15447c478bd9Sstevel@tonic-gate                   while (*p)
15457c478bd9Sstevel@tonic-gate                     putchar (*p++);
15467c478bd9Sstevel@tonic-gate                   break;
1547*1b8adde7SWilliam Kucharski
15487c478bd9Sstevel@tonic-gate                 default:
15497c478bd9Sstevel@tonic-gate                   putchar (*((int *) arg++));
15507c478bd9Sstevel@tonic-gate                   break;
15517c478bd9Sstevel@tonic-gate                 }
15527c478bd9Sstevel@tonic-gate             }
15537c478bd9Sstevel@tonic-gate         }
15547c478bd9Sstevel@tonic-gate     }
15557c478bd9Sstevel@tonic-gate
15567c478bd9Sstevel@tonic-gate
15577c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Other Multiboot kernels,  Prev: kernel.c,  Up: Example OS code
15587c478bd9Sstevel@tonic-gate
1559*1b8adde7SWilliam Kucharski4.3.4 Other Multiboot kernels
1560*1b8adde7SWilliam Kucharski-----------------------------
15617c478bd9Sstevel@tonic-gate
1562*1b8adde7SWilliam KucharskiOther useful information should be available in Multiboot kernels, such
1563*1b8adde7SWilliam Kucharskias GNU Mach and Fiasco `http://os.inf.tu-dresden.de/fiasco/'. And, it
1564*1b8adde7SWilliam Kucharskiis worth mentioning the OSKit
1565*1b8adde7SWilliam Kucharski`http://www.cs.utah.edu/projects/flux/oskit/', which provides a library
15667c478bd9Sstevel@tonic-gatesupporting the specification.
15677c478bd9Sstevel@tonic-gate
15687c478bd9Sstevel@tonic-gate
15697c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Example boot loader code,  Prev: Example OS code,  Up: Examples
15707c478bd9Sstevel@tonic-gate
1571*1b8adde7SWilliam Kucharski4.4 Example boot loader code
1572*1b8adde7SWilliam Kucharski============================
15737c478bd9Sstevel@tonic-gate
1574*1b8adde7SWilliam KucharskiThe GNU GRUB (*note GRUB: (grub.info)Top.) project is a full
15757c478bd9Sstevel@tonic-gateMultiboot-compliant boot loader, supporting all required and optional
15767c478bd9Sstevel@tonic-gatefeatures present in this specification. A public release has not been
15777c478bd9Sstevel@tonic-gatemade, but the test release is available from:
15787c478bd9Sstevel@tonic-gate
1579*1b8adde7SWilliam Kucharski   `ftp://alpha.gnu.org/gnu/grub'
15807c478bd9Sstevel@tonic-gate
1581*1b8adde7SWilliam Kucharski   See the webpage `http://www.gnu.org/software/grub/grub.html', for
15827c478bd9Sstevel@tonic-gatemore information.
15837c478bd9Sstevel@tonic-gate
15847c478bd9Sstevel@tonic-gate
15857c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: History,  Next: Index,  Prev: Examples,  Up: Top
15867c478bd9Sstevel@tonic-gate
1587*1b8adde7SWilliam Kucharski5 The change log of this specification
1588*1b8adde7SWilliam Kucharski**************************************
15897c478bd9Sstevel@tonic-gate
15907c478bd9Sstevel@tonic-gate0.7
15917c478bd9Sstevel@tonic-gate        * "Multiboot Standard" is renamed to "Multiboot Specification".
15927c478bd9Sstevel@tonic-gate
15937c478bd9Sstevel@tonic-gate        * Graphics fields are added to Multiboot header.
15947c478bd9Sstevel@tonic-gate
15957c478bd9Sstevel@tonic-gate        * BIOS drive information, BIOS configuration table, the name of
15967c478bd9Sstevel@tonic-gate          a boot loader, APM information, and graphics information are
15977c478bd9Sstevel@tonic-gate          added to Multiboot information.
15987c478bd9Sstevel@tonic-gate
15997c478bd9Sstevel@tonic-gate        * Rewritten in Texinfo format.
16007c478bd9Sstevel@tonic-gate
16017c478bd9Sstevel@tonic-gate        * Rewritten, using more strict words.
16027c478bd9Sstevel@tonic-gate
16037c478bd9Sstevel@tonic-gate        * The maintainer changes to the GNU GRUB maintainer team
16047c478bd9Sstevel@tonic-gate          <bug-grub@gnu.org>, from Bryan Ford and Erich Stefan Boleyn.
16057c478bd9Sstevel@tonic-gate
16067c478bd9Sstevel@tonic-gate0.6
16077c478bd9Sstevel@tonic-gate        * A few wording changes.
16087c478bd9Sstevel@tonic-gate
16097c478bd9Sstevel@tonic-gate        * Header checksum.
16107c478bd9Sstevel@tonic-gate
16117c478bd9Sstevel@tonic-gate        * Clasification of machine state passed to an operating system.
16127c478bd9Sstevel@tonic-gate
16137c478bd9Sstevel@tonic-gate0.5
16147c478bd9Sstevel@tonic-gate        * Name change.
16157c478bd9Sstevel@tonic-gate
16167c478bd9Sstevel@tonic-gate0.4
16177c478bd9Sstevel@tonic-gate        * Major changes plus HTMLification.
16187c478bd9Sstevel@tonic-gate
16197c478bd9Sstevel@tonic-gate
16207c478bd9Sstevel@tonic-gateFile: multiboot.info,  Node: Index,  Prev: History,  Up: Top
16217c478bd9Sstevel@tonic-gate
16227c478bd9Sstevel@tonic-gateIndex
16237c478bd9Sstevel@tonic-gate*****
16247c478bd9Sstevel@tonic-gate
1625*1b8adde7SWilliam Kucharski[Index]
16267c478bd9Sstevel@tonic-gate* Menu:
16277c478bd9Sstevel@tonic-gate
16287c478bd9Sstevel@tonic-gate
16297c478bd9Sstevel@tonic-gateTag Table:
1630*1b8adde7SWilliam KucharskiNode: Top990
1631*1b8adde7SWilliam KucharskiNode: Overview1326
1632*1b8adde7SWilliam KucharskiNode: Motivation1794
1633*1b8adde7SWilliam KucharskiNode: Architecture3191
1634*1b8adde7SWilliam KucharskiNode: Operating systems3724
1635*1b8adde7SWilliam KucharskiNode: Boot sources4518
1636*1b8adde7SWilliam KucharskiNode: Boot-time configuration5488
1637*1b8adde7SWilliam KucharskiNode: Convenience to operating systems6096
1638*1b8adde7SWilliam KucharskiNode: Boot modules8327
1639*1b8adde7SWilliam KucharskiNode: Terminology9476
1640*1b8adde7SWilliam KucharskiNode: Specification11855
1641*1b8adde7SWilliam KucharskiNode: OS image format12418
1642*1b8adde7SWilliam KucharskiNode: Header layout13476
1643*1b8adde7SWilliam KucharskiNode: Header magic fields14644
1644*1b8adde7SWilliam KucharskiNode: Header address fields17505
1645*1b8adde7SWilliam KucharskiNode: Header graphics fields19351
1646*1b8adde7SWilliam KucharskiNode: Machine state20737
1647*1b8adde7SWilliam KucharskiNode: Boot information format22997
1648*1b8adde7SWilliam KucharskiNode: Examples38368
1649*1b8adde7SWilliam KucharskiNode: Notes on PC38741
1650*1b8adde7SWilliam KucharskiNode: BIOS device mapping techniques40307
1651*1b8adde7SWilliam KucharskiNode: Data comparison technique41217
1652*1b8adde7SWilliam KucharskiNode: I/O restriction technique42079
1653*1b8adde7SWilliam KucharskiNode: Example OS code43296
1654*1b8adde7SWilliam KucharskiNode: multiboot.h44838
1655*1b8adde7SWilliam KucharskiNode: boot.S48662
1656*1b8adde7SWilliam KucharskiNode: kernel.c51286
1657*1b8adde7SWilliam KucharskiNode: Other Multiboot kernels60013
1658*1b8adde7SWilliam KucharskiNode: Example boot loader code60444
1659*1b8adde7SWilliam KucharskiNode: History60970
1660*1b8adde7SWilliam KucharskiNode: Index61891
16617c478bd9Sstevel@tonic-gate
16627c478bd9Sstevel@tonic-gateEnd Tag Table
1663