1 #ifndef _INCLUDE_TOOLS_H
2 #define _INCLUDE_TOOLS_H 1
4 /* Constants describing the disk */
5 #define SECTOR_SIZE 512
7 #define RATIO(b) ((b)/SECTOR_SIZE)
8 #define ISO_SECTOR_SIZE 2048
9 #define ISO_PVD_OFFSET 16
10 #define HRATIO (SECTOR_SIZE / HCLICK_SIZE)
11 #define PARAMSEC 1 /* sector containing boot parameters */
12 #define DSKBASE 0x1E /* floppy disk parameter vector */
13 #define DSKPARSIZE 11 /* there are this many bytes of parameters */
14 #define ESC '\33' /* escape key */
15 #define HEADERSEG 0x0060 /* place for an array of struct exec's */
16 #define MINIXSEG 0x0080 /* MINIX loaded here (rounded up to a click) */
17 #define BOOTSEG 0x07C0 /* bootstraps are loaded here */
18 #define SIGNATURE 0xAA55 /* proper bootstraps have this signature */
19 #define SIGNATPOS 510 /* offset within bootblock */
20 #define FREESEG 0x0800 /* Memory from FREESEG to cseg is free */
21 #define MSEC_PER_TICK 55 /* 18.2 ticks per second */
23 /* Scan codes for four different keyboards (from kernel/keyboard.c) */
24 #define DUTCH_EXT_SCAN 32 /* 'd' */
25 #define OLIVETTI_SCAN 12 /* '=' key on olivetti */
26 #define STANDARD_SCAN 13 /* '=' key on IBM */
27 #define US_EXT_SCAN 22 /* 'u' */
30 #define ROOT_INO ((ino_t) 1) /* Inode nr of root dir. */
31 #define IM_NAME_MAX 63
38 typedef struct vector
{
44 char name
[IM_NAME_MAX
+ 1]; /* Null terminated. */
48 EXTERN vector rem_part
; /* boot partition table entry */
49 EXTERN u16_t cseg
, dseg
; /* code and data segment of the boot program */
50 EXTERN u32_t runsize
; /* size of this program */
51 EXTERN u16_t device
; /* drive being booted from */
52 EXTERN u16_t heads
, sectors
; /* the drive's number of heads and sectors */
53 extern u16_t eqscancode
; /* Set by peek/getch() if they see a '=' */
55 /* Sticky attributes */
56 #define E_SPECIAL 0x01 /* These are known to the program */
57 #define E_DEV 0x02 /* The value is a device name */
58 #define E_RESERVED 0x04 /* May not be set by user, e.g. scancode */
59 #define E_STICKY 0x07 /* Don't go once set */
61 /* Volatile attributes */
62 #define E_VAR 0x08 /* Variable */
63 #define E_FUNCTION 0x10 /* Function definition */
65 typedef struct environment
{
66 struct environment
*next
;
68 char *name
; /* name = value */
69 char *arg
; /* name(arg) {value} */
71 char *defval
; /* Safehouse for default values */
74 /* External variables */
75 EXTERN environment
*env
; /* Lists the environment */
76 EXTERN
int fsok
; /* True if the boot device contains an FS */
77 EXTERN u32_t lowsec
; /* Offset to the file system on the boot dev */
79 #if defined(_MINIX) || defined(__minix) || defined(__ACK__)
81 _PROTOTYPE( off_t r_super
, (void));
82 _PROTOTYPE( void r_stat
, (Ino_t _inum
, struct stat
*_stp
));
83 _PROTOTYPE( ino_t r_readdir
, (char *_name
));
84 _PROTOTYPE( off_t r_vir2abs
, (off_t _virblk
));
85 _PROTOTYPE( ino_t r_lookup
, (Ino_t _cwd
, char *_path
));
89 _PROTOTYPE( void readerr
, (off_t _sec
, int _err
));
90 _PROTOTYPE( int numprefix
, (char *_s
, char **_ps
));
91 _PROTOTYPE( int numeric
, (char *_s
));
92 _PROTOTYPE( dev_t name2dev
, (char *_name
));
93 _PROTOTYPE( int delay
, (char *_msec
));
94 _PROTOTYPE( char *unix_err
, (int _err
));
95 _PROTOTYPE( void init_cache
, (void));
96 _PROTOTYPE( void invalidate_cache
, (void));
97 _PROTOTYPE( char *b_value
, (char *_name
));
98 _PROTOTYPE( void raw_copy
, (int _doff
, int _dseg
, int _soff
, int _sseg
,
100 _PROTOTYPE( void raw_clear
, (int _off
, int _seg
, int _count
));
101 _PROTOTYPE( void bootstrap
, (int _device
, int _partoff
, int _partseg
));
103 _PROTOTYPE( long a2l
, (char *_a
));
104 _PROTOTYPE( char *ul2a
, (u32_t _n
));
105 _PROTOTYPE( char *u2a
, (int _n1
));
107 /* Functions defined in monhead.s and usable by other files. */
108 _PROTOTYPE( void reset_video
, (int color
));
109 _PROTOTYPE( int dev_geometry
, (void));
110 _PROTOTYPE( u16_t get_ext_memsize
, (void));
111 _PROTOTYPE( u16_t get_low_memsize
, (void));
112 _PROTOTYPE( u16_t get_processor
, (void));
113 _PROTOTYPE( u32_t get_tick
, (void));
114 _PROTOTYPE( u16_t get_video
, (void));
115 _PROTOTYPE( u16_t get_word
, (int _off
, int _seg
));
116 _PROTOTYPE( int getchar
, (void));
117 _PROTOTYPE( void minix
, (void));
118 _PROTOTYPE( void minix86
, (int _kcs
, int _kds
, char *_bpar
, int _psize
));
119 _PROTOTYPE( void minix386
, (int _kcs
, int _kds
, char *_bpar
, int _psize
));
120 _PROTOTYPE( int peekchar
, (void));
121 _PROTOTYPE( void put_word
, (int _off
, int _seg
, int _word
));
122 _PROTOTYPE( int putchar
, (char _c
));
123 _PROTOTYPE( int readsectors
, (int _off
, int _seg
, off_t _adr
, int _ct
));
124 _PROTOTYPE( void reboot
, (void));
125 _PROTOTYPE( void relocate
, (void));
126 _PROTOTYPE( int writesectors
, (int _off
, int _seg
, off_t _adr
, int _ct
));