Fixed disk handling

This commit is contained in:
Lucia Ceionia 2023-01-04 19:36:29 -06:00
parent 9aa56cdce2
commit 43e902e83c
7 changed files with 29 additions and 7 deletions

View File

@ -29,6 +29,9 @@ extern void v86DiskRead();
uint32_t DFS_ReadSector(uint8_t unit, uint8_t *buffer, uint32_t sector, uint32_t count) { uint32_t DFS_ReadSector(uint8_t unit, uint8_t *buffer, uint32_t sector, uint32_t count) {
v86disk_addr_packet.start_block = sector; v86disk_addr_packet.start_block = sector;
v86disk_addr_packet.blocks = count; v86disk_addr_packet.blocks = count;
v86disk_addr_packet.transfer_buffer =
(uintptr_t)buffer & 0x000F |
(((uintptr_t)buffer & 0xFFFF0) << 12);
FARPTR v86_entry = i386LinearToFp(v86DiskRead); FARPTR v86_entry = i386LinearToFp(v86DiskRead);
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry)); enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry));
return 0; return 0;

View File

@ -1,4 +1,3 @@
#pragma once
#include <stdint.h> #include <stdint.h>
struct interrupt_frame { struct interrupt_frame {

View File

@ -122,7 +122,7 @@ void TestDiskRead() {
} }
void TestFAT() { void TestFAT() {
word *vga_text = (word *)0xb8000; word *vga_text = (word *)0xb8000;
uint8_t *diskReadBuf = (uint8_t *)0x23000; uint8_t *diskReadBuf = (uint8_t *)0x22400;
for (int i = 0; i < 80*25; i++) for (int i = 0; i < 80*25; i++)
vga_text[i] = 0x0f00; vga_text[i] = 0x0f00;
VOLINFO vi; VOLINFO vi;
@ -143,7 +143,7 @@ void TestFAT() {
vga_text += printStr("PartType: ", vga_text); vga_text += printStr("PartType: ", vga_text);
vga_text += printByte(ptype, vga_text); vga_text += printByte(ptype, vga_text);
vga_text = (word *)((((((uintptr_t)vga_text)-0xb8000) - ((((uintptr_t)vga_text)-0xb8000) % 160)) + 160)+0xb8000); vga_text = (word *)((((((uintptr_t)vga_text)-0xb8000) - ((((uintptr_t)vga_text)-0xb8000) % 160)) + 160)+0xb8000);
asm ("xchgw %bx, %bx"); //asm ("xchgw %bx, %bx");
DFS_GetVolInfo(0, diskReadBuf, pstart, &vi); DFS_GetVolInfo(0, diskReadBuf, pstart, &vi);
vga_text += printStr("Label: ", vga_text); vga_text += printStr("Label: ", vga_text);
@ -167,7 +167,7 @@ void TestFAT() {
vga_text += printStr("ROOT@: ", vga_text); vga_text += printStr("ROOT@: ", vga_text);
vga_text += printDword(vi.rootdir, vga_text); vga_text += printDword(vi.rootdir, vga_text);
vga_text = (word *)((((((uintptr_t)vga_text)-0xb8000) - ((((uintptr_t)vga_text)-0xb8000) % 160)) + 160)+0xb8000); vga_text = (word *)((((((uintptr_t)vga_text)-0xb8000) - ((((uintptr_t)vga_text)-0xb8000) % 160)) + 160)+0xb8000);
asm ("xchgw %bx, %bx"); //asm ("xchgw %bx, %bx");
vga_text += printStr("Files in root:", vga_text); vga_text += printStr("Files in root:", vga_text);
DIRINFO di; DIRINFO di;
@ -182,9 +182,12 @@ void TestFAT() {
*(uint8_t *)vga_text = de.name[i]; *(uint8_t *)vga_text = de.name[i];
vga_text++; vga_text++;
} }
vga_text += printStr(" ", vga_text);
vga_text += printDec((uint32_t)de.filesize_0 + ((uint32_t)de.filesize_1 << 8) + ((uint32_t)de.filesize_2 << 16) + ((uint32_t)de.filesize_3 << 24), vga_text);
*(uint8_t*)vga_text++ = 'B';
vga_text = (word *)((((((uintptr_t)vga_text)-0xb8000) - ((((uintptr_t)vga_text)-0xb8000) % 160)) + 160)+0xb8000); vga_text = (word *)((((((uintptr_t)vga_text)-0xb8000) - ((((uintptr_t)vga_text)-0xb8000) % 160)) + 160)+0xb8000);
} }
asm ("xchgw %bx, %bx"); //asm ("xchgw %bx, %bx");
} }
} }

13
print.c
View File

@ -25,3 +25,16 @@ uintptr_t printStr(char *v, uint16_t *buff) {
*(char*)buff = *s; *(char*)buff = *s;
return s - v; return s - v;
} }
uintptr_t printDec(uint32_t v, uint16_t *buff) {
char b[12];
char *s = &b[11];
if (!v) {
*(uint16_t*)&b[10] = '0'; // '0',0x00
s = &b[10];
} else {
*s = 0;
for (;v;v/=10) *--s = '0' + v%10;
}
return printStr(s, buff);
}

View File

@ -1,7 +1,7 @@
#pragma once
#include <stdint.h> #include <stdint.h>
uintptr_t printByte(uint8_t v, uint16_t *buff); uintptr_t printByte(uint8_t v, uint16_t *buff);
uintptr_t printWord(uint16_t v, uint16_t *buff); uintptr_t printWord(uint16_t v, uint16_t *buff);
uintptr_t printDword(uint32_t v, uint16_t *buff); uintptr_t printDword(uint32_t v, uint16_t *buff);
uintptr_t printStr(char *v, uint16_t *buff); uintptr_t printStr(char *v, uint16_t *buff);
uintptr_t printDec(uint32_t v, uint16_t *buff);

1
tss.h
View File

@ -1,2 +1 @@
#pragma once
void setup_tss(); void setup_tss();

View File

@ -26,6 +26,7 @@ call real_hexprint
mov ax, dx mov ax, dx
call real_hexprint call real_hexprint
ret ret
global v86Test global v86Test
v86Test: v86Test:
mov ax, 0xb814 mov ax, 0xb814
@ -45,18 +46,21 @@ int 3
int 3 int 3
int 0x30 ; exit int 0x30 ; exit
jmp $ jmp $
global v86GfxMode global v86GfxMode
v86GfxMode: v86GfxMode:
mov ax, 0x13 mov ax, 0x13
int 0x10 int 0x10
int 0x30 int 0x30
jmp $ jmp $
global v86TextMode global v86TextMode
v86TextMode: v86TextMode:
mov ax, 0x3 mov ax, 0x3
int 0x10 int 0x10
int 0x30 int 0x30
jmp $ jmp $
global v86DiskRead global v86DiskRead
v86DiskRead: v86DiskRead:
xor ax, ax ; TODO fix assuming we're in first 64k xor ax, ax ; TODO fix assuming we're in first 64k
@ -73,6 +77,7 @@ db 0x10, 0x00 ; size, reserved
dw 0x1 ; blocks dw 0x1 ; blocks
dd 0x23000000 ; transfer buffer 0x23000 dd 0x23000000 ; transfer buffer 0x23000
dq 0x1 ; start block dq 0x1 ; start block
[BITS 32] [BITS 32]
; extern void enter_v86(uint32_t ss, uint32_t esp, uint32_t cs, uint32_t eip); ; extern void enter_v86(uint32_t ss, uint32_t esp, uint32_t cs, uint32_t eip);
global enter_v86 global enter_v86