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. */
62 typedef struct { /* One chunk of free memory. */
63 u32_t base
; /* Start byte. */
64 u32_t size
; /* Number of bytes. */
67 EXTERN memory mem
[3]; /* List of available memory. */
68 EXTERN
int mon_return
; /* Monitor stays in memory? */
70 typedef struct bios_env
78 #define FL_CARRY 0x0001 /* carry flag */
80 /* Functions defined by boothead.s: */
83 /* Exit the monitor. */
84 u32_t
mon2abs(void *ptr
);
85 /* Local monitor address to absolute address. */
86 u32_t
vec2abs(vector
*vec
);
87 /* Vector to absolute address. */
88 void raw_copy(u32_t dstaddr
, u32_t srcaddr
, u32_t count
);
89 /* Copy bytes from anywhere to anywhere. */
90 u16_t
get_word(u32_t addr
);
91 /* Get a word from anywhere. */
92 void put_word(u32_t addr
, U16_t word
);
93 /* Put a word anywhere. */
95 /* Switch to a copy of this program. */
96 int dev_open(void), dev_close(void);
97 /* Open device and determine params / close device. */
98 int dev_boundary(u32_t sector
);
99 /* True if sector is on a track boundary. */
100 int readsectors(u32_t bufaddr
, u32_t sector
, U8_t count
);
101 /* Read 1 or more sectors from "device". */
102 int writesectors(u32_t bufaddr
, u32_t sector
, U8_t count
);
103 /* Write 1 or more sectors to "device". */
105 /* Read a keypress. */
106 void scan_keyboard(void);
107 /* Read keypress directly from kb controller. */
109 /* Undo a keypress. */
111 /* True if escape typed. */
113 /* Send a character to the screen. */
116 /* Wait for an interrupt. */
117 void serial_init(int line
);
118 #endif /* Enable copying console I/O to a serial line. */
120 void set_mode(unsigned mode
);
121 void clear_screen(void);
122 /* Set video mode / clear the screen. */
125 /* System bus type, XT, AT, or MCA. */
126 u16_t
get_video(void);
127 /* Display type, MDA to VGA. */
128 u32_t
get_tick(void);
129 /* Current value of the clock tick counter. */
131 void bootstrap(int device
, struct part_entry
*entry
);
132 /* Execute a bootstrap routine for a different O.S. */
133 void minix(u32_t koff
, u32_t kcs
, u32_t kds
,
134 char *bootparams
, size_t paramsize
, u32_t aout
);
136 void int15(bios_env_t
*);
139 /* Shared between boot.c and bootimage.c: */
141 /* Sticky attributes. */
142 #define E_SPECIAL 0x01 /* These are known to the program. */
143 #define E_DEV 0x02 /* The value is a device name. */
144 #define E_RESERVED 0x04 /* May not be set by user, e.g. 'boot' */
145 #define E_STICKY 0x07 /* Don't go once set. */
147 /* Volatile attributes. */
148 #define E_VAR 0x08 /* Variable */
149 #define E_FUNCTION 0x10 /* Function definition. */
151 /* Variables, functions, and commands. */
152 typedef struct environment
{
153 struct environment
*next
;
155 char *name
; /* name = value */
156 char *arg
; /* name(arg) {value} */
158 char *defval
; /* Safehouse for default values. */
161 EXTERN environment
*env
; /* Lists the environment. */
163 char *b_value(char *name
); /* Get/set the value of a variable. */
164 int b_setvar(int flags
, char *name
, char *value
);
166 void parse_code(char *code
); /* Parse boot monitor commands. */
168 extern int fsok
; /* True if the boot device contains an FS. */
169 EXTERN u32_t lowsec
; /* Offset to the file system on the boot device. */
171 /* Called by boot.c: */
173 void bootminix(void); /* Load and start a Minix image. */
176 /* Called by bootimage.c: */
178 void readerr(off_t sec
, int err
);
179 /* Report a read error. */
180 char *ul2a(u32_t n
, unsigned b
), *ul2a10(u32_t n
);
181 /* Transform u32_t to ASCII at base b or base 10. */
184 unsigned a2x(char *a
);
186 dev_t
name2dev(char *name
);
187 /* Translate a device name to a device number. */
188 int numprefix(char *s
, char **ps
);
189 /* True for a numeric prefix. */
190 int numeric(char *s
);
191 /* True for a numeric string. */
192 char *unix_err(int err
);
193 /* Give a descriptive text for some UNIX errors. */
194 int run_trailer(void);
195 /* Run the trailer function. */
198 /* The monitor runs under MS-DOS. */
199 extern char PSP
[256]; /* Program Segment Prefix. */
200 EXTERN
char *vdisk
; /* Name of the virtual disk. */
201 EXTERN
char *drun
; /* Initial command from DOS command line. */
203 /* The monitor uses only the BIOS. */
207 void readblock(off_t
, char *, int);
211 * $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $