i want to make a file system ?
i want to make a file system ?
how can i make this ?i need a tutorilas or some thing plz
is that right after booting trying to wrie the file system before the memory managment ot not ?is the file system diffrent in the case of real or protected mode ?
is that right after booting trying to wrie the file system before the memory managment ot not ?is the file system diffrent in the case of real or protected mode ?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: i want to make a file system ?
In protected mode, people generally do the memory management before any disk accesses. The filesystem itself is independent of os, even from the architecture itself: A CD will be the same independent of wether you put it into an x86 or, lets say, an HPPA machine.mohammed wrote:how can i make this ?i need a tutorilas or some thing plz
is that right after booting trying to wrie the file system before the memory managment ot not ?is the file system diffrent in the case of real or protected mode ?
Regarding the filesystem, theres some thorough documentation on the FAT system in the wiki, which is good for starters. For different FSes you'll probably have to look around for yourself as there are just brief descriptions on non-fat filesystems.
In general, you should implement a memory manager at first. But this is task of the kernel, not of the boot loader. So at first, you need to load the kernel.
If you use grub and multiboot, you don't need to load the kernel and you should start with memory management.
But if you want to load your kernel and the kernel image is a file, you need of course write some filesystem code to find the kernel file. In general, the kernel file has got a fixed position and you don't need to start with a file system.
If you use grub and multiboot, you don't need to load the kernel and you should start with memory management.
But if you want to load your kernel and the kernel image is a file, you need of course write some filesystem code to find the kernel file. In general, the kernel file has got a fixed position and you don't need to start with a file system.
i read the tutorials here http://www.osdev.org/osfaq2/ and downloaded the document of the fat (i finaly understod the theory of file system)Regarding the filesystem, theres some thorough documentation on the FAT system in the wiki, which is good for starters. For different FSes you'll probably have to look around for yourself as there are just brief descriptions on non-fat filesystems.
this is a good stuff too: http://bcos.zapto.org/sfs/sfs.html
i think with int 13h you cane put the kernel in the second sector (that is for FAT as i read) and and your boot sector will use the int 13h to read the kernel but in this way the disk will need to be formated if i opened it with windows actually i am using bochsBut if you want to load your kernel and the kernel image is a file, you need of course write some filesystem code to find the kernel file. In general, the kernel file has got a fixed position and you don't need to start with a file system.
Yes, for example, you will use INT13 to read and write sectors from the diskette. BIOS loads the first sector into 0000:7c00, so you must do these things:
1. Load the Root directory from the diskette.
2. Search in the root directory to find the filename of the file you want to load.
3. Take the entry cluster value from there.
4. Load the FAT into the memory.
5. Use the entry cluster value to calculate and load clusters of the file into the memory.
6. Jump far to the location of the file's entry point to begin execution!
1. Load the Root directory from the diskette.
2. Search in the root directory to find the filename of the file you want to load.
3. Take the entry cluster value from there.
4. Load the FAT into the memory.
5. Use the entry cluster value to calculate and load clusters of the file into the memory.
6. Jump far to the location of the file's entry point to begin execution!
I think, I have problems with Bochs. The biggest one: Bochs hates me!
Yes, for example, you will use INT13 to read and write sectors from the diskette. BIOS loads the first sector into 0000:7c00, so you must do these things:
1. Load the Root directory from the diskette.
2. Search in the root directory to find the filename of the file you want to load.
3. Take the entry cluster value from there.
4. Load the FAT into the memory.
5. Use the entry cluster value to calculate and load clusters of the file into the memory.
6. Jump far to the location of the file's entry point to begin execution!
can we use this way without formating the disk with windows?
i think when you copy the boot loader to the boot sector it clear all the data on the disk even FAT. i mean if i used part copy the FAT will be on the disk the program willn't delete the FAT ?
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Find a FAT bootloader. For example, the following searches the root directory of the FAT12 filesystem for KERNEL.COM and then runs it:
This searches a FAT12 filesystem for the file, then loads it into the memory and executes it. (KERNEL.COM must have an origin of 0x0000)
Code: Select all
; FAT12 Boot Sector
; Assemble with NASM
bits 16
org 0x7C00
start: jmp short begin
nop
bsOEM db "Mattise1" ; OEM String
bsSectSize dw 512 ; Bytes per sector
bsClustSize db 1 ; Sectors per cluster
bsRessect dw 1 ; # of reserved sectors
bsFatCnt db 2 ; # of fat copies
bsRootSize dw 224 ; size of root directory
bsTotalSect dw 2880 ; total # of sectors if < 32 meg
bsMedia db 0xF0 ; Media Descriptor
bsFatSize dw 9 ; Size of each FAT
bsTrackSect dw 18 ; Sectors per track
bsHeadCnt dw 2 ; number of read-write heads
bsHidenSect dd 0 ; number of hidden sectors
bsHugeSect dd 0 ; if bsTotalSect is 0 this value is
; the number of sectors
bsBootDrv db 0 ; holds drive that the bs came from
bsReserv db 0 ; not used for anything
bsBootSign db 29h ; boot signature 29h
bsVolID dd 0 ; Disk volume ID also used for temp
; sector # / # sectors to load
bsVoLabel db "MATTISEOS " ; Volume Label
bsFSType db "FAT12 " ; File System type
begin: cli ; disable interrupts
mov [bsBootDrv],dl ; save drive number
mov ax,0x9000 ; put stack at 0x98000
mov ss,ax
mov sp,0x8000
mov cx,[bsTrackSect] ; update int 1E FDC param table
mov bx,0x0078
lds si,[ds:bx]
mov byte [si+4], cl
mov byte [si+9], 0x0F
sti ; enable interrupts
push ds
mov dl,[bsBootDrv] ; reset controller
xor ax,ax
int 0x13
pop ds
jc bootfail2 ; display error message
jmp _l1
bootfail2: jmp bootfail
_l1:
mov ax,0x0000
mov es,ax
mov ds,ax
mov si,MsgLoad ; display load message
call putstr
; find the root directory
xor ax,ax
mov al,[bsFatCnt]
mov bx,[bsFatSize]
mul bx
add ax,word [bsHidenSect]
adc ax,word [bsHidenSect+2]
add ax,word [bsRessect] ; ax holds root directory location
mov word [BootSig],ax
call checkroot
mov bx,word [bsVolID]
mov word [filesect],bx
xor ax,ax
add ax,word [start]
add ax,word [bsVolID] ; sector number
add ax,word [BootSig]
sub ax,2 ; correction for a mis-calc
mov cx,word [bsVolID+2] ; number of sectors
mov bx,0x8000
mov es,bx
nextsector: push ax ; save registers
push cx
push dx
push es
xor bx,bx ; set zero offset
call readsect ; read a sector
mov si,MsgDot ; display a dot
call putstr
pop es ; restore registers
pop dx
pop cx
pop ax
mov bx,es
add bx,20h ; increment address 512 bytes
mov es,bx
inc ax ; read next sector
loopnz nextsector
mov si,MsgComp ; display a dot
call putstr
push bsBootDrv
push filesect ; sector of mattise
mov ax,0x8000 ; set segment registers and jump
mov es,ax
mov ds,ax
push ax
mov ax,0
push ax
retf
checkroot:
push ax ; save registers
push bx
push cx
push dx
push si
push di
mov ax,0x8000 ; put root directory at 0x80000
mov es,ax
mov ax,32 ; AX = ((32*RootSize)/512) + 2
mul word [bsRootSize]
div word [bsSectSize]
mov cx,ax ; cx holds # of sectors in root
mov word [start],ax
mov ax,word [BootSig] ; get prev. saved loc. for root dir
r1: xor bx,bx
push cx ; save count
push ax ; save sector number
push es
push dx
call readsect
xor bx,bx
l_1: mov di,bx ; set address to check from
mov cx,11 ; check 11 bytes
mov si,FileName ; address of string to check with
repz cmpsb
je foundit
add bx,32 ; check next entry
cmp bx,[bsSectSize] ; end of sector?
je l_2
jmp l_1
l_2: pop dx ; restore registers
pop es
pop ax
pop cx
inc ax ; read next sector
loopnz r1
jmp bootfail
foundit: pop dx ; get these off the stack
pop es
pop ax
pop cx
mov di,0x1A ; get clustor #
add di,bx
push bx ; save bx for finding # of sectors
mov ax,[es:di]
xor bx,bx ; calculate sector #
mov bl,[bsClustSize]
mul bx ; ax holds sector #
mov word [bsVolID],ax
pop bx ; get location of directory entry
mov di,0x1C
add di,bx
mov ax,[es:di] ; put number of bytes in ax
xor dx,dx
mov bx,[bsClustSize] ; # of bytes / 512
div bx
inc ax
mov word [bsVolID+2],ax ; save number of sectors to load
pop di ; restore registers
pop si
pop dx
pop cx
pop bx
pop ax
ret ; return to caller
putstr: ; SI = address of string to display
lodsb
or al,al
jz short putstrd
mov ah,0x0E
mov bx,0x0007
int 0x10
jmp putstr
putstrd: retn ; return to caller
bootfail: ; display failure message
mov si,MsgBad ; display error message
call putstr
xor ax,ax ; wait for keypress
int 0x16
int 0x19 ; reboot
readsect: ; ES:BX = Location ; AX = Sector
mov si,[bsTrackSect]
div si ; divide logical sect by track size
inc dl ; sector # begins at 1
mov [bsReserv],dl ; sector to read
xor dx,dx ; logical track left in ax
div word [bsHeadCnt] ; leaves head in dl, cyl in ax
mov dh, [bsBootDrv] ;
xchg dl,dh ; head to dh, drive to dl
mov cx,ax ; cyl to cx
xchg cl,ch ; low 8 bits of cyl to ch, hi 2 bits
shl cl,6 ; shifted to bits 6 and 7
or cl, byte [bsReserv] ; or with sector number
mov al,1 ; number of sectors
mov ah,2 ; use read function of int 0x13
int 0x13 ; read sector
jc bootfail ; display error message
ret ; return to caller
FileName db "KERNEL COM" ; 8.3 format - spaces make sure of it
MsgBad db "Couldn't boot!",13,10,0
MsgDot db ".",0
Newline db 13,10,0
MsgLoad db "Loading...",0
MsgComp db " Complete!",13,10,0
filesect dw 0
times 510-($-$$) db 0
BootSig db 0x55, 0xAA
thanks
then i can copy the kernel with copy>>paste normaly in to the desk and use the boot loader to load it into memory but if i use boshs how can i make this i make them one file(bootloader+kernel) with the copy command and then use it normaly with boshs ?
edit:
i mean bochs he he he
then i can copy the kernel with copy>>paste normaly in to the desk and use the boot loader to load it into memory but if i use boshs how can i make this i make them one file(bootloader+kernel) with the copy command and then use it normaly with boshs ?
edit:
i mean bochs he he he
Last edited by mohammed on Sat Jan 20, 2007 4:33 am, edited 1 time in total.
You need a floppy image. If you have a FAT12 Bootloader, creare an empty floppy image with that boot loader. Mount it and copy your kernel to the floppy. For windows, there a some tools to work with images. I don't know a good one, but I know that UltraISO for example can deal with FAT12-Images.
For Linux, you could use:
# mount -o loop floppy.img /mnt/floppy
If you know how the FAT12 file system works, you could write your own code to do that if you don't find any tools
For Linux, you could use:
# mount -o loop floppy.img /mnt/floppy
If you know how the FAT12 file system works, you could write your own code to do that if you don't find any tools
If you are using Windows XP, filedisk(http://www.acc.umu.se/~bosse/) can be used to mount disk images. After you mount them, windows treats them just as a normal drive and lets you format them, run a chkdsk on them, or anything else you can do with a normal drive.
i knew how you can do it with the command "cat" in Cygwin
so you can use this file with boshs
edit:
bochs..you are so kind here cause no body laughed at me when i said "boshs"
Code: Select all
cat boot.bin kernel.bin | dd of=image_file bs=512 conv=notrunc
edit:
bochs..you are so kind here cause no body laughed at me when i said "boshs"