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