17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  *  GRUB  --  GRand Unified Bootloader
37c478bd9Sstevel@tonic-gate  *  Copyright (C) 2000   Free Software Foundation, Inc.
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  *  This program is free software; you can redistribute it and/or modify
67c478bd9Sstevel@tonic-gate  *  it under the terms of the GNU General Public License as published by
77c478bd9Sstevel@tonic-gate  *  the Free Software Foundation; either version 2 of the License, or
87c478bd9Sstevel@tonic-gate  *  (at your option) any later version.
97c478bd9Sstevel@tonic-gate  *
107c478bd9Sstevel@tonic-gate  *  This program is distributed in the hope that it will be useful,
117c478bd9Sstevel@tonic-gate  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
127c478bd9Sstevel@tonic-gate  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
137c478bd9Sstevel@tonic-gate  *  GNU General Public License for more details.
147c478bd9Sstevel@tonic-gate  *
157c478bd9Sstevel@tonic-gate  *  You should have received a copy of the GNU General Public License
167c478bd9Sstevel@tonic-gate  *  along with this program; if not, write to the Free Software
177c478bd9Sstevel@tonic-gate  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
187c478bd9Sstevel@tonic-gate  */
197c478bd9Sstevel@tonic-gate 
207c478bd9Sstevel@tonic-gate /*
217c478bd9Sstevel@tonic-gate  *  MultiBoot Header description
227c478bd9Sstevel@tonic-gate  */
237c478bd9Sstevel@tonic-gate 
247c478bd9Sstevel@tonic-gate struct multiboot_header
257c478bd9Sstevel@tonic-gate {
267c478bd9Sstevel@tonic-gate   /* Must be MULTIBOOT_MAGIC - see below.  */
277c478bd9Sstevel@tonic-gate   unsigned magic;
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate   /* Feature flags - see below.  */
307c478bd9Sstevel@tonic-gate   unsigned flags;
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate   /*
337c478bd9Sstevel@tonic-gate    * Checksum
347c478bd9Sstevel@tonic-gate    *
357c478bd9Sstevel@tonic-gate    * The above fields plus this one must equal 0 mod 2^32.
367c478bd9Sstevel@tonic-gate    */
377c478bd9Sstevel@tonic-gate   unsigned checksum;
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate   /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set.  */
407c478bd9Sstevel@tonic-gate   unsigned header_addr;
417c478bd9Sstevel@tonic-gate   unsigned load_addr;
427c478bd9Sstevel@tonic-gate   unsigned load_end_addr;
437c478bd9Sstevel@tonic-gate   unsigned bss_end_addr;
447c478bd9Sstevel@tonic-gate   unsigned entry_addr;
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate   /* These are only valid if MULTIBOOT_VIDEO_MODE is set.  */
477c478bd9Sstevel@tonic-gate   unsigned mode_type;
487c478bd9Sstevel@tonic-gate   unsigned width;
497c478bd9Sstevel@tonic-gate   unsigned height;
507c478bd9Sstevel@tonic-gate   unsigned depth;
517c478bd9Sstevel@tonic-gate };
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  * The entire multiboot_header must be contained
557c478bd9Sstevel@tonic-gate  * within the first MULTIBOOT_SEARCH bytes of the kernel image.
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate #define MULTIBOOT_SEARCH		8192
587c478bd9Sstevel@tonic-gate #define MULTIBOOT_FOUND(addr, len) \
597c478bd9Sstevel@tonic-gate   (! ((addr) & 0x3) \
607c478bd9Sstevel@tonic-gate    && (len) >= 12 \
617c478bd9Sstevel@tonic-gate    && *((int *) (addr)) == MULTIBOOT_MAGIC \
627c478bd9Sstevel@tonic-gate    && ! (*((unsigned *) (addr)) + *((unsigned *) (addr + 4)) \
637c478bd9Sstevel@tonic-gate 	 + *((unsigned *) (addr + 8))) \
647c478bd9Sstevel@tonic-gate    && (! (MULTIBOOT_AOUT_KLUDGE & *((int *) (addr + 4))) || (len) >= 32) \
657c478bd9Sstevel@tonic-gate    && (! (MULTIBOOT_VIDEO_MODE & *((int *) (addr + 4))) || (len) >= 48))
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /* Magic value identifying the multiboot_header.  */
687c478bd9Sstevel@tonic-gate #define MULTIBOOT_MAGIC			0x1BADB002
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Features flags for 'flags'.
727c478bd9Sstevel@tonic-gate  * If a boot loader sees a flag in MULTIBOOT_MUSTKNOW set
737c478bd9Sstevel@tonic-gate  * and it doesn't understand it, it must fail.
747c478bd9Sstevel@tonic-gate  */
757c478bd9Sstevel@tonic-gate #define MULTIBOOT_MUSTKNOW		0x0000FFFF
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /* currently unsupported flags...  this is a kind of version number.  */
787c478bd9Sstevel@tonic-gate #define MULTIBOOT_UNSUPPORTED		0x0000FFF8
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /* Align all boot modules on i386 page (4KB) boundaries.  */
817c478bd9Sstevel@tonic-gate #define MULTIBOOT_PAGE_ALIGN		0x00000001
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /* Must pass memory information to OS.  */
847c478bd9Sstevel@tonic-gate #define MULTIBOOT_MEMORY_INFO		0x00000002
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /* Must pass video information to OS.  */
877c478bd9Sstevel@tonic-gate #define MULTIBOOT_VIDEO_MODE		0x00000004
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate /* This flag indicates the use of the address fields in the header.  */
907c478bd9Sstevel@tonic-gate #define MULTIBOOT_AOUT_KLUDGE		0x00010000
91