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

📄 shared.h

📁 i386的bootloader源码grub
💻 H
📖 第 1 页 / 共 2 页
字号:
/* shared.h - definitions used in all GRUB-specific code *//* *  GRUB  --  GRand Unified Bootloader *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc. * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* *  Generic defines to use anywhere */#ifndef GRUB_SHARED_HEADER#define GRUB_SHARED_HEADER	1#include <config.h>/* Add an underscore to a C symbol in assembler code if needed. */#ifdef HAVE_ASM_USCORE# define EXT_C(sym) _ ## sym#else# define EXT_C(sym) sym#endif/* Maybe redirect memory requests through grub_scratch_mem. */#ifdef GRUB_UTILextern char *grub_scratch_mem;# define RAW_ADDR(x) ((x) + (int) grub_scratch_mem)# define RAW_SEG(x) (RAW_ADDR ((x) << 4) >> 4)#else# define RAW_ADDR(x) (x)# define RAW_SEG(x) (x)#endif/* *  Integer sizes */#define MAXINT     0x7FFFFFFF/* Maximum command line size. Before you blindly increase this value,   see the comment in char_io.c (get_cmdline).  */#define MAX_CMDLINE 1600#define NEW_HEAPSIZE 1500/* 512-byte scratch area */#define SCRATCHADDR  RAW_ADDR (0x77e00)#define SCRATCHSEG   RAW_SEG (0x77e0)/* *  This is the location of the raw device buffer.  It is 31.5K *  in size. */#define BUFFERLEN   0x7e00#define BUFFERADDR  RAW_ADDR (0x70000)#define BUFFERSEG   RAW_SEG (0x7000)#define BOOT_PART_TABLE	RAW_ADDR (0x07be)/* *  BIOS disk defines */#define BIOSDISK_READ			0x0#define BIOSDISK_WRITE			0x1#define BIOSDISK_ERROR_GEOMETRY		0x100#define BIOSDISK_FLAG_LBA_EXTENSION	0x1#define BIOSDISK_FLAG_CDROM		0x2/* *  This is the filesystem (not raw device) buffer. *  It is 32K in size, do not overrun! */#define FSYS_BUFLEN  0x8000#define FSYS_BUF RAW_ADDR (0x68000)/* Command-line buffer for Multiboot kernels and modules. This area   includes the area into which Stage 1.5 and Stage 1 are loaded, but   that's no problem.  */#define MB_CMDLINE_BUF		RAW_ADDR (0x2000)#define MB_CMDLINE_BUFLEN	0x6000/* The buffer for the password.  */#define PASSWORD_BUF		RAW_ADDR (0x78000)#define PASSWORD_BUFLEN		0x200/* The buffer for the command-line.  */#define CMDLINE_BUF		(PASSWORD_BUF + PASSWORD_BUFLEN)#define CMDLINE_BUFLEN		MAX_CMDLINE/* The kill buffer for the command-line.  */#define KILL_BUF		(CMDLINE_BUF + CMDLINE_BUFLEN)#define KILL_BUFLEN		MAX_CMDLINE/* The history buffer for the command-line.  */#define HISTORY_BUF		(KILL_BUF + KILL_BUFLEN)#define HISTORY_SIZE		5#define HISTORY_BUFLEN		(MAX_CMDLINE * HISTORY_SIZE)/* The buffer for the completion.  */#define COMPLETION_BUF		(HISTORY_BUF + HISTORY_BUFLEN)#define COMPLETION_BUFLEN	MAX_CMDLINE/* The buffer for the unique string.  */#define UNIQUE_BUF		(COMPLETION_BUF + COMPLETION_BUFLEN)#define UNIQUE_BUFLEN		MAX_CMDLINE/* The buffer for the menu entries.  */#define MENU_BUF		(UNIQUE_BUF + UNIQUE_BUFLEN)#define MENU_BUFLEN		(0x8000 + PASSWORD_BUF - UNIQUE_BUF)/* The size of the drive map.  */#define DRIVE_MAP_SIZE		8/* The size of the key map.  */#define KEY_MAP_SIZE		128/* The size of the io map.  */#define IO_MAP_SIZE		128/* *  Linux setup parameters */#define LINUX_MAGIC_SIGNATURE		0x53726448	/* "HdrS" */#define LINUX_DEFAULT_SETUP_SECTS	4#define LINUX_FLAG_CAN_USE_HEAP		0x80#define LINUX_INITRD_MAX_ADDRESS	0x38000000#define LINUX_MAX_SETUP_SECTS		64#define LINUX_BOOT_LOADER_TYPE		0x71#define LINUX_HEAP_END_OFFSET		(0x9000 - 0x200)#define LINUX_BZIMAGE_ADDR		RAW_ADDR (0x100000)#define LINUX_ZIMAGE_ADDR		RAW_ADDR (0x10000)#define LINUX_OLD_REAL_MODE_ADDR	RAW_ADDR (0x90000)#define LINUX_SETUP_STACK		0x9000#define LINUX_FLAG_BIG_KERNEL		0x1/* Linux's video mode selection support. Actually I hate it!  */#define LINUX_VID_MODE_NORMAL		0xFFFF#define LINUX_VID_MODE_EXTENDED		0xFFFE#define LINUX_VID_MODE_ASK		0xFFFD#define LINUX_CL_OFFSET			0x9000#define LINUX_CL_END_OFFSET		0x90FF#define LINUX_SETUP_MOVE_SIZE		0x9100#define LINUX_CL_MAGIC			0xA33F/* *  General disk stuff */#define SECTOR_SIZE		0x200#define SECTOR_BITS		9#define BIOS_FLAG_FIXED_DISK	0x80#define BOOTSEC_LOCATION		RAW_ADDR (0x7C00)#define BOOTSEC_SIGNATURE		0xAA55#define BOOTSEC_BPB_OFFSET		0x3#define BOOTSEC_BPB_LENGTH		0x3B#define BOOTSEC_BPB_SYSTEM_ID		0x3#define BOOTSEC_BPB_HIDDEN_SECTORS	0x1C#define BOOTSEC_PART_OFFSET		0x1BE#define BOOTSEC_PART_LENGTH		0x40#define BOOTSEC_SIG_OFFSET		0x1FE#define BOOTSEC_LISTSIZE		8/* Not bad, perhaps.  */#define NETWORK_DRIVE	0x20/* *  GRUB specific information *    (in LSB order) */#include <stage1.h>#define STAGE2_VER_MAJ_OFFS	0x6#define STAGE2_INSTALLPART	0x8#define STAGE2_SAVED_ENTRYNO	0xc#define STAGE2_STAGE2_ID	0x10#define STAGE2_FORCE_LBA	0x11#define STAGE2_VER_STR_OFFS	0x12/* Stage 2 identifiers */#define STAGE2_ID_STAGE2		0#define STAGE2_ID_FFS_STAGE1_5		1#define STAGE2_ID_E2FS_STAGE1_5		2#define STAGE2_ID_FAT_STAGE1_5		3#define STAGE2_ID_MINIX_STAGE1_5	4#define STAGE2_ID_REISERFS_STAGE1_5	5#define STAGE2_ID_VSTAFS_STAGE1_5	6#define STAGE2_ID_JFS_STAGE1_5		7#define STAGE2_ID_XFS_STAGE1_5		8#define STAGE2_ID_ISO9660_STAGE1_5	9#define STAGE2_ID_UFS2_STAGE1_5		10#ifndef STAGE1_5# define STAGE2_ID	STAGE2_ID_STAGE2#else# if defined(FSYS_FFS)#  define STAGE2_ID	STAGE2_ID_FFS_STAGE1_5# elif defined(FSYS_EXT2FS)#  define STAGE2_ID	STAGE2_ID_E2FS_STAGE1_5# elif defined(FSYS_FAT)#  define STAGE2_ID	STAGE2_ID_FAT_STAGE1_5# elif defined(FSYS_MINIX)#  define STAGE2_ID	STAGE2_ID_MINIX_STAGE1_5# elif defined(FSYS_REISERFS)#  define STAGE2_ID	STAGE2_ID_REISERFS_STAGE1_5# elif defined(FSYS_VSTAFS)#  define STAGE2_ID	STAGE2_ID_VSTAFS_STAGE1_5# elif defined(FSYS_JFS)#  define STAGE2_ID	STAGE2_ID_JFS_STAGE1_5# elif defined(FSYS_XFS)#  define STAGE2_ID	STAGE2_ID_XFS_STAGE1_5# elif defined(FSYS_ISO9660)#  define STAGE2_ID	STAGE2_ID_ISO9660_STAGE1_5# elif defined(FSYS_UFS2)#  define STAGE2_ID	STAGE2_ID_UFS2_STAGE1_5# else#  error "unknown Stage 2"# endif#endif/* *  defines for use when switching between real and protected mode */#define CR0_PE_ON	0x1#define CR0_PE_OFF	0xfffffffe#define PROT_MODE_CSEG	0x8#define PROT_MODE_DSEG  0x10#define PSEUDO_RM_CSEG	0x18#define PSEUDO_RM_DSEG	0x20#define STACKOFF	(0x2000 - 0x10)#define PROTSTACKINIT   (FSYS_BUF - 0x10)/* * Assembly code defines * * "EXT_C" is assumed to be defined in the Makefile by the configure *   command. */#define ENTRY(x) .globl EXT_C(x) ; EXT_C(x):#define VARIABLE(x) ENTRY(x)#define K_RDWR  	0x60	/* keyboard data & cmds (read/write) */#define K_STATUS	0x64	/* keyboard status */#define K_CMD		0x64	/* keybd ctlr command (write-only) */#define K_OBUF_FUL 	0x01	/* output buffer full */#define K_IBUF_FUL 	0x02	/* input buffer full */#define KC_CMD_WIN	0xd0	/* read  output port */#define KC_CMD_WOUT	0xd1	/* write output port */#define KB_OUTPUT_MASK  0xdd	/* enable output buffer full interrupt				   enable data line				   enable clock line */#define KB_A20_ENABLE   0x02/* Codes for getchar. */#define ASCII_CHAR(x)   ((x) & 0xFF)#if !defined(GRUB_UTIL) || !defined(HAVE_LIBCURSES)# define KEY_LEFT        0x4B00# define KEY_RIGHT       0x4D00# define KEY_UP          0x4800# define KEY_DOWN        0x5000# define KEY_IC          0x5200	/* insert char */# define KEY_DC          0x5300	/* delete char */# define KEY_BACKSPACE   0x0008# define KEY_HOME        0x4700# define KEY_END         0x4F00# define KEY_NPAGE       0x5100# define KEY_PPAGE       0x4900# define A_NORMAL        0x7# define A_REVERSE       0x70#elif defined(HAVE_NCURSES_CURSES_H)# include <ncurses/curses.h>#elif defined(HAVE_NCURSES_H)# include <ncurses.h>#elif defined(HAVE_CURSES_H)# include <curses.h>#endif/* In old BSD curses, A_NORMAL and A_REVERSE are not defined, so we   define them here if they are undefined.  */#ifndef A_NORMAL# define A_NORMAL	0#endif /* ! A_NORMAL */#ifndef A_REVERSE# ifdef A_STANDOUT#  define A_REVERSE	A_STANDOUT# else /* ! A_STANDOUT */#  define A_REVERSE	0# endif /* ! A_STANDOUT */#endif /* ! A_REVERSE *//* Define ACS_* ourselves, since the definitions are not consistent among   various curses implementations.  */#undef ACS_ULCORNER#undef ACS_URCORNER#undef ACS_LLCORNER#undef ACS_LRCORNER#undef ACS_HLINE#undef ACS_VLINE#undef ACS_LARROW#undef ACS_RARROW#undef ACS_UARROW#undef ACS_DARROW#define ACS_ULCORNER	'+'#define ACS_URCORNER	'+'#define ACS_LLCORNER	'+'#define ACS_LRCORNER	'+'#define ACS_HLINE	'-'#define ACS_VLINE	'|'#define ACS_LARROW	'<'#define ACS_RARROW	'>'#define ACS_UARROW	'^'#define ACS_DARROW	'v'/* Special graphics characters for IBM displays. */#define DISP_UL		218#define DISP_UR		191#define DISP_LL		192#define DISP_LR		217#define DISP_HORIZ	196#define DISP_VERT	179#define DISP_LEFT	0x1b#define DISP_RIGHT	0x1a#define DISP_UP		0x18#define DISP_DOWN	0x19/* Remap some libc-API-compatible function names so that we prevent   circularararity. */#ifndef WITHOUT_LIBC_STUBS#define memmove grub_memmove#define memcpy grub_memmove	/* we don't need a separate memcpy */#define memset grub_memset#define isspace grub_isspace#define printf grub_printf#define sprintf grub_sprintf#undef putchar#define putchar grub_putchar#define strncat grub_strncat#define strstr grub_strstr#define memcmp grub_memcmp#define strcmp grub_strcmp#define tolower grub_tolower#define strlen grub_strlen#define strcpy grub_strcpy#endif /* WITHOUT_LIBC_STUBS */#ifndef ASM_FILE/* *  Below this should be ONLY defines and other constructs for C code. *//* multiboot stuff */#include "mb_header.h"#include "mb_info.h"/* For the Linux/i386 boot protocol version 2.03.  */struct linux_kernel_header{  char code1[0x0020];  unsigned short cl_magic;		/* Magic number 0xA33F */  unsigned short cl_offset;		/* The offset of command line */  char code2[0x01F1 - 0x0020 - 2 - 2];  unsigned char setup_sects;		/* The size of the setup in sectors */  unsigned short root_flags;		/* If the root is mounted readonly */  unsigned short syssize;		/* obsolete */  unsigned short swap_dev;		/* obsolete */  unsigned short ram_size;		/* obsolete */  unsigned short vid_mode;		/* Video mode control */  unsigned short root_dev;		/* Default root device number */  unsigned short boot_flag;		/* 0xAA55 magic number */  unsigned short jump;			/* Jump instruction */  unsigned long header;			/* Magic signature "HdrS" */  unsigned short version;		/* Boot protocol version supported */  unsigned long realmode_swtch;		/* Boot loader hook */  unsigned long start_sys;		/* Points to kernel version string */  unsigned char type_of_loader;		/* Boot loader identifier */  unsigned char loadflags;		/* Boot protocol option flags */  unsigned short setup_move_size;	/* Move to high memory size */  unsigned long code32_start;		/* Boot loader hook */  unsigned long ramdisk_image;		/* initrd load address */  unsigned long ramdisk_size;		/* initrd size */  unsigned long bootsect_kludge;	/* obsolete */  unsigned short heap_end_ptr;		/* Free memory after setup end */  unsigned short pad1;			/* Unused */  char *cmd_line_ptr;			/* Points to the kernel command line */  unsigned long initrd_addr_max;	/* The highest address of initrd */} __attribute__ ((packed));/* Memory map address range descriptor used by GET_MMAP_ENTRY. */struct mmar_desc{  unsigned long desc_len;	/* Size of this descriptor. */  unsigned long long addr;	/* Base address. */  unsigned long long length;	/* Length in bytes. */  unsigned long type;		/* Type of address range. */} __attribute__ ((packed));/* VBE controller information.  */struct vbe_controller{  unsigned char signature[4];  unsigned short version;  unsigned long oem_string;  unsigned long capabilities;  unsigned long video_mode;  unsigned short total_memory;  unsigned short oem_software_rev;  unsigned long oem_vendor_name;  unsigned long oem_product_name;  unsigned long oem_product_rev;  unsigned char reserved[222];  unsigned char oem_data[256];} __attribute__ ((packed));/* VBE mode information.  */struct vbe_mode{  unsigned short mode_attributes;  unsigned char win_a_attributes;  unsigned char win_b_attributes;  unsigned short win_granularity;  unsigned short win_size;  unsigned short win_a_segment;  unsigned short win_b_segment;  unsigned long win_func;  unsigned short bytes_per_scanline;  /* >=1.2 */  unsigned short x_resolution;  unsigned short y_resolution;  unsigned char x_char_size;  unsigned char y_char_size;  unsigned char number_of_planes;  unsigned char bits_per_pixel;  unsigned char number_of_banks;  unsigned char memory_model;  unsigned char bank_size;  unsigned char number_of_image_pages;  unsigned char reserved0;  /* direct color */  unsigned char red_mask_size;  unsigned char red_field_position;  unsigned char green_mask_size;  unsigned char green_field_position;  unsigned char blue_mask_size;  unsigned char blue_field_position;  unsigned char reserved_mask_size;  unsigned char reserved_field_position;  unsigned char direct_color_mode_info;  /* >=2.0 */  unsigned long phys_base;  unsigned long reserved1;  unsigned short reversed2;  /* >=3.0 */  unsigned short linear_bytes_per_scanline;  unsigned char banked_number_of_image_pages;  unsigned char linear_number_of_image_pages;  unsigned char linear_red_mask_size;  unsigned char linear_red_field_position;  unsigned char linear_green_mask_size;  unsigned char linear_green_field_position;  unsigned char linear_blue_mask_size;  unsigned char linear_blue_field_position;  unsigned char linear_reserved_mask_size;  unsigned char linear_reserved_field_position;  unsigned long max_pixel_clock;

⌨️ 快捷键说明

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