BIOS loader fixups, should kinda work in vmware?

This commit is contained in:
K. Lange 2018-09-12 19:39:12 +09:00
parent e264fb3ab6
commit e6f8d0fae1
3 changed files with 18 additions and 14 deletions

View File

@ -197,25 +197,24 @@ _try_again:
outports(bus, command.command_words[i]);
}
uint16_t size_to_read = dev->atapi_sector_size;
for (int i = 0; i < sectors; ++i) {
while (1) {
uint8_t status = inportb(dev->io_base + ATA_REG_STATUS);
if ((status & ATA_SR_ERR)) goto atapi_error_on_read_setup_cmd;
if (!(status & ATA_SR_BSY) && (status & ATA_SR_DRQ)) break;
}
uint16_t size_to_read = inportb(bus + ATA_REG_LBA2) << 8;
size_to_read = size_to_read | inportb(bus + ATA_REG_LBA1);
while (1) {
uint8_t status = inportb(dev->io_base + ATA_REG_STATUS);
if ((status & ATA_SR_ERR)) goto atapi_error_on_read_setup_cmd;
if (!(status & ATA_SR_BSY) && (status & ATA_SR_DRQ)) break;
}
inportsm(bus,buf,size_to_read/2);
buf += 2048;
buf += size_to_read;
while (1) {
uint8_t status = inportb(dev->io_base + ATA_REG_STATUS);
if ((status & ATA_SR_ERR)) goto atapi_error_on_read_setup;
if (!(status & ATA_SR_BSY) && (status & ATA_SR_DRDY)) break;
}
while (1) {
uint8_t status = inportb(dev->io_base + ATA_REG_STATUS);
if ((status & ATA_SR_ERR)) goto atapi_error_on_read_setup;
if (!(status & ATA_SR_BSY) && (status & ATA_SR_DRDY)) break;
}
}
return;

View File

@ -1,7 +1,12 @@
[bits 16]
main:
jmp far 0x000:0x7c05
main2:
mov ax, 0x0000
mov ds, ax
mov ss, ax
mov ax, 0x7b00
mov sp, ax
mov ax, 0x0500
mov es, ax

View File

@ -487,7 +487,7 @@ done:
int i = dir_entry->extent_start_LSB;
int sectors = dir_entry->extent_length_LSB / 2048 + 1;
#define SECTORS 65536
#define SECTORS 512
while (sectors >= SECTORS) {
print_(".");
ata_device_read_sectors_atapi(device, i, (uint8_t *)KERNEL_LOAD_START + offset, SECTORS);