boot.h

Go to the documentation of this file.
00001 /*      boot.h - Info between different parts of boot.  Author: Kees J. Bot
00002  */
00003 
00004 #ifndef DEBUG
00005 #define DEBUG 0
00006 #endif
00007 
00008 /* Constants describing the metal: */
00009 
00010 #define SECTOR_SIZE     512
00011 #define SECTOR_SHIFT    9
00012 #define RATIO(b)                ((b) / SECTOR_SIZE)
00013 
00014 #define PARAMSEC        1       /* Sector containing boot parameters. */
00015 
00016 #define DSKBASE         0x1E    /* Floppy disk parameter vector. */
00017 #define DSKPARSIZE      11      /* There are this many bytes of parameters. */
00018 
00019 #define ESC             '\33'   /* Escape key. */
00020 
00021 #define HEADERPOS      0x00600L /* Place for an array of struct exec's. */
00022 
00023 #define FREEPOS        0x08000L /* Memory from FREEPOS to caddr is free to
00024                                  * play with.
00025                                  */
00026 #if BIOS
00027 #define MSEC_PER_TICK     55    /* Clock does 18.2 ticks per second. */
00028 #define TICKS_PER_DAY 0x1800B0L /* After 24 hours it wraps. */
00029 #endif
00030 
00031 #if UNIX
00032 #define MSEC_PER_TICK   1000    /* Clock does 18.2 ticks per second. */
00033 #define TICKS_PER_DAY  86400L   /* Doesn't wrap, but that doesn't matter. */
00034 #endif
00035 
00036 #define BOOTPOS        0x07C00L /* Bootstraps are loaded here. */
00037 #define SIGNATURE       0xAA55  /* Proper bootstraps have this signature. */
00038 #define SIGNATOFF       510     /* Offset within bootblock. */
00039 
00040 /* BIOS video modes. */
00041 #define MONO_MODE       0x07    /* 80x25 monochrome. */
00042 #define COLOR_MODE      0x03    /* 80x25 color. */
00043 
00044 
00045 /* Variables shared with boothead.s: */
00046 #ifndef EXTERN
00047 #define EXTERN extern
00048 #endif
00049 
00050 typedef struct vector {         /* 8086 vector */
00051         u16_t   offset;
00052         u16_t   segment;
00053 } vector;
00054 
00055 EXTERN vector rem_part;         /* Boot partition table entry. */
00056 
00057 EXTERN u32_t caddr, daddr;      /* Code and data address of the boot program. */
00058 EXTERN u32_t runsize;           /* Size of this program. */
00059 
00060 EXTERN u16_t device;            /* Drive being booted from. */
00061 
00062 typedef struct {                /* One chunk of free memory. */
00063         u32_t   base;           /* Start byte. */
00064         u32_t   size;           /* Number of bytes. */
00065 } memory;
00066 
00067 EXTERN memory mem[3];           /* List of available memory. */
00068 EXTERN int mon_return;          /* Monitor stays in memory? */
00069 
00070 typedef struct bios_env
00071 {
00072         u16_t ax;
00073         u16_t bx;
00074         u16_t cx;
00075         u16_t flags;
00076 } bios_env_t;
00077 
00078 #define FL_CARRY        0x0001  /* carry flag */
00079 
00080 /* Functions defined by boothead.s: */
00081 
00082 void exit(int code);
00083                         /* Exit the monitor. */
00084 u32_t mon2abs(void *ptr);
00085                         /* Local monitor address to absolute address. */
00086 u32_t vec2abs(vector *vec);
00087                         /* Vector to absolute address. */
00088 void raw_copy(u32_t dstaddr, u32_t srcaddr, u32_t count);
00089                         /* Copy bytes from anywhere to anywhere. */
00090 u16_t get_word(u32_t addr);
00091                         /* Get a word from anywhere. */
00092 void put_word(u32_t addr, U16_t word);
00093                         /* Put a word anywhere. */
00094 void relocate(void);
00095                         /* Switch to a copy of this program. */
00096 int dev_open(void), dev_close(void);
00097                         /* Open device and determine params / close device. */
00098 int dev_boundary(u32_t sector);
00099                         /* True if sector is on a track boundary. */
00100 int readsectors(u32_t bufaddr, u32_t sector, U8_t count);
00101                         /* Read 1 or more sectors from "device". */
00102 int writesectors(u32_t bufaddr, u32_t sector, U8_t count);
00103                         /* Write 1 or more sectors to "device". */
00104 int getch(void);
00105                         /* Read a keypress. */
00106 void scan_keyboard(void);       
00107                         /* Read keypress directly from kb controller. */
00108 void ungetch(int c);
00109                         /* Undo a keypress. */
00110 int escape(void);
00111                         /* True if escape typed. */
00112 void putch(int c);
00113                         /* Send a character to the screen. */
00114 #if BIOS
00115 void pause(void);
00116                         /* Wait for an interrupt. */
00117 void serial_init(int line);
00118 #endif                  /* Enable copying console I/O to a serial line. */
00119 
00120 void set_mode(unsigned mode);
00121 void clear_screen(void);
00122                         /* Set video mode / clear the screen. */
00123 
00124 u16_t get_bus(void);
00125                         /* System bus type, XT, AT, or MCA. */
00126 u16_t get_video(void);
00127                         /* Display type, MDA to VGA. */
00128 u32_t get_tick(void);
00129                         /* Current value of the clock tick counter. */
00130 
00131 void bootstrap(int device, struct part_entry *entry);
00132                         /* Execute a bootstrap routine for a different O.S. */
00133 void minix(u32_t koff, u32_t kcs, u32_t kds,
00134                                 char *bootparams, size_t paramsize, u32_t aout);
00135                         /* Start Minix. */
00136 void int15(bios_env_t *);
00137 
00138 
00139 /* Shared between boot.c and bootimage.c: */
00140 
00141 /* Sticky attributes. */
00142 #define E_SPECIAL       0x01    /* These are known to the program. */
00143 #define E_DEV           0x02    /* The value is a device name. */
00144 #define E_RESERVED      0x04    /* May not be set by user, e.g. 'boot' */
00145 #define E_STICKY        0x07    /* Don't go once set. */
00146 
00147 /* Volatile attributes. */
00148 #define E_VAR           0x08    /* Variable */
00149 #define E_FUNCTION      0x10    /* Function definition. */
00150 
00151 /* Variables, functions, and commands. */
00152 typedef struct environment {
00153         struct environment *next;
00154         char    flags;
00155         char    *name;          /* name = value */
00156         char    *arg;           /* name(arg) {value} */
00157         char    *value;
00158         char    *defval;        /* Safehouse for default values. */
00159 } environment;
00160 
00161 EXTERN environment *env;        /* Lists the environment. */
00162 
00163 char *b_value(char *name);      /* Get/set the value of a variable. */
00164 int b_setvar(int flags, char *name, char *value);
00165 
00166 void parse_code(char *code);    /* Parse boot monitor commands. */
00167 
00168 extern int fsok;        /* True if the boot device contains an FS. */
00169 EXTERN u32_t lowsec;    /* Offset to the file system on the boot device. */
00170 
00171 /* Called by boot.c: */
00172 
00173 void bootminix(void);           /* Load and start a Minix image. */
00174 
00175 
00176 /* Called by bootimage.c: */
00177 
00178 void readerr(off_t sec, int err);
00179                         /* Report a read error. */
00180 char *ul2a(u32_t n, unsigned b), *ul2a10(u32_t n);
00181                         /* Transform u32_t to ASCII at base b or base 10. */
00182 long a2l(char *a);
00183                         /* Cheap atol(). */
00184 unsigned a2x(char *a);
00185                         /* ASCII to hex. */
00186 dev_t name2dev(char *name);
00187                         /* Translate a device name to a device number. */
00188 int numprefix(char *s, char **ps);
00189                         /* True for a numeric prefix. */
00190 int numeric(char *s);
00191                         /* True for a numeric string. */
00192 char *unix_err(int err);
00193                         /* Give a descriptive text for some UNIX errors. */
00194 int run_trailer(void);
00195                         /* Run the trailer function. */
00196 
00197 #if DOS
00198 /* The monitor runs under MS-DOS. */
00199 extern char PSP[256];   /* Program Segment Prefix. */
00200 EXTERN char *vdisk;     /* Name of the virtual disk. */
00201 EXTERN char *drun;      /* Initial command from DOS command line. */
00202 #else
00203 /* The monitor uses only the BIOS. */
00204 #define DOS     0
00205 #endif
00206 
00207 void readblock(off_t, char *, int);
00208 void delay(char *);
00209 
00210 /*
00211  * $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $
00212  */

Generated on Fri Apr 14 22:56:37 2006 for minix by  doxygen 1.4.6