Fill in bi_bios_geom[] in the bootinfo structure passed to the kernel.

This should resolve the problem raised in PR 12315, and incidentally
makes it easier to determine what geometry the BIOS is actually using
(by way of boot -v and dmesg).
This commit is contained in:
rnordier 1999-06-21 18:27:02 +00:00
parent 337113f078
commit 0571a0f633
5 changed files with 44 additions and 11 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: biosdisk.c,v 1.22 1999/01/24 06:03:44 msmith Exp $
* $Id: biosdisk.c,v 1.23 1999/01/25 23:07:02 rnordier Exp $
*/
/*
@ -746,6 +746,35 @@ bd_getgeom(struct open_disk *od)
return(0);
}
/*
* Return the BIOS geometry of a given "fixed drive" in a format
* suitable for the legacy bootinfo structure. Since the kernel is
* expecting raw int 0x13/0x8 values for N_BIOS_GEOM drives, we
* prefer to get the information directly, rather than rely on being
* able to put it together from information already maintained for
* different purposes and for a probably different number of drives.
*
* For valid drives, the geometry is expected in the format (31..0)
* "000000cc cccccccc hhhhhhhh 00ssssss"; and invalid drives are
* indicated by returning the geometry of a "1.2M" PC-format floppy
* disk. And, incidentally, what is returned is not the geometry as
* such but the highest valid cylinder, head, and sector numbers.
*/
u_int32_t
bd_getbigeom(int bunit)
{
v86.ctl = V86_FLAGS;
v86.addr = 0x13;
v86.eax = 0x800;
v86.edx = 0x80 + bunit;
v86int();
if (v86.efl & 0x1)
return 0x4f010f;
return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) |
(v86.edx & 0xff00) | (v86.ecx & 0x3f);
}
/*
* Return a suitable dev_t value for (dev).
*

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bootinfo.c,v 1.18 1999/03/18 14:36:22 dcs Exp $
* $Id: bootinfo.c,v 1.19 1999/06/04 03:18:28 ghelmer Exp $
*/
#include <stand.h>
@ -239,7 +239,7 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
struct i386_devdesc *rootdev;
vm_offset_t addr, bootinfo_addr;
char *rootdevname;
int bootdevnr;
int bootdevnr, i;
u_int pad;
char *kernelname;
const char *kernelpath;
@ -279,7 +279,8 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
bi.bi_kernelname = 0; /* XXX char * -> kernel name */
bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
/* bi.bi_bios_geom[] */
for (i = 0; i < N_BIOS_GEOM; i++)
bi.bi_bios_geom[i] = bd_getbigeom(i);
bi.bi_size = sizeof(bi);
bi.bi_memsizes_valid = 1;
bi.bi_basemem = getbasemem();

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bootinfo.c,v 1.18 1999/03/18 14:36:22 dcs Exp $
* $Id: bootinfo.c,v 1.19 1999/06/04 03:18:28 ghelmer Exp $
*/
#include <stand.h>
@ -239,7 +239,7 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
struct i386_devdesc *rootdev;
vm_offset_t addr, bootinfo_addr;
char *rootdevname;
int bootdevnr;
int bootdevnr, i;
u_int pad;
char *kernelname;
const char *kernelpath;
@ -279,7 +279,8 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
bi.bi_kernelname = 0; /* XXX char * -> kernel name */
bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
/* bi.bi_bios_geom[] */
for (i = 0; i < N_BIOS_GEOM; i++)
bi.bi_bios_geom[i] = bd_getbigeom(i);
bi.bi_size = sizeof(bi);
bi.bi_memsizes_valid = 1;
bi.bi_basemem = getbasemem();

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bootinfo.c,v 1.18 1999/03/18 14:36:22 dcs Exp $
* $Id: bootinfo.c,v 1.19 1999/06/04 03:18:28 ghelmer Exp $
*/
#include <stand.h>
@ -239,7 +239,7 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
struct i386_devdesc *rootdev;
vm_offset_t addr, bootinfo_addr;
char *rootdevname;
int bootdevnr;
int bootdevnr, i;
u_int pad;
char *kernelname;
const char *kernelpath;
@ -279,7 +279,8 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
bi.bi_kernelname = 0; /* XXX char * -> kernel name */
bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
/* bi.bi_bios_geom[] */
for (i = 0; i < N_BIOS_GEOM; i++)
bi.bi_bios_geom[i] = bd_getbigeom(i);
bi.bi_size = sizeof(bi);
bi.bi_memsizes_valid = 1;
bi.bi_basemem = getbasemem();

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: libi386.h,v 1.7 1998/10/02 16:32:45 msmith Exp $
* $Id: libi386.h,v 1.8 1998/10/02 20:53:17 msmith Exp $
*/
@ -63,6 +63,7 @@ extern struct devdesc currdev; /* our current device */
/* exported devices XXX rename? */
extern struct devsw biosdisk;
u_int32_t bd_getbigeom(int bunit); /* return geometry in bootinfo format */
extern int bd_bios2unit(int biosdev); /* xlate BIOS device -> biosdisk unit */
extern int bd_unit2bios(int unit); /* xlate biosdisk unit -> BIOS device */
extern int bd_getdev(struct i386_devdesc *dev); /* return dev_t for (dev) */