1 /* boot.h - Info between different parts of boot. Author: Kees J. Bot
8 /* Constants describing the metal: */
10 #define SECTOR_SIZE 512
11 #define SECTOR_SHIFT 9
12 #define RATIO(b) ((b) / SECTOR_SIZE)
14 #define PARAMSEC 1 /* Sector containing boot parameters. */
16 #define DSKBASE 0x1E /* Floppy disk parameter vector. */
17 #define DSKPARSIZE 11 /* There are this many bytes of parameters. */
19 #define ESC '\33' /* Escape key. */
21 #define HEADERPOS 0x00600L /* Place for an array of struct exec's. */
23 #define FREEPOS 0x08000L /* Memory from FREEPOS to caddr is free to
27 #define MSEC_PER_TICK 55 /* Clock does 18.2 ticks per second. */
28 #define TICKS_PER_DAY 0x1800B0L /* After 24 hours it wraps. */
32 #define MSEC_PER_TICK 1000 /* Clock does 18.2 ticks per second. */
33 #define TICKS_PER_DAY 86400L /* Doesn't wrap, but that doesn't matter. */
36 #define BOOTPOS 0x07C00L /* Bootstraps are loaded here. */
37 #define SIGNATURE 0xAA55 /* Proper bootstraps have this signature. */
38 #define SIGNATOFF 510 /* Offset within bootblock. */
40 /* BIOS video modes. */
41 #define MONO_MODE 0x07 /* 80x25 monochrome. */
42 #define COLOR_MODE 0x03 /* 80x25 color. */
45 /* Variables shared with boothead.s: */
50 typedef struct vector
{ /* 8086 vector */
55 EXTERN vector rem_part
; /* Boot partition table entry. */
57 EXTERN u32_t caddr
, daddr
; /* Code and data address of the boot program. */
58 EXTERN u32_t runsize
; /* Size of this program. */
60 EXTERN u16_t device
; /* Drive being booted from. */
61 EXTERN u16_t cddevice
; /* Drive that is CD if known. */
63 #define CDNAME "cd" /* Name of the CD device. */
65 typedef struct { /* One chunk of free memory. */
66 u32_t base
; /* Start byte. */
67 u32_t size
; /* Number of bytes. */
70 typedef struct { /* One chunk of free memory. */
71 u32_t base_lo
; /* Start byte. */
73 u32_t size_lo
; /* Number of bytes. */
74 u32_t size_hi
; /* Number of bytes. */
79 EXTERN memory mem
[3]; /* List of available memory. */
80 EXTERN e820_memory emem
[16]; /* List of available memory. */
81 EXTERN
int mem_entries
;
82 EXTERN
int mon_return
; /* Monitor stays in memory? */
83 EXTERN
int cdbooted
; /* Did we boot from CD? (Set by boothead.s.) */
85 typedef struct bios_env
93 #define FL_CARRY 0x0001 /* carry flag */
95 /* Functions defined by boothead.s: */
98 /* Exit the monitor. */
99 u32_t
mon2abs(void *ptr
);
100 /* Local monitor address to absolute address. */
101 u32_t
vec2abs(vector
*vec
);
102 /* Vector to absolute address. */
103 void raw_copy(u32_t dstaddr
, u32_t srcaddr
, u32_t count
);
104 /* Copy bytes from anywhere to anywhere. */
105 u16_t
get_word(u32_t addr
);
106 /* Get a word from anywhere. */
107 void put_word(u32_t addr
, u16_t word
);
108 /* Put a word anywhere. */
110 /* Switch to a copy of this program. */
111 int dev_open(void), dev_close(void);
112 /* Open device and determine params / close device. */
113 int dev_boundary(u32_t sector
);
114 /* True if sector is on a track boundary. */
115 int readsectors(u32_t bufaddr
, u32_t sector
, u8_t count
);
116 /* Read 1 or more sectors from "device". */
117 int writesectors(u32_t bufaddr
, u32_t sector
, u8_t count
);
118 /* Write 1 or more sectors to "device". */
120 int biosreadsectors(u32_t bufaddr
, u32_t sector
, u8_t count
);
123 /* Read a keypress. */
124 void scan_keyboard(void);
125 /* Read keypress directly from kb controller. */
127 /* Undo a keypress. */
129 /* True if escape typed. */
131 /* Send a character to the screen. */
134 /* Wait for an interrupt. */
135 void serial_init(int line
);
136 #endif /* Enable copying console I/O to a serial line. */
138 void set_mode(unsigned mode
);
139 void clear_screen(void);
140 /* Set video mode / clear the screen. */
143 /* System bus type, XT, AT, or MCA. */
144 u16_t
get_video(void);
145 /* Display type, MDA to VGA. */
146 u32_t
get_tick(void);
147 /* Current value of the clock tick counter. */
149 void bootstrap(int device
, struct part_entry
*entry
);
150 /* Execute a bootstrap routine for a different O.S. */
151 void minix(u32_t koff
, u32_t kcs
, u32_t kds
,
152 char *bootparams
, size_t paramsize
, u32_t aout
);
155 void int15(bios_env_t
*);
156 /* Do an "INT 15" call, primarily for APM. */
157 void scan_keyboard(void);
158 /* Read keyboard character.
159 * Needs to be done in case one is waiting. */
163 /* Shared between boot.c and bootimage.c: */
165 /* Sticky attributes. */
166 #define E_SPECIAL 0x01 /* These are known to the program. */
167 #define E_DEV 0x02 /* The value is a device name. */
168 #define E_RESERVED 0x04 /* May not be set by user, e.g. 'boot' */
169 #define E_STICKY 0x07 /* Don't go once set. */
171 /* Volatile attributes. */
172 #define E_VAR 0x08 /* Variable */
173 #define E_FUNCTION 0x10 /* Function definition. */
175 /* Variables, functions, and commands. */
176 typedef struct environment
{
177 struct environment
*next
;
179 char *name
; /* name = value */
180 char *arg
; /* name(arg) {value} */
182 char *defval
; /* Safehouse for default values. */
185 EXTERN environment
*env
; /* Lists the environment. */
187 char *b_value(const char *name
); /* Get/set the value of a variable. */
188 int b_setvar(int flags
, char *name
, char *value
);
189 void b_unset(const char *name
);
191 void parse_code(char *code
); /* Parse boot monitor commands. */
193 extern int fsok
; /* True if the boot device contains an FS. */
194 EXTERN u32_t lowsec
; /* Offset to the file system on the boot device. */
196 /* Called by boot.c: */
198 void bootminix(void); /* Load and start a Minix image. */
201 /* Called by bootimage.c: */
203 void readerr(off_t sec
, int err
);
204 /* Report a read error. */
205 char *ul2a(u32_t n
, unsigned b
), *ul2a10(u32_t n
);
206 /* Transform u32_t to ASCII at base b or base 10. */
207 long a2l(const char *a
);
209 unsigned a2x(const char *a
);
211 dev_t
name2dev(char *name
);
212 /* Translate a device name to a device number. */
213 int numprefix(char *s
, char **ps
);
214 /* True for a numeric prefix. */
215 int numeric(char *s
);
216 /* True for a numeric string. */
217 char *unix_err(int err
);
218 /* Give a descriptive text for some UNIX errors. */
219 int run_trailer(void);
220 /* Run the trailer function. */
223 /* The monitor runs under MS-DOS. */
224 extern char PSP
[256]; /* Program Segment Prefix. */
225 EXTERN
char *vdisk
; /* Name of the virtual disk. */
226 EXTERN
char *drun
; /* Initial command from DOS command line. */
228 /* The monitor uses only the BIOS. */
232 void readblock(off_t
, char *, int);
233 void delay(const char *);
236 * $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $