OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 15, 2024 10:05 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: getting 2nd cluster No.
PostPosted: Tue Jun 27, 2017 12:35 pm 
Offline
Member
Member

Joined: Wed Nov 18, 2015 3:04 pm
Posts: 396
Location: San Jose San Francisco Bay Area
Jump starting my os design project this week after long pause. Took me a whole day to re-familiarize.
Looks like I need to take the mini-fat32 driver more seriously and need to come up with several api-s.

I am almost certain on this: to read the next (2nd cluster No.) after obtaining first one from boot sector of volume, you basically offset into by 1st cluster No and read the 4 bytes for fat32 right?

here is the pseudo plan for load file from fat32 volume:
Quote:
function load_file (in cluster_no_1st, in memDest)
----currCluster = cluster_no_1st
----start loop
--------read cluster currCluster into memDest
--------memDest+=ClusterSize
--------find next cluster No. (get it from fat32 table) - offset into curCluster in FAT and read the 4 bytes, that is your next cluster) -> nextCluster
--------currCluster = nextCluster
--------terminate and exit loop if currCluster is empty, bad or EOF.

_________________
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails


Top
 Profile  
 
 Post subject: Re: getting 2nd cluster No.
PostPosted: Tue Jun 27, 2017 6:40 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
It looks correct. What exactly is your question?

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: getting 2nd cluster No.
PostPosted: Wed Jun 28, 2017 2:58 am 
Offline
Member
Member

Joined: Wed Nov 18, 2015 3:04 pm
Posts: 396
Location: San Jose San Francisco Bay Area
i was not sure my assumption was right regarding how to read second cluster and so on.
I had to boot to efi shell and dblk to search through a bunch of blocks and deciphering those hex-s to verify my assumption was right.
it was grueling task.

_________________
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails


Top
 Profile  
 
 Post subject: Re: getting 2nd cluster No.
PostPosted: Wed Jun 28, 2017 6:26 am 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 642
Location: Ukraine, Bachmut
FAT documentation. it exists, it is small and it's a very easy reading. try it.)
PS.
Quote:
after obtaining first one from boot sector of volume,

You take 1st cluster number of an entity from DIR_FstClusLO and DIR_FstClusHI fields of a directory entry. The only 1st cluster number in the BPB is the root dir's 1st cluster, on FAT32. And on FAT32, significant bytes are 28 not 32.
Quote:
Looks like I need to take the mini-fat32 driver more seriously

yup, you do. :)

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: getting 2nd cluster No.
PostPosted: Wed Jun 28, 2017 12:05 pm 
Offline
Member
Member

Joined: Wed Nov 18, 2015 3:04 pm
Posts: 396
Location: San Jose San Francisco Bay Area
is it good approach to load all of FAT to memory? I initially thinking to load just 1 sector worth of FAT (128 entries) into memory at a time but it has too much complicacy:
if FAT pointer falls outside the current sectors and have to do a mathematical calculation to get which sector to load etc.,
Instead I just declared 64KB area for entire FAT assuming this is the limit (current size I see is much less than that).

_________________
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails


Top
 Profile  
 
 Post subject: Re: getting 2nd cluster No.
PostPosted: Wed Jun 28, 2017 3:26 pm 
Offline
Member
Member

Joined: Wed Nov 18, 2015 3:04 pm
Posts: 396
Location: San Jose San Francisco Bay Area
zaval wrote:
FAT documentation. it exists, it is small and it's a very easy reading. try it.)
PS.
Quote:
after obtaining first one from boot sector of volume,

You take 1st cluster number of an entity from DIR_FstClusLO and DIR_FstClusHI fields of a directory entry. The only 1st cluster number in the BPB is the root dir's 1st cluster, on FAT32. And on FAT32, significant bytes are 28 not 32.
Quote:
Looks like I need to take the mini-fat32 driver more seriously

yup, you do. :)


Yes i got it from directory entry. Initially (or probably just set it as permanent limitation), I am going to design such that only can work with directory entries in the root folder, but even though it was quite a bit, reading all these BPB-s and root dir entries and having to shuffle those numbers between CPU registers! I decided to use memory variables freely otherwise it is just too much!

_________________
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails


Top
 Profile  
 
 Post subject: Re: getting 2nd cluster No.
PostPosted: Wed Jun 28, 2017 4:32 pm 
Offline
Member
Member
User avatar

Joined: Mon Apr 18, 2016 9:50 am
Posts: 138
Location: New York New York
Quote:
I decided to use memory variables


I mean... that's kind of the point of memory.

_________________
The OS is P5. Don't expect it to build.


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

All times are UTC - 6 hours


Who is online

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