1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
#if 0
/* common.h - Common data structures and functions. */
/*
Copyright 1992-1998 Werner Almesberger.
Copyright 1999-2000 John Coffman.
All rights reserved.
Licensed under the terms contained in the file 'COPYING' in the
source directory.
*/
#endif
#ifndef COMMON_H
#define COMMON_H
#ifndef LILO_ASM
#include <sys/stat.h>
#include <asm/types.h>
#include <linux/genhd.h>
#include "lilo.h"
#define O_NOACCESS 3 /* open a file for "no access" */
#endif
/*
;*/typedef struct { /*
block 0
;*/ unsigned char sector,track; /* CX
sa_sector: .blkb 1
sa_track: .blkb 1
;*/ unsigned char device,head; /* DX
sa_device: .blkb 1
sa_head: .blkb 1
;*/ unsigned char num_sect; /* AL
sa_num_sect: .blkb 1
;*/} SECTOR_ADDR; /*
sa_size:
endb
;*/typedef struct { /*
block 0
;*/ char name[MAX_IMAGE_NAME+1]; /* image name, NUL terminated
id_name: .blkb MAX_IMAGE_NAME_asm+1
;*/ unsigned short password_crc[MAX_PW_CRC*(sizeof(long)/sizeof(short))]; /* 4 password CRC-32 values
id_password_crc:.blkb MAX_PW_CRC_asm*4
;*/ unsigned short rd_size[2]; /* RAM disk size in bytes, 0 if none
id_rd_size: .blkb 4 ;don't change the order !!!
;*/ SECTOR_ADDR initrd,start; /* start of initrd & kernel
id_initrd: .blkb sa_size ; **
id_start: .blkb sa_size ; **
;*/ unsigned short start_page; /* page at which the kernel is loaded high, 0
;*/ /* if loading low
id_start_page: .blkb 2 ; **
;*/ unsigned short flags,vga_mode; /* image flags & video mode
id_flags: .blkb 2 ; **
id_vga_mode: .blkb 2 ; **
;*/} IMAGE_DESCR; /*
id_size:
endb
;*/typedef struct { /*
block 0
;*/ unsigned char cli; /* clear interrupt flag instruction
par1_cli: .blkb 1
;*/ unsigned char call_ins; /* call instruction opcode
par1_call_ins: .blkb 1
;*/ short call_offset; /* offset to destination of call instruction
par1_call_offs: .blkb 2
;*/ unsigned short code_length; /* length of the first stage code
par1_code_len: .blkb 2
;*/ char signature[4]; /* "LILO"
par1_signature: .blkb 4
;*/ unsigned short stage,version; /*
par1_stage: .blkb 2
par1_version: .blkb 2
;*/ unsigned char port; /* COM port. 0 = none, 1 = COM1, etc. !!! keep these two serial bytes together !!!
;*/ unsigned char ser_param; /* RS-232 parameters, must be 0 if unused
par1_port: .blkb 1 ; referenced together
par1_ser_param: .blkb 1 ; **
;*/ unsigned long raid_offset; /* raid partition/partition offset
par1_raid_offset: .blkb 4
;*/ unsigned long timestamp; /* timestamp for restoration
par1_timestamp: .blkb 4
;*/ unsigned short timeout; /* 54 msec delay until input time-out,
0xffff: never
par1_timeout: .blkb 2
;*/ unsigned short delay; /* delay: wait that many 54 msec units.
par1_delay: .blkb 2
;*/ unsigned short msg_len; /* 0 if none
par1_msg_len: .blkb 2
;*/ SECTOR_ADDR msg; /* initial greeting message
par1_msg: .blkb sa_size
;*/ SECTOR_ADDR descr[MAX_DESCR_SECS+1]; /* 2 descriptors and default command line
par1_descr: .blkb sa_size*MAX_DESCR_SECS_asm
par1_dflcmd: .blkb sa_size
;*/ unsigned char prompt; /* FLAG_PROMPT=always, FLAG_RAID install
par1_prompt: .blkb 1
;*/ SECTOR_ADDR keytab; /* keyboard translation table
par1_keytab: .blkb sa_size
;*/ SECTOR_ADDR secondary; /* sectors of the second stage loader
par1_secondary: .blkb sa_size
;*/} BOOT_PARAMS_1; /* first stage boot loader
.align 4
par1_size:
endb
;*/typedef struct { /*
block 0
;*/ char menu_sig[4]; /* "MENU" or "BMP4" signature, or NULs if not present
mt_sig: .blkb 4
;*/ unsigned char at_text; /* attribute for normal menu text
mt_at_text: .blkb 1
;*/ unsigned char at_highlight; /* attribute for highlighted text
mt_at_hilite: .blkb 1
;*/ unsigned char at_border; /* attribute for borders
mt_at_border: .blkb 1
;*/ unsigned char at_title; /* attribute for title
mt_at_title: .blkb 1
;*/ unsigned char len_title; /* length of the title string
mt_len_title: .blkb 1
;*/ char title[MAX_MENU_TITLE+2]; /* MENU title to override default
mt_title: .blkb MAX_MENU_TITLE_asm+2
;*/ short row, col, ncol; /* BMP row, col, and ncols
mt_row: .blkw 1
mt_col: .blkw 1
mt_ncol: .blkw 1
;*/ short maxcol, xpitch; /* BMP max per col, xpitch between cols
mt_maxcol: .blkw 1
mt_xpitch: .blkw 1
;*/ short fg, bg, sh; /* BMP normal text fore, backgr, shadow
mt_fg: .blkw 1
mt_bg: .blkw 1
mt_sh: .blkw 1
;*/ short h_fg, h_bg, h_sh; /* highlight fg, bg, & shadow
mt_h_fg: .blkw 1
mt_h_bg: .blkw 1
mt_h_sh: .blkw 1
;*/ short t_fg, t_bg, t_sh; /* timer fg, bg, & shadow colors
mt_t_fg: .blkw 1
mt_t_bg: .blkw 1
mt_t_sh: .blkw 1
;*/ short t_row, t_col; /* timer position
mt_t_row: .blkw 1
mt_t_col: .blkw 1
;*/ unsigned char mt_flag; /* contains the FLAG_NOBD only
mt_flag: .blkb 1
;*/} MENUTABLE; /* MENU and BITMAP parameters at KEYTABLE+256
mt_size:
endb
;*/
#ifndef LILO_ASM
typedef struct {
char jump[6]; /* jump over the data */
char signature[4]; /* "LILO" */
unsigned short stage,version;
} BOOT_PARAMS_2; /* second stage boot loader */
typedef struct {
char jump[6]; /* jump over the data */
char signature[4]; /* "LILO" */
unsigned short stage,version; /* stage is 0x10 */
unsigned short offset; /* partition entry offset */
unsigned char drive; /* BIOS drive code */
unsigned char head; /* head; always 0 */
unsigned short drvmap; /* offset of drive map */
unsigned char ptable[PARTITION_ENTRY*PARTITION_ENTRIES]; /* part. table */
} BOOT_PARAMS_C; /* chain loader */
typedef union {
BOOT_PARAMS_1 par_1;
BOOT_PARAMS_2 par_2;
BOOT_PARAMS_C par_c;
unsigned char sector[SECTOR_SIZE];
} BOOT_SECTOR;
typedef union {
struct {
IMAGE_DESCR descr[MAX_IMAGES]; /* boot file descriptors */
} d;
unsigned char sector[SECTOR_SIZE*MAX_DESCR_SECS];
struct {
unsigned long sector[SECTOR_SIZE/4*MAX_DESCR_SECS - 1];
unsigned long checksum;
} l;
} DESCR_SECTORS;
#endif
/*
IMAGES_numerator = SECTOR_SIZE_asm*MAX_DESCR_SECS_asm - 4 - 1
IMAGES = IMAGES_numerator / id_size
;*/
#ifndef LILO_ASM
typedef struct {
unsigned short jump; /* 0: jump to startup code */
char signature[4]; /* 2: "HdrS" */
unsigned short version; /* 6: header version */
unsigned short x,y,z; /* 8: LOADLIN hacks */
unsigned short ver_offset; /* 14: kernel version string */
unsigned char loader; /* 16: loader type */
unsigned char flags; /* 17: loader flags */
unsigned short a; /* 18: more LOADLIN hacks */
unsigned long start; /* 20: kernel start, filled in by loader */
unsigned long ramdisk; /* 24: RAM disk start address */
unsigned long ramdisk_size; /* 28: RAM disk size */
unsigned short b,c; /* 32: bzImage hacks */
unsigned short heap_end_ptr;/* 36: end of free area after setup code */
} SETUP_HDR;
#define alloc_t(t) ((t *) alloc(sizeof(t)))
extern int verbose,test,compact,linear,nowarn,lba32,autoauto,passw,geometric;
extern int boot_dev_nr,raid_flags,do_md_install,zflag;
extern unsigned short drv_map[DRVMAP_SIZE+1]; /* needed for fixup maps */
extern int curr_drv_map;
extern unsigned long prt_map[PRTMAP_SIZE+1];
extern int curr_prt_map, config_read;
#if 0
extern unsigned long crc_polynomial[MAX_PW_CRC];
#endif
extern char *config_file;
extern FILE *errstd;
/*volatile*/ void pdie(char *msg);
/* Do a perror and then exit. */
/*volatile*/ void die(char *fmt,...);
/* fprintf an error message and then exit. */
void *alloc(int size);
/* Allocates the specified number of bytes. Dies on error. */
void *ralloc(void *old,int size);
/* Changes the size of an allocated memory area. Dies on error. */
char *stralloc(const char *str);
/* Like strdup, but dies on error. */
int to_number(char *num);
/* Converts a string to a number. Dies if the number is invalid. */
void check_version(BOOT_SECTOR *sect, int stage);
/* Verify that a boot sector has the correct version number. */
int stat_equal(struct stat *a, struct stat *b);
/* Compares two stat structures. Returns a non-zero integer if they describe
the same file, zero if they don't. */
unsigned long crc32 (unsigned char *cp, int nsize, unsigned long polynomial);
/* calculate a CRC-32 polynomial */
#endif
#endif
|