improve FreeBSD support in the grub shell.

This commit is contained in:
okuji 1999-09-14 09:05:57 +00:00
parent be514997d2
commit 47ba3d654e
4 changed files with 102 additions and 45 deletions

View file

@ -1,3 +1,17 @@
1999-09-14 Pavel Roskin <pavel_roskin@geocities.com>
* grub/asmstub.c [__linux__]: On GLibc 2.0 and newer use lseek,
don't include <linux/fs.h> and define BLKFLSBUF if needed.
1999-09-14 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
Now the grub shell works fine on FreeBSD. A patch by Pavel
Roskin is modified and applied.
* grub/asmstub.c (get_drive_geometry): New function.
(get_diskinfo): Use get_drive_geometry to set the geometry of
DRIVE.
1999-09-14 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp> 1999-09-14 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
* configure.in (--enable-ne): Made the description more clear. * configure.in (--enable-ne): Made the description more clear.

1
NEWS
View file

@ -23,6 +23,7 @@ New in 0.5.93:
no floppy, and the option `--probe-second-floppy' enables the probe of no floppy, and the option `--probe-second-floppy' enables the probe of
the second floppy drive. the second floppy drive.
* Integrated the netboot support in the Dresden version of GRUB. * Integrated the netboot support in the Dresden version of GRUB.
* FreeBSD support in the grub shell is improved.
New in 0.5.92 - 1999-07-26: New in 0.5.92 - 1999-07-26:
* Bug fixes (i.e. Stage 1.5 can work fine again). * Bug fixes (i.e. Stage 1.5 can work fine again).

2
README
View file

@ -74,7 +74,7 @@ Just hit enter when CVS prompts you for a password.
in the stage1, then be sure your blocklist is big enough. The in the stage1, then be sure your blocklist is big enough. The
automated install will generally do this for you, it's just when 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 dropping it on a raw floppy, you get the default compiled in, which
is 512 * 110 disk sectors, or 56320 bytes. is 512 * 130 disk sectors, or 66560 bytes.
- For the FFS stage1.5, if you want to fit into the "bootloader" area - 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, of an FFS partition, it cannot be larger than 512 * 14 disk sectors,

View file

@ -47,11 +47,20 @@ int grub_stage2 (void);
#ifdef __linux__ #ifdef __linux__
# include <sys/ioctl.h> /* ioctl */ # include <sys/ioctl.h> /* ioctl */
# include <linux/hdreg.h> /* HDIO_GETGEO */ # include <linux/hdreg.h> /* HDIO_GETGEO */
/* FIXME: only include if libc doesn't have large file support. */ # if __GLIBC__ < 2
# include <linux/unistd.h> /* _llseek */ /* Maybe libc doesn't have large file support. */
# include <linux/fs.h> /* BLKFLSBUF */ # include <linux/unistd.h> /* _llseek */
# include <linux/fs.h> /* BLKFLSBUF */
# endif /* GLIBC < 2 */
# ifndef BLKFLSBUF
# define BLKFLSBUF _IO (0x12,97)
# endif /* ! BLKFLSBUF */
#endif /* __linux__ */ #endif /* __linux__ */
#ifdef __FreeBSD__
# include <sys/disklabel.h>
#endif /* __FreeBSD__ */
/* Simulated memory sizes. */ /* Simulated memory sizes. */
#define EXTENDED_MEMSIZE (4 * 1024 * 1024) /* 4MB */ #define EXTENDED_MEMSIZE (4 * 1024 * 1024) /* 4MB */
#define CONVENTIONAL_MEMSIZE (640) /* 640kB */ #define CONVENTIONAL_MEMSIZE (640) /* 640kB */
@ -261,6 +270,9 @@ get_floppy_disk_name (char *name, int unit)
#if defined(__linux__) || defined(__GNU__) #if defined(__linux__) || defined(__GNU__)
/* GNU/Linux and GNU/Hurd */ /* GNU/Linux and GNU/Hurd */
sprintf (name, "/dev/fd%d", unit); sprintf (name, "/dev/fd%d", unit);
#elif defined(__FreeBSD__)
/* FreeBSD */
sprintf (name, "/dev/rfd%d", unit);
#else #else
# warning "BIOS drives cannot be guessed in your operating system." # warning "BIOS drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */ /* Set NAME to a bogus string. */
@ -277,6 +289,9 @@ get_ide_disk_name (char *name, int unit)
#elif defined(__GNU__) #elif defined(__GNU__)
/* GNU/Hurd */ /* GNU/Hurd */
sprintf (name, "/dev/hd%d", unit); sprintf (name, "/dev/hd%d", unit);
#elif defined(__FreeBSD__)
/* FreeBSD */
sprintf (name, "/dev/rwd%d", unit);
#else #else
# warning "BIOS drives cannot be guessed in your operating system." # warning "BIOS drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */ /* Set NAME to a bogus string. */
@ -293,6 +308,9 @@ get_scsi_disk_name (char *name, int unit)
#elif defined(__GNU__) #elif defined(__GNU__)
/* GNU/Hurd */ /* GNU/Hurd */
sprintf (name, "/dev/sd%d", unit); sprintf (name, "/dev/sd%d", unit);
#elif defined(__FreeBSD__)
/* FreeBSD */
sprintf (name, "/dev/rda%d", unit);
#else #else
# warning "BIOS drives cannot be guessed in your operating system." # warning "BIOS drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */ /* Set NAME to a bogus string. */
@ -621,6 +639,47 @@ set_attrib (int attr)
} }
/* Get the geometry of a drive DRIVE. If an error occurs, return zero,
otherwise non-zero. */
static int
get_drive_geometry (int drive)
{
struct geometry *geom = &disks[drive];
#if defined(__linux__)
/* Linux */
struct hd_geometry hdg;
if (ioctl (geom->flags, HDIO_GETGEO, &hdg))
return 0;
/* Got the geometry, so save it. */
geom->cylinders = hdg.cylinders;
geom->heads = hdg.heads;
geom->sectors = hdg.sectors;
/* FIXME: Should get the real number of sectors. */
geom->total_sectors = hdg.cylinders * hdg.heads * hdg.sectors;
return 1;
#elif defined(__FreeBSD__)
/* FreeBSD */
struct disklabel hdg;
if (ioctl (disks[drive].flags, DIOCGDINFO, &hdg))
return 0;
disks[drive].cylinders = hdg.d_ncylinders;
disks[drive].heads = hdg.d_ntracks;
disks[drive].sectors = hdg.d_nsectors;
disks[drive].total_sectors = hdg.d_secperunit;
return 1;
#else
# warning "In your operating system, automatic detection of geometries \
will not be performed."
return 0;
#endif
}
/* Low-level disk I/O. Our stubbed version just returns a file /* Low-level disk I/O. Our stubbed version just returns a file
descriptor, not the actual geometry. */ descriptor, not the actual geometry. */
int int
@ -671,46 +730,29 @@ get_diskinfo (int drive, struct geometry *geometry)
if (disks[drive].flags != -1) if (disks[drive].flags != -1)
{ {
#ifdef __linux__ if (! get_drive_geometry (drive))
struct hd_geometry hdg;
if (! ioctl (disks[drive].flags, HDIO_GETGEO, &hdg))
{ {
/* Got the geometry, so save it. */ /* Set some arbitrary defaults. */
disks[drive].cylinders = hdg.cylinders; if (drive & 0x80)
disks[drive].heads = hdg.heads; {
disks[drive].sectors = hdg.sectors; /* Hard drive. */
/* FIXME: Should get the real number of sectors. */ disks[drive].cylinders = DEFAULT_HD_CYLINDERS;
disks[drive].total_sectors = (hdg.cylinders disks[drive].heads = DEFAULT_HD_HEADS;
* hdg.heads disks[drive].sectors = DEFAULT_HD_SECTORS;
* hdg.sectors); disks[drive].total_sectors = (DEFAULT_HD_CYLINDERS
} * DEFAULT_HD_HEADS
else * DEFAULT_HD_SECTORS);
/* FIXME: should have some other alternatives before using }
arbitrary defaults. */ else
#else {
# warning "In your operating system, automatic detection of geometries \ /* Floppy. */
will not be performed." disks[drive].cylinders = DEFAULT_FD_CYLINDERS;
#endif disks[drive].heads = DEFAULT_FD_HEADS;
/* Set some arbitrary defaults. */ disks[drive].sectors = DEFAULT_FD_SECTORS;
if (drive & 0x80) disks[drive].total_sectors = (DEFAULT_FD_CYLINDERS
{ * DEFAULT_FD_HEADS
/* Hard drive. */ * DEFAULT_FD_SECTORS);
disks[drive].cylinders = DEFAULT_HD_CYLINDERS; }
disks[drive].heads = DEFAULT_HD_HEADS;
disks[drive].sectors = DEFAULT_HD_SECTORS;
disks[drive].total_sectors = (DEFAULT_HD_CYLINDERS
* DEFAULT_HD_HEADS
* DEFAULT_HD_SECTORS);
}
else
{
/* Floppy. */
disks[drive].cylinders = DEFAULT_FD_CYLINDERS;
disks[drive].heads = DEFAULT_FD_HEADS;
disks[drive].sectors = DEFAULT_FD_SECTORS;
disks[drive].total_sectors = (DEFAULT_FD_CYLINDERS
* DEFAULT_FD_HEADS
* DEFAULT_FD_SECTORS);
} }
} }
} }
@ -835,8 +877,8 @@ biosdisk (int subfunc, int drive, struct geometry *geometry,
return BIOSDISK_ERROR_GEOMETRY; return BIOSDISK_ERROR_GEOMETRY;
/* Seek to the specified location. */ /* Seek to the specified location. */
#ifdef __linux__ #if defined(__linux) && (__GLIBC__ < 2)
/* FIXME: only use this section if libc doesn't have large file support */ /* Maybe libc doesn't have large file support. */
{ {
loff_t offset, result; loff_t offset, result;
static int _llseek (uint fd, ulong hi, ulong lo, loff_t *res, uint wh); static int _llseek (uint fd, ulong hi, ulong lo, loff_t *res, uint wh);