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