Page 1 of 1
Floppy driver
Posted: Sat Jul 09, 2005 11:00 pm
by stafe
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 ...
Re: Floppy driver
Posted: Sat Jul 09, 2005 11:00 pm
by earlz
umm well i havent quite made a read_fat_file function but i have made this
Code: Select all
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
Re: Floppy driver
Posted: Sat Jul 09, 2005 11:00 pm
by yetAnotherOS
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 ... iscDrives/
Examine the links about floppy drives. I wish though that there were examples of code somewhere.
Re: Floppy driver
Posted: Sat Jul 09, 2005 11:00 pm
by stafe
@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 ...
Re: Floppy driver
Posted: Sat Jul 09, 2005 11:00 pm
by yetAnotherOS
I've sent you an email and look forward to your info.
Re: Floppy driver
Posted: Sat Jul 09, 2005 11:00 pm
by earlz
oh sorry i was just assuming u were in real mode
i got nothing for protected mode
Re: Floppy driver
Posted: Tue Jul 12, 2005 11:00 pm
by matthias
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
Re: Floppy driver
Posted: Tue Jul 12, 2005 11:00 pm
by Hery
Re: Floppy driver
Posted: Wed Jul 13, 2005 11:00 pm
by yetAnotherOS
the first link is excellent. Thanks!!!
Re: Floppy driver
Posted: Thu Jul 14, 2005 11:00 pm
by wrigley
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
Re: Floppy driver
Posted: Sat Jul 16, 2005 11:00 pm
by bubach