diff options
| -rw-r--r-- | sys/pc98/pc98/pc98_machdep.c | 65 | ||||
| -rw-r--r-- | sys/pc98/pc98/pc98_machdep.h | 3 | ||||
| -rw-r--r-- | sys/scsi/sd.c | 37 |
3 files changed, 71 insertions, 34 deletions
diff --git a/sys/pc98/pc98/pc98_machdep.c b/sys/pc98/pc98/pc98_machdep.c index 5bd82bc73872..b24362a4bc8c 100644 --- a/sys/pc98/pc98/pc98_machdep.c +++ b/sys/pc98/pc98/pc98_machdep.c @@ -29,6 +29,8 @@ #include <sys/systm.h> #include <sys/vmmeter.h> +#include <scsi/scsiconf.h> + #include <vm/vm.h> #include <vm/vm_param.h> #include <vm/vm_prot.h> @@ -212,3 +214,66 @@ pc98_getmemsize(void) init_epson_memwin(); #endif } + +#include "sd.h" + +#if NSD > 0 +/* + * XXX copied from sd.c. + */ +struct disk_parms { + u_char heads; /* Number of heads */ + u_int16_t cyls; /* Number of cylinders */ + u_char sectors; /*dubious *//* Number of sectors/track */ + u_int16_t secsiz; /* Number of bytes/sector */ + u_int32_t disksize; /* total number sectors */ +}; + +int sd_bios_parms __P((struct disk_parms *, struct scsi_link *)); + +/* + * Read a geometry information of SCSI HDD from BIOS work area. + * + * XXX - Before reading BIOS work area, we should check whether + * host adapter support it. + */ +int +sd_bios_parms(disk_parms, sc_link) + struct disk_parms *disk_parms; + struct scsi_link *sc_link; +{ + u_char *tmp; + + tmp = (u_char *)&PC98_SYSTEM_PARAMETER(0x460 + sc_link->target*4); + if ((PC98_SYSTEM_PARAMETER(0x482) & ((1 << sc_link->target)&0xff)) != 0) { + disk_parms->sectors = *tmp; + disk_parms->cyls = ((*(tmp+3)<<8)|*(tmp+2))&0xfff; + switch (*(tmp + 3) & 0x30) { + case 0x00: + disk_parms->secsiz = 256; + printf("Warning!: not supported.\n"); + break; + case 0x10: + disk_parms->secsiz = 512; + break; + case 0x20: + disk_parms->secsiz = 1024; + break; + default: + disk_parms->secsiz = 512; + printf("Warning!: not supported. But force to 512\n"); + break; + } + if (*(tmp+3) & 0x40) { + disk_parms->cyls += (*(tmp+1)&0xf0)<<8; + disk_parms->heads = *(tmp+1)&0x0f; + } else { + disk_parms->heads = *(tmp+1); + } + disk_parms->disksize = disk_parms->sectors * disk_parms->heads * + disk_parms->cyls; + return 1; + } + return 0; +} +#endif diff --git a/sys/pc98/pc98/pc98_machdep.h b/sys/pc98/pc98/pc98_machdep.h index 2986f79f0da3..42f5cf1f3e14 100644 --- a/sys/pc98/pc98/pc98_machdep.h +++ b/sys/pc98/pc98/pc98_machdep.h @@ -31,4 +31,7 @@ void pc98_init_dmac __P((void)); void pc98_getmemsize __P((void)); +struct disk_parms; +int sd_bios_parms __P((struct disk_parms *, struct scsi_link *)); + #endif /* __PC98_PC98_PC98_MACHDEP_H__ */ diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index c47e71b8117f..bb3105371138 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -48,7 +48,7 @@ #include <machine/md_var.h> #include <i386/i386/cons.h> /* XXX *//* for aborting dump */ #ifdef PC98 -#include <pc98/pc98/pc98.h> +#include <pc98/pc98/pc98_machdep.h> #endif static u_int32_t sdstrats, sdqueues; @@ -787,9 +787,7 @@ sd_get_parms(unit, flags) union disk_pages pages; } scsi_sense; u_int32_t sectors; -#ifdef PC98 - unsigned char *tmp; -#endif + /* * First check if we have it all loaded */ @@ -804,36 +802,7 @@ sd_get_parms(unit, flags) scsi_cmd.page = 4; scsi_cmd.length = 0x20; #ifdef PC98 -#define PC98_SYSTEM_PARAMETER(x) pc98_system_parameter[(x)-0x400] - tmp = (unsigned char *)&PC98_SYSTEM_PARAMETER(0x460 + sc_link->target*4); - if ((PC98_SYSTEM_PARAMETER(0x482) & - ((1 << sc_link->target)&0xff)) != 0) { - disk_parms->sectors = *tmp; - disk_parms->cyls = ((*(tmp+3)<<8)|*(tmp+2))&0xfff; - switch (*(tmp + 3) & 0x30) { - case 0x00: - disk_parms->secsiz = 256; - printf("Warning!: not supported.\n"); - break; - case 0x10: - disk_parms->secsiz = 512; - break; - case 0x20: - disk_parms->secsiz = 1024; - printf("Warning!: not supported.\n"); - break; - default: - disk_parms->secsiz = 512; - printf("Warning!: not supported. But force to 512\n"); - } - if (*(tmp+3) & 0x40) { - disk_parms->cyls += (*(tmp+1)&0xf0)<<8; - disk_parms->heads = *(tmp+1)&0x0f; - } else { - disk_parms->heads = *(tmp+1); - } - disk_parms->disksize = disk_parms->sectors * disk_parms->heads * - disk_parms->cyls; + if (sd_bios_parms(disk_parms, sc_link)) { } else #endif /* |
