Fat12 Directory
Fat12 Directory
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..
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..
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Fat12 Directory
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 ]
[ Project UDI ]
Re: Fat12 Directory
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?
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?
Re: Fat12 Directory
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
Re: Fat12 Directory
ok it's what i tried to to:
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
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?
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
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
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?
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Fat12 Directory
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:
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).
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;
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Fat12 Directory
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
after i've done this what i need to do ?
i resolved the times error shortening the string variable
Re: Fat12 Directory
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.
Re: Fat12 Directory
Read. It's a simple, straightforward description. If you do not understand it, I do not believe you can develop an OS.sakuya84 wrote:can you help me?
JAL