diff --git a/ChangeLog b/ChangeLog index 5a1430517..2d822b4f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +1999-11-01 OKUJI Yoshinori + + * 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 + + 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 and + . + [__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 * grub/asmstub.c (init_device_map): Add a floppy device name diff --git a/NEWS b/NEWS index c15b9326f..f862393a3 100644 --- a/NEWS +++ b/NEWS @@ -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. diff --git a/TODO b/TODO index 9bd4bc178..7899040b0 100644 --- a/TODO +++ b/TODO @@ -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. diff --git a/docs/grub.texi b/docs/grub.texi index db71fe1f7..65d1e3c29 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -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 diff --git a/docs/prog-ref.texi b/docs/prog-ref.texi index 5f51dc549..2609803d7 100644 --- a/docs/prog-ref.texi +++ b/docs/prog-ref.texi @@ -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} diff --git a/docs/user-ref.texi b/docs/user-ref.texi index 6e11e216b..4560f7628 100644 --- a/docs/user-ref.texi +++ b/docs/user-ref.texi @@ -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 diff --git a/grub/asmstub.c b/grub/asmstub.c index e5aab9638..9998e6b2b 100644 --- a/grub/asmstub.c +++ b/grub/asmstub.c @@ -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 /* ioctl */ # include -#endif /* __FreeBSD__ || __NetBSD__ */ +#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */ #ifdef HAVE_OPENDISK # include @@ -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)) diff --git a/stage2/asm.S b/stage2/asm.S index 86ec4fdbe..ac5a1c38f 100644 --- a/stage2/asm.S +++ b/stage2/asm.S @@ -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: