FDC Implementation

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
DeepOS
Posts: 4
Joined: Thu Feb 21, 2008 6:36 am

FDC Implementation

Post by DeepOS »

I've already read the OSdev wiki about it, and the links that the wiki gives, but I can't implement the source code examples, for examlpe, this code:

http://bos.asmhackers.net/docs/floppy/d ... torial.txt

Can anyone give me a source code or a guide that explain me how I code the FDC???

Thanks.
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Post by xyjamepa »

Why don't you try this?
just search the forum :wink:
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
User avatar
Jef
Member
Member
Posts: 112
Joined: Tue Jan 08, 2008 7:25 am
Location: Greece
Contact:

Post by Jef »

download the source code of my OS.
It contains a FDC driver, if this helps you.
Keep coding...
...the sky is the limit

AsteriOS project: http://www.mindfields.gr/main/index.php ... &Itemid=27
User avatar
astrocrep
Member
Member
Posts: 127
Joined: Sat Apr 21, 2007 7:21 pm

Post by astrocrep »

That Mystran tutorial looks awesome....

I have been eyeing that for quiet some time... just not ready to start fdc coding yet.
Mouse Pad - Coming in the distant future...
Kernel: Indigo Kernel - v0.0.1

Thanks to JamesM and BrokenThorn for there tutorials!
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

If anyone need code for a none bios floppy driver in ASM, i have written a simple OS, that does nothing but goes to pmode and sets up a pmode floppy driver.
If so let me know and i will find it and upload it.
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post by os.hacker64 »

Dex wrote:If anyone need code for a none bios floppy driver in ASM, i have written a simple OS, that does nothing but goes to pmode and sets up a pmode floppy driver.
If so let me know and i will find it and upload it.
Are you working on another OS? Or just improving DexOS. From my look at DexOS, I wonder what you could do writing a Desktop OS. :D
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Post by xyjamepa »

@Dex:
Yes would you please?
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Linux give me everything i need in a desktop OS, But i am alway building electronics projects and robots etc, and i used to use Dos, but i got tied of the 1 MB limit and segmention, plus the low graphics.
So i tried to find a modern pmode Dos like OS, and the only thing that came close was the Xbox, so i decided to code my own Xbox type OS, along with a team of coders. That what Dex stands for "Dos EXtreme".
Now all my robots are controled by DexOS and i even program pic's with it.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Dex wrote:Now all my robots are controled by DexOS and i even program pic's with it.
That is rather cool.


JAL
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

abuashraf wrote:@Dex:
Yes would you please?
Sure, here is the demo that boots to Pmode and sets up a Pmode fdd. http://www.dex4u.com/demos/FddDemo.zip

Also here is just the fdd driver part (same as the one in the above), but it is much better commentated, also there notes to go with the per-do code from the "Intel floppy controller" PDF.
http://www.dex4u.com/demos/FloppyDriver.zip

PS: If you want the write to floppy code, let me know and i will post it, as that demo, demos read floppy only, it 95% the same code as the write floppy.
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Post by xyjamepa »

Dex wrote: PS: If you want the write to floppy code, let me know and i will post it, as that demo, demos read floppy only, it 95% the same code as the write floppy.
That would be great,thanks Dex.
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Just add this code, under the FddRead function

Code: Select all

 ;----------------------------------------------------;
 ; FddWrite               ; Pmode write  function ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input:                                           ;
 ;          CH  = Track/cylinder                      ;
 ;          CL  = Sector                              ;
 ;          DH  = Head                                ;
 ;          DL  = Drive (only A: drive used 00 )      ;
 ;                                                    ;
 ;  Output:                                           ;
 ;          AH  = Status                              ;
 ;          AL  = Sector number read                  ;
 ;          CF  = 0 If successful                     ;
 ;              = 1 If error                          ;
 ;                                             (100%) ;
 ;....................................................;

FddWrite:
	pushad
	and   dh,00000001b
	mov   [Head],dh
	shl   dh,2
	mov   [DriveHead],dh
	mov   [FddErrorStatus],0x04
	cmp   ch,0x51
	jae   FddWriteErrorT
	mov   [cTrack],ch
	cmp   cl,0x13
	jae   FddWriteErrorT
	mov   [Sector],cl
	mov   [FddMTimer],0
	and   [FddMotorTimer0n],0
	test  [MotorOn],1
	jnz   @f
	call  FddMotorOn
@@:
	mov   dx,CcrReg
	mov   al,00000000b
	out   dx,al
	mov   [FddErrorStatus],0x80
	;call  FddRecalibrate
	;jc    FddWriteError
	xor    ecx,ecx
	mov    cx,3					
@@:
	call  FddReadWriteSeek				
	jnc   @f
	loop  @b
	jmp   FddWriteErrorT
@@:
	mov   dx,MsReg
	in    al,dx
	test  al,00100000b
	jnz   FddWriteErrorT
	Call  Setup_DMA2_Write
;******************************
; 1. Write Sector Command
;******************************
	call  FdcSendByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	mov   al,0xe5
	out   dx,al
;******************************
; 2. Drive
;******************************
	call  FdcSendByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	mov   al,[DriveHead]
	out   dx,al
;******************************
; 3. Cylinder
;******************************
	call  FdcSendByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	mov   al,[cTrack]				 
	out   dx,al
;******************************
; 4. Head
;******************************
	call  FdcSendByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	mov   al,[Head]
	out   dx,al
;******************************
; 5. Sector
;******************************
	call  FdcSendByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	mov   al,[Sector]				
	out   dx,al
;******************************
; 6. Sector Size
;******************************
	call  FdcSendByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	mov   al,0x02
	out   dx,al
;******************************
; 7. Sectors to a track
;******************************
	call  FdcSendByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	mov   al,0x12
	out   dx,al
;******************************
; 8. Gap Length
;******************************
	call  FdcSendByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	mov   al,0x1B				       
	out   dx,al
;******************************
; 9. Data Length
;******************************
	call  FdcSendByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	mov   al,0xFF
	out   dx,al
;******************************
; Wait floppy int
;******************************
	mov   [done],0
	call  WaitDone
	jc    FddWriteErrorT
	call  FdcGetByteReady				
	jc    FddWriteErrorT
	mov   dx,DtReg					
	in    al,dx
	mov   [ResultST0],al				
	call  FdcGetByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	in    al,dx
	mov   [ResultST1],al
	call  FdcGetByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	in    al,dx
	mov   [ResultST2],al
	call  FdcGetByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	in    al,dx
	cmp   [cTrack],al
	jne    @f
	mov   [ResultC],al
@@:
	call  FdcGetByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	in    al,dx
	mov   [ResultH],al
	call  FdcGetByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	in    al,dx
	mov   [ResultR],al
	call  FdcGetByteReady
	jc    FddWriteErrorT
	mov   dx,DtReg
	in    al,dx
	mov   [ResultN],al
	test  [ResultST0],11000000b			
	jnz   FddWriteErrorT
	mov   [FddErrorStatus],0x00			
FddWriteSuccsessT:
	popad
	mov   ah,[FddErrorStatus]
	mov   al,[ResultR]
	clc
	ret
FddWriteErrorT:
	popad
	mov   ah,[FddErrorStatus]
	stc
	ret

Post Reply