OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:17 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Floppy driver
PostPosted: Sat Jul 09, 2005 11:00 pm 
Offline

Joined: Fri Oct 29, 2004 11:00 pm
Posts: 22
Hello,

i tried to write my own Floppy Driver for my own Operating System, but so far no floppy driver work ... I need a function in C those loads a File from the Floppy driver in the memory ...

For example:

fileopen( "A:\\File.txt", 0x10000 );
FILENAME , MEMORY

If it is in C not feasible can anyone told me how I can make this in NASM ?? I have tryed to make a Fileloader in NASM ( liks a bootloader but with other adresses ) ... but this program doesn't work ...


Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Sat Jul 09, 2005 11:00 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
umm well i havent quite made a read_fat_file function but i have made this

Code:
unsigned char* read_disk(drive_params t) /*reads a single sector and returns it */
{

   byte ret[512];
   byte temp;
   word tmp2;
   word tmp3;
   byte tmp;
      asm mov tmp3,cs
      asm mov es,tmp3
      tmp2=&ret;
      asm mov bx,tmp2
      asm mov ah,0x02
      asm mov al,1
      asm mov ch,t.cylinder
      asm mov cl,t.sector
      asm mov dh,t.head
      asm mov dl,t.drive
      asm mov ah,0x02
      asm int 0x13
asm mov temp,ah
      if (temp>0x00) {
      ret[0]=temp;
      }

      return ret;

}

byte write_disk(drive_params t,byte data[512]) /*writes a single sector*/
{
   byte ret2;
   byte temp;
   word tmp2;
   dword tmp3;
      asm mov tmp3,cs
      asm mov es,tmp3
      tmp2=&*data;
      asm mov bx,tmp2
      asm mov ah,0x03
      asm mov al,1
      asm mov ch,t.cylinder
      asm mov cl,t.sector
      asm mov dh,t.head
      asm mov dl,t.drive
      asm mov ah,0x03
      asm int 0x13
asm mov ret2,ah
      temp=ret2;
      return ret2;

}

void testing(void) /*just a reserved function for testing junk*/
{


   byte tmp2;
drive_params t;
   t.cylinder=0;
   t.head=0;
   t.sector=1;
   t.drive=0x00;
   reset_disks(0x00);
   *tmp5="hi";
   tmp2=write_disk(t,*tmp5);
   *tmp5=read_disk(t);
printf(*tmp5);
if (streq(*tmp5,"hi")==1) { printf("yay!");}
/*try using get the address rather than return the var
/*asm mov WORD [es:20*4+2], CS omg that actually works*/
   /*U IDIOT u never did write hi to disk*/
}


it reads/writes a single sector into/from a C 512 byte character array

_________________
My new NEW blag


Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Sat Jul 09, 2005 11:00 pm 
Offline

Joined: Fri Jul 01, 2005 11:00 pm
Posts: 12
You've met the same problem as I am currently working on. Just there is one thing you need to clarify. Have you already switched into 32 bit protected mode or are you still in real mode? If you're in real mode you can use the 0x13 BIOS interrupt, but if you're in protected mode, like I am, then you must program the i/o ports of the floppy controller, and the dma controller. If you find any resources about the floppy controller, I'd appreciate you pointing them out for me. So far I have:
http://www.nondot.org/sabre/os/articles/DiskandDiscDrives/
Examine the links about floppy drives. I wish though that there were examples of code somewhere.


Last edited by yetAnotherOS on Sat Jul 09, 2005 11:00 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Sat Jul 09, 2005 11:00 pm 
Offline

Joined: Fri Oct 29, 2004 11:00 pm
Posts: 22
@hckr83:

Thank You ... but I can't use your code because I my OS workt in Protected Mode ...

@yetAnotherOS:

Ok ... I have already pointed out documents about programming the FDC and DMA ... I have created a Floppy Driver out of the documents but this driver doesn't work well ... If you give me your Mail addy I can send you the documents ... maby you can create a fine floppy driver ...


Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Sat Jul 09, 2005 11:00 pm 
Offline

Joined: Fri Jul 01, 2005 11:00 pm
Posts: 12
I've sent you an email and look forward to your info.


Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Sat Jul 09, 2005 11:00 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
oh sorry i was just assuming u were in real mode

i got nothing for protected mode

_________________
My new NEW blag


Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Tue Jul 12, 2005 11:00 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 158
Location: Vlaardingen, Holland
stafe wrote:
Hello,

i tried to write my own Floppy Driver for my own Operating System, but so far no floppy driver work ... I need a function in C those loads a File from the Floppy driver in the memory ...

For example:

fileopen( "A:\\File.txt", 0x10000 );
FILENAME , MEMORY

If it is in C not feasible can anyone told me how I can make this in NASM ?? I have tryed to make a Fileloader in NASM ( liks a bootloader but with other adresses ) ... but this program doesn't work ...


To use such a function you'll first have to write a driver to read sectors from disk. Then you'll have to write a filesystem driver (in this case a floppy, this will be a FAT driver.) In this driver you'll have to implent some fucntions to write and read files. I knew a good site where I learned this from, but I've forgotten the link. Send me an email and I'll send you some source.. You'll have to tweak it to fit into your own os ;)

_________________
The source of my problems is in the source.


Last edited by matthias on Tue Jul 12, 2005 11:00 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Tue Jul 12, 2005 11:00 pm 
Offline
Member
Member

Joined: Sat Dec 04, 2004 12:00 am
Posts: 65
I have the same problem, and i found something interesting:
http://bos.asmhackers.net/docs/floppy/d ... torial.txt
http://www.mega-tokyo.com/forum/index.p ... eadid=7843


Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Wed Jul 13, 2005 11:00 pm 
Offline

Joined: Fri Jul 01, 2005 11:00 pm
Posts: 12
the first link is excellent. Thanks!!!


Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Thu Jul 14, 2005 11:00 pm 
Offline

Joined: Sun Jul 10, 2005 11:00 pm
Posts: 2
would there be any chance you people emailing around, could post some of that stuff here, I would like to see it too, please. Besides, other people visiting might find it useful as well :)


Top
 Profile  
 
 Post subject: Re: Floppy driver
PostPosted: Sat Jul 16, 2005 11:00 pm 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 1223
Location: Sweden
Maybe this helps?
http://bos.asmhackers.net/docs/floppy/

_________________
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 61 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group