|
|
@ -1,10 +1,71 @@ |
|
|
|
BITS 16 |
|
|
|
vsfs_format_disk: |
|
|
|
; When SingOS it booted for the first time, |
|
|
|
; we have to format the disk to create the global structure |
|
|
|
; of the VSFS. |
|
|
|
|
|
|
|
;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 |
|
|
|
|
|
|
|
; Set the bx to point to the pointer of the sector we have to write |
|
|
|
; to the disk. |
|
|
|
mov bx, .vsfs_format_disk_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, 0x00 ;Drive number |
|
|
|
int 0x13 ;Low level disk services |
|
|
|
|
|
|
|
ret |
|
|
|
|
|
|
|
.vsfs_format_disk_buffer db 'VSFS v0.1', 13, 10, '(VerySimpelFileSystem)', 13, 10, 'Developed to SingOS', 13, 10, 'by Jorn Guldberg', 13, 10 ; 66 chars + 8 bytes |
|
|
|
times 434 db 0 |
|
|
|
dw 8, 9 |
|
|
|
|
|
|
|
vsfs_get_fs_info: |
|
|
|
popa |
|
|
|
mov bx, ds |
|
|
|
mov es, bx |
|
|
|
mov bx, vsfs_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 cl, 0x01 ; First sector to read (bits 0-5), upper bits of cylinder (bits 6-7) |
|
|
|
mov dh, 0x00 ; Head number |
|
|
|
mov dl, 0x00 ; Drive number |
|
|
|
int 0x13 |
|
|
|
|
|
|
|
mov si, vsfs_loading_buffer |
|
|
|
call print_os |
|
|
|
pusha |
|
|
|
|
|
|
|
vsfs_read_file_index_in_ax: |
|
|
|
; INPUT ax = file index |
|
|
|
; INPUT FOR FUNCTION file index at bx |
|
|
|
; INPUT bx = filebuffer |
|
|
|
pusha ; save all register state |
|
|
|
call vsfs_convert_index_into_regs |
|
|
|
;call vsfs_convert_index_into_regs |
|
|
|
;mov bx, .buffer_for_svim |
|
|
|
push bx |
|
|
|
mov bx, ds |
|
|
|
mov es, bx |
|
|
|
pop bx |
|
|
|
|
|
|
|
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 |
|
|
@ -52,51 +113,103 @@ vsfs_convert_index_into_regs: |
|
|
|
|
|
|
|
ret |
|
|
|
|
|
|
|
vfsf_write_file_system_information: |
|
|
|
|
|
|
|
ret |
|
|
|
|
|
|
|
vfsf_create_file: |
|
|
|
vsfs_create_file: |
|
|
|
; ax pointer to filename |
|
|
|
; bx size |
|
|
|
; cx fileIndex |
|
|
|
|
|
|
|
pusha ; save all register state |
|
|
|
|
|
|
|
mov si, .vfsf_create_file_type_filename |
|
|
|
|
|
|
|
mov si, .vsfs_create_file_type_filename |
|
|
|
call print_os |
|
|
|
|
|
|
|
; Ask the user for the filename |
|
|
|
xor bx, bx |
|
|
|
xor cx, cx ; are going to be the counter |
|
|
|
xor dx, dx |
|
|
|
.enter_filename_loop: |
|
|
|
push cx |
|
|
|
mov ax, 0x10 ; BIOS call to wait for key |
|
|
|
int 0x16 |
|
|
|
cmp ax, 0x1c0d ; enter key |
|
|
|
je .filename_done |
|
|
|
.no_enter: |
|
|
|
mov bh, 0x00 |
|
|
|
mov bl, 0x02 |
|
|
|
mov ah, 0x0E |
|
|
|
int 0x10 ; print char |
|
|
|
pop cx |
|
|
|
mov bx, .new_filename_buffer |
|
|
|
add bx, cx |
|
|
|
mov [bx], al |
|
|
|
add cx, 1 |
|
|
|
; filename must only be 120 chars |
|
|
|
cmp cx, 120 |
|
|
|
jae .filename_done |
|
|
|
|
|
|
|
jmp .enter_filename_loop |
|
|
|
|
|
|
|
.filename_done: |
|
|
|
pop cx ; Cleanup, and now contain filename size |
|
|
|
call printCRLF_os |
|
|
|
|
|
|
|
|
|
|
|
; We first need to know the index for the file. |
|
|
|
; The next avaliable index are we going to get from the |
|
|
|
; FSinfo sctor of the disk: |
|
|
|
mov bx, ds |
|
|
|
mov es, bx |
|
|
|
|
|
|
|
mov bx, vsfs_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, 0x00 ; Drive number |
|
|
|
int 0x13 |
|
|
|
|
|
|
|
mov ax, [vsfs_loading_buffer + 510] |
|
|
|
; We have to do modulo 4, to know where in the sector the |
|
|
|
; file entry has to be written |
|
|
|
|
|
|
|
mov [.to_write_fileindex], ax |
|
|
|
; Now we have the index in ax. |
|
|
|
|
|
|
|
;AH 03h |
|
|
|
;AL Sectors To Write Count |
|
|
|
;CH Track |
|
|
|
;CL Sector |
|
|
|
;DH Head |
|
|
|
;DL Drive |
|
|
|
;ES:BX Buffer Address Pointer |
|
|
|
|
|
|
|
; 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 |
|
|
|
xor bx, bx |
|
|
|
mov bx, .test_file_name |
|
|
|
xor cx, cx |
|
|
|
xor ax, ax |
|
|
|
|
|
|
|
; 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 cl, 0x01 ;First sector to read (bits 0-5), upper bits of cylinder (bits 6-7) |
|
|
|
mov ch, 0x09 |
|
|
|
mov cl, 0x02 ;First sector to write (bits 0-5), upper bits of cylinder (bits 6-7) |
|
|
|
mov ch, 0x08 |
|
|
|
mov dh, 0x00 ;Head number |
|
|
|
mov dl, 0x00 ;Drive number |
|
|
|
int 0x13 ;Low level disk services |
|
|
|
popa |
|
|
|
ret |
|
|
|
|
|
|
|
ret |
|
|
|
|
|
|
|
.vfsf_create_file_type_filename db 'Enter filename: ', 0 |
|
|
|
.vfsf_create_file_type_filetype db 'Enter file index: ', 0 |
|
|
|
.test_file_name db 'README.md' |
|
|
|
times 118 db 0 |
|
|
|
dw 9 |
|
|
|
.vsfs_create_file_type_filename db 'Enter filename: ', 0 |
|
|
|
.new_filename_buffer times 122 db 0 |
|
|
|
.new_file_size dw 0, 0 |
|
|
|
.to_write_fileindex dw 0 |
|
|
|
|
|
|
|
vfsf_list_files_command: |
|
|
|
vsfs_list_files_command: |
|
|
|
; This function takes the adress of the first sector of the disk |
|
|
|
; which the OS has to know |
|
|
|
; the adress is given by ax |
|
|
@ -105,12 +218,26 @@ vfsf_list_files_command: |
|
|
|
pusha |
|
|
|
|
|
|
|
; Load the master table into memory |
|
|
|
mov ax, 9 ; file index for master record |
|
|
|
mov bx, vfsf_loading_buffer ; pointer to the input buffer |
|
|
|
call vsfs_read_file_index_in_ax ; call the fucntion which read the master record |
|
|
|
;mov ax, 8 ; file index for master record |
|
|
|
;mov bx, vsfs_loading_buffer ; pointer to the input buffer |
|
|
|
;call vsfs_read_file_index_in_ax ; call the fucntion which read the master record |
|
|
|
; TODO we might want this to be in memory at all times |
|
|
|
; loaded already from boot |
|
|
|
|
|
|
|
mov bx, ds |
|
|
|
mov es, bx |
|
|
|
mov bx, vsfs_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 cl, 0x02 ; First sector to read (bits 0-5), upper bits of cylinder (bits 6-7) |
|
|
|
mov dh, 0x00 ; Head number |
|
|
|
mov dl, 0x00 ; Drive number |
|
|
|
int 0x13 |
|
|
|
|
|
|
|
mov si, .ls_header |
|
|
|
call print_os |
|
|
|
|
|
|
@ -118,7 +245,7 @@ vfsf_list_files_command: |
|
|
|
call print_os |
|
|
|
|
|
|
|
|
|
|
|
mov ax, [vfsf_loading_buffer + 127] |
|
|
|
mov ax, [vsfs_loading_buffer + 126] |
|
|
|
mov bx, ax |
|
|
|
mov cx, ' ' |
|
|
|
mov dx, 'X' |
|
|
@ -148,30 +275,12 @@ vfsf_list_files_command: |
|
|
|
|
|
|
|
mov si, .fileentry_line ; printing the buffer |
|
|
|
call print_os |
|
|
|
mov si, vfsf_loading_buffer ; printing the buffer |
|
|
|
mov si, vsfs_loading_buffer ; printing the buffer |
|
|
|
call print_os |
|
|
|
|
|
|
|
call printCRLF_os |
|
|
|
mov si, .seperate_line |
|
|
|
call print_os |
|
|
|
;mov si, .seperate_line |
|
|
|
;call print_os |
|
|
|
;mov si, .File_name_1 |
|
|
|
;call print_os |
|
|
|
;mov si, .seperate_line |
|
|
|
;call print_os |
|
|
|
;mov si, .File_name_2 |
|
|
|
;call print_os |
|
|
|
;mov si, .seperate_line |
|
|
|
;call print_os |
|
|
|
;mov si, .File_name_3 |
|
|
|
;call print_os |
|
|
|
;mov si, .seperate_line |
|
|
|
;call print_os |
|
|
|
;mov si, .File_name_4 |
|
|
|
;call print_os |
|
|
|
;mov si, .seperate_line |
|
|
|
;call print_os |
|
|
|
.end_ls: |
|
|
|
popa |
|
|
|
ret |
|
|
@ -180,4 +289,4 @@ vfsf_list_files_command: |
|
|
|
.seperate_line db '- - - - - - - - - - - - - - - - ', 13, 10, 0 |
|
|
|
.fileentry_line db ' 456 | ', 0 |
|
|
|
|
|
|
|
vfsf_loading_buffer times 512 db 0 |
|
|
|
vsfs_loading_buffer times 512 db 0 |