OSDev.org

The Place to Start for Operating System Developers
It is currently Fri May 10, 2024 11:45 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Low-Level IO - I love it!
PostPosted: Tue Jun 05, 2007 9:40 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2566
Location: Sydney, Australia (I come from a land down under!)
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!

_________________
Pedigree | GitHub | Twitter | LinkedIn


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 10:07 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
Good job, I think I speak for everyone when I say, we're all very proud of you..lol

_________________
My new NEW blag


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 10:11 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2566
Location: Sydney, Australia (I come from a land down under!)
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:
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

_________________
Pedigree | GitHub | Twitter | LinkedIn


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 10:20 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
umm..why is an int used?
and how do you keep track with just a simple int?

_________________
My new NEW blag


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 10:21 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2566
Location: Sydney, Australia (I come from a land down under!)
Look at your documentation:

Code:
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:
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.

_________________
Pedigree | GitHub | Twitter | LinkedIn


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 4 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