I'm trying to get a basic floppy driver operational to allow me to read my Command Line from disk into memory. Now most parts of the driver work (recalibrate, seek, Activating/Deactivating motor), yet the actual read seems to fail. I have tried to fix the problem but I can't seem to find the problem. Maybe someone else does?
DMA code:
Code: Select all
.INIT:
mov al,0x06 ;DMA channel 2 Mask
out 0x0A,al ;Mask the Bastard
mov al,0xFF
out 0xD8,al ;Set Master Flip-Flop
mov eax,ebx
out 0x04,al ;low address of buffer
mov al,ah
out 0x04,al ;high address of buffer
mov al,0xFF
out 0xD8,al ;Length Master Flip-Flop
out 0x05,al ;Low count of Sector - 1
mov al,0x01
out 0x05,al ;high count of sector - 1
mov al,dl
mov al,0x01
out 0x81,al ;Page Register number
mov al,0x02
out 0x0a,al ;unmask the bastard
ret ;return to calling procedure
.READFLOPPY:
mov al,0x06 ;DMA channel 2 Mask
out 0x0A,al ;Mask the Bastard
mov al,0x46 ;Single Transfer, To Mem, CH2
out 0x0b,al ;output to port
mov al,0x02
out 0x0a,al ;unmask the bastard
ret ;return to calling procedure
Floppy Read Function:
Code: Select all
.READ:
push eax
push ebx
push ecx
push edx
mov al,'N'
call [0x20028]
mov dx,FD.FIFO ;Port Address
call .CHREADY ;Check if FIFO is ready
mov al,'9'
call [0x20028]
mov al,0x46 ;Read Sector Command
out dx,al
mov al,0x00 ;Disk 0
out dx,al
out dx,al ;Cylinder
out dx,al ;Head
mov al,bl ;Sector Number
out dx,al
mov al,0x02 ;Sector = 512 bytes
out dx,al ;SectorSize
mov al,bl
inc al
out dx,al ;Last Sector Of Track
mov al,0x1B
out dx,al ;Gap Length
mov al,0xFF
out dx,al ;Obsolete Hardware Requirement
call .RSN
mov ecx,0x07
.READFIN:
call .RECEIVED
loop .READFIN
mov al,'M'
call [0x20028]
pop edx
pop ecx
pop ebx
pop eax
ret
Code: Select all
.RSN:
mov al,[FINT]
cmp al,0xFF
jne .SNI
mov ax,FD.FIFO
mov dx,ax
mov al,'8'
call [0x20028]
mov al,0x08
call .CHREADY
out dx,al
mov al,'Z'
call [0x20028]
xor al,al
mov [FINT],al
ret
.CHREADY:
push eax
push edx
mov dx,FD.DRIVE_CONTROLLER_STATUS
.CH:
in al,dx
and al,0xC0
cmp al,0x80
jne .CH
pop edx
pop eax
ret
.RECEIVED:
push eax
push edx
mov dx,FD.DRIVE_CONTROLLER_STATUS
.RC:
in al,dx
and al,0xC0
cmp al,0xC0
jne .RC
mov dx,FD.FIFO
in al,dx
pop edx
pop eax
ret
(call [0x20028] is a a system call)