[Solved] FDC - Read not working on real hardware

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

[Solved] FDC - Read not working on real hardware

Post by onlyonemac »

Hi!

A little while back I was trying to read floppies by dropping back to real mode and using BIOS; now I'm trying an FDC mini-driver.

Code: Select all

	;Set up the DMA
	mov	al, #0x06
	outb	0x0A, al	;Mask DMA channel 2 (FDC)
	mov	al, #0xFF
	outb	0x0C, al	;Reset the flip-flop
	mov	ax, #0x6000
	outb	0x04, al	;Set the base address
	mov	al, ah
	outb	0x04, al
	mov	al, #0xFF
	outb	0x0C, al	;Reset the flip-flop
	mov	ax, #0x23FF
	outb	0x05, al	;Set the byte count (512 bytes = 1 sector)
	mov	al, ah
	outb	0x05, al
	mov	al, #0x00
	outb	0x81, al	;Highest byte of base address
	mov	al, #0x46
	outb	0x0B, al	;Set mode for reading
	mov	al, #0x02
	outb	0x0A, al	;Unmask DMA channel 2

	;Set up the FDC
	mov	ax, #0x0008
	mov	ds, ax
	mov	[510], #0x41
	mov	[511], #0x71
	call	initmessage

	mov	al, #0x13
	call	sendcommand	;Send configure command (this one is required to confirm the state of drive polling mode)
	mov	al, #0x00
	call	sendcommand	;Send 0 parameter
	mov	al, #0x47
	call	sendcommand	;Send options (Implied Seek, FIFO Threshold = 8)
	mov	al, #0x00
	call	sendcommand	;Send precompensation (0 = Default)

	call	progressmessage

	call	preparewaitirq

	mov	al, #0x0C
	mov	dx, #0x03F2
	outb	dx, al	;Set DOR (Drive 0, Motor 0 off, use IRQ/DMA)
	mov	al, #0x80
	mov	dx, #0x03F4
	outb	dx, al	;Set DSR (1.44 MB, Reset)

	call	progressmessage

	call	waitirq

	call	progressmessage

	mov	al, #0x08
	call	sendcommand	;Send sense interrupt (required after reset)
	call	getresult	;Dump result byte 1
	call	getresult	;Dump result byte 2

	call	progressmessage

	mov	al, #0x08
	call	sendcommand	;Send sense interrupt (required after reset)
	call	getresult	;Dump result byte 1
	call	getresult	;Dump result byte 2

	call	progressmessage

	mov	al, #0x08
	call	sendcommand	;Send sense interrupt (required after reset)
	call	getresult	;Dump result byte 1
	call	getresult	;Dump result byte 2

	call	progressmessage

	mov	al, #0x08
	call	sendcommand	;Send sense interrupt (required after reset)
	call	getresult	;Dump result byte 1
	call	getresult	;Dump result byte 2

	call	progressmessage

	mov	al, #0x13
	call	sendcommand	;Send configure command (this is the one we actually want)
	mov	al, #0x00
	call	sendcommand	;Send parameter 1 (always 0)
	mov	al, #0x47
	call	sendcommand	;Send parameter 2 (Implied Seek, FIFO Threshold = 8)
	mov	al, #0x00
	call	sendcommand	;Send parameter 3 (precompensation; 0 = Default)

	call	progressmessage

	mov	al, #0x00
	mov	dx, #0x03F4
	outb	dx, al	;Set DSR (1.44 MB)

	call	progressmessage

	mov	al, #0x03
	call	sendcommand	;Send specify command
	mov	al, #0x8F
	call	sendcommand	;Send parameter 1 (SRT = 8ms, HUT = 240ms)
	mov	al, #0x0A
	call	sendcommand	;Send parameter 2 (HLT = 10ms, NDMA off = use DMA)

	call	progressmessage

	mov	al, #0x1C
	mov	dx, #0x03F2
	outb	dx, al	;Set DOR (Drive 0, Motor 0 on, use IRQ/DMA)

	call	progressmessage

	;Read the sector

	mov	ax, #0x0050
	mov	ds, ax
	mov	al, #0x00
	mov	[1], al
	waittimer:
	mov	al, [1]
	cmp	al, #0x0F	;0x0A
	jnz	waittimer

	call	progressmessage

	;call	preparewaitirq

	;mov	al, #0x0F
	;call	sendcommand	;Send seek command
	;mov	al, #0x00
	;call	sendcommand	;Send parameter 1 (H << 2 | D - must match current drive selection in DOR)
	;mov	al, #0x4F
	;call	sendcommand	;Send parameter 2 (Track)

	;call	progressmessage

	;call	waitirq

	;call	progressmessage

	;mov	al, #0x08
	;call	sendcommand	;Send sense interrupt (required after seek)
	;call	getresult	;Dump result byte 1
	;call	getresult	;Dump result byte 2

	;call	progressmessage

	;call	preparewaitirq

	;mov	al, #0x0F
	;call	sendcommand	;Send seek command
	;mov	al, #0x00
	;call	sendcommand	;Send parameter 1 (H << 2 | D - must match current drive selection in DOR)
	;mov	al, #0x00
	;call	sendcommand	;Send parameter 2 (Track)

	;call	progressmessage

	;call	waitirq

	;call	progressmessage

	;mov	al, #0x08
	;call	sendcommand	;Send sense interrupt (required after seek)
	;call	getresult	;Dump result byte 1
	;call	getresult	;Dump result byte 2

	;call	progressmessage

	call	preparewaitirq

	mov	al, #0x46
	call	sendcommand	;Send read command (with MFM bit)
	mov	al, #0x00
	call	sendcommand	;Send parameter 1 (H << 2 | D - must match current drive selection in DOR)
	mov	al, #0x00
	call	sendcommand	;Send parameter 2 (Track)
	mov	al, #0x00
	call	sendcommand	;Send parameter 3 (H - must match previous H)
	mov	al, #0x01
	call	sendcommand	;Send parameter 4 (Start Sector)
	mov	al, #0x02
	call	sendcommand	;Send parameter 5 (Bytes per sector; 2 = 512)
	mov	al, #0x12
	call	sendcommand	;Send parameter 6 (Number of sectors)
	mov	al, #0x1B
	call	sendcommand	;Send parameter 7 (Gap size; 1B = default for 3 1/2 inch drive)
	mov	al, #0xFF
	call	sendcommand	;Send parameter 8 (always FF)

	call	progressmessage

	call	waitirq

	call	progressmessage

	call	getresult	;Dump result byte 1
	call	getresult	;Dump result byte 2
	call	getresult	;Dump result byte 3
	call	getresult	;Dump result byte 4
	call	getresult	;Dump result byte 5
	call	getresult	;Dump result byte 6
	call	getresult	;Dump result byte 7

	call	progressmessage

	;Turn the motor off
	mov	al, #0x0C
	mov	dx, #0x03F2
	outb	dx, al	;Set DOR (Drive 0, Motor 0 off, use IRQ/DMA)

	call	progressmessage

	;Disable interrupts (the caller probably assumes that we will leave interrupts as we found them)
	;cli

	;Restore previous interrupt mask
	pop	ax
	outb	#0xA1, al
	pop	ax
	outb	#0x21, al

	call	progressmessage

	;Pop registers
	pop	ax
	mov	gs, ax
	pop	ax
	mov	fs, ax
	pop	ax
	mov	es, ax
	pop	ax
	mov	ds, ax
	pop	edx
	pop	ecx
	pop	ebx
	pop	eax
	ret

;Subroutine to prepare for waiting for an IRQ 6
	preparewaitirq:

	push	ax
	mov	ax, ds
	push 	ax
	mov	ax, #0x0050
	mov	ds, ax
	mov	al, #0x01
	mov	[0], al		;Set the IRQ 38 (FDC IRQ) flag
	pop	ax
	mov	ds, ax
	pop	ax
	ret

;Subroutine to wait for an IRQ 6
	waitirq:

	push	ax
	mov	ax, ds
	push 	ax
	mov	ax, #0x0008
	mov	ds, ax
	mov	[600], #0x41
	mov	[601], #0x71
	mov	ax, #0x0050
	mov	ds, ax
	waitloop:
	mov	al, [0]
	cmp	al, #0x00
	jnz	waitloop
	pop	ax
	mov	ds, ax
	pop	ax
	ret

;Subroutine to send the byte in register al to the FDC (handles RQM and all that)
	sendcommand:

	push	dx
	push	ax
	mov	ax, ds
	push	ax
	mov	ax, #0x0008
	mov	ds, ax
	mov	[600], #0x42
	mov	[601], #0x71
	mov	dx, #0x03F4
	inb	al, dx
	and	al, #0x80
	cmp	al, #0x00
	pop	ax
	mov	ds, ax
	pop	ax
	pop	dx
	jz	sendcommand
	push	dx
	mov	dx, #0x03F5
	outb	dx, al
	pop	dx
	ret

;Subroutine to return a result byte from a command in register al (handles RQM and all that)
	getresult:

	push	dx
	push	ax
	mov	dx, #0x03F4
	inb	al, dx
	and	al, #0x80
	cmp	al, #0x00
	pop	ax
	pop	dx
	jz	getresult
	push	dx
	mov	dx, #0x03F5
	inb	al, dx
	pop	dx
	ret

	initmessage:

	push	ax
	mov	ax, ds
	push	ax
	mov	ax, #0x0008
	mov	ds, ax
	mov	[500], #0x41
	mov	[501], #0x71
	pop	ax
	mov	ds, ax
	pop	ax
	ret

	progressmessage:

	push	ax
	mov	ax, ds
	push	ax
	mov	ax, #0x0008
	mov	ds, ax
	mov	al, [500]
	inc	al
	mov	[500], al
	mov	[501], #0x71
	pop	ax
	mov	ds, ax
	pop	ax
	ret
Excuse the messy code (watch out for the bits which are commented out).

Anyway, the problem is that when I run this on Bochs and Qemu it works, but on real hardware it runs without crashing but it doesn't return the data.

Any ideas? I've compared the code to a few tutorials and checked it against documentation but it's still not working.

Thanks,

onlyonemac
Last edited by onlyonemac on Sun Apr 20, 2014 12:46 pm, edited 1 time in total.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
BASICFreak
Member
Member
Posts: 284
Joined: Fri Jan 16, 2009 8:34 pm
Location: Louisiana, USA

Re: FDC - Read not working on real hardware

Post by BASICFreak »

onlyonemac wrote:Hi!

A little while back I was trying to read floppies by dropping back to real mode and using BIOS; now I'm trying an FDC mini-driver.

...

Excuse the messy code (watch out for the bits which are commented out).

Anyway, the problem is that when I run this on Bochs and Qemu it works, but on real hardware it runs without crashing but it doesn't return the data.

Any ideas? I've compared the code to a few tutorials and checked it against documentation but it's still not working.

Thanks,

onlyonemac
I have not read your code, but one thing I have found while working on mine is real hardware produces errors (especially floppy drive) check each function for error

Really interested in this one too, will keep an eye out for the both of us.




P.S. I haven't got mine running yet
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
Sortie wrote:
  • Don't play the role of an operating systems developer, be one.
  • Be truly afraid of undefined [behavior].
  • Your operating system should be itself, not fight what it is.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: FDC - Read not working on real hardware

Post by onlyonemac »

I didn't bother with error-checking code just yet, because I reasoned that surely if I tried the code a few times it would work at least once? I've tried it many times in many variations and it's never worked - not even once - and the floppy I'm using is good, so I doubt there's any errors.

I'll try that anyway though, if no one finds any other problems with it.

I'm actually suspecting that the problem lies more in the DMA code than in the FDC code, but DMA's really easy peasy so I can't see what I could have done wrong!
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: FDC - Read not working on real hardware

Post by onlyonemac »

I've checked the following code and on Bochs it returns 0, 0, 0, 0, 0, 3, 2 as the result of the read (which is as expected) but on real hardware it gives 0, 4, 16, 0, 0, 2, 2 (which not only indicates that it didn't read anything but that apparently my disk and drive are bad!).

Code: Select all

	;Set up the DMA
	mov	al, #0x06
	outb	0x0A, al	;Mask DMA channel 2 (FDC)
	mov	al, #0xFF
	outb	0x0C, al	;Reset the flip-flop
	mov	ax, #0x6000
	outb	0x04, al	;Set the base address
	mov	al, ah
	outb	0x04, al
	mov	al, #0xFF
	outb	0x0C, al	;Reset the flip-flop
	mov	ax, #0x01FF <-THIS LINE HAS CHANGED
	outb	0x05, al	;Set the byte count (512 bytes = 1 sector)
	mov	al, ah
	outb	0x05, al
	mov	al, #0x00
	outb	0x81, al	;Highest byte of base address
	mov	al, #0x46
	outb	0x0B, al	;Set mode for reading
	mov	al, #0x02
	outb	0x0A, al	;Unmask DMA channel 2

	;Set up the FDC
	mov	ax, #0x0008
	mov	ds, ax
	mov	[510], #0x41
	mov	[511], #0x71
	call	initmessage

	mov	al, #0x13
	call	sendcommand	;Send configure command (this one is required to confirm the state of drive polling mode)
	mov	al, #0x00
	call	sendcommand	;Send 0 parameter
	mov	al, #0x47
	call	sendcommand	;Send options (Implied Seek, FIFO Threshold = 8)
	mov	al, #0x00
	call	sendcommand	;Send precompensation (0 = Default)

	call	progressmessage

	call	preparewaitirq

	mov	al, #0x0C
	mov	dx, #0x03F2
	outb	dx, al	;Set DOR (Drive 0, Motor 0 off, use IRQ/DMA)
	mov	al, #0x80
	mov	dx, #0x03F4
	outb	dx, al	;Set DSR (1.44 MB, Reset)

	call	progressmessage

	call	waitirq

	call	progressmessage

	mov	al, #0x08
	call	sendcommand	;Send sense interrupt (required after reset)
	call	getresult	;Dump result byte 1
	call	getresult	;Dump result byte 2

	call	progressmessage

	mov	al, #0x08
	call	sendcommand	;Send sense interrupt (required after reset)
	call	getresult	;Dump result byte 1
	call	getresult	;Dump result byte 2

	call	progressmessage

	mov	al, #0x08
	call	sendcommand	;Send sense interrupt (required after reset)
	call	getresult	;Dump result byte 1
	call	getresult	;Dump result byte 2

	call	progressmessage

	mov	al, #0x08
	call	sendcommand	;Send sense interrupt (required after reset)
	call	getresult	;Dump result byte 1
	call	getresult	;Dump result byte 2

	call	progressmessage

	mov	al, #0x13
	call	sendcommand	;Send configure command (this is the one we actually want)
	mov	al, #0x00
	call	sendcommand	;Send parameter 1 (always 0)
	mov	al, #0x47
	call	sendcommand	;Send parameter 2 (Implied Seek, FIFO Threshold = 8)
	mov	al, #0x00
	call	sendcommand	;Send parameter 3 (precompensation; 0 = Default)

	call	progressmessage

	mov	al, #0x00
	mov	dx, #0x03F4
	outb	dx, al	;Set DSR (1.44 MB)

	call	progressmessage

	mov	al, #0x03
	call	sendcommand	;Send specify command
	mov	al, #0x8F
	call	sendcommand	;Send parameter 1 (SRT = 8ms, HUT = 240ms)
	mov	al, #0x0A
	call	sendcommand	;Send parameter 2 (HLT = 10ms, NDMA off = use DMA)

	call	progressmessage

	mov	al, #0x1C
	mov	dx, #0x03F2
	outb	dx, al	;Set DOR (Drive 0, Motor 0 on, use IRQ/DMA)

	call	progressmessage

	;Read the sector

	mov	ax, #0x0050
	mov	ds, ax
	mov	al, #0x00
	mov	[1], al
	waittimer:
	mov	al, [1]
	cmp	al, #0x0F	;0x0A
	jnz	waittimer

	call	progressmessage

	call	preparewaitirq

	mov	al, #0x46
	call	sendcommand	;Send read command (with MFM bit)
	mov	al, #0x00
	call	sendcommand	;Send parameter 1 (H << 2 | D - must match current drive selection in DOR)
	mov	al, #0x00
	call	sendcommand	;Send parameter 2 (Track)
	mov	al, #0x00
	call	sendcommand	;Send parameter 3 (H - must match previous H)
	mov	al, #0x02
	call	sendcommand	;Send parameter 4 (Start sector)
	mov	al, #0x02
	call	sendcommand	;Send parameter 5 (Bytes per sector; 2 = 512)
	mov	al, #0x12 <-THIS LINE HAS CHANGED
	call	sendcommand	;Send parameter 6 (End sector)
	mov	al, #0x1B
	call	sendcommand	;Send parameter 7 (Gap size; 1B = default for 3 1/2 inch drive)
	mov	al, #0xFF
	call	sendcommand	;Send parameter 8 (always FF)

	call	progressmessage

	call	waitirq

	call	progressmessage

	mov	ax, #0x0008
	mov	ds, ax
	mov	[698], #0x7141

	call	getresult	;Dump result byte 1
	mov	[700], al
	call	getresult	;Dump result byte 2
	mov	[702], al
	call	getresult	;Dump result byte 3
	mov	[704], al
	call	getresult	;Dump result byte 4
	mov	[706], al
	call	getresult	;Dump result byte 5
	mov	[708], al
	call	getresult	;Dump result byte 6
	mov	[710], al
	call	getresult	;Dump result byte 7
	mov	[712], al
	mov	[714], #0x7141

	call	progressmessage

	;Turn the motor off
	mov	al, #0x0C
	mov	dx, #0x03F2
	outb	dx, al	;Set DOR (Drive 0, Motor 0 off, use IRQ/DMA)

	call	progressmessage

	;Disable interrupts (the caller probably assumes that we will leave interrupts as we found them)
	;cli

	;Restore previous interrupt mask
	pop	ax
	outb	#0xA1, al
	pop	ax
	outb	#0x21, al

	call	progressmessage

	;Pop registers
	pop	ax
	mov	gs, ax
	pop	ax
	mov	fs, ax
	pop	ax
	mov	es, ax
	pop	ax
	mov	ds, ax
	pop	edx
	pop	ecx
	pop	ebx
	pop	eax
	ret

;Subroutine to prepare for waiting for an IRQ 6
	preparewaitirq:

	push	ax
	mov	ax, ds
	push 	ax
	mov	ax, #0x0050
	mov	ds, ax
	mov	al, #0x01
	mov	[0], al		;Set the IRQ 38 (FDC IRQ) flag
	pop	ax
	mov	ds, ax
	pop	ax
	ret

;Subroutine to wait for an IRQ 6
	waitirq:

	push	ax
	mov	ax, ds
	push 	ax
	mov	ax, #0x0008
	mov	ds, ax
	mov	[600], #0x41
	mov	[601], #0x71
	mov	ax, #0x0050
	mov	ds, ax
	waitloop:
	mov	al, [0]
	cmp	al, #0x00
	jnz	waitloop
	pop	ax
	mov	ds, ax
	pop	ax
	ret

;Subroutine to send the byte in register al to the FDC (handles RQM and all that)
	sendcommand:

	push	dx
	push	ax
	mov	ax, ds
	push	ax
	mov	ax, #0x0008
	mov	ds, ax
	mov	[600], #0x42
	mov	[601], #0x71
	mov	dx, #0x03F4
	inb	al, dx
	and	al, #0x80
	cmp	al, #0x00
	pop	ax
	mov	ds, ax
	pop	ax
	pop	dx
	jz	sendcommand
	push	dx
	mov	dx, #0x03F5
	outb	dx, al
	pop	dx
	ret

;Subroutine to return a result byte from a command in register al (handles RQM and all that)
	getresult:

	push	dx
	push	ax
	mov	dx, #0x03F4
	inb	al, dx
	and	al, #0x80
	cmp	al, #0x00
	pop	ax
	pop	dx
	jz	getresult
	push	dx
	mov	dx, #0x03F5
	inb	al, dx
	pop	dx
	ret

	initmessage:

	push	ax
	mov	ax, ds
	push	ax
	mov	ax, #0x0008
	mov	ds, ax
	mov	[500], #0x41
	mov	[501], #0x71
	pop	ax
	mov	ds, ax
	pop	ax
	ret

	progressmessage:

	push	ax
	mov	ax, ds
	push	ax
	mov	ax, #0x0008
	mov	ds, ax
	mov	al, [500]
	inc	al
	mov	[500], al
	mov	[501], #0x71
	pop	ax
	mov	ds, ax
	pop	ax
	ret
I changed the DMA count and the FDC "track length", because it seems as though this is how other people read a single sector.

Any ideas?
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: FDC - Read not working on real hardware

Post by onlyonemac »

I checked the data sheet and it seems as though both of those register values indicate some problem with reading the ID fields. Could this mean I'm not giving the motor long enough to spin up? (Although I've calculated that it is long enough - I'll try giving it something stupid like 2 seconds to spin up and if that doesn't work then I'm really stuck!)
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: FDC - Read not working on real hardware

Post by onlyonemac »

Well I've given it a good five seconds to spin up and I get the exact same result - any more ideas?
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: FDC - Read not working on real hardware

Post by onlyonemac »

Bump. It's still not working, and I don't think the DMA code is at fault.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
BASICFreak
Member
Member
Posts: 284
Joined: Fri Jan 16, 2009 8:34 pm
Location: Louisiana, USA

Re: FDC - Read not working on real hardware

Post by BASICFreak »

onlyonemac wrote:Bump. It's still not working, and I don't think the DMA code is at fault.
I'm trying to get mine up when/if I get a conclusion I'll let you know. Currently as stands our issues are identical just two different languages.

I'll try to comb through your code while I'm at it, but from glance it looks like its the same (used loosely)

Side note: is there an emulator/virtualizer with a "real hardware" compatible FDC because Bochs, MSVPC and VMWare all work flawlessly when real hardware will fail. I'm starting to get tired of switching my KB and Monitor back and forth. (need a KVM)
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
Sortie wrote:
  • Don't play the role of an operating systems developer, be one.
  • Be truly afraid of undefined [behavior].
  • Your operating system should be itself, not fight what it is.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: FDC - Read not working on real hardware

Post by Combuster »

If a thing like that is a pain, why don't you write a tiny app that lets you manually poke and read floppy ports and display an IRQ counter? That way you can live test different things without needing reboots or lots of cabling changes.


While I haven't done a floppy driver without int 13, I am missing the logical equivalent of the reset call. You only seem to be configuring the controller end but not the mechanical end (add a calibrate/reset call perhaps?). The obligatory retries are also missing from this snippet.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: FDC - Read not working on real hardware

Post by onlyonemac »

Combuster wrote:I am missing the logical equivalent of the reset call.
Here it is right here:
onlyonemac wrote: mov al, #0x80
mov dx, #0x03F4
outb dx, al ;Set DSR (1.44 MB, Reset)
Combuster wrote:The obligatory retries are also missing from this snippet.
As I have said before, I wasn't doing any of those yet because I'm trying the code more than once before I conclude that it's not working (i.e. I'm doing manual retries, just in case). In any case, I doubt that every attempt of every version of my code would be failing, especially when I don't get any errors with my floppy drive or disk any other times (i.e. under linux).
Combuster wrote:You only seem to be configuring the controller end but not the mechanical end (add a calibrate/reset call perhaps?).
In what way? Could you elaborate on what you mean by that? The only thing missing is a calibrate, which I'll try now (although I doubt it will help).
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
tom9876543
Member
Member
Posts: 170
Joined: Wed Jul 18, 2007 5:51 am

Re: FDC - Read not working on real hardware

Post by tom9876543 »

A very silly question.... have you tested the FDC with Linux / Windows?
You need to verify the ancient hardware actually works correctly with another OS first.

You should just copy the logic (NOT the code) from the Linux driver.
User avatar
bwat
Member
Member
Posts: 359
Joined: Fri Jul 03, 2009 6:21 am

Re: FDC - Read not working on real hardware

Post by bwat »

onlyonemac wrote:In any case, I doubt that every attempt of every version of my code would be failing, especially when I don't get any errors with my floppy drive or disk any other times (i.e. under linux).
onlyonemac wrote:The only thing missing is a calibrate, which I'll try now (although I doubt it will help).
You're very confident for someone who hasn't got a working driver. You're not acting like an experienced developer. Have you read the disk controller's data sheet? Have you read the floppy disk controller info on the wiki? Have you followed the advice given by these two documents?

Last night I botched something up in an area where I have little experience. I was making all kinds of assumptions like you are now. I'm not saying you're wrong, as your assumptions may very well be correct, I'm just that you're not doing it right. Doing it properly saves time in the long run.
Every universe of discourse has its logical structure --- S. K. Langer.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: FDC - Read not working on real hardware

Post by onlyonemac »

Sorry about the late reply, but it turned out that calibrations after resets are essential. I always thought they were optional, like as in you only do them when you're getting a bunch of read/write errors and chances are your drive's out of alignment.

Now onto implementing my filesystem... (I'm NOT doing FAT!)
tom9876543 wrote:A very silly question.... have you tested the FDC with Linux / Windows?
You need to verify the ancient hardware actually works correctly with another OS first.
I would not be saying that I know the hardware works when I haven't tested it (in any case, how do you think I'm making the disk?).
bwat wrote:Have you read the disk controller's data sheet? Have you read the floppy disk controller info on the wiki? Have you followed the advice given by these two documents?
Umm... No, I just typed in some random code to see if it worked. Honestly, how do you think I would have made any sort of driver without reading either the datasheet or the wiki? I have read both.

Anyway, as far as I'm concerned this thread is closed. Is there any way to mark it as such? (There's another forum I'm on where one marks a thread as "solved" when they have fixed their problem.)
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

Re: FDC - Read not working on real hardware

Post by Bender »

Anyway, as far as I'm concerned this thread is closed. Is there any way to mark it as such? (There's another forum I'm on where one marks a thread as "solved" when they have fixed their problem.)
Yes. Just roll on to your first post, choose "Edit" and in the subject text box just add a '[Solved]'.
I'm NOT doing FAT!
I wouldn't force you to do FAT but other general purpose file systems in use (EXTn, NTFS, HFS(+) mostly) are more complicated than FAT, I'd say it will be a good exercise to study FAT for a while so you get an idea of how file systems work.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: FDC - Read not working on real hardware

Post by onlyonemac »

I'm making my own filesystem, and the reason is because one of my OS goals is to make a completely independent OS which is not based on any existing standards, thus I am using my own executable file format as well, and generally ignoring the "accepted" or "conventional" way of doing this.

Having said that, however, I might add FAT support later on for compatibility purposes. For now though I'm considering making a Linux filesystem driver in order to allow me to access my special disks.

EDIT: I didn't realise one could change the thread title later. Thanks for the tip!
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Post Reply