Indented and started off the long journey to becoming an Automakified GNU package.

This commit is contained in:
gord committed 1999-02-28 18:37:50 +00:00
1 parent 8b2e640b8c
commit 5cf05b32d2
37 files changed
+2704 -2622

No files matched your search

+1 -2
View File
@@ -69,5 +69,4 @@
#define LAPIC_TCCR 0x390
#define LAPIC_TDCR 0x3E0
#endif /* _APIC_H */
#endif /* _APIC_H */
+96 -94
View File
@@ -39,16 +39,18 @@ static struct mod_list mll[99];
*/
int
load_image(void)
load_image (void)
{
int len, i, exec_type, align_4k = 1, type = 0;
unsigned long flags = 0, text_len, data_len, bss_len;
char *str, *str2;
union {
struct multiboot_header *mb;
struct exec *aout;
Elf32_Ehdr *elf;
} pu;
union
{
struct multiboot_header *mb;
struct exec *aout;
Elf32_Ehdr *elf;
}
pu;
/* presuming that MULTIBOOT_SEARCH is large enough to encompass an
executable header */
unsigned char buffer[MULTIBOOT_SEARCH];
@@ -57,10 +59,10 @@ load_image(void)
buffer by default */
pu.aout = (struct exec *) buffer;
if (!open(cur_cmdline))
if (!open (cur_cmdline))
return 0;
if (!(len = read((int)buffer, MULTIBOOT_SEARCH)) || len < 32)
if (!(len = read ((int) buffer, MULTIBOOT_SEARCH)) || len < 32)
{
if (!errnum)
errnum = ERR_EXEC_FORMAT;
@@ -70,9 +72,9 @@ load_image(void)
for (i = 0; i < len; i++)
{
if (MULTIBOOT_FOUND((int)(buffer+i), len-i))
if (MULTIBOOT_FOUND ((int) (buffer + i), len - i))
{
flags = ((struct multiboot_header *) (buffer+i))->flags;
flags = ((struct multiboot_header *) (buffer + i))->flags;
if (flags & MULTIBOOT_UNSUPPORTED)
{
errnum = ERR_BOOT_FEATURES;
@@ -85,12 +87,12 @@ load_image(void)
}
/* ELF loading only supported if kernel using multiboot */
if (type == 'm' && len > sizeof(Elf32_Ehdr)
&& BOOTABLE_I386_ELF((*((Elf32_Ehdr *)buffer))))
if (type == 'm' && len > sizeof (Elf32_Ehdr)
&& BOOTABLE_I386_ELF ((*((Elf32_Ehdr *) buffer))))
{
entry_addr = (entry_func) pu.elf->e_entry;
if (((int)entry_addr) < 0x100000)
if (((int) entry_addr) < 0x100000)
errnum = ERR_BELOW_1MB;
/* don't want to deal with ELF program header at some random
@@ -105,7 +107,7 @@ load_image(void)
}
else if (flags & MULTIBOOT_AOUT_KLUDGE)
{
pu.mb = (struct multiboot_header *) (buffer+i);
pu.mb = (struct multiboot_header *) (buffer + i);
entry_addr = (entry_func) pu.mb->entry_addr;
cur_addr = pu.mb->load_addr;
/* first offset into file */
@@ -127,7 +129,7 @@ load_image(void)
exec_type = 2;
str = "kludge";
}
else if (len > sizeof(struct exec) && !N_BADMAG((*(pu.aout))))
else if (len > sizeof (struct exec) && !N_BADMAG ((*(pu.aout))))
{
entry_addr = (entry_func) pu.aout->a_entry;
@@ -147,14 +149,14 @@ load_image(void)
if (buffer[0] == 0xb && buffer[1] == 1)
{
type = 'f';
entry_addr = (entry_func) (((int)entry_addr) & 0xFFFFFF);
entry_addr = (entry_func) (((int) entry_addr) & 0xFFFFFF);
str2 = "FreeBSD";
}
else
{
type = 'n';
entry_addr = (entry_func) (((int)entry_addr) & 0xF00000);
if (N_GETMAGIC((*(pu.aout))) != NMAGIC)
entry_addr = (entry_func) (((int) entry_addr) & 0xF00000);
if (N_GETMAGIC ((*(pu.aout))) != NMAGIC)
align_4k = 0;
str2 = "NetBSD";
}
@@ -162,7 +164,7 @@ load_image(void)
cur_addr = (int) entry_addr;
/* first offset into file */
filepos = N_TXTOFF((*(pu.aout)));
filepos = N_TXTOFF ((*(pu.aout)));
text_len = pu.aout->a_text;
data_len = pu.aout->a_data;
bss_len = pu.aout->a_bss;
@@ -173,60 +175,60 @@ load_image(void)
exec_type = 1;
str = "a.out";
}
else if ((*((unsigned short *) (buffer+BOOTSEC_SIG_OFFSET))
else if ((*((unsigned short *) (buffer + BOOTSEC_SIG_OFFSET))
== BOOTSEC_SIGNATURE)
&& ((data_len
= (((long)*((unsigned char *)
(buffer+LINUX_SETUP_LEN_OFFSET))) << 9))
= (((long) *((unsigned char *)
(buffer + LINUX_SETUP_LEN_OFFSET))) << 9))
<= LINUX_SETUP_MAXLEN)
&& ((text_len
= (((long)*((unsigned short *)
(buffer+LINUX_KERNEL_LEN_OFFSET))) << 4)),
(data_len+text_len+SECTOR_SIZE) <= ((filemax+15)&0xFFFFFFF0)))
= (((long) *((unsigned short *)
(buffer + LINUX_KERNEL_LEN_OFFSET))) << 4)),
(data_len + text_len + SECTOR_SIZE) <= ((filemax + 15) & 0xFFFFFFF0)))
{
int big_linux = buffer[LINUX_SETUP_LOAD_FLAGS] & LINUX_FLAG_BIG_KERNEL;
buffer[LINUX_SETUP_LOADER] = 0x70;
if (!big_linux && text_len > LINUX_KERNEL_MAXLEN)
{
printf(" linux 'zImage' kernel too big, try 'make bzImage'\n");
printf (" linux 'zImage' kernel too big, try 'make bzImage'\n");
errnum = ERR_WONT_FIT;
return 0;
}
printf(" [Linux-%s, setup=0x%x, size=0x%x]\n",
(big_linux ? "bzImage" : "zImage"), data_len, text_len);
printf (" [Linux-%s, setup=0x%x, size=0x%x]\n",
(big_linux ? "bzImage" : "zImage"), data_len, text_len);
if (mbi.mem_lower >= 608)
{
bcopy(buffer, (char *)LINUX_SETUP, data_len+SECTOR_SIZE);
bcopy (buffer, (char *) LINUX_SETUP, data_len + SECTOR_SIZE);
/* copy command-line plus memory hack to staging area */
{
char *src = cur_cmdline;
char *dest = (char *) (CL_MY_LOCATION+4);
char *dest = (char *) (CL_MY_LOCATION + 4);
bcopy("mem=", (char *)CL_MY_LOCATION, 4);
bcopy ("mem=", (char *) CL_MY_LOCATION, 4);
*((unsigned short *) CL_OFFSET) = CL_MY_LOCATION-CL_BASE_ADDR;
*((unsigned short *) CL_OFFSET) = CL_MY_LOCATION - CL_BASE_ADDR;
*((unsigned short *) CL_MAGIC_ADDR) = CL_MAGIC;
dest = convert_to_ascii(dest, 'u', (mbi.mem_upper+0x400));
dest = convert_to_ascii (dest, 'u', (mbi.mem_upper + 0x400));
*(dest++) = 'K';
*(dest++) = ' ';
while (*src && *src != ' ')
src++;
while (((int)dest) < CL_MY_END_ADDR && (*(dest++) = *(src++)));
while (((int) dest) < CL_MY_END_ADDR && (*(dest++) = *(src++)));
*dest = 0;
}
/* offset into file */
filepos = data_len+SECTOR_SIZE;
filepos = data_len + SECTOR_SIZE;
cur_addr = LINUX_STAGING_AREA + text_len;
if (read(LINUX_STAGING_AREA, text_len) >= (text_len-16))
if (read (LINUX_STAGING_AREA, text_len) >= (text_len - 16))
return (big_linux ? 'L' : 'l');
else if (!errnum)
errnum = ERR_EXEC_FORMAT;
@@ -234,7 +236,7 @@ load_image(void)
else
errnum = ERR_WONT_FIT;
}
else /* no recognizable format */
else /* no recognizable format */
errnum = ERR_EXEC_FORMAT;
/* return if error */
@@ -242,7 +244,7 @@ load_image(void)
return 0;
/* fill the multiboot info structure */
mbi.cmdline = (int)cur_cmdline;
mbi.cmdline = (int) cur_cmdline;
mbi.mods_count = 0;
mbi.mods_addr = 0;
mbi.boot_device = (saved_drive << 24) | saved_partition;
@@ -252,19 +254,19 @@ load_image(void)
mbi.syms.a.addr = 0;
mbi.syms.a.pad = 0;
printf(" [%s-%s", str2, str);
printf (" [%s-%s", str2, str);
str = "";
if (exec_type) /* can be loaded like a.out */
if (exec_type) /* can be loaded like a.out */
{
if (flags & MULTIBOOT_AOUT_KLUDGE)
str = "-and-data";
printf(", loadaddr=0x%x, text%s=0x%x", cur_addr, str, text_len);
printf (", loadaddr=0x%x, text%s=0x%x", cur_addr, str, text_len);
/* read text, then read data */
if (read(cur_addr, text_len) == text_len)
if (read (cur_addr, text_len) == text_len)
{
cur_addr += text_len;
@@ -274,21 +276,21 @@ load_image(void)
if (align_4k)
cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
else
printf(", C");
printf (", C");
printf(", data=0x%x", data_len);
printf (", data=0x%x", data_len);
if (read(cur_addr, data_len) != data_len && !errnum)
if (read (cur_addr, data_len) != data_len && !errnum)
errnum = ERR_EXEC_FORMAT;
cur_addr += data_len;
}
if (!errnum)
{
bzero((char*)cur_addr, bss_len);
bzero ((char *) cur_addr, bss_len);
cur_addr += bss_len;
printf(", bss=0x%x", bss_len);
printf (", bss=0x%x", bss_len);
}
}
else if (!errnum)
@@ -304,26 +306,26 @@ load_image(void)
mbi.syms.a.addr = cur_addr;
*(((int *)cur_addr)++) = pu.aout->a_syms;
*(((int *) cur_addr)++) = pu.aout->a_syms;
printf(", symtab=0x%x", pu.aout->a_syms);
printf (", symtab=0x%x", pu.aout->a_syms);
if (read(cur_addr, pu.aout->a_syms) == pu.aout->a_syms)
if (read (cur_addr, pu.aout->a_syms) == pu.aout->a_syms)
{
cur_addr += pu.aout->a_syms;
mbi.syms.a.tabsize = pu.aout->a_syms;
if (read((int)(&i), sizeof(int)) == sizeof(int))
if (read ((int) (&i), sizeof (int)) == sizeof (int))
{
*(((int *)cur_addr)++) = i;
*(((int *) cur_addr)++) = i;
mbi.syms.a.strsize = i;
i -= sizeof(int);
i -= sizeof (int);
printf(", strtab=0x%x", i);
printf (", strtab=0x%x", i);
symtab_err = (read(cur_addr, i) != i);
symtab_err = (read (cur_addr, i) != i);
cur_addr += i;
}
else
@@ -334,7 +336,7 @@ load_image(void)
if (symtab_err)
{
printf("(bad)");
printf ("(bad)");
cur_addr = orig_addr;
mbi.syms.a.tabsize = 0;
mbi.syms.a.strsize = 0;
@@ -344,7 +346,8 @@ load_image(void)
mbi.flags |= MB_INFO_AOUT_SYMS;
}
}
else /* ELF executable */
else
/* ELF executable */
{
int loaded = 0, memaddr, memsiz, filesiz;
Elf32_Phdr *phdr;
@@ -356,8 +359,8 @@ load_image(void)
for (i = 0; i < pu.elf->e_phnum; i++)
{
phdr = (Elf32_Phdr *)
(pu.elf->e_phoff + ((int)buffer)
+ (pu.elf->e_phentsize * i));
(pu.elf->e_phoff + ((int) buffer)
+ (pu.elf->e_phentsize * i));
if (phdr->p_type == PT_LOAD)
{
/* offset into file */
@@ -371,19 +374,19 @@ load_image(void)
if (filesiz > memsiz)
filesiz = memsiz;
/* mark memory as used */
if (cur_addr < memaddr+memsiz)
cur_addr = memaddr+memsiz;
printf(", <0x%x:0x%x:0x%x>", memaddr, filesiz,
memsiz-filesiz);
if (cur_addr < memaddr + memsiz)
cur_addr = memaddr + memsiz;
printf (", <0x%x:0x%x:0x%x>", memaddr, filesiz,
memsiz - filesiz);
/* increment number of segments */
loaded++;
/* load the segment */
if (memcheck(memaddr, memsiz)
&& read(memaddr, filesiz) == filesiz)
if (memcheck (memaddr, memsiz)
&& read (memaddr, filesiz) == filesiz)
{
if (memsiz > filesiz)
bzero((char *)(memaddr+filesiz), memsiz-filesiz);
bzero ((char *) (memaddr + filesiz), memsiz - filesiz);
}
else
break;
@@ -402,10 +405,10 @@ load_image(void)
}
if (!errnum)
printf(", entry=0x%x]\n", (int)entry_addr);
printf (", entry=0x%x]\n", (int) entry_addr);
else
{
putchar('\n');
putchar ('\n');
type = 0;
}
@@ -413,23 +416,23 @@ load_image(void)
}
int
load_module(void)
load_module (void)
{
int len;
/* if we are supposed to load on 4K boundaries */
cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
if (!open(cur_cmdline) || !(len = read(cur_addr, -1)))
if (!open (cur_cmdline) || !(len = read (cur_addr, -1)))
return 0;
printf(" [Multiboot-module @ 0x%x, 0x%x bytes]\n", cur_addr, len);
printf (" [Multiboot-module @ 0x%x, 0x%x bytes]\n", cur_addr, len);
/* these two simply need to be set if any modules are loaded at all */
mbi.flags |= MB_INFO_MODS;
mbi.mods_addr = (int)mll;
mbi.mods_addr = (int) mll;
mll[mbi.mods_count].cmdline = (int)cur_cmdline;
mll[mbi.mods_count].cmdline = (int) cur_cmdline;
mll[mbi.mods_count].mod_start = cur_addr;
cur_addr += len;
mll[mbi.mods_count].mod_end = cur_addr;
@@ -442,20 +445,20 @@ load_module(void)
}
int
load_initrd(void)
load_initrd (void)
{
int len;
long *ramdisk, moveto;
if (!open(cur_cmdline) || !(len = read(cur_addr, -1)))
if (!open (cur_cmdline) || !(len = read (cur_addr, -1)))
return 0;
moveto = ((mbi.mem_upper+0x400)*0x400 - len) & 0xfffff000;
bcopy((void*)cur_addr, (void*)moveto, len);
moveto = ((mbi.mem_upper + 0x400) * 0x400 - len) & 0xfffff000;
bcopy ((void *) cur_addr, (void *) moveto, len);
printf(" [Linux-initrd @ 0x%x, 0x%x bytes]\n", moveto, len);
printf (" [Linux-initrd @ 0x%x, 0x%x bytes]\n", moveto, len);
ramdisk = (long*)(LINUX_SETUP+LINUX_SETUP_INITRD);
ramdisk = (long *) (LINUX_SETUP + LINUX_SETUP_INITRD);
ramdisk[0] = moveto;
ramdisk[1] = len;
@@ -472,13 +475,13 @@ load_initrd(void)
void
bsd_boot(int type, int bootdev)
bsd_boot (int type, int bootdev)
{
char *str;
int clval = 0, i;
struct bootinfo bi;
stop_floppy();
stop_floppy ();
while (*(++cur_cmdline) && *cur_cmdline != ' ');
str = cur_cmdline;
@@ -486,7 +489,7 @@ bsd_boot(int type, int bootdev)
{
if (*str == '-')
{
while(*str && *str != ' ')
while (*str && *str != ' ')
{
if (*str == 'C')
clval |= RB_CDROM;
@@ -520,19 +523,19 @@ bsd_boot(int type, int bootdev)
bi.bi_version = BOOTINFO_VERSION;
*cur_cmdline = 0;
while ((--cur_cmdline) > (char *)(mbi.cmdline) && *cur_cmdline != '/');
while ((--cur_cmdline) > (char *) (mbi.cmdline) && *cur_cmdline != '/');
if (*cur_cmdline == '/')
bi.bi_kernelname = cur_cmdline+1;
bi.bi_kernelname = cur_cmdline + 1;
else
bi.bi_kernelname = 0;
bi.bi_nfs_diskless = 0;
bi.bi_n_bios_used = 0; /* this field is apparently unused */
bi.bi_n_bios_used = 0; /* this field is apparently unused */
for(i = 0; i < N_BIOS_GEOM; i++)
bi.bi_bios_geom[i] = get_diskinfo(i + 0x80);
for (i = 0; i < N_BIOS_GEOM; i++)
bi.bi_bios_geom[i] = get_diskinfo (i + 0x80);
bi.bi_size = sizeof(struct bootinfo);
bi.bi_size = sizeof (struct bootinfo);
bi.bi_memsizes_valid = 1;
bi.bi_basemem = mbi.mem_lower;
bi.bi_extmem = mbi.mem_upper;
@@ -541,7 +544,7 @@ bsd_boot(int type, int bootdev)
+ mbi.syms.a.tabsize + mbi.syms.a.strsize;
/* call entry point */
(*entry_addr)(clval, bootdev, 0, 0, 0, ((int)(&bi)));
(*entry_addr) (clval, bootdev, 0, 0, 0, ((int) (&bi)));
}
else
{
@@ -565,10 +568,9 @@ bsd_boot(int type, int bootdev)
*/
/* call entry point */
(*entry_addr)(clval, bootdev, 0,
(mbi.syms.a.addr + 4
+ mbi.syms.a.tabsize + mbi.syms.a.strsize),
mbi.mem_upper, mbi.mem_lower);
(*entry_addr) (clval, bootdev, 0,
(mbi.syms.a.addr + 4
+ mbi.syms.a.tabsize + mbi.syms.a.strsize),
mbi.mem_upper, mbi.mem_lower);
}
}
+152 -145
View File
@@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@@ -24,31 +25,31 @@
#ifndef NO_FANCY_STUFF
int
getkey(void)
getkey (void)
{
buf_drive = -1;
return asm_getkey();
return asm_getkey ();
}
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
void
print_error(void)
print_error (void)
{
if (errnum > ERR_NONE && errnum < MAX_ERR_NUM)
#ifndef NO_FANCY_STUFF
/* printf("\7\n %s\n", err_list[errnum]); */
printf("\n %s\n", err_list[errnum]);
printf ("\n %s\n", err_list[errnum]);
#else /* NO_FANCY_STUFF */
printf("Error: %d\n", errnum);
#endif /* NO_FANCY_STUFF */
printf ("Error: %d\n", errnum);
#endif /* NO_FANCY_STUFF */
errnum = ERR_NONE;
}
char *
convert_to_ascii(char *buf, int c, ...)
convert_to_ascii (char *buf, int c,...)
{
unsigned long num = *((&c) + 1), mult = 10;
char *ptr = buf;
@@ -58,7 +59,7 @@ convert_to_ascii(char *buf, int c, ...)
if ((num & 0x80000000uL) && c == 'd')
{
num = (~num)+1;
num = (~num) + 1;
*(ptr++) = '-';
buf++;
}
@@ -66,13 +67,13 @@ convert_to_ascii(char *buf, int c, ...)
do
{
int dig = num % mult;
*(ptr++) = ( (dig > 9) ? dig + 'a' - 10 : '0' + dig );
*(ptr++) = ((dig > 9) ? dig + 'a' - 10 : '0' + dig);
}
while (num /= mult);
/* reorder to correct direction!! */
{
char *ptr1 = ptr-1;
char *ptr1 = ptr - 1;
char *ptr2 = buf;
while (ptr1 > ptr2)
{
@@ -89,7 +90,7 @@ convert_to_ascii(char *buf, int c, ...)
void
printf(char *format, ... )
printf (char *format,...)
{
int *dataptr = (int *) &format;
char c, *ptr, str[16];
@@ -99,26 +100,30 @@ printf(char *format, ... )
while (c = *(format++))
{
if (c != '%')
putchar(c);
putchar (c);
else
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
*convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
case 'd':
case 'u':
case 'x':
*convert_to_ascii (str, c, *((unsigned long *) dataptr++)) = 0;
ptr = str;
while (*ptr)
putchar(*(ptr++));
putchar (*(ptr++));
break;
case 'c': putchar((*(dataptr++))&0xff); break;
case 'c':
putchar ((*(dataptr++)) & 0xff);
break;
case 's':
ptr = (char *)(*(dataptr++));
ptr = (char *) (*(dataptr++));
while (c = *(ptr++))
putchar(c);
putchar (c);
break;
}
}
@@ -128,12 +133,12 @@ printf(char *format, ... )
#ifndef NO_FANCY_STUFF
void
init_page(void)
init_page (void)
{
cls();
cls ();
printf("\n GRUB version %s (%dK lower / %dK upper memory)\n\n",
version_string, mbi.mem_lower, mbi.mem_upper);
printf ("\n GRUB version %s (%dK lower / %dK upper memory)\n\n",
version_string, mbi.mem_lower, mbi.mem_upper);
}
@@ -145,66 +150,66 @@ init_page(void)
cmdline... the cmdline must be a valid string at the start */
int
get_cmdline(char *prompt, char *commands, char *cmdline, int maxlen)
get_cmdline (char *prompt, char *commands, char *cmdline, int maxlen)
{
int ystart, yend, xend, lpos, c;
int plen = 0;
int llen = 0;
/* nested function definition for code simplicity XXX GCC only, I think */
void cl_print(char *str)
{
while (*str != 0)
{
putchar(*(str++));
if (++xend > 78)
{
xend = 0;
putchar(' ');
if (yend == (getxy() & 0xFF))
ystart--;
else
yend++;
}
}
}
void cl_print (char *str)
{
while (*str != 0)
{
putchar (*(str++));
if (++xend > 78)
{
xend = 0;
putchar (' ');
if (yend == (getxy () & 0xFF))
ystart--;
else
yend++;
}
}
}
/* nested function definition for code simplicity XXX GCC only, I think */
void cl_setcpos(void)
{
yend = ((lpos+plen) / 79) + ystart;
xend = ((lpos+plen) % 79);
gotoxy(xend, yend);
}
void cl_setcpos (void)
{
yend = ((lpos + plen) / 79) + ystart;
xend = ((lpos + plen) % 79);
gotoxy (xend, yend);
}
/* nested function definition for initial command-line printing */
void cl_init()
{
/* distinguish us from other lines and error messages! */
putchar('\n');
void cl_init ()
{
/* distinguish us from other lines and error messages! */
putchar ('\n');
/* print full line and set position here */
ystart = (getxy() & 0xFF);
yend = ystart;
xend = 0;
cl_print(prompt);
cl_print(cmdline);
cl_setcpos();
}
/* print full line and set position here */
ystart = (getxy () & 0xFF);
yend = ystart;
xend = 0;
cl_print (prompt);
cl_print (cmdline);
cl_setcpos ();
}
/* nested function definition for erasing to the end of the line */
void cl_kill_to_end()
{
int i;
void cl_kill_to_end ()
{
int i;
cmdline[lpos] = 0;
for (i = lpos; i <= llen; i++)
{
if (i && ((i + plen) % 79) == 0)
putchar(' ');
putchar(' ');
}
llen = lpos;
cl_setcpos();
}
for (i = lpos; i <= llen; i++)
{
if (i && ((i + plen) % 79) == 0)
putchar (' ');
putchar (' ');
}
llen = lpos;
cl_setcpos ();
}
while (prompt[plen])
plen++;
@@ -222,9 +227,9 @@ get_cmdline(char *prompt, char *commands, char *cmdline, int maxlen)
}
lpos = llen;
cl_init();
cl_init ();
while (ASCII_CHAR(c = getkey()) != '\n' && ASCII_CHAR(c) != '\r')
while (ASCII_CHAR (c = getkey ()) != '\n' && ASCII_CHAR (c) != '\r')
{
switch (c)
{
@@ -245,13 +250,13 @@ get_cmdline(char *prompt, char *commands, char *cmdline, int maxlen)
default:
}
c = ASCII_CHAR(c);
c = ASCII_CHAR (c);
switch (c)
{
case 27: /* ESC immediately return 1*/
case 27: /* ESC immediately return 1 */
return 1;
case 9: /* TAB lists completions */
case 9: /* TAB lists completions */
{
int i, j = 0, llen_old = llen;
@@ -261,122 +266,123 @@ get_cmdline(char *prompt, char *commands, char *cmdline, int maxlen)
/* since the command line cannot have a '\n', we're OK to use c */
c = cmdline[lpos];
cl_kill_to_end();
cl_kill_to_end ();
/* goto part after line here */
yend = ((llen+plen) / 79) + ystart;
gotoxy(0, yend); putchar('\n');
yend = ((llen + plen) / 79) + ystart;
gotoxy (0, yend);
putchar ('\n');
if (lpos > j)
{
for (i = lpos; i > 0 && cmdline[i-1] != ' '; i--);
for (i = lpos; i > 0 && cmdline[i - 1] != ' '; i--);
if (i <= j)
i = j+1;
i = j + 1;
/* print possible completions */
print_completions(cmdline+i);
print_completions (cmdline + i);
}
else if (commands)
printf(commands);
printf (commands);
else
break;
/* restore command-line */
cmdline[lpos] = c;
llen = llen_old;
cl_init();
cl_init ();
}
break;
case 1: /* C-a go to beginning of line */
case 1: /* C-a go to beginning of line */
lpos = 0;
cl_setcpos();
cl_setcpos ();
break;
case 5: /* C-e go to end of line */
case 5: /* C-e go to end of line */
lpos = llen;
cl_setcpos();
cl_setcpos ();
break;
case 6: /* C-f forward one character */
case 6: /* C-f forward one character */
if (lpos < llen)
{
lpos++;
cl_setcpos();
cl_setcpos ();
}
break;
case 2: /* C-b backward one character */
case 2: /* C-b backward one character */
if (lpos > 0)
{
lpos--;
cl_setcpos();
cl_setcpos ();
}
break;
case 4: /* C-d delete character under cursor */
case 4: /* C-d delete character under cursor */
if (lpos == llen)
break;
lpos++;
/* fallthrough is on purpose! */
case 8: /* C-h backspace */
case 8: /* C-h backspace */
if (lpos > 0)
{
int i;
for (i = lpos-1; i < llen; i++)
cmdline[i] = cmdline[i+1];
for (i = lpos - 1; i < llen; i++)
cmdline[i] = cmdline[i + 1];
i = lpos;
lpos = llen - 1;
cl_setcpos();
putchar(' ');
lpos = i - 1; /* restore lpos and decrement */
cl_setcpos ();
putchar (' ');
lpos = i - 1; /* restore lpos and decrement */
llen--;
cl_setcpos();
cl_setcpos ();
if (lpos != llen)
{
cl_print(cmdline+lpos);
cl_setcpos();
cl_print (cmdline + lpos);
cl_setcpos ();
}
}
break;
case 21: /* C-u kill to beginning of line */
case 21: /* C-u kill to beginning of line */
if (lpos == 0)
break;
{
int i;
for (i = 0; i < (llen-lpos); i++)
cmdline[i] = cmdline[lpos+i];
for (i = 0; i < (llen - lpos); i++)
cmdline[i] = cmdline[lpos + i];
}
lpos = llen-lpos;
cl_setcpos();
lpos = llen - lpos;
cl_setcpos ();
/* fallthrough on purpose! */
case 11: /* C-k kill to end of line */
case 11: /* C-k kill to end of line */
if (lpos < llen)
{
cl_kill_to_end();
cl_kill_to_end ();
if (c == 21)
{
lpos = 0;
cl_setcpos();
cl_print(cmdline);
cl_setcpos();
cl_setcpos ();
cl_print (cmdline);
cl_setcpos ();
}
}
break;
default: /* insert printable character into line */
if (llen < (maxlen-1) && c >= ' ' && c <= '~')
default: /* insert printable character into line */
if (llen < (maxlen - 1) && c >= ' ' && c <= '~')
{
if (lpos == llen)
{
cmdline[lpos] = c;
cmdline[lpos+1] = 0;
cl_print(cmdline+lpos);
cmdline[lpos + 1] = 0;
cl_print (cmdline + lpos);
lpos++;
}
else
{
int i;
for (i = llen; i >= lpos; i--)
cmdline[i+1] = cmdline[i];
cmdline[i + 1] = cmdline[i];
cmdline[lpos] = c;
cl_setcpos();
cl_print(cmdline+lpos);
cl_setcpos ();
cl_print (cmdline + lpos);
lpos++;
cl_setcpos();
cl_setcpos ();
}
llen++;
}
@@ -384,8 +390,9 @@ get_cmdline(char *prompt, char *commands, char *cmdline, int maxlen)
}
/* goto part after line here */
yend = ((llen+plen) / 79) + ystart;
gotoxy(0, yend); putchar('\n');
yend = ((llen + plen) / 79) + ystart;
gotoxy (0, yend);
putchar ('\n');
/* remove leading spaces */
/* use c and lpos as indexes now */
@@ -412,12 +419,12 @@ get_cmdline(char *prompt, char *commands, char *cmdline, int maxlen)
int
get_based_digit(int c, int base)
get_based_digit (int c, int base)
{
int digit = -1;
/* make sure letter in the the range we can check! */
c = tolower(c);
c = tolower (c);
/*
* Is it in the range between zero and nine?
@@ -440,7 +447,7 @@ get_based_digit(int c, int base)
int
safe_parse_maxint(char **str_ptr, int *myint_ptr)
safe_parse_maxint (char **str_ptr, int *myint_ptr)
{
register char *ptr = *str_ptr;
register int myint = 0, digit;
@@ -449,16 +456,16 @@ safe_parse_maxint(char **str_ptr, int *myint_ptr)
/*
* Is this a hex number?
*/
if (*ptr == '0' && tolower(*(ptr+1)) == 'x')
if (*ptr == '0' && tolower (*(ptr + 1)) == 'x')
{
ptr += 2;
mult = 16;
}
while ((digit = get_based_digit(*ptr, mult)) != -1)
while ((digit = get_based_digit (*ptr, mult)) != -1)
{
found = 1;
if (myint > ((MAXINT - digit)/mult))
if (myint > ((MAXINT - digit) / mult))
{
errnum = ERR_NUMBER_PARSING;
return 0;
@@ -481,7 +488,7 @@ safe_parse_maxint(char **str_ptr, int *myint_ptr)
int
tolower(int c)
tolower (int c)
{
if (c >= 'A' && c <= 'Z')
return (c + ('a' - 'A'));
@@ -491,7 +498,7 @@ tolower(int c)
int
isspace(int c)
isspace (int c)
{
if (c == ' ' || c == '\t' || c == '\n')
return 1;
@@ -501,7 +508,7 @@ isspace(int c)
int
strncat(char *s1, char *s2, int n)
strncat (char *s1, char *s2, int n)
{
int i = -1;
@@ -509,7 +516,7 @@ strncat(char *s1, char *s2, int n)
while (i < n && (s1[i++] = *(s2++)) != 0);
s1[n-1] = 0;
s1[n - 1] = 0;
if (i >= n)
return 0;
@@ -521,7 +528,7 @@ strncat(char *s1, char *s2, int n)
int
substring(char *s1, char *s2)
substring (char *s1, char *s2)
{
while (*s1 == *s2)
{
@@ -541,7 +548,7 @@ substring(char *s1, char *s2)
char *
strstr(char *s1, char *s2)
strstr (char *s1, char *s2)
{
char *ptr, *tmp;
@@ -552,7 +559,7 @@ strstr(char *s1, char *s2)
while (*s1 && *s1++ == *tmp++);
if (tmp > s2 && !*(tmp-1))
if (tmp > s2 && !*(tmp - 1))
return ptr;
}
@@ -561,12 +568,12 @@ strstr(char *s1, char *s2)
int
memcheck(int start, int len)
memcheck (int start, int len)
{
if ( (start < 0x1000) || (start < 0x100000
&& (mbi.mem_lower * 1024) < (start+len))
|| (start >= 0x100000
&& (mbi.mem_upper * 1024) < ((start-0x100000)+len)) )
if ((start < 0x1000) || (start < 0x100000
&& (mbi.mem_lower * 1024) < (start + len))
|| (start >= 0x100000
&& (mbi.mem_upper * 1024) < ((start - 0x100000) + len)))
errnum = ERR_WONT_FIT;
return (!errnum);
@@ -574,16 +581,16 @@ memcheck(int start, int len)
int
bcopy(char *from, char *to, int len)
bcopy (char *from, char *to, int len)
{
if (memcheck((int)to, len))
if (memcheck ((int) to, len))
{
if ((to >= from+len) || (to <= from))
if ((to >= from + len) || (to <= from))
{
while (len >= sizeof (unsigned long))
{
len -= sizeof (unsigned long);
*(((unsigned long *)to)++) = *(((unsigned long *)from)++);
*(((unsigned long *) to)++) = *(((unsigned long *) from)++);
}
while (len-- > 0)
*(to++) = *(from++);
@@ -602,9 +609,9 @@ bcopy(char *from, char *to, int len)
int
bzero(char *start, int len)
bzero (char *start, int len)
{
if (memcheck((int)start, len))
if (memcheck ((int) start, len))
{
while (len-- > 0)
*(start++) = 0;
+28 -26
View File
@@ -42,7 +42,8 @@ int errnum = 0;
char *err_list[] =
{
[ERR_NONE] = 0,
[ERR_BAD_FILENAME] = "Bad filename (must be absolute pathname or blocklist)",
[ERR_BAD_FILENAME] =
"Bad filename (must be absolute pathname or blocklist)",
[ERR_BAD_FILETYPE] = "Bad file or directory type",
[ERR_BAD_GZIP_DATA] = "Bad or corrupt data while decompressing file",
[ERR_BAD_GZIP_HEADER] = "Bad or incompatible header on compressed file",
@@ -55,7 +56,8 @@ char *err_list[] =
[ERR_DEV_FORMAT] = "Device string unrecognizable",
[ERR_DEV_VALUES] = "Invalid device requested",
[ERR_EXEC_FORMAT] = "Invalid or unsupported executable format",
[ERR_FILELENGTH] = "Filesystem compatibility error, cannot read whole file",
[ERR_FILELENGTH] =
"Filesystem compatibility error, cannot read whole file",
[ERR_FILE_NOT_FOUND] = "File not found",
[ERR_FSYS_CORRUPT] = "Inconsistent filesystem structure",
[ERR_FSYS_MOUNT] = "Cannot mount selected partition",
@@ -77,11 +79,11 @@ char *err_list[] =
/* static for BIOS memory map fakery */
static struct AddrRangeDesc fakemap[3] =
{
{ 20, 0, 0, 0, 0, MB_ARD_MEMORY },
{ 20, 0x100000, 0, 0, 0, MB_ARD_MEMORY },
{ 20, 0x1000000, 0, 0, 0, MB_ARD_MEMORY }
{20, 0, 0, 0, 0, MB_ARD_MEMORY},
{20, 0x100000, 0, 0, 0, MB_ARD_MEMORY},
{20, 0x1000000, 0, 0, 0, MB_ARD_MEMORY}
};
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
/*
@@ -89,7 +91,7 @@ static struct AddrRangeDesc fakemap[3] =
*/
void
init_bios_info(void)
init_bios_info (void)
{
int cont, memtmp, addr;
@@ -97,8 +99,8 @@ init_bios_info(void)
* Get information from BIOS on installed RAM.
*/
mbi.mem_lower = get_memsize(0);
mbi.mem_upper = get_memsize(1);
mbi.mem_lower = get_memsize (0);
mbi.mem_upper = get_memsize (1);
#ifndef NO_FANCY_STUFF
/*
@@ -107,7 +109,7 @@ init_bios_info(void)
* to 0. Not too desirable.
*/
gateA20(1);
gateA20 (1);
/*
* The "mbi.mem_upper" variable only recognizes upper memory in the
@@ -122,13 +124,13 @@ init_bios_info(void)
do
{
cont = get_mem_map(addr, cont);
cont = get_mem_map (addr, cont);
if ( ! *((int *)addr) )
if (!*((int *) addr))
break;
mbi.mmap_length += *((int *)addr) + 4;
addr += *((int *)addr) + 4;
mbi.mmap_length += *((int *) addr) + 4;
addr += *((int *) addr) + 4;
}
while (cont);
@@ -152,14 +154,14 @@ init_bios_info(void)
addr < mbi.mmap_addr + mbi.mmap_length;
addr += *((int *) addr) + 4)
{
if (((struct AddrRangeDesc *)addr)->BaseAddrHigh == 0
&& ((struct AddrRangeDesc *)addr)->Type == MB_ARD_MEMORY
&& ((struct AddrRangeDesc *)addr)->BaseAddrLow <= memtmp
&& (((struct AddrRangeDesc *)addr)->BaseAddrLow
+ ((struct AddrRangeDesc *)addr)->LengthLow) > memtmp)
if (((struct AddrRangeDesc *) addr)->BaseAddrHigh == 0
&& ((struct AddrRangeDesc *) addr)->Type == MB_ARD_MEMORY
&& ((struct AddrRangeDesc *) addr)->BaseAddrLow <= memtmp
&& (((struct AddrRangeDesc *) addr)->BaseAddrLow
+ ((struct AddrRangeDesc *) addr)->LengthLow) > memtmp)
{
memtmp = (((struct AddrRangeDesc *)addr)->BaseAddrLow
+ ((struct AddrRangeDesc *)addr)->LengthLow);
memtmp = (((struct AddrRangeDesc *) addr)->BaseAddrLow
+ ((struct AddrRangeDesc *) addr)->LengthLow);
cont++;
}
}
@@ -168,7 +170,7 @@ init_bios_info(void)
mbi.mem_upper = (memtmp - 0x100000) >> 10;
}
else if ((memtmp = get_eisamemsize()) != -1)
else if ((memtmp = get_eisamemsize ()) != -1)
{
cont = memtmp & ~0xFFFF;
memtmp = memtmp & 0xFFFF;
@@ -179,8 +181,8 @@ init_bios_info(void)
{
/* XXX should I do this at all ??? */
mbi.mmap_addr = (int)fakemap;
mbi.mmap_length = sizeof(fakemap);
mbi.mmap_addr = (int) fakemap;
mbi.mmap_length = sizeof (fakemap);
fakemap[0].LengthLow = (mbi.mem_lower << 10);
fakemap[1].LengthLow = (memtmp << 10);
fakemap[2].LengthLow = cont;
@@ -197,7 +199,7 @@ init_bios_info(void)
mbi.flags = MB_INFO_MEMORY | MB_INFO_CMDLINE | MB_INFO_BOOTDEV;
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
/*
* Set boot drive and partition.
@@ -210,5 +212,5 @@ init_bios_info(void)
* Start main routine here.
*/
cmain();
cmain ();
}
+15 -13
View File
@@ -1,3 +1,4 @@
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
@@ -46,21 +47,23 @@
* Compatibility definitions for old type names.
*/
typedef unsigned char u_char; /* unsigned char */
typedef unsigned short u_short; /* unsigned short */
typedef unsigned int u_int; /* unsigned int */
typedef unsigned char u_char; /* unsigned char */
typedef unsigned short u_short; /* unsigned short */
typedef unsigned int u_int; /* unsigned int */
typedef struct _quad_ {
unsigned int val[2]; /* 2 int values make... */
} quad; /* an 8-byte item */
typedef struct _quad_
{
unsigned int val[2]; /* 2 int values make... */
}
quad; /* an 8-byte item */
typedef unsigned int time_t; /* an unsigned int */
typedef unsigned int daddr_t; /* an unsigned int */
typedef unsigned int off_t; /* another unsigned int */
typedef unsigned int time_t; /* an unsigned int */
typedef unsigned int daddr_t; /* an unsigned int */
typedef unsigned int off_t; /* another unsigned int */
typedef unsigned short uid_t;
typedef unsigned short gid_t;
typedef unsigned int ino_t;
typedef unsigned short uid_t;
typedef unsigned short gid_t;
typedef unsigned int ino_t;
#define NBBY 8
@@ -90,4 +93,3 @@ typedef unsigned int ino_t;
#define MAXPATHLEN 1024
#define MAXSYMLINKS 8
+32 -27
View File
@@ -1,3 +1,4 @@
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
@@ -73,12 +74,13 @@
#define DIRBLKSIZ DEV_BSIZE
#define MAXNAMLEN 255
struct direct {
u_int d_ino; /* inode number of entry */
u_short d_reclen; /* length of this record */
u_short d_namlen; /* length of string in d_name */
char d_name[MAXNAMLEN + 1]; /* name with length <= MAXNAMLEN */
};
struct direct
{
u_int d_ino; /* inode number of entry */
u_short d_reclen; /* length of this record */
u_short d_namlen; /* length of string in d_name */
char d_name[MAXNAMLEN + 1]; /* name with length <= MAXNAMLEN */
};
/*
* The DIRSIZ macro gives the minimum record length which will hold
@@ -96,16 +98,17 @@ struct direct {
* Should use struct direct's, but the name field
* is MAXNAMLEN - 1, and this just won't do.
*/
struct dirtemplate {
u_int dot_ino;
short dot_reclen;
short dot_namlen;
char dot_name[4]; /* must be multiple of 4 */
u_int dotdot_ino;
short dotdot_reclen;
short dotdot_namlen;
char dotdot_name[4]; /* ditto */
};
struct dirtemplate
{
u_int dot_ino;
short dot_reclen;
short dot_namlen;
char dot_name[4]; /* must be multiple of 4 */
u_int dotdot_ino;
short dotdot_reclen;
short dotdot_namlen;
char dotdot_name[4]; /* ditto */
};
#endif
/*
@@ -120,23 +123,25 @@ struct dirtemplate {
/*
* Definitions for library routines operating on directories.
*/
typedef struct _dirdesc {
int dd_fd;
int dd_loc;
int dd_size;
char dd_buf[DIRBLKSIZ];
} DIR;
typedef struct _dirdesc
{
int dd_fd;
int dd_loc;
int dd_size;
char dd_buf[DIRBLKSIZ];
}
DIR;
#define dirfd(dirp) ((dirp)->dd_fd)
#ifndef NULL
#define NULL 0
#endif
extern DIR *opendir();
extern struct direct *readdir();
extern int telldir();
extern void seekdir();
extern DIR *opendir ();
extern struct direct *readdir ();
extern int telldir ();
extern void seekdir ();
#define rewinddir(dirp) seekdir((dirp), (long)0)
extern void closedir();
extern void closedir ();
#endif /* not KERNEL */
#endif /* _BOOT_UFS_DIR_H_ */
+41 -32
View File
@@ -58,44 +58,53 @@
#define FFS_MAX_FASTLINK_SIZE ((FFS_NDADDR + FFS_NIADDR) * sizeof(daddr_t))
struct icommon {
u_short ic_mode; /* 0: mode and type of file */
short ic_nlink; /* 2: number of links to file */
uid_t ic_uid; /* 4: owner's user id */
gid_t ic_gid; /* 6: owner's group id */
quad ic_size; /* 8: number of bytes in file */
time_t ic_atime; /* 16: time last accessed */
int ic_atspare;
time_t ic_mtime; /* 24: time last modified */
int ic_mtspare;
time_t ic_ctime; /* 32: last time inode changed */
int ic_ctspare;
union {
struct {
daddr_t Mb_db[FFS_NDADDR]; /* 40: disk block addresses */
daddr_t Mb_ib[FFS_NIADDR]; /* 88: indirect blocks */
} ic_Mb;
char ic_Msymlink[FFS_MAX_FASTLINK_SIZE];
/* 40: symbolic link name */
} ic_Mun;
struct icommon
{
u_short ic_mode; /* 0: mode and type of file */
short ic_nlink; /* 2: number of links to file */
uid_t ic_uid; /* 4: owner's user id */
gid_t ic_gid; /* 6: owner's group id */
quad ic_size; /* 8: number of bytes in file */
time_t ic_atime; /* 16: time last accessed */
int ic_atspare;
time_t ic_mtime; /* 24: time last modified */
int ic_mtspare;
time_t ic_ctime; /* 32: last time inode changed */
int ic_ctspare;
union
{
struct
{
daddr_t Mb_db[FFS_NDADDR]; /* 40: disk block addresses */
daddr_t Mb_ib[FFS_NIADDR]; /* 88: indirect blocks */
}
ic_Mb;
char ic_Msymlink[FFS_MAX_FASTLINK_SIZE];
/* 40: symbolic link name */
}
ic_Mun;
#define ic_db ic_Mun.ic_Mb.Mb_db
#define ic_ib ic_Mun.ic_Mb.Mb_ib
#define ic_symlink ic_Mun.ic_Msymlink
int ic_flags; /* 100: status, currently unused */
int ic_blocks; /* 104: blocks actually held */
int ic_gen; /* 108: generation number */
int ic_spare[4]; /* 112: reserved, currently unused */
} i_ic;
int ic_flags; /* 100: status, currently unused */
int ic_blocks; /* 104: blocks actually held */
int ic_gen; /* 108: generation number */
int ic_spare[4]; /* 112: reserved, currently unused */
}
i_ic;
/*
* Same structure, but on disk.
*/
struct dinode {
union {
struct icommon di_com;
char di_char[128];
} di_un;
};
struct dinode
{
union
{
struct icommon di_com;
char di_char[128];
}
di_un;
};
#define di_ic di_un.di_com
#endif /* _BOOT_UFS_DISK_INODE_H_ */
#endif /* _BOOT_UFS_DISK_INODE_H_ */
+15 -15
View File
@@ -50,7 +50,7 @@
#define MAX_FASTLINK_SIZE FFS_MAX_FASTLINK_SIZE
#define IC_FASTLINK 0x0001 /* Symbolic link in inode */
#define IC_FASTLINK 0x0001 /* Symbolic link in inode */
#define i_mode ic_mode
#define i_nlink ic_nlink
@@ -58,7 +58,7 @@
#define i_gid ic_gid
#if BYTE_MSF
#define i_size ic_size.val[1]
#else /* BYTE_LSF */
#else /* BYTE_LSF */
#define i_size ic_size.val[0]
#endif
#define i_db ic_db
@@ -73,19 +73,19 @@
#define i_gen ic_gen
/* modes */
#define IFMT 0xf000 /* type of file */
#define IFCHR 0x2000 /* character special */
#define IFDIR 0x4000 /* directory */
#define IFBLK 0x6000 /* block special */
#define IFREG 0x8000 /* regular */
#define IFLNK 0xa000 /* symbolic link */
#define IFSOCK 0xc000 /* socket */
#define IFMT 0xf000 /* type of file */
#define IFCHR 0x2000 /* character special */
#define IFDIR 0x4000 /* directory */
#define IFBLK 0x6000 /* block special */
#define IFREG 0x8000 /* regular */
#define IFLNK 0xa000 /* symbolic link */
#define IFSOCK 0xc000 /* socket */
#define ISUID 0x0800 /* set user id on execution */
#define ISGID 0x0400 /* set group id on execution */
#define ISVTX 0x0200 /* save swapped text even after use */
#define IREAD 0x0100 /* read, write, execute permissions */
#define ISUID 0x0800 /* set user id on execution */
#define ISGID 0x0400 /* set group id on execution */
#define ISVTX 0x0200 /* save swapped text even after use */
#define IREAD 0x0100 /* read, write, execute permissions */
#define IWRITE 0x0080
#define IEXEC 0x0040
@@ -96,6 +96,6 @@
#define f_blk u.ffs.ffs_blk
#define f_blksize u.ffs.ffs_blksize
#define f_blkno u.ffs.ffs_blkno
#endif /* EEK */
#endif /* EEK */
#endif _BOOT_UFS_DISK_INODE_FFS_H_
#endif /* _BOOT_UFS_DISK_INODE_FFS_H_ */
+176 -175
View File
@@ -29,9 +29,9 @@
#ifndef NO_FANCY_STUFF
/* instrumentation variables */
void (*debug_fs)(int) = NULL;
void (*debug_fs_func)(int) = NULL;
#endif /* NO_FANCY_STUFF */
void (*debug_fs) (int) = NULL;
void (*debug_fs_func) (int) = NULL;
#endif /* NO_FANCY_STUFF */
/* These have the same format as "boot_drive" and "install_partition", but
are meant to be working values. */
@@ -49,7 +49,7 @@ int bsd_evil_hack;
int fsys_type = NUM_FSYS;
#ifndef NO_BLOCK_FILES
int block_file = 0;
#endif /* NO_BLOCK_FILES */
#endif /* NO_BLOCK_FILES */
/* these are the translated numbers for the open partition */
long part_start;
@@ -68,9 +68,9 @@ int filemax;
int
rawread(int drive, int sector, int byte_offset, int byte_len, int addr)
rawread (int drive, int sector, int byte_offset, int byte_len, int addr)
{
int slen = (byte_offset+byte_len+511)/SECTOR_SIZE;
int slen = (byte_offset + byte_len + 511) / SECTOR_SIZE;
if (byte_len <= 0)
return 1;
@@ -85,7 +85,7 @@ rawread(int drive, int sector, int byte_offset, int byte_len, int addr)
*/
if (buf_drive != drive)
{
buf_geom = get_diskinfo(drive);
buf_geom = get_diskinfo (drive);
buf_drive = drive;
buf_track = -1;
}
@@ -97,14 +97,14 @@ rawread(int drive, int sector, int byte_offset, int byte_len, int addr)
}
/* Get first sector of track */
soff = sector % SECTORS(buf_geom);
soff = sector % SECTORS (buf_geom);
track = sector - soff;
num_sect = SECTORS(buf_geom) - soff;
num_sect = SECTORS (buf_geom) - soff;
bufaddr = BUFFERADDR + (soff * SECTOR_SIZE) + byte_offset;
if (track != buf_track)
{
int bios_err, read_start = track, read_len = SECTORS(buf_geom);
int bios_err, read_start = track, read_len = SECTORS (buf_geom);
/*
* If there's more than one read in this entire loop, then
@@ -118,8 +118,8 @@ rawread(int drive, int sector, int byte_offset, int byte_len, int addr)
bufaddr = BUFFERADDR + byte_offset;
}
if (bios_err = biosdisk(BIOSDISK_SUBFUNC_READ, drive, buf_geom,
read_start, read_len, BUFFERSEG))
if (bios_err = biosdisk (BIOSDISK_SUBFUNC_READ, drive, buf_geom,
read_start, read_len, BUFFERSEG))
{
buf_track = -1;
@@ -132,8 +132,8 @@ rawread(int drive, int sector, int byte_offset, int byte_len, int addr)
* required sector(s) rather than failing completely.
*/
if (slen > num_sect
|| biosdisk(BIOSDISK_SUBFUNC_READ, drive, buf_geom,
sector, slen, BUFFERSEG))
|| biosdisk (BIOSDISK_SUBFUNC_READ, drive, buf_geom,
sector, slen, BUFFERSEG))
errnum = ERR_READ;
bufaddr = BUFFERSEG + byte_offset;
@@ -153,14 +153,14 @@ rawread(int drive, int sector, int byte_offset, int byte_len, int addr)
int sector_num = sector;
while (sector_num < sector_end)
(*debug_fs_func)(sector_num++);
(*debug_fs_func) (sector_num++);
}
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
if (size > ((num_sect * SECTOR_SIZE) - byte_offset))
size = (num_sect * SECTOR_SIZE) - byte_offset;
bcopy((char *)bufaddr, (char *)addr, size);
bcopy ((char *) bufaddr, (char *) addr, size);
addr += size;
byte_len -= size;
@@ -174,13 +174,13 @@ rawread(int drive, int sector, int byte_offset, int byte_len, int addr)
int
devread(int sector, int byte_offset, int byte_len, int addr)
devread (int sector, int byte_offset, int byte_len, int addr)
{
/*
* Check partition boundaries
*/
if (sector < 0
|| (sector + ((byte_offset+byte_len-1)/SECTOR_SIZE)) >= part_length)
|| (sector + ((byte_offset + byte_len - 1) / SECTOR_SIZE)) >= part_length)
{
errnum = ERR_OUTSIDE_PART;
return 0;
@@ -197,8 +197,8 @@ devread(int sector, int byte_offset, int byte_len, int addr)
#if !defined(NO_FANCY_STUFF) && defined(DEBUG)
if (debug_fs)
printf("<%d, %d, %d>", sector, byte_offset, byte_len);
#endif /* !NO_FANCY_STUFF && DEBUG */
printf ("<%d, %d, %d>", sector, byte_offset, byte_len);
#endif /* !NO_FANCY_STUFF && DEBUG */
/*
* Call "rawread", which is very similar, but:
@@ -209,21 +209,21 @@ devread(int sector, int byte_offset, int byte_len, int addr)
* -- It doesn't handle offsets of more than 511 bytes into the
* sector.
*/
return rawread(current_drive, part_start+sector, byte_offset,
byte_len, addr);
return rawread (current_drive, part_start + sector, byte_offset,
byte_len, addr);
}
int
sane_partition(void)
sane_partition (void)
{
if ( !(current_partition & 0xFF000000uL)
&& (current_drive & 0xFFFFFF7F) < 8
&& (current_partition & 0xFF) == 0xFF
&& ( (current_partition & 0xFF00) == 0xFF00
|| (current_partition & 0xFF00) < 0x800 )
&& ( (current_partition >> 16) == 0xFF
|| (current_drive & 0x80) ) )
if (!(current_partition & 0xFF000000uL)
&& (current_drive & 0xFFFFFF7F) < 8
&& (current_partition & 0xFF) == 0xFF
&& ((current_partition & 0xFF00) == 0xFF00
|| (current_partition & 0xFF00) < 0x800)
&& ((current_partition >> 16) == 0xFF
|| (current_drive & 0x80)))
return 1;
errnum = ERR_DEV_VALUES;
@@ -232,10 +232,10 @@ sane_partition(void)
static void
attempt_mount(void)
attempt_mount (void)
{
for ( fsys_type = 0; fsys_type < NUM_FSYS
&& (*(fsys_table[fsys_type].mount_func))() != 1; fsys_type++);
for (fsys_type = 0; fsys_type < NUM_FSYS
&& (*(fsys_table[fsys_type].mount_func)) () != 1; fsys_type++);
if (fsys_type == NUM_FSYS && errnum == ERR_NONE)
errnum = ERR_FSYS_MOUNT;
@@ -244,7 +244,7 @@ attempt_mount(void)
#ifndef NO_FANCY_STUFF
int
make_saved_active(void)
make_saved_active (void)
{
if (saved_drive & 0x80)
{
@@ -256,22 +256,22 @@ make_saved_active(void)
return 0;
}
if (!rawread(saved_drive, 0, 0, SECTOR_SIZE, SCRATCHADDR))
if (!rawread (saved_drive, 0, 0, SECTOR_SIZE, SCRATCHADDR))
return 0;
if (PC_SLICE_FLAG(SCRATCHADDR, part) != PC_SLICE_FLAG_BOOTABLE)
if (PC_SLICE_FLAG (SCRATCHADDR, part) != PC_SLICE_FLAG_BOOTABLE)
{
int i;
for (i = 0; i < 4; i++)
PC_SLICE_FLAG(SCRATCHADDR, i) = 0;
PC_SLICE_FLAG (SCRATCHADDR, i) = 0;
PC_SLICE_FLAG(SCRATCHADDR, part) = PC_SLICE_FLAG_BOOTABLE;
PC_SLICE_FLAG (SCRATCHADDR, part) = PC_SLICE_FLAG_BOOTABLE;
buf_track = -1;
if (biosdisk(BIOSDISK_SUBFUNC_WRITE, saved_drive, buf_geom,
0, 1, SCRATCHSEG))
if (biosdisk (BIOSDISK_SUBFUNC_WRITE, saved_drive, buf_geom,
0, 1, SCRATCHSEG))
{
errnum = ERR_WRITE;
return 0;
@@ -284,73 +284,73 @@ make_saved_active(void)
static void
check_and_print_mount(void)
check_and_print_mount (void)
{
attempt_mount();
attempt_mount ();
if (errnum == ERR_FSYS_MOUNT)
errnum = ERR_NONE;
if (!errnum)
print_fsys_type();
print_error();
print_fsys_type ();
print_error ();
}
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
static int
check_BSD_parts(int flags)
check_BSD_parts (int flags)
{
char label_buf[SECTOR_SIZE];
int part_no, got_part = 0;
if ( part_length < (BSD_LABEL_SECTOR+1) )
if (part_length < (BSD_LABEL_SECTOR + 1))
{
errnum = ERR_BAD_PART_TABLE;
return 0;
}
if (!rawread(current_drive, part_start + BSD_LABEL_SECTOR,
0, SECTOR_SIZE, (int) label_buf))
if (!rawread (current_drive, part_start + BSD_LABEL_SECTOR,
0, SECTOR_SIZE, (int) label_buf))
return 0;
if ( BSD_LABEL_CHECK_MAG(label_buf) )
if (BSD_LABEL_CHECK_MAG (label_buf))
{
for (part_no = 0; part_no < BSD_LABEL_NPARTS(label_buf); part_no++)
for (part_no = 0; part_no < BSD_LABEL_NPARTS (label_buf); part_no++)
{
if (BSD_PART_TYPE(label_buf, part_no))
if (BSD_PART_TYPE (label_buf, part_no))
{
/* XXX should do BAD144 sector remapping setup here */
current_slice = ((BSD_PART_TYPE(label_buf, part_no) << 8)
current_slice = ((BSD_PART_TYPE (label_buf, part_no) << 8)
| PC_SLICE_TYPE_BSD);
part_start = BSD_PART_START(label_buf, part_no);
part_length = BSD_PART_LENGTH(label_buf, part_no);
part_start = BSD_PART_START (label_buf, part_no);
part_length = BSD_PART_LENGTH (label_buf, part_no);
#ifndef NO_FANCY_STUFF
if (flags)
{
if (!got_part)
{
printf("[BSD sub-partitions immediately follow]\n");
printf ("[BSD sub-partitions immediately follow]\n");
got_part = 1;
}
printf(" BSD Partition num: \'%c\', ", part_no + 'a');
check_and_print_mount();
printf (" BSD Partition num: \'%c\', ", part_no + 'a');
check_and_print_mount ();
}
else
#endif /* NO_FANCY_STUFF */
if (part_no == ((current_partition >> 8) & 0xFF))
break;
#endif /* NO_FANCY_STUFF */
if (part_no == ((current_partition >> 8) & 0xFF))
break;
}
}
if (part_no >= BSD_LABEL_NPARTS(label_buf) && !got_part)
if (part_no >= BSD_LABEL_NPARTS (label_buf) && !got_part)
{
errnum = ERR_NO_PART;
return 0;
}
if ((current_drive & 0x80)
&& BSD_LABEL_DTYPE(label_buf) == DTYPE_SCSI)
&& BSD_LABEL_DTYPE (label_buf) == DTYPE_SCSI)
bsd_evil_hack = 4;
return 1;
@@ -364,7 +364,7 @@ check_BSD_parts(int flags)
static char cur_part_desc[16];
static int
real_open_partition(int flags)
real_open_partition (int flags)
{
char mbr_buf[SECTOR_SIZE];
int i, part_no, slice_no, ext = 0, part_offset = 0;
@@ -373,14 +373,14 @@ real_open_partition(int flags)
* The "rawread" is probably unnecessary here, but it is good to
* know it works.
*/
if ( !sane_partition()
|| !rawread(current_drive, 0, 0, SECTOR_SIZE, (int) mbr_buf) )
if (!sane_partition ()
|| !rawread (current_drive, 0, 0, SECTOR_SIZE, (int) mbr_buf))
return 0;
bsd_evil_hack = 0;
current_slice = 0;
part_start = 0;
part_length = SECTORS(buf_geom) * HEADS(buf_geom) * CYLINDERS(buf_geom);
part_length = SECTORS (buf_geom) * HEADS (buf_geom) * CYLINDERS (buf_geom);
if (current_drive & 0x80)
{
@@ -399,15 +399,15 @@ real_open_partition(int flags)
/*
* Load the current MBR-style PC partition table (4 entries)
*/
while ( slice_no < 255 && ext >= 0
&& (part_no == 0xFF || slice_no <= part_no)
&& rawread(current_drive, part_offset,
0, SECTOR_SIZE, (int) mbr_buf) )
while (slice_no < 255 && ext >= 0
&& (part_no == 0xFF || slice_no <= part_no)
&& rawread (current_drive, part_offset,
0, SECTOR_SIZE, (int) mbr_buf))
{
/*
* If the table isn't valid, we can't continue
*/
if ( !PC_MBR_CHECK_SIG(mbr_buf) )
if (!PC_MBR_CHECK_SIG (mbr_buf))
{
errnum = ERR_BAD_PART_TABLE;
return 0;
@@ -421,11 +421,11 @@ real_open_partition(int flags)
for (i = 0; i < PC_SLICE_MAX; i++)
{
current_partition = ((slice_no << 16)
| (current_partition & 0xFFFF));
current_slice = PC_SLICE_TYPE(mbr_buf, i);
part_start = part_offset + PC_SLICE_START(mbr_buf, i);
part_length = PC_SLICE_LENGTH(mbr_buf, i);
bcopy(mbr_buf+PC_SLICE_OFFSET+(i<<4), cur_part_desc, 16);
| (current_partition & 0xFFFF));
current_slice = PC_SLICE_TYPE (mbr_buf, i);
part_start = part_offset + PC_SLICE_START (mbr_buf, i);
part_length = PC_SLICE_LENGTH (mbr_buf, i);
bcopy (mbr_buf + PC_SLICE_OFFSET + (i << 4), cur_part_desc, 16);
/*
* Is this PC partition entry valid?
@@ -449,14 +449,14 @@ real_open_partition(int flags)
else if (flags)
{
current_partition |= 0xFFFF;
printf(" Partition num: %d, ", slice_no);
printf (" Partition num: %d, ", slice_no);
if (current_slice != PC_SLICE_TYPE_BSD)
check_and_print_mount();
check_and_print_mount ();
else
check_BSD_parts(1);
check_BSD_parts (1);
errnum = ERR_NONE;
}
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
/*
* If we've found the right partition, we're done
*/
@@ -467,7 +467,7 @@ real_open_partition(int flags)
if ((current_partition & 0xFF00) != 0xFF00)
{
if (current_slice == PC_SLICE_TYPE_BSD)
check_BSD_parts(0);
check_BSD_parts (0);
else
errnum = ERR_NO_PART;
}
@@ -488,7 +488,7 @@ real_open_partition(int flags)
slice_no++;
}
part_offset = ext_offset + PC_SLICE_START(mbr_buf, ext);
part_offset = ext_offset + PC_SLICE_START (mbr_buf, ext);
if (!ext_offset)
ext_offset = part_offset;
}
@@ -500,7 +500,7 @@ real_open_partition(int flags)
*/
ext = -1;
if ((flags || (current_partition & 0xFF00) != 0xFF00)
&& check_BSD_parts(flags))
&& check_BSD_parts (flags))
ext = -2;
else
{
@@ -518,10 +518,10 @@ real_open_partition(int flags)
else
{
current_partition = 0xFFFFFF;
check_and_print_mount();
check_and_print_mount ();
errnum = 0;
}
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
}
}
@@ -536,24 +536,25 @@ real_open_partition(int flags)
int
open_partition(void)
open_partition (void)
{
return real_open_partition(0);
return real_open_partition (0);
}
/* XX used for device completion in 'set_device' and 'print_completions' */
static int incomplete, disk_choice;
static enum
{
PART_UNSPECIFIED = 0,
PART_DISK,
PART_CHOSEN,
} part_choice;
{
PART_UNSPECIFIED = 0,
PART_DISK,
PART_CHOSEN,
}
part_choice;
char *
set_device(char *device)
set_device (char *device)
{
/* The use of retval in this function is not really clean, but it works */
char *retval = 0;
@@ -571,10 +572,10 @@ set_device(char *device)
char ch = *device;
if ((*device == 'f' || *device == 'h')
&& (device += 2, (*(device-1) != 'd')))
&& (device += 2, (*(device - 1) != 'd')))
errnum = ERR_NUMBER_PARSING;
safe_parse_maxint(&device, (int*)&current_drive);
safe_parse_maxint (&device, (int *) &current_drive);
disk_choice = 0;
if (ch == 'h')
@@ -602,7 +603,7 @@ set_device(char *device)
current_partition = 0;
if (!(current_drive & 0x80)
|| !safe_parse_maxint(&device, (int*)&current_partition)
|| !safe_parse_maxint (&device, (int *) &current_partition)
|| current_partition > 254)
{
errnum = ERR_DEV_FORMAT;
@@ -612,7 +613,7 @@ set_device(char *device)
current_partition = (current_partition << 16) + 0xFFFF;
if (*device == ','
&& *(device+1) >= 'a' && *(device+1) <= 'h')
&& *(device + 1) >= 'a' && *(device + 1) <= 'h')
{
device++;
current_partition = (((*(device++) - 'a') << 8)
@@ -657,10 +658,10 @@ set_device(char *device)
*/
int
open_device(void)
open_device (void)
{
if (open_partition())
attempt_mount();
if (open_partition ())
attempt_mount ();
if (errnum != ERR_NONE)
return 0;
@@ -671,14 +672,14 @@ open_device(void)
#ifndef NO_FANCY_STUFF
int
set_bootdev(int hdbias)
set_bootdev (int hdbias)
{
int i, j;
/*
* Set chainloader boot device.
*/
bcopy(cur_part_desc, (char *)(BOOTSEC_LOCATION-16), 16);
bcopy (cur_part_desc, (char *) (BOOTSEC_LOCATION - 16), 16);
/*
* Set BSD boot device.
@@ -694,32 +695,32 @@ set_bootdev(int hdbias)
if (saved_drive & 0x80)
j = bsd_evil_hack;
return MAKEBOOTDEV( j, (i >> 4), (i & 0xF),
return MAKEBOOTDEV (j, (i >> 4), (i & 0xF),
((saved_drive - hdbias) & 0x79),
((saved_partition >> 8) & 0xFF) );
((saved_partition >> 8) & 0xFF));
}
#endif /* NO_FANCY_STUFF */
static char *
setup_part(char *filename)
setup_part (char *filename)
{
if (*filename == '(')
{
if ( (filename = set_device(filename)) == 0 )
{
current_drive = 0xFF;
return 0;
}
if ((filename = set_device (filename)) == 0)
{
current_drive = 0xFF;
return 0;
}
#ifndef NO_BLOCK_FILES
if (*filename != '/')
open_partition();
open_partition ();
else
#endif /* NO_BLOCK_FILES */
open_device();
open_device ();
}
else if (saved_drive != current_drive
|| saved_partition != current_partition
|| saved_partition != current_partition
|| (*filename == '/' && fsys_type == NUM_FSYS)
|| buf_drive == -1)
{
@@ -729,10 +730,10 @@ setup_part(char *filename)
is found. This makes block files work fine on no filesystem */
#ifndef NO_BLOCK_FILES
if (*filename != '/')
open_partition();
open_partition ();
else
#endif /* NO_BLOCK_FILES */
open_device();
open_device ();
}
if (errnum && (*filename == '/' || errnum != ERR_FSYS_MOUNT))
@@ -740,7 +741,7 @@ setup_part(char *filename)
else
errnum = 0;
if (!sane_partition())
if (!sane_partition ())
return 0;
return filename;
@@ -753,19 +754,19 @@ setup_part(char *filename)
*/
void
print_fsys_type(void)
print_fsys_type (void)
{
printf(" Filesystem type ");
printf (" Filesystem type ");
if (fsys_type != NUM_FSYS)
printf("is %s, ", fsys_table[fsys_type].name);
printf ("is %s, ", fsys_table[fsys_type].name);
else
printf("unknown, ");
printf ("unknown, ");
if (current_partition == 0xFFFFFF)
printf("using whole disk\n");
printf ("using whole disk\n");
else
printf("partition type 0x%x\n", current_slice);
printf ("partition type 0x%x\n", current_slice);
}
/*
@@ -774,11 +775,11 @@ print_fsys_type(void)
*/
void
print_completions(char *filename)
print_completions (char *filename)
{
char *ptr = filename;
if (*filename == '/' || (ptr = set_device(filename)) || incomplete)
if (*filename == '/' || (ptr = set_device (filename)) || incomplete)
{
errnum = 0;
@@ -789,7 +790,7 @@ print_completions(char *filename)
/* disk completions */
int disk_no, i, j;
printf(" Possible disks are: ");
printf (" Possible disks are: ");
for (i = 0; i < 2; i++)
{
@@ -797,39 +798,39 @@ print_completions(char *filename)
{
disk_no = (i * 0x80) + j;
if ((disk_choice || disk_no == current_drive)
&& get_diskinfo(disk_no))
printf(" %cd%d", (i ? 'h' : 'f'), j);
&& get_diskinfo (disk_no))
printf (" %cd%d", (i ? 'h' : 'f'), j);
}
}
putchar('\n');
putchar ('\n');
}
else
{
/* partition completions */
if (part_choice == PART_DISK)
{
printf(" Possible partitions are:\n");
real_open_partition(1);
printf (" Possible partitions are:\n");
real_open_partition (1);
}
else
{
if (open_partition())
check_and_print_mount();
if (open_partition ())
check_and_print_mount ();
}
}
}
else if (*ptr == '/')
{
/* filename completions */
printf(" Possible files are:");
dir(filename);
printf (" Possible files are:");
dir (filename);
}
else
errnum = ERR_BAD_FILENAME;
}
print_error();
print_error ();
}
#endif /* NO_FANCY_STUFF */
@@ -839,17 +840,17 @@ print_completions(char *filename)
*/
int
open(char *filename)
open (char *filename)
{
#ifndef NO_DECOMPRESSION
compressed_file = 0;
#endif /* NO_DECOMPRESSION */
#endif /* NO_DECOMPRESSION */
/* if any "dir" function uses/sets filepos, it must
set it to zero before returning if opening a file! */
filepos = 0;
if (!(filename = setup_part(filename)))
if (!(filename = setup_part (filename)))
return 0;
#ifndef NO_BLOCK_FILES
@@ -869,12 +870,12 @@ open(char *filename)
while (list_addr < BLK_MAX_ADDR)
{
tmp = 0;
safe_parse_maxint(&ptr, &tmp);
safe_parse_maxint (&ptr, &tmp);
errnum = 0;
if (*ptr != '+')
{
if ((*ptr && *ptr != '/' && !isspace(*ptr))
if ((*ptr && *ptr != '/' && !isspace (*ptr))
|| tmp == 0 || tmp > filemax)
errnum = ERR_BAD_FILENAME;
else
@@ -887,18 +888,18 @@ open(char *filename)
be remounted */
fsys_type = NUM_FSYS;
BLK_BLKSTART(list_addr) = tmp;
BLK_BLKSTART (list_addr) = tmp;
ptr++;
if (!safe_parse_maxint(&ptr, &tmp)
if (!safe_parse_maxint (&ptr, &tmp)
|| tmp == 0
|| (*ptr && *ptr != ',' && *ptr != '/' && !isspace(*ptr)))
|| (*ptr && *ptr != ',' && *ptr != '/' && !isspace (*ptr)))
{
errnum = ERR_BAD_FILENAME;
break;
}
BLK_BLKLENGTH(list_addr) = tmp;
BLK_BLKLENGTH (list_addr) = tmp;
filemax += (tmp * SECTOR_SIZE);
list_addr += BLK_BLKLIST_INC_VAL;
@@ -917,14 +918,14 @@ open(char *filename)
BLK_CUR_BLKNUM = 0;
#ifndef NO_DECOMPRESSION
return gunzip_test_header();
#else /* NO_DECOMPRESSION */
return gunzip_test_header ();
#else /* NO_DECOMPRESSION */
return 1;
#endif /* NO_DECOMPRESSION */
#endif /* NO_DECOMPRESSION */
}
#else /* NO_BLOCK_FILES */
#else /* NO_BLOCK_FILES */
errnum = ERR_BAD_FILENAME;
#endif /* NO_BLOCK_FILES */
#endif /* NO_BLOCK_FILES */
}
if (!errnum && fsys_type == NUM_FSYS)
@@ -933,13 +934,13 @@ open(char *filename)
/* set "dir" function to open a file */
print_possibilities = 0;
if (!errnum && (*(fsys_table[fsys_type].dir_func))(filename))
if (!errnum && (*(fsys_table[fsys_type].dir_func)) (filename))
{
#ifndef NO_DECOMPRESSION
return gunzip_test_header();
#else /* NO_DECOMPRESSION */
return gunzip_test_header ();
#else /* NO_DECOMPRESSION */
return 1;
#endif /* NO_DECOMPRESSION */
#endif /* NO_DECOMPRESSION */
}
return 0;
@@ -947,7 +948,7 @@ open(char *filename)
int
read(int addr, int len)
read (int addr, int len)
{
/* Make sure "filepos" is a sane value */
if ((filepos < 0) | (filepos > filemax))
@@ -960,7 +961,7 @@ read(int addr, int len)
/* if target file position is past the end of
the supported/configured filesize, then
there is an error */
if (filepos+len > fsmax)
if (filepos + len > fsmax)
{
errnum = ERR_FILELENGTH;
return 0;
@@ -968,8 +969,8 @@ read(int addr, int len)
#ifndef NO_DECOMPRESSION
if (compressed_file)
return gunzip_read(addr, len);
#endif /* NO_DECOMPRESSION */
return gunzip_read (addr, len);
#endif /* NO_DECOMPRESSION */
#ifndef NO_BLOCK_FILES
if (block_file)
@@ -987,15 +988,15 @@ read(int addr, int len)
}
/* run BLK_CUR_FILEPOS up to filepos */
while ( filepos > BLK_CUR_FILEPOS )
while (filepos > BLK_CUR_FILEPOS)
{
if ( (filepos - (BLK_CUR_FILEPOS & ~(SECTOR_SIZE - 1)))
>= SECTOR_SIZE )
if ((filepos - (BLK_CUR_FILEPOS & ~(SECTOR_SIZE - 1)))
>= SECTOR_SIZE)
{
BLK_CUR_FILEPOS += SECTOR_SIZE;
BLK_CUR_BLKNUM++;
if ( BLK_CUR_BLKNUM >= BLK_BLKLENGTH(BLK_CUR_BLKLIST) )
if (BLK_CUR_BLKNUM >= BLK_BLKLENGTH (BLK_CUR_BLKLIST))
{
BLK_CUR_BLKLIST += BLK_BLKLIST_INC_VAL;
BLK_CUR_BLKNUM = 0;
@@ -1006,22 +1007,22 @@ read(int addr, int len)
}
off = filepos & (SECTOR_SIZE - 1);
size = ( ( BLK_BLKLENGTH(BLK_CUR_BLKLIST) - BLK_CUR_BLKNUM )
* SECTOR_SIZE ) - off;
size = ((BLK_BLKLENGTH (BLK_CUR_BLKLIST) - BLK_CUR_BLKNUM)
* SECTOR_SIZE) - off;
if (size > len)
size = len;
#ifndef NO_FANCY_STUFF
debug_fs_func = debug_fs;
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
/* read current block and put it in the right place in memory */
devread(BLK_BLKSTART(BLK_CUR_BLKLIST) + BLK_CUR_BLKNUM,
off, size, addr);
devread (BLK_BLKSTART (BLK_CUR_BLKLIST) + BLK_CUR_BLKNUM,
off, size, addr);
#ifndef NO_FANCY_STUFF
debug_fs_func = NULL;
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
len -= size;
filepos += size;
@@ -1034,7 +1035,7 @@ read(int addr, int len)
return ret;
}
#endif /* NO_BLOCK_FILES */
#endif /* NO_BLOCK_FILES */
if (fsys_type == NUM_FSYS)
{
@@ -1042,18 +1043,18 @@ read(int addr, int len)
return 0;
}
return (*(fsys_table[fsys_type].read_func))(addr, len);
return (*(fsys_table[fsys_type].read_func)) (addr, len);
}
int
dir(char *dirname)
dir (char *dirname)
{
#ifndef NO_DECOMPRESSION
compressed_file = 0;
#endif /* NO_DECOMPRESSION */
#endif /* NO_DECOMPRESSION */
if (!(dirname = setup_part(dirname)))
if (!(dirname = setup_part (dirname)))
return 0;
if (*dirname != '/')
@@ -1068,5 +1069,5 @@ dir(char *dirname)
/* set "dir" function to list completions */
print_possibilities = 1;
return (*(fsys_table[fsys_type].dir_func))(dirname);
return (*(fsys_table[fsys_type].dir_func)) (dirname);
}
+2 -3
View File
@@ -71,13 +71,13 @@
* Defines minimum disk size to be considered a FAT partition
*/
#define FAT_MIN_NUM_SECTORS 720 /* 360 K disk */
#define FAT_MIN_NUM_SECTORS 720 /* 360 K disk */
/*
* Defines how to differentiate a 12-bit and 16-bit FAT.
*/
#define FAT_MAX_12BIT_CLUST 4087 /* 4085 + 2 */
#define FAT_MAX_12BIT_CLUST 4087 /* 4085 + 2 */
#define FAT_BPB_FLOPPY_NUM_SECTORS(bpb) \
( *((unsigned short *) (((int)bpb) + 19)) \
@@ -111,4 +111,3 @@
(*((unsigned short *) (entry+26)))
#define FAT_DIRENTRY_FILELENGTH(entry) \
(*((unsigned long *) (entry+28)))
+21 -21
View File
@@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@@ -35,18 +36,18 @@
#ifdef FSYS_FFS
#define FSYS_FFS_NUM 1
int ffs_mount(void);
int ffs_read(int addr, int len);
int ffs_dir(char *dirname);
int ffs_mount (void);
int ffs_read (int addr, int len);
int ffs_dir (char *dirname);
#else
#define FSYS_FFS_NUM 0
#endif
#ifdef FSYS_FAT
#define FSYS_FAT_NUM 1
int fat_mount(void);
int fat_mount (void);
/* XX FAT filesystem uses block filesystem code for read! */
int fat_dir(char *dirname);
int fat_dir (char *dirname);
#ifdef NO_BLOCK_FILES
#undef NO_BLOCK_FILES
#endif /* NO_BLOCK_FILES */
@@ -56,9 +57,9 @@ int fat_dir(char *dirname);
#ifdef FSYS_EXT2FS
#define FSYS_EXT2FS_NUM 1
int ext2fs_mount(void);
int ext2fs_read(int addr, int len);
int ext2fs_dir(char *dirname);
int ext2fs_mount (void);
int ext2fs_read (int addr, int len);
int ext2fs_dir (char *dirname);
#else
#define FSYS_EXT2FS_NUM 0
#endif
@@ -82,38 +83,37 @@ int ext2fs_dir(char *dirname);
/* this next part is pretty ugly, but it keeps it in one place! */
struct fsys_entry
{
char *name;
int (*mount_func)(void);
int (*read_func)(int addr, int len);
int (*dir_func)(char *dirname);
};
{
char *name;
int (*mount_func) (void);
int (*read_func) (int addr, int len);
int (*dir_func) (char *dirname);
};
#ifndef _DISK_IO_C
extern int fsmax;
extern int print_possibilities;
extern struct fsys_entry fsys_table[NUM_FSYS+1];
extern struct fsys_entry fsys_table[NUM_FSYS + 1];
#else
int fsmax;
int print_possibilities;
struct fsys_entry fsys_table[NUM_FSYS+1] =
struct fsys_entry fsys_table[NUM_FSYS + 1] =
{
#ifdef FSYS_FAT
{ "fat", fat_mount, 0, fat_dir },
{"fat", fat_mount, 0, fat_dir},
#endif
#ifdef FSYS_EXT2FS
{ "ext2fs", ext2fs_mount, ext2fs_read, ext2fs_dir },
{"ext2fs", ext2fs_mount, ext2fs_read, ext2fs_dir},
#endif
/* XX FFS should come last as it's superblock is commonly crossing tracks
on floppies from track 1 to 2, while others only use 1. */
#ifdef FSYS_FFS
{ "ffs", ffs_mount, ffs_read, ffs_dir },
{"ffs", ffs_mount, ffs_read, ffs_dir},
#endif
{ 0, 0, 0, 0 }
{0, 0, 0, 0}
};
#endif
+32 -31
View File
@@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@@ -18,22 +19,22 @@
*/
/* command-line parameter defines */
#define RB_ASKNAME 0x01 /* ask for file name to reboot from */
#define RB_SINGLE 0x02 /* reboot to single user only */
#define RB_NOSYNC 0x04 /* dont sync before reboot */
#define RB_HALT 0x08 /* don't reboot, just halt */
#define RB_INITNAME 0x10 /* name given for /etc/init (unused) */
#define RB_DFLTROOT 0x20 /* use compiled-in rootdev */
#define RB_KDB 0x40 /* give control to kernel debugger */
#define RB_RDONLY 0x80 /* mount root fs read-only */
#define RB_DUMP 0x100 /* dump kernel memory before reboot */
#define RB_MINIROOT 0x200 /* mini-root present in memory at boot time */
#define RB_CONFIG 0x400 /* invoke user configuration routing */
#define RB_VERBOSE 0x800 /* print all potentially useful info */
#define RB_SERIAL 0x1000 /* user serial port as console */
#define RB_CDROM 0x2000 /* use cdrom as root */
#define RB_ASKNAME 0x01 /* ask for file name to reboot from */
#define RB_SINGLE 0x02 /* reboot to single user only */
#define RB_NOSYNC 0x04 /* dont sync before reboot */
#define RB_HALT 0x08 /* don't reboot, just halt */
#define RB_INITNAME 0x10 /* name given for /etc/init (unused) */
#define RB_DFLTROOT 0x20 /* use compiled-in rootdev */
#define RB_KDB 0x40 /* give control to kernel debugger */
#define RB_RDONLY 0x80 /* mount root fs read-only */
#define RB_DUMP 0x100 /* dump kernel memory before reboot */
#define RB_MINIROOT 0x200 /* mini-root present in memory at boot time */
#define RB_CONFIG 0x400 /* invoke user configuration routing */
#define RB_VERBOSE 0x800 /* print all potentially useful info */
#define RB_SERIAL 0x1000 /* user serial port as console */
#define RB_CDROM 0x2000 /* use cdrom as root */
#define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */
#define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */
/*
* Constants for converting boot-style device number to type,
@@ -71,20 +72,20 @@
* Flags are used to indicate the validity of fields where zero is a
* normal value.
*/
struct bootinfo {
unsigned int bi_version;
unsigned char *bi_kernelname;
struct nfs_diskless *bi_nfs_diskless;
/* End of fields that are always present. */
struct bootinfo
{
unsigned int bi_version;
unsigned char *bi_kernelname;
struct nfs_diskless *bi_nfs_diskless;
/* End of fields that are always present. */
#define bi_endcommon bi_n_bios_used
unsigned int bi_n_bios_used;
unsigned long bi_bios_geom[N_BIOS_GEOM];
unsigned int bi_size;
unsigned char bi_memsizes_valid;
unsigned char bi_pad[3];
unsigned long bi_basemem;
unsigned long bi_extmem;
unsigned long bi_symtab;
unsigned long bi_esymtab;
};
unsigned int bi_n_bios_used;
unsigned long bi_bios_geom[N_BIOS_GEOM];
unsigned int bi_size;
unsigned char bi_memsizes_valid;
unsigned char bi_pad[3];
unsigned long bi_basemem;
unsigned long bi_extmem;
unsigned long bi_symtab;
unsigned long bi_esymtab;
};
+126 -123
View File
@@ -1,3 +1,4 @@
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
@@ -131,110 +132,111 @@
* N.B. sizeof(struct csum) must be a power of two in order for
* the ``fs_cs'' macro to work (see below).
*/
struct csum {
int cs_ndir; /* number of directories */
int cs_nbfree; /* number of free blocks */
int cs_nifree; /* number of free inodes */
int cs_nffree; /* number of free frags */
};
struct csum
{
int cs_ndir; /* number of directories */
int cs_nbfree; /* number of free blocks */
int cs_nifree; /* number of free inodes */
int cs_nffree; /* number of free frags */
};
/*
* Super block for a file system.
*/
#define FS_MAGIC 0x011954
struct fs
{
int xxx1; /* struct fs *fs_link;*/
int xxx2; /* struct fs *fs_rlink;*/
daddr_t fs_sblkno; /* addr of super-block in filesys */
daddr_t fs_cblkno; /* offset of cyl-block in filesys */
daddr_t fs_iblkno; /* offset of inode-blocks in filesys */
daddr_t fs_dblkno; /* offset of first data after cg */
int fs_cgoffset; /* cylinder group offset in cylinder */
int fs_cgmask; /* used to calc mod fs_ntrak */
time_t fs_time; /* last time written */
int fs_size; /* number of blocks in fs */
int fs_dsize; /* number of data blocks in fs */
int fs_ncg; /* number of cylinder groups */
int fs_bsize; /* size of basic blocks in fs */
int fs_fsize; /* size of frag blocks in fs */
int fs_frag; /* number of frags in a block in fs */
struct fs
{
int xxx1; /* struct fs *fs_link; */
int xxx2; /* struct fs *fs_rlink; */
daddr_t fs_sblkno; /* addr of super-block in filesys */
daddr_t fs_cblkno; /* offset of cyl-block in filesys */
daddr_t fs_iblkno; /* offset of inode-blocks in filesys */
daddr_t fs_dblkno; /* offset of first data after cg */
int fs_cgoffset; /* cylinder group offset in cylinder */
int fs_cgmask; /* used to calc mod fs_ntrak */
time_t fs_time; /* last time written */
int fs_size; /* number of blocks in fs */
int fs_dsize; /* number of data blocks in fs */
int fs_ncg; /* number of cylinder groups */
int fs_bsize; /* size of basic blocks in fs */
int fs_fsize; /* size of frag blocks in fs */
int fs_frag; /* number of frags in a block in fs */
/* these are configuration parameters */
int fs_minfree; /* minimum percentage of free blocks */
int fs_rotdelay; /* num of ms for optimal next block */
int fs_rps; /* disk revolutions per second */
int fs_minfree; /* minimum percentage of free blocks */
int fs_rotdelay; /* num of ms for optimal next block */
int fs_rps; /* disk revolutions per second */
/* these fields can be computed from the others */
int fs_bmask; /* ``blkoff'' calc of blk offsets */
int fs_fmask; /* ``fragoff'' calc of frag offsets */
int fs_bshift; /* ``lblkno'' calc of logical blkno */
int fs_fshift; /* ``numfrags'' calc number of frags */
int fs_bmask; /* ``blkoff'' calc of blk offsets */
int fs_fmask; /* ``fragoff'' calc of frag offsets */
int fs_bshift; /* ``lblkno'' calc of logical blkno */
int fs_fshift; /* ``numfrags'' calc number of frags */
/* these are configuration parameters */
int fs_maxcontig; /* max number of contiguous blks */
int fs_maxbpg; /* max number of blks per cyl group */
int fs_maxcontig; /* max number of contiguous blks */
int fs_maxbpg; /* max number of blks per cyl group */
/* these fields can be computed from the others */
int fs_fragshift; /* block to frag shift */
int fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
int fs_sbsize; /* actual size of super block */
int fs_csmask; /* csum block offset */
int fs_csshift; /* csum block number */
int fs_nindir; /* value of NINDIR */
int fs_inopb; /* value of INOPB */
int fs_nspf; /* value of NSPF */
int fs_fragshift; /* block to frag shift */
int fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
int fs_sbsize; /* actual size of super block */
int fs_csmask; /* csum block offset */
int fs_csshift; /* csum block number */
int fs_nindir; /* value of NINDIR */
int fs_inopb; /* value of INOPB */
int fs_nspf; /* value of NSPF */
/* yet another configuration parameter */
int fs_optim; /* optimization preference, see below */
int fs_optim; /* optimization preference, see below */
/* these fields are derived from the hardware */
int fs_npsect; /* # sectors/track including spares */
int fs_interleave; /* hardware sector interleave */
int fs_trackskew; /* sector 0 skew, per track */
int fs_headswitch; /* head switch time, usec */
int fs_trkseek; /* track-to-track seek, usec */
int fs_npsect; /* # sectors/track including spares */
int fs_interleave; /* hardware sector interleave */
int fs_trackskew; /* sector 0 skew, per track */
int fs_headswitch; /* head switch time, usec */
int fs_trkseek; /* track-to-track seek, usec */
/* sizes determined by number of cylinder groups and their sizes */
daddr_t fs_csaddr; /* blk addr of cyl grp summary area */
int fs_cssize; /* size of cyl grp summary area */
int fs_cgsize; /* cylinder group size */
daddr_t fs_csaddr; /* blk addr of cyl grp summary area */
int fs_cssize; /* size of cyl grp summary area */
int fs_cgsize; /* cylinder group size */
/* these fields are derived from the hardware */
int fs_ntrak; /* tracks per cylinder */
int fs_nsect; /* sectors per track */
int fs_spc; /* sectors per cylinder */
int fs_ntrak; /* tracks per cylinder */
int fs_nsect; /* sectors per track */
int fs_spc; /* sectors per cylinder */
/* this comes from the disk driver partitioning */
int fs_ncyl; /* cylinders in file system */
int fs_ncyl; /* cylinders in file system */
/* these fields can be computed from the others */
int fs_cpg; /* cylinders per group */
int fs_ipg; /* inodes per group */
int fs_fpg; /* blocks per group * fs_frag */
int fs_cpg; /* cylinders per group */
int fs_ipg; /* inodes per group */
int fs_fpg; /* blocks per group * fs_frag */
/* this data must be re-computed after crashes */
struct csum fs_cstotal; /* cylinder summary information */
struct csum fs_cstotal; /* cylinder summary information */
/* these fields are cleared at mount time */
char fs_fmod; /* super block modified flag */
char fs_clean; /* file system is clean flag */
char fs_ronly; /* mounted read-only flag */
char fs_flags; /* currently unused flag */
char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
char fs_fmod; /* super block modified flag */
char fs_clean; /* file system is clean flag */
char fs_ronly; /* mounted read-only flag */
char fs_flags; /* currently unused flag */
char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
/* these fields retain the current block allocation info */
int fs_cgrotor; /* last cg searched */
int fs_cgrotor; /* last cg searched */
#if 1
int was_fs_csp[MAXCSBUFS];
int was_fs_csp[MAXCSBUFS];
#else
struct csum *fs_csp[MAXCSBUFS];/* list of fs_cs info buffers */
struct csum *fs_csp[MAXCSBUFS]; /* list of fs_cs info buffers */
#endif
int fs_cpc; /* cyl per cycle in postbl */
short fs_opostbl[16][8]; /* old rotation block list head */
long fs_sparecon[50]; /* reserved for future constants */
long fs_contigsumsize; /* size of cluster summary array */
long fs_maxsymlinklen; /* max length of an internal symlink */
long fs_inodefmt; /* format of on-disk inodes */
quad fs_maxfilesize; /* maximum representable file size */
quad fs_qbmask; /* ~fs_bmask - for use with quad size */
quad fs_qfmask; /* ~fs_fmask - for use with quad size */
long fs_state; /* validate fs_clean field */
int fs_postblformat; /* format of positional layout tables */
int fs_nrpos; /* number of rotaional positions */
int fs_postbloff; /* (short) rotation block list head */
int fs_rotbloff; /* (u_char) blocks for each rotation */
int fs_magic; /* magic number */
u_char fs_space[1]; /* list of blocks for each rotation */
int fs_cpc; /* cyl per cycle in postbl */
short fs_opostbl[16][8]; /* old rotation block list head */
long fs_sparecon[50]; /* reserved for future constants */
long fs_contigsumsize; /* size of cluster summary array */
long fs_maxsymlinklen; /* max length of an internal symlink */
long fs_inodefmt; /* format of on-disk inodes */
quad fs_maxfilesize; /* maximum representable file size */
quad fs_qbmask; /* ~fs_bmask - for use with quad size */
quad fs_qfmask; /* ~fs_fmask - for use with quad size */
long fs_state; /* validate fs_clean field */
int fs_postblformat; /* format of positional layout tables */
int fs_nrpos; /* number of rotaional positions */
int fs_postbloff; /* (short) rotation block list head */
int fs_rotbloff; /* (u_char) blocks for each rotation */
int fs_magic; /* magic number */
u_char fs_space[1]; /* list of blocks for each rotation */
/* actually longer */
};
};
/*
* Preference for optimization.
*/
@@ -270,28 +272,29 @@ struct fs
* Cylinder group block for a file system.
*/
#define CG_MAGIC 0x090255
struct cg {
int xxx1; /* struct cg *cg_link;*/
int cg_magic; /* magic number */
time_t cg_time; /* time last written */
int cg_cgx; /* we are the cgx'th cylinder group */
short cg_ncyl; /* number of cyl's this cg */
short cg_niblk; /* number of inode blocks this cg */
int cg_ndblk; /* number of data blocks this cg */
struct csum cg_cs; /* cylinder summary information */
int cg_rotor; /* position of last used block */
int cg_frotor; /* position of last used frag */
int cg_irotor; /* position of last used inode */
int cg_frsum[MAXFRAG]; /* counts of available frags */
int cg_btotoff; /* (long) block totals per cylinder */
int cg_boff; /* (short) free block positions */
int cg_iusedoff; /* (char) used inode map */
int cg_freeoff; /* (u_char) free block map */
int cg_nextfreeoff; /* (u_char) next available space */
int cg_sparecon[16]; /* reserved for future use */
u_char cg_space[1]; /* space for cylinder group maps */
struct cg
{
int xxx1; /* struct cg *cg_link; */
int cg_magic; /* magic number */
time_t cg_time; /* time last written */
int cg_cgx; /* we are the cgx'th cylinder group */
short cg_ncyl; /* number of cyl's this cg */
short cg_niblk; /* number of inode blocks this cg */
int cg_ndblk; /* number of data blocks this cg */
struct csum cg_cs; /* cylinder summary information */
int cg_rotor; /* position of last used block */
int cg_frotor; /* position of last used frag */
int cg_irotor; /* position of last used inode */
int cg_frsum[MAXFRAG]; /* counts of available frags */
int cg_btotoff; /* (long) block totals per cylinder */
int cg_boff; /* (short) free block positions */
int cg_iusedoff; /* (char) used inode map */
int cg_freeoff; /* (u_char) free block map */
int cg_nextfreeoff; /* (u_char) next available space */
int cg_sparecon[16]; /* reserved for future use */
u_char cg_space[1]; /* space for cylinder group maps */
/* actually longer */
};
};
/*
* Macros for access to cylinder group array structures
*/
@@ -318,26 +321,27 @@ struct cg {
* The following structure is defined
* for compatibility with old file systems.
*/
struct ocg {
int xxx1; /* struct ocg *cg_link;*/
int xxx2; /* struct ocg *cg_rlink;*/
time_t cg_time; /* time last written */
int cg_cgx; /* we are the cgx'th cylinder group */
short cg_ncyl; /* number of cyl's this cg */
short cg_niblk; /* number of inode blocks this cg */
int cg_ndblk; /* number of data blocks this cg */
struct csum cg_cs; /* cylinder summary information */
int cg_rotor; /* position of last used block */
int cg_frotor; /* position of last used frag */
int cg_irotor; /* position of last used inode */
int cg_frsum[8]; /* counts of available frags */
int cg_btot[32]; /* block totals per cylinder */
short cg_b[32][8]; /* positions of free blocks */
char cg_iused[256]; /* used inode map */
int cg_magic; /* magic number */
u_char cg_free[1]; /* free block map */
struct ocg
{
int xxx1; /* struct ocg *cg_link; */
int xxx2; /* struct ocg *cg_rlink; */
time_t cg_time; /* time last written */
int cg_cgx; /* we are the cgx'th cylinder group */
short cg_ncyl; /* number of cyl's this cg */
short cg_niblk; /* number of inode blocks this cg */
int cg_ndblk; /* number of data blocks this cg */
struct csum cg_cs; /* cylinder summary information */
int cg_rotor; /* position of last used block */
int cg_frotor; /* position of last used frag */
int cg_irotor; /* position of last used inode */
int cg_frsum[8]; /* counts of available frags */
int cg_btot[32]; /* block totals per cylinder */
short cg_b[32][8]; /* positions of free blocks */
char cg_iused[256]; /* used inode map */
int cg_magic; /* magic number */
u_char cg_free[1]; /* free block map */
/* actually longer */
};
};
/*
* Turn file system block numbers into disk block addresses.
@@ -452,4 +456,3 @@ struct ocg {
* NINDIR is the number of indirects in a file system block.
*/
#define NINDIR(fs) ((fs)->fs_nindir)
+518 -454
View File
File diff suppressed because it is too large. Load diff
+48 -47
View File
@@ -30,31 +30,31 @@ static int data_offset;
static int fat_size;
/* pointer(s) into filesystem info buffer for DOS stuff */
#define BPB ( FSYS_BUF + 32256 ) /* 512 bytes long */
#define FAT_BUF ( FSYS_BUF + 30208 ) /* 4 sector FAT buffer */
#define BPB ( FSYS_BUF + 32256 ) /* 512 bytes long */
#define FAT_BUF ( FSYS_BUF + 30208 ) /* 4 sector FAT buffer */
int
fat_mount(void)
fat_mount (void)
{
int retval = 1;
if ( (((current_drive & 0x80) || (current_slice != 0))
&& (current_slice != PC_SLICE_TYPE_FAT12)
&& (current_slice != PC_SLICE_TYPE_FAT16_LT32M)
&& (current_slice != PC_SLICE_TYPE_FAT16_GT32M)
&& (current_slice != (PC_SLICE_TYPE_BSD | (FS_MSDOS<<8))))
|| !devread(0, 0, SECTOR_SIZE, BPB)
|| FAT_BPB_BYTES_PER_SECTOR(BPB) != SECTOR_SIZE
|| FAT_BPB_SECT_PER_CLUST(BPB) < 1 || FAT_BPB_SECT_PER_CLUST(BPB) > 64
|| (FAT_BPB_SECT_PER_CLUST(BPB) & (FAT_BPB_SECT_PER_CLUST(BPB) - 1))
|| !( (current_drive & 0x80)
|| FAT_BPB_FLOPPY_NUM_SECTORS(BPB) ) )
if ((((current_drive & 0x80) || (current_slice != 0))
&& (current_slice != PC_SLICE_TYPE_FAT12)
&& (current_slice != PC_SLICE_TYPE_FAT16_LT32M)
&& (current_slice != PC_SLICE_TYPE_FAT16_GT32M)
&& (current_slice != (PC_SLICE_TYPE_BSD | (FS_MSDOS << 8))))
|| !devread (0, 0, SECTOR_SIZE, BPB)
|| FAT_BPB_BYTES_PER_SECTOR (BPB) != SECTOR_SIZE
|| FAT_BPB_SECT_PER_CLUST (BPB) < 1 || FAT_BPB_SECT_PER_CLUST (BPB) > 64
|| (FAT_BPB_SECT_PER_CLUST (BPB) & (FAT_BPB_SECT_PER_CLUST (BPB) - 1))
|| !((current_drive & 0x80)
|| FAT_BPB_FLOPPY_NUM_SECTORS (BPB)))
retval = 0;
else
{
mapblock = -4096;
data_offset = FAT_BPB_DATA_OFFSET(BPB);
num_clust = FAT_BPB_NUM_CLUST(BPB) + 2;
data_offset = FAT_BPB_DATA_OFFSET (BPB);
num_clust = FAT_BPB_NUM_CLUST (BPB) + 2;
if (num_clust > FAT_MAX_12BIT_CLUST)
fat_size = 4;
else
@@ -66,7 +66,7 @@ fat_mount(void)
static int
fat_create_blocklist(int first_fat_entry)
fat_create_blocklist (int first_fat_entry)
{
BLK_CUR_FILEPOS = 0;
BLK_CUR_BLKNUM = 0;
@@ -78,11 +78,12 @@ fat_create_blocklist(int first_fat_entry)
{
/* root directory */
BLK_BLKSTART(BLK_BLKLIST_START) = FAT_BPB_ROOT_DIR_START(BPB);
fsmax = filemax = SECTOR_SIZE * (BLK_BLKLENGTH(BLK_BLKLIST_START)
= FAT_BPB_ROOT_DIR_LENGTH(BPB));
BLK_BLKSTART (BLK_BLKLIST_START) = FAT_BPB_ROOT_DIR_START (BPB);
fsmax = filemax = SECTOR_SIZE * (BLK_BLKLENGTH (BLK_BLKLIST_START)
= FAT_BPB_ROOT_DIR_LENGTH (BPB));
}
else /* any real directory/file */
else
/* any real directory/file */
{
int blk_cur_blklist = BLK_BLKLIST_START, blk_cur_blknum;
int last_fat_entry, new_mapblock;
@@ -91,13 +92,13 @@ fat_create_blocklist(int first_fat_entry)
do
{
BLK_BLKSTART(blk_cur_blklist)
= (first_fat_entry-2) * FAT_BPB_SECT_PER_CLUST(BPB) + data_offset;
BLK_BLKSTART (blk_cur_blklist)
= (first_fat_entry - 2) * FAT_BPB_SECT_PER_CLUST (BPB) + data_offset;
blk_cur_blknum = 0;
do
{
blk_cur_blknum += FAT_BPB_SECT_PER_CLUST(BPB);
blk_cur_blknum += FAT_BPB_SECT_PER_CLUST (BPB);
last_fat_entry = first_fat_entry;
/*
@@ -108,10 +109,10 @@ fat_create_blocklist(int first_fat_entry)
if (new_mapblock > (mapblock + 2045)
|| new_mapblock < (mapblock + 3))
{
mapblock = ( (new_mapblock < 6) ? 0 :
((new_mapblock - 6) & ~0x1FF) );
if (!devread((mapblock>>9)+FAT_BPB_FAT_START(BPB),
0, SECTOR_SIZE * 4, FAT_BUF))
mapblock = ((new_mapblock < 6) ? 0 :
((new_mapblock - 6) & ~0x1FF));
if (!devread ((mapblock >> 9) + FAT_BPB_FAT_START (BPB),
0, SECTOR_SIZE * 4, FAT_BUF))
return 0;
}
@@ -135,7 +136,7 @@ fat_create_blocklist(int first_fat_entry)
while (first_fat_entry == (last_fat_entry + 1)
&& first_fat_entry < num_clust);
BLK_BLKLENGTH(blk_cur_blklist) = blk_cur_blknum;
BLK_BLKLENGTH (blk_cur_blklist) = blk_cur_blknum;
fsmax += blk_cur_blknum * SECTOR_SIZE;
blk_cur_blklist += BLK_BLKLIST_INC_VAL;
}
@@ -151,7 +152,7 @@ fat_create_blocklist(int first_fat_entry)
int
fat_dir(char *dirname)
fat_dir (char *dirname)
{
char *rest, ch, filename[13], dir_buf[FAT_DIRENTRY_LENGTH];
int attrib = FAT_ATTRIB_DIR, map = -1;
@@ -159,13 +160,13 @@ fat_dir(char *dirname)
/* main loop to find desired directory entry */
loop:
if (!fat_create_blocklist(map))
if (!fat_create_blocklist (map))
return 0;
/* if we have a real file (and we're not just printing possibilities),
then this is where we want to exit */
if (!*dirname || isspace(*dirname))
if (!*dirname || isspace (*dirname))
{
if (attrib & FAT_ATTRIB_DIR)
{
@@ -189,19 +190,19 @@ loop:
return 0;
}
for (rest = dirname; (ch = *rest) && !isspace(ch) && ch != '/'; rest++) ;
for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++);
*rest = 0;
do
{
if (read((int)dir_buf, FAT_DIRENTRY_LENGTH) != FAT_DIRENTRY_LENGTH)
if (read ((int) dir_buf, FAT_DIRENTRY_LENGTH) != FAT_DIRENTRY_LENGTH)
{
if (!errnum)
{
if (print_possibilities < 0)
{
putchar('\n');
putchar ('\n');
return 1;
}
@@ -212,43 +213,43 @@ loop:
return 0;
}
if (!FAT_DIRENTRY_VALID(dir_buf))
if (!FAT_DIRENTRY_VALID (dir_buf))
continue;
/* XXX convert to 8.3 filename format here */
{
int i, j, c;
for (i = 0; i < 8 && (c = filename[i] = tolower(dir_buf[i]))
&& !isspace(c) ; i++) ;
for (i = 0; i < 8 && (c = filename[i] = tolower (dir_buf[i]))
&& !isspace (c); i++);
filename[i++] = '.';
for (j = 0; j < 3 && (c = filename[i+j] = tolower(dir_buf[8+j]))
&& !isspace(c) ; j++) ;
for (j = 0; j < 3 && (c = filename[i + j] = tolower (dir_buf[8 + j]))
&& !isspace (c); j++);
if (j == 0)
i--;
filename[i+j] = 0;
filename[i + j] = 0;
}
if (print_possibilities && ch != '/'
&& (!*dirname || substring(dirname, filename) <= 0))
&& (!*dirname || substring (dirname, filename) <= 0))
{
if (print_possibilities > 0)
print_possibilities = -print_possibilities;
printf(" %s", filename);
printf (" %s", filename);
}
}
while (substring(dirname, filename) != 0 ||
while (substring (dirname, filename) != 0 ||
(print_possibilities && ch != '/'));
*(dirname = rest) = ch;
attrib = FAT_DIRENTRY_ATTRIB(dir_buf);
filemax = FAT_DIRENTRY_FILELENGTH(dir_buf);
map = FAT_DIRENTRY_FIRST_CLUSTER(dir_buf);
attrib = FAT_DIRENTRY_ATTRIB (dir_buf);
filemax = FAT_DIRENTRY_FILELENGTH (dir_buf);
map = FAT_DIRENTRY_FIRST_CLUSTER (dir_buf);
/* go back to main loop at top of function */
goto loop;
+39 -39
View File
@@ -75,15 +75,15 @@ static int mapblock;
int
ffs_mount(void)
ffs_mount (void)
{
int retval = 1;
if ( (((current_drive & 0x80) || (current_slice != 0))
&& current_slice != (PC_SLICE_TYPE_BSD | (FS_BSDFFS<<8)))
|| part_length < (SBLOCK + (SBSIZE/DEV_BSIZE))
|| !devread(SBLOCK, 0, SBSIZE, (int) SUPERBLOCK)
|| SUPERBLOCK->fs_magic != FS_MAGIC )
if ((((current_drive & 0x80) || (current_slice != 0))
&& current_slice != (PC_SLICE_TYPE_BSD | (FS_BSDFFS << 8)))
|| part_length < (SBLOCK + (SBSIZE / DEV_BSIZE))
|| !devread (SBLOCK, 0, SBSIZE, (int) SUPERBLOCK)
|| SUPERBLOCK->fs_magic != FS_MAGIC)
retval = 0;
mapblock = -1;
@@ -92,16 +92,16 @@ ffs_mount(void)
}
int
block_map(int file_block)
block_map (int file_block)
{
int bnum;
if (file_block < NDADDR)
return(INODE->i_db[file_block]);
return (INODE->i_db[file_block]);
if ( (bnum = fsbtodb(SUPERBLOCK, INODE->i_ib[0])) != mapblock )
if ((bnum = fsbtodb (SUPERBLOCK, INODE->i_ib[0])) != mapblock)
{
if (!devread(bnum, 0, SUPERBLOCK->fs_bsize, MAPBUF))
if (!devread (bnum, 0, SUPERBLOCK->fs_bsize, MAPBUF))
{
mapblock = -1;
errnum = ERR_FSYS_CORRUPT;
@@ -111,22 +111,22 @@ block_map(int file_block)
mapblock = bnum;
}
return (((int *)MAPBUF)[(file_block - NDADDR) % NINDIR(SUPERBLOCK)]);
return (((int *) MAPBUF)[(file_block - NDADDR) % NINDIR (SUPERBLOCK)]);
}
int
ffs_read(int addr, int len)
ffs_read (int addr, int len)
{
int logno, off, size, map, ret = 0;
while (len && !errnum)
{
off = blkoff(SUPERBLOCK, filepos);
logno = lblkno(SUPERBLOCK, filepos);
size = blksize(SUPERBLOCK, INODE, logno);
off = blkoff (SUPERBLOCK, filepos);
logno = lblkno (SUPERBLOCK, filepos);
size = blksize (SUPERBLOCK, INODE, logno);
if ((map = block_map(logno)) < 0)
if ((map = block_map (logno)) < 0)
break;
size -= off;
@@ -136,13 +136,13 @@ ffs_read(int addr, int len)
#ifndef NO_FANCY_STUFF
debug_fs_func = debug_fs;
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
devread(fsbtodb(SUPERBLOCK, map), off, size, addr);
devread (fsbtodb (SUPERBLOCK, map), off, size, addr);
#ifndef NO_FANCY_STUFF
debug_fs_func = NULL;
#endif /* NO_FANCY_STUFF */
#endif /* NO_FANCY_STUFF */
addr += size;
len -= size;
@@ -158,7 +158,7 @@ ffs_read(int addr, int len)
int
ffs_dir(char *dirname)
ffs_dir (char *dirname)
{
char *rest, ch;
int block, off, loc, map, ino = ROOTINO;
@@ -169,17 +169,17 @@ loop:
/* load current inode (defaults to the root inode) */
if (!devread(fsbtodb(SUPERBLOCK,itod(SUPERBLOCK,ino)),
0, SUPERBLOCK->fs_bsize, FSYS_BUF))
return 0; /* XXX what return value? */
if (!devread (fsbtodb (SUPERBLOCK, itod (SUPERBLOCK, ino)),
0, SUPERBLOCK->fs_bsize, FSYS_BUF))
return 0; /* XXX what return value? */
bcopy((void *)&(((struct dinode *)FSYS_BUF)[ino % (SUPERBLOCK->fs_inopb)]),
(void *)INODE, sizeof (struct dinode));
bcopy ((void *) &(((struct dinode *) FSYS_BUF)[ino % (SUPERBLOCK->fs_inopb)]),
(void *) INODE, sizeof (struct dinode));
/* if we have a real file (and we're not just printing possibilities),
then this is where we want to exit */
if (!*dirname || isspace(*dirname))
if (!*dirname || isspace (*dirname))
{
if ((INODE->i_mode & IFMT) != IFREG)
{
@@ -190,7 +190,7 @@ loop:
filemax = INODE->i_size;
/* incomplete implementation requires this! */
fsmax = (NDADDR + NINDIR(SUPERBLOCK)) * SUPERBLOCK->fs_bsize;
fsmax = (NDADDR + NINDIR (SUPERBLOCK)) * SUPERBLOCK->fs_bsize;
return 1;
}
@@ -205,7 +205,7 @@ loop:
return 0;
}
for (rest = dirname; (ch = *rest) && !isspace(ch) && ch != '/'; rest++) ;
for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++);
*rest = 0;
loc = 0;
@@ -216,7 +216,7 @@ loop:
{
if (loc >= INODE->i_size)
{
putchar('\n');
putchar ('\n');
if (print_possibilities < 0)
return 1;
@@ -226,13 +226,13 @@ loop:
return 0;
}
if (!(off = blkoff(SUPERBLOCK, loc)))
if (!(off = blkoff (SUPERBLOCK, loc)))
{
block = lblkno(SUPERBLOCK, loc);
block = lblkno (SUPERBLOCK, loc);
if ( (map = block_map(block)) < 0
|| !devread(fsbtodb(SUPERBLOCK, map), 0,
blksize(SUPERBLOCK, INODE, block), FSYS_BUF) )
if ((map = block_map (block)) < 0
|| !devread (fsbtodb (SUPERBLOCK, map), 0,
blksize (SUPERBLOCK, INODE, block), FSYS_BUF))
{
errnum = ERR_FSYS_CORRUPT;
*rest = ch;
@@ -240,20 +240,20 @@ loop:
}
}
dp = (struct direct *)(FSYS_BUF + off);
dp = (struct direct *) (FSYS_BUF + off);
loc += dp->d_reclen;
if (dp->d_ino && print_possibilities && ch != '/'
&& (!*dirname || substring(dirname, dp->d_name) <= 0))
&& (!*dirname || substring (dirname, dp->d_name) <= 0))
{
if (print_possibilities > 0)
print_possibilities = -print_possibilities;
printf(" %s", dp->d_name);
printf (" %s", dp->d_name);
}
}
while (!dp->d_ino || (substring(dirname, dp->d_name) != 0
|| (print_possibilities && ch != '/')) );
while (!dp->d_ino || (substring (dirname, dp->d_name) != 0
|| (print_possibilities && ch != '/')));
/* only get here if we have a matching directory entry */
+383 -356
View File
File diff suppressed because it is too large. Load diff
+64 -55
View File
@@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@@ -19,19 +20,20 @@
/* 32-bit data types */
typedef unsigned long Elf32_Addr;
typedef unsigned short Elf32_Half;
typedef unsigned long Elf32_Off;
typedef signed long Elf32_Sword;
typedef unsigned long Elf32_Word;
typedef unsigned long Elf32_Addr;
typedef unsigned short Elf32_Half;
typedef unsigned long Elf32_Off;
typedef signed long Elf32_Sword;
typedef unsigned long Elf32_Word;
/* "unsigned char" already exists */
/* ELF header */
typedef struct {
typedef struct
{
#define EI_NIDENT 16
/* first four characters are defined below */
/* first four characters are defined below */
#define EI_MAG0 0
#define ELFMAG0 0x7f
#define EI_MAG1 1
@@ -41,34 +43,34 @@ typedef struct {
#define EI_MAG3 3
#define ELFMAG3 'F'
#define EI_CLASS 4 /* data sizes */
#define ELFCLASS32 1 /* i386 -- up to 32-bit data sizes present */
#define EI_CLASS 4 /* data sizes */
#define ELFCLASS32 1 /* i386 -- up to 32-bit data sizes present */
#define EI_DATA 5 /* data type and ordering */
#define ELFDATA2LSB 1 /* i386 -- LSB 2's complement */
#define EI_DATA 5 /* data type and ordering */
#define ELFDATA2LSB 1 /* i386 -- LSB 2's complement */
#define EI_VERSION 6 /* version number. "e_version" must be the same */
#define EV_CURRENT 1 /* current version number */
#define EI_VERSION 6 /* version number. "e_version" must be the same */
#define EV_CURRENT 1 /* current version number */
#define EI_PAD 7 /* from here in is just padding */
#define EI_PAD 7 /* from here in is just padding */
unsigned char e_ident[EI_NIDENT]; /* basic identification block */
unsigned char e_ident[EI_NIDENT]; /* basic identification block */
#define ET_EXEC 2 /* we only care about executable types */
Elf32_Half e_type; /* file types */
#define ET_EXEC 2 /* we only care about executable types */
Elf32_Half e_type; /* file types */
#define EM_386 3 /* i386 -- obviously use this one */
Elf32_Half e_machine; /* machine types */
Elf32_Word e_version; /* use same as "EI_VERSION" above */
Elf32_Addr e_entry; /* entry point of the program */
Elf32_Off e_phoff; /* program header table file offset */
Elf32_Off e_shoff; /* section header table file offset */
Elf32_Word e_flags; /* flags */
Elf32_Half e_ehsize; /* elf header size in bytes */
Elf32_Half e_phentsize; /* program header entry size */
Elf32_Half e_phnum; /* number of entries in program header */
Elf32_Half e_shentsize; /* section header entry size */
Elf32_Half e_shnum; /* number of entries in section header */
#define EM_386 3 /* i386 -- obviously use this one */
Elf32_Half e_machine; /* machine types */
Elf32_Word e_version; /* use same as "EI_VERSION" above */
Elf32_Addr e_entry; /* entry point of the program */
Elf32_Off e_phoff; /* program header table file offset */
Elf32_Off e_shoff; /* section header table file offset */
Elf32_Word e_flags; /* flags */
Elf32_Half e_ehsize; /* elf header size in bytes */
Elf32_Half e_phentsize; /* program header entry size */
Elf32_Half e_phnum; /* number of entries in program header */
Elf32_Half e_shentsize; /* section header entry size */
Elf32_Half e_shnum; /* number of entries in section header */
#define SHN_UNDEF 0
#define SHN_LORESERVE 0xff00
@@ -77,8 +79,9 @@ typedef struct {
#define SHN_ABS 0xfff1
#define SHN_COMMON 0xfff2
#define SHN_HIRESERVE 0xffff
Elf32_Half e_shstrndx; /* section header table index */
} Elf32_Ehdr;
Elf32_Half e_shstrndx; /* section header table index */
}
Elf32_Ehdr;
#define BOOTABLE_I386_ELF(h) \
@@ -91,14 +94,15 @@ typedef struct {
/* symbol table - page 4-25, figure 4-15 */
typedef struct
{
Elf32_Word st_name;
Elf32_Addr st_value;
Elf32_Word st_size;
{
Elf32_Word st_name;
Elf32_Addr st_value;
Elf32_Word st_size;
unsigned char st_info;
unsigned char st_other;
Elf32_Half st_shndx;
} Elf32_Sym;
Elf32_Half st_shndx;
}
Elf32_Sym;
/* symbol type and binding attributes - page 4-26 */
@@ -134,16 +138,18 @@ typedef struct
/* program header - page 5-2, figure 5-1 */
typedef struct {
Elf32_Word p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
Elf32_Addr p_paddr;
Elf32_Word p_filesz;
Elf32_Word p_memsz;
Elf32_Word p_flags;
Elf32_Word p_align;
} Elf32_Phdr;
typedef struct
{
Elf32_Word p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
Elf32_Addr p_paddr;
Elf32_Word p_filesz;
Elf32_Word p_memsz;
Elf32_Word p_flags;
Elf32_Word p_align;
}
Elf32_Phdr;
/* segment types - page 5-3, figure 5-2 */
@@ -168,13 +174,17 @@ typedef struct {
/* dynamic structure - page 5-15, figure 5-9 */
typedef struct {
Elf32_Sword d_tag;
union {
Elf32_Word d_val;
Elf32_Addr d_ptr;
} d_un;
} Elf32_Dyn;
typedef struct
{
Elf32_Sword d_tag;
union
{
Elf32_Word d_val;
Elf32_Addr d_ptr;
}
d_un;
}
Elf32_Dyn;
/* Dynamic array tags - page 5-16, figure 5-10. */
@@ -202,4 +212,3 @@ typedef struct {
#define DT_DEBUG 21
#define DT_TEXTREL 22
#define DT_JMPREL 23
+19 -17
View File
@@ -1,3 +1,4 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -94,7 +95,7 @@
/* Text segment offset. */
#define N_TXTOFF(ex) \
(N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \
N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct exec))
N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct exec))
/* Data segment offset. */
#define N_DATOFF(ex) \
@@ -117,23 +118,24 @@
* N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
*/
struct exec {
unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
unsigned long a_text; /* text segment size */
unsigned long a_data; /* initialized data size */
unsigned long a_bss; /* uninitialized data size */
unsigned long a_syms; /* symbol table size */
unsigned long a_entry; /* entry point */
unsigned long a_trsize; /* text relocation size */
unsigned long a_drsize; /* data relocation size */
};
#define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */
struct exec
{
unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
unsigned long a_text; /* text segment size */
unsigned long a_data; /* initialized data size */
unsigned long a_bss; /* uninitialized data size */
unsigned long a_syms; /* symbol table size */
unsigned long a_entry; /* entry point */
unsigned long a_trsize; /* text relocation size */
unsigned long a_drsize; /* data relocation size */
};
#define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */
/* a_magic */
#define OMAGIC 0x107 /* 0407 old impure format */
#define NMAGIC 0x108 /* 0410 read-only text */
#define ZMAGIC 0x10b /* 0413 demand load format */
#define QMAGIC 0xcc /* 0314 "compact" demand load format */
#define OMAGIC 0x107 /* 0407 old impure format */
#define NMAGIC 0x108 /* 0410 read-only text */
#define ZMAGIC 0x10b /* 0413 demand load format */
#define QMAGIC 0xcc /* 0314 "compact" demand load format */
/* a_mid */
#define MID_ZERO 0 /* unknown - implementation dependent */
@@ -144,7 +146,7 @@ struct exec {
#define MID_HP200 200 /* hp200 (68010) BSD binary */
#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
/*
* a_flags
+18 -19
View File
@@ -22,27 +22,27 @@
*/
struct multiboot_header
{
/* Must be MULTIBOOT_MAGIC - see below. */
unsigned magic;
{
/* Must be MULTIBOOT_MAGIC - see below. */
unsigned magic;
/* Feature flags - see below. */
unsigned flags;
/* Feature flags - see below. */
unsigned flags;
/*
* Checksum
*
* The above fields plus this one must equal 0 mod 2^32.
*/
unsigned checksum;
/*
* Checksum
*
* The above fields plus this one must equal 0 mod 2^32.
*/
unsigned checksum;
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
unsigned header_addr;
unsigned load_addr;
unsigned load_end_addr;
unsigned bss_end_addr;
unsigned entry_addr;
};
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
unsigned header_addr;
unsigned load_addr;
unsigned load_end_addr;
unsigned bss_end_addr;
unsigned entry_addr;
};
/*
* The entire multiboot_header must be contained
@@ -76,4 +76,3 @@ struct multiboot_header
/* This flag indicates the use of the other fields in the header. */
#define MULTIBOOT_AOUT_KLUDGE 0x00010000
+62 -59
View File
@@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@@ -22,17 +23,17 @@
*/
struct mod_list
{
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
unsigned long mod_start;
unsigned long mod_end;
{
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
unsigned long mod_start;
unsigned long mod_end;
/* Module command line */
unsigned long cmdline;
/* Module command line */
unsigned long cmdline;
/* padding to take it to 16 bytes (must be zero) */
unsigned long pad;
};
/* padding to take it to 16 bytes (must be zero) */
unsigned long pad;
};
/*
@@ -43,16 +44,16 @@ struct mod_list
*/
struct AddrRangeDesc
{
unsigned long size;
unsigned long BaseAddrLow;
unsigned long BaseAddrHigh;
unsigned long LengthLow;
unsigned long LengthHigh;
unsigned long Type;
{
unsigned long size;
unsigned long BaseAddrLow;
unsigned long BaseAddrHigh;
unsigned long LengthLow;
unsigned long LengthHigh;
unsigned long Type;
/* unspecified optional padding... */
};
/* unspecified optional padding... */
};
/* usable memory "Type", all others are reserved. */
#define MB_ARD_MEMORY 1
@@ -66,49 +67,52 @@ struct AddrRangeDesc
*/
struct multiboot_info
{
/* MultiBoot info version number */
unsigned long flags;
/* Available memory from BIOS */
unsigned long mem_lower;
unsigned long mem_upper;
/* "root" partition */
unsigned long boot_device;
/* Kernel command line */
unsigned long cmdline;
/* Boot-Module list */
unsigned long mods_count;
unsigned long mods_addr;
union
{
struct
{
/* (a.out) Kernel symbol table info */
unsigned long tabsize;
unsigned long strsize;
unsigned long addr;
unsigned long pad;
} a;
/* MultiBoot info version number */
unsigned long flags;
struct
{
/* (ELF) Kernel section header table */
unsigned long num;
unsigned long size;
unsigned long addr;
unsigned long shndx;
} e;
} syms;
/* Available memory from BIOS */
unsigned long mem_lower;
unsigned long mem_upper;
/* Memory Mapping buffer */
unsigned long mmap_length;
unsigned long mmap_addr;
};
/* "root" partition */
unsigned long boot_device;
/* Kernel command line */
unsigned long cmdline;
/* Boot-Module list */
unsigned long mods_count;
unsigned long mods_addr;
union
{
struct
{
/* (a.out) Kernel symbol table info */
unsigned long tabsize;
unsigned long strsize;
unsigned long addr;
unsigned long pad;
}
a;
struct
{
/* (ELF) Kernel section header table */
unsigned long num;
unsigned long size;
unsigned long addr;
unsigned long shndx;
}
e;
}
syms;
/* Memory Mapping buffer */
unsigned long mmap_length;
unsigned long mmap_addr;
};
/*
* Flags to be set in the 'flags' parameter above
@@ -138,4 +142,3 @@ struct multiboot_info
*/
#define MULTIBOOT_VALID 0x2BADB002
+25 -25
View File
@@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@@ -170,33 +171,32 @@
/* possible values for the "DISKTYPE"... all essentially irrelevant
except for DTYPE_SCSI */
#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
#define DTYPE_MSCP 2 /* MSCP */
#define DTYPE_DEC 3 /* other DEC (rk, rl) */
#define DTYPE_SCSI 4 /* SCSI */
#define DTYPE_ESDI 5 /* ESDI interface */
#define DTYPE_ST506 6 /* ST506 etc. */
#define DTYPE_HPIB 7 /* CS/80 on HP-IB */
#define DTYPE_HPFL 8 /* HP Fiber-link */
#define DTYPE_FLOPPY 10 /* floppy */
#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
#define DTYPE_MSCP 2 /* MSCP */
#define DTYPE_DEC 3 /* other DEC (rk, rl) */
#define DTYPE_SCSI 4 /* SCSI */
#define DTYPE_ESDI 5 /* ESDI interface */
#define DTYPE_ST506 6 /* ST506 etc. */
#define DTYPE_HPIB 7 /* CS/80 on HP-IB */
#define DTYPE_HPFL 8 /* HP Fiber-link */
#define DTYPE_FLOPPY 10 /* floppy */
/* possible values for the *BSD-style partition type */
#define FS_UNUSED 0 /* unused */
#define FS_SWAP 1 /* swap */
#define FS_V6 2 /* Sixth Edition */
#define FS_V7 3 /* Seventh Edition */
#define FS_SYSV 4 /* System V */
#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
#define FS_V8 6 /* Eighth Edition, 4K blocks */
#define FS_BSDFFS 7 /* 4.2BSD fast file system */
#define FS_MSDOS 8 /* MSDOS file system */
#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */
#define FS_OTHER 10 /* in use, but unknown/unsupported */
#define FS_HPFS 11 /* OS/2 high-performance file system */
#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
#define FS_BOOT 13 /* partition contains bootstrap */
#define FS_UNUSED 0 /* unused */
#define FS_SWAP 1 /* swap */
#define FS_V6 2 /* Sixth Edition */
#define FS_V7 3 /* Seventh Edition */
#define FS_SYSV 4 /* System V */
#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
#define FS_V8 6 /* Eighth Edition, 4K blocks */
#define FS_BSDFFS 7 /* 4.2BSD fast file system */
#define FS_MSDOS 8 /* MSDOS file system */
#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */
#define FS_OTHER 10 /* in use, but unknown/unsupported */
#define FS_HPFS 11 /* OS/2 high-performance file system */
#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
#define FS_BOOT 13 /* partition contains bootstrap */
#endif /* _PC_SLICE_H */
#endif /* _PC_SLICE_H */
+162 -158
View File
@@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@@ -154,18 +155,18 @@
#define VARIABLE(x) ENTRY(x)
#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */
#define K_STATUS 0x64 /* keyboard status */
#define K_CMD 0x64 /* keybd ctlr command (write-only) */
#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */
#define K_STATUS 0x64 /* keyboard status */
#define K_CMD 0x64 /* keybd ctlr command (write-only) */
#define K_OBUF_FUL 0x01 /* output buffer full */
#define K_IBUF_FUL 0x02 /* input buffer full */
#define K_OBUF_FUL 0x01 /* output buffer full */
#define K_IBUF_FUL 0x02 /* input buffer full */
#define KC_CMD_WIN 0xd0 /* read output port */
#define KC_CMD_WOUT 0xd1 /* write output port */
#define KB_OUTPUT_MASK 0xdd /* enable output buffer full interrupt
enable data line
enable clock line */
#define KC_CMD_WIN 0xd0 /* read output port */
#define KC_CMD_WOUT 0xd1 /* write output port */
#define KB_OUTPUT_MASK 0xdd /* enable output buffer full interrupt
enable data line
enable clock line */
#define KB_A20_ENABLE 0x02
@@ -178,18 +179,18 @@
static inline unsigned char
inb(unsigned short port)
inb (unsigned short port)
{
unsigned char data;
unsigned char data;
__asm __volatile("inb %1,%0" : "=a" (data) : "d" (port));
return data;
__asm __volatile ("inb %1,%0":"=a" (data):"d" (port));
return data;
}
static inline void
outb(unsigned short port, unsigned char val)
outb (unsigned short port, unsigned char val)
{
__asm __volatile("outb %0,%1" : :"a" (val), "d" (port));
__asm __volatile ("outb %0,%1"::"a" (val), "d" (port));
}
@@ -198,10 +199,12 @@ outb(unsigned short port, unsigned char val)
#include "mb_header.h"
#include "mb_info.h"
extern char end[]; /* will be the end of the bss */
extern char end[]; /* will be the end of the bss */
/* this function must be called somewhere... */
void cmain(void) __attribute__ ((noreturn));
void
cmain (void)
__attribute__ ((noreturn));
#define NULL ((void *) 0)
@@ -210,37 +213,37 @@ void cmain(void) __attribute__ ((noreturn));
* From "asm.S"
*/
extern unsigned long install_partition;
extern unsigned long boot_drive;
extern char version_string[];
extern char config_file[];
extern unsigned long install_partition;
extern unsigned long boot_drive;
extern char version_string[];
extern char config_file[];
/* calls for direct boot-loader chaining */
void chain_stage1(int segment, int offset, int part_table_addr)
__attribute__ ((noreturn));
void chain_stage2(int segment, int offset) __attribute__ ((noreturn));
void chain_stage1 (int segment, int offset, int part_table_addr)
__attribute__ ((noreturn));
void chain_stage2 (int segment, int offset) __attribute__ ((noreturn));
/* do some funky stuff, then boot linux */
void linux_boot(void) __attribute__ ((noreturn));
void linux_boot (void) __attribute__ ((noreturn));
/* booting a multiboot executable */
void multi_boot(int start, int mbi) __attribute__ ((noreturn));
void multi_boot (int start, int mbi) __attribute__ ((noreturn));
/* sets it to linear or wired A20 operation */
void gateA20(int linear);
void gateA20 (int linear);
/* memory probe routines */
int get_memsize(int type);
int get_eisamemsize(void);
int get_mmap_entry(int buf, int cont);
int get_memsize (int type);
int get_eisamemsize (void);
int get_mmap_entry (int buf, int cont);
/* low-level timing info */
int getrtsecs(void);
int getrtsecs (void);
/* low-level character I/O */
void cls(void);
int getxy(void); /* returns packed values, LSB+1 is x, LSB is y */
void gotoxy(int x, int y);
void cls (void);
int getxy (void); /* returns packed values, LSB+1 is x, LSB is y */
void gotoxy (int x, int y);
/* displays an ASCII character. IBM displays will translate some
characters to special graphical ones */
@@ -254,7 +257,7 @@ void gotoxy(int x, int y);
#define DISP_RIGHT 0x1a
#define DISP_UP 0x18
#define DISP_DOWN 0x19
void putchar(int c);
void putchar (int c);
/* returns packed BIOS/ASCII code */
#define BIOS_CODE(x) ((x) >> 8)
@@ -269,24 +272,24 @@ void putchar(int c);
#define KEY_END 0x4F00
#define KEY_PGUP 0x4900
#define KEY_PGDN 0x5100
int asm_getkey(void);
int asm_getkey (void);
/* returns 0 if non-ASCII character */
#define getc() ASCII_CHAR(getkey())
/* like 'getkey', but doesn't wait, returns -1 if nothing available */
int checkkey(void);
int checkkey (void);
/* sets text mode character attribute at the cursor position */
#define ATTRIB_NORMAL 0x7
#define ATTRIB_INVERSE 0x70
void set_attrib(int attr);
void set_attrib (int attr);
/* low-level disk I/O */
int get_diskinfo(int drive);
int biosdisk(int subfunc, int drive, int geometry,
int sector, int nsec, int segment);
void stop_floppy(void);
int get_diskinfo (int drive);
int biosdisk (int subfunc, int drive, int geometry,
int sector, int nsec, int segment);
void stop_floppy (void);
/*
@@ -295,15 +298,15 @@ void stop_floppy(void);
#ifndef _CMDLINE_C
extern int fallback;
extern char *password;
extern char commands[];
extern int fallback;
extern char *password;
extern char commands[];
#endif /* _CMDLINE_C */
#endif /* _CMDLINE_C */
char *skip_to(int after_equal, char *cmdline);
void init_cmdline(void);
int enter_cmdline(char *script, char *heap);
char *skip_to (int after_equal, char *cmdline);
void init_cmdline (void);
int enter_cmdline (char *script, char *heap);
/*
@@ -312,44 +315,45 @@ int enter_cmdline(char *script, char *heap);
#ifndef _CHAR_IO_C
int special_attribute;
int special_attribute;
#endif /* _CHAR_IO_C */
#endif /* _CHAR_IO_C */
enum grub_error_t {
ERR_NONE = 0,
ERR_BAD_FILENAME,
ERR_BAD_FILETYPE,
ERR_BAD_GZIP_DATA,
ERR_BAD_GZIP_HEADER,
ERR_BAD_PART_TABLE,
ERR_BAD_VERSION,
ERR_BELOW_1MB,
ERR_BOOT_COMMAND,
ERR_BOOT_FAILURE,
ERR_BOOT_FEATURES,
ERR_DEV_FORMAT,
ERR_DEV_VALUES,
ERR_EXEC_FORMAT,
ERR_FILELENGTH,
ERR_FILE_NOT_FOUND,
ERR_FSYS_CORRUPT,
ERR_FSYS_MOUNT,
ERR_GEOM,
ERR_NEED_LX_KERNEL,
ERR_NEED_MB_KERNEL,
ERR_NO_DISK,
ERR_NO_PART,
ERR_NUMBER_PARSING,
ERR_OUTSIDE_PART,
ERR_READ,
ERR_SYMLINK_LOOP,
ERR_UNRECOGNIZED,
ERR_WONT_FIT,
ERR_WRITE,
enum grub_error_t
{
ERR_NONE = 0,
ERR_BAD_FILENAME,
ERR_BAD_FILETYPE,
ERR_BAD_GZIP_DATA,
ERR_BAD_GZIP_HEADER,
ERR_BAD_PART_TABLE,
ERR_BAD_VERSION,
ERR_BELOW_1MB,
ERR_BOOT_COMMAND,
ERR_BOOT_FAILURE,
ERR_BOOT_FEATURES,
ERR_DEV_FORMAT,
ERR_DEV_VALUES,
ERR_EXEC_FORMAT,
ERR_FILELENGTH,
ERR_FILE_NOT_FOUND,
ERR_FSYS_CORRUPT,
ERR_FSYS_MOUNT,
ERR_GEOM,
ERR_NEED_LX_KERNEL,
ERR_NEED_MB_KERNEL,
ERR_NO_DISK,
ERR_NO_PART,
ERR_NUMBER_PARSING,
ERR_OUTSIDE_PART,
ERR_READ,
ERR_SYMLINK_LOOP,
ERR_UNRECOGNIZED,
ERR_WONT_FIT,
ERR_WRITE,
MAX_ERR_NUM
};
MAX_ERR_NUM
};
/* returns packed BIOS/ASCII code */
#define BIOS_CODE(x) ((x) >> 8)
@@ -364,24 +368,24 @@ enum grub_error_t {
#define KEY_END 0x4F00
#define KEY_PGUP 0x4900
#define KEY_PGDN 0x5100
int getkey(void); /* actually just calls asm_getkey and invalidates the
disk buffer */
int getkey (void); /* actually just calls asm_getkey and invalidates the
disk buffer */
void init_page(void);
void print_error(void);
char *convert_to_ascii(char *buf, int c, ...);
void printf(char *format, ... );
int get_cmdline(char *prompt, char *commands, char *cmdline, int maxlen);
int tolower(int c);
int isspace(int c);
int strncat(char *s1, char *s2, int n);
int substring(char *s1, char *s2);
char *strstr(char *s1, char *s2);
int bcopy(char *from, char *to, int len);
int bzero(char *start, int len);
int get_based_digit(int c, int base);
int safe_parse_maxint(char **str_ptr, int *myint_ptr);
int memcheck(int start, int len);
void init_page (void);
void print_error (void);
char *convert_to_ascii (char *buf, int c,...);
void printf (char *format,...);
int get_cmdline (char *prompt, char *commands, char *cmdline, int maxlen);
int tolower (int c);
int isspace (int c);
int strncat (char *s1, char *s2, int n);
int substring (char *s1, char *s2);
char *strstr (char *s1, char *s2);
int bcopy (char *from, char *to, int len);
int bzero (char *start, int len);
int get_based_digit (int c, int base);
int safe_parse_maxint (char **str_ptr, int *myint_ptr);
int memcheck (int start, int len);
/*
@@ -390,13 +394,13 @@ int memcheck(int start, int len);
#ifndef _GUNZIP_C
extern int no_decompression;
extern int compressed_file;
extern int no_decompression;
extern int compressed_file;
#endif /* _GUNZIP_C */
#endif /* _GUNZIP_C */
int gunzip_test_header(void);
int gunzip_read(int addr, int len);
int gunzip_test_header (void);
int gunzip_read (int addr, int len);
/*
@@ -407,55 +411,55 @@ int gunzip_read(int addr, int len);
#ifndef NO_FANCY_STUFF
/* instrumentation variables */
extern void (*debug_fs)(int);
extern void (*debug_fs_func)(int);
#endif /* NO_FANCY_STUFF */
extern void (*debug_fs) (int);
extern void (*debug_fs_func) (int);
#endif /* NO_FANCY_STUFF */
extern unsigned long current_drive;
extern unsigned long current_partition;
extern unsigned long current_drive;
extern unsigned long current_partition;
extern int fsys_type;
extern int fsys_type;
#ifndef NO_BLOCK_FILES
extern int block_file;
#endif /* NO_BLOCK_FILES */
extern int block_file;
#endif /* NO_BLOCK_FILES */
extern long part_start;
extern long part_length;
extern long part_start;
extern long part_length;
extern int current_slice;
extern int current_slice;
extern int buf_drive;
extern int buf_track;
extern int buf_geom;
extern int buf_drive;
extern int buf_track;
extern int buf_geom;
/* these are the current file position and maximum file position */
extern int filepos;
extern int filemax;
extern int filepos;
extern int filemax;
#endif /* _DISK_IO_C */
#endif /* _DISK_IO_C */
int rawread(int drive, int sector, int byte_offset, int byte_len, int addr);
int devread(int sector, int byte_offset, int byte_len, int addr);
int rawread (int drive, int sector, int byte_offset, int byte_len, int addr);
int devread (int sector, int byte_offset, int byte_len, int addr);
char *set_device(char *device); /* this gets a device from the string and
places it into the global parameters */
int open_device(void);
int make_saved_active(void); /* sets the active partition to the that
represented by the "saved_" parameters */
char *set_device (char *device); /* this gets a device from the string and
places it into the global parameters */
int open_device (void);
int make_saved_active (void); /* sets the active partition to the that
represented by the "saved_" parameters */
int open(char *filename);
int read(int addr, int len); /* if "length" is -1, read all the
remaining data in the file */
int dir(char *dirname); /* list directory, printing all completions */
int open (char *filename);
int read (int addr, int len); /* if "length" is -1, read all the
remaining data in the file */
int dir (char *dirname); /* list directory, printing all completions */
int set_bootdev(int hdbias);
void print_fsys_type(void); /* this prints stats on the currently
mounted filesystem */
void print_completions(char *filename); /* this prints device and filename
completions */
void copy_current_part_entry(int addr); /* copies the current partition data
to the desired address */
int set_bootdev (int hdbias);
void print_fsys_type (void); /* this prints stats on the currently
mounted filesystem */
void print_completions (char *filename); /* this prints device and filename
completions */
void copy_current_part_entry (int addr); /* copies the current partition data
to the desired address */
/*
@@ -463,19 +467,19 @@ void copy_current_part_entry(int addr); /* copies the current partition data
*/
/* for the entry address */
typedef void
(*entry_func)(int, int, int, int, int, int) __attribute__ ((noreturn));
typedef void
(*entry_func) (int, int, int, int, int, int) __attribute__ ((noreturn));
#ifndef _BOOT_C
extern char *cur_cmdline;
extern entry_func entry_addr;
extern char *cur_cmdline;
extern entry_func entry_addr;
#endif /* _BOOT_C */
#endif /* _BOOT_C */
void bsd_boot(int type, int bootdev) __attribute__ ((noreturn));
int load_image(void);
int load_module(void);
void bsd_boot (int type, int bootdev) __attribute__ ((noreturn));
int load_image (void);
int load_module (void);
/*
@@ -489,20 +493,20 @@ int load_module(void);
* Common BIOS/boot data.
*/
extern struct multiboot_info mbi;
extern unsigned long saved_drive;
extern unsigned long saved_partition;
extern unsigned long saved_mem_upper;
extern struct multiboot_info mbi;
extern unsigned long saved_drive;
extern unsigned long saved_partition;
extern unsigned long saved_mem_upper;
/*
* Error variables.
*/
extern int errnum;
extern char *err_list[];
extern int errnum;
extern char *err_list[];
#endif /* _COMMON_C */
#endif /* _COMMON_C */
void init_bios_info(void) __attribute__ ((noreturn));
void init_bios_info (void) __attribute__ ((noreturn));
#endif /* ASM_FILE */
+434 -308
View File
@@ -1,3 +1,4 @@
/*
* <Insert copyright here : it must be BSD-like so anyone can use it>
*
@@ -66,36 +67,121 @@
#define DEF_ENTRIES 23
static int lapic_dummy = 0;
static struct {
imps_processor proc[2];
imps_bus bus[2];
imps_ioapic ioapic;
imps_interrupt intin[16];
imps_interrupt lintin[2];
} defconfig = {
{ { IMPS_BCT_PROCESSOR, 0, 0, 0, 0, 0},
{ IMPS_BCT_PROCESSOR, 1, 0, 0, 0, 0} },
{ { IMPS_BCT_BUS, 0, {'E', 'I', 'S', 'A', ' ', ' '}},
{ 255, 1, {'P', 'C', 'I', ' ', ' ', ' '}} },
{ IMPS_BCT_IOAPIC, 0, 0, IMPS_FLAG_ENABLED, IOAPIC_ADDR_DEFAULT },
{ { IMPS_BCT_IO_INTERRUPT, IMPS_INT_EXTINT, 0, 0, 0, 0xFF, 0},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 1, 0xFF, 1},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 0, 0xFF, 2},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 3, 0xFF, 3},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 4, 0xFF, 4},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 5, 0xFF, 5},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 6, 0xFF, 6},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 7, 0xFF, 7},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 8, 0xFF, 8},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 9, 0xFF, 9},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 10, 0xFF, 10},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 11, 0xFF, 11},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 12, 0xFF, 12},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 13, 0xFF, 13},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 14, 0xFF, 14},
{ IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 15, 0xFF, 15} },
{ { IMPS_BCT_LOCAL_INTERRUPT, IMPS_INT_EXTINT, 0, 0, 15, 0xFF, 0},
{ IMPS_BCT_LOCAL_INTERRUPT, IMPS_INT_NMI, 0, 0, 15, 0xFF, 1} }
static struct
{
imps_processor proc[2];
imps_bus bus[2];
imps_ioapic ioapic;
imps_interrupt intin[16];
imps_interrupt lintin[2];
}
defconfig =
{
{
{
IMPS_BCT_PROCESSOR, 0, 0, 0, 0, 0
}
,
{
IMPS_BCT_PROCESSOR, 1, 0, 0, 0, 0
}
}
,
{
{
IMPS_BCT_BUS, 0,
{
'E', 'I', 'S', 'A', ' ', ' '
}
}
,
{
255, 1,
{
'P', 'C', 'I', ' ', ' ', ' '
}
}
}
,
{
IMPS_BCT_IOAPIC, 0, 0, IMPS_FLAG_ENABLED, IOAPIC_ADDR_DEFAULT
}
,
{
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_EXTINT, 0, 0, 0, 0xFF, 0
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 1, 0xFF, 1
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 0, 0xFF, 2
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 3, 0xFF, 3
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 4, 0xFF, 4
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 5, 0xFF, 5
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 6, 0xFF, 6
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 7, 0xFF, 7
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 8, 0xFF, 8
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 9, 0xFF, 9
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 10, 0xFF, 10
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 11, 0xFF, 11
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 12, 0xFF, 12
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 13, 0xFF, 13
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 14, 0xFF, 14
}
,
{
IMPS_BCT_IO_INTERRUPT, IMPS_INT_INT, 0, 0, 15, 0xFF, 15
}
}
,
{
{
IMPS_BCT_LOCAL_INTERRUPT, IMPS_INT_EXTINT, 0, 0, 15, 0xFF, 0
}
,
{
IMPS_BCT_LOCAL_INTERRUPT, IMPS_INT_NMI, 0, 0, 15, 0xFF, 1
}
}
};
/*
@@ -106,7 +192,7 @@ int imps_any_new_apics = 0;
volatile int imps_release_cpus = 0;
int imps_enabled = 0;
int imps_num_cpus = 1;
unsigned imps_lapic_addr = ((unsigned)(&lapic_dummy)) - LAPIC_ID;
unsigned imps_lapic_addr = ((unsigned) (&lapic_dummy)) - LAPIC_ID;
unsigned char imps_cpu_apic_map[IMPS_MAX_CPUS];
unsigned char imps_apic_cpu_map[IMPS_MAX_CPUS];
@@ -118,15 +204,16 @@ unsigned char imps_apic_cpu_map[IMPS_MAX_CPUS];
*/
static int
get_checksum(unsigned start, int length)
get_checksum (unsigned start, int length)
{
unsigned sum = 0;
unsigned sum = 0;
while (length-- > 0) {
sum += *((unsigned char *) (start++));
}
while (length-- > 0)
{
sum += *((unsigned char *) (start++));
}
return (sum&0xFF);
return (sum & 0xFF);
}
@@ -138,55 +225,56 @@ get_checksum(unsigned start, int length)
*/
static int
boot_cpu(imps_processor *proc)
boot_cpu (imps_processor * proc)
{
int apicid = proc->apic_id;
unsigned bootaddr, send_status, accept_status, cfg;
unsigned bios_reset_vector = PHYS_TO_VIRTUAL(BIOS_RESET_VECTOR);
int apicid = proc->apic_id;
unsigned bootaddr, send_status, accept_status, cfg;
unsigned bios_reset_vector = PHYS_TO_VIRTUAL (BIOS_RESET_VECTOR);
/* %%%%% ESB */
extern char patch_code[];
bootaddr = 256*1024;
bcopy(patch_code, (char *)bootaddr, 32);
/* %%%%% ESB */
extern char patch_code[];
bootaddr = 256 * 1024;
bcopy (patch_code, (char *) bootaddr, 32);
/*
* Generic CPU startup sequence starts here.
*/
/*
* Generic CPU startup sequence starts here.
*/
/* set BIOS reset vector */
CMOS_WRITE_BYTE(CMOS_RESET_CODE, CMOS_RESET_JUMP);
*((volatile unsigned *) bios_reset_vector) = bootaddr << 12;
/* set BIOS reset vector */
CMOS_WRITE_BYTE (CMOS_RESET_CODE, CMOS_RESET_JUMP);
*((volatile unsigned *) bios_reset_vector) = bootaddr << 12;
/* clear the error register */
if (proc->apic_ver & 0x10) {
IMPS_LAPIC_WRITE(LAPIC_ESR, 0);
accept_status = IMPS_LAPIC_READ(LAPIC_ESR);
}
/* clear the error register */
if (proc->apic_ver & 0x10)
{
IMPS_LAPIC_WRITE (LAPIC_ESR, 0);
accept_status = IMPS_LAPIC_READ (LAPIC_ESR);
}
#if 0
/* assert INIT IPI */
cfg = IMPS_LAPIC_READ(LAPIC_ICR+1);
cfg &= LAPIC_DEST_MASK;
IMPS_LAPIC_WRITE(LAPIC_ICR+1, cfg);
cfg = IMPS_LAPIC_READ(LAPIC_ACR);
cfg &= ;
/* assert INIT IPI */
cfg = IMPS_LAPIC_READ (LAPIC_ICR + 1);
cfg &= LAPIC_DEST_MASK;
IMPS_LAPIC_WRITE (LAPIC_ICR + 1, cfg);
cfg = IMPS_LAPIC_READ (LAPIC_ACR);
cfg &=;
/* %%%%% ESB finish adding startup sequence */
/* %%%%% ESB finish adding startup sequence */
#endif
/* clean up BIOS reset vector */
CMOS_WRITE_BYTE(CMOS_RESET_CODE, 0);
*((volatile unsigned *) bios_reset_vector) = 0;
/* clean up BIOS reset vector */
CMOS_WRITE_BYTE (CMOS_RESET_CODE, 0);
*((volatile unsigned *) bios_reset_vector) = 0;
/*
* Generic CPU startup sequence ends here.
*/
/*
* Generic CPU startup sequence ends here.
*/
KERNEL_PRINT(("\n"));
KERNEL_PRINT (("\n"));
return 1;
return 1;
/* XXXXX add OS-specific initialization here! */
/* XXXXX add OS-specific initialization here! */
}
@@ -195,233 +283,267 @@ boot_cpu(imps_processor *proc)
*/
static void
add_processor(imps_processor *proc)
add_processor (imps_processor * proc)
{
int apicid = proc->apic_id;
int apicid = proc->apic_id;
KERNEL_PRINT((" Processor [APIC id %d ver %d]: ",
apicid, proc->apic_ver));
if (!(proc->flags & IMPS_FLAG_ENABLED)) {
KERNEL_PRINT(("DISABLED\n"));
return;
}
if (proc->apic_ver > 0xF) {
imps_any_new_apics = 1;
}
if (proc->flags & (IMPS_CPUFLAG_BOOT)) {
KERNEL_PRINT(("#0 Bootstrap Processor (BSP)\n"));
return;
}
imps_cpu_apic_map[imps_num_cpus] = apicid;
imps_apic_cpu_map[apicid] = imps_num_cpus;
if (boot_cpu(proc)) {
KERNEL_PRINT ((" Processor [APIC id %d ver %d]: ",
apicid, proc->apic_ver));
if (!(proc->flags & IMPS_FLAG_ENABLED))
{
KERNEL_PRINT (("DISABLED\n"));
return;
}
if (proc->apic_ver > 0xF)
{
imps_any_new_apics = 1;
}
if (proc->flags & (IMPS_CPUFLAG_BOOT))
{
KERNEL_PRINT (("#0 Bootstrap Processor (BSP)\n"));
return;
}
imps_cpu_apic_map[imps_num_cpus] = apicid;
imps_apic_cpu_map[apicid] = imps_num_cpus;
if (boot_cpu (proc))
{
/* XXXXX add OS-specific setup for secondary CPUs here */
/* XXXXX add OS-specific setup for secondary CPUs here */
imps_num_cpus++;
}
imps_num_cpus++;
}
}
static void
add_bus(imps_bus *bus)
add_bus (imps_bus * bus)
{
char str[8];
char str[8];
bcopy(bus->bus_type, str, 6);
str[6] = 0;
KERNEL_PRINT((" Bus id %d is %s\n", bus->id, str));
bcopy (bus->bus_type, str, 6);
str[6] = 0;
KERNEL_PRINT ((" Bus id %d is %s\n", bus->id, str));
/* XXXXX add OS-specific code here */
/* XXXXX add OS-specific code here */
}
static void
add_ioapic(imps_ioapic *ioapic)
add_ioapic (imps_ioapic * ioapic)
{
KERNEL_PRINT((" I/O APIC id %d ver %d, address: 0x%x ",
ioapic->id, ioapic->ver, ioapic->addr));
if (!(ioapic->flags & IMPS_FLAG_ENABLED)) {
KERNEL_PRINT(("DISABLED\n"));
return;
}
KERNEL_PRINT(("\n"));
KERNEL_PRINT ((" I/O APIC id %d ver %d, address: 0x%x ",
ioapic->id, ioapic->ver, ioapic->addr));
if (!(ioapic->flags & IMPS_FLAG_ENABLED))
{
KERNEL_PRINT (("DISABLED\n"));
return;
}
KERNEL_PRINT (("\n"));
/* XXXXX add OS-specific code here */
/* XXXXX add OS-specific code here */
}
static void
imps_read_config_table(unsigned start, int count)
imps_read_config_table (unsigned start, int count)
{
while (count-- > 0) {
switch (*((unsigned char *)start)) {
case IMPS_BCT_PROCESSOR:
add_processor((imps_processor *)start);
start += 12; /* 20 total */
break;
case IMPS_BCT_BUS:
add_bus((imps_bus *)start);
break;
case IMPS_BCT_IOAPIC:
add_ioapic((imps_ioapic *)start);
break;
#if 0 /* XXXXX uncomment this if "add_io_interrupt" is implemented */
case IMPS_BCT_IO_INTERRUPT:
add_io_interrupt((imps_interrupt *)start);
break;
while (count-- > 0)
{
switch (*((unsigned char *) start))
{
case IMPS_BCT_PROCESSOR:
add_processor ((imps_processor *) start);
start += 12; /* 20 total */
break;
case IMPS_BCT_BUS:
add_bus ((imps_bus *) start);
break;
case IMPS_BCT_IOAPIC:
add_ioapic ((imps_ioapic *) start);
break;
#if 0 /* XXXXX uncomment this if "add_io_interrupt" is implemented */
case IMPS_BCT_IO_INTERRUPT:
add_io_interrupt ((imps_interrupt *) start);
break;
#endif
#if 0 /* XXXXX uncomment this if "add_local_interrupt" is implemented */
case IMPS_BCT_LOCAL_INTERRUPT:
add_local_interupt((imps_interrupt *)start);
break;
#if 0 /* XXXXX uncomment this if "add_local_interrupt" is implemented */
case IMPS_BCT_LOCAL_INTERRUPT:
add_local_interupt ((imps_interrupt *) start);
break;
#endif
default:
}
start += 8;
default:
}
start += 8;
}
}
static int
imps_bad_bios(imps_fps *fps_ptr)
imps_bad_bios (imps_fps * fps_ptr)
{
int sum;
imps_cth *local_cth_ptr
= (imps_cth *) PHYS_TO_VIRTUAL(fps_ptr->cth_ptr);
int sum;
imps_cth *local_cth_ptr
= (imps_cth *) PHYS_TO_VIRTUAL (fps_ptr->cth_ptr);
if (fps_ptr->feature_info[0] > IMPS_FPS_DEFAULT_MAX) {
KERNEL_PRINT((" Invalid MP System Configuration type %d\n",
fps_ptr->feature_info[0]));
return 1;
if (fps_ptr->feature_info[0] > IMPS_FPS_DEFAULT_MAX)
{
KERNEL_PRINT ((" Invalid MP System Configuration type %d\n",
fps_ptr->feature_info[0]));
return 1;
}
if (fps_ptr->cth_ptr)
{
sum = get_checksum ((unsigned) local_cth_ptr,
local_cth_ptr->base_length);
if (local_cth_ptr->sig != IMPS_CTH_SIGNATURE || sum)
{
KERNEL_PRINT
((" Bad MP Config Table sig 0x%x and/or checksum 0x%x\n",
(unsigned) (fps_ptr->cth_ptr), sum));
return 1;
}
if (fps_ptr->cth_ptr) {
sum = get_checksum((unsigned)local_cth_ptr,
local_cth_ptr->base_length);
if (local_cth_ptr->sig != IMPS_CTH_SIGNATURE || sum) {
KERNEL_PRINT((" Bad MP Config Table sig 0x%x and/or checksum 0x%x\n", (unsigned)(fps_ptr->cth_ptr), sum));
return 1;
}
if (local_cth_ptr->spec_rev != fps_ptr->spec_rev) {
KERNEL_PRINT((" Bad MP Config Table sub-revision # %d\n", local_cth_ptr->spec_rev));
return 1;
}
if (local_cth_ptr->extended_length) {
sum = (get_checksum(((unsigned)local_cth_ptr)
+ local_cth_ptr->base_length,
local_cth_ptr->extended_length)
+ local_cth_ptr->extended_checksum) & 0xFF;
if (sum) {
KERNEL_PRINT((" Bad Extended MP Config Table checksum 0x%x\n", sum));
return 1;
}
}
} else if (!fps_ptr->feature_info[0]) {
KERNEL_PRINT((" Missing configuration information\n"));
return 1;
if (local_cth_ptr->spec_rev != fps_ptr->spec_rev)
{
KERNEL_PRINT ((" Bad MP Config Table sub-revision # %d\n", local_cth_ptr->spec_rev));
return 1;
}
if (local_cth_ptr->extended_length)
{
sum = (get_checksum (((unsigned) local_cth_ptr)
+ local_cth_ptr->base_length,
local_cth_ptr->extended_length)
+ local_cth_ptr->extended_checksum) & 0xFF;
if (sum)
{
KERNEL_PRINT
((" Bad Extended MP Config Table checksum 0x%x\n", sum));
return 1;
}
}
}
else if (!fps_ptr->feature_info[0])
{
KERNEL_PRINT ((" Missing configuration information\n"));
return 1;
}
return 0;
return 0;
}
static void
imps_read_bios(imps_fps *fps_ptr)
imps_read_bios (imps_fps * fps_ptr)
{
int apicid;
unsigned cth_start, cth_count;
imps_cth *local_cth_ptr
= (imps_cth *)PHYS_TO_VIRTUAL(fps_ptr->cth_ptr);
char *str_ptr;
int apicid;
unsigned cth_start, cth_count;
imps_cth *local_cth_ptr
= (imps_cth *) PHYS_TO_VIRTUAL (fps_ptr->cth_ptr);
char *str_ptr;
KERNEL_PRINT(("Intel MultiProcessor Spec 1.%d BIOS support detected\n",
fps_ptr->spec_rev));
KERNEL_PRINT (("Intel MultiProcessor Spec 1.%d BIOS support detected\n",
fps_ptr->spec_rev));
/*
* Do all checking of errors which would definitely
* lead to failure of the SMP boot here.
*/
/*
* Do all checking of errors which would definitely
* lead to failure of the SMP boot here.
*/
if (imps_bad_bios(fps_ptr)) {
KERNEL_PRINT((" Disabling MPS support\n"));
return;
if (imps_bad_bios (fps_ptr))
{
KERNEL_PRINT ((" Disabling MPS support\n"));
return;
}
if (fps_ptr->feature_info[1] & IMPS_FPS_IMCRP_BIT)
{
str_ptr = "IMCR and PIC";
}
else
{
str_ptr = "Virtual Wire";
}
if (fps_ptr->cth_ptr)
{
imps_lapic_addr = local_cth_ptr->lapic_addr;
}
else
{
imps_lapic_addr = LAPIC_ADDR_DEFAULT;
}
KERNEL_PRINT
((" APIC config: \"%s mode\" Local APIC address: 0x%x\n",
str_ptr, imps_lapic_addr));
imps_lapic_addr = PHYS_TO_VIRTUAL (imps_lapic_addr);
/*
* Setup primary CPU.
*/
apicid = IMPS_LAPIC_READ (LAPIC_SPIV);
IMPS_LAPIC_WRITE (LAPIC_SPIV, apicid | LAPIC_SPIV_ENABLE_APIC);
imps_any_new_apics = IMPS_LAPIC_READ (LAPIC_VER) & 0xF0;
apicid = IMPS_APIC_ID (IMPS_LAPIC_READ (LAPIC_ID));
imps_cpu_apic_map[0] = apicid;
imps_apic_cpu_map[apicid] = 0;
if (fps_ptr->cth_ptr)
{
char str1[16], str2[16];
bcopy (local_cth_ptr->oem_id, str1, 8);
str1[8] = 0;
bcopy (local_cth_ptr->prod_id, str2, 12);
str2[12] = 0;
KERNEL_PRINT ((" OEM id: %s Product id: %s\n", str1, str2));
cth_start = ((unsigned) local_cth_ptr) + sizeof (imps_cth);
cth_count = local_cth_ptr->entry_count;
}
else
{
*((volatile unsigned *) IOAPIC_ADDR_DEFAULT) = IOAPIC_ID;
defconfig.ioapic.id
= IMPS_APIC_ID (*((volatile unsigned *)
(IOAPIC_ADDR_DEFAULT + IOAPIC_RW)));
*((volatile unsigned *) IOAPIC_ADDR_DEFAULT) = IOAPIC_VER;
defconfig.ioapic.ver
= APIC_VERSION (*((volatile unsigned *)
(IOAPIC_ADDR_DEFAULT + IOAPIC_RW)));
defconfig.proc[apicid].flags
= IMPS_FLAG_ENABLED | IMPS_CPUFLAG_BOOT;
defconfig.proc[!apicid].flags = IMPS_FLAG_ENABLED;
imps_num_cpus = 2;
if (fps_ptr->feature_info[0] == 1
|| fps_ptr->feature_info[0] == 5)
{
bcopy ("ISA ", defconfig.bus[0].bus_type, 6);
}
if (fps_ptr->feature_info[1] & IMPS_FPS_IMCRP_BIT) {
str_ptr = "IMCR and PIC";
} else {
str_ptr = "Virtual Wire";
if (fps_ptr->feature_info[0] == 4
|| fps_ptr->feature_info[0] == 7)
{
bcopy ("MCA ", defconfig.bus[0].bus_type, 6);
}
if (fps_ptr->cth_ptr) {
imps_lapic_addr = local_cth_ptr->lapic_addr;
} else {
imps_lapic_addr = LAPIC_ADDR_DEFAULT;
if (fps_ptr->feature_info[0] > 4)
{
defconfig.proc[0].apic_ver = 0x10;
defconfig.proc[1].apic_ver = 0x10;
defconfig.bus[1].type = IMPS_BCT_BUS;
}
KERNEL_PRINT((" APIC config: \"%s mode\" Local APIC address: 0x%x\n",
str_ptr, imps_lapic_addr));
imps_lapic_addr = PHYS_TO_VIRTUAL(imps_lapic_addr);
/*
* Setup primary CPU.
*/
apicid = IMPS_LAPIC_READ(LAPIC_SPIV);
IMPS_LAPIC_WRITE(LAPIC_SPIV, apicid|LAPIC_SPIV_ENABLE_APIC);
imps_any_new_apics = IMPS_LAPIC_READ(LAPIC_VER) & 0xF0;
apicid = IMPS_APIC_ID(IMPS_LAPIC_READ(LAPIC_ID));
imps_cpu_apic_map[0] = apicid;
imps_apic_cpu_map[apicid] = 0;
if (fps_ptr->cth_ptr) {
char str1[16], str2[16];
bcopy(local_cth_ptr->oem_id, str1, 8);
str1[8] = 0;
bcopy(local_cth_ptr->prod_id, str2, 12);
str2[12] = 0;
KERNEL_PRINT((" OEM id: %s Product id: %s\n", str1, str2));
cth_start = ((unsigned) local_cth_ptr) + sizeof(imps_cth);
cth_count = local_cth_ptr->entry_count;
} else {
*((volatile unsigned *) IOAPIC_ADDR_DEFAULT) = IOAPIC_ID;
defconfig.ioapic.id
= IMPS_APIC_ID(*((volatile unsigned *)
(IOAPIC_ADDR_DEFAULT+IOAPIC_RW)));
*((volatile unsigned *) IOAPIC_ADDR_DEFAULT) = IOAPIC_VER;
defconfig.ioapic.ver
= APIC_VERSION(*((volatile unsigned *)
(IOAPIC_ADDR_DEFAULT+IOAPIC_RW)));
defconfig.proc[apicid].flags
= IMPS_FLAG_ENABLED|IMPS_CPUFLAG_BOOT;
defconfig.proc[!apicid].flags = IMPS_FLAG_ENABLED;
imps_num_cpus = 2;
if (fps_ptr->feature_info[0] == 1
|| fps_ptr->feature_info[0] == 5) {
bcopy("ISA ", defconfig.bus[0].bus_type, 6);
}
if (fps_ptr->feature_info[0] == 4
|| fps_ptr->feature_info[0] == 7) {
bcopy("MCA ", defconfig.bus[0].bus_type, 6);
}
if (fps_ptr->feature_info[0] > 4) {
defconfig.proc[0].apic_ver = 0x10;
defconfig.proc[1].apic_ver = 0x10;
defconfig.bus[1].type = IMPS_BCT_BUS;
}
if (fps_ptr->feature_info[0] == 2) {
defconfig.intin[2].type = 255;
defconfig.intin[13].type = 255;
}
if (fps_ptr->feature_info[0] == 7) {
defconfig.intin[0].type = 255;
}
cth_start = (unsigned) &defconfig;
cth_count = DEF_ENTRIES;
if (fps_ptr->feature_info[0] == 2)
{
defconfig.intin[2].type = 255;
defconfig.intin[13].type = 255;
}
imps_read_config_table(cth_start, cth_count);
if (fps_ptr->feature_info[0] == 7)
{
defconfig.intin[0].type = 255;
}
cth_start = (unsigned) &defconfig;
cth_count = DEF_ENTRIES;
}
imps_read_config_table (cth_start, cth_count);
/* %%%%% ESB read extended entries here */
/* %%%%% ESB read extended entries here */
imps_enabled = 1;
imps_enabled = 1;
}
@@ -441,28 +563,30 @@ imps_read_bios(imps_fps *fps_ptr)
*/
static int
imps_scan(unsigned start, unsigned length)
imps_scan (unsigned start, unsigned length)
{
IMPS_DEBUG_PRINT(("Scanning from 0x%x for %d bytes\n",
start, length));
IMPS_DEBUG_PRINT (("Scanning from 0x%x for %d bytes\n",
start, length));
while (length > 0) {
imps_fps *fps_ptr = (imps_fps *) PHYS_TO_VIRTUAL(start);
while (length > 0)
{
imps_fps *fps_ptr = (imps_fps *) PHYS_TO_VIRTUAL (start);
if (fps_ptr->sig == IMPS_FPS_SIGNATURE
&& fps_ptr->length == 1
&& (fps_ptr->spec_rev == 1 || fps_ptr->spec_rev == 4)
&& !get_checksum(start, 16)) {
IMPS_DEBUG_PRINT(("Found MP Floating Structure Pointer at %x\n", start));
imps_read_bios(fps_ptr);
return 1;
}
length -= 16;
start += 16;
if (fps_ptr->sig == IMPS_FPS_SIGNATURE
&& fps_ptr->length == 1
&& (fps_ptr->spec_rev == 1 || fps_ptr->spec_rev == 4)
&& !get_checksum (start, 16))
{
IMPS_DEBUG_PRINT (("Found MP Floating Structure Pointer at %x\n", start));
imps_read_bios (fps_ptr);
return 1;
}
return 0;
length -= 16;
start += 16;
}
return 0;
}
@@ -496,54 +620,56 @@ imps_scan(unsigned start, unsigned length)
*/
int
imps_probe(void)
imps_probe (void)
{
/*
* Determine possible address of the EBDA
*/
unsigned ebda_addr = *((unsigned short *)
PHYS_TO_VIRTUAL(EBDA_SEG_ADDR)) << 4;
/*
* Determine possible address of the EBDA
*/
unsigned ebda_addr = *((unsigned short *)
PHYS_TO_VIRTUAL (EBDA_SEG_ADDR)) << 4;
/*
* Determine amount of installed lower memory (not *available*
* lower memory).
*
* NOTE: This should work reliably as long as we verify the
* machine is at least a system that could possibly have
* MPS compatibility to begin with.
*/
unsigned mem_lower = ((CMOS_READ_BYTE(CMOS_BASE_MEMORY+1) << 8)
| CMOS_READ_BYTE(CMOS_BASE_MEMORY)) << 10;
/*
* Determine amount of installed lower memory (not *available*
* lower memory).
*
* NOTE: This should work reliably as long as we verify the
* machine is at least a system that could possibly have
* MPS compatibility to begin with.
*/
unsigned mem_lower = ((CMOS_READ_BYTE (CMOS_BASE_MEMORY + 1) << 8)
| CMOS_READ_BYTE (CMOS_BASE_MEMORY)) << 10;
#ifdef IMPS_DEBUG
imps_enabled = 0;
imps_num_cpus = 1;
imps_enabled = 0;
imps_num_cpus = 1;
#endif
/*
* Sanity check : if this isn't reasonable, it is almost impossibly
* unlikely to be an MPS compatible machine, so return failure.
*/
if (mem_lower < 512*1024 || mem_lower > 640*1024) {
return 0;
}
/*
* Sanity check : if this isn't reasonable, it is almost impossibly
* unlikely to be an MPS compatible machine, so return failure.
*/
if (mem_lower < 512 * 1024 || mem_lower > 640 * 1024)
{
return 0;
}
if (ebda_addr > mem_lower - 1024
|| ebda_addr + *((unsigned char *) PHYS_TO_VIRTUAL(ebda_addr))
* 1024 > mem_lower) {
ebda_addr = 0;
}
if (ebda_addr > mem_lower - 1024
|| ebda_addr + *((unsigned char *) PHYS_TO_VIRTUAL (ebda_addr))
* 1024 > mem_lower)
{
ebda_addr = 0;
}
if (((ebda_addr && imps_scan(ebda_addr, 1024))
|| (!ebda_addr && imps_scan(mem_lower - 1024, 1024))
|| imps_scan(0xF0000, 0x10000)) && imps_enabled) {
return 1;
}
if (((ebda_addr && imps_scan (ebda_addr, 1024))
|| (!ebda_addr && imps_scan (mem_lower - 1024, 1024))
|| imps_scan (0xF0000, 0x10000)) && imps_enabled)
{
return 1;
}
/*
* If no BIOS info on MPS hardware is found, then return failure.
*/
/*
* If no BIOS info on MPS hardware is found, then return failure.
*/
return 0;
return 0;
}
+57 -58
View File
@@ -18,7 +18,7 @@
/* make sure "apic.h" is included */
#ifndef _APIC_H
#error Must include "apic.h" before "smp-imps.h"
#endif /* !_APIC_H */
#endif /* !_APIC_H */
/*
* Defines used.
@@ -26,7 +26,7 @@
#ifdef IMPS_DEBUG
#define IMPS_DEBUG_PRINT(x) KERNEL_PRINT(x)
#else /* !IMPS_DEBUG */
#else /* !IMPS_DEBUG */
#define IMPS_DEBUG_PRINT(x)
#endif /* !IMPS_DEBUG */
@@ -101,14 +101,14 @@ typedef struct imps_interrupt imps_interrupt;
* this structure.
*/
struct imps_fps
{
unsigned sig;
imps_cth *cth_ptr;
unsigned char length;
unsigned char spec_rev;
unsigned char checksum;
unsigned char feature_info[5];
};
{
unsigned sig;
imps_cth *cth_ptr;
unsigned char length;
unsigned char spec_rev;
unsigned char checksum;
unsigned char feature_info[5];
};
/*
* MP Configuration Table Header (cth)
@@ -117,21 +117,21 @@ struct imps_fps
* this structure.
*/
struct imps_cth
{
unsigned sig;
unsigned short base_length;
unsigned char spec_rev;
unsigned char checksum;
char oem_id[8];
char prod_id[12];
unsigned oem_table_ptr;
unsigned short oem_table_size;
unsigned short entry_count;
unsigned lapic_addr;
unsigned short extended_length;
unsigned char extended_checksum;
char reserved[1];
};
{
unsigned sig;
unsigned short base_length;
unsigned char spec_rev;
unsigned char checksum;
char oem_id[8];
char prod_id[12];
unsigned oem_table_ptr;
unsigned short oem_table_size;
unsigned short entry_count;
unsigned lapic_addr;
unsigned short extended_length;
unsigned char extended_checksum;
char reserved[1];
};
/*
* Base MP Configuration Table Types. They are sorted according to
@@ -140,42 +140,42 @@ struct imps_cth
*/
struct imps_processor
{
unsigned char type; /* must be 0 */
unsigned char apic_id;
unsigned char apic_ver;
unsigned char flags;
unsigned signature;
unsigned features;
char reserved[8];
};
{
unsigned char type; /* must be 0 */
unsigned char apic_id;
unsigned char apic_ver;
unsigned char flags;
unsigned signature;
unsigned features;
char reserved[8];
};
struct imps_bus
{
unsigned char type; /* must be 1 */
unsigned char id;
char bus_type[6];
};
{
unsigned char type; /* must be 1 */
unsigned char id;
char bus_type[6];
};
struct imps_ioapic
{
unsigned char type; /* must be 2 */
unsigned char id;
unsigned char ver;
unsigned char flags;
unsigned addr;
};
{
unsigned char type; /* must be 2 */
unsigned char id;
unsigned char ver;
unsigned char flags;
unsigned addr;
};
struct imps_interrupt
{
unsigned char type; /* must be 3 or 4 */
unsigned char int_type;
unsigned short flags;
unsigned char source_bus_id;
unsigned char source_bus_irq;
unsigned char dest_apic_id;
unsigned char dest_apic_intin;
};
{
unsigned char type; /* must be 3 or 4 */
unsigned char int_type;
unsigned short flags;
unsigned char source_bus_id;
unsigned char source_bus_irq;
unsigned char dest_apic_id;
unsigned char dest_apic_intin;
};
/*
@@ -224,7 +224,7 @@ extern unsigned char imps_apic_cpu_map[IMPS_MAX_CPUS];
* Returns 1 if IMPS information was found and is valid, else 0.
*/
int imps_probe(void);
int imps_probe (void);
/*
@@ -235,5 +235,4 @@ int imps_probe(void);
#define IMPS_LAPIC_WRITE(x, y) \
(*((volatile unsigned *) (imps_lapic_addr+(x))) = (y))
#endif /* !_SMP_IMPS_H */
#endif /* !_SMP_IMPS_H */
+7 -7
View File
@@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@@ -20,23 +21,22 @@
#include "shared.h"
void
cmain(void)
cmain (void)
{
printf("\n\nGRUB loading, please wait...\n");
printf ("\n\nGRUB loading, please wait...\n");
/*
* Here load the true second-stage boot-loader.
*/
if (open(config_file) && read(0x8000, -1))
chain_stage2(0, 0x8000);
if (open (config_file) && read (0x8000, -1))
chain_stage2 (0, 0x8000);
/*
* If not, then print error message and die.
*/
print_error();
print_error ();
stop();
stop ();
}