Changeset View
Changeset View
Standalone View
Standalone View
head/stand/i386/libi386/biosdisk.c
Show First 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | |||||
static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, | static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, | ||||
char *buf, size_t *rsize); | char *buf, size_t *rsize); | ||||
static int bd_open(struct open_file *f, ...); | static int bd_open(struct open_file *f, ...); | ||||
static int bd_close(struct open_file *f); | static int bd_close(struct open_file *f); | ||||
static int bd_ioctl(struct open_file *f, u_long cmd, void *data); | static int bd_ioctl(struct open_file *f, u_long cmd, void *data); | ||||
static int bd_print(int verbose); | static int bd_print(int verbose); | ||||
static int cd_print(int verbose); | static int cd_print(int verbose); | ||||
static int fd_print(int verbose); | static int fd_print(int verbose); | ||||
static void bd_reset_disk(int); | |||||
static int bd_get_diskinfo_std(struct bdinfo *); | |||||
struct devsw biosfd = { | struct devsw biosfd = { | ||||
.dv_name = "fd", | .dv_name = "fd", | ||||
.dv_type = DEVT_FD, | .dv_type = DEVT_FD, | ||||
.dv_init = fd_init, | .dv_init = fd_init, | ||||
.dv_strategy = bd_strategy, | .dv_strategy = bd_strategy, | ||||
.dv_open = bd_open, | .dv_open = bd_open, | ||||
.dv_close = bd_close, | .dv_close = bd_close, | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | STAILQ_FOREACH(bd, bdi, bd_link) { | ||||
if (unit == dev->dd.d_unit) | if (unit == dev->dd.d_unit) | ||||
return (bd->bd_unit); | return (bd->bd_unit); | ||||
unit++; | unit++; | ||||
} | } | ||||
return (-1); | return (-1); | ||||
} | } | ||||
/* | /* | ||||
* Use INT13 AH=15 - Read Drive Type. | |||||
*/ | |||||
static int | |||||
fd_count(void) | |||||
{ | |||||
int drive; | |||||
for (drive = 0; drive < MAXBDDEV; drive++) { | |||||
bd_reset_disk(drive); | |||||
v86.ctl = V86_FLAGS; | |||||
v86.addr = 0x13; | |||||
v86.eax = 0x1500; | |||||
v86.edx = drive; | |||||
v86int(); | |||||
if (V86_CY(v86.efl)) | |||||
break; | |||||
if ((v86.eax & 0x300) == 0) | |||||
break; | |||||
} | |||||
return (drive); | |||||
} | |||||
/* | |||||
* Quiz the BIOS for disk devices, save a little info about them. | * Quiz the BIOS for disk devices, save a little info about them. | ||||
*/ | */ | ||||
static int | static int | ||||
fd_init(void) | fd_init(void) | ||||
{ | { | ||||
int unit; | int unit, numfd; | ||||
bdinfo_t *bd; | bdinfo_t *bd; | ||||
for (unit = 0; unit < MAXBDDEV; unit++) { | numfd = fd_count(); | ||||
for (unit = 0; unit < numfd; unit++) { | |||||
if ((bd = calloc(1, sizeof(*bd))) == NULL) | if ((bd = calloc(1, sizeof(*bd))) == NULL) | ||||
break; | break; | ||||
bd->bd_sectorsize = BIOSDISK_SECSIZE; | |||||
bd->bd_flags = BD_FLOPPY; | bd->bd_flags = BD_FLOPPY; | ||||
bd->bd_unit = unit; | bd->bd_unit = unit; | ||||
if (!bd_int13probe(bd)) { | |||||
/* Use std diskinfo for floppy drive */ | |||||
if (bd_get_diskinfo_std(bd) != 0) { | |||||
free(bd); | free(bd); | ||||
break; | break; | ||||
} | } | ||||
if (bd->bd_sectors == 0) | if (bd->bd_sectors == 0) | ||||
bd->bd_flags |= BD_NO_MEDIA; | bd->bd_flags |= BD_NO_MEDIA; | ||||
printf("BIOS drive %c: is %s%d\n", ('A' + unit), | printf("BIOS drive %c: is %s%d\n", ('A' + unit), | ||||
biosfd.dv_name, unit); | biosfd.dv_name, unit); | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* Return EDD version or 0 if EDD is not supported on this drive. | * Return EDD version or 0 if EDD is not supported on this drive. | ||||
*/ | */ | ||||
static int | static int | ||||
bd_check_extensions(int unit) | bd_check_extensions(int unit) | ||||
{ | { | ||||
/* do not use ext calls for floppy devices */ | |||||
if (unit < 0x80) | |||||
return (0); | |||||
/* Determine if we can use EDD with this device. */ | /* Determine if we can use EDD with this device. */ | ||||
v86.ctl = V86_FLAGS; | v86.ctl = V86_FLAGS; | ||||
v86.addr = 0x13; | v86.addr = 0x13; | ||||
v86.eax = 0x4100; | v86.eax = 0x4100; | ||||
v86.edx = unit; | v86.edx = unit; | ||||
v86.ebx = 0x55aa; | v86.ebx = 0x55aa; | ||||
v86int(); | v86int(); | ||||
▲ Show 20 Lines • Show All 887 Lines • Show Last 20 Lines |