17c478bdstevel@tonic-gate/* shared.h - definitions used in all GRUB-specific code */
27c478bdstevel@tonic-gate/*
37c478bdstevel@tonic-gate *  GRUB  --  GRand Unified Bootloader
47c478bdstevel@tonic-gate *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
57c478bdstevel@tonic-gate *
67c478bdstevel@tonic-gate *  This program is free software; you can redistribute it and/or modify
77c478bdstevel@tonic-gate *  it under the terms of the GNU General Public License as published by
87c478bdstevel@tonic-gate *  the Free Software Foundation; either version 2 of the License, or
97c478bdstevel@tonic-gate *  (at your option) any later version.
107c478bdstevel@tonic-gate *
117c478bdstevel@tonic-gate *  This program is distributed in the hope that it will be useful,
127c478bdstevel@tonic-gate *  but WITHOUT ANY WARRANTY; without even the implied warranty of
137c478bdstevel@tonic-gate *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
147c478bdstevel@tonic-gate *  GNU General Public License for more details.
157c478bdstevel@tonic-gate *
167c478bdstevel@tonic-gate *  You should have received a copy of the GNU General Public License
177c478bdstevel@tonic-gate *  along with this program; if not, write to the Free Software
187c478bdstevel@tonic-gate *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
197c478bdstevel@tonic-gate */
207c478bdstevel@tonic-gate
217c478bdstevel@tonic-gate/*
227c478bdstevel@tonic-gate *  Generic defines to use anywhere
237c478bdstevel@tonic-gate */
247c478bdstevel@tonic-gate
257c478bdstevel@tonic-gate#ifndef GRUB_SHARED_HEADER
267c478bdstevel@tonic-gate#define GRUB_SHARED_HEADER	1
277c478bdstevel@tonic-gate
287c478bdstevel@tonic-gate#include <config.h>
297c478bdstevel@tonic-gate
307c478bdstevel@tonic-gate/* Add an underscore to a C symbol in assembler code if needed. */
317c478bdstevel@tonic-gate#ifdef HAVE_ASM_USCORE
327c478bdstevel@tonic-gate# define EXT_C(sym) _ ## sym
337c478bdstevel@tonic-gate#else
347c478bdstevel@tonic-gate# define EXT_C(sym) sym
357c478bdstevel@tonic-gate#endif
367c478bdstevel@tonic-gate
377c478bdstevel@tonic-gate/* Maybe redirect memory requests through grub_scratch_mem. */
387c478bdstevel@tonic-gate#ifdef GRUB_UTIL
397c478bdstevel@tonic-gateextern char *grub_scratch_mem;
407c478bdstevel@tonic-gate# define RAW_ADDR(x) ((x) + (int) grub_scratch_mem)
417c478bdstevel@tonic-gate# define RAW_SEG(x) (RAW_ADDR ((x) << 4) >> 4)
427c478bdstevel@tonic-gate#else
437c478bdstevel@tonic-gate# define RAW_ADDR(x) (x)
447c478bdstevel@tonic-gate# define RAW_SEG(x) (x)
457c478bdstevel@tonic-gate#endif
467c478bdstevel@tonic-gate
47843e198johnlev/* ZFS will use the top 4 Meg of physical memory (below 4Gig) for sratch */
48843e198johnlev#define ZFS_SCRATCH_SIZE 0x400000
49843e198johnlev
50ffb5616Lin Ling#ifndef MAXPATHLEN
51ffb5616Lin Ling#define	MAXPATHLEN	1024
52ffb5616Lin Ling#endif
53ffb5616Lin Ling
54b1b8ab3lling#define	MAXNAMELEN	256
55b1b8ab3lling#define MIN(x, y) ((x) < (y) ? (x) : (y))
56b1b8ab3lling
57eb2bd66vikram/* Boot signature related defines for the findroot command */
58eb2bd66vikram#define	BOOTSIGN_DIR	"/boot/grub/bootsign"
59eb2bd66vikram#define	BOOTSIGN_ARGLEN	(MAXNAMELEN + 10)	/* (<sign>,0,d) */
60eb2bd66vikram#define	BOOTSIGN_LEN	(sizeof (BOOTSIGN_DIR) + 1 + BOOTSIGN_ARGLEN)
61eb2bd66vikram#define	BOOTSIGN_BACKUP	"/etc/bootsign"
62eb2bd66vikram
637c478bdstevel@tonic-gate/*
647c478bdstevel@tonic-gate *  Integer sizes
657c478bdstevel@tonic-gate */
667c478bdstevel@tonic-gate
677c478bdstevel@tonic-gate#define MAXINT     0x7FFFFFFF
68828d47cShidokht Yadegari#define	MAXUINT		0xFFFFFFFF
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gate/* Maximum command line size. Before you blindly increase this value,
717c478bdstevel@tonic-gate   see the comment in char_io.c (get_cmdline).  */
727c478bdstevel@tonic-gate#define MAX_CMDLINE 1600
737c478bdstevel@tonic-gate#define NEW_HEAPSIZE 1500
747c478bdstevel@tonic-gate
757c478bdstevel@tonic-gate/* 512-byte scratch area */
767c478bdstevel@tonic-gate#define SCRATCHADDR  RAW_ADDR (0x77e00)
777c478bdstevel@tonic-gate#define SCRATCHSEG   RAW_SEG (0x77e0)
787c478bdstevel@tonic-gate
797c478bdstevel@tonic-gate/*
807c478bdstevel@tonic-gate *  This is the location of the raw device buffer.  It is 31.5K
817c478bdstevel@tonic-gate *  in size.
827c478bdstevel@tonic-gate */
837c478bdstevel@tonic-gate
847c478bdstevel@tonic-gate#define BUFFERLEN   0x7e00
857c478bdstevel@tonic-gate#define BUFFERADDR  RAW_ADDR (0x70000)
867c478bdstevel@tonic-gate#define BUFFERSEG   RAW_SEG (0x7000)
877c478bdstevel@tonic-gate
887c478bdstevel@tonic-gate#define BOOT_PART_TABLE	RAW_ADDR (0x07be)
897c478bdstevel@tonic-gate
907c478bdstevel@tonic-gate/*
917c478bdstevel@tonic-gate *  BIOS disk defines
927c478bdstevel@tonic-gate */
937c478bdstevel@tonic-gate#define BIOSDISK_READ			0x0
947c478bdstevel@tonic-gate#define BIOSDISK_WRITE			0x1
957c478bdstevel@tonic-gate#define BIOSDISK_ERROR_GEOMETRY		0x100
969caa148szhou#define BIOSDISK_ERROR_SHORT_IO		0x101
977c478bdstevel@tonic-gate#define BIOSDISK_FLAG_LBA_EXTENSION	0x1
987c478bdstevel@tonic-gate#define BIOSDISK_FLAG_CDROM		0x2
997c478bdstevel@tonic-gate
1007c478bdstevel@tonic-gate/*
1017c478bdstevel@tonic-gate *  This is the filesystem (not raw device) buffer.
1027c478bdstevel@tonic-gate *  It is 32K in size, do not overrun!
1037c478bdstevel@tonic-gate */
1047c478bdstevel@tonic-gate
1057c478bdstevel@tonic-gate#define FSYS_BUFLEN  0x8000
1067c478bdstevel@tonic-gate#define FSYS_BUF RAW_ADDR (0x68000)
1077c478bdstevel@tonic-gate
1087c478bdstevel@tonic-gate/* Command-line buffer for Multiboot kernels and modules. This area
1097c478bdstevel@tonic-gate   includes the area into which Stage 1.5 and Stage 1 are loaded, but
1107c478bdstevel@tonic-gate   that's no problem.  */
1117c478bdstevel@tonic-gate#define MB_CMDLINE_BUF		RAW_ADDR (0x2000)
1127c478bdstevel@tonic-gate#define MB_CMDLINE_BUFLEN	0x6000
1137c478bdstevel@tonic-gate
1147c478bdstevel@tonic-gate/* The buffer for the password.  */
1157c478bdstevel@tonic-gate#define PASSWORD_BUF		RAW_ADDR (0x78000)
1167c478bdstevel@tonic-gate#define PASSWORD_BUFLEN		0x200
1177c478bdstevel@tonic-gate
1187c478bdstevel@tonic-gate/* THe buffer for the filename of "/boot/grub/default".  */
1197c478bdstevel@tonic-gate#define DEFAULT_FILE_BUF	(PASSWORD_BUF + PASSWORD_BUFLEN)
1207c478bdstevel@tonic-gate#define DEFAULT_FILE_BUFLEN	0x60
1217c478bdstevel@tonic-gate
1227c478bdstevel@tonic-gate/* The buffer for the command-line.  */
1237c478bdstevel@tonic-gate#define CMDLINE_BUF		(DEFAULT_FILE_BUF + DEFAULT_FILE_BUFLEN)
1247c478bdstevel@tonic-gate#define CMDLINE_BUFLEN		MAX_CMDLINE
1257c478bdstevel@tonic-gate
1267c478bdstevel@tonic-gate/* The kill buffer for the command-line.  */
1277c478bdstevel@tonic-gate#define KILL_BUF		(CMDLINE_BUF + CMDLINE_BUFLEN)
1287c478bdstevel@tonic-gate#define KILL_BUFLEN		MAX_CMDLINE
1297c478bdstevel@tonic-gate
1307c478bdstevel@tonic-gate/* The history buffer for the command-line.  */
1317c478bdstevel@tonic-gate#define HISTORY_BUF		(KILL_BUF + KILL_BUFLEN)
1327c478bdstevel@tonic-gate#define HISTORY_SIZE		5
1337c478bdstevel@tonic-gate#define HISTORY_BUFLEN		(MAX_CMDLINE * HISTORY_SIZE)
1347c478bdstevel@tonic-gate
1357c478bdstevel@tonic-gate/* The buffer for the completion.  */
1367c478bdstevel@tonic-gate#define COMPLETION_BUF		(HISTORY_BUF + HISTORY_BUFLEN)
1377c478bdstevel@tonic-gate#define COMPLETION_BUFLEN	MAX_CMDLINE
1387c478bdstevel@tonic-gate
1397c478bdstevel@tonic-gate/* The buffer for the unique string.  */
1407c478bdstevel@tonic-gate#define UNIQUE_BUF		(COMPLETION_BUF + COMPLETION_BUFLEN)
1417c478bdstevel@tonic-gate#define UNIQUE_BUFLEN		MAX_CMDLINE
1427c478bdstevel@tonic-gate
1437c478bdstevel@tonic-gate/* The buffer for the menu entries.  */
1447c478bdstevel@tonic-gate#define MENU_BUF		(UNIQUE_BUF + UNIQUE_BUFLEN)
1457c478bdstevel@tonic-gate#define MENU_BUFLEN		(0x8000 + PASSWORD_BUF - MENU_BUF)
1467c478bdstevel@tonic-gate
1477c478bdstevel@tonic-gate/* The size of the drive map.  */
1487c478bdstevel@tonic-gate#define DRIVE_MAP_SIZE		8
1497c478bdstevel@tonic-gate
1507c478bdstevel@tonic-gate/* The size of the key map.  */
1517c478bdstevel@tonic-gate#define KEY_MAP_SIZE		128
1527c478bdstevel@tonic-gate
1537c478bdstevel@tonic-gate/* The size of the io map.  */
1547c478bdstevel@tonic-gate#define IO_MAP_SIZE		128
1557c478bdstevel@tonic-gate
1567c478bdstevel@tonic-gate/*
1577c478bdstevel@tonic-gate *  Linux setup parameters
1587c478bdstevel@tonic-gate */
1597c478bdstevel@tonic-gate
1607c478bdstevel@tonic-gate#define LINUX_MAGIC_SIGNATURE		0x53726448	/* "HdrS" */
1617c478bdstevel@tonic-gate#define LINUX_DEFAULT_SETUP_SECTS	4
1627c478bdstevel@tonic-gate#define LINUX_FLAG_CAN_USE_HEAP		0x80
1637c478bdstevel@tonic-gate#define LINUX_INITRD_MAX_ADDRESS	0x38000000
1647c478bdstevel@tonic-gate#define LINUX_MAX_SETUP_SECTS		64
1657c478bdstevel@tonic-gate#define LINUX_BOOT_LOADER_TYPE		0x71
1667c478bdstevel@tonic-gate#define LINUX_HEAP_END_OFFSET		(0x9000 - 0x200)
1677c478bdstevel@tonic-gate
1687c478bdstevel@tonic-gate#define LINUX_BZIMAGE_ADDR		RAW_ADDR (0x100000)
1697c478bdstevel@tonic-gate#define LINUX_ZIMAGE_ADDR		RAW_ADDR (0x10000)
1707c478bdstevel@tonic-gate#define LINUX_OLD_REAL_MODE_ADDR	RAW_ADDR (0x90000)
1717c478bdstevel@tonic-gate#define LINUX_SETUP_STACK		0x9000
1727c478bdstevel@tonic-gate
1737c478bdstevel@tonic-gate#define LINUX_FLAG_BIG_KERNEL		0x1
1747c478bdstevel@tonic-gate
1757c478bdstevel@tonic-gate/* Linux's video mode selection support. Actually I hate it!  */
1767c478bdstevel@tonic-gate#define LINUX_VID_MODE_NORMAL		0xFFFF
1777c478bdstevel@tonic-gate#define LINUX_VID_MODE_EXTENDED		0xFFFE
1787c478bdstevel@tonic-gate#define LINUX_VID_MODE_ASK		0xFFFD
1797c478bdstevel@tonic-gate
1807c478bdstevel@tonic-gate#define LINUX_CL_OFFSET			0x9000
1817c478bdstevel@tonic-gate#define LINUX_CL_END_OFFSET		0x90FF
1827c478bdstevel@tonic-gate#define LINUX_SETUP_MOVE_SIZE		0x9100
1837c478bdstevel@tonic-gate#define LINUX_CL_MAGIC			0xA33F
1847c478bdstevel@tonic-gate
1857c478bdstevel@tonic-gate/*
1867c478bdstevel@tonic-gate *  General disk stuff
1877c478bdstevel@tonic-gate */
1887c478bdstevel@tonic-gate
1897c478bdstevel@tonic-gate#define SECTOR_SIZE		0x200
1907c478bdstevel@tonic-gate#define SECTOR_BITS		9
1917c478bdstevel@tonic-gate#define BIOS_FLAG_FIXED_DISK	0x80
1927c478bdstevel@tonic-gate
1937c478bdstevel@tonic-gate#define BOOTSEC_LOCATION		RAW_ADDR (0x7C00)
1947c478bdstevel@tonic-gate#define BOOTSEC_SIGNATURE		0xAA55
1957c478bdstevel@tonic-gate#define BOOTSEC_BPB_OFFSET		0x3
1967c478bdstevel@tonic-gate#define BOOTSEC_BPB_LENGTH		0x3B
1977c478bdstevel@tonic-gate#define BOOTSEC_BPB_SYSTEM_ID		0x3
1987c478bdstevel@tonic-gate#define BOOTSEC_BPB_HIDDEN_SECTORS	0x1C
1997c478bdstevel@tonic-gate#define BOOTSEC_PART_OFFSET		0x1BE
2007c478bdstevel@tonic-gate#define BOOTSEC_PART_LENGTH		0x40
2017c478bdstevel@tonic-gate#define BOOTSEC_SIG_OFFSET		0x1FE
2027c478bdstevel@tonic-gate#define BOOTSEC_LISTSIZE		8
2037c478bdstevel@tonic-gate
2047c478bdstevel@tonic-gate/* Not bad, perhaps.  */
2057c478bdstevel@tonic-gate#define NETWORK_DRIVE	0x20
2067c478bdstevel@tonic-gate
2077c478bdstevel@tonic-gate/*
2087c478bdstevel@tonic-gate *  GRUB specific information
2097c478bdstevel@tonic-gate *    (in LSB order)
2107c478bdstevel@tonic-gate */
2117c478bdstevel@tonic-gate
2127c478bdstevel@tonic-gate#include <stage1.h>
2137c478bdstevel@tonic-gate
2147c478bdstevel@tonic-gate#define STAGE2_VER_MAJ_OFFS	0x6
2157c478bdstevel@tonic-gate#define STAGE2_INSTALLPART	0x8
2167c478bdstevel@tonic-gate#define STAGE2_SAVED_ENTRYNO	0xc
2177c478bdstevel@tonic-gate#define STAGE2_STAGE2_ID	0x10
2187c478bdstevel@tonic-gate#define STAGE2_FORCE_LBA	0x11
2197c478bdstevel@tonic-gate#define STAGE2_VER_STR_OFFS	0x12
2207c478bdstevel@tonic-gate
2217c478bdstevel@tonic-gate/* Stage 2 identifiers */
2227c478bdstevel@tonic-gate#define STAGE2_ID_STAGE2		0
2237c478bdstevel@tonic-gate#define STAGE2_ID_FFS_STAGE1_5		1
2247c478bdstevel@tonic-gate#define STAGE2_ID_E2FS_STAGE1_5		2
2257c478bdstevel@tonic-gate#define STAGE2_ID_FAT_STAGE1_5		3
2267c478bdstevel@tonic-gate#define STAGE2_ID_MINIX_STAGE1_5	4
2277c478bdstevel@tonic-gate#define STAGE2_ID_REISERFS_STAGE1_5	5
2287c478bdstevel@tonic-gate#define STAGE2_ID_VSTAFS_STAGE1_5	6
2297c478bdstevel@tonic-gate#define STAGE2_ID_JFS_STAGE1_5		7
2307c478bdstevel@tonic-gate#define STAGE2_ID_XFS_STAGE1_5		8
2317c478bdstevel@tonic-gate#define STAGE2_ID_ISO9660_STAGE1_5	9
2327c478bdstevel@tonic-gate#define STAGE2_ID_UFS2_STAGE1_5		10
2337c478bdstevel@tonic-gate#define STAGE2_ID_UFS_STAGE1_5		11
234b1b8ab3lling#define STAGE2_ID_ZFS_STAGE1_5		12
2357c478bdstevel@tonic-gate
2367c478bdstevel@tonic-gate#ifndef STAGE1_5
2377c478bdstevel@tonic-gate# define STAGE2_ID	STAGE2_ID_STAGE2
2387c478bdstevel@tonic-gate#else
2397c478bdstevel@tonic-gate# if defined(FSYS_FFS)
2407c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_FFS_STAGE1_5
2417c478bdstevel@tonic-gate# elif defined(FSYS_EXT2FS)
2427c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_E2FS_STAGE1_5
2437c478bdstevel@tonic-gate# elif defined(FSYS_FAT)
2447c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_FAT_STAGE1_5
2457c478bdstevel@tonic-gate# elif defined(FSYS_MINIX)
2467c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_MINIX_STAGE1_5
2477c478bdstevel@tonic-gate# elif defined(FSYS_REISERFS)
2487c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_REISERFS_STAGE1_5
2497c478bdstevel@tonic-gate# elif defined(FSYS_VSTAFS)
2507c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_VSTAFS_STAGE1_5
2517c478bdstevel@tonic-gate# elif defined(FSYS_JFS)
2527c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_JFS_STAGE1_5
2537c478bdstevel@tonic-gate# elif defined(FSYS_XFS)
2547c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_XFS_STAGE1_5
2557c478bdstevel@tonic-gate# elif defined(FSYS_ISO9660)
2567c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_ISO9660_STAGE1_5
2577c478bdstevel@tonic-gate# elif defined(FSYS_UFS2)
2587c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_UFS2_STAGE1_5
2597c478bdstevel@tonic-gate# elif defined(FSYS_UFS)
2607c478bdstevel@tonic-gate#  define STAGE2_ID	STAGE2_ID_UFS_STAGE1_5
261b1b8ab3lling# elif defined(FSYS_ZFS)
262b1b8ab3lling#  define STAGE2_ID	STAGE2_ID_ZFS_STAGE1_5
2637c478bdstevel@tonic-gate# else
2647c478bdstevel@tonic-gate#  error "unknown Stage 2"
2657c478bdstevel@tonic-gate# endif
2667c478bdstevel@tonic-gate#endif
2677c478bdstevel@tonic-gate
2687c478bdstevel@tonic-gate/*
2697c478bdstevel@tonic-gate *  defines for use when switching between real and protected mode
2707c478bdstevel@tonic-gate */
2717c478bdstevel@tonic-gate
2727c478bdstevel@tonic-gate#define CR0_PE_ON	0x1
2737c478bdstevel@tonic-gate#define CR0_PE_OFF	0xfffffffe
2747c478bdstevel@tonic-gate#define PROT_MODE_CSEG	0x8
2757c478bdstevel@tonic-gate#define PROT_MODE_DSEG  0x10
2767c478bdstevel@tonic-gate#define PSEUDO_RM_CSEG	0x18
2777c478bdstevel@tonic-gate#define PSEUDO_RM_DSEG	0x20
2787c478bdstevel@tonic-gate#define STACKOFF	(0x2000 - 0x10)
2797c478bdstevel@tonic-gate#define PROTSTACKINIT   (FSYS_BUF - 0x10)
2807c478bdstevel@tonic-gate
2817c478bdstevel@tonic-gate
2827c478bdstevel@tonic-gate/*
2837c478bdstevel@tonic-gate * Assembly code defines
2847c478bdstevel@tonic-gate *
2857c478bdstevel@tonic-gate * "EXT_C" is assumed to be defined in the Makefile by the configure
2867c478bdstevel@tonic-gate *   command.
2877c478bdstevel@tonic-gate */
2887c478bdstevel@tonic-gate
2897c478bdstevel@tonic-gate#define ENTRY(x) .globl EXT_C(x) ; EXT_C(x):
2907c478bdstevel@tonic-gate#define VARIABLE(x) ENTRY(x)
2917c478bdstevel@tonic-gate
2927c478bdstevel@tonic-gate
2937c478bdstevel@tonic-gate#define K_RDWR  	0x60	/* keyboard data & cmds (read/write) */
2947c478bdstevel@tonic-gate#define K_STATUS	0x64	/* keyboard status */
2957c478bdstevel@tonic-gate#define K_CMD		0x64	/* keybd ctlr command (write-only) */
2967c478bdstevel@tonic-gate
2977c478bdstevel@tonic-gate#define K_OBUF_FUL 	0x01	/* output buffer full */
2987c478bdstevel@tonic-gate#define K_IBUF_FUL 	0x02	/* input buffer full */
2997c478bdstevel@tonic-gate
3007c478bdstevel@tonic-gate#define KC_CMD_WIN	0xd0	/* read  output port */
3017c478bdstevel@tonic-gate#define KC_CMD_WOUT	0xd1	/* write output port */
3027c478bdstevel@tonic-gate#define KB_OUTPUT_MASK  0xdd	/* enable output buffer full interrupt
3037c478bdstevel@tonic-gate				   enable data line
3047c478bdstevel@tonic-gate				   enable clock line */
3057c478bdstevel@tonic-gate#define KB_A20_ENABLE   0x02
3067c478bdstevel@tonic-gate
3077c478bdstevel@tonic-gate/* Codes for getchar. */
3087c478bdstevel@tonic-gate#define ASCII_CHAR(x)   ((x) & 0xFF)
3097c478bdstevel@tonic-gate#if !defined(GRUB_UTIL) || !defined(HAVE_LIBCURSES)
3107c478bdstevel@tonic-gate# define KEY_LEFT        0x4B00
3117c478bdstevel@tonic-gate# define KEY_RIGHT       0x4D00
3127c478bdstevel@tonic-gate# define KEY_UP          0x4800
3137c478bdstevel@tonic-gate# define KEY_DOWN        0x5000
3147c478bdstevel@tonic-gate# define KEY_IC          0x5200	/* insert char */
3157c478bdstevel@tonic-gate# define KEY_DC          0x5300	/* delete char */
3167c478bdstevel@tonic-gate# define KEY_BACKSPACE   0x0008
3177c478bdstevel@tonic-gate# define KEY_HOME        0x4700
3187c478bdstevel@tonic-gate# define KEY_END         0x4F00
3197c478bdstevel@tonic-gate# define KEY_NPAGE       0x5100
3207c478bdstevel@tonic-gate# define KEY_PPAGE       0x4900
3217c478bdstevel@tonic-gate# define A_NORMAL        0x7
3227c478bdstevel@tonic-gate# define A_REVERSE       0x70
3237c478bdstevel@tonic-gate#elif defined(HAVE_NCURSES_CURSES_H)
3247c478bdstevel@tonic-gate# include <ncurses/curses.h>
3257c478bdstevel@tonic-gate#elif defined(HAVE_NCURSES_H)
3267c478bdstevel@tonic-gate# include <ncurses.h>
3277c478bdstevel@tonic-gate#elif defined(HAVE_CURSES_H)
3287c478bdstevel@tonic-gate# include <curses.h>
3297c478bdstevel@tonic-gate#endif
3307c478bdstevel@tonic-gate
3317c478bdstevel@tonic-gate/* In old BSD curses, A_NORMAL and A_REVERSE are not defined, so we
3327c478bdstevel@tonic-gate   define them here if they are undefined.  */
3337c478bdstevel@tonic-gate#ifndef A_NORMAL
3347c478bdstevel@tonic-gate# define A_NORMAL	0
3357c478bdstevel@tonic-gate#endif /* ! A_NORMAL */
3367c478bdstevel@tonic-gate#ifndef A_REVERSE
3377c478bdstevel@tonic-gate# ifdef A_STANDOUT
3387c478bdstevel@tonic-gate#  define A_REVERSE	A_STANDOUT
3397c478bdstevel@tonic-gate# else /* ! A_STANDOUT */
3407c478bdstevel@tonic-gate#  define A_REVERSE	0
3417c478bdstevel@tonic-gate# endif /* ! A_STANDOUT */
3427c478bdstevel@tonic-gate#endif /* ! A_REVERSE */
3437c478bdstevel@tonic-gate
3447c478bdstevel@tonic-gate/* Define ACS_* ourselves, since the definitions are not consistent among
3457c478bdstevel@tonic-gate   various curses implementations.  */
3467c478bdstevel@tonic-gate#undef ACS_ULCORNER
3477c478bdstevel@tonic-gate#undef ACS_URCORNER
3487c478bdstevel@tonic-gate#undef ACS_LLCORNER
3497c478bdstevel@tonic-gate#undef ACS_LRCORNER
3507c478bdstevel@tonic-gate#undef ACS_HLINE
3517c478bdstevel@tonic-gate#undef ACS_VLINE
3527c478bdstevel@tonic-gate#undef ACS_LARROW
3537c478bdstevel@tonic-gate#undef ACS_RARROW
3547c478bdstevel@tonic-gate#undef ACS_UARROW
3557c478bdstevel@tonic-gate#undef ACS_DARROW
3567c478bdstevel@tonic-gate
3577c478bdstevel@tonic-gate#define ACS_ULCORNER	'+'
3587c478bdstevel@tonic-gate#define ACS_URCORNER	'+'
3597c478bdstevel@tonic-gate#define ACS_LLCORNER	'+'
3607c478bdstevel@tonic-gate#define ACS_LRCORNER	'+'
3617c478bdstevel@tonic-gate#define ACS_HLINE	'-'
3627c478bdstevel@tonic-gate#define ACS_VLINE	'|'
3637c478bdstevel@tonic-gate#define ACS_LARROW	'<'
3647c478bdstevel@tonic-gate#define ACS_RARROW	'>'
3657c478bdstevel@tonic-gate#define ACS_UARROW	'^'
3667c478bdstevel@tonic-gate#define ACS_DARROW	'v'
3677c478bdstevel@tonic-gate
3687c478bdstevel@tonic-gate/* Special graphics characters for IBM displays. */
3697c478bdstevel@tonic-gate#define DISP_UL		218
3707c478bdstevel@tonic-gate#define DISP_UR		191
3717c478bdstevel@tonic-gate#define DISP_LL		192
3727c478bdstevel@tonic-gate#define DISP_LR		217
3737c478bdstevel@tonic-gate#define DISP_HORIZ	196
3747c478bdstevel@tonic-gate#define DISP_VERT	179
3757c478bdstevel@tonic-gate#define DISP_LEFT	0x1b
3767c478bdstevel@tonic-gate#define DISP_RIGHT	0x1a
3777c478bdstevel@tonic-gate#define DISP_UP		0x18
3787c478bdstevel@tonic-gate#define DISP_DOWN	0x19
3797c478bdstevel@tonic-gate
3807c478bdstevel@tonic-gate/* Remap some libc-API-compatible function names so that we prevent
3817c478bdstevel@tonic-gate   circularararity. */
3827c478bdstevel@tonic-gate#ifndef WITHOUT_LIBC_STUBS
3837c478bdstevel@tonic-gate#define memmove grub_memmove
3847c478bdstevel@tonic-gate#define memcpy grub_memmove	/* we don't need a separate memcpy */
3857c478bdstevel@tonic-gate#define memset grub_memset
3867c478bdstevel@tonic-gate#undef isspace
3877c478bdstevel@tonic-gate#define isspace grub_isspace
3887c478bdstevel@tonic-gate#define printf grub_printf
3897c478bdstevel@tonic-gate#define sprintf grub_sprintf
3907c478bdstevel@tonic-gate#undef putchar
3917c478bdstevel@tonic-gate#define putchar grub_putchar
3927c478bdstevel@tonic-gate#define strncat grub_strncat
3937c478bdstevel@tonic-gate#define strstr grub_strstr
3947c478bdstevel@tonic-gate#define memcmp grub_memcmp
3957c478bdstevel@tonic-gate#define strcmp grub_strcmp
3967c478bdstevel@tonic-gate#define tolower grub_tolower
3977c478bdstevel@tonic-gate#define strlen grub_strlen
3987c478bdstevel@tonic-gate#define strcpy grub_strcpy
3997c478bdstevel@tonic-gate#endif /* WITHOUT_LIBC_STUBS */
4007c478bdstevel@tonic-gate
4017c478bdstevel@tonic-gate#define UNDI_STACK (512 + 64) << 10
4027c478bdstevel@tonic-gate#define UNDI_STACK_SEG (UNDI_STACK >> 4) /*  PXE load GRUB here */
4037c478bdstevel@tonic-gate#define UNDI_STACK_OFF (0x10000 - 0x10)
4047c478bdstevel@tonic-gate
4057c478bdstevel@tonic-gate#ifndef ASM_FILE
4067c478bdstevel@tonic-gate/*
4077c478bdstevel@tonic-gate *  Below this should be ONLY defines and other constructs for C code.
4087c478bdstevel@tonic-gate */
4097c478bdstevel@tonic-gate
4107c478bdstevel@tonic-gate/* multiboot stuff */
4117c478bdstevel@tonic-gate
4127c478bdstevel@tonic-gate#include "mb_header.h"
4137c478bdstevel@tonic-gate#include "mb_info.h"
4147c478bdstevel@tonic-gate
4157c478bdstevel@tonic-gate/* For the Linux/i386 boot protocol version 2.03.  */
4167c478bdstevel@tonic-gatestruct linux_kernel_header
4177c478bdstevel@tonic-gate{
4187c478bdstevel@tonic-gate  char code1[0x0020];
4197c478bdstevel@tonic-gate  unsigned short cl_magic;		/* Magic number 0xA33F */
4207c478bdstevel@tonic-gate  unsigned short cl_offset;		/* The offset of command line */
4217c478bdstevel@tonic-gate  char code2[0x01F1 - 0x0020 - 2 - 2];
4227c478bdstevel@tonic-gate  unsigned char setup_sects;		/* The size of the setup in sectors */
4237c478bdstevel@tonic-gate  unsigned short root_flags;		/* If the root is mounted readonly */
4247c478bdstevel@tonic-gate  unsigned short syssize;		/* obsolete */
4257c478bdstevel@tonic-gate  unsigned short swap_dev;		/* obsolete */
4267c478bdstevel@tonic-gate  unsigned short ram_size;		/* obsolete */
4277c478bdstevel@tonic-gate  unsigned short vid_mode;		/* Video mode control */
4287c478bdstevel@tonic-gate  unsigned short root_dev;		/* Default root device number */
4297c478bdstevel@tonic-gate  unsigned short boot_flag;		/* 0xAA55 magic number */
4307c478bdstevel@tonic-gate  unsigned short jump;			/* Jump instruction */
4317c478bdstevel@tonic-gate  unsigned long header;			/* Magic signature "HdrS" */
4327c478bdstevel@tonic-gate  unsigned short version;		/* Boot protocol version supported */
4337c478bdstevel@tonic-gate  unsigned long realmode_swtch;		/* Boot loader hook */
4347c478bdstevel@tonic-gate  unsigned long start_sys;		/* Points to kernel version string */
4357c478bdstevel@tonic-gate  unsigned char type_of_loader;		/* Boot loader identifier */
4367c478bdstevel@tonic-gate  unsigned char loadflags;		/* Boot protocol option flags */
4377c478bdstevel@tonic-gate  unsigned short setup_move_size;	/* Move to high memory size */
4387c478bdstevel@tonic-gate  unsigned long code32_start;		/* Boot loader hook */
4397c478bdstevel@tonic-gate  unsigned long ramdisk_image;		/* initrd load address */
4407c478bdstevel@tonic-gate  unsigned long ramdisk_size;		/* initrd size */
4417c478bdstevel@tonic-gate  unsigned long bootsect_kludge;	/* obsolete */
4427c478bdstevel@tonic-gate  unsigned short heap_end_ptr;		/* Free memory after setup end */
4437c478bdstevel@tonic-gate  unsigned short pad1;			/* Unused */
4447c478bdstevel@tonic-gate  char *cmd_line_ptr;			/* Points to the kernel command line */
4457c478bdstevel@tonic-gate  unsigned long initrd_addr_max;	/* The highest address of initrd */
4467c478bdstevel@tonic-gate} __attribute__ ((packed));
4477c478bdstevel@tonic-gate
4487c478bdstevel@tonic-gate/* Memory map address range descriptor used by GET_MMAP_ENTRY. */
4497c478bdstevel@tonic-gatestruct mmar_desc
4507c478bdstevel@tonic-gate{
4517c478bdstevel@tonic-gate  unsigned long desc_len;	/* Size of this descriptor. */
4527c478bdstevel@tonic-gate  unsigned long long addr;	/* Base address. */
4537c478bdstevel@tonic-gate  unsigned long long length;	/* Length in bytes. */
4547c478bdstevel@tonic-gate  unsigned long type;		/* Type of address range. */
4557c478bdstevel@tonic-gate} __attribute__ ((packed));
4567c478bdstevel@tonic-gate
4577c478bdstevel@tonic-gate/* VBE controller information.  */
4587c478bdstevel@tonic-gatestruct vbe_controller
4597c478bdstevel@tonic-gate{
4607c478bdstevel@tonic-gate  unsigned char signature[4];
4617c478bdstevel@tonic-gate  unsigned short version;
4627c478bdstevel@tonic-gate  unsigned long oem_string;
4637c478bdstevel@tonic-gate  unsigned long capabilities;
4647c478bdstevel@tonic-gate  unsigned long video_mode;
4657c478bdstevel@tonic-gate  unsigned short total_memory;
4667c478bdstevel@tonic-gate  unsigned short oem_software_rev;
4677c478bdstevel@tonic-gate  unsigned long oem_vendor_name;
4687c478bdstevel@tonic-gate  unsigned long oem_product_name;
4697c478bdstevel@tonic-gate  unsigned long oem_product_rev;
4707c478bdstevel@tonic-gate  unsigned char reserved[222];
4717c478bdstevel@tonic-gate  unsigned char oem_data[256];
4727c478bdstevel@tonic-gate} __attribute__ ((packed));
4737c478bdstevel@tonic-gate
4747c478bdstevel@tonic-gate/* VBE mode information.  */
4757c478bdstevel@tonic-gatestruct vbe_mode
4767c478bdstevel@tonic-gate{
4777c478bdstevel@tonic-gate  unsigned short mode_attributes;
4787c478bdstevel@tonic-gate  unsigned char win_a_attributes;
4797c478bdstevel@tonic-gate  unsigned char win_b_attributes;
4807c478bdstevel@tonic-gate  unsigned short win_granularity;
4817c478bdstevel@tonic-gate  unsigned short win_size;
4827c478bdstevel@tonic-gate  unsigned short win_a_segment;
4837c478bdstevel@tonic-gate  unsigned short win_b_segment;
4847c478bdstevel@tonic-gate  unsigned long win_func;
4857c478bdstevel@tonic-gate  unsigned short bytes_per_scanline;
4867c478bdstevel@tonic-gate
4877c478bdstevel@tonic-gate  /* >=1.2 */
4887c478bdstevel@tonic-gate  unsigned short x_resolution;
4897c478bdstevel@tonic-gate  unsigned short y_resolution;
4907c478bdstevel@tonic-gate  unsigned char x_char_size;
4917c478bdstevel@tonic-gate  unsigned char y_char_size;
4927c478bdstevel@tonic-gate  unsigned char number_of_planes;
4937c478bdstevel@tonic-gate  unsigned char bits_per_pixel;
4947c478bdstevel@tonic-gate  unsigned char number_of_banks;
4957c478bdstevel@tonic-gate  unsigned char memory_model;
4967c478bdstevel@tonic-gate  unsigned char bank_size;
4977c478bdstevel@tonic-gate  unsigned char number_of_image_pages;
4987c478bdstevel@tonic-gate  unsigned char reserved0;
4997c478bdstevel@tonic-gate
5007c478bdstevel@tonic-gate  /* direct color */
5017c478bdstevel@tonic-gate  unsigned char red_mask_size;
5027c478bdstevel@tonic-gate  unsigned char red_field_position;
5037c478bdstevel@tonic-gate  unsigned char green_mask_size;
5047c478bdstevel@tonic-gate  unsigned char green_field_position;
5057c478bdstevel@tonic-gate  unsigned char blue_mask_size;
5067c478bdstevel@tonic-gate  unsigned char blue_field_position;
5077c478bdstevel@tonic-gate  unsigned char reserved_mask_size;
5087c478bdstevel@tonic-gate  unsigned char reserved_field_position;
5097c478bdstevel@tonic-gate  unsigned char direct_color_mode_info;
5107c478bdstevel@tonic-gate
5117c478bdstevel@tonic-gate  /* >=2.0 */
5127c478bdstevel@tonic-gate  unsigned long phys_base;
5137c478bdstevel@tonic-gate  unsigned long reserved1;
5147c478bdstevel@tonic-gate  unsigned short reversed2;
5157c478bdstevel@tonic-gate
5167c478bdstevel@tonic-gate  /* >=3.0 */
5177c478bdstevel@tonic-gate  unsigned short linear_bytes_per_scanline;
5187c478bdstevel@tonic-gate  unsigned char banked_number_of_image_pages;
5197c478bdstevel@tonic-gate  unsigned char linear_number_of_image_pages;
5207c478bdstevel@tonic-gate  unsigned char linear_red_mask_size;
5217c478bdstevel@tonic-gate  unsigned char linear_red_field_position;
5227c478bdstevel@tonic-gate  unsigned char linear_green_mask_size;
5237c478bdstevel@tonic-gate  unsigned char linear_green_field_position;
5247c478bdstevel@tonic-gate  unsigned char linear_blue_mask_size;
5257c478bdstevel@tonic-gate  unsigned char linear_blue_field_position;
5267c478bdstevel@tonic-gate  unsigned char linear_reserved_mask_size;
5277c478bdstevel@tonic-gate  unsigned char linear_reserved_field_position;
5287c478bdstevel@tonic-gate  unsigned long max_pixel_clock;
5297c478bdstevel@tonic-gate
5307c478bdstevel@tonic-gate  unsigned char reserved3[189];
5317c478bdstevel@tonic-gate} __attribute__ ((packed));
5327c478bdstevel@tonic-gate
5337c478bdstevel@tonic-gate#undef NULL
5347c478bdstevel@tonic-gate#define NULL         ((void *) 0)
5357c478bdstevel@tonic-gate
5367c478bdstevel@tonic-gate/* Error codes (descriptions are in common.c) */
5377c478bdstevel@tonic-gatetypedef enum
5387c478bdstevel@tonic-gate{
5397c478bdstevel@tonic-gate  ERR_NONE = 0,
5407c478bdstevel@tonic-gate  ERR_BAD_FILENAME,
5417c478bdstevel@tonic-gate  ERR_BAD_FILETYPE,
5427c478bdstevel@tonic-gate  ERR_BAD_GZIP_DATA,
5437c478bdstevel@tonic-gate  ERR_BAD_GZIP_HEADER,
5447c478bdstevel@tonic-gate  ERR_BAD_PART_TABLE,
5457c478bdstevel@tonic-gate  ERR_BAD_VERSION,
5467c478bdstevel@tonic-gate  ERR_BELOW_1MB,
5477c478bdstevel@tonic-gate  ERR_BOOT_COMMAND,
5487c478bdstevel@tonic-gate  ERR_BOOT_FAILURE,
5497c478bdstevel@tonic-gate  ERR_BOOT_FEATURES,
5507c478bdstevel@tonic-gate  ERR_DEV_FORMAT,
5517c478bdstevel@tonic-gate  ERR_DEV_VALUES,
5527c478bdstevel@tonic-gate  ERR_EXEC_FORMAT,
5537c478bdstevel@tonic-gate  ERR_FILELENGTH,
5547c478bdstevel@tonic-gate  ERR_FILE_NOT_FOUND,
5557c478bdstevel@tonic-gate  ERR_FSYS_CORRUPT,
5567c478bdstevel@tonic-gate  ERR_FSYS_MOUNT,
5577c478bdstevel@tonic-gate  ERR_GEOM,
5587c478bdstevel@tonic-gate  ERR_NEED_LX_KERNEL,
5597c478bdstevel@tonic-gate  ERR_NEED_MB_KERNEL,
5607c478bdstevel@tonic-gate  ERR_NO_DISK,
5617c478bdstevel@tonic-gate  ERR_NO_PART,
5627c478bdstevel@tonic-gate  ERR_NUMBER_PARSING,
5637c478bdstevel@tonic-gate  ERR_OUTSIDE_PART,
5647c478bdstevel@tonic-gate  ERR_READ,
5657c478bdstevel@tonic-gate  ERR_SYMLINK_LOOP,
5667c478bdstevel@tonic-gate  ERR_UNRECOGNIZED,
5677c478bdstevel@tonic-gate  ERR_WONT_FIT,
5687c478bdstevel@tonic-gate  ERR_WRITE,
5697c478bdstevel@tonic-gate  ERR_BAD_ARGUMENT,
5707c478bdstevel@tonic-gate  ERR_UNALIGNED,
5717c478bdstevel@tonic-gate  ERR_PRIVILEGED,
5727c478bdstevel@tonic-gate  ERR_DEV_NEED_INIT,
5737c478bdstevel@tonic-gate  ERR_NO_DISK_SPACE,
5747c478bdstevel@tonic-gate  ERR_NUMBER_OVERFLOW,
5759caa148szhou  ERR_BAD_GZIP_CRC,
576b1b8ab3lling  ERR_FILESYSTEM_NOT_FOUND,
577e7cbe64gw  ERR_NO_BOOTPATH,
578fe3e263Eric Taylor  ERR_NEWER_VERSION,
5799b4e3acWilliam Kucharski  ERR_NOTXPM,
5809b4e3acWilliam Kucharski  ERR_TOOMANYCOLORS,
5819b4e3acWilliam Kucharski  ERR_CORRUPTXPM,
582a5602e1Keith M Wesolowski  ERR_NOVAR,
5837c478bdstevel@tonic-gate  MAX_ERR_NUM
5847c478bdstevel@tonic-gate} grub_error_t;
5857c478bdstevel@tonic-gate
5862506833Jan Setje-Eilerstypedef enum
5872506833Jan Setje-Eilers{
5882506833Jan Setje-Eilers	CFG_HARDCODED,
5892506833Jan Setje-Eilers	CFG_150,
5902506833Jan Setje-Eilers	CFG_MAC,
5912506833Jan Setje-Eilers	CFG_BOOTFILE
5922506833Jan Setje-Eilers} configfile_origin_t;
5932506833Jan Setje-Eilers
5947c478bdstevel@tonic-gateextern unsigned long install_partition;
5957c478bdstevel@tonic-gateextern unsigned long boot_drive;
5967c478bdstevel@tonic-gateextern unsigned long install_second_sector;
5977c478bdstevel@tonic-gateextern struct apm_info apm_bios_info;
5987c478bdstevel@tonic-gateextern unsigned long boot_part_addr;
5997c478bdstevel@tonic-gateextern int saved_entryno;
6007c478bdstevel@tonic-gateextern unsigned char force_lba;
6017c478bdstevel@tonic-gateextern char version_string[];
6027c478bdstevel@tonic-gateextern char config_file[];
6032506833Jan Setje-Eilersextern char *bootfile;
6042506833Jan Setje-Eilersextern configfile_origin_t configfile_origin;
6057c478bdstevel@tonic-gateextern unsigned long linux_text_len;
6067c478bdstevel@tonic-gateextern char *linux_data_tmp_addr;
6077c478bdstevel@tonic-gateextern char *linux_data_real_addr;
6087c478bdstevel@tonic-gate
6097c478bdstevel@tonic-gate#ifdef GRUB_UTIL
6107c478bdstevel@tonic-gate/* If not using config file, this variable is set to zero,
6117c478bdstevel@tonic-gate   otherwise non-zero.  */
6127c478bdstevel@tonic-gateextern int use_config_file;
6137c478bdstevel@tonic-gate/* If using the preset menu, this variable is set to non-zero,
6147c478bdstevel@tonic-gate   otherwise zero.  */
6157c478bdstevel@tonic-gateextern int use_preset_menu;
6167c478bdstevel@tonic-gate/* If not using curses, this variable is set to zero, otherwise non-zero.  */
6177c478bdstevel@tonic-gateextern int use_curses;
6187c478bdstevel@tonic-gate/* The flag for verbose messages.  */
6197c478bdstevel@tonic-gateextern int verbose;
6207c478bdstevel@tonic-gate/* The flag for read-only.  */
6217c478bdstevel@tonic-gateextern int read_only;
6227c478bdstevel@tonic-gate/* The number of floppies to be probed.  */
6237c478bdstevel@tonic-gateextern int floppy_disks;
6247c478bdstevel@tonic-gate/* The map between BIOS drives and UNIX device file names.  */
6257c478bdstevel@tonic-gateextern char **device_map;
6267c478bdstevel@tonic-gate/* The filename which stores the information about a device map.  */
6277c478bdstevel@tonic-gateextern char *device_map_file;
6287c478bdstevel@tonic-gate/* The array of geometries.  */
6297c478bdstevel@tonic-gateextern struct geometry *disks;
6307c478bdstevel@tonic-gate/* Assign DRIVE to a device name DEVICE.  */
6317c478bdstevel@tonic-gateextern void assign_device_name (int drive, const char *device);
6327c478bdstevel@tonic-gate#endif
6337c478bdstevel@tonic-gate
6347c478bdstevel@tonic-gate#ifndef STAGE1_5
6357c478bdstevel@tonic-gate/* GUI interface variables. */
6367c478bdstevel@tonic-gate# define MAX_FALLBACK_ENTRIES	8
6377c478bdstevel@tonic-gateextern int fallback_entries[MAX_FALLBACK_ENTRIES];
6387c478bdstevel@tonic-gateextern int fallback_entryno;
6397c478bdstevel@tonic-gateextern int default_entry;
6407c478bdstevel@tonic-gateextern int current_entryno;
6417c478bdstevel@tonic-gate
642a5602e1Keith M Wesolowskiextern unsigned int min_mem64;
643a5602e1Keith M Wesolowski
6447c478bdstevel@tonic-gate/* The constants for password types.  */
6457c478bdstevel@tonic-gatetypedef enum
6467c478bdstevel@tonic-gate{
6477c478bdstevel@tonic-gate  PASSWORD_PLAIN,
6487c478bdstevel@tonic-gate  PASSWORD_MD5,
6497c478bdstevel@tonic-gate  PASSWORD_UNSUPPORTED
6507c478bdstevel@tonic-gate}
6517c478bdstevel@tonic-gatepassword_t;
6527c478bdstevel@tonic-gate
6537c478bdstevel@tonic-gateextern char *password;
6547c478bdstevel@tonic-gateextern password_t password_type;
6557c478bdstevel@tonic-gateextern int auth;
6567c478bdstevel@tonic-gateextern char commands[];
6577c478bdstevel@tonic-gate
6587c478bdstevel@tonic-gate/* For `more'-like feature.  */
6597c478bdstevel@tonic-gateextern int max_lines;
6607c478bdstevel@tonic-gateextern int count_lines;
6617c478bdstevel@tonic-gateextern int use_pager;
6627c478bdstevel@tonic-gate#endif
6637c478bdstevel@tonic-gate
6647c478bdstevel@tonic-gate#ifndef NO_DECOMPRESSION
6657c478bdstevel@tonic-gateextern int no_decompression;
6667c478bdstevel@tonic-gateextern int compressed_file;
6677c478bdstevel@tonic-gate#endif
6687c478bdstevel@tonic-gate
6697c478bdstevel@tonic-gate/* instrumentation variables */
6709890706Hans Rosenfeldextern void (*disk_read_hook) (unsigned long long, int, int);
6719890706Hans Rosenfeldextern void (*disk_read_func) (unsigned long long, int, int);
6727c478bdstevel@tonic-gate
6737c478bdstevel@tonic-gate#ifndef STAGE1_5
6747c478bdstevel@tonic-gate/* The flag for debug mode.  */
6757c478bdstevel@tonic-gateextern int debug;
6767c478bdstevel@tonic-gate#endif /* STAGE1_5 */
6777c478bdstevel@tonic-gate
6787c478bdstevel@tonic-gateextern unsigned long current_drive;
6797c478bdstevel@tonic-gateextern unsigned long current_partition;
680b1b8ab3llingextern char current_rootpool[MAXNAMELEN];
681b1b8ab3llingextern char current_bootfs[MAXNAMELEN];
682b1b8ab3llingextern unsigned long long current_bootfs_obj;
683ffb5616Lin Lingextern char current_bootpath[MAXPATHLEN];
684ffb5616Lin Lingextern char current_devid[MAXPATHLEN];
685b1b8ab3llingextern int is_zfs_mount;
686051aabetaylorextern unsigned long best_drive;
687051aabetaylorextern unsigned long best_part;
688051aabetaylorextern int find_best_root;
6897c478bdstevel@tonic-gate
6907c478bdstevel@tonic-gateextern int fsys_type;
6917c478bdstevel@tonic-gate
6927c478bdstevel@tonic-gate/* The information for a disk geometry. The CHS information is only for
6937c478bdstevel@tonic-gate   DOS/Partition table compatibility, and the real number of sectors is
6947c478bdstevel@tonic-gate   stored in TOTAL_SECTORS.  */
6957c478bdstevel@tonic-gatestruct geometry
6967c478bdstevel@tonic-gate{
6977c478bdstevel@tonic-gate  /* The number of cylinders */
6987c478bdstevel@tonic-gate  unsigned long cylinders;
6997c478bdstevel@tonic-gate  /* The number of heads */
7007c478bdstevel@tonic-gate  unsigned long heads;
7017c478bdstevel@tonic-gate  /* The number of sectors */
7027c478bdstevel@tonic-gate  unsigned long sectors;
7037c478bdstevel@tonic-gate  /* The total number of sectors */
704828d47cShidokht Yadegari  unsigned long long total_sectors;
7057c478bdstevel@tonic-gate  /* Device sector size */
7067c478bdstevel@tonic-gate  unsigned long sector_size;
7077c478bdstevel@tonic-gate  /* Flags */
7087c478bdstevel@tonic-gate  unsigned long flags;
7097c478bdstevel@tonic-gate};
7107c478bdstevel@tonic-gate
7119890706Hans Rosenfeldextern unsigned long long part_start;
7129890706Hans Rosenfeldextern unsigned long long part_length;
7137c478bdstevel@tonic-gate
7147c478bdstevel@tonic-gateextern int current_slice;
7157c478bdstevel@tonic-gate
7167c478bdstevel@tonic-gateextern int buf_drive;
7179890706Hans Rosenfeld#define BUF_CACHE_INVALID (-1ULL)
7189890706Hans Rosenfeldextern unsigned long long buf_track;
7197c478bdstevel@tonic-gateextern struct geometry buf_geom;
7207c478bdstevel@tonic-gate
7217c478bdstevel@tonic-gate/* these are the current file position and maximum file position */
7227c478bdstevel@tonic-gateextern int filepos;
7237c478bdstevel@tonic-gateextern int filemax;
7247c478bdstevel@tonic-gate
7257c478bdstevel@tonic-gate/*
7267c478bdstevel@tonic-gate *  Common BIOS/boot data.
7277c478bdstevel@tonic-gate */
7287c478bdstevel@tonic-gate
7297c478bdstevel@tonic-gateextern struct multiboot_info mbi;
7307c478bdstevel@tonic-gateextern unsigned long saved_drive;
7317c478bdstevel@tonic-gateextern unsigned long saved_partition;
7327c478bdstevel@tonic-gateextern unsigned long cdrom_drive;
7337c478bdstevel@tonic-gate#ifndef STAGE1_5
7347c478bdstevel@tonic-gate#ifdef SOLARIS_NETBOOT
7357c478bdstevel@tonic-gateextern unsigned long dhcpack_length;
7367c478bdstevel@tonic-gateextern unsigned long dhcpack_buf;
7377c478bdstevel@tonic-gate#endif
7387c478bdstevel@tonic-gateextern unsigned long saved_mem_upper;
7397c478bdstevel@tonic-gateextern unsigned long extended_memory;
7407c478bdstevel@tonic-gate#endif
7417c478bdstevel@tonic-gate
7427c478bdstevel@tonic-gate/*
7437c478bdstevel@tonic-gate *  Error variables.
7447c478bdstevel@tonic-gate */
7457c478bdstevel@tonic-gate
7467c478bdstevel@tonic-gateextern grub_error_t errnum;
7477c478bdstevel@tonic-gateextern char *err_list[];
7487c478bdstevel@tonic-gate
7491fac5a6setje/* don't print geeky noise */
7501fac5a6setjetypedef enum
7511fac5a6setje{
7521fac5a6setje  SILENT,
7531fac5a6setje  VERBOSE,
7541fac5a6setje  DEFER_SILENT,
7551fac5a6setje  DEFER_VERBOSE
7561fac5a6setje} silent_status;
7571fac5a6setje
7581fac5a6setje/* one screen worth of messages 80x24 = 1920 chars -- more with newlines */
7591fac5a6setje#define	SCREENBUF 2000
7601fac5a6setje
7611fac5a6setjestruct silentbuf {
7621fac5a6setje	silent_status status;
7631fac5a6setje	int looped;
7641fac5a6setje	char buffer[SCREENBUF];
7651fac5a6setje	char *buffer_start;
7661fac5a6setje};
7671fac5a6setje
7681fac5a6setjeextern struct silentbuf silent;
7691fac5a6setjeextern int reset_term;
7701fac5a6setje
7717c478bdstevel@tonic-gate/* Simplify declaration of entry_addr. */
7727c478bdstevel@tonic-gatetypedef void (*entry_func) (int, int, int, int, int, int)
7737c478bdstevel@tonic-gate     __attribute__ ((noreturn));
7747c478bdstevel@tonic-gate
7757c478bdstevel@tonic-gateextern entry_func entry_addr;
7767c478bdstevel@tonic-gate
7777c478bdstevel@tonic-gate/* Enter the stage1.5/stage2 C code after the stack is set up. */
7787c478bdstevel@tonic-gatevoid cmain (void);
7797c478bdstevel@tonic-gate
7807c478bdstevel@tonic-gate/* Halt the processor (called after an unrecoverable error). */
7817c478bdstevel@tonic-gatevoid stop (void) __attribute__ ((noreturn));
7827c478bdstevel@tonic-gate
7837c478bdstevel@tonic-gate/* Reboot the system.  */
7847c478bdstevel@tonic-gatevoid grub_reboot (void) __attribute__ ((noreturn));
7857c478bdstevel@tonic-gate
7867c478bdstevel@tonic-gate/* Halt the system, using APM if possible. If NO_APM is true, don't use
7877c478bdstevel@tonic-gate   APM even if it is available.  */
7887c478bdstevel@tonic-gatevoid grub_halt (int no_apm) __attribute__ ((noreturn));
7897c478bdstevel@tonic-gate
7907c478bdstevel@tonic-gate/* Copy MAP to the drive map and set up int13_handler.  */
7917c478bdstevel@tonic-gatevoid set_int13_handler (unsigned short *map);
7927c478bdstevel@tonic-gate
7937c478bdstevel@tonic-gate/* Set up int15_handler.  */
7947c478bdstevel@tonic-gatevoid set_int15_handler (void);
7957c478bdstevel@tonic-gate
7967c478bdstevel@tonic-gate/* Restore the original int15 handler.  */
7977c478bdstevel@tonic-gatevoid unset_int15_handler (void);
7987c478bdstevel@tonic-gate
7997c478bdstevel@tonic-gate/* Track the int13 handler to probe I/O address space.  */
8007c478bdstevel@tonic-gatevoid track_int13 (int drive);
8017c478bdstevel@tonic-gate
8027c478bdstevel@tonic-gate/* The key map.  */
8037c478bdstevel@tonic-gateextern unsigned short bios_key_map[];
8047c478bdstevel@tonic-gateextern unsigned short ascii_key_map[];
8057c478bdstevel@tonic-gateextern unsigned short io_map[];
8067c478bdstevel@tonic-gate
8077c478bdstevel@tonic-gate/* calls for direct boot-loader chaining */
8087c478bdstevel@tonic-gatevoid chain_stage1 (unsigned long segment, unsigned long offset,
8097c478bdstevel@tonic-gate		   unsigned long part_table_addr)
8107c478bdstevel@tonic-gate     __attribute__ ((noreturn));
8117c478bdstevel@tonic-gatevoid chain_stage2 (unsigned long segment, unsigned long offset,
8127c478bdstevel@tonic-gate		   int second_sector)
8137c478bdstevel@tonic-gate     __attribute__ ((noreturn));
8147c478bdstevel@tonic-gate
8157c478bdstevel@tonic-gate/* do some funky stuff, then boot linux */
8167c478bdstevel@tonic-gatevoid linux_boot (void) __attribute__ ((noreturn));
8177c478bdstevel@tonic-gate
8187c478bdstevel@tonic-gate/* do some funky stuff, then boot bzImage linux */
8197c478bdstevel@tonic-gatevoid big_linux_boot (void) __attribute__ ((noreturn));
8207c478bdstevel@tonic-gate
8217c478bdstevel@tonic-gate/* booting a multiboot executable */
8227c478bdstevel@tonic-gatevoid multi_boot (int start, int mb_info) __attribute__ ((noreturn));
8237c478bdstevel@tonic-gate
8247c478bdstevel@tonic-gate/* If LINEAR is nonzero, then set the Intel processor to linear mode.
8257c478bdstevel@tonic-gate   Otherwise, bit 20 of all memory accesses is always forced to zero,
8267c478bdstevel@tonic-gate   causing a wraparound effect for bugwards compatibility with the
8277c478bdstevel@tonic-gate   8086 CPU. */
8287c478bdstevel@tonic-gatevoid gateA20 (int linear);
8297c478bdstevel@tonic-gate
8307c478bdstevel@tonic-gate/* memory probe routines */
8317c478bdstevel@tonic-gateint get_memsize (int type);
8327c478bdstevel@tonic-gateint get_eisamemsize (void);
8337c478bdstevel@tonic-gate
8347c478bdstevel@tonic-gate/* Fetch the next entry in the memory map and return the continuation
8357c478bdstevel@tonic-gate   value.  DESC is a pointer to the descriptor buffer, and CONT is the
8367c478bdstevel@tonic-gate   previous continuation value (0 to get the first entry in the
8377c478bdstevel@tonic-gate   map). */
8387c478bdstevel@tonic-gateint get_mmap_entry (struct mmar_desc *desc, int cont);
8397c478bdstevel@tonic-gate
8407c478bdstevel@tonic-gate/* Get the linear address of a ROM configuration table. Return zero,
8417c478bdstevel@tonic-gate   if fails.  */
8427c478bdstevel@tonic-gateunsigned long get_rom_config_table (void);
8437c478bdstevel@tonic-gate
8447c478bdstevel@tonic-gate/* Get APM BIOS information.  */
8457c478bdstevel@tonic-gatevoid get_apm_info (void);
8467c478bdstevel@tonic-gate
8477c478bdstevel@tonic-gate/* Get VBE controller information.  */
8487c478bdstevel@tonic-gateint get_vbe_controller_info (struct vbe_controller *controller);
8497c478bdstevel@tonic-gate
8507c478bdstevel@tonic-gate/* Get VBE mode information.  */
8517c478bdstevel@tonic-gateint get_vbe_mode_info (int mode_number, struct vbe_mode *mode);
8527c478bdstevel@tonic-gate
8537c478bdstevel@tonic-gate/* Set VBE mode.  */
8547c478bdstevel@tonic-gateint set_vbe_mode (int mode_number);
8557c478bdstevel@tonic-gate
8567c478bdstevel@tonic-gate/* Return the data area immediately following our code. */
8577c478bdstevel@tonic-gateint get_code_end (void);
8587c478bdstevel@tonic-gate
8597c478bdstevel@tonic-gate/* low-level timing info */
8607c478bdstevel@tonic-gateint getrtsecs (void);
8617c478bdstevel@tonic-gateint currticks (void);
8627c478bdstevel@tonic-gate
8637c478bdstevel@tonic-gate/* Clear the screen. */
8647c478bdstevel@tonic-gatevoid cls (void);
8657c478bdstevel@tonic-gate
8667c478bdstevel@tonic-gate/* Turn on/off cursor. */
8677c478bdstevel@tonic-gateint setcursor (int on);
8687c478bdstevel@tonic-gate
8697c478bdstevel@tonic-gate/* Get the current cursor position (where 0,0 is the top left hand
8707c478bdstevel@tonic-gate   corner of the screen).  Returns packed values, (RET >> 8) is x,
8717c478bdstevel@tonic-gate   (RET & 0xff) is y. */
8727c478bdstevel@tonic-gateint getxy (void);
8737c478bdstevel@tonic-gate
8747c478bdstevel@tonic-gate/* Set the cursor position. */
8757c478bdstevel@tonic-gatevoid gotoxy (int x, int y);
8767c478bdstevel@tonic-gate
8777c478bdstevel@tonic-gate/* Displays an ASCII character.  IBM displays will translate some
8787c478bdstevel@tonic-gate   characters to special graphical ones (see the DISP_* constants). */
8797c478bdstevel@tonic-gatevoid grub_putchar (int c);
8807c478bdstevel@tonic-gate
8817c478bdstevel@tonic-gate/* Wait for a keypress, and return its packed BIOS/ASCII key code.
8827c478bdstevel@tonic-gate   Use ASCII_CHAR(ret) to extract the ASCII code. */
8837c478bdstevel@tonic-gateint getkey (void);
8847c478bdstevel@tonic-gate
8857c478bdstevel@tonic-gate/* Like GETKEY, but doesn't block, and returns -1 if no keystroke is
8867c478bdstevel@tonic-gate   available. */
8877c478bdstevel@tonic-gateint checkkey (void);
8887c478bdstevel@tonic-gate
8897c478bdstevel@tonic-gate/* Low-level disk I/O */
8907c478bdstevel@tonic-gateint get_diskinfo (int drive, struct geometry *geometry);
8917c478bdstevel@tonic-gateint biosdisk (int subfunc, int drive, struct geometry *geometry,
8929890706Hans Rosenfeld    unsigned long long sector, int nsec, int segment);
8937c478bdstevel@tonic-gatevoid stop_floppy (void);
8947c478bdstevel@tonic-gate
8957c478bdstevel@tonic-gate/* Command-line interface functions. */
8967c478bdstevel@tonic-gate#ifndef STAGE1_5
8977c478bdstevel@tonic-gate
8987c478bdstevel@tonic-gate/* The flags for the builtins.  */
8997c478bdstevel@tonic-gate#define BUILTIN_CMDLINE		0x1	/* Run in the command-line.  */
9007c478bdstevel@tonic-gate#define BUILTIN_MENU		0x2	/* Run in the menu.  */
9017c478bdstevel@tonic-gate#define BUILTIN_TITLE		0x4	/* Only for the command title.  */
9027c478bdstevel@tonic-gate#define BUILTIN_SCRIPT		0x8	/* Run in the script.  */
9037c478bdstevel@tonic-gate#define BUILTIN_NO_ECHO		0x10	/* Don't print command on booting. */
9047c478bdstevel@tonic-gate#define BUILTIN_HELP_LIST	0x20	/* Show help in listing.  */
9057c478bdstevel@tonic-gate
9067c478bdstevel@tonic-gate/* The table for a builtin.  */
9077c478bdstevel@tonic-gatestruct builtin
9087c478bdstevel@tonic-gate{
9097c478bdstevel@tonic-gate  /* The command name.  */
9107c478bdstevel@tonic-gate  char *name;
9117c478bdstevel@tonic-gate  /* The callback function.  */
9127c478bdstevel@tonic-gate  int (*func) (char *, int);
9137c478bdstevel@tonic-gate  /* The combination of the flags defined above.  */
9147c478bdstevel@tonic-gate  int flags;
9157c478bdstevel@tonic-gate  /* The short version of the documentation.  */
9167c478bdstevel@tonic-gate  char *short_doc;
9177c478bdstevel@tonic-gate  /* The long version of the documentation.  */
9187c478bdstevel@tonic-gate  char *long_doc;
9197c478bdstevel@tonic-gate};
9207c478bdstevel@tonic-gate
9217c478bdstevel@tonic-gate/* All the builtins are registered in this.  */
9227c478bdstevel@tonic-gateextern struct builtin *builtin_table[];
9237c478bdstevel@tonic-gate
9247c478bdstevel@tonic-gate/* The constants for kernel types.  */
9257c478bdstevel@tonic-gatetypedef enum
9267c478bdstevel@tonic-gate{
9277c478bdstevel@tonic-gate  KERNEL_TYPE_NONE,		/* None is loaded.  */
9287c478bdstevel@tonic-gate  KERNEL_TYPE_MULTIBOOT,	/* Multiboot.  */
9297c478bdstevel@tonic-gate  KERNEL_TYPE_LINUX,		/* Linux.  */
9307c478bdstevel@tonic-gate  KERNEL_TYPE_BIG_LINUX,	/* Big Linux.  */
9317c478bdstevel@tonic-gate  KERNEL_TYPE_FREEBSD,		/* FreeBSD.  */
9327c478bdstevel@tonic-gate  KERNEL_TYPE_NETBSD,		/* NetBSD.  */
9337c478bdstevel@tonic-gate  KERNEL_TYPE_CHAINLOADER	/* Chainloader.  */
9347c478bdstevel@tonic-gate}
9357c478bdstevel@tonic-gatekernel_t;
9367c478bdstevel@tonic-gate
9377c478bdstevel@tonic-gateextern kernel_t kernel_type;
9387c478bdstevel@tonic-gateextern int show_menu;
9397c478bdstevel@tonic-gateextern int grub_timeout;
9407c478bdstevel@tonic-gate
9417c478bdstevel@tonic-gatevoid init_builtins (void);
9427c478bdstevel@tonic-gatevoid init_config (void);
9437c478bdstevel@tonic-gatechar *skip_to (int after_equal, char *cmdline);
9447c478bdstevel@tonic-gatestruct builtin *find_command (char *command);
9457c478bdstevel@tonic-gatevoid print_cmdline_message (int forever);
9467c478bdstevel@tonic-gatevoid enter_cmdline (char *heap, int forever);
9477c478bdstevel@tonic-gateint run_script (char *script, char *heap);
9487c478bdstevel@tonic-gate#endif
9497c478bdstevel@tonic-gate
9507c478bdstevel@tonic-gate/* C library replacement functions with identical semantics. */
9517c478bdstevel@tonic-gatevoid grub_printf (const char *format,...);
9527c478bdstevel@tonic-gateint grub_sprintf (char *buffer, const char *format, ...);
9537c478bdstevel@tonic-gateint grub_tolower (int c);
9547c478bdstevel@tonic-gateint grub_isspace (int c);
9557c478bdstevel@tonic-gateint grub_strncat (char *s1, const char *s2, int n);
9567c478bdstevel@tonic-gatevoid grub_memcpy(void *dest, const void *src, int len);
9577c478bdstevel@tonic-gatevoid *grub_memmove (void *to, const void *from, int len);
9587c478bdstevel@tonic-gatevoid *grub_memset (void *start, int c, int len);
9597c478bdstevel@tonic-gateint grub_strncat (char *s1, const char *s2, int n);
9607c478bdstevel@tonic-gatechar *grub_strstr (const char *s1, const char *s2);
9617c478bdstevel@tonic-gateint grub_memcmp (const char *s1, const char *s2, int n);
9627c478bdstevel@tonic-gateint grub_strcmp (const char *s1, const char *s2);
9637c478bdstevel@tonic-gateint grub_strlen (const char *str);
9647c478bdstevel@tonic-gatechar *grub_strcpy (char *dest, const char *src);
965eb2bd66vikramchar *grub_strchr (char *str, char c);
9667c478bdstevel@tonic-gate
9671fac5a6setjevoid noisy_printf (const char *format,...);
9681fac5a6setje
9697c478bdstevel@tonic-gate#ifndef GRUB_UTIL
9707c478bdstevel@tonic-gatetypedef unsigned long grub_jmp_buf[6];
9717c478bdstevel@tonic-gate#else
9727c478bdstevel@tonic-gate/* In the grub shell, use the libc jmp_buf instead.  */
9737c478bdstevel@tonic-gate# include <setjmp.h>
9747c478bdstevel@tonic-gate# define grub_jmp_buf jmp_buf
9757c478bdstevel@tonic-gate#endif
9767c478bdstevel@tonic-gate
9777c478bdstevel@tonic-gate#ifdef GRUB_UTIL
9787c478bdstevel@tonic-gate# define grub_setjmp	setjmp
9797c478bdstevel@tonic-gate# define grub_longjmp	longjmp
9807c478bdstevel@tonic-gate#else /* ! GRUB_UTIL */
9817c478bdstevel@tonic-gateint grub_setjmp (grub_jmp_buf env);
9827c478bdstevel@tonic-gatevoid grub_longjmp (grub_jmp_buf env, int val);
9837c478bdstevel@tonic-gate#endif /* ! GRUB_UTIL */
9847c478bdstevel@tonic-gate
9857c478bdstevel@tonic-gate/* The environment for restarting Stage 2.  */
9867c478bdstevel@tonic-gateextern grub_jmp_buf restart_env;
9877c478bdstevel@tonic-gate/* The environment for restarting the command-line interface.  */
9887c478bdstevel@tonic-gateextern grub_jmp_buf restart_cmdline_env;
9897c478bdstevel@tonic-gate
9907c478bdstevel@tonic-gate/* misc */
9917c478bdstevel@tonic-gatevoid init_page (void);
9927c478bdstevel@tonic-gatevoid print_error (void);
9939890706Hans Rosenfeldchar *convert_to_ascii (char *buf, int c, unsigned long long num);
9947c478bdstevel@tonic-gateint get_cmdline (char *prompt, char *cmdline, int maxlen,
9957c478bdstevel@tonic-gate		 int echo_char, int history);
9967c478bdstevel@tonic-gateint substring (const char *s1, const char *s2);
9977c478bdstevel@tonic-gateint nul_terminate (char *str);
9987c478bdstevel@tonic-gateint get_based_digit (int c, int base);
9997c478bdstevel@tonic-gateint safe_parse_maxint (char **str_ptr, int *myint_ptr);
100035497fcsetjeint memcheck (unsigned long start, unsigned long len);
10017c478bdstevel@tonic-gatevoid grub_putstr (const char *str);
10027c478bdstevel@tonic-gate
10037c478bdstevel@tonic-gate#ifndef NO_DECOMPRESSION
10047c478bdstevel@tonic-gate/* Compression support. */
10057c478bdstevel@tonic-gateint gunzip_test_header (void);
10067c478bdstevel@tonic-gateint gunzip_read (char *buf, int len);
10077c478bdstevel@tonic-gate#endif /* NO_DECOMPRESSION */
10087c478bdstevel@tonic-gate
10099890706Hans Rosenfeldint rawread (int drive, unsigned long long sector, int byte_offset, int byte_len,
1010342440ePrasad Singamsetty	char *buf);
10119890706Hans Rosenfeldint devread (unsigned long long sector, int byte_offset, int byte_len, char *buf);
10129890706Hans Rosenfeldint rawwrite (int drive, unsigned long long sector, char *buf);
10139890706Hans Rosenfeldint devwrite (unsigned long long sector, int sector_len, char *buf);
10147c478bdstevel@tonic-gate
10157c478bdstevel@tonic-gate/* Parse a device string and initialize the global parameters. */
10167c478bdstevel@tonic-gatechar *set_device (char *device);
10177c478bdstevel@tonic-gateint open_device (void);
10187c478bdstevel@tonic-gateint real_open_partition (int flags);
10197c478bdstevel@tonic-gateint open_partition (void);
10207c478bdstevel@tonic-gateint next_partition (unsigned long drive, unsigned long dest,
10217c478bdstevel@tonic-gate		    unsigned long *partition, int *type,
10229890706Hans Rosenfeld		    unsigned long long *start, unsigned long long *len,
10239890706Hans Rosenfeld		    unsigned long long *offset, int *entry,
10249890706Hans Rosenfeld                   unsigned long long *ext_offset,
10259890706Hans Rosenfeld                   unsigned long long *gpt_offset, int *gpt_count,
102644bc912Richard Yao                   int *gpt_size, char *buf);
10277c478bdstevel@tonic-gate
10287c478bdstevel@tonic-gate/* Sets device to the one represented by the SAVED_* parameters. */
10297c478bdstevel@tonic-gateint make_saved_active (void);
10307c478bdstevel@tonic-gate
10317c478bdstevel@tonic-gate/* Set or clear the current root partition's hidden flag.  */
10327c478bdstevel@tonic-gateint set_partition_hidden_flag (int hidden);
10337c478bdstevel@tonic-gate
10347c478bdstevel@tonic-gate/* Open a file or directory on the active device, using GRUB's
10357c478bdstevel@tonic-gate   internal filesystem support. */
10367c478bdstevel@tonic-gateint grub_open (char *filename);
10377c478bdstevel@tonic-gate
10387c478bdstevel@tonic-gate/* Read LEN bytes into BUF from the file that was opened with
10397c478bdstevel@tonic-gate   GRUB_OPEN.  If LEN is -1, read all the remaining data in the file.  */
10407c478bdstevel@tonic-gateint grub_read (char *buf, int len);
10417c478bdstevel@tonic-gate
10427c478bdstevel@tonic-gate/* Reposition a file offset.  */
10437c478bdstevel@tonic-gateint grub_seek (int offset);
10447c478bdstevel@tonic-gate
10457c478bdstevel@tonic-gate/* Close a file.  */
10467c478bdstevel@tonic-gatevoid grub_close (void);
10477c478bdstevel@tonic-gate
10487c478bdstevel@tonic-gate/* List the contents of the directory that was opened with GRUB_OPEN,
10497c478bdstevel@tonic-gate   printing all completions. */
10507c478bdstevel@tonic-gateint dir (char *dirname);
10517c478bdstevel@tonic-gate
10527c478bdstevel@tonic-gateint set_bootdev (int hdbias);
10537c478bdstevel@tonic-gate
10547c478bdstevel@tonic-gate/* Display statistics on the current active device. */
10557c478bdstevel@tonic-gatevoid print_fsys_type (void);
10567c478bdstevel@tonic-gate
10577c478bdstevel@tonic-gate/* Display device and filename completions. */
10587c478bdstevel@tonic-gatevoid print_a_completion (char *filename);
10597c478bdstevel@tonic-gateint print_completions (int is_filename, int is_completion);
10607c478bdstevel@tonic-gate
10617c478bdstevel@tonic-gate/* Copies the current partition data to the desired address. */
10627c478bdstevel@tonic-gatevoid copy_current_part_entry (char *buf);
10637c478bdstevel@tonic-gate
10647c478bdstevel@tonic-gate#ifndef STAGE1_5
10657c478bdstevel@tonic-gatevoid bsd_boot (kernel_t type, int bootdev, char *arg)
10667c478bdstevel@tonic-gate     __attribute__ ((noreturn));
10677c478bdstevel@tonic-gate
10687c478bdstevel@tonic-gate/* Define flags for load_image here.  */
10697c478bdstevel@tonic-gate/* Don't pass a Linux's mem option automatically.  */
10707c478bdstevel@tonic-gate#define KERNEL_LOAD_NO_MEM_OPTION	(1 << 0)
10717c478bdstevel@tonic-gate
10727c478bdstevel@tonic-gatekernel_t load_image (char *kernel, char *arg, kernel_t suggested_type,
10737c478bdstevel@tonic-gate		     unsigned long load_flags);
10747c478bdstevel@tonic-gate
10757c478bdstevel@tonic-gateint load_module (char *module, char *arg);
10767c478bdstevel@tonic-gateint load_initrd (char *initrd);
10777c478bdstevel@tonic-gate
10787c478bdstevel@tonic-gateint check_password(char *entered, char* expected, password_t type);
10797c478bdstevel@tonic-gate#endif
10807c478bdstevel@tonic-gate
10817c478bdstevel@tonic-gatevoid init_bios_info (void);
10827c478bdstevel@tonic-gate
10837c478bdstevel@tonic-gate#endif /* ASM_FILE */
10847c478bdstevel@tonic-gate
10857c478bdstevel@tonic-gate#endif /* ! GRUB_SHARED_HEADER */
1086