compat.S: add setlocale(3)
[minix3.git] / boot / boot.h
blob50160ba258e686c55f8fb0f0a4742c2846231e50
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 typedef struct { /* One chunk of free memory. */
71 u32_t base_lo; /* Start byte. */
72 u32_t base_hi;
73 u32_t size_lo; /* Number of bytes. */
74 u32_t size_hi; /* Number of bytes. */
75 u32_t type;
76 u32_t acpi_attrs;
77 } e820_memory;
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
87 u16_t ax;
88 u16_t bx;
89 u16_t cx;
90 u16_t flags;
91 } bios_env_t;
93 #define FL_CARRY 0x0001 /* carry flag */
95 /* Functions defined by boothead.s: */
97 void exit(int code);
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. */
109 void relocate(void);
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);
122 int getch(void);
123 /* Read a keypress. */
124 void scan_keyboard(void);
125 /* Read keypress directly from kb controller. */
126 void ungetch(int c);
127 /* Undo a keypress. */
128 int escape(void);
129 /* True if escape typed. */
130 void putch(int c);
131 /* Send a character to the screen. */
132 #if BIOS
133 void pause(void);
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. */
142 u16_t get_bus(void);
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);
153 /* Start Minix. */
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. */
160 void reset(void);
161 /* */
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;
178 char flags;
179 char *name; /* name = value */
180 char *arg; /* name(arg) {value} */
181 char *value;
182 char *defval; /* Safehouse for default values. */
183 } environment;
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);
208 /* Cheap atol(). */
209 unsigned a2x(const char *a);
210 /* ASCII to hex. */
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. */
222 #if DOS
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. */
227 #else
228 /* The monitor uses only the BIOS. */
229 #define DOS 0
230 #endif
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 $