flat assembler
Message board for the users of flat assembler.

Index > OS Construction > []

Author
Thread Post new topic Reply to topic
mikegonta



Joined: 20 Nov 2005
Posts: 99
mikegonta 26 May 2007, 20:58
[ Post removed by author. ]


Last edited by mikegonta on 27 Jan 2009, 21:59; edited 2 times in total
Post 26 May 2007, 20:58
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 27 May 2007, 05:46
Cool. Though I never quite understood what the File Allocation Table itself is, maybe that's why I'm stuck in the mud with trying to understand it constantly. All I know is that there's one File Allocation Table for every FAT partition and (not sure on this) individual folder. Also I know that blocks are singly linked lists.
Post 27 May 2007, 05:46
View user's profile Send private message Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 314
Mac2004 27 May 2007, 09:00
Nice example indeed!

regards,
Mac2004
Post 27 May 2007, 09:00
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 27 May 2007, 17:00
rhyno_dagreat wrote:
Cool. Though I never quite understood what the File Allocation Table itself is, maybe that's why I'm stuck in the mud with trying to understand it constantly. All I know is that there's one File Allocation Table for every FAT partition
Theres two copies of the FAT, just in case one is damaged and this fat is used for all files/dir on disk.
Post 27 May 2007, 17:00
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 27 May 2007, 17:59
Dex4u wrote:
rhyno_dagreat wrote:
Cool. Though I never quite understood what the File Allocation Table itself is, maybe that's why I'm stuck in the mud with trying to understand it constantly. All I know is that there's one File Allocation Table for every FAT partition
Theres two copies of the FAT, just in case one is damaged and this fat is used for all files/dir on disk.

which explains why he has two FATs there. But what's their structure? All I see is three bytes in the first sector out of nine sectors total.
Post 27 May 2007, 17:59
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 28 May 2007, 04:38
http://en.wikipedia.org/wiki/File_Allocation_Table

This has just helped quite a bit... yet I still don't know what those 3 bytes are, as they aren't in the list of bytes representing something/and or another about a cluster.

Edit: I found where he/you (depending on if you're reading this, Mike) got the first byte from, but what about the following two?
Post 28 May 2007, 04:38
View user's profile Send private message Reply with quote
mikegonta



Joined: 20 Nov 2005
Posts: 99
mikegonta 28 May 2007, 10:51
[ Post removed by author. ]


Last edited by mikegonta on 27 Jan 2009, 21:59; edited 3 times in total
Post 28 May 2007, 10:51
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 29 May 2007, 04:05
Thanks.
Post 29 May 2007, 04:05
View user's profile Send private message Reply with quote
Hayden



Joined: 06 Oct 2005
Posts: 132
Hayden 30 May 2007, 02:54
Here is a small boot record that i wrote... by default it will load 64k from lba[1] and then execute, you can make adjustments to that easily. it will also work from hard disks and maybee from boot-cd in program mode. the system is left in real mode and a default stack is supplied. [ds:bx] and [es:bx] points to the origin on entry into the users system, by default this origin is zero.

Code:

; ------------------------------------------------
; BOOT-OS.ASM Build(0620a)
; Created By: Hayden McKay
; ------------------------------------------------
use16

jmp far 007C0h:init_bootsys          ; must be far
align 4

    SystemStack  dd 08000h:0fbffh    ;  1k
    SystemSpace  dd 09000h:00000h    ; 64k

    SectorStart  dw 1                ; lba
    SectorCount  db 128              ; maximum 64k

align 4

init_bootsys:

    ; setup stack ect...

    lss  sp, dword [cs:SystemStack]     ; nmi safe
    pushf
    pusha
    push dx                             ; boot num
    push sp

    ; setup for lba->chs translation...

    mov  ah,08h                     ; drive params
    int  13h
    xor  ah, ah
    mov  al, dh                     ; maximum head
    and  cx,3fh                     ; clear d6->d7
    inc  ax
    mul  cx
    mov  si, cx                     ; sector count
    mov  di, ax                     ; heads x secs

    ; begin the lba->chs, mutli-sector read...

    pop  bp                         ; ptr boot num
    les  bx, dword [cs:SystemSpace]
    align 4

read_sectors:

    mov  ax, word  [cs:SectorStart]
    xor  dx, dx
    div  di
    mov  cl, ah
    mov  ch, al                  ; cylinder d0->d7
    shl  cl, 6d                  ; cylinder d8->d9
    mov  ax, dx
    xor  dx, dx
    div  si
    inc  dl
    mov  dh, al                  ; head
    or    cl, dl                  ; sector d0->d5
    mov  dl, byte  [ss:bp]

    ; read how many sectors...

    mov  al, cl
    and  ax,3fh
    sub  ax, si                     ; - max sec...
    neg  ax                          ; abs
    inc  al                         ; +=1
    cmp  al, byte  [cs:SectorCount] ; more than...
    jbe  @f
    mov  al, byte  [cs:SectorCount] ; less than...
    align 4
    @@:

    ; use the bios int13 i/o...

    pusha                              ; bios safe
    xor  ax, ax                        ; calibrate
    int  13h
    popa
    pusha
    mov  ah,02h                        ; read secs
    stc                               ; bios safe
    int  13h
    popa
    jc   @b                            ; use force

    ; prepare for some more sectors...

    add  word  [cs:SectorStart], ax ; update start
    sub  byte  [cs:SectorCount], al ; update count
    jz     @f                         ; done!
    shl  ax, 9d                     ; *=512
    add  bx, ax                     ; update es:bx
    jmp  near  read_sectors
    align 4
    @@:
    pop  dx                         ; boot num

    ; initiate the system file...

    popa
    popf
    lds  bx, dword [cs:SystemSpace]   ; setup data
    call far dword [cs:SystemSpace]   ; enter code

    ; 157 bytes

    ; Todo list...

    ; * maybee copy the system to the hma
    ; * maybee supply an open file system

    rb 510d - $
    db 055h
    db 0AAh                              ; bootme!

    


enjoy!

_________________
New User.. Hayden McKay.


Last edited by Hayden on 19 Jun 2007, 14:47; edited 2 times in total
Post 30 May 2007, 02:54
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 31 May 2007, 02:48
Thanks for that Hayden!
Post 31 May 2007, 02:48
View user's profile Send private message Reply with quote
hckr83



Joined: 12 Nov 2006
Posts: 86
Location: usa
hckr83 07 Jun 2007, 00:33
This is really pretty amazing!
The only bad thing i syou don't do A20, but that doesn't matter as long as you only do odd number MB like 1
or something...
Am I wrong about A20? I know you can use 0x10,000 but what limits are done by not doing A20?
Post 07 Jun 2007, 00:33
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Hayden



Joined: 06 Oct 2005
Posts: 132
Hayden 07 Jun 2007, 21:42
http://en.wikipedia.org/wiki/A20_line

* The a20 gate enables realmode access to the ~64k HMA below the 1M
* From protected mode the a20 gate has no usefulness at all
* From realmode the HMA can not be used for device buffers

Example, if i enable the a20 gate then do sector reads to [ffff:0010] via int13, the data is not there, the fdd/dma controller gets it lost someware...

I'm really bad at explaining these things...
[/url]

_________________
New User.. Hayden McKay.
Post 07 Jun 2007, 21:42
View user's profile Send private message Reply with quote
JMD



Joined: 24 Sep 2003
Posts: 32
JMD 08 Jun 2007, 01:05
The fat table is just a contigious list of pointers to cluster for which each file fragement is located on the disk. A cluster is just a group of sectors. A sector is a group of bytes, typical sector contains 512 bytes where you can store data.

If you want to read a file, You first start by calculating the (root) directory posistion. A directory contains one 32 byte entry for each file. The entries begin with the name of the file and also contain other information about the file.

Next search through the directory for the file name you want, once you find the file name, within the file entry is other information including the cluster number of the first file fragement.

Using this cluster number you can determine the position in the data section of the disk of the files first fragement and the offset to the next fragment in the fat table. To determine the location of the file fragment in the data section you need to know the starting sector of the data section then add to it the cluster number times number of sectors per cluster..... fragement location = (Data Section starting sector) + (Cluster number from file entry * sectors/cluster)

Once you copied all fragements of the file the last entry in the fat table is usually 0xFFF indicating End Of File.

A typical harddrive is laid out like this.....

Code:
***********************************
Sector 1 contains boot loader code 
and drive geometry and format information
***********************************
Predefined number of Reserved sectors.
***********************************
Fat Table 1
***********************************
Fat Table 2
***********************************
Root Directory
***********************************
Data Section
***********************************
    


Within sector one is the disk geometry and format information, here you can use this data to determine how many reserved sectors there are, how many sectors for each fat table there is, and how many entries are in the root directory. With all this information you can determine where the start of the data section is.

To see how this works you can look at my boot sector also its located in this thread.... http://board.flatassembler.net/topic.php?p=51973#51973
Post 08 Jun 2007, 01:05
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.