Hey,guys......i m new to this forum and i hope u wont make me feel that way for long
actually ..i hav been busy writing a PROTECTED MODE OS IN C...for my final year project.....i hav been a silent rader of this forum...bt i stucka hurdle since last week.........
I WANT TO WRITE A FLOPPY DRIVER TO READ SECTORS of the disc WITHOUT USING DMA....jst cos dma is too complicated for me.........
Can someone help
by the way...i seemed to have crawlwd over most of the web for this stuff....i cudnt find somthing satisfactory........bt i hope i left out something......
and i have a working IDT,GDT and a Keyboard driver!
How to write a floppy driver in pmode without using DMA
Do not enable DMA (default) and use your own IRQ handlers? That's all... I just don't know what you find hard here; did you check the intel manuals? Or you have problem what to write on the FDC ports?
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
- Combuster
- 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: How to write a floppy driver in pmode without using DMA
You scored a direct hit in the Beginner_MistakesJAK wrote:i hav been busy writing a PROTECTED MODE OS IN C...for my final year project.....i hav been a silent rader of this forum...bt i stucka hurdle since last week.........
Other than that I agree with Inflater, your question is too unspecific to allow us to provide a good answer. You may want to check your spelling as well...
DMA is very easy compared to some of the things you come against in OS dev.
Then theres also the fact that i have not seen one none DMA fdd code example that works.
But i thought like you, when i started and spent a week trying to get none DMA fdd code to work, but in the end, it took me 20 mins to get the DMA part of fdd code working.
Then theres also the fact that i have not seen one none DMA fdd code example that works.
But i thought like you, when i started and spent a week trying to get none DMA fdd code to work, but in the end, it took me 20 mins to get the DMA part of fdd code working.
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
I know I should help, but I have to say....
1) Read the POSTING RULES, READ THIS post!
2) You can use IM slang, but I find it annoying if overused.
3) CAPS are annoying too....so make everything normal, unless some word is important.
Anyway, I agree with Combuster, Beginner Mistake!
-JL
1) Read the POSTING RULES, READ THIS post!
2) You can use IM slang, but I find it annoying if overused.
3) CAPS are annoying too....so make everything normal, unless some word is important.
Anyway, I agree with Combuster, Beginner Mistake!
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Sorry..guys..for the Mistakes!u know ,i m just a Beginner!
The problem for me is that,i like to keep it simple (ie) simplicity is the main aim for the project.So i thought rather than learing to program dma separately,it would be more simple to just give the controller the read/write command and obtain result bytes individually and store them into a global buffer!
I hope i am correct on the theory i mentioned!If so,please let me know actually WHERE to send (ie)which port, the sector number,head number and track number!are any other parameters required?
i hope i cleared my point!
The problem for me is that,i like to keep it simple (ie) simplicity is the main aim for the project.So i thought rather than learing to program dma separately,it would be more simple to just give the controller the read/write command and obtain result bytes individually and store them into a global buffer!
I hope i am correct on the theory i mentioned!If so,please let me know actually WHERE to send (ie)which port, the sector number,head number and track number!are any other parameters required?
i hope i cleared my point!
Sorry..guys..for the Mistakes!u know ,i m just a Beginner!
The problem for me is that,i like to keep it simple (ie) simplicity is the main aim for the project.So i thought rather than learing to program dma separately,it would be more simple to just give the controller the read/write command and obtain result bytes individually and store them into a global buffer!
I hope i am correct on the theory i mentioned!If so,please let me know actually WHERE to send (ie)which port, the sector number,head number and track number!are any other parameters required?
i hope i cleared my point!
The problem for me is that,i like to keep it simple (ie) simplicity is the main aim for the project.So i thought rather than learing to program dma separately,it would be more simple to just give the controller the read/write command and obtain result bytes individually and store them into a global buffer!
I hope i am correct on the theory i mentioned!If so,please let me know actually WHERE to send (ie)which port, the sector number,head number and track number!are any other parameters required?
i hope i cleared my point!
I tried to write a bit of code myself and came up with the below code ..basically it just tries to read the bootsector from the floppy to a global buffer and diaplay it..WITHOUT USING DMA!
the recaliberate() and seek()....r working fine!please have a look at the code if there is a biginners mistake or is the logic entirely wrong!
by the way..actually i first tried to get the buffer fill up until a variable in my IRQhandler()....reached 512 ,but it didnt work cos the variable didnt seem to increment as i had read in an article saying that "when programming in a NON DMA mode..the floppy contoller will raise an interrupt everytime it has send a byte to u..(ie)after u issue a read/write etc!"
here is the code-
extern int readfloppy(int drive,int head ,int cylinder,int sector)
{ int tries,j;
int k=0,p=0;
unsigned int c;
// puts("inside read floppy\n");
for(c=0;c<10000;c++){}
fdc_recaliberate();
outportb(0x3f7,0);
for(tries=0;tries<5;tries++)
{if(inportb(0x3f4)&0xa0)//i put 0xa0h here bcos i guess setting the 5th bit in MSR means disabling the DMA..am i right with that?
{// puts("inside for loop..if..just b4 seeking\n");
fd_seek(cylinder);
// puts("returned 4m seek");
fd_out(0x46);//read
fd_out(0x00);//i dont know the name of the field...but bits 2,1,0 represent
fd_out(0x00);//cylinder
fd_out(0x00);//head
fd_out(0x00);//secor num
fd_out(0x02);//size
fd_out(0x12);//num of sectors per track
fd_out(0x1b);//length of gap 3....27d is the standard
fd_out(0xff);//size..default
// puts("commands over\n");
}
for(c=0;c<10000;c++){}
while(p<512)
{
buffer[j]=fd_in();
p++;
}
puts("after getting the stuff into buffer into buffer\n");
if(p>511)
{
while(k<512)
{//puts("\n gonna putch\n");
putch(buffer[k]);
k++;
}
puts("returning zero\n");
return 0;
}
else
continue;
}
puts("returning one\n");
return 1;
}
please ignore the arguments,for now!
the control passes through entire code bt the buffer dosent seem to display anything!
the recaliberate() and seek()....r working fine!please have a look at the code if there is a biginners mistake or is the logic entirely wrong!
by the way..actually i first tried to get the buffer fill up until a variable in my IRQhandler()....reached 512 ,but it didnt work cos the variable didnt seem to increment as i had read in an article saying that "when programming in a NON DMA mode..the floppy contoller will raise an interrupt everytime it has send a byte to u..(ie)after u issue a read/write etc!"
here is the code-
extern int readfloppy(int drive,int head ,int cylinder,int sector)
{ int tries,j;
int k=0,p=0;
unsigned int c;
// puts("inside read floppy\n");
for(c=0;c<10000;c++){}
fdc_recaliberate();
outportb(0x3f7,0);
for(tries=0;tries<5;tries++)
{if(inportb(0x3f4)&0xa0)//i put 0xa0h here bcos i guess setting the 5th bit in MSR means disabling the DMA..am i right with that?
{// puts("inside for loop..if..just b4 seeking\n");
fd_seek(cylinder);
// puts("returned 4m seek");
fd_out(0x46);//read
fd_out(0x00);//i dont know the name of the field...but bits 2,1,0 represent
fd_out(0x00);//cylinder
fd_out(0x00);//head
fd_out(0x00);//secor num
fd_out(0x02);//size
fd_out(0x12);//num of sectors per track
fd_out(0x1b);//length of gap 3....27d is the standard
fd_out(0xff);//size..default
// puts("commands over\n");
}
for(c=0;c<10000;c++){}
while(p<512)
{
buffer[j]=fd_in();
p++;
}
puts("after getting the stuff into buffer into buffer\n");
if(p>511)
{
while(k<512)
{//puts("\n gonna putch\n");
putch(buffer[k]);
k++;
}
puts("returning zero\n");
return 0;
}
else
continue;
}
puts("returning one\n");
return 1;
}
please ignore the arguments,for now!
the control passes through entire code bt the buffer dosent seem to display anything!
You don't HAVE to have DMA enabled for anything... (almost).
Direct Memory Access is just a convenience used to take load off of the processor by bypassing it almost completely and accessing the memory directly from the calling device. So really, coding a non-DMA'd driver is fine, it just will strain the CPU a bit, and I suspect you don't have all that much going on anyways to bog-down the CPU by not using DMA.
Direct Memory Access is just a convenience used to take load off of the processor by bypassing it almost completely and accessing the memory directly from the calling device. So really, coding a non-DMA'd driver is fine, it just will strain the CPU a bit, and I suspect you don't have all that much going on anyways to bog-down the CPU by not using DMA.
Website: https://joscor.com
Hey...guys.Thanks for the concern but fortunately i got one working using DMA..after all the fuss i created .
i can now read a whole cylinder.....bt now the new doubt is how to limit the read to more than 1 sector...(for 1 sector i could use the read sector command).Do i limit it by setting the EOT bit...or by fixing the DMA buffer size?
i can now read a whole cylinder.....bt now the new doubt is how to limit the read to more than 1 sector...(for 1 sector i could use the read sector command).Do i limit it by setting the EOT bit...or by fixing the DMA buffer size?