Explorar el Código

LSFS starting to work, creation of files

pull/1/head
Jørn Guldberg hace 5 años
padre
commit
86a4e6e357
Se han modificado 2 ficheros con 101 adiciones y 84 borrados
  1. +11
    -8
      kernel.nasm
  2. +90
    -76
      vsfs/lsfs.nasm

+ 11
- 8
kernel.nasm Ver fichero

@ -2,10 +2,10 @@ BITS 16
start_sing:
; loading essentials for SingOS to run
; VSFS is loaded:
mov [global_disk_identifier], dl ; saving disk_identifier, this is the number the disk that we are booting from.
; This number is set by the bios
call lsfs_check_extended_support ; Check that the int 0x13 extended read and write is available
jmp sing_loaded
%include "mem_lib/mem_lib.nasm"
%include "lib/os_lib.nasm"
@ -284,10 +284,10 @@ wait_for_key:
global_vars:
global_lsfs_master_record dw 8 ; this is the index of the start of the master table for the filesystem
; This should maby contain more information.
; and somehow be setted in a fix sector, which holds all the variabels for SingOS
; 8 is currently the magic number where the file system starts on our disk.
global_lsfs_master_record dw 2064 ; this is the index of the start of the master table for the filesystem
; This should maby contain more information.
; and somehow be setted in a fix sector, which holds all the variabels for SingOS
; 2064 is currently the magic number where the file system starts on our disk.
global_lsfs_next_index dw 0 ; This is the next index to the next file created.
; this var is set durling load of SingOS
@ -297,7 +297,7 @@ global_vars:
; this is the bios ID
data:
welcome db "###############################################################################", 13, 10, "# Welcome to SingOS VERSION 0.0.3.6 #", 13, 10, "# #", 13, 10, "###############################################################################", 13, 10, 'Press ESC to halt.', 13, 10, 13, 10, 0
welcome db "###############################################################################", 13, 10, "# Welcome to SingOS VERSION 0.0.3.12 #", 13, 10, "# #", 13, 10, "###############################################################################", 13, 10, 'Press ESC to halt.', 13, 10, 13, 10, 0
exit_message db 13, 10, 'Goodbye from SingOS',13,10,'The system has halted.', 0
command_line db 13, 10, 'groot@SingOS $ ', 0
number_one_zstring db '71', 0
@ -305,4 +305,7 @@ data:
;times 131072-($-$$) db 0 ; 256 sectos
;GLOBAL_VSFS_START db 'VSFS v0.1' ; sector 257 reserved for file system information
times (1<<20)-($-$$) db 0 ; sector 258 to sector 2048 should be avaliable to the filesystem.
times ((1<<20)-($-$$) - 26) db 0 ; sector 258 to sector 2048 should be avaliable to the filesystem.
magic_string_end_of_SingOS_kernel db '** END OF KERNEL SingOS **'
times ((1<<23)-($-$$)) db 0

+ 90
- 76
vsfs/lsfs.nasm Ver fichero

@ -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)

Cargando…
Cancelar
Guardar