Added kernel disk reading test

This commit is contained in:
Lucia Ceionia 2022-09-19 19:46:26 -05:00
parent 606fc37e37
commit 8c309c6d9f
3 changed files with 60 additions and 24 deletions

View File

@ -102,17 +102,17 @@ void gpf_handler_v86(struct interrupt_frame *frame, unsigned long error_code) {
stack32 = (uint32_t*)stack; stack32 = (uint32_t*)stack;
char *vga = (char*)0xb8000 + (160 * 10); char *vga = (char*)0xb8000 + (160 * 10);
//vga[0] = 'I'; vga[2] = 'P'; int_printWord(frame->eip, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'I'; vga[2] = 'P'; int_printWord(frame->eip, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'C'; vga[2] = 'S'; int_printWord(frame->cs, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'C'; vga[2] = 'S'; int_printWord(frame->cs, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'F'; vga[2] = 'L'; int_printDword(frame->eflags, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'F'; vga[2] = 'L'; int_printDword(frame->eflags, (uint16_t*)&vga[4]); vga += 14;
//vga = (char*)0xb8000 + (160 * 11); vga = (char*)0xb8000 + (160 * 11);
//vga[0] = 'S'; vga[2] = 'P'; int_printWord(frame->esp, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'S'; vga[2] = 'P'; int_printWord(frame->esp, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'S'; vga[2] = 'S'; int_printWord(frame->ss, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'S'; vga[2] = 'S'; int_printWord(frame->ss, (uint16_t*)&vga[4]); vga += 14;
//vga = (char*)0xb8000 + (160 * 12); vga = (char*)0xb8000 + (160 * 12);
//vga[0] = 'E'; vga[2] = 'S'; int_printWord(frame->es, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'E'; vga[2] = 'S'; int_printWord(frame->es, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'D'; vga[2] = 'S'; int_printWord(frame->ds, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'D'; vga[2] = 'S'; int_printWord(frame->ds, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'F'; vga[2] = 'S'; int_printWord(frame->fs, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'F'; vga[2] = 'S'; int_printWord(frame->fs, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'G'; vga[2] = 'S'; int_printWord(frame->gs, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'G'; vga[2] = 'S'; int_printWord(frame->gs, (uint16_t*)&vga[4]); vga += 14;
//vga[2]++; //vga[2]++;
//printDword(frame, &vga[20]); //printDword(frame, &vga[20]);
@ -220,18 +220,18 @@ void gpf_handler_v86(struct interrupt_frame *frame, unsigned long error_code) {
} }
} }
done:; done:;
//vga = (char*)0xb8000 + (160 * 13); vga = (char*)0xb8000 + (160 * 13);
//vga[0] = 'I'; vga[2] = 'P'; int_printWord(frame->eip, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'I'; vga[2] = 'P'; int_printWord(frame->eip, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'C'; vga[2] = 'S'; int_printWord(frame->cs, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'C'; vga[2] = 'S'; int_printWord(frame->cs, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'F'; vga[2] = 'L'; int_printDword(frame->eflags, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'F'; vga[2] = 'L'; int_printDword(frame->eflags, (uint16_t*)&vga[4]); vga += 14;
//vga = (char*)0xb8000 + (160 * 14); vga = (char*)0xb8000 + (160 * 14);
//vga[0] = 'S'; vga[2] = 'P'; int_printWord(frame->esp, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'S'; vga[2] = 'P'; int_printWord(frame->esp, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'S'; vga[2] = 'S'; int_printWord(frame->ss, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'S'; vga[2] = 'S'; int_printWord(frame->ss, (uint16_t*)&vga[4]); vga += 14;
//vga = (char*)0xb8000 + (160 * 15); vga = (char*)0xb8000 + (160 * 15);
//vga[0] = 'E'; vga[2] = 'S'; int_printWord(frame->es, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'E'; vga[2] = 'S'; int_printWord(frame->es, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'D'; vga[2] = 'S'; int_printWord(frame->ds, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'D'; vga[2] = 'S'; int_printWord(frame->ds, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'F'; vga[2] = 'S'; int_printWord(frame->fs, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'F'; vga[2] = 'S'; int_printWord(frame->fs, (uint16_t*)&vga[4]); vga += 14;
//vga[0] = 'G'; vga[2] = 'S'; int_printWord(frame->gs, (uint16_t*)&vga[4]); vga += 14; vga[0] = 'G'; vga[2] = 'S'; int_printWord(frame->gs, (uint16_t*)&vga[4]); vga += 14;
} }
extern void timerHandler(); extern void timerHandler();

View File

@ -56,8 +56,12 @@ __attribute((__no_caller_saved_registers__))
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);
extern void v86Test(); extern void v86Test();
extern void v86GfxMode(); extern void v86GfxMode();
extern void v86TextMode();
extern void v86DiskRead();
__attribute((__no_caller_saved_registers__)) __attribute((__no_caller_saved_registers__))
extern char *jmp_usermode_test(); extern char *jmp_usermode_test();
__attribute((__no_caller_saved_registers__))
extern void kbd_wait();
/* /*
Real Mode Accessible (First MB) Real Mode Accessible (First MB)
@ -71,7 +75,8 @@ Real Mode Accessible (First MB)
20080 - 22080 TSS IOMAP (8kB) 20080 - 22080 TSS IOMAP (8kB)
22080 - 22400 Unused (896B) 22080 - 22400 Unused (896B)
22400 - 23000 Free (3kB) 22400 - 23000 Free (3kB)
23000 - 80000 Free (372kB) 23000 - 30000 Disk Buffer (52kB)
30000 - 80000 Free (320kB)
80000 - 90000 Real Mode Stack (64kB) 80000 - 90000 Real Mode Stack (64kB)
90000 - A0000 Free (64kB) 90000 - A0000 Free (64kB)
A0000 - FFFFF BIOS Area (384kB) A0000 - FFFFF BIOS Area (384kB)
@ -127,5 +132,15 @@ void start() {
for (int i = 0; i < 320; i++) { for (int i = 0; i < 320; i++) {
vga[i] = i; vga[i] = i;
} }
kbd_wait();
v86_entry = i386LinearToFp(v86TextMode);
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry));
v86_entry = i386LinearToFp(v86DiskRead);
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry));
vga_text = (word *)0xb8000;
char *bootloader = (char *)0x23000;
for (int i = 0; i < (80*25)/2; i++) {
printByte(bootloader[i], &vga_text[i*2]);
}
} }

View File

@ -51,6 +51,27 @@ mov ax, 0x13
int 0x10 int 0x10
int 0x30 int 0x30
jmp $ jmp $
global v86TextMode
v86TextMode:
mov ax, 0x3
int 0x10
int 0x30
jmp $
global v86DiskRead
v86DiskRead:
xor ax, ax ; TODO fix assuming we're in first 64k
mov ds, ax
mov ah, 0x42
mov dl, 0x80 ; TODO get this from BIOS or something
mov si, v86disk_addr_packet ; ds:si
int 0x13
int 0x30
jmp $
v86disk_addr_packet:
db 0x10, 0x00 ; size, reserved
dw 0x20 ; blocks
dd 0x23000000 ; transfer buffer 0x23000
dq 0 ; 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