File System Issues
Posted: Wed Apr 25, 2018 2:57 pm
Hey, this is my first time here and I was wondering if anyone could give me some help setting up the file system. So far I've set up the BPB with the FAT12 File system and written some small amount of code that looks for the root directory in a set location and searches the table for the kernel file. I then write the code to the boot sector of a floppy drive and insert the floppy drive into a windows computer but the computer reports back that the disk doesn't have a filesystem. I'm not sure what I've done wrong but here is my actual code.
This was compiled by nasm and when emulated in QEMU, I get the Disk read error.
Any help would be great. Thanks.
Code: Select all
org 0x7C00
jmp near Boot
nop
bpbBytesPerSector: DW 512
bpbSectorsPerCluster: DB 1
bpbReservedSectors: DW 1
bpbNumberOfFATs: DB 2
bpbRootEntries: DW 224
bpbTotalSectors: DW 2880
bpbMedia: DB 0xF0
bpbSectorsPerFAT: DW 9
bpbSectorsPerTrack: DW 18
bpbHeadsPerCylinder: DW 2
bpbHiddenSectors: DD 0
bpbTotalSectorsBig: DD 0
bsDriveNumber: DB 0
bsUnused: DB 0
bsExtBootSignature: DB 0x29
bsSerialNumber: DD 0xa0a1a2a3
bsVolumeLabel: DB "TSO "
bsFileSystem: DB "FAT12 "
Boot:
cli
mov ax, 0x0000
mov es, ax
mov dx, ax
mov ss, ax
mov sp, 0x7C00
mov bp, 0x0500
sti
ReadDisk:
mov ah, 0x02
mov al, 13 ;how many sectors to read
mov cl, 19 ;Starting sector
mov ch, 0 ;cylinder
mov dh, 0 ;head
mov dl, 0x80 ;Floppy Drive
mov bx, 0x7E00 ;ES:BX 0x0000:0x7E00
int 0x13
jc _DiskReadError
mov cx, 8
mov di, 0x7E00
mov si, KERNEL
jmp ReadFAT
_DiskReadError:
mov si, READERR
jmp BPrint
ReadFAT:
cmp si, di
jne _NotFound
inc si
inc di
dec cx
cmp cx, 0
je _LoadEntry
jne ReadFAT
_LoadEntry:
mov si, KERF
jmp BPrint
_NotFound:
mov si, KERNF
jmp BPrint
BPrint:
mov ah, 0x0E
_BPrintLoop:
lodsb
cmp al, 0
je _BDone
int 0x10
jmp _BPrintLoop
_BDone:
cli
hlt
READERR db '!!ATTENTION!! - Disk Read Error. The system has been halted to prevent damage.', 0x0A, 0x0D, 0
KERNF db '!!ATTENTION!! - No Kernel [TerSysVI.bin] found. The system has been halted to prevent damage.', 0x0A, 0x0D, 0
KERNEL db 'TerSysVI BIN'
KERF db 'Kernel found. Loading Kernel from disk...', 0x0A, 0x0D, 0
times 510 - ($-$$) db 0
dw 0xAA55
Any help would be great. Thanks.