Page 1 of 1

Low-Level IO - I love it!

Posted: Tue Jun 05, 2007 9:40 pm
by pcmattman
OK, I just finished the low-level ATA driver for my OS (read, write, lseek)...

Now I have to change all the ReadSector calls in my FAT32 driver to lseek/read pairs, and I've noticed how clean my code is now! It's incredible!

Posted: Tue Jun 05, 2007 10:07 pm
by earlz
Good job, I think I speak for everyone when I say, we're all very proud of you..lol

Posted: Tue Jun 05, 2007 10:11 pm
by pcmattman
Seriously, read/write/ioctl/lseek/open/close - all reasonably simple to implement but really quite helpful. My device management system means I can do:

Code: Select all

int d = open( "dr0", READWRITE );
char buff[512];
lseek( d, 1024, SEEK_SET );
read( d, buff, 1 );
close( d );
To open the first hard drive for read/write access, and read in the data at sector 1024. I'm really happy it works now :D

Posted: Tue Jun 05, 2007 10:20 pm
by earlz
umm..why is an int used?
and how do you keep track with just a simple int?

Posted: Tue Jun 05, 2007 10:21 pm
by pcmattman
Look at your documentation:

Code: Select all

int _open( const char *filename, int oflag [, int pmode] );
(That's MSDN)

The int is nothing more than an index in a linked list of descriptors stored elsewhere.

Edit: this is it in action, when inside my fread() function:

Code: Select all

Welcome to Mattise!
Version 1.1, ALPHA
Hello world, this is a test of the fread function, which is based on the read fu
nction, which is shiny and new and hopefully works well in my OS.