Add disk write support
This commit is contained in:
parent
9396931592
commit
a0fa0361ae
|
@ -206,7 +206,9 @@ int bus_io_write(void *user, uint32_t value, uint32_t port) {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
case 0x40: {
|
case 0x40: {
|
||||||
// TODO: write specified disk sector from memory
|
// write specified disk sector from memory
|
||||||
|
set_disk_sector(id, value);
|
||||||
|
write_disk_from_memory(id);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
case 0x50: {
|
case 0x50: {
|
||||||
|
|
|
@ -52,3 +52,8 @@ size_t read_disk_into_memory(size_t id) {
|
||||||
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return 0; }
|
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return 0; }
|
||||||
return fread(&vm.memory_ram[disk_controller.buffer_pointer], 1, 512, disk_controller.disks[id].file);
|
return fread(&vm.memory_ram[disk_controller.buffer_pointer], 1, 512, disk_controller.disks[id].file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t write_disk_from_memory(size_t id) {
|
||||||
|
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return 0; }
|
||||||
|
return fwrite(&vm.memory_ram[disk_controller.buffer_pointer], 1, 512, disk_controller.disks[id].file);
|
||||||
|
}
|
||||||
|
|
|
@ -16,3 +16,4 @@ void remove_disk(size_t id);
|
||||||
uint64_t get_disk_size(size_t id);
|
uint64_t get_disk_size(size_t id);
|
||||||
void set_disk_sector(size_t id, uint64_t sector);
|
void set_disk_sector(size_t id, uint64_t sector);
|
||||||
size_t read_disk_into_memory(size_t id);
|
size_t read_disk_into_memory(size_t id);
|
||||||
|
size_t write_disk_from_memory(size_t id);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user