Fix code that determines BIOS CHS from MBR - used to get confused by big disks.

Make same function return useful defaults if it can't find an answer.
Make all ports default to the useful defaults if bios geometry is unknown.
Move some messages to mbr set from mi set.
Fix i386 code that selects which bios disk, simplify interface to menus.
Remove now unnecessary global data from many ports.
This commit is contained in:
dsl 2003-06-13 22:27:03 +00:00
parent f9d5f7ab0c
commit deef134ca4
27 changed files with 211 additions and 240 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.h,v 1.8 2003/06/12 12:41:55 dsl Exp $ */
/* $NetBSD: md.h,v 1.9 2003/06/13 22:27:04 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -95,10 +95,6 @@ EXTERN char *boottype INIT("");
*/
EXTERN char *fdtype INIT("msdos");
extern struct disklist *disklist;
extern struct nativedisk_info *nativedisk;
extern struct biosdisk_info *biosdisk;
#define _PATH_MBR DEFAULT_BOOTDIR "/" DEFAULT_BOOTCODE
#define _PATH_BOOTSEL DEFAULT_BOOTDIR "/" DEFAULT_BOOTSELCODE

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.12 2003/06/12 10:51:38 dsl Exp $ */
/* $NetBSD: md.c,v 1.13 2003/06/13 22:27:05 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -49,9 +49,6 @@
#include "menu_defs.h"
struct disklist *disklist = NULL;
/* prototypes */

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.h,v 1.9 2003/06/11 21:35:38 dsl Exp $ */
/* $NetBSD: md.h,v 1.10 2003/06/13 22:27:05 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -89,11 +89,6 @@
*/
EXTERN char *fdtype INIT("ados");
extern struct disklist *disklist;
extern struct nativedisk_info *nativedisk;
#define SCAN_ENTER 0x1c
#define SCAN_F1 0x3b
/*
* prototypes for MD code.

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.15 2003/06/12 10:51:38 dsl Exp $ */
/* $NetBSD: md.c,v 1.16 2003/06/13 22:27:05 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -56,9 +56,6 @@
mbr_sector_t mbr;
int mbr_len;
struct disklist *disklist = NULL;
struct nativedisk_info *nativedisk;
struct biosdisk_info *biosdisk = NULL;
static void md_upgrade_mbrtype (void);
@ -219,11 +216,9 @@ md_bios_info(char *dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0)
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else
set_bios_geom(dlcyl, dlhead, dlsec);
set_bios_geom(cyl, head, sec);
bsize = dlsize;
bcylsize = bhead * bsec;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.h,v 1.6 2003/06/11 21:35:38 dsl Exp $ */
/* $NetBSD: md.h,v 1.7 2003/06/13 22:27:05 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -81,9 +81,6 @@
*/
EXTERN char *fdtype INIT("msdos");
extern struct disklist *disklist;
extern struct nativedisk_info *nativedisk;
extern struct biosdisk_info *biosdisk;
/*
* prototypes for MD code.

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.12 2003/06/12 10:51:39 dsl Exp $ */
/* $NetBSD: md.c,v 1.13 2003/06/13 22:27:05 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -49,8 +49,6 @@
#include "menu_defs.h"
struct disklist *disklist = NULL;
/* prototypes */

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.h,v 1.9 2003/06/13 11:57:30 dsl Exp $ */
/* $NetBSD: md.h,v 1.10 2003/06/13 22:27:06 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -91,8 +91,6 @@
*/
EXTERN char *fdtype INIT("msdos");
extern struct disklist *disklist;
extern struct nativedisk_info *nativedisk;
/*
* prototypes for MD code.

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.38 2003/06/12 10:51:39 dsl Exp $ */
/* $NetBSD: md.c,v 1.39 2003/06/13 22:27:06 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -182,11 +182,9 @@ md_bios_info(char *dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0)
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else
set_bios_geom(dlcyl, dlhead, dlsec);
set_bios_geom(cyl, head, sec);
bsize = bcyl * bhead * bsec;
bcylsize = bhead * bsec;
return 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.13 2003/06/12 10:51:40 dsl Exp $ */
/* $NetBSD: md.c,v 1.14 2003/06/13 22:27:06 dsl Exp $ */
/*
* Copyright 1997,2002 Piermont Information Systems Inc.
@ -186,11 +186,9 @@ md_bios_info(dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0)
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else
set_bios_geom(dlcyl, dlhead, dlsec);
set_bios_geom(cyl, head, sec);
bsize = bcyl * bhead * bsec;
bcylsize = bhead * bsec;
return 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.30 2003/06/13 11:57:31 dsl Exp $ */
/* $NetBSD: md.c,v 1.31 2003/06/13 22:27:07 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -57,9 +57,6 @@ extern mbr_sector_t mbr;
mbr_sector_t mbr;
#endif
int mbr_present, mbr_len;
struct disklist *disklist = NULL;
struct nativedisk_info *nativedisk;
struct biosdisk_info *biosdisk = NULL;
int netbsd_mbr_installed = 0;
static void md_upgrade_mbrtype (void);
@ -209,12 +206,9 @@ md_bios_info(char *dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0)
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else
set_bios_geom(dlcyl, dlhead, dlsec);
biosdisk = NULL;
set_bios_geom(cyl, head, sec);
bsize = bcyl * bhead * bsec;
bcylsize = bhead * bsec;
return 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.h,v 1.19 2003/06/13 11:57:31 dsl Exp $ */
/* $NetBSD: md.h,v 1.20 2003/06/13 22:27:07 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -84,10 +84,6 @@
*/
EXTERN char *fdtype INIT("msdos");
extern struct disklist *disklist;
extern struct nativedisk_info *nativedisk;
extern struct biosdisk_info *biosdisk;
/*
* prototypes for MD code.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.86 2003/06/12 12:41:55 dsl Exp $ */
/* $NetBSD: md.c,v 1.87 2003/06/13 22:27:07 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -63,9 +63,8 @@
mbr_sector_t mbr;
int mbr_len;
struct disklist *disklist = NULL;
struct nativedisk_info *nativedisk;
struct biosdisk_info *biosdisk = NULL;
static struct biosdisk_info *biosdisk = NULL;
int netbsd_mbr_installed = 0;
/* prototypes */
@ -388,15 +387,15 @@ int
md_bios_info(dev)
char *dev;
{
int mib[2], i;
static struct disklist *disklist = NULL;
static int mib[2] = {CTL_MACHDEP, CPU_DISKINFO};
int i;
size_t len;
struct biosdisk_info *bip;
struct nativedisk_info *nip = NULL, *nat;
int cyl, head, sec;
if (disklist == NULL) {
mib[0] = CTL_MACHDEP;
mib[1] = CPU_DISKINFO;
if (sysctl(mib, 2, NULL, &len, NULL, 0) < 0)
goto nogeom;
disklist = malloc(len);
@ -419,30 +418,47 @@ md_bios_info(dev)
if (nip == NULL || nip->ni_nmatches == 0) {
nogeom:
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0)
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else
set_bios_geom(dlcyl, dlhead, dlsec);
biosdisk = NULL;
} else if (nip->ni_nmatches == 1) {
bip = &disklist->dl_biosdisks[nip->ni_biosmatches[0]];
msg_display(MSG_onebiosmatch);
msg_table_add(MSG_onebiosmatch_header);
msg_table_add(MSG_onebiosmatch_row, bip->bi_dev - 0x80,
bip->bi_cyl, bip->bi_head, bip->bi_sec);
msg_display_add(MSG_biosgeom_advise);
process_menu(MENU_biosonematch, NULL);
} else {
msg_display(MSG_biosmultmatch);
msg_table_add(MSG_biosmultmatch_header);
for (i = 0; i < nip->ni_nmatches; i++) {
bip = &disklist->dl_biosdisks[nip->ni_biosmatches[i]];
msg_table_add(MSG_biosmultmatch_row, i,
bip->bi_dev - 0x80, bip->bi_cyl, bip->bi_head,
bip->bi_sec);
guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec);
if (nip->ni_nmatches == 1) {
bip = &disklist->dl_biosdisks[nip->ni_biosmatches[0]];
msg_display(MSG_onebiosmatch);
msg_table_add(MSG_onebiosmatch_header);
msg_table_add(MSG_onebiosmatch_row, bip->bi_dev,
bip->bi_cyl, bip->bi_head, bip->bi_sec,
(unsigned)bip->bi_lbasecs,
(unsigned)(bip->bi_lbasecs / (1000000000 / 512)));
msg_display_add(MSG_biosgeom_advise);
biosdisk = bip;
process_menu(MENU_biosonematch, &biosdisk);
} else {
msg_display(MSG_biosmultmatch);
msg_table_add(MSG_biosmultmatch_header);
for (i = 0; i < nip->ni_nmatches; i++) {
bip = &disklist->dl_biosdisks[
nip->ni_biosmatches[i]];
msg_table_add(MSG_biosmultmatch_row, i,
bip->bi_dev, bip->bi_cyl, bip->bi_head,
bip->bi_sec, (unsigned)bip->bi_lbasecs,
(unsigned)bip->bi_lbasecs/(1000000000/512));
}
process_menu(MENU_biosmultmatch, &i);
if (i == -1)
biosdisk = NULL;
else
biosdisk = &disklist->dl_biosdisks[
nip->ni_biosmatches[i]];
}
process_menu(MENU_biosmultmatch, NULL);
}
if (biosdisk == NULL)
set_bios_geom(cyl, head, sec);
else {
bcyl = biosdisk->bi_cyl;
bhead = biosdisk->bi_head;
bsec = biosdisk->bi_sec;
}
if (biosdisk != NULL && (biosdisk->bi_flags & BIFLAG_EXTINT13))
bsize = dlsize;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.h,v 1.42 2003/06/12 12:41:56 dsl Exp $ */
/* $NetBSD: md.h,v 1.43 2003/06/13 22:27:07 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -106,10 +106,6 @@ EXTERN char *boottype INIT("");
*/
EXTERN char *fdtype INIT("msdos");
extern struct disklist *disklist;
extern struct nativedisk_info *nativedisk;
extern struct biosdisk_info *biosdisk;
#define _PATH_MBR DEFAULT_BOOTDIR "/" DEFAULT_BOOTCODE
#define _PATH_BOOTSEL DEFAULT_BOOTDIR "/" DEFAULT_BOOTSELCODE

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md,v 1.5 2003/06/12 10:51:41 dsl Exp $ */
/* $NetBSD: menus.md,v 1.6 2003/06/13 22:27:08 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -51,44 +51,23 @@ menu getboottype, title MSG_Bootblocks_selection;
{boottype = "serial115200";};
menu biosonematch;
option MSG_This_is_the_correct_geometry, exit, action {
extern struct disklist *disklist;
extern struct nativedisk_info *nativedisk;
struct biosdisk_info *bip;
extern struct biosdisk_info *biosdisk;
bip = &disklist->dl_biosdisks[nativedisk->ni_biosmatches[0]];
bcyl = bip->bi_cyl;
bhead = bip->bi_head;
bsec = bip->bi_sec;
biosdisk = bip;
};
option MSG_Set_the_geometry_by_hand, exit, action {
set_bios_geom(dlcyl, dlhead, dlsec);
biosdisk = NULL;
};
option MSG_This_is_the_correct_geometry, exit, action { };
option MSG_Set_the_geometry_by_hand, exit, action
{*(void **)arg = NULL;};
menu biosmultmatch;
option MSG_Use_one_of_these_disks, exit, action {
extern struct disklist *disklist;
extern struct nativedisk_info *nativedisk;
struct biosdisk_info *bip;
extern struct biosdisk_info *biosdisk;
int sel;
char res[80];
char res[4];
do {
strcpy(res, "0");
msg_prompt(MSG_pickdisk, res, res, 80);
msg_prompt_win(MSG_pickdisk, -1, -1, 0, 0,
res, res, sizeof res);
sel = atoi(res);
} while (sel < 0 || sel >= nativedisk->ni_nmatches);
bip = &disklist->dl_biosdisks[nativedisk->ni_biosmatches[0]];
bcyl = bip->bi_cyl;
bhead = bip->bi_head;
bsec = bip->bi_sec;
biosdisk = bip;
} while (sel < 0 || sel >= *(int *)arg);
*(int *)arg = sel;
};
option MSG_Set_the_geometry_by_hand, exit, action {
set_bios_geom(dlcyl, dlhead, dlsec);
biosdisk = NULL;
*(int *)arg = -1;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.en,v 1.37 2003/06/12 12:41:56 dsl Exp $ */
/* $NetBSD: msg.md.en,v 1.38 2003/06/13 22:27:08 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -95,12 +95,12 @@ message onebiosmatch
}
message onebiosmatch_header
{BIOS # cylinders heads sectors
------ ---------- ------- -------
{BIOS # cylinders heads sectors total sectors GB
------ --------- ----- ------- ------------- ---
}
message onebiosmatch_row
{%-6x %-10d %-7d %d\n}
{%#6x %9d %5d %7d %13u %3u\n}
message This_is_the_correct_geometry
{This is the correct geometry}
@ -115,10 +115,13 @@ message biosmultmatch
}
message biosmultmatch_header
{ BIOS # cylinders heads sectors
------ ---------- ------- -------
{ BIOS # cylinders heads sectors total sectors GB
------ --------- ----- ------- ------------- ----
}
message biosmultmatch_row
{%-1d: %#6x %9d %5d %7d %13u %3u\n}
message biosgeom_advise
{
Note: since sysinst was able to uniquely match the disk you chose with a disk
@ -126,9 +129,6 @@ known to the BIOS, the values displayed above are very likely correct, and
should not be changed. Only change them if they are very obviously wrong.
}
message biosmultmatch_row
{%-1d: %-6x %-10d %-7d %d\n}
message pickdisk
{Choose disk: }

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.fr,v 1.27 2003/06/12 12:41:56 dsl Exp $ */
/* $NetBSD: msg.md.fr,v 1.28 2003/06/13 22:27:08 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -91,13 +91,13 @@ message onebiosmatch
}
message onebiosmatch_header
{BIOS # cylinders heads sectors
------ ---------- ------- -------
message onebiosmatch_header /* XXX translate */
{BIOS # cylinders heads sectors total sectors GB
------ --------- ----- ------- ------------- ---
}
message onebiosmatch_row
{%-6x %-10d %-7d %-10d\n}
message onebiosmatch_row /* XXX adjust for length of titles above */
{%#6x %9d %5d %7d %13u %3u\n}
message This_is_the_correct_geometry
{C'est le bon géométrie}
@ -111,11 +111,14 @@ message biosmultmatch
}
message biosmultmatch_header
{ BIOS # cylinders heads sectors
------ ---------- ------- -------
message biosmultmatch_header /* XXX translate */
{ BIOS # cylinders heads sectors total sectors GB
------ --------- ----- ------- ------------- ---
}
message biosmultmatch_row /* XXX adjust for length of titles above */
{%-1d: %#6x %9d %5d %7d %13u %3u\n}
message biosgeom_advise /* XXX translate */
{
Note: since sysinst was able to uniquely match the disk you chose with a disk
@ -123,9 +126,6 @@ known to the BIOS, the values displayed above are very likely correct, and
should not be changed. Only change them if they are very obviously wrong.
}
message biosmultmatch_row
{%-1d: %-6x %-10d %-7d %d\n}
message pickdisk
{Choisissez un disque: }

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.pl,v 1.12 2003/06/12 12:41:56 dsl Exp $ */
/* $NetBSD: msg.md.pl,v 1.13 2003/06/13 22:27:08 dsl Exp $ */
/* Based on english version: */
/* NetBSD: msg.md.en,v 1.24 2001/01/27 07:34:39 jmc Exp */
@ -92,13 +92,13 @@ message onebiosmatch
}
message onebiosmatch_header
{BIOS # cylindry glowice sektory
------ ---------- ------- -------
message onebiosmatch_header /* XXX translate total */
{BIOS # cylindry glowice sektory total sektory GB
------ -------- ------- ------- ------------- ---
}
message onebiosmatch_row
{%-6x %-10d %-7d %d\n}
{%#6x %8d %6d %7d %13u %3u\n}
message This_is_the_correct_geometry
{To jest prawidlowa geometria}
@ -112,11 +112,14 @@ message biosmultmatch
}
message biosmultmatch_header
{ BIOS # cylindry glowice sektory
------ ---------- ------- -------
message biosmultmatch_header /* XXX translate total */
{ BIOS # cylindry glowice sektory total sektory GB
------ -------- ------- ------- ------------- ---
}
message biosmultmatch_row
{%-1d: %6x %8d %7d %7d %13u %3u\n}
message biosgeom_advise
{
Notatka: od kiedy sysinst jest w stanie unikalnie rozpoznac dysk, ktory
@ -125,9 +128,6 @@ bardzo prawdopodobnie prawidlowe i nie powinny byc zmieniane. Zmieniaj je
tylko wtedy jesli sa naprawde _obrzydliwie_ zle.
}
message biosmultmatch_row
{%-1d: %-6x %-10d %-7d %d\n}
message pickdisk
{Wybierz dysk: }

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.10 2003/06/13 11:57:33 dsl Exp $ */
/* $NetBSD: md.c,v 1.11 2003/06/13 22:27:09 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -67,12 +67,9 @@ md_get_info()
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0)
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else {
set_bios_geom(dlcyl, dlhead, dlsec);
}
set_bios_geom(cyl, head, sec);
bsize = bcyl * bhead * bsec;
bcylsize = bhead * bsec;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.14 2003/06/13 11:57:34 dsl Exp $ */
/* $NetBSD: md.c,v 1.15 2003/06/13 22:27:09 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -55,9 +55,6 @@
mbr_sector_t mbr;
int mbr_present, mbr_len;
struct disklist *disklist = NULL;
struct nativedisk_info *nativedisk;
struct biosdisk_info *biosdisk = NULL;
int netbsd_mbr_installed = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.15 2003/06/12 10:51:42 dsl Exp $ */
/* $NetBSD: md.c,v 1.16 2003/06/13 22:27:09 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -185,11 +185,9 @@ md_bios_info(char *dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0)
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else
set_bios_geom(dlcyl, dlhead, dlsec);
set_bios_geom(cyl, head, sec);
bsize = bcyl * bhead * bsec;
bcylsize = bhead * bsec;
return 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbr.c,v 1.39 2003/06/13 11:57:29 dsl Exp $ */
/* $NetBSD: mbr.c,v 1.40 2003/06/13 22:27:03 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -106,7 +106,7 @@ struct part_id {
int dosptyp_nbsd = MBR_PTYPE_NETBSD;
static int get_mapping(struct mbr_partition *, int, int *, int *, int *,
long *);
unsigned long *);
static void convert_mbr_chs(int, int, int, u_int8_t *, u_int8_t *,
u_int8_t *, u_int32_t);
@ -557,58 +557,72 @@ convert_mbr_chs(int cyl, int head, int sec,
* is not present, or a match could not be made with a NetBSD
* device.
*/
#define MAXCYL 1023 /* Possibly 1024 */
#define MAXHEAD 255 /* Possibly 256 */
#define MAXSECTOR 63
int
guess_biosgeom_from_mbr(mbr_sector_t *mbr, int *cyl, int *head, int *sec)
{
struct mbr_partition *parts = &mbr->mbr_parts[0];
int cylinders = -1, heads = -1, sectors = -1, i, j;
int xcylinders, xheads, xsectors, i, j;
int c1, h1, s1, c2, h2, s2;
long a1, a2;
quad_t num, denom;
unsigned long a1, a2;
uint64_t num, denom;
*cyl = *head = *sec = -1;
/*
* The physical parameters may be invalid as bios geometry.
* If we cannot determine the actual bios geometry, we are
* better off picking a likely 'faked' geometry than leaving
* the invalid physical one.
*/
xcylinders = dlcyl;
xheads = dlhead;
xsectors = dlsec;
if (xcylinders > MAXCYL || xheads > MAXHEAD || xsectors > MAXSECTOR) {
xsectors = MAXSECTOR;
xheads = MAXHEAD;
xcylinders = disk->dd_totsec / (MAXSECTOR * MAXHEAD);
if (xcylinders > MAXCYL)
xcylinders = MAXCYL;
}
*cyl = xcylinders;
*head = xheads;
*sec = xsectors;
xheads = -1;
/* Try to deduce the number of heads from two different mappings. */
for (i = 0; i < NMBRPART * 2; i++) {
for (i = 0; i < NMBRPART * 2 - 1; i++) {
if (get_mapping(parts, i, &c1, &h1, &s1, &a1) < 0)
continue;
for (j = 0; j < 8; j++) {
for (j = i + 1; j < NMBRPART * 2; j++) {
if (get_mapping(parts, j, &c2, &h2, &s2, &a2) < 0)
continue;
num = (quad_t)h1*(a2-s2) - (quad_t)h2*(a1-s1);
denom = (quad_t)c2*(a1-s1) - (quad_t)c1*(a2-s2);
a1 -= s1;
a2 -= s2;
num = (uint64_t)h1 * a2 - (quad_t)h2 * a1;
denom = (uint64_t)c2 * a1 - (quad_t)c1 * a2;
if (denom != 0 && num % denom == 0) {
heads = (int)(num / denom);
xheads = (int)(num / denom);
xsectors = a1 / (c1 * xheads + h1);
break;
}
}
if (heads != -1)
if (xheads != -1)
break;
}
if (heads == -1)
return -1;
/* Now figure out the number of sectors from a single mapping. */
for (i = 0; i < NMBRPART * 2; i++) {
if (get_mapping(parts, i, &c1, &h1, &s1, &a1) < 0)
continue;
num = a1 - s1;
denom = c1 * heads + h1;
if (denom != 0 && num % denom == 0) {
sectors = (int)(num / denom);
break;
}
}
if (sectors == -1)
if (xheads == -1)
return -1;
/*
* Estimate the number of cylinders.
* XXX relies on get_disks having been called.
*/
cylinders = disk->dd_totsec / heads / sectors;
xcylinders = disk->dd_totsec / xheads / xsectors;
/* Now verify consistency with each of the partition table entries.
* Be willing to shove cylinders up a little bit to make things work,
@ -616,23 +630,25 @@ guess_biosgeom_from_mbr(mbr_sector_t *mbr, int *cyl, int *head, int *sec)
for (i = 0; i < NMBRPART * 2; i++) {
if (get_mapping(parts, i, &c1, &h1, &s1, &a1) < 0)
continue;
if (sectors * (c1 * heads + h1) + s1 != a1)
if (xsectors * (c1 * xheads + h1) + s1 != a1)
return -1;
if (c1 >= cylinders)
cylinders = c1 + 1;
if (c1 >= xcylinders)
xcylinders = c1 + 1;
}
/* Everything checks out. Reset the geometry to use for further
* calculations. */
*cyl = cylinders;
*head = heads;
*sec = sectors;
/*
* Everything checks out. Reset the geometry to use for further
* calculations.
*/
*cyl = MIN(xcylinders, MAXCYL);
*head = xheads;
*sec = xsectors;
return 0;
}
static int
get_mapping(mbr_partition_t *parts, int i,
int *cylinder, int *head, int *sector, long *absolute)
int *cylinder, int *head, int *sector, unsigned long *absolute)
{
struct mbr_partition *apart = &parts[i / 2];
@ -642,13 +658,19 @@ get_mapping(mbr_partition_t *parts, int i,
*cylinder = MBR_PCYL(apart->mbrp_scyl, apart->mbrp_ssect);
*head = apart->mbrp_shd;
*sector = MBR_PSECT(apart->mbrp_ssect) - 1;
*absolute = apart->mbrp_start;
*absolute = le32toh(apart->mbrp_start);
} else {
*cylinder = MBR_PCYL(apart->mbrp_ecyl, apart->mbrp_esect);
*head = apart->mbrp_ehd;
*sector = MBR_PSECT(apart->mbrp_esect) - 1;
*absolute = apart->mbrp_start + apart->mbrp_size - 1;
*absolute = le32toh(apart->mbrp_start)
+ le32toh(apart->mbrp_size) - 1;
}
/* Sanity check the data against max values */
if ((((*cylinder * MAXHEAD) + *head) * MAXSECTOR + *sector) < *absolute)
/* cannot be a CHS mapping */
return -1;
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mbr.en,v 1.3 2003/06/12 10:51:37 dsl Exp $ */
/* $NetBSD: msg.mbr.en,v 1.4 2003/06/13 22:27:03 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -77,7 +77,8 @@ message part_row_end
{ %s\n}
message setbiosgeom
{You will be prompted for the geometry. Please enter the values you
{
You will be prompted for the geometry. Please enter the values you
want. The number of cylinders should be <= 1024 and the number of sectors
should be <= 63. If you have the BIOS set up to use > 1024 cylinders just
truncate that number to 1024 here; NetBSD will know about the rest of the
@ -85,6 +86,14 @@ cylinders.
}
message nobiosgeom
{Sysinst could not automatically determine the BIOS geometry of the disk.
The physical geometry is %d cylinders %d sectors %d heads\n}
message biosguess
{Using the information already on the disk, my best guess for the BIOS
geometry is %d cylinders %d sectors %d heads\n}
.if 0
message confirmbiosgeom
{Please verify if the BIOS disk geometry below is correct. The value for

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mbr.fr,v 1.2 2003/06/12 10:51:38 dsl Exp $ */
/* $NetBSD: msg.mbr.fr,v 1.3 2003/06/13 22:27:03 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -79,13 +79,24 @@ message part_row_end
{ %s\n}
message setbiosgeom
{On va vous demander la géométrie. SVP entrer les valeur que vous désirez.
{
On va vous demander la géométrie. SVP entrer les valeur que vous désirez.
Rappelez vous que le nombre de cylindre doit être <= 1024 et que le nombre
de secteur doit être <=63. Si votre BIOS est configuré avec plus de 1024
cylindre, tronquez ce nombre à 1024 ici, NetBSD saura utiliser les cylindres
restant.
}
message nobiosgeom
{Sysinst n'a pas pu déterminer automatiquement la géométrie utilisée par le
BIOS pour votre disque.
La géométrie physique est %d cylindres %d secteurs %d têtes\n}
message biosguess
{En utilisant les informations déja présentes sur le disque, je suppose que
la géométrie utilisée par le BIOS est %d cylindres %d secteurs %d têtes\n}
.if 0
message confirmbiosgeom
{SVP vérifiez que la géometrie du BIOS ci-dessous est correcte. Le nombre

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mbr.pl,v 1.2 2003/06/12 10:51:38 dsl Exp $ */
/* $NetBSD: msg.mbr.pl,v 1.3 2003/06/13 22:27:03 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -77,13 +77,22 @@ message part_row_end
{ %s\n}
message setbiosgeom
{Zostaniesz poproszony o podanie geometrii. Podaj wartosci jakie chcesz.
{
Zostaniesz poproszony o podanie geometrii. Podaj wartosci jakie chcesz.
Ilosc cylindrow powinna byc <= 1024 a ilosc sektorow <= 63. Jesli twoj
BIOS jest ustawiony aby obslugiwac > 1024 cylindry po prostu zmniejsz
tutaj ta ilosc do 1024; NetBSD rozpozna reszte cylindrow.
}
message nobiosgeom
{Sysinst nie mogl automatycznie rozpoznac geometrii dysku z BIOS.
Fizyczna geometria to %d cylindrow %d sektorow %d glowic\n}
message biosguess
{Uzywajac informacji z dysku, najlepsze parametry geometrii dysku z BIOS to
%d cylindrow %d sektorow %d glowic\n}
.if 0
message confirmbiosgeom
{Sprawdz czy geometria dysku z BIOS ponizej jest poprawna. Mozliwe ze

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.en,v 1.106 2003/06/13 11:45:49 dsl Exp $ */
/* $NetBSD: msg.mi.en,v 1.107 2003/06/13 22:27:03 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -898,14 +898,6 @@ message config_open_error
message config_read_error
{Could not read config file %s\n}
message nobiosgeom
{Sysinst could not automatically determine the BIOS geometry of the disk.
The physical geometry is %d cylinders %d sectors %d heads\n}
message biosguess
{Using the information already on the disk, my best guess for the BIOS
geometry is %d cylinders %d sectors %d heads\n}
message cmdfail
{Command
%s

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.fr,v 1.55 2003/06/13 11:45:49 dsl Exp $ */
/* $NetBSD: msg.mi.fr,v 1.56 2003/06/13 22:27:03 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -905,15 +905,6 @@ message config_open_error
message config_read_error
{Impossible de lire le fichier de configuration %s.n}
message nobiosgeom
{Sysinst n'a pas pu déterminer automatiquement la géométrie utilisée par le
BIOS pour votre disque.
La géométrie physique est %d cylindres %d secteurs %d têtes\n}
message biosguess
{En utilisant les informations déja présentes sur le disque, je suppose que
la géométrie utilisée par le BIOS est %d cylindres %d secteurs %d têtes\n}
message cmdfail
{La commande
%s

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.pl,v 1.18 2003/06/13 11:45:50 dsl Exp $ */
/* $NetBSD: msg.mi.pl,v 1.19 2003/06/13 22:27:04 dsl Exp $ */
/* Based on english version: */
/* NetBSD: msg.mi.en,v 1.86 2002/04/04 14:26:44 ad Exp */
@ -883,14 +883,6 @@ message config_open_error
message config_read_error
{Nie moglem odczytac pliku konfiguracyjnego %s\n}
message nobiosgeom
{Sysinst nie mogl automatycznie rozpoznac geometrii dysku z BIOS.
Fizyczna geometria to %d cylindrow %d sektorow %d glowic\n}
message biosguess
{Uzywajac informacji z dysku, najlepsze parametry geometrii dysku z BIOS to
%d cylindrow %d sektorow %d glowic\n}
message cmdfail
{Polecenie
%s