|
|
1.1 ! root 1: /* Include file for tertiary boot programs. ! 2: * ! 3: * This is a real hodge-podge of symbols. If you are looking to improve ! 4: * code readability, start by hacking this file into many tiny pieces. ! 5: * ! 6: * La Monte H. Yarroll <[email protected]>, September 1991 ! 7: */ ! 8: ! 9: #ifndef TBOOT_H /* Rest of file. */ ! 10: #define TBOOT_H ! 11: ! 12: #ifdef MAIN ! 13: #define EXTERN ! 14: #else ! 15: #define EXTERN extern ! 16: #endif ! 17: ! 18: #include <sys/types.h> ! 19: #include <sys/buf.h> ! 20: #include <sys/ptypes.h> ! 21: ! 22: #define TRUE (1==1) ! 23: #define FALSE (1==2) ! 24: #define WS " \t" ! 25: #define NULL ((char *)0) ! 26: #define FOURK 0x1000 /* 4k page. Needed for alignment purposes. */ ! 27: #define FOURKBOUNDRY 0xf000 ! 28: #define BLOCK 512 /* 512 bytes per disk block. */ ! 29: #define LINESIZE 81 /* Size of typical line with NUL terminator. */ ! 30: #define MAX_SEGS 8 /* Maximum number of executable file segs + 1. */ ! 31: #define NORMAL_MAGIC 0x10B /* Value of optional header magic ! 32: * for normal executable file. ! 33: */ ! 34: ! 35: #define DISKINT 0x13 /* Disk drive interrupt. */ ! 36: #define DISK_PARAMS (8 << 8) /* Return Disk Drive Parameters function. */ ! 37: #define HARD_DRIVE 0x80 /* Select fixed disks. */ ! 38: ! 39: #define SIXBITS 0x3f /* Lower six bits of a byte. */ ! 40: ! 41: #define INODES_PER_BLOCK 8 ! 42: ! 43: ! 44: #ifndef NHD ! 45: #define NHD 1 /* # of heads per drive [1 for f9d0]. */ ! 46: #endif ! 47: ! 48: #ifndef NSPT ! 49: #define NSPT 9 /* # of sectors per track on floppy. */ ! 50: #define NTRK 40 /* # of tracks on floppy. */ ! 51: #endif ! 52: ! 53: #define ROOTINO 2 /* Root inode # */ ! 54: #define INOORG 2 /* First inode block. */ ! 55: #define IBSHIFT 3 /* Shift, inode to blocks */ ! 56: #define IOSHIFT 6 /* Shift, inode to bytes */ ! 57: #define INOMASK 0x0007 /* Mask, inode to offset */ ! 58: #define BUFSIZE 512 /* Block size. */ ! 59: #define DISK 0x13 /* Disk Interrupt */ ! 60: #define KEYBD 0x16 /* Keyboard Interrupt */ ! 61: #define READ1 0x0201 /* read one sector */ ! 62: #define FIRST 8 /* Relative start of partition. */ ! 63: #define FULLSEG 0xffff /* Size of a whole 8086 segment. */ ! 64: #define PPMASK (unsigned short) 0xfff0 /* Mask for rounding to paragraph. */ ! 65: ! 66: #define COFF_SYS_BASE 0x0200 /* System load base paragraph for 386. */ ! 67: #define DEF_SYS_BASE 0x0060 /* System load base paragraph. */ ! 68: #define SYS_START 0x0100 /* System entry point. */ ! 69: ! 70: #define THE_DEV ((dev_t)0x01) /* The one disk device we recognize. */ ! 71: #define THE_XDEV ((dev_t)0x02) /* The whole disk device, rather than partition. */ ! 72: ! 73: /* WAIT_DELAY is how long to wait after finding autoboot before booting. */ ! 74: #define WAIT_DELAY 91 /* 5 seconds * 18.2 clicks per second. */ ! 75: ! 76: /* Useful macros. */ ! 77: #define GREATEST(a, b, c) (a > (b>c?b:c) ? a : (b>c?b:c)) ! 78: #define LESSER(a, b) (a < b ? a : b) ! 79: #define HIGH(x) (x >> 8) /* High byte of 16 bit number. */ ! 80: #define LOW(x) (x & 0xff) /* Low byte of 16 bit number. */ ! 81: ! 82: /* Register structure used by call_bios(). */ ! 83: struct reg { ! 84: unsigned r_ax; ! 85: unsigned r_bx; ! 86: unsigned r_cx; ! 87: unsigned r_dx; ! 88: unsigned r_si; ! 89: unsigned r_di; ! 90: unsigned r_ds; ! 91: unsigned r_es; ! 92: unsigned r_flags; ! 93: }; ! 94: ! 95: /* Table entry describing a generic segment in an executable file. */ ! 96: struct load_segment { ! 97: int valid; /* Is this a valid table entry? */ ! 98: char *message; /* Message to print while loading. */ ! 99: uint16 load_toseg; /* Where in memory to */ ! 100: uint16 load_tooffset; /* load this segment. */ ! 101: fsize_t load_offset; /* Where in file to get it. */ ! 102: fsize_t load_length; /* How long it is. */ ! 103: }; ! 104: ! 105: extern int intcall(); /* Provide C interface to bios interrupts. */ ! 106: /* int intcall(reg *srcreg, reg *destreg, int intnum); */ ! 107: extern void puts(); /* Put a string on the screen. */ ! 108: extern char *gets(); /* Get a string from the keyboard. */ ! 109: extern void reverse(); /* Reverse a string in place. */ ! 110: extern void itoa(); /* Convert an integer to a decimal string. */ ! 111: extern void itobase(); /* Convert an integer to an arbitrary base string. */ ! 112: extern uint16 basetoi(); /* Convert an arbitrary base string to an integer. */ ! 113: extern daddr_t vmap(); /* Convert file block number to physical block number. */ ! 114: extern char *lpad(); /* Pad a string on the left. */ ! 115: extern uint16 object_nlist(); /* Look up a symbol in an object file. */ ! 116: extern uint16 object_sys_base(); /* Generate a default sys_base. */ ! 117: extern uint32 wrap_coffnlist(); /* Candy coated coff nlist(). */ ! 118: extern int wait_for_keystrok(); /* Wait a time delay for a keystroke. */ ! 119: extern BUF *bread(); /* Read a disk block. */ ! 120: extern BUF *xbread(); /* Read a disk block rel. to the whole disk. */ ! 121: extern BUF *bclaim(); /* Claim a disk buffer. */ ! 122: extern BUF *bpick(); /* Pick a buffer to trash. */ ! 123: extern void bufinit(); /* Initialize disk buffers. */ ! 124: extern void brelease(); /* Free a disk buffer. */ ! 125: extern int gate_lock(); /* Attempt to lock a GATE. */ ! 126: extern int gate_locked(); /* Check to see if a GATE is locked. */ ! 127: extern void gate_unlock(); /* Unlock a GATE. */ ! 128: extern void print8(); /* Print an 8 bit integer, base 16. */ ! 129: extern void print16(); /* Print a 16 bit integer, base 16. */ ! 130: extern void print32(); /* Print a 32 bit integer, base 16. */ ! 131: extern void sanity_check(); /* Check for insane conditions. */ ! 132: extern void seg_align(); /* Align a far address. */ ! 133: extern int coff2load(); /* Convert COFF to load table. */ ! 134: extern int coffnlist(); /* Search COFF file for symbols. */ ! 135: extern void dump_bios_disk(); /* Dump a T_BIOS_DISK typed space. */ ! 136: extern void dump_fifo(); /* Dump a T_FIFO* typed space. */ ! 137: extern void dump_gift(); /* Dump the boot_gift typed space. */ ! 138: extern void dump_rootdev(); /* Dump a T_BIOS_ROOTDEV typed space. */ ! 139: extern int gift_argf(); /* Prepare a command line gift. */ ! 140: extern int gift_drive_params(); /* Prepare a drive description from the BIOS. */ ! 141: extern int gift_rootdev(); /* Indentify the boot partition to the kernel. */ ! 142: extern void seginc(); /* Add an offset to a segment. */ ! 143: extern void ffcopy(); /* Copy from one far address to another. */ ! 144: extern int read(); /* Read from a file descriptor. */ ! 145: extern int open(); /* Open a file descriptor. */ ! 146: extern long lseek(); /* Set a read/write position in a file. */ ! 147: extern int close(); /* Close a file descriptor. */ ! 148: extern int object2load(); /* Extract information to load an executable. */ ! 149: extern void monitor(); /* Mini-monitor for testing boot code. */ ! 150: extern int lout2load(); /* Convert l.out to load table. */ ! 151: extern void l_out_nlist(); /* Get entries from l.out name list. */ ! 152: extern int iopen(); /* Open an inode for a file. */ ! 153: extern ino_t namei(); /* Convert from a name to an inode. */ ! 154: extern void iread(); /* Read from a file, given an inode. */ ! 155: extern void ifread(); /* Read from a file into a far buffer, given an inode. */ ! 156: extern daddr_t indirect(); /* Follow a block indirection out. */ ! 157: extern daddr_t ind_lookup(); /* Look up a block in an indirection table. */ ! 158: extern uint16 ind_index(); /* Calculate index into an indirection table. */ ! 159: extern int get_num_of_drives(); /* Ask the BIOS how many drives are attached. */ ! 160: extern int interpret(); /* Attempt to execute a builtin command. */ ! 161: extern void dpb(); /* Display parameters from bios. */ ! 162: extern void dir(); /* List contents of /. */ ! 163: extern int fdisk(); /* Read fixed disk configuration. */ ! 164: ! 165: extern int errno; /* Error number for "system" calls. */ ! 166: EXTERN uint16 sys_base; /* Segment into which to load the kernel. */ ! 167: EXTERN int sys_base_set; /* Has sys_base been explicitly set? */ ! 168: EXTERN int want_monitor; /* Should we invoke monitor before execution? */ ! 169: ! 170: #endif /* TBOOT_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.