source: trunk/minix/boot/boot.h@ 12

Last change on this file since 12 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 6.0 KB
Line 
1/* boot.h - Info between different parts of boot. Author: Kees J. Bot
2 */
3
4#ifndef DEBUG
5#define DEBUG 0
6#endif
7
8/* Constants describing the metal: */
9
10#define SECTOR_SIZE 512
11#define SECTOR_SHIFT 9
12#define RATIO(b) ((b) / SECTOR_SIZE)
13
14#define PARAMSEC 1 /* Sector containing boot parameters. */
15
16#define DSKBASE 0x1E /* Floppy disk parameter vector. */
17#define DSKPARSIZE 11 /* There are this many bytes of parameters. */
18
19#define ESC '\33' /* Escape key. */
20
21#define HEADERPOS 0x00600L /* Place for an array of struct exec's. */
22
23#define FREEPOS 0x08000L /* Memory from FREEPOS to caddr is free to
24 * play with.
25 */
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
30
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
35
36#define BOOTPOS 0x07C00L /* Bootstraps are loaded here. */
37#define SIGNATURE 0xAA55 /* Proper bootstraps have this signature. */
38#define SIGNATOFF 510 /* Offset within bootblock. */
39
40/* BIOS video modes. */
41#define MONO_MODE 0x07 /* 80x25 monochrome. */
42#define COLOR_MODE 0x03 /* 80x25 color. */
43
44
45/* Variables shared with boothead.s: */
46#ifndef EXTERN
47#define EXTERN extern
48#endif
49
50typedef struct vector { /* 8086 vector */
51 u16_t offset;
52 u16_t segment;
53} vector;
54
55EXTERN vector rem_part; /* Boot partition table entry. */
56
57EXTERN u32_t caddr, daddr; /* Code and data address of the boot program. */
58EXTERN u32_t runsize; /* Size of this program. */
59
60EXTERN u16_t device; /* Drive being booted from. */
61
62typedef struct { /* One chunk of free memory. */
63 u32_t base; /* Start byte. */
64 u32_t size; /* Number of bytes. */
65} memory;
66
67EXTERN memory mem[3]; /* List of available memory. */
68EXTERN int mon_return; /* Monitor stays in memory? */
69
70typedef struct bios_env
71{
72 u16_t ax;
73 u16_t bx;
74 u16_t cx;
75 u16_t flags;
76} bios_env_t;
77
78#define FL_CARRY 0x0001 /* carry flag */
79
80/* Functions defined by boothead.s: */
81
82void exit(int code);
83 /* Exit the monitor. */
84u32_t mon2abs(void *ptr);
85 /* Local monitor address to absolute address. */
86u32_t vec2abs(vector *vec);
87 /* Vector to absolute address. */
88void raw_copy(u32_t dstaddr, u32_t srcaddr, u32_t count);
89 /* Copy bytes from anywhere to anywhere. */
90u16_t get_word(u32_t addr);
91 /* Get a word from anywhere. */
92void put_word(u32_t addr, U16_t word);
93 /* Put a word anywhere. */
94void relocate(void);
95 /* Switch to a copy of this program. */
96int dev_open(void), dev_close(void);
97 /* Open device and determine params / close device. */
98int dev_boundary(u32_t sector);
99 /* True if sector is on a track boundary. */
100int readsectors(u32_t bufaddr, u32_t sector, U8_t count);
101 /* Read 1 or more sectors from "device". */
102int writesectors(u32_t bufaddr, u32_t sector, U8_t count);
103 /* Write 1 or more sectors to "device". */
104int getch(void);
105 /* Read a keypress. */
106void scan_keyboard(void);
107 /* Read keypress directly from kb controller. */
108void ungetch(int c);
109 /* Undo a keypress. */
110int escape(void);
111 /* True if escape typed. */
112void putch(int c);
113 /* Send a character to the screen. */
114#if BIOS
115void pause(void);
116 /* Wait for an interrupt. */
117void serial_init(int line);
118#endif /* Enable copying console I/O to a serial line. */
119
120void set_mode(unsigned mode);
121void clear_screen(void);
122 /* Set video mode / clear the screen. */
123
124u16_t get_bus(void);
125 /* System bus type, XT, AT, or MCA. */
126u16_t get_video(void);
127 /* Display type, MDA to VGA. */
128u32_t get_tick(void);
129 /* Current value of the clock tick counter. */
130
131void bootstrap(int device, struct part_entry *entry);
132 /* Execute a bootstrap routine for a different O.S. */
133void minix(u32_t koff, u32_t kcs, u32_t kds,
134 char *bootparams, size_t paramsize, u32_t aout);
135 /* Start Minix. */
136void int15(bios_env_t *);
137
138
139/* Shared between boot.c and bootimage.c: */
140
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. */
146
147/* Volatile attributes. */
148#define E_VAR 0x08 /* Variable */
149#define E_FUNCTION 0x10 /* Function definition. */
150
151/* Variables, functions, and commands. */
152typedef struct environment {
153 struct environment *next;
154 char flags;
155 char *name; /* name = value */
156 char *arg; /* name(arg) {value} */
157 char *value;
158 char *defval; /* Safehouse for default values. */
159} environment;
160
161EXTERN environment *env; /* Lists the environment. */
162
163char *b_value(char *name); /* Get/set the value of a variable. */
164int b_setvar(int flags, char *name, char *value);
165
166void parse_code(char *code); /* Parse boot monitor commands. */
167
168extern int fsok; /* True if the boot device contains an FS. */
169EXTERN u32_t lowsec; /* Offset to the file system on the boot device. */
170
171/* Called by boot.c: */
172
173void bootminix(void); /* Load and start a Minix image. */
174
175
176/* Called by bootimage.c: */
177
178void readerr(off_t sec, int err);
179 /* Report a read error. */
180char *ul2a(u32_t n, unsigned b), *ul2a10(u32_t n);
181 /* Transform u32_t to ASCII at base b or base 10. */
182long a2l(char *a);
183 /* Cheap atol(). */
184unsigned a2x(char *a);
185 /* ASCII to hex. */
186dev_t name2dev(char *name);
187 /* Translate a device name to a device number. */
188int numprefix(char *s, char **ps);
189 /* True for a numeric prefix. */
190int numeric(char *s);
191 /* True for a numeric string. */
192char *unix_err(int err);
193 /* Give a descriptive text for some UNIX errors. */
194int run_trailer(void);
195 /* Run the trailer function. */
196
197#if DOS
198/* The monitor runs under MS-DOS. */
199extern char PSP[256]; /* Program Segment Prefix. */
200EXTERN char *vdisk; /* Name of the virtual disk. */
201EXTERN char *drun; /* Initial command from DOS command line. */
202#else
203/* The monitor uses only the BIOS. */
204#define DOS 0
205#endif
206
207void readblock(off_t, char *, int);
208void delay(char *);
209
210/*
211 * $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $
212 */
Note: See TracBrowser for help on using the repository browser.