disk: On BIOS, change how optical is determined
This commit is contained in:
parent
ce33e9dff3
commit
d265cad7b6
@ -126,6 +126,39 @@ int disk_read_sectors(struct volume *volume, void *buf, uint64_t block, size_t c
|
||||
return DISK_SUCCESS;
|
||||
}
|
||||
|
||||
static int disk_write_sectors(struct volume *volume, void *buf, uint64_t block, size_t count) {
|
||||
struct dap dap = {0};
|
||||
|
||||
if (count * volume->sector_size > XFER_BUF_SIZE)
|
||||
panic(false, "XFER");
|
||||
|
||||
if (xfer_buf == NULL)
|
||||
xfer_buf = conv_mem_alloc(XFER_BUF_SIZE);
|
||||
|
||||
dap.size = 16;
|
||||
dap.count = count;
|
||||
dap.segment = rm_seg(xfer_buf);
|
||||
dap.offset = rm_off(xfer_buf);
|
||||
dap.lba = block;
|
||||
|
||||
struct rm_regs r = {0};
|
||||
r.eax = 0x4301;
|
||||
r.edx = volume->drive;
|
||||
r.esi = (uint32_t)rm_off(&dap);
|
||||
r.ds = rm_seg(&dap);
|
||||
|
||||
if (buf != NULL)
|
||||
memcpy(xfer_buf, buf, count * volume->sector_size);
|
||||
|
||||
rm_int(0x13, &r, &r);
|
||||
|
||||
if (r.eflags & EFLAGS_CF) {
|
||||
return DISK_FAILURE;
|
||||
}
|
||||
|
||||
return DISK_SUCCESS;
|
||||
}
|
||||
|
||||
static bool detect_sector_size(struct volume *volume) {
|
||||
struct dap dap = {0};
|
||||
|
||||
@ -226,14 +259,14 @@ void disk_create_index(void) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (drive_params.info_flags & (1 << 2) && drive > 0x8f) {
|
||||
// The medium could not be present (e.g.: CD-ROMs)
|
||||
// Do a test run to see if we can actually read it
|
||||
if (disk_read_sectors(block, NULL, 0, 1) != DISK_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
if (disk_read_sectors(block, xfer_buf, 0, 1) != DISK_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
block->is_optical = disk_write_sectors(block, xfer_buf, 0, 1) != DISK_SUCCESS;
|
||||
|
||||
if (block->is_optical) {
|
||||
block->index = optical_indices++;
|
||||
block->is_optical = true;
|
||||
} else {
|
||||
block->index = hdd_indices++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user