Fixed disk handling
This commit is contained in:
		@@ -29,6 +29,9 @@ extern void v86DiskRead();
 | 
			
		||||
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.blocks = count;
 | 
			
		||||
	v86disk_addr_packet.transfer_buffer =
 | 
			
		||||
		(uintptr_t)buffer & 0x000F |
 | 
			
		||||
		(((uintptr_t)buffer & 0xFFFF0) << 12);
 | 
			
		||||
    FARPTR v86_entry = i386LinearToFp(v86DiskRead);
 | 
			
		||||
    enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry));
 | 
			
		||||
	return 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
struct interrupt_frame {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								kernel.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								kernel.c
									
									
									
									
									
								
							@@ -122,7 +122,7 @@ void TestDiskRead() {
 | 
			
		||||
}
 | 
			
		||||
void TestFAT() {
 | 
			
		||||
    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++)
 | 
			
		||||
        vga_text[i] = 0x0f00;
 | 
			
		||||
    VOLINFO vi;
 | 
			
		||||
@@ -143,7 +143,7 @@ void TestFAT() {
 | 
			
		||||
    vga_text += printStr("PartType: ", vga_text);
 | 
			
		||||
    vga_text += printByte(ptype, vga_text);
 | 
			
		||||
    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);
 | 
			
		||||
    vga_text += printStr("Label: ", vga_text);
 | 
			
		||||
@@ -167,7 +167,7 @@ void TestFAT() {
 | 
			
		||||
    vga_text += printStr("ROOT@: ", 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);
 | 
			
		||||
    asm ("xchgw %bx, %bx");
 | 
			
		||||
    //asm ("xchgw %bx, %bx");
 | 
			
		||||
 | 
			
		||||
    vga_text += printStr("Files in root:", vga_text);
 | 
			
		||||
    DIRINFO di;
 | 
			
		||||
@@ -182,9 +182,12 @@ void TestFAT() {
 | 
			
		||||
                *(uint8_t *)vga_text = de.name[i];
 | 
			
		||||
                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);
 | 
			
		||||
        }
 | 
			
		||||
        asm ("xchgw %bx, %bx");
 | 
			
		||||
        //asm ("xchgw %bx, %bx");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								print.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								print.c
									
									
									
									
									
								
							@@ -25,3 +25,16 @@ uintptr_t printStr(char *v, uint16_t *buff) {
 | 
			
		||||
        *(char*)buff = *s;
 | 
			
		||||
    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);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								print.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								print.h
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
uintptr_t printByte(uint8_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 printStr(char *v, uint16_t *buff);
 | 
			
		||||
uintptr_t printDec(uint32_t v, uint16_t *buff);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								v86.nasm
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								v86.nasm
									
									
									
									
									
								
							@@ -26,6 +26,7 @@ call real_hexprint
 | 
			
		||||
mov ax, dx
 | 
			
		||||
call real_hexprint
 | 
			
		||||
ret
 | 
			
		||||
 | 
			
		||||
global v86Test
 | 
			
		||||
v86Test:
 | 
			
		||||
mov ax, 0xb814
 | 
			
		||||
@@ -45,18 +46,21 @@ int 3
 | 
			
		||||
int 3
 | 
			
		||||
int 0x30 ; exit
 | 
			
		||||
jmp $
 | 
			
		||||
 | 
			
		||||
global v86GfxMode
 | 
			
		||||
v86GfxMode:
 | 
			
		||||
mov ax, 0x13
 | 
			
		||||
int 0x10
 | 
			
		||||
int 0x30
 | 
			
		||||
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
 | 
			
		||||
@@ -73,6 +77,7 @@ db 0x10, 0x00 ; size, reserved
 | 
			
		||||
dw 0x1 ; blocks
 | 
			
		||||
dd 0x23000000 ; transfer buffer 0x23000
 | 
			
		||||
dq 0x1 ; start block
 | 
			
		||||
 | 
			
		||||
[BITS 32]
 | 
			
		||||
; extern void enter_v86(uint32_t ss, uint32_t esp, uint32_t cs, uint32_t eip);
 | 
			
		||||
global enter_v86
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user