|
|
@ -1,23 +1,39 @@ |
|
|
|
BITS 16 |
|
|
|
lsfs_format_disk: |
|
|
|
; When SingOS it booted for the first time, |
|
|
|
; we have to format the disk to create the global structure |
|
|
|
; of the lSFS. |
|
|
|
pusha |
|
|
|
|
|
|
|
lsfs_check_extended_support: |
|
|
|
; We have to test if the System support exented read/write bios int 13, |
|
|
|
; If not, the system cannot use the disk. |
|
|
|
|
|
|
|
; If not, the system cannot use the disk. |
|
|
|
mov ah, 0x41 ;Set AH = 0x41 |
|
|
|
mov bx, 0x55aa ;BX = 0x55AA |
|
|
|
mov dl, [global_disk_identifier] ;DL = disk_id |
|
|
|
int 0x13 ;Issue an INT 0x13. |
|
|
|
|
|
|
|
jnc .no_carry |
|
|
|
int 0x13 |
|
|
|
;Issue an INT 0x13. |
|
|
|
jnc .is_supported |
|
|
|
; The System does support exented read write |
|
|
|
mov si, lsfs_disk_error_msg |
|
|
|
call print |
|
|
|
|
|
|
|
mov si, lsfs_disk_error_halt |
|
|
|
call print |
|
|
|
|
|
|
|
mov ax, 0 |
|
|
|
mov ah, 0x10 |
|
|
|
int 0x16 |
|
|
|
jmp .return |
|
|
|
|
|
|
|
.is_supported: |
|
|
|
mov BYTE [lsfs_global_is_suported], 0x1 |
|
|
|
|
|
|
|
.return: |
|
|
|
ret |
|
|
|
|
|
|
|
lsfs_format_disk: |
|
|
|
; When SingOS it booted for the first time, |
|
|
|
; we have to format the disk to create the global structure |
|
|
|
; of the lSFS. |
|
|
|
pusha |
|
|
|
cmp BYTE [lsfs_global_is_suported], 0x0 |
|
|
|
je .error |
|
|
|
|
|
|
|
.no_carry: |
|
|
|
xor ax, ax |
|
|
|
xor bx, bx |
|
|
@ -30,7 +46,7 @@ lsfs_format_disk: |
|
|
|
.blkcnt: dw 0x1 ; int 13 resets this to # of blocks actually read/written |
|
|
|
.db_add_first: dw 0x0 ; memory buffer destination address (0:7c00) |
|
|
|
.db_add_second: dw 0x050 ; in memory page zero |
|
|
|
.d_lba: dd 100 ; put the lba to read in this spot |
|
|
|
.d_lba: dd 2064 ; put the lba to read in this spot |
|
|
|
dd 0x0 ; more storage bytes only for big lba's ( > 4 bytes ) |
|
|
|
|
|
|
|
;mov WORD [.db_add_second], 0x50 |
|
|
@ -51,14 +67,18 @@ lsfs_format_disk: |
|
|
|
|
|
|
|
call dumpax |
|
|
|
call printCRLF |
|
|
|
jmp .return |
|
|
|
.error: |
|
|
|
mov si, lsfs_disk_error_msg |
|
|
|
call print |
|
|
|
|
|
|
|
.return: |
|
|
|
popa |
|
|
|
ret |
|
|
|
|
|
|
|
.lsfs_format_disk_buffer db 'LSFS v0.1', 13, 10, '(VerySimpelFileSystem)', 13, 10, 'Developed to SingOS', 13, 10, 'by Jorn Guldberg', 13, 10, 0 ; 66 chars + 8 bytes |
|
|
|
times 431 db 0 |
|
|
|
dw 8, 0, 9 ; Start index, number of files, next free index |
|
|
|
.lsfs_format_disk_buffer db 'LSFS v0.0.3', 13, 10, '(LessSimpelFileSystem)', 13, 10, 'Developed to SingOS', 13, 10, 'by Jorn Guldberg', 13, 10, 0 ; 66 chars + 8 bytes |
|
|
|
times 429 db 0 |
|
|
|
dw 2064, 0, 1 ; Start index, number of files, next free index |
|
|
|
|
|
|
|
lsfs_get_fs_info: |
|
|
|
pusha |
|
|
@ -75,10 +95,10 @@ lsfs_get_fs_info: |
|
|
|
.db_add: dw 0x0000 ; memory buffer destination address (0:7c00) |
|
|
|
.db_add_sec: dw 0x0050 ; in memory page zero |
|
|
|
|
|
|
|
.d_lba: dd 100 ; put the lba to read in this spot |
|
|
|
.d_lba: dd 2064 ; put the lba to read in this spot |
|
|
|
dd 0 ; more storage bytes only for big lba's ( > 4 bytes ) |
|
|
|
|
|
|
|
mov DWORD [.d_lba], 100 |
|
|
|
mov DWORD [.d_lba], 2064 |
|
|
|
mov WORD [.blkcnt], 0x1 |
|
|
|
mov WORD [.db_add_sec], 0x50 |
|
|
|
mov WORD [.db_add], lsfs_loading_buffer |
|
|
@ -225,15 +245,14 @@ lsfs_create_file: |
|
|
|
mov bx, ds |
|
|
|
mov es, bx |
|
|
|
|
|
|
|
mov bx, lsfs_loading_buffer |
|
|
|
mov ch, 0x08 ; Low 8 bits of cylinder |
|
|
|
; the file index into ch, we need to calculatet this, if the number is larger than 16-bits |
|
|
|
mov ah, 0x02 ; Read sectors from drive |
|
|
|
mov al, 0x01 ; Number of sectors to read (8 * 512 = 4096 bytes) |
|
|
|
mov cl, 0x01 ; First sector to read (bits 0-5), upper bits of cylinder (bits 6-7) |
|
|
|
mov dh, 0x00 ; Head number |
|
|
|
mov dl, [global_disk_identifier] ; Drive number |
|
|
|
int 0x13 |
|
|
|
mov DWORD [DAPACK.lba_addr_dw_one], 2064 |
|
|
|
mov WORD [DAPACK.blkcnt], 0x1 |
|
|
|
mov WORD [DAPACK.db_addr_segment], 0x50 |
|
|
|
mov WORD [DAPACK.db_addr_offset], lsfs_loading_buffer |
|
|
|
mov si, DAPACK ; address of "disk address packet" |
|
|
|
mov ah, 0x42 ; READ |
|
|
|
mov dl, [global_disk_identifier] |
|
|
|
int 0x13 |
|
|
|
|
|
|
|
mov ax, [lsfs_loading_buffer + 510] |
|
|
|
mov [.to_write_fileindex], ax |
|
|
@ -243,43 +262,37 @@ lsfs_create_file: |
|
|
|
add DWORD [lsfs_loading_buffer + 510], 1 |
|
|
|
add DWORD [lsfs_loading_buffer + 508], 1 |
|
|
|
|
|
|
|
mov bx, lsfs_loading_buffer |
|
|
|
mov ah, 0x03 ;Write sectors to drive |
|
|
|
mov al, 0x01 ;Number of sectors to write (8 * 512 = 4096 bytes) |
|
|
|
mov cl, 0x01 ;First sector to read (bits 0-5), upper bits of cylinder (bits 6-7) |
|
|
|
mov ch, 0x08 |
|
|
|
mov dh, 0x00 ;Head number |
|
|
|
mov dl, [global_disk_identifier] ;Drive number |
|
|
|
int 0x13 ;Low level disk services |
|
|
|
; Write the buffer back. |
|
|
|
mov DWORD [DAPACK.lba_addr_dw_one], 2064 |
|
|
|
mov WORD [DAPACK.blkcnt], 0x1 |
|
|
|
mov WORD [DAPACK.db_addr_segment], 0x50 |
|
|
|
mov WORD [DAPACK.db_addr_offset], lsfs_loading_buffer |
|
|
|
mov si, DAPACK ; address of "disk address packet" |
|
|
|
mov ah, 0x43 ; WRITE |
|
|
|
mov dl, [global_disk_identifier] |
|
|
|
int 0x13 |
|
|
|
|
|
|
|
; Now we have the index in ax. |
|
|
|
|
|
|
|
;AH 03h |
|
|
|
;AL Sectors To Write Count |
|
|
|
;CH Track |
|
|
|
;CL Sector |
|
|
|
;DH Head |
|
|
|
;DL Drive |
|
|
|
|
|
|
|
; Set the es to point to the data segment, |
|
|
|
; this is the global segment, where we calculate all |
|
|
|
; our adresses from |
|
|
|
; ES:BX Buffer Address Pointer |
|
|
|
mov bx, ds |
|
|
|
mov es, bx |
|
|
|
|
|
|
|
mov ax, [lsfs_loading_buffer + 508] ; The number of files in the system |
|
|
|
add ax, 2064 ; The Master Record is at 2064, plus the file index, then we have the sector where the file information has to be placed. |
|
|
|
|
|
|
|
mov bx, [.to_write_fileindex] |
|
|
|
sub bx, 0x07 ; Det skal den bare |
|
|
|
mov cl, bl ; First sector to write (bits 0-5), upper bits of cylinder (bits 6-7) |
|
|
|
; Set the bx to point to the pointer of the sector we have to write |
|
|
|
; to the disk. |
|
|
|
mov bx, .new_filename_buffer |
|
|
|
mov ah, 0x03 ;Write sectors to drive |
|
|
|
mov al, 0x01 ;Number of sectors to write (8 * 512 = 4096 bytes) |
|
|
|
mov ch, 0x08 |
|
|
|
mov dh, 0x00 ;Head number |
|
|
|
mov dl, [global_disk_identifier] ;Drive number |
|
|
|
int 0x13 ;Low level disk services |
|
|
|
mov WORD [DAPACK.lba_addr_dw_one], ax |
|
|
|
mov WORD [DAPACK.blkcnt], 0x1 |
|
|
|
mov WORD [DAPACK.db_addr_segment], 0x50 |
|
|
|
mov WORD [DAPACK.db_addr_offset], .new_filename_buffer |
|
|
|
mov si, DAPACK ; address of "disk address packet" |
|
|
|
mov ah, 0x43 ; WRITE |
|
|
|
mov dl, [global_disk_identifier] |
|
|
|
int 0x13 |
|
|
|
|
|
|
|
popa |
|
|
|
ret |
|
|
|
|
|
|
@ -312,21 +325,20 @@ lsfs_list_files_command: |
|
|
|
mov si, .seperate_line |
|
|
|
call print |
|
|
|
|
|
|
|
mov BYTE [.ls_counter], 1 |
|
|
|
mov WORD [.ls_counter], 2064 |
|
|
|
.load_next_fileinfo: |
|
|
|
add BYTE [.ls_counter], 1 |
|
|
|
mov bl, [.ls_counter] |
|
|
|
mov cl, bl ; First sector to read (bits 0-5), upper bits of cylinder (bits 6-7) |
|
|
|
mov bx, lsfs_loading_buffer |
|
|
|
;mov ch, al ; Low 8 bits of cylinder |
|
|
|
; the file index into ch, we need to calculatet this, if the number is larger than 16-bits |
|
|
|
mov ah, 0x02 ; Read sectors from drive |
|
|
|
mov al, 0x01 ; Number of sectors to read (8 * 512 = 4096 bytes) |
|
|
|
mov ch, 0x08 ; cylinder |
|
|
|
mov dh, 0x00 ; Head number |
|
|
|
mov dl, [global_disk_identifier] ; Drive number |
|
|
|
int 0x13 |
|
|
|
add WORD [.ls_counter], 1 |
|
|
|
|
|
|
|
mov bx, [.ls_counter] |
|
|
|
mov WORD [DAPACK.lba_addr_dw_one], bx |
|
|
|
mov WORD [DAPACK.blkcnt], 0x1 |
|
|
|
mov WORD [DAPACK.db_addr_segment], 0x50 |
|
|
|
mov WORD [DAPACK.db_addr_offset], lsfs_loading_buffer |
|
|
|
mov si, DAPACK ; address of "disk address packet" |
|
|
|
mov ah, 0x42 ; READ |
|
|
|
mov dl, [global_disk_identifier] |
|
|
|
int 0x13 |
|
|
|
|
|
|
|
mov ax, [lsfs_loading_buffer + 126] |
|
|
|
mov bx, ax |
|
|
|
mov cx, ' ' |
|
|
@ -372,22 +384,24 @@ lsfs_list_files_command: |
|
|
|
popa |
|
|
|
ret |
|
|
|
|
|
|
|
.ls_counter db 0 |
|
|
|
.ls_counter dw 0 |
|
|
|
.ls_header db 'List of files:', 13, 10, 'Index | Filename ', 13, 10, 0 |
|
|
|
.seperate_line db '- - - - - - - - - - - - - - - - ', 13, 10, 0 |
|
|
|
.fileentry_line db ' 456 | ', 0 |
|
|
|
|
|
|
|
lsfs_disk_error_msg db 'The system does not support disk operations', 13, 10, 0 |
|
|
|
lsfs_disk_error_msg db 'The system does not support disk operations,', 13, 10, 0 |
|
|
|
lsfs_disk_error_halt db 'press a key to continue with no disk operations', 13, 10, 0 |
|
|
|
|
|
|
|
align 2 |
|
|
|
lsfs_loading_buffer times 512 db 0 |
|
|
|
|
|
|
|
DAPACK: |
|
|
|
.dap_Size: db 0x10 ; This is always 16 bytes (0x10) |
|
|
|
.rev_byte: db 0x00 ; reserved byte, should always be zero |
|
|
|
.blkcnt: dw 0x01 ; int 13 resets this to # of blocks actually read/written |
|
|
|
.db_addr_offset: dw 0x0000 ; memory buffer destination address (0:7c00) |
|
|
|
.db_add_segment: dw 0x0050 ; in memory page zero |
|
|
|
|
|
|
|
.d_lba: dd 100 ; put the lba to read in this spot |
|
|
|
dd 0 ; more storage bytes only for big lba's ( > 4 bytes ) |
|
|
|
.dap_Size: db 0x10 ; This is always 16 bytes (0x10) |
|
|
|
.rev_byte: db 0x0 ; reserved byte, should always be zero |
|
|
|
.blkcnt: dw 0x0 ; int 13 resets this to # of blocks actually read/written |
|
|
|
.db_addr_offset: dw 0x0 ; memory buffer destination address (0:7c00) |
|
|
|
.db_addr_segment: dw 0x0 ; in memory page zero |
|
|
|
.lba_addr_dw_one: dd 0x0 ; put the lba to read in this spot |
|
|
|
.lba_addr_dw_two: dd 0x0 ; more storage bytes only for big lba's ( > 4 bytes ) |
|
|
|
|
|
|
|
lsfs_global_is_suported db 0x0 ; 0 means is not supported, when SingOS i booted it will check if it is supported (int 0x13 extended read/write) |