0200 /* boot.h - Info between
different parts of boot. Author: Kees J. Bot
0201 */
0202
0203 /* Constants describing the metal: */
0204
0205 #define SECTOR_SIZE
512
0206 #define SECTOR_SHIFT 9
0207 #define RATIO
(BLOCK_SIZE / SECTOR_SIZE)
0208
0209 #define PARAMSEC
1 /* Sector containing boot parameters.
*/
0210
0211 #define DSKBASE
0x1E /* Floppy disk parameter vector. */
0212 #define DSKPARSIZE
11 /* There are this many bytes of parameters.
*/
0213
0214 #define ESC
'\33' /* Escape key. */
0215
0216 #define HEADERPOS
0x00600L /* Place for an array of struct exec's. */
0217
0218 #define FREEPOS
0x08000L /* Memory from FREEPOS to caddr is free to
0219
* play with.
0220
*/
0221 #if BIOS
0222 #define MSEC_PER_TICK
55 /* Clock does 18.2 ticks per second. */
0223 #define TICKS_PER_DAY 0x1800B0L /* After 24 hours
it wraps. */
0224 #endif
0225
0226 #if UNIX
0227 #define MSEC_PER_TICK 1000
/* Clock does 18.2 ticks per second. */
0228 #define TICKS_PER_DAY 86400L
/* Doesn't wrap, but that doesn't matter. */
0229 #endif
0230
0231 #define BOOTPOS
0x07C00L /* Bootstraps are loaded here. */
0232 #define SIGNATURE
0xAA55 /* Proper bootstraps have this signature. */
0233 #define SIGNATOFF
510 /* Offset within bootblock. */
0234
0235 /* BIOS video modes. */
0236 #define MONO_MODE
0x07 /* 80x25 monochrome. */
0237 #define COLOR_MODE
0x03 /* 80x25 color. */
0238
0239
0240 /* Variables shared with boothead.s: */
0241 #ifndef EXTERN
0242 #define EXTERN extern
0243 #endif
0244
0245 typedef struct vector
{ /* 8086 vector */
0246
u16_t offset;
0247
u16_t segment;
0248 } vector;
0249
0250 EXTERN vector rem_part;
/* Boot partition table entry. */
0251
0252 EXTERN u32_t caddr,
daddr; /* Code and data address of the boot
program. */
0253 EXTERN u32_t runsize;
/* Size of this program. */
0254
0255 EXTERN u16_t device;
/* Drive being booted from. */
0256
0257 typedef struct
{
/* One chunk of free memory. */
0258
u32_t base;
/* Start byte. */
0259
u32_t size;
/* Number of bytes. */
0260 } memory;
0261
0262 EXTERN memory mem[3];
/* List of available memory. */
0263
0264
0265 /* Functions defined by boothead.s: */
0266
0267 void exit(int code);
0268
/* Exit the monitor. */
0269 u32_t mon2abs(void *ptr);
0270
/* Local monitor address to absolute address. */
0271 u32_t vec2abs(vector *vec);
0272
/* Vector to absolute address. */
0273 void raw_copy(u32_t dstaddr, u32_t srcaddr, u32_t
count);
0274
/* Copy bytes from anywhere to anywhere. */
0275 u16_t get_word(u32_t addr);
0276
/* Get a word from anywhere. */
0277 void put_word(u32_t addr, U16_t word);
0278
/* Put a word anywhere. */
0279 void relocate(void);
0280
/* Switch to a copy of this program. */
0281 int dev_open(void), dev_close(void);
0282
/* Open device and determine params / close device. */
0283 int dev_boundary(u32_t sector);
0284
/* True if sector is on a track boundary. */
0285 int readsectors(u32_t bufaddr, u32_t sector, U8_t
count);
0286
/* Read 1 or more sectors from "device". */
0287 int writesectors(u32_t bufaddr, u32_t sector,
U8_t count);
0288
/* Write 1 or more sectors to "device". */
0289 int getch(void);
0290
/* Read a keypress. */
0291 int escape(void);
0292
/* True if escape typed. */
0293 void putch(int c);
0294
/* Send a character to the screen. */
0295 void set_mode(unsigned mode);
0296 void clear_screen(void);
0297
/* Set video mode / clear the screen. */
0298
0299 u16_t get_bus(void);
0300
/* System bus type, XT, AT, or MCA. */
0301 u16_t get_video(void);
0302
/* Display type, MDA to VGA. */
0303 u32_t get_tick(void);
0304
/* Current value of the clock tick counter. */
0305
0306 void bootstrap(int device, struct part_entry *entry);
0307
/* Execute a bootstrap routine for a different O.S. */
0308 u32_t minix(u32_t koff, u32_t kcs, u32_t kds,
0309
char *bootparams, size_t paramsize, u32_t aout);
0310
/* Start Minix. */
0311
0312
0313 /* Shared between boot.c and bootimage.c: */
0314
0315 /* Sticky attributes. */
0316 #define E_SPECIAL
0x01 /* These are known to the program. */
0317 #define E_DEV
0x02 /* The value is a device name. */
0318 #define E_RESERVED
0x04 /* May not be set by user, e.g. 'boot' */
0319 #define E_STICKY
0x07 /* Don't go once set. */
0320
0321 /* Volatile attributes. */
0322 #define E_VAR
0x08 /* Variable */
0323 #define E_FUNCTION
0x10 /* Function definition. */
0324
0325 /* Variables, functions, and commands. */
0326 typedef struct environment {
0327
struct environment *next;
0328
char flags;
0329
char *name;
/* name = value */
0330
char *arg;
/* name(arg) {value} */
0331
char *value;
0332
char *defval;
/* Safehouse for default values. */
0333 } environment;
0334
0335 EXTERN environment *env;
/* Lists the environment. */
0336
0337 char *b_value(char *name);
/* Get/set the value of a variable. */
0338 int b_setvar(int flags, char *name, char *value);
0339
0340 EXTERN int fsok;
/* True if the boot device contains an FS. */
0341 EXTERN u32_t lowsec; /* Offset
to the file system on the boot device. */
0342 EXTERN u32_t reboot_code; /* Program returned
by a rebooting Minix. */
0343
0344 /* Called by boot.c: */
0345
0346 void bootminix(void);
/* Load and start a Minix image. */
0347
0348
0349 /* Called by bootimage.c: */
0350
0351 void readerr(off_t sec, int err);
0352
/* Report a read error. */
0353 char *ul2a(u32_t n, unsigned b), *ul2a10(u32_t
n);
0354
/* Transform u32_t to ASCII at base b or base 10. */
0355 long a2l(char *a);
0356
/* Cheap atol(). */
0357 unsigned a2x(char *a);
0358
/* ASCII to hex. */
0359 dev_t name2dev(char *name);
0360
/* Translate a device name to a device number. */
0361 int numprefix(char *s, char **ps);
0362
/* True for a numeric prefix. */
0363 int numeric(char *s);
0364
/* True for a numeric string. */
0365 char *unix_err(int err);
0366
/* Give a descriptive text for some UNIX errors. */
0367 int run_trailer(void);
0368
/* Run the trailer function. */
0369
0370 #if BIOS
0371 /* Use the kernel printf(): */
0372 void printk(char *fmt, ...);
0373 #define printf printk
0374 #endif
0375
0376 #if DOS
0377 /* The monitor runs under MS-DOS. */
0378 extern char PSP[256]; /* Program Segment
Prefix. */
0379 EXTERN char *vdisk; /*
Name of the virtual disk. */
0380 EXTERN char *drun;
/* Initial command from DOS command line. */
0381 #else
0382 /* The monitor uses only the BIOS. */
0383 #define DOS 0
0384 #endif