Skip to content

Commit

Permalink
Merge pull request #1779 from tyama501/pc98_bioshd3
Browse files Browse the repository at this point in the history
[bioshd] 720KB 2DD support for PC-98 2HD/2DD common drive
  • Loading branch information
ghaerr authored Dec 29, 2023
2 parents 20b2a5e + 4af3e3e commit 86a6061
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions elks/arch/i86/drivers/block/bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ void bios_switch_device98(int target, unsigned int device, struct drive_infot *d
(device | (bios_drive_map[target + DRIVE_FD0] & 0x0F));
if (device == 0x30)
*drivep = fd_types[FD1440];
else if (device == 0x10)
*drivep = fd_types[FD720];
else if (device == 0x90)
*drivep = fd_types[FD1232];
}
Expand Down
27 changes: 18 additions & 9 deletions elks/arch/i86/drivers/block/bioshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static void probe_floppy(int target, struct hd_struct *hdp)
* somewhere near)
*/
#ifdef CONFIG_ARCH_PC98
static unsigned char sector_probe[2] = { 8, 18 };
static unsigned char sector_probe[3] = { 8, 9, 18 };
static unsigned char track_probe[2] = { 77, 80 };
#else
static unsigned char sector_probe[5] = { 8, 9, 15, 18, 36 };
Expand Down Expand Up @@ -227,15 +227,18 @@ static void probe_floppy(int target, struct hd_struct *hdp)

count = 0;
#ifdef CONFIG_ARCH_PC98
int pc98_720KB = 0;
do {
if (count)
bios_switch_device98(target, 0x30, drivep); /* 1.44 MB */
/* skip probing first entry */
if (count && read_sector(target, track_probe[count] - 1, 1)) {
bios_switch_device98(target, 0x90, drivep); /* 1.232 MB */
break;
bios_switch_device98(target, 0x10, drivep); /* 720 KB */
if (read_sector(target, track_probe[count] - 1, 1))
bios_switch_device98(target, 0x90, drivep); /* 1.232 MB */
else
pc98_720KB = 1;
}
drivep->cylinders = track_probe[count];
} while (++count < sizeof(track_probe)/sizeof(track_probe[0]));
#else
do {
Expand All @@ -261,14 +264,20 @@ static void probe_floppy(int target, struct hd_struct *hdp)
count = 0;
#ifdef CONFIG_ARCH_PC98
do {
if (count)
if (count == 2)
bios_switch_device98(target, 0x30, drivep); /* 1.44 MB */
/* skip reading first entry */
if (count && read_sector(target, 0, sector_probe[count])) {
bios_switch_device98(target, 0x90, drivep); /* 1.232 MB */
break;
if ((count == 2) && read_sector(target, 0, sector_probe[count])) {
if (pc98_720KB) {
bios_switch_device98(target, 0x10, drivep); /* 720 KB */
/* Read BPB to find 8 sectors, 640KB format. Currently, it is not supported */
unsigned char __far *boot = _MK_FP(DMASEG, 0);
if (!read_sector(target, 0, 1) && (boot[24] == 8))
bios_switch_device98(target, 0x90, drivep);
}
else
bios_switch_device98(target, 0x90, drivep); /* 1.232 MB */
}
drivep->sectors = sector_probe[count];
} while (++count < sizeof(sector_probe)/sizeof(sector_probe[0]));
#else
do {
Expand Down
4 changes: 3 additions & 1 deletion pc98-1232.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CONFIG_ARCH_PC98=y
#

CONFIG_BOOTOPTS=y
# CONFIG_ASYNCIO is not set
CONFIG_CPU_USAGE=y
CONFIG_TIME_RTC_LOCALTIME=y
CONFIG_TIME_TZ="JST-9"
Expand Down Expand Up @@ -69,8 +70,9 @@ CONFIG_EXEC_MMODEL=y
#

CONFIG_BLK_DEV_BFD=y
# CONFIG_BLK_DEV_BFD_HARD is not set
# CONFIG_BLK_DEV_FD is not set
CONFIG_TRACK_CACHE=y
# CONFIG_BLK_DEV_BFD_HARD is not set
CONFIG_BLK_DEV_BHD=y
# CONFIG_IDE_PROBE is not set
# CONFIG_BLK_DEV_RAM is not set
Expand Down
4 changes: 3 additions & 1 deletion pc98-1440.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CONFIG_ARCH_PC98=y
#

CONFIG_BOOTOPTS=y
# CONFIG_ASYNCIO is not set
CONFIG_CPU_USAGE=y
CONFIG_TIME_RTC_LOCALTIME=y
CONFIG_TIME_TZ="JST-9"
Expand Down Expand Up @@ -69,8 +70,9 @@ CONFIG_EXEC_MMODEL=y
#

CONFIG_BLK_DEV_BFD=y
# CONFIG_BLK_DEV_BFD_HARD is not set
# CONFIG_BLK_DEV_FD is not set
CONFIG_TRACK_CACHE=y
# CONFIG_BLK_DEV_BFD_HARD is not set
CONFIG_BLK_DEV_BHD=y
# CONFIG_IDE_PROBE is not set
# CONFIG_BLK_DEV_RAM is not set
Expand Down

0 comments on commit 86a6061

Please sign in to comment.