Fat12 Directory

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
sakuya84
Posts: 9
Joined: Thu May 29, 2008 3:12 pm

Fat12 Directory

Post by sakuya84 »

Hi guys,
i'm working on my bootloader and new to FS.
my bootloader is a two stage type,and it work right if the second stage is on the root,
i need to know how to load it from a directory such System\stage2.sys
can you help me?

thank you in advance for your answer..
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Fat12 Directory

Post by Love4Boobies »

Are you sure you understand exactly what a file system is and what it does?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
sakuya84
Posts: 9
Joined: Thu May 29, 2008 3:12 pm

Re: Fat12 Directory

Post by sakuya84 »

if i don't misundarstand what i read..
fat12 keep a table of the file and directory in a part of the disk called root directory.

what i don't really understand is how tell him that the second stage is'nt on a:\stage2.sys but in a:\system\stage2.sys (just to use a windows example)
because if i leave the stage2.sys on a: my bootloader load the file and it works, but in the second case not
so i thought that i need to tell him that the file is under system. no?
ruisleipa
Member
Member
Posts: 46
Joined: Wed Sep 10, 2008 8:39 am
Location: Finland

Re: Fat12 Directory

Post by ruisleipa »

Basically you find the entry called "system" from the root directory and then find the "stage2.sys" in that directory.
http://code.google.com/p/rmmtos/ - Real Mode MultiTasking Operating System
User avatar
sakuya84
Posts: 9
Joined: Thu May 29, 2008 3:12 pm

Re: Fat12 Directory

Post by sakuya84 »

ok it's what i tried to to:

Code: Select all

 ;----------------------------------------------------
     ; Find System Folder
     ;----------------------------------------------------  
		  mov     cx, WORD [bpbRootEntries]             ; load loop counter
          mov     di, 0x0200                            ; locate first root entry
     .LOOPS:
          push    cx
          mov     cx, 0x000B                            ; eleven character name
          mov     si, SysFolder                         ; image name to find
          push    di
     rep  cmpsb                                         ; test for entry match
          pop     di
          je      FIND_S2
          pop     cx
          add     di, 0x0020                            ; queue next directory entry
          loop    .LOOPS
          jmp     FAILURE
with this i search on root directory the sysfolder
and now the things become pretty confused to me..... i copied the same thing and i don't resetted di

Code: Select all

 ;----------------------------------------------------
     ; Find stage 2
     ;----------------------------------------------------

     ; browse root directory for binary image
       FIND_S2:
		  mov     cx, WORD [bpbRootEntries]             ; load loop counter
      .LOOP:
          push    cx
          mov     cx, 0x000B                            ; eleven character name
          mov     si, ImageName                         ; image name to find
          push    di
     rep  cmpsb                                         ; test for entry match
          pop     di
          je      LOAD_FAT
          pop     cx
          add     di, 0x0020                            ; queue next directory entry
          loop    .LOOP
          jmp     FAILURE
but i'm pretty sure that something it's wrong.

PS: when i compiling this it give me an error on times 0 filler
times value -19 is negative. i reached the max dimension of 512byte?
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Fat12 Directory

Post by Love4Boobies »

First of all, you never mentioned FAT12 in your original post, you said you were developing a boot loader and a file system so I assumed you were working on your own design. The root directory in your example is A: and for FAT12 and FAT16 it has a fixed location and size. This region doesn't even exist on FAT32 volumes.

The first thing you need to do is to find out where the root directory region ends. After that, you calculate the start of the data region (i.e. the first sector of cluster 2) as follows:

Code: Select all

RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec – 1)) / BPB_BytsPerSec;
FirstDataSector = BPB_ResvdSecCnt + (BPB_NumFATs * BPB_FATSz16) + RootDirSectors;
The TIMES error, just as you said, shows up because it can't turn the counter backwards and start deleting code to get to the position it needs to reach :) Don't forget that the 2nd stage isn't limited to 512 bytes. You wrote the first stage - just make it load more sectors (if the sector size is 512 bytes).
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
sakuya84
Posts: 9
Joined: Thu May 29, 2008 3:12 pm

Re: Fat12 Directory

Post by sakuya84 »

i'm sorry for never tell i was working on fat12 ^^'''''

after i've done this what i need to do ?

i resolved the times error shortening the string variable
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Fat12 Directory

Post by egos »

And System directory can occupies more than one claster (sector). Take account that in FAT12/16 its structure is differ from root directory. I could see how you are making the search of the dir entries, but I don't see how you are loading the directories.
If you have seen bad English in my words, tell me what's wrong, please.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Fat12 Directory

Post by jal »

sakuya84 wrote:can you help me?
Read. It's a simple, straightforward description. If you do not understand it, I do not believe you can develop an OS.


JAL
Post Reply