more stack for boot
[minix.git] / boot / boot.h
blob3b9bc65281dd821f355522c28846c01fe7f6f8b5
1 /* boot.h - Info between different parts of boot. Author: Kees J. Bot
2 */
4 #ifndef DEBUG
5 #define DEBUG 0
6 #endif
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
24 * play with.
26 #if BIOS
27 #define MSEC_PER_TICK 55 /* Clock does 18.2 ticks per second. */
28 #define TICKS_PER_DAY 0x1800B0L /* After 24 hours it wraps. */
29 #endif
31 #if UNIX
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. */
34 #endif
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: */
46 #ifndef EXTERN
47 #define EXTERN extern
48 #endif
50 typedef struct vector { /* 8086 vector */
51 u16_t offset;
52 u16_t segment;
53 } 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. */
68 } memory;
70 EXTERN memory mem[3]; /* List of available memory. */
71 EXTERN int mon_return; /* Monitor stays in memory? */
72 EXTERN int cdbooted; /* Did we boot from CD? (Set by boothead.s.) */
74 typedef struct bios_env
76 u16_t ax;
77 u16_t bx;
78 u16_t cx;
79 u16_t flags;
80 } bios_env_t;
82 #define FL_CARRY 0x0001 /* carry flag */
84 /* Functions defined by boothead.s: */
86 void exit(int code);
87 /* Exit the monitor. */
88 u32_t mon2abs(void *ptr);
89 /* Local monitor address to absolute address. */
90 u32_t vec2abs(vector *vec);
91 /* Vector to absolute address. */
92 void raw_copy(u32_t dstaddr, u32_t srcaddr, u32_t count);
93 /* Copy bytes from anywhere to anywhere. */
94 u16_t get_word(u32_t addr);
95 /* Get a word from anywhere. */
96 void put_word(u32_t addr, U16_t word);
97 /* Put a word anywhere. */
98 void relocate(void);
99 /* Switch to a copy of this program. */
100 int dev_open(void), dev_close(void);
101 /* Open device and determine params / close device. */
102 int dev_boundary(u32_t sector);
103 /* True if sector is on a track boundary. */
104 int readsectors(u32_t bufaddr, u32_t sector, u8_t count);
105 /* Read 1 or more sectors from "device". */
106 int writesectors(u32_t bufaddr, u32_t sector, u8_t count);
107 /* Write 1 or more sectors to "device". */
109 int biosreadsectors(u32_t bufaddr, u32_t sector, u8_t count);
111 int getch(void);
112 /* Read a keypress. */
113 void scan_keyboard(void);
114 /* Read keypress directly from kb controller. */
115 void ungetch(int c);
116 /* Undo a keypress. */
117 int escape(void);
118 /* True if escape typed. */
119 void putch(int c);
120 /* Send a character to the screen. */
121 #if BIOS
122 void pause(void);
123 /* Wait for an interrupt. */
124 void serial_init(int line);
125 #endif /* Enable copying console I/O to a serial line. */
127 void set_mode(unsigned mode);
128 void clear_screen(void);
129 /* Set video mode / clear the screen. */
131 u16_t get_bus(void);
132 /* System bus type, XT, AT, or MCA. */
133 u16_t get_video(void);
134 /* Display type, MDA to VGA. */
135 u32_t get_tick(void);
136 /* Current value of the clock tick counter. */
138 void bootstrap(int device, struct part_entry *entry);
139 /* Execute a bootstrap routine for a different O.S. */
140 void minix(u32_t koff, u32_t kcs, u32_t kds,
141 char *bootparams, size_t paramsize, u32_t aout);
142 /* Start Minix. */
143 void int15(bios_env_t *);
146 /* Shared between boot.c and bootimage.c: */
148 /* Sticky attributes. */
149 #define E_SPECIAL 0x01 /* These are known to the program. */
150 #define E_DEV 0x02 /* The value is a device name. */
151 #define E_RESERVED 0x04 /* May not be set by user, e.g. 'boot' */
152 #define E_STICKY 0x07 /* Don't go once set. */
154 /* Volatile attributes. */
155 #define E_VAR 0x08 /* Variable */
156 #define E_FUNCTION 0x10 /* Function definition. */
158 /* Variables, functions, and commands. */
159 typedef struct environment {
160 struct environment *next;
161 char flags;
162 char *name; /* name = value */
163 char *arg; /* name(arg) {value} */
164 char *value;
165 char *defval; /* Safehouse for default values. */
166 } environment;
168 EXTERN environment *env; /* Lists the environment. */
170 char *b_value(const char *name); /* Get/set the value of a variable. */
171 int b_setvar(int flags, char *name, char *value);
172 void b_unset(const char *name);
174 void parse_code(char *code); /* Parse boot monitor commands. */
176 extern int fsok; /* True if the boot device contains an FS. */
177 EXTERN u32_t lowsec; /* Offset to the file system on the boot device. */
179 /* Called by boot.c: */
181 void bootminix(void); /* Load and start a Minix image. */
184 /* Called by bootimage.c: */
186 void readerr(off_t sec, int err);
187 /* Report a read error. */
188 char *ul2a(u32_t n, unsigned b), *ul2a10(u32_t n);
189 /* Transform u32_t to ASCII at base b or base 10. */
190 long a2l(const char *a);
191 /* Cheap atol(). */
192 unsigned a2x(const char *a);
193 /* ASCII to hex. */
194 dev_t name2dev(char *name);
195 /* Translate a device name to a device number. */
196 int numprefix(char *s, char **ps);
197 /* True for a numeric prefix. */
198 int numeric(char *s);
199 /* True for a numeric string. */
200 char *unix_err(int err);
201 /* Give a descriptive text for some UNIX errors. */
202 int run_trailer(void);
203 /* Run the trailer function. */
205 #if DOS
206 /* The monitor runs under MS-DOS. */
207 extern char PSP[256]; /* Program Segment Prefix. */
208 EXTERN char *vdisk; /* Name of the virtual disk. */
209 EXTERN char *drun; /* Initial command from DOS command line. */
210 #else
211 /* The monitor uses only the BIOS. */
212 #define DOS 0
213 #endif
215 void readblock(off_t, char *, int);
216 void delay(const char *);
219 * $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $