Other small changes to disk driver

This commit is contained in:
mintsuki 2019-06-01 23:56:20 +02:00
parent bbfc5d36af
commit 3768a8cf2e
2 changed files with 8 additions and 15 deletions

View File

@ -17,16 +17,7 @@ static struct {
uint64_t lba;
} dap = { 16, 1, 0, 0, 0 };
static int check_results(struct rm_regs *out) {
int ah = (out->eax >> 8) & 0xFF;
if (ah)
print("Disk error %x\n", ah);
return ah;
}
int read_sector(int drive, int lba, int count, uint8_t *buffer) {
int read_sector(int drive, int lba, int count, void *buffer) {
dap.offset = (uint16_t)(size_t)sector_buf;
while (count--) {
@ -36,8 +27,12 @@ int read_sector(int drive, int lba, int count, uint8_t *buffer) {
r.edx = drive;
r.esi = (unsigned int)&dap;
rm_int(0x13, &r, &r);
if (check_results(&r))
return (r.eax >> 8) & 0xFF;
int ah = (r.eax >> 8) & 0xFF;
if (ah) {
print("Disk error %x\n", ah);
return ah;
}
memcpy(buffer, sector_buf, SECTOR_SIZE);

View File

@ -1,8 +1,6 @@
#ifndef __DISK_H__
#define __DISK_H__
#include <stdint.h>
int read_sector(int, int, int, uint8_t *);
int read_sector(int, int, int, void *);
#endif