Quote: "Dreq: How many lines have you done so far? Any chance of posting a snippet of code? "
Heh sure:
%macro UFS_Init 0 ; This MUST be called before anything else
; First, load the filetable
mov cx, [_UFS_FILETABLE_DATA_ENTRY]
LoadDisk cx, 0x0005, 0x0002,0x0000
; Then, check to make sure the filesystem is correct
mov cx, [_UFS_FILETABLE_DATA_ENTRY] ; Get the position of the table, header should be here
shl cx, 4
mov dx, _UFS_HEADINFO ; Header to compare the data to
xor bx,bx ; using BX as a counter
%%checkchar:
mov si,cx
lodsb ; Loads next byte in string into AL at DS:SI
; and then incraments SI.
mov bl, al ; Load the next FileTable byte
add cx, 1
mov si,dx ; Load the next headerinfo byte
lodsb
add dx,1
cmp al,0x00
je %%donecheck
cmp bl,al
je %%checkchar
teletypeB{"$10",0}
jmp $
jmp %%checkchar
%%donecheck:
mov cx, [_UFS_FILETABLE_DATA_ENTRY]
add cx, 28 ; This is where the first file's size is
shr cx, 5
mov dx, [_FS_BOOTCODE]
LoadDisk dx, 0x30, 0x0004,0x0000
%endmacro
__LoadDisk:
; Reset the floppy
xor cx, cx
xor ah, ah
xor dl, dl
int 0x13
jc _error
mov ax,[_DISK_DAT_1]
push ax ; This will store the current address location
mov ax,[_DISK_DAT_2]
push ax ; This stores the loop count
mov ax,[_DISK_DAT_3]
push ax ; This will store the sector number and track
mov ax,[_DISK_DAT_4]
push ax ; This will store the current head
jmp _over_error
_error:
teletypeB {"$2",0}
jmp $
_over_error:
_boot_loading_proc:
pop dx ; Load the head
pop cx ; Load the sector
pop bx
sub bx,1 ; Subtract for the loop
pop ax
mov es,ax ; Segment address of the buffer
push ax ; Store the segmand offset
push bx ; Store the loop count
push cx ; Stores the sector number
push dx ; Stores the head number
jmp _do_load
boot_loading_proc_retry:
teletypeB {'X',0}
pop dx ; Head
pop cx ; Sector
pop bx ; Loop
pop ax ; Segment
mov es,ax ; Segment address of the buffer
_done:
push ax
push bx
push cx
push dx
_do_load:
mov ah,0x02 ;Service 02h
mov dl,0x00 ;Drive to read from
;mov dh,0x00 ;Number of the read/write head
;mov ch,0x00 ;Number of the track or cylinder ( 0 = first track )
;mov cl,0x02 ;Number of the sector ( 1 = first sector )
mov al,0x01 ;Number of sectors to read (stage2 size div 512)
mov bx,0x00 ;Offset address of the buffer
int 0x13
jnc _done_load_sect
jmp boot_loading_proc_retry
_done_load_sect:
pop dx ; Get the head number
pop cx ; Get the sector number
pop bx ; Get the loop count
pop ax ; Get the address
cmp bx,0 ; See if we have finished our loop
je _done_loading ; If so, march on!
add ax, 20h ; There are 512 bytes per sector, add for next!
add cl, 1 ; And we want to load the next sector of course!
cmp cl,19 ; Whoops, we are now pointing to an invalid sector!
jc _skip_track_add
cmp dh,0x01
je _do_head_1
_do_head_0: ; Head zero is selected, we must set it to 1 and reset our sector and leave our track alone
mov dh, 0x01 ; Set the head to 1
mov cl, 0x01 ; Reset the sector
jmp _skip_track_add
_do_head_1: ; Head one is selected, we can now advanced our track and reset the head
add ch, 0x01 ; Lets try the next track!
mov cl, 0x01 ; And of course reset the sector
mov dh, 0x00 ; Finaly, we set our head back to 0
_skip_track_add:
push ax ; Store the new address
push bx ; Store the loop count
push cx ; Store the sector number
push dx ; Store the head number
jmp _boot_loading_proc ; And continue on with the loading
_done_loading:
;pop ax ; Clear the stack
;pop ax
;pop ax
;pop ax
ret
Thats a macro I used in a slightly older version of JFOS (back when i was using my UFS disk filesystem I wrote), although now it boots from CD. That code intializes the UFS table in order to load the first file that was written to the disk (ala the kernel).
"I LIKE MARSHMELLOWS!" - Homestar Runner