add OpenBSD support, add some explanations into the manual.

This commit is contained in:
okuji 1999-11-01 13:07:53 +00:00
parent 0612bf14c0
commit 8fb66b3a69
8 changed files with 78 additions and 10 deletions

View file

@ -1,3 +1,24 @@
1999-11-01 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
* docs/grub.texi: Add "I/O ports detection" into the menu.
* docs/user-ref.texi: Added a description about the command
"ioprobe".
* docs/prog-ref.texi (I/O ports detection): New chapter.
1999-11-01 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
From Pavel Roskin:
* stage2/asm.S (int1_handler): Use EXT_C(io_map) instead of
io_map.
(int1_handler): Use EXT_C(bios_key_map) instead of bios_key_map.
* grub/asmstub.c [__OpenBSD__]: Include <sys/ioctl.h> and
<sys/disklabel.h>.
[__OpenBSD__] (get_floppy_disk_name): Added support for OpenBSD.
[__OpenBSD__] (get_ide_disk_name): Likewise.
[__OpenBSD__] (get_scsi_disk_name): Likewise.
(get_drive_geometry) [__OpenBSD__]: Use for OpenBSD the same
ioctl as for NetBSD and FreeBSD.
1999-10-31 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
* grub/asmstub.c (init_device_map): Add a floppy device name

1
NEWS
View file

@ -23,6 +23,7 @@ New in 0.5.94:
appendices.
* The command "ioprobe" detects what I/O ports are used for a BIOS
drive.
* OpenBSD support in the grub shell is improved.
New in 0.5.93:
* ELF format of FreeBSD kernel is supported.

6
TODO
View file

@ -15,19 +15,17 @@ Priorities:
* Add configuration inclusion support by adding a command "include". !
* Make symbolic links work for BSD FFS. !
* Make symbolic links work for BSD FFS. !!
* Add indirect block support to the BSD FFS filesystem code, so files
larger than 16MB can be read. !
* Fix-up FreeBSD, NetBSD (and OpenBSD ?) command-line boot
parameters. !!
parameters. !!!
* Support embedding a Stage 1.5 in the "bootloader" area of a FFS
partition. !!!
* Clean up and enhance the manuals, especially indices. !!!
* Complete the netboot support. !
* Add automatic configuration support.

View file

@ -114,6 +114,7 @@ Part III: The Programmer Reference Manual
* Embedded data:: Embedded variables in GRUB
* Filesystem interface:: The generic interface for the fs code
* Bootstrap tricks:: The bootstrap mechanism used in GRUB
* I/O ports detection:: INT 13H tracking technique
* Memory detection:: How to detect all installed @sc{ram}
* Low-level disk I/O:: INT 13H disk I/O interrupts
* MBR:: The structure of Master Boot Record

View file

@ -339,6 +339,38 @@ or the accessing mode of the @dfn{loading drive}, since @dfn{stage1} has
already probed them.
@node I/O ports detection
@chapter How to detect I/O ports used for a BIOS drive
In the @sc{pc} world, BIOS cannot detect if a hard disk drive is SCSI or
IDE, generally speaking. Thus, it is not trivial to know which BIOS
drive corresponds to an OS device. So the Multiboot Specification
describes some techniques on how to guess mappings (@pxref{BIOS device
mapping techniques, Multiboot Specification, BIOS device mapping
techniques, multiboot, The Multiboot Specification}).
However, the techniques decribed are unreliable or difficult to be
implemented, so we use a different technique from them in GRUB. Our
technique is @dfn{INT 13H tracking technique}. More precisely, it runs
the INT 13 call (@pxref{Low-level disk I/O}) in single-step mode just
like a debugger and parses the instructions.
To execute the call one instruction at a time, set the TF (trap flag)
flag in the register @dfn{FLAGS}. By this, your CPU generates @dfn{Break
Point Trap} after each instruction is executed and call INT 1. In the
stack in the interrupt handler, callee's FLAGS and the far pointer which
points to the next instruction to be executed are pushed, so we can know
what instruction will be executed in the next time and the current
contents of all the registers. If the next instruction is an I/O
operation, the interrupt handler adds the I/O port into the @dfn{I/O
map}.
If the INT 13 handler returns, the TF flag is cleared automatically by
the instruction @code{iret}, and then output the I/O map on the screen.
See the source code for the command @command{ioprobe}
(@pxref{Command-line-specific commands}), for more information.
@node Memory detection
@chapter How to detect all installed @sc{ram}

View file

@ -854,6 +854,12 @@ time. This command preserves the DOS BPB (and for hard disks, the
partition table) of the sector the Stage 1 is to be installed into.
@end deffn
@deffn Command ioprobe drive
Probe I/O ports used for the drive @var{drive}. This command will list
the I/O ports on the screen. For technical information, @xref{I/O ports
detection}.
@end deffn
@deffn Command kernel file @dots{}
Attempt to load the primary boot image (Multiboot a.out or @sc{elf},
Linux zImage or bzImage, FreeBSD a.out, NetBSD a.out, etc.) from

View file

@ -58,10 +58,10 @@ int grub_stage2 (void);
# endif /* ! BLKFLSBUF */
#endif /* __linux__ */
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# include <sys/ioctl.h> /* ioctl */
# include <sys/disklabel.h>
#endif /* __FreeBSD__ || __NetBSD__ */
#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */
#ifdef HAVE_OPENDISK
# include <util.h>
@ -405,6 +405,9 @@ get_floppy_disk_name (char *name, int unit)
/* NetBSD */
/* opendisk() doesn't work for floppies. */
sprintf (name, "/dev/rfd%da", unit);
#elif defined(__OpenBSD__)
/* OpenBSD */
sprintf (name, "/dev/rfd%dc", unit);
#else
# warning "BIOS floppy drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */
@ -435,6 +438,9 @@ get_ide_disk_name (char *name, int unit)
0 /* char device */
);
close (fd);
#elif defined(__OpenBSD__)
/* OpenBSD */
sprintf (name, "/dev/rwd%dc", unit);
#else
# warning "BIOS IDE drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */
@ -465,6 +471,9 @@ get_scsi_disk_name (char *name, int unit)
0 /* char device */
);
close (fd);
#elif defined(__OpenBSD__)
/* OpenBSD */
sprintf (name, "/dev/rsd%dc", unit);
#else
# warning "BIOS SCSI drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */
@ -841,7 +850,7 @@ get_drive_geometry (int drive)
geom->total_sectors = hdg.cylinders * hdg.heads * hdg.sectors;
return 1;
#elif defined(__FreeBSD__) || defined(__NetBSD__)
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
/* FreeBSD */
struct disklabel hdg;
if (ioctl (disks[drive].flags, DIOCGDINFO, &hdg))

View file

@ -331,7 +331,7 @@ int1_handler:
movw %ax, %ds
/* set %si to the io map */
movw $ABS(io_map), %si
movw $ABS(EXT_C(io_map)), %si
9: /* check if the io map already has the port */
@ -346,7 +346,7 @@ int1_handler:
jmp 8f
1: /* check for the buffer overrun */
cmpw $(ABS(io_map) + (IO_MAP_SIZE + 1) * 2), %si
cmpw $(ABS(EXT_C(io_map)) + (IO_MAP_SIZE + 1) * 2), %si
je 8f
/* add the port into the io map */
movw %dx, -2(%si)
@ -490,7 +490,7 @@ int15_skip_flag:
xorw %ax, %ax
movw %ax, %ds
/* set %si to the key map */
movw $ABS(bios_key_map), %si
movw $ABS(EXT_C(bios_key_map)), %si
/* find the key code from the key map */
2: