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

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

9
AUTHORS Normal file
View file

@ -0,0 +1,9 @@
Erich Boleyn originally designed and implemented GRUB.
VaX#n8 (real name unknown) wrote shared_src/fsys_ext2fs.c.
Heiko Schroeder rewrote shared_src/stage1.S to be more readable.
Gordon Matzigkeit adopted GRUB into the GNU Project. He fixed several
bugs, added symbolic link support to shared_src/fsys_ext2fs.c, and
implemented the grub configuration program.

View file

@ -1,3 +1,14 @@
1999-02-28 Gordon Matzigkeit <gord@trick.fig.org>
* AUTHORS, INSTALL: New files.
1999-02-24 Gordon Matzigkeit <gord@trick.fig.org>
* stage1/stage1.S (after_BPB): Do a hard disk probe first, so that
we can work with IDE floppies (like the LS-120).
* Run GNU Indent on */*.[ch].
1999-02-21 Gordon Matzigkeit <gord@trick.fig.org>
* debian: Add to the distribution, since we maintain the GRUB

43
INSTALL Normal file
View file

@ -0,0 +1,43 @@
Soon, we hope that GRUB will fully support GNU-standard installation,
and simple runtime configuration, but until then, here are the old
instructions for installing GRUB:
Instructions for installing can be found in "docs/install.html".
Building From Source
To build GRUB from source, first run the bourne-shell script "configure"
(options can be found by running "./configure --help"). It will complain
of missing or bad tools determined by it's tests. If it completes
successfully, then just type "make".
Note that the binary names correspond to subdirectories in the top level
of the distribution. See the makefiles in there for details on where
the source files are drawn from, but in general, the "stage1" only uses
the "stage1.S" file, and the others use source files from the "shared_src"
subdirectory.
IMPORTANT SIZE LIMITS:
- For the various stage2's, if they are being loaded from a block-list
in the stage1, then be sure your blocklist is big enough. The
automated install will generally do this for you, it's just when
dropping it on a raw floppy, you get the default compiled in, which
is 512 * 80 disk sectors, or 40960 bytes.
- For the FFS stage1.5, if you want to fit into the "bootloader" area
of an FFS partition, it cannot be larger than 512 * 14 disk sectors,
or 7168 bytes.
Other Documentation
Pretty much all of the documentation and other helpful information is
in the "docs" directory mostly as HTML files, the root of which is
"index.html".
The FAQ and Installation instructions really need to be updated and
improved!
The TODO and NEWS files are always up-to-date.

89
README
View file

@ -1,76 +1,23 @@
This is GRUB, the GRand Unified Boot-loader. Note that this version
is maintained by Gordon Matzigkeit <gord@debian.org>, until Erich
Boleyn has a chance to catch up with all the patches needed for
Debian. Please do not bother Erich about this release, because he
hasn't approved of it.
This is GNU GRUB, the GRand Unified Bootloader. GRUB is intended to
provide important bootloader features that are missing from typical
personal computer BIOSes:
Here is the original README:
- provides fully-featured command line and graphical interfaces
- recognizes fdisk partitions and BSD disklabels
- can dynamically read Linux ext2fs, BSD ufs, and MS-DOS FAT
filesystems, plus hardcoded blocklists
- can boot Multiboot-compliant kernels (such as GNU Mach), as well
as standard Linux and BSD kernels
See the file docs/NEWS for a description of recent changes to GRUB.
See the file INSTALL for instructions on how to build and install
GRUB.
GRUB -- GRand Unified Boot-loader
If you have any suggestions or bug reports, please send electronic
mail to the GRUB mailing list <bug-grub@gnu.org>.
version 0.5
by Erich Boleyn <erich@uruk.org>
Introduction
This is the public release of GRUB version 0.5, a bootloader for
PC-compatible machines.
Installation
Precompiled versions are included in the "bin" directory:
bin/
stage1 This is the 512-byte stage1 which reads
in the rest of GRUB at boot-time.
ffs_stage1_5 This is an example for how to build a
"stage 1.5" to automatically load a stage2
from the filesystem.
stage2 This is the main part of GRUB.
stage2_debug Same as "stage2", but compiled with the
debug features enabled.
Instructions for installing can be found in "docs/install.html".
Building From Source
To build GRUB from source, first run the bourne-shell script "configure"
(options can be found by running "./configure --help"). It will complain
of missing or bad tools determined by it's tests. If it completes
successfully, then just type "make".
Note that the binary names correspond to subdirectories in the top level
of the distribution. See the makefiles in there for details on where
the source files are drawn from, but in general, the "stage1" only uses
the "stage1.S" file, and the others use source files from the "shared_src"
subdirectory.
IMPORTANT SIZE LIMITS:
- For the various stage2's, if they are being loaded from a block-list
in the stage1, then be sure your blocklist is big enough. The
automated install will generally do this for you, it's just when
dropping it on a raw floppy, you get the default compiled in, which
is 512 * 80 disk sectors, or 40960 bytes.
- For the FFS stage1.5, if you want to fit into the "bootloader" area
of an FFS partition, it cannot be larger than 512 * 14 disk sectors,
or 7168 bytes.
Other Documentation
Pretty much all of the documentation and other helpful information is
in the "docs" directory mostly as HTML files, the root of which is
"index.html".
The FAQ and Installation instructions really need to be updated and
improved!
The TODO and NEWS files are always up-to-date.
DEVELOPERS: to subscribe to the mailing list, send e-mail to
<bug-grub-request@gnu.org>. You can get the latest GRUB CVS tree from
`:pserver:anoncvs@anoncvs.gnu.org:/gd/gnu/anoncvsroot', module `grub'.
Just hit enter when CVS prompts you for a password.

View file

@ -1,9 +1,6 @@
Known problems/bugs:
- Try `d' to delete the selected line while editing a menu entry
(maybe only when deleting the last line). Everything goes to hell.
- FreeBSD boot command-line options are slightly problematic, and
OpenBSD options are probably quite wrong. This is because they
use options that are bits in a data word passed at boot time, and

View file

@ -1,8 +1,9 @@
NEWS - list of user-visible changes between releases of GRUB
New in 0.5.2 - 1999-01-31, Gordon Matzigkeit:
New in 0.6 - FIXME, Gordon Matzigkeit:
* Bug fixes.
*
* GRUB understands symlinks on ext2fs (but not ffs).
* Many source code and build cleanups to comply with GNU standards.
Version 0.5:

View file

@ -1,17 +1,25 @@
Treat `(hd)/boot/grub/menu.lst' as searching through the hard drives
for a partition that contains /boot/grub/menu.lst. Either this, or
`(hd:0x82)' means the first partition of type 0x82. We need one of
these dynamic search mechanisms for clean Hurd install floppies.
Get /sbin/grub to work.
Syntax:
Change partition syntax to correspond with BSD ``slice'' syntax
(`(hd0,1a)' -> `/dev/hd0s2a').
(hd0,0) -> hd0s1
(hd0,1,b) -> hd0s1b
(hd0) -> hd0
Add a partition naming syntax that means ``the first partition of this
type''. We need this for clean Hurd install floppies.
Find out the size restrictions for FAT and ext2fs stage1.5 boot blocks.
Find out the size restrictions for FAT and ext2fs stage1.5 boot
blocks. Enforce all arbitrary limits using the Makefiles.
Check for other patches sent in e-mail!!! There are several...
Look at network booting.
Add stripped-down Guile support, and rewrite current behaviour in
Scheme. Make sure not to break backward compatibilty, or else we'll
be roasted by anti-Guile people.
Add internationalization support, emulating gettext as much as is
feasible.
Maybe add BIOS password support. In any event, improve the existing
password support.
Add support/delays so that a floppy can be installed from
another floppy.
@ -25,7 +33,7 @@ Find out the size restrictions for FAT and ext2fs stage1.5 boot blocks.
Add indirect block support to the BSD FFS filesystem code, so files
larger than 16MB can be read.
??? Make symbolic links work for BSD FFS and Linux ext2fs filesystems.
??? Make symbolic links work for BSD FFS.
??? Add command for modifying partition types.

View file

@ -85,7 +85,7 @@ initial implementation for the ext2fs filesystem.<P>
<LI><B>Miles Bader (miles@gnu.ai.mit.edu)</B> -- for testing feedback.<P>
<LI><B>Eric Hanchrow (erich@microsoft.com)</B> -- for interstate remote
debugging by hand.<P>
<LI><B>Gord Matzigkeit (gord@enci.ucalgary.ca)</B> -- for lots of
<LI><B>Gord Matzigkeit (gord@fig.org)</B> -- for lots of
testing feedback.<P>
<LI><B>Heiko Schroeder (heiko@pool.informatik.rwth-aachen.de)</B> -- for
a re-writing stage1 to be much more readable, plus several patches.<P>
@ -117,4 +117,3 @@ Here are links to the <A HREF=NEWS>NEWS file</A>,
</BODY>
</HTML>

198
mail
View file

@ -1,198 +0,0 @@
From nobody Mon Feb 1 15:36:44 1999
X-From-Line: debian-hurd-request@lists.debian.org Sat Jan 09 01:50:49 1999
Return-Path: <debian-hurd-request@lists.debian.org>
Delivered-To: gord@trick.fig.org
Received: (qmail 25241 invoked from network); 9 Jan 1999 01:50:48 -0000
Received: from gen2-93ip34.cadvision.com (HELO bambam.m-tech.ab.ca) (209.91.93.34)
by ip223.net247210.cr.sk.ca with SMTP; 9 Jan 1999 01:50:48 -0000
Received: from murphy.novare.net (gateway [10.0.0.1])
by bambam.m-tech.ab.ca (8.8.7/8.8.7) with SMTP id SAA19193
for <gord@m-tech.ab.ca>; Fri, 8 Jan 1999 18:47:34 -0700
Received: (qmail 13337 invoked by uid 38); 9 Jan 1999 01:47:33 -0000
Resent-Date: 9 Jan 1999 01:47:32 -0000
Resent-Cc: recipient list not shown: ;
X-Envelope-Sender: ege@rano.demon.co.uk
To: Matthias.Pfisterer@gmx.de
CC: debian-hurd@lists.debian.org
In-reply-to: <36966815.9DA7E110@rupert.informatik.uni-stuttgart.de> (message
from Matthias Pfisterer on Fri, 08 Jan 1999 21:18:29 +0100)
Subject: Re: Debian GNU/Hurd Base Set "gnu-19990104" available now!
From: edmundo@rano.demon.co.uk
Message-Id: <E0zymXI-0001PY-00@localhost>
Sender: Edmund GRIMLEY EVANS <ege@rano.demon.co.uk>
Date: Sat, 9 Jan 1999 00:45:52 +0000
Resent-Message-ID: <"nJdi8B.A.LQD.zUrl2"@murphy>
Resent-From: debian-hurd@lists.debian.org
X-Mailing-List: <debian-hurd@lists.debian.org> archive/latest/581
X-Loop: debian-hurd@lists.debian.org
Precedence: list
Resent-Sender: debian-hurd-request@lists.debian.org
Lines: 64
Xref: trick.fig.org list.debian-hurd:748
> Also, there seems to be a problem booting from internal LS-120 drives.
> Normal operating systems (Windows...) can boot from internal drives if
> the BIOS can handle it. GRUB hangs when I try to boot from an ordinary
> 3,5" disk inserted into the LS-120. I've tested GRUB 0.4, but not
> further explored this issue. It may be a problem of GRUB, but perhaps it
> is a problem of the chipset or the BIOS. I will give a detailed report
> once I've tested it with the newest version of GRUB.
I wrote about this problem earlier in debian-hurd (2 Dec).
I hacked my copy of GRUB so that it works from my internal LS-120. I'm
copying the relevant paragraphs again, below.
By the way, SYSLINUX boots off my LS-120 without problems: it applies
a different algorithm for deciding whether the device is a floppy or a
hard disc. Boot sectors can be quite amusing, really ...
Edmund
As I wrote before, the GRUB boot floppy provided with gnu-0.2.tar.gz
doesn't work off my LS120 IDE floppy. Neither does the 0.5 release of
GRUB, which I built from source. However, after many failed
experiments, I managed to modify grub-0.5's boot sector so that it
works with both my ordinary and my IDE floppies. (I include the patch
below, and I will tell Erich about my experiences.)
...
My GRUB patch:
It's just a hack, not a serious attempt to improve the software, but it
did give a floppy that boots off both my ordinary and my IDE floppy drives.
In grub-0.5/stage1/stage1.S the patch is:
< andb $BIOS_HD_FLAG, %al
<
< /* jz floppy_probe */
< .byte 0x0f, 0x84; REL(floppy_probe)
---
> orb $BIOS_HD_FLAG, %al
>
> /* jz floppy_probe */
> .byte 0x0f, 0x84; REL(floppy_probe)
If you prefer to patch the binary boot sector, the change is:
< 24 80
---
> 0c 80
That's at address 0x55 in grub-0.5/bin/stage1; the address is
different, no doubt, in the Hurd's boot floppy, which is based on an
earlier release of GRUB, but the same change might work for that too.
Edmund
--
To UNSUBSCRIBE, email to debian-hurd-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
To: Erich Boleyn <erich@uruk.org>
cc: debian-hurd@lists.debian.org
Subject: GRUB installation thoughts
X-Attribution: Gord
Gcc: nnml:archive
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: text/plain; charset=US-ASCII
From: Gordon Matzigkeit <gord@trick.fig.org>
Date: 02 Feb 1999 13:24:24 -0600
Message-ID: <86iudk1udz.fsf@trick.fig.org>
Lines: 47
--text follows this line--
Hi!
I've been thinking about GRUB and how to make installation easier.
Here is my plan of how Debian GNU/Hurd installation should work:
1) Boot from floppy or CD or whatever, and GRUB starts. You get
a menu like this:
Install Debian GNU/Hurd
Boot an installed Debian GNU/Hurd system
Install GRUB
2) Go through a typical Debian installation. The install process will
ask you to mark your partition(s) as type 63 (currently reserved
for the GNU Hurd, for some odd reason... I wonder how that
happened?).
3) When the base set is installed, the system reboots from the floppy
again. At that point, all the other menu options should work.
I'd like to implement a GRUB feature so that `(hd:0x63)' means `the
first hard disk partition that is of type 0x63'.
So, the floppy's menu.lst can look something like this:
title = Install Debian GNU/Hurd
root = (fd0)
kernel = /boot/gnumach.gz
title = Boot an installed Debian GNU/Hurd system
root = (hd:0x63)
kernel = /boot/gnumach.gz
title = Install GRUB in the Debian GNU/Hurd root partition
root = (hd:0x63)
install= (fd0)+1 (hd:0x63) (hd:0x63)/boot/grub/fs_stage1_5 0x2000 p
The last bit of magic is to make sure gnumach uses the Multiboot
`boot_device' parameter as its default root, so that we don't need to
specify a root= option to Mach.
Comments?
--
Gordon Matzigkeit <gord@fig.org> //\ I'm a FIG (http://www.fig.org/)
Lovers of freedom, unite! \// I use GNU (http://www.gnu.org/)
[Unfortunately, www.fig.org is broken. Please stay tuned for details.]
From nobody Sun Feb 21 01:59:03 1999
X-From-Line: dunham@cse.msu.edu Sat Feb 20 17:43:34 1999
Return-Path: <dunham@cse.msu.edu>
Delivered-To: gord@trick.fig.org
Received: (qmail 16082 invoked from network); 20 Feb 1999 17:43:34 -0000
Received: from sargasso.cse.msu.edu (35.9.20.14)
by ip223.net247210.cr.sk.ca with SMTP; 20 Feb 1999 17:43:34 -0000
Received: from fatneck.cse.msu.edu (dunham@fatneck.cse.msu.edu [35.9.20.47])
by sargasso.cse.msu.edu (8.8.8/8.8.8) with ESMTP id MAA25678
for <gord@trick.fig.org>; Sat, 20 Feb 1999 12:43:26 -0500 (EST)
Received: (from dunham@localhost)
by fatneck.cse.msu.edu (8.9.2/8.9.2/Debian/GNU) id MAA19662;
Sat, 20 Feb 1999 12:45:10 -0500 (EST)
To: Gordon Matzigkeit <gord@trick.fig.org>
Subject: GRUB
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: text/plain; charset=US-ASCII
From: Steve Dunham <dunham@cse.msu.edu>
Date: 20 Feb 1999 12:45:09 -0500
In-Reply-To: Gordon Matzigkeit's message of "18 Feb 1999 09:12:49 -0600"
Message-ID: <m9bemnl6kbe.fsf_-_@fatneck.cse.msu.edu>
X-Mailer: Gnus v5.5/XEmacs 20.4 - "Emerald"
Lines: 18
Xref: trick.fig.org misc:2354
IIRC, you took over the Grub package and upstream Grub.
You might be interested in the work by the "Fiasco" (aka L4) people at
tu-dresden - they taken Grub 0.4.1 and added network booting to it.
You can get their code at:
ftp://ftp.inf.tu-dresden.de/pub/os/L4/devel/
or grab a local copy of it that I put up at:
http://www.cse.msu.edu/~dunham/out/grub-l4-981207.tar.gz
Steve
dunham@cse.msu.edu

View file

@ -70,4 +70,3 @@
#define LAPIC_TDCR 0x3E0
#endif /* _APIC_H */

View file

@ -44,11 +44,13 @@ 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 {
union
{
struct multiboot_header *mb;
struct exec *aout;
Elf32_Ehdr *elf;
} pu;
}
pu;
/* presuming that MULTIBOOT_SEARCH is large enough to encompass an
executable header */
unsigned char buffer[MULTIBOOT_SEARCH];
@ -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;
@ -571,4 +574,3 @@ bsd_boot(int type, int bootdev)
mbi.mem_upper, mbi.mem_lower);
}
}

View file

@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@ -103,7 +104,9 @@ printf(char *format, ... )
else
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
case 'd':
case 'u':
case 'x':
*convert_to_ascii (str, c, *((unsigned long *) dataptr++)) = 0;
ptr = str;
@ -112,7 +115,9 @@ printf(char *format, ... )
putchar (*(ptr++));
break;
case 'c': putchar((*(dataptr++))&0xff); break;
case 'c':
putchar ((*(dataptr++)) & 0xff);
break;
case 's':
ptr = (char *) (*(dataptr++));
@ -265,7 +270,8 @@ 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');
gotoxy (0, yend);
putchar ('\n');
if (lpos > j)
{
@ -385,7 +391,8 @@ 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');
gotoxy (0, yend);
putchar ('\n');
/* remove leading spaces */
/* use c and lpos as indexes now */

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",

View file

@ -1,3 +1,4 @@
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
@ -50,9 +51,11 @@ typedef unsigned char u_char; /* unsigned char */
typedef unsigned short u_short; /* unsigned short */
typedef unsigned int u_int; /* unsigned int */
typedef struct _quad_ {
typedef struct _quad_
{
unsigned int val[2]; /* 2 int values make... */
} quad; /* an 8-byte item */
}
quad; /* an 8-byte item */
typedef unsigned int time_t; /* an unsigned int */
typedef unsigned int daddr_t; /* an unsigned int */
@ -90,4 +93,3 @@ typedef unsigned int ino_t;
#define MAXPATHLEN 1024
#define MAXSYMLINKS 8

View file

@ -1,3 +1,4 @@
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
@ -73,7 +74,8 @@
#define DIRBLKSIZ DEV_BSIZE
#define MAXNAMLEN 255
struct direct {
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 */
@ -96,7 +98,8 @@ struct direct {
* Should use struct direct's, but the name field
* is MAXNAMLEN - 1, and this just won't do.
*/
struct dirtemplate {
struct dirtemplate
{
u_int dot_ino;
short dot_reclen;
short dot_namlen;
@ -120,12 +123,14 @@ struct dirtemplate {
/*
* Definitions for library routines operating on directories.
*/
typedef struct _dirdesc {
typedef struct _dirdesc
{
int dd_fd;
int dd_loc;
int dd_size;
char dd_buf[DIRBLKSIZ];
} DIR;
}
DIR;
#define dirfd(dirp) ((dirp)->dd_fd)

View file

@ -58,7 +58,8 @@
#define FFS_MAX_FASTLINK_SIZE ((FFS_NDADDR + FFS_NIADDR) * sizeof(daddr_t))
struct icommon {
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 */
@ -70,14 +71,18 @@ struct icommon {
int ic_mtspare;
time_t ic_ctime; /* 32: last time inode changed */
int ic_ctspare;
union {
struct {
union
{
struct
{
daddr_t Mb_db[FFS_NDADDR]; /* 40: disk block addresses */
daddr_t Mb_ib[FFS_NIADDR]; /* 88: indirect blocks */
} ic_Mb;
}
ic_Mb;
char ic_Msymlink[FFS_MAX_FASTLINK_SIZE];
/* 40: symbolic link name */
} ic_Mun;
}
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
@ -85,16 +90,20 @@ struct icommon {
int ic_blocks; /* 104: blocks actually held */
int ic_gen; /* 108: generation number */
int ic_spare[4]; /* 112: reserved, currently unused */
} i_ic;
}
i_ic;
/*
* Same structure, but on disk.
*/
struct dinode {
union {
struct dinode
{
union
{
struct icommon di_com;
char di_char[128];
} di_un;
}
di_un;
};
#define di_ic di_un.di_com

View file

@ -98,4 +98,4 @@
#define f_blkno u.ffs.ffs_blkno
#endif /* EEK */
#endif _BOOT_UFS_DISK_INODE_FFS_H_
#endif /* _BOOT_UFS_DISK_INODE_FFS_H_ */

View file

@ -549,7 +549,8 @@ static enum
PART_UNSPECIFIED = 0,
PART_DISK,
PART_CHOSEN,
} part_choice;
}
part_choice;
char *

View file

@ -111,4 +111,3 @@
(*((unsigned short *) (entry+26)))
#define FAT_DIRENTRY_FILELENGTH(entry) \
(*((unsigned long *) (entry+28)))

View file

@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@ -116,4 +117,3 @@ struct fsys_entry fsys_table[NUM_FSYS+1] =
};
#endif

View file

@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@ -71,7 +72,8 @@
* Flags are used to indicate the validity of fields where zero is a
* normal value.
*/
struct bootinfo {
struct bootinfo
{
unsigned int bi_version;
unsigned char *bi_kernelname;
struct nfs_diskless *bi_nfs_diskless;
@ -87,4 +89,3 @@ struct bootinfo {
unsigned long bi_symtab;
unsigned long bi_esymtab;
};

View file

@ -1,3 +1,4 @@
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
@ -131,7 +132,8 @@
* N.B. sizeof(struct csum) must be a power of two in order for
* the ``fs_cs'' macro to work (see below).
*/
struct csum {
struct csum
{
int cs_ndir; /* number of directories */
int cs_nbfree; /* number of free blocks */
int cs_nifree; /* number of free inodes */
@ -270,7 +272,8 @@ struct fs
* Cylinder group block for a file system.
*/
#define CG_MAGIC 0x090255
struct cg {
struct cg
{
int xxx1; /* struct cg *cg_link; */
int cg_magic; /* magic number */
time_t cg_time; /* time last written */
@ -318,7 +321,8 @@ struct cg {
* The following structure is defined
* for compatibility with old file systems.
*/
struct ocg {
struct ocg
{
int xxx1; /* struct ocg *cg_link; */
int xxx2; /* struct ocg *cg_rlink; */
time_t cg_time; /* time last written */
@ -452,4 +456,3 @@ struct ocg {
* NINDIR is the number of indirects in a file system block.
*/
#define NINDIR(fs) ((fs)->fs_nindir)

View file

@ -52,7 +52,8 @@ typedef unsigned int __u32;
#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
/* include/linux/ext2_fs.h */
struct ext2_super_block {
struct ext2_super_block
{
__u32 s_inodes_count; /* Inodes count */
__u32 s_blocks_count; /* Blocks count */
__u32 s_r_blocks_count; /* Reserved blocks count */
@ -93,7 +94,8 @@ struct ext2_group_desc
__u32 bg_reserved[3];
};
struct ext2_inode {
struct ext2_inode
{
__u16 i_mode; /* File mode */
__u16 i_uid; /* Owner Uid */
__u32 i_size; /* 4: Size in bytes */
@ -105,44 +107,60 @@ struct ext2_inode {
__u16 i_links_count; /* 24: Links count */
__u32 i_blocks; /* Blocks count */
__u32 i_flags; /* 32: File flags */
union {
struct {
union
{
struct
{
__u32 l_i_reserved1;
} linux1;
struct {
}
linux1;
struct
{
__u32 h_i_translator;
} hurd1;
struct {
}
hurd1;
struct
{
__u32 m_i_reserved1;
} masix1;
} osd1; /* OS dependent 1 */
}
masix1;
}
osd1; /* OS dependent 1 */
__u32 i_block[EXT2_N_BLOCKS]; /* 40: Pointers to blocks */
__u32 i_version; /* File version (for NFS) */
__u32 i_file_acl; /* File ACL */
__u32 i_dir_acl; /* Directory ACL */
__u32 i_faddr; /* Fragment address */
union {
struct {
union
{
struct
{
__u8 l_i_frag; /* Fragment number */
__u8 l_i_fsize; /* Fragment size */
__u16 i_pad1;
__u32 l_i_reserved2[2];
} linux2;
struct {
}
linux2;
struct
{
__u8 h_i_frag; /* Fragment number */
__u8 h_i_fsize; /* Fragment size */
__u16 h_i_mode_high;
__u16 h_i_uid_high;
__u16 h_i_gid_high;
__u32 h_i_author;
} hurd2;
struct {
}
hurd2;
struct
{
__u8 m_i_frag; /* Fragment number */
__u8 m_i_fsize; /* Fragment size */
__u16 m_pad1;
__u32 m_i_reserved2[2];
} masix2;
} osd2; /* OS dependent 2 */
}
masix2;
}
osd2; /* OS dependent 2 */
};
/* linux/limits.h */
@ -153,7 +171,8 @@ typedef long off_t;
/* linux/ext2fs.h */
#define EXT2_NAME_LEN 255
struct ext2_dir_entry {
struct ext2_dir_entry
{
__u32 inode; /* Inode number */
__u16 rec_len; /* Directory entry length */
__u16 name_len; /* Name length */
@ -219,7 +238,8 @@ struct ext2_dir_entry {
* ffz = Find First Zero in word. Undefined if no zero exists,
* so code should check against ~0UL first..
*/
__inline__ unsigned long ffz(unsigned long word)
__inline__ unsigned long
ffz (unsigned long word)
{
__asm__ ("bsfl %1,%0"
: "=r" (word)
@ -248,7 +268,8 @@ ext2fs_mount(void)
takes a file system block number and reads it into area pointed
to by buffer */
int
ext2_rdfsb (int fsblock, int buffer) {
ext2_rdfsb (int fsblock, int buffer)
{
#ifdef E2DEBUG
printf ("fsblock %d buffer %d\n", fsblock, buffer);
#endif /* E2DEBUG */
@ -270,17 +291,25 @@ ext2fs_block_map(int logical_block)
unsigned char *i;
for (i = (unsigned char *) INODE;
i < ((unsigned char *) INODE + sizeof (struct ext2_inode));
i++) {
i++)
{
printf ("%c", "0123456789abcdef"[*i >> 4]);
printf ("%c", "0123456789abcdef"[*i % 16]);
if (!((i + 1 - (unsigned char *)INODE) % 16)) { printf("\n"); }
else { printf(" "); }
if (!((i + 1 - (unsigned char *) INODE) % 16))
{
printf ("\n");
}
else
{
printf (" ");
}
}
printf ("logical block %d\n", logical_block);
#endif /* E2DEBUG */
/* if it is directly pointed to by the inode, return that physical addr */
if (logical_block < EXT2_NDIR_BLOCKS) {
if (logical_block < EXT2_NDIR_BLOCKS)
{
#ifdef E2DEBUG
printf ("returning %d\n", (unsigned char *) (INODE->i_block[logical_block]));
printf ("returning %d\n", INODE->i_block[logical_block]);
@ -290,9 +319,11 @@ ext2fs_block_map(int logical_block)
/* else */
logical_block -= EXT2_NDIR_BLOCKS;
/* try the indirect block */
if (logical_block < EXT2_ADDR_PER_BLOCK(SUPERBLOCK)) {
if (logical_block < EXT2_ADDR_PER_BLOCK (SUPERBLOCK))
{
if (mapblock1 != 1
&& !ext2_rdfsb(INODE->i_block[EXT2_IND_BLOCK], DATABLOCK1)) {
&& !ext2_rdfsb (INODE->i_block[EXT2_IND_BLOCK], DATABLOCK1))
{
errnum = ERR_FSYS_CORRUPT;
return -1;
}
@ -302,10 +333,12 @@ ext2fs_block_map(int logical_block)
/* else */
logical_block -= EXT2_ADDR_PER_BLOCK (SUPERBLOCK);
/* now try the double indirect block */
if (logical_block < (1 << (EXT2_ADDR_PER_BLOCK_BITS(SUPERBLOCK) * 2))) {
if (logical_block < (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2)))
{
int bnum;
if (mapblock1 != 2
&& !ext2_rdfsb(INODE->i_block[EXT2_DIND_BLOCK], DATABLOCK1)) {
&& !ext2_rdfsb (INODE->i_block[EXT2_DIND_BLOCK], DATABLOCK1))
{
errnum = ERR_FSYS_CORRUPT;
return -1;
}
@ -313,7 +346,8 @@ ext2fs_block_map(int logical_block)
if ((bnum = (((__u32 *) DATABLOCK1)
[logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)]))
!= mapblock2
&& !ext2_rdfsb(bnum, DATABLOCK2)) {
&& !ext2_rdfsb (bnum, DATABLOCK2))
{
errnum = ERR_FSYS_CORRUPT;
return -1;
}
@ -325,21 +359,25 @@ ext2fs_block_map(int logical_block)
mapblock2 = -1;
logical_block -= (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2));
if (mapblock1 != 3
&& !ext2_rdfsb(INODE->i_block[EXT2_TIND_BLOCK], DATABLOCK1)) {
&& !ext2_rdfsb (INODE->i_block[EXT2_TIND_BLOCK], DATABLOCK1))
{
errnum = ERR_FSYS_CORRUPT;
return -1;
}
mapblock1 = 3;
if (!ext2_rdfsb (((__u32 *) DATABLOCK1)
[logical_block >> (EXT2_ADDR_PER_BLOCK_BITS(SUPERBLOCK)*2)],
DATABLOCK2)) {
[logical_block >> (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)
* 2)],
DATABLOCK2))
{
errnum = ERR_FSYS_CORRUPT;
return -1;
}
if (!ext2_rdfsb (((__u32 *) DATABLOCK2)
[(logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK))
& (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)],
DATABLOCK2)) {
DATABLOCK2))
{
errnum = ERR_FSYS_CORRUPT;
return -1;
}
@ -362,14 +400,22 @@ ext2fs_read(int addr, int len)
unsigned char *i;
for (i = (unsigned char *) INODE;
i < ((unsigned char *) INODE + sizeof (struct ext2_inode));
i++) {
i++)
{
printf ("%c", hexdigit[*i >> 4]);
printf ("%c", hexdigit[*i % 16]);
if (!((i + 1 - (unsigned char *)INODE) % 16)) { printf("\n"); }
else { printf(" "); }
if (!((i + 1 - (unsigned char *) INODE) % 16))
{
printf ("\n");
}
else
{
printf (" ");
}
}
#endif /* E2DEBUG */
while(len > 0) {
while (len > 0)
{
/* find the (logical) block component of our location */
logical_block = filepos >> EXT2_BLOCK_SIZE_BITS (SUPERBLOCK);
offset = filepos & (EXT2_BLOCK_SIZE (SUPERBLOCK) - 1);
@ -465,7 +511,7 @@ ext2fs_dir(char *dirname)
struct ext2_dir_entry *dp; /* pointer to directory entry */
#ifdef E2DEBUG
unsigned char *i;
#endif E2DEBUG
#endif /* E2DEBUG */
/* loop invariants:
current_ino = inode to lookup
@ -473,7 +519,8 @@ ext2fs_dir(char *dirname)
the directory known pointed to by current_ino (if any)
*/
while (1) {
while (1)
{
#ifdef E2DEBUG
printf ("inode %d\n", current_ino);
printf ("dirname=%s\n", dirname);
@ -490,7 +537,8 @@ ext2fs_dir(char *dirname)
#endif /* E2DEBUG */
if (!ext2_rdfsb (
(WHICH_SUPER + group_desc + SUPERBLOCK->s_first_data_block),
(int)GROUP_DESC)) {
(int) GROUP_DESC))
{
return 0;
}
gdp = GROUP_DESC;
@ -500,7 +548,8 @@ ext2fs_dir(char *dirname)
#ifdef E2DEBUG
printf ("inode table fsblock=%d\n", ino_blk);
#endif /* E2DEBUG */
if (!ext2_rdfsb(ino_blk, (int)INODE)) {
if (!ext2_rdfsb (ino_blk, (int) INODE))
{
return 0;
}
@ -516,11 +565,19 @@ ext2fs_dir(char *dirname)
sizeof (struct ext2_inode));
printf ("inode=%x, raw_inode=%x\n", INODE, raw_inode);
printf ("offset into inode table block=%d\n", (int) raw_inode - (int) INODE);
for (i = (unsigned char *)INODE; i <= (unsigned char *)raw_inode; i++) {
for (i = (unsigned char *) INODE; i <= (unsigned char *) raw_inode;
i++)
{
printf ("%c", "0123456789abcdef"[*i >> 4]);
printf ("%c", "0123456789abcdef"[*i % 16]);
if (!((i + 1 - (unsigned char *)INODE) % 16)) { printf("\n"); }
else { printf(" "); }
if (!((i + 1 - (unsigned char *) INODE) % 16))
{
printf ("\n");
}
else
{
printf (" ");
}
}
printf ("first word=%x\n", *((int *) raw_inode));
#endif /* E2DEBUG */
@ -628,14 +685,16 @@ ext2fs_dir(char *dirname)
}
/* skip to next slash or end of filename (space) */
for (rest = dirname; (ch = *rest) && !isspace(ch) && ch != '/'; rest++) ;
for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/';
rest++);
/* look through this directory and find the next filename component */
/* invariant: rest points to slash after the next filename component */
*rest = 0;
loc = 0;
do {
do
{
#ifdef E2DEBUG
printf ("dirname=%s, rest=%s, loc=%d\n", dirname, rest, loc);
@ -643,11 +702,14 @@ ext2fs_dir(char *dirname)
/* if our location/byte offset into the directory exceeds the size,
give up */
if (loc >= INODE->i_size) {
if (print_possibilities < 0) {
if (loc >= INODE->i_size)
{
if (print_possibilities < 0)
{
putchar ('\n');
}
else {
else
{
errnum = ERR_FILE_NOT_FOUND;
*rest = ch;
}
@ -665,7 +727,8 @@ ext2fs_dir(char *dirname)
printf ("fs block=%d\n", map);
#endif /* E2DEBUG */
mapblock2 = -1;
if ((map < 0) || !ext2_rdfsb(map, DATABLOCK2)) {
if ((map < 0) || !ext2_rdfsb (map, DATABLOCK2))
{
errnum = ERR_FSYS_CORRUPT;
*rest = ch;
return 0;
@ -701,7 +764,8 @@ ext2fs_dir(char *dirname)
dp->name[dp->name_len] = saved_c;
}
} while (!dp->inode || (str_chk || (print_possibilities && ch != '/')) );
}
while (!dp->inode || (str_chk || (print_possibilities && ch != '/')));
current_ino = dp->inode;
*(dirname = rest) = ch;

View file

@ -82,7 +82,8 @@ fat_create_blocklist(int first_fat_entry)
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;

View file

@ -327,13 +327,16 @@ gunzip_test_header(void)
the next table, which codes e - 16 bits, and lastly e == 99 indicates
an unused code. If a code with e == 99 is looked up, this implies an
error in the data. */
struct huft {
struct huft
{
uch e; /* number of extra bits or operation */
uch b; /* number of bits in this code or subcode */
union {
union
{
ush n; /* literal, length base, or distance base */
struct huft *t; /* pointer to next level of table */
} v;
}
v;
};
@ -355,20 +358,25 @@ static unsigned wp;
/* Tables for deflate from PKZIP's appnote.txt. */
static unsigned border[] = { /* Order of the bit length code lengths */
static unsigned border[] =
{ /* Order of the bit length code lengths */
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
static ush cplens[] = { /* Copy lengths for literal codes 257..285 */
static ush cplens[] =
{ /* Copy lengths for literal codes 257..285 */
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
/* note: see note #13 above about the 258 in this list. */
static ush cplext[] = { /* Extra bits for literal codes 257..285 */
static ush cplext[] =
{ /* Extra bits for literal codes 257..285 */
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */
static ush cpdist[] = { /* Copy offsets for distance codes 0..29 */
static ush cpdist[] =
{ /* Copy offsets for distance codes 0..29 */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577};
static ush cpdext[] = { /* Extra bits for distance codes */
static ush cpdext[] =
{ /* Extra bits for distance codes */
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 13, 13};
@ -452,7 +460,8 @@ static unsigned hufts; /* track memory usage */
static ulg bb; /* bit buffer */
static unsigned bk; /* bits in bit buffer */
static ush mask_bits[] = {
static ush mask_bits[] =
{
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
@ -528,11 +537,14 @@ huft_build(unsigned *b, /* code lengths in bits (all assumed <= BMAX) */
/* Generate counts for each bit length */
bzero ((char *) c, sizeof (c));
p = b; i = n;
do {
p = b;
i = n;
do
{
c[*p]++; /* assume all entries <= BMAX */
p++; /* Can't combine with above line (Solaris bug) */
} while (--i);
}
while (--i);
if (c[0] == n) /* null input--all zero length codes */
{
*t = (struct huft *) NULL;
@ -566,17 +578,22 @@ huft_build(unsigned *b, /* code lengths in bits (all assumed <= BMAX) */
/* Generate starting offsets into the value table for each length */
x[1] = j = 0;
p = c + 1; xp = x + 2;
while (--i) { /* note that i == g from above */
p = c + 1;
xp = x + 2;
while (--i)
{ /* note that i == g from above */
*xp++ = (j += *p++);
}
/* Make a table of values in order of bit lengths */
p = b; i = 0;
do {
p = b;
i = 0;
do
{
if ((j = *p++) != 0)
v[x[j]++] = i;
} while (++i < n);
}
while (++i < n);
/* Generate the Huffman codes and for each, make the table entries */
x[0] = i = 0; /* first Huffman code is zero */
@ -709,7 +726,8 @@ inflate_codes_in_window(void)
{
NEEDBITS ((unsigned) bl);
if ((e = (t = tl + ((unsigned) b & ml))->e) > 16)
do {
do
{
if (e == 99)
{
errnum = ERR_BAD_GZIP_DATA;
@ -718,7 +736,8 @@ inflate_codes_in_window(void)
DUMPBITS (t->b);
e -= 16;
NEEDBITS (e);
} while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16);
}
while ((e = (t = t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
DUMPBITS (t->b);
if (e == 16) /* then it's a literal */
@ -727,7 +746,8 @@ inflate_codes_in_window(void)
if (w == WSIZE)
break;
}
else /* it's an EOB or a length */
else
/* it's an EOB or a length */
{
/* exit if end of block */
if (e == 15)
@ -744,7 +764,8 @@ inflate_codes_in_window(void)
/* decode distance of block to copy */
NEEDBITS ((unsigned) bd);
if ((e = (t = td + ((unsigned) b & md))->e) > 16)
do {
do
{
if (e == 99)
{
errnum = ERR_BAD_GZIP_DATA;
@ -753,7 +774,9 @@ inflate_codes_in_window(void)
DUMPBITS (t->b);
e -= 16;
NEEDBITS (e);
} while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16);
}
while ((e = (t = t->v.t + ((unsigned) b & mask_bits[e]))->e)
> 16);
DUMPBITS (t->b);
NEEDBITS (e);
d = w - t->v.n - ((unsigned) b & mask_bits[e]);
@ -765,22 +788,26 @@ inflate_codes_in_window(void)
if (code_state)
{
/* do the copy */
do {
n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e);
do
{
n -= (e = (e = WSIZE - ((d &= WSIZE - 1) > w ? d : w)) > n ? n
: e);
if (w - d >= e)
{
bcopy (slide + d, slide + w, e);
w += e;
d += e;
}
else /* purposefully use the overlap for extra copies here!! */
else
/* purposefully use the overlap for extra copies here!! */
{
while (e--)
slide[w++] = slide[d++];
}
if (w == WSIZE)
break;
} while (n);
}
while (n);
if (!n)
code_state--;
@ -968,7 +995,8 @@ init_dynamic_block(void)
ll[i++] = 0;
l = 0;
}
else /* j == 18: 11 to 138 zero length codes */
else
/* j == 18: 11 to 138 zero length codes */
{
NEEDBITS (7);
j = 11 + ((unsigned) b & 0x7f);
@ -1191,4 +1219,3 @@ gunzip_read(int addr, int len)
return ret;
}

View file

@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@ -27,7 +28,8 @@ typedef unsigned long Elf32_Word;
/* "unsigned char" already exists */
/* ELF header */
typedef struct {
typedef struct
{
#define EI_NIDENT 16
@ -78,7 +80,8 @@ typedef struct {
#define SHN_COMMON 0xfff2
#define SHN_HIRESERVE 0xffff
Elf32_Half e_shstrndx; /* section header table index */
} Elf32_Ehdr;
}
Elf32_Ehdr;
#define BOOTABLE_I386_ELF(h) \
@ -98,7 +101,8 @@ typedef struct
unsigned char st_info;
unsigned char st_other;
Elf32_Half st_shndx;
} Elf32_Sym;
}
Elf32_Sym;
/* symbol type and binding attributes - page 4-26 */
@ -134,7 +138,8 @@ typedef struct
/* program header - page 5-2, figure 5-1 */
typedef struct {
typedef struct
{
Elf32_Word p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
@ -143,7 +148,8 @@ typedef struct {
Elf32_Word p_memsz;
Elf32_Word p_flags;
Elf32_Word p_align;
} Elf32_Phdr;
}
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 {
typedef struct
{
Elf32_Sword d_tag;
union {
union
{
Elf32_Word d_val;
Elf32_Addr d_ptr;
} d_un;
} Elf32_Dyn;
}
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

View file

@ -1,3 +1,4 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@ -117,7 +118,8 @@
* N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
*/
struct exec {
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 */

View file

@ -76,4 +76,3 @@ struct multiboot_header
/* This flag indicates the use of the other fields in the header. */
#define MULTIBOOT_AOUT_KLUDGE 0x00010000

View file

@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@ -93,7 +94,8 @@ struct multiboot_info
unsigned long strsize;
unsigned long addr;
unsigned long pad;
} a;
}
a;
struct
{
@ -102,8 +104,10 @@ struct multiboot_info
unsigned long size;
unsigned long addr;
unsigned long shndx;
} e;
} syms;
}
e;
}
syms;
/* Memory Mapping buffer */
unsigned long mmap_length;
@ -138,4 +142,3 @@ struct multiboot_info
*/
#define MULTIBOOT_VALID 0x2BADB002

View file

@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@ -199,4 +200,3 @@
#endif /* _PC_SLICE_H */

View file

@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@ -201,7 +202,9 @@ outb(unsigned short port, unsigned char val)
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)
@ -316,7 +319,8 @@ int special_attribute;
#endif /* _CHAR_IO_C */
enum grub_error_t {
enum grub_error_t
{
ERR_NONE = 0,
ERR_BAD_FILENAME,
ERR_BAD_FILETYPE,

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 {
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} }
}
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
}
}
};
/*
@ -122,7 +208,8 @@ get_checksum(unsigned start, int length)
{
unsigned sum = 0;
while (length-- > 0) {
while (length-- > 0)
{
sum += *((unsigned char *) (start++));
}
@ -158,7 +245,8 @@ boot_cpu(imps_processor *proc)
*((volatile unsigned *) bios_reset_vector) = bootaddr << 12;
/* clear the error register */
if (proc->apic_ver & 0x10) {
if (proc->apic_ver & 0x10)
{
IMPS_LAPIC_WRITE (LAPIC_ESR, 0);
accept_status = IMPS_LAPIC_READ (LAPIC_ESR);
}
@ -201,20 +289,24 @@ add_processor(imps_processor *proc)
KERNEL_PRINT ((" Processor [APIC id %d ver %d]: ",
apicid, proc->apic_ver));
if (!(proc->flags & IMPS_FLAG_ENABLED)) {
if (!(proc->flags & IMPS_FLAG_ENABLED))
{
KERNEL_PRINT (("DISABLED\n"));
return;
}
if (proc->apic_ver > 0xF) {
if (proc->apic_ver > 0xF)
{
imps_any_new_apics = 1;
}
if (proc->flags & (IMPS_CPUFLAG_BOOT)) {
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)) {
if (boot_cpu (proc))
{
/* XXXXX add OS-specific setup for secondary CPUs here */
@ -241,7 +333,8 @@ 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)) {
if (!(ioapic->flags & IMPS_FLAG_ENABLED))
{
KERNEL_PRINT (("DISABLED\n"));
return;
}
@ -254,8 +347,10 @@ add_ioapic(imps_ioapic *ioapic)
static void
imps_read_config_table (unsigned start, int count)
{
while (count-- > 0) {
switch (*((unsigned char *)start)) {
while (count-- > 0)
{
switch (*((unsigned char *) start))
{
case IMPS_BCT_PROCESSOR:
add_processor ((imps_processor *) start);
start += 12; /* 20 total */
@ -290,34 +385,45 @@ imps_bad_bios(imps_fps *fps_ptr)
imps_cth *local_cth_ptr
= (imps_cth *) PHYS_TO_VIRTUAL (fps_ptr->cth_ptr);
if (fps_ptr->feature_info[0] > IMPS_FPS_DEFAULT_MAX) {
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) {
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));
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) {
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) {
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));
if (sum)
{
KERNEL_PRINT
((" Bad Extended MP Config Table checksum 0x%x\n", sum));
return 1;
}
}
} else if (!fps_ptr->feature_info[0]) {
}
else if (!fps_ptr->feature_info[0])
{
KERNEL_PRINT ((" Missing configuration information\n"));
return 1;
}
@ -343,22 +449,30 @@ imps_read_bios(imps_fps *fps_ptr)
* lead to failure of the SMP boot here.
*/
if (imps_bad_bios(fps_ptr)) {
if (imps_bad_bios (fps_ptr))
{
KERNEL_PRINT ((" Disabling MPS support\n"));
return;
}
if (fps_ptr->feature_info[1] & IMPS_FPS_IMCRP_BIT) {
if (fps_ptr->feature_info[1] & IMPS_FPS_IMCRP_BIT)
{
str_ptr = "IMCR and PIC";
} else {
}
else
{
str_ptr = "Virtual Wire";
}
if (fps_ptr->cth_ptr) {
if (fps_ptr->cth_ptr)
{
imps_lapic_addr = local_cth_ptr->lapic_addr;
} else {
}
else
{
imps_lapic_addr = LAPIC_ADDR_DEFAULT;
}
KERNEL_PRINT((" APIC config: \"%s mode\" Local APIC address: 0x%x\n",
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);
@ -372,7 +486,8 @@ imps_read_bios(imps_fps *fps_ptr)
imps_cpu_apic_map[0] = apicid;
imps_apic_cpu_map[apicid] = 0;
if (fps_ptr->cth_ptr) {
if (fps_ptr->cth_ptr)
{
char str1[16], str2[16];
bcopy (local_cth_ptr->oem_id, str1, 8);
str1[8] = 0;
@ -381,7 +496,9 @@ imps_read_bios(imps_fps *fps_ptr)
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 {
}
else
{
*((volatile unsigned *) IOAPIC_ADDR_DEFAULT) = IOAPIC_ID;
defconfig.ioapic.id
= IMPS_APIC_ID (*((volatile unsigned *)
@ -395,23 +512,28 @@ imps_read_bios(imps_fps *fps_ptr)
defconfig.proc[!apicid].flags = IMPS_FLAG_ENABLED;
imps_num_cpus = 2;
if (fps_ptr->feature_info[0] == 1
|| fps_ptr->feature_info[0] == 5) {
|| 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) {
|| fps_ptr->feature_info[0] == 7)
{
bcopy ("MCA ", defconfig.bus[0].bus_type, 6);
}
if (fps_ptr->feature_info[0] > 4) {
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) {
if (fps_ptr->feature_info[0] == 2)
{
defconfig.intin[2].type = 255;
defconfig.intin[13].type = 255;
}
if (fps_ptr->feature_info[0] == 7) {
if (fps_ptr->feature_info[0] == 7)
{
defconfig.intin[0].type = 255;
}
cth_start = (unsigned) &defconfig;
@ -446,13 +568,15 @@ imps_scan(unsigned start, unsigned length)
IMPS_DEBUG_PRINT (("Scanning from 0x%x for %d bytes\n",
start, length));
while (length > 0) {
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)) {
&& !get_checksum (start, 16))
{
IMPS_DEBUG_PRINT (("Found MP Floating Structure Pointer at %x\n", start));
imps_read_bios (fps_ptr);
return 1;
@ -524,19 +648,22 @@ imps_probe(void)
* 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) {
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) {
* 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) {
|| imps_scan (0xF0000, 0x10000)) && imps_enabled)
{
return 1;
}
@ -546,4 +673,3 @@ imps_probe(void)
return 0;
}

View file

@ -236,4 +236,3 @@ int imps_probe(void);
(*((volatile unsigned *) (imps_lapic_addr+(x))) = (y))
#endif /* !_SMP_IMPS_H */

View file

@ -1,3 +1,4 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@ -39,4 +40,3 @@ cmain(void)
stop ();
}

View file

@ -112,21 +112,22 @@ after_BPB:
/* save drive reference first thing! */
pushw %dx
/*
* Jump to floppy probe instead of the hard disk probe ?
*/
movb %dl, %al
andb $BIOS_HD_FLAG, %al
jz floppy_probe
/*
* Determine the hard disk geometry from the BIOS!
* We do this first, so that LS-120 IDE floppies work correctly.
*/
movb $8, %ah
int $0x13
jnc final_init
/* if BIOS geometry call fails, display error and die! */
jc hd_probe_error
/*
* The call failed, so maybe use the floppy probe instead.
*/
andb $BIOS_HD_FLAG, %dl
jz floppy_probe
/* Nope, we definitely have a hard disk, and we're screwed. */
jmp hd_probe_error
final_init:
/* save number of heads */