Ver a proveniência

Merge branch 'master' of git.imada.sdu.dk:SingOS/SingOS into IDT

IDT
Jakob Kjær-Kammersgaard há 5 anos
ascendente
cometimento
0aa742d386
8 ficheiros alterados com 423 adições e 72 eliminações
  1. +24
    -17
      bootloader.nasm
  2. +6
    -6
      build.sh
  3. +114
    -33
      filesystems/lsfs/lsfs.nasm
  4. +23
    -0
      filesystems/lsfs/test_lsfs.nasm
  5. +7
    -7
      kernel.nasm
  6. +14
    -1
      lib/os_lib.nasm
  7. +9
    -8
      lib/svim.nasm
  8. +226
    -0
      vbr.nasm

+ 24
- 17
bootloader.nasm Ver ficheiro

@ -2,7 +2,7 @@ ORG 0x7C00
BITS 16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Bootloader for SingOS
; version 0.1.0.6
; version 0.1.0.9-exp
;
; Please edit the version number if any changes is made, the last number
; represent the build number.
@ -31,6 +31,7 @@ start:
mov si, enter_debug_mode
call print
call printCRLF
%IF 1
; here goes wait call, for the user to enter debug mode.
; Wating for 2 seconds:
mov ah, 0x86 ; code for waiting interupt call
@ -43,7 +44,7 @@ start:
mov ah, 0x01 ; BIOS call to wait for key
int 0x16
jnz debug_mode
%ENDIF
; entering system check:
mov si, enter_system_check
@ -54,15 +55,15 @@ start:
call print ; Call our string-printing routine
;This goes first as to now overwrite %ah and %al.
mov ax, 0x0
mov ax, 0x0050
mov es, ax ;Section to write into
mov ah, 0x2 ;Read sectors from drive
mov al, 0x1f ;Number of sectors to read (31 * 512 = 15872 bytes)
mov al, 0x08 ;Number of sectors to read (31 * 512 = 15872 bytes)
mov ch, 0x0 ;Low 8 bits of cylinder
mov cl, 0x11 ;First sector to read (bits 0-5), upper bits of cylinder (bits 6-7)
mov dh, 0x0 ;Head number
mov dl, [disk_identifier] ;Drive number
mov bx, 0x500 ;Offset into section
mov bx, 0x0000 ;Offset into section
int 0x13 ;Low level disk services
jnc notcarry
@ -82,10 +83,16 @@ start:
;call printCRLF
mov dl, [disk_identifier]
xor ax, ax
mov al, dl
call dumpax
call printCRLF
mov ax, 0x50
mov ds, ax
jmp 0x50:0x00 ; Jump to the kernel
mov ax, 89 ; lba adress
jmp 0x50:0x0000 ; Jump to the kernel
endcarrycheck:
cli ; Clear the Interrupt Flag (disable external interrupts)
@ -143,7 +150,7 @@ print:
ret
data:
message db 'Bootloader for SingOS! v0.1.0.7',13,10,0
message db 'Bootloader for SingOS! v0.1.0.9-exp',13,10,0
enter_debug_mode db 'Press d to enter bootloader debug mode',13,10,0
enter_system_check db 'Performing system check:',13,10,0
sys_check_ok db 'System check ok', 13, 10, 0
@ -155,18 +162,18 @@ data:
; Pad to 510 bytes (boot sector size minus 2) with 0s, and finish with the two-byte standard boot signature
times 446-($-$$) db 0 ; First partion entry
db 0x80 ; active partition
db 0, 0x01, 0x00 ; First sector CHS
db 0, 0x00, 0x17 ; First sector CHS
db 0x00 ; Disk type (Other)
db 0x3f, 0x60, 0x21 ; Ending CHS values
db 0, 0, 0, 0x00 ; Staring LBA
db 0, 0x10, 0x09, 0x00 ; Size
db 0xff, 0xff, 0xff ; Ending CHS values
db 0x17, 0, 0, 0x00 ; Staring LBA
db 0, 0xff, 0xff, 0xff ; Size
db 0x00
db 0xFE, 0xFF, 0xFF
db 0xEF
db 0xFE, 0xFF, 0xFF
db 0xB0, 0x0E, 0x00, 0x00
db 0x40, 0x03, 0x00, 0x00
db 0x0, 0x0, 0x0
db 0x0
db 0x0, 0x0, 0x0
db 0x00, 0x00, 0x00, 0x00
db 0x0, 0x00, 0x00, 0x00
times 478-($-$$) db 0 ; Third partion entry

+ 6
- 6
build.sh Ver ficheiro

@ -1,13 +1,13 @@
#!/bin/bash
if [ "$1" != "run" ]; then
nasm -fbin bootloader.nasm -o bootloader.bin
nasm -fbin kernel.nasm -o kernel.bin
cat bootloader.bin kernel.bin > SingOS.img
nasm -fbin bootloader.nasm -o bootloader.bin
nasm -fbin vbr.nasm -o vbr.bin
nasm -fbin filesystems/lsfs/test_lsfs.nasm -o lsfs.bin
nasm -fbin kernel.nasm -o kernel.bin
cat bootloader.bin vbr.bin lsfs.bin kernel.bin > SingOS.img
fi
if [ "$1" != "make" ]; then
qemu-system-x86_64 -drive index=0,format=raw,file=SingOS.img
qemu-system-x86_64 -drive index=0,format=raw,file=SingOS.img
fi
echo "Done"

+ 114
- 33
filesystems/lsfs/lsfs.nasm Ver ficheiro

@ -1,10 +1,15 @@
BITS 16
%define LSFS_FIX_FILE_SIZE 0x10
%define LSFS_magic_start_sector 2064 ; This is the sector right after the SingOS kernel stops and is a magic number that has to be changed when the kernel grows.
%define LSFS_magic_start_sector 24 ; This is the sector right after the SingOS kernel stops and is a magic number that has to be changed when the kernel grows.
%define FSCI_sector 88
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.
xor ax, ax
mov BYTE al, [global_disk_identifier]
call dumpax
mov ah, 0x41 ;Set AH = 0x41
mov bx, 0x55aa ;BX = 0x55AA
mov dl, [global_disk_identifier] ;DL = disk_id
@ -66,7 +71,7 @@ lsfs_get_fs_info:
pusha
mov WORD [DAPACK.db_addr_offset], lsfs_loading_buffer
mov WORD [DAPACK.lba_addr_dw_low], LSFS_magic_start_sector
mov WORD [DAPACK.lba_addr_dw_low], FSCI_sector
mov WORD [DAPACK.blkcnt], 0x1 ; Read to sectors, that is what the space is for the buffer in svim
mov WORD [DAPACK.db_addr_segment], 0x50
mov si, DAPACK ; address of "disk address packet"
@ -84,15 +89,30 @@ lsfs_read_file:
; INPUT ax = file index
; INPUT bx = filebuffer
pusha ; save all register state
; Save the buffer addr
mov WORD [DAPACK.db_addr_offset], bx
; We need to find the data pointers for the file.
; The file index, has to be multiplied by the magic file_size
mov bx, LSFS_FIX_FILE_SIZE
mul bx
; OBS HARDCODED, The mul can give us a much higher number and DAPACK.lba_addr_dw_low takes a DWORD.
add ax, LSFS_magic_start_sector
push bx
mov dx, LSFS_magic_start_sector
add ax, dx ; senctor number, into the master Table.
mov WORD [DAPACK.db_addr_offset], lsfs_loading_buffer
mov WORD [DAPACK.lba_addr_dw_low], ax
mov WORD [DAPACK.blkcnt], 0x1 ; Read to sectors, that is what the space is for the buffer in svim
mov WORD [DAPACK.db_addr_segment], 0x50
mov si, DAPACK ; address of "disk address packet"
mov ah, 0x42 ; READ
mov dl, [global_disk_identifier]
int 0x13
pop bx
; Save the buffer addr
mov WORD [DAPACK.db_addr_offset], bx
mov bx, [lsfs_loading_buffer + 288] ; this is the first data pointer
mov ax, bx
mov WORD [DAPACK.lba_addr_dw_low], bx
mov WORD [DAPACK.blkcnt], 0x4 ; Read to sectors, that is what the space is for the buffer in svim
mov WORD [DAPACK.db_addr_segment], 0x50
mov si, DAPACK ; address of "disk address packet"
@ -101,22 +121,49 @@ lsfs_read_file:
int 0x13
popa
mov ax, [lsfs_loading_buffer + 264]
ret
lsfs_write_file:
; INPUT ax = file index
; INPUT bx = filebuffer
; INOUT cx = file size
pusha ; save all register state
; Save the buffer addr
mov WORD [DAPACK.db_addr_offset], bx
; We need to find the data pointers for the file.
push bp
mov bp, sp
sub sp, 6
; The file index, has to be multiplied by the magic file_size
mov bx, LSFS_FIX_FILE_SIZE
mul bx
; OBS HARDCODED, The mul can give us a much higher number and DAPACK.lba_addr_dw_low takes a DWORD.
add ax, LSFS_magic_start_sector
%define var_file_id [bp - 0]
%define var_file_buffer [bp - 2]
%define var_file_size [bp - 4]
mov var_file_buffer, bx
mov var_file_size, cx
mov dx, LSFS_magic_start_sector
add ax, dx ; senctor number, into the master Table.
mov var_file_id, ax
mov WORD [DAPACK.db_addr_offset], lsfs_loading_buffer
mov WORD [DAPACK.lba_addr_dw_low], ax
mov WORD [DAPACK.blkcnt], 0x1 ; Read to sectors, that is what the space is for the buffer in svim
mov WORD [DAPACK.db_addr_segment], 0x50
mov si, DAPACK ; address of "disk address packet"
mov ah, 0x42 ; READ
mov dl, [global_disk_identifier]
int 0x13
; Save the buffer addr
mov bx, var_file_buffer
mov WORD [DAPACK.db_addr_offset], bx
mov bx, [lsfs_loading_buffer + 288] ; this is the first data pointer
mov WORD [DAPACK.lba_addr_dw_low], bx
mov ax, bx
mov WORD [DAPACK.blkcnt], 0x4 ; Read to sectors, that is what the space is for the buffer in svim
mov WORD [DAPACK.db_addr_segment], 0x50
mov si, DAPACK ; address of "disk address packet"
@ -124,6 +171,21 @@ lsfs_write_file:
mov dl, [global_disk_identifier]
int 0x13
mov ax, var_file_id
mov bx, var_file_size
mov [lsfs_loading_buffer + 264], bx
mov WORD [DAPACK.db_addr_offset], lsfs_loading_buffer
mov WORD [DAPACK.lba_addr_dw_low], ax
mov WORD [DAPACK.blkcnt], 0x1 ; Read to sectors, that is what the space is for the buffer in svim
mov WORD [DAPACK.db_addr_segment], 0x50
mov si, DAPACK ; address of "disk address packet"
mov ah, 0x43 ; WRITE
mov dl, [global_disk_identifier]
int 0x13
mov sp, bp
pop bp
popa
ret
@ -198,7 +260,7 @@ lsfs_create_file:
; 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 DWORD [DAPACK.lba_addr_dw_low], LSFS_magic_start_sector
mov DWORD [DAPACK.lba_addr_dw_low], FSCI_sector
mov WORD [DAPACK.blkcnt], 0x1
mov WORD [DAPACK.db_addr_segment], 0x50
mov WORD [DAPACK.db_addr_offset], lsfs_loading_buffer
@ -207,16 +269,17 @@ lsfs_create_file:
mov dl, [global_disk_identifier]
int 0x13
mov ax, [lsfs_loading_buffer + 510]
mov [.to_write_fileindex], ax
; We have to do modulo 4, to know where in the sector the
; file entry has to be written
add DWORD [lsfs_loading_buffer + 510], 1
add DWORD [lsfs_loading_buffer + 508], 1
mov bx, [lsfs_loading_buffer + 510]
mov [.new_file_data_pointer], bx
mov ax, [lsfs_loading_buffer + 508]
mov [.to_write_fileindex_16_bit_part], ax
add DWORD [lsfs_loading_buffer + 510], 4 ; First save the data pointer, and then add 4 sectors to get the next free sectors.
add DWORD [lsfs_loading_buffer + 508], 1 ; Increment since we are creating a new file.
; Write the buffer back.
mov DWORD [DAPACK.lba_addr_dw_low], LSFS_magic_start_sector
mov DWORD [DAPACK.lba_addr_dw_low], FSCI_sector
mov WORD [DAPACK.blkcnt], 0x1
mov WORD [DAPACK.db_addr_segment], 0x50
mov WORD [DAPACK.db_addr_offset], lsfs_loading_buffer
@ -234,7 +297,7 @@ lsfs_create_file:
mov bx, ds
mov es, bx
mov ax, [lsfs_loading_buffer + 508] ; The number of files in the system
mov ax, [.to_write_fileindex_16_bit_part] ; The number of files in the system
add ax, LSFS_magic_start_sector ; The Master Record is at LSFS_magic_start_sector, plus the file index, then we have the sector where the file information has to be placed.
mov WORD [DAPACK.lba_addr_dw_low], ax
@ -250,9 +313,20 @@ lsfs_create_file:
ret
.lsfs_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
.new_filename_buffer times 256 db 0
;.file_id:
.to_write_fileindex_16_bit_part dw 0
.to_write_fileindex dw 0, 0, 0
;.file_size
.new_file_size dw 0, 0, 0
.new_file_size_16_bit_part dw 0
.ext_file_data dw 0, 0, 0, 0
.control_bits dw 0, 0, 0, 0
;.file_data_pointers
.new_file_data_pointer dw 0
times 222 db 0
lsfs_list_files_command:
; This function takes the adress of the first sector of the disk
@ -278,7 +352,7 @@ lsfs_list_files_command:
mov si, .seperate_line
call print
mov WORD [.ls_counter], LSFS_magic_start_sector
mov WORD [.ls_counter], 23
.load_next_fileinfo:
add WORD [.ls_counter], 1
@ -292,12 +366,12 @@ lsfs_list_files_command:
mov dl, [global_disk_identifier]
int 0x13
mov ax, [lsfs_loading_buffer + 126]
mov ax, [lsfs_loading_buffer + 256]
mov bx, ax
mov cx, ' '
mov dx, 'X'
cmp ax, 0
cmp BYTE [lsfs_loading_buffer], 0
je .end_ls
cmp ax, 10
ja .index_over_10
@ -348,6 +422,13 @@ lsfs_disk_error_halt db 'press a key to continue with no disk operations', 13, 1
align 2
lsfs_loading_buffer times 512 db 0
MetaInformationFormat:
.filename: times 252 db 0
.file_id: dw 0
.file_size dw 0
.file_data_pointers times 256 db 0
DAPACK:
.dap_Size: db 0x10 ; This is always 16 bytes (0x10)
.rev_byte: db 0x0 ; reserved byte, should always be zero
@ -357,4 +438,4 @@ DAPACK:
.lba_addr_dw_low: dd 0x0 ; put the lba to read in this spot
.lba_addr_dw_high: 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)
lsfs_global_is_suported db 0x1 ; 0 means is not supported, when SingOS i booted it will check if it is supported (int 0x13 extended read/write)

+ 23
- 0
filesystems/lsfs/test_lsfs.nasm Ver ficheiro

@ -0,0 +1,23 @@
BITS 16
%define LSFS_magic_start_sector 24
;This is for the FSCI, where this is stored on the disk.
lsfs_format_disk_buffer db 'LSFS v0.1.1-exp', 13, 10, '(LessSimpelFileSystem)', 13, 10, 'Developed to SingOS', 13, 10, 'by Jorn Guldberg', 13, 10, 0 ; 66 chars + 8 bytes
times 506-($-$$) db 0
dw LSFS_magic_start_sector, 3, 2306 ; Start index, number of files, next free index
; 4 is right now the next number of file
; This is the data that is in the file system file.
lfsf_systemcall:
mov ax, 0
mov ah, 0x10
int 0x16
mov ah, 0x0e
mov al, 65 ; backspace
int 0x10 ; print char
ret
File_System_Control_information:
;(FSCI)
times 4608-($-$$) db 0

+ 7
- 7
kernel.nasm Ver ficheiro

@ -1,13 +1,13 @@
BITS 16
ORG 0x512
start_sing:
; loading essentials for SingOS to run
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"
;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"
%include "lib/string.nasm"
%include "lib/debug_tools.nasm"
@ -283,7 +283,7 @@ global_vars:
; this is the bios ID
data:
welcome db "###############################################################################", 13, 10, "# Welcome to SingOS VERSION 0.0.4.0 #", 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.4.5-exp #", 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
@ -300,4 +300,4 @@ data:
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
times ((1<<24)-($-$$)) db 0

+ 14
- 1
lib/os_lib.nasm Ver ficheiro

@ -1,4 +1,14 @@
BITS 16
;mov si, test_string
lfsf_systemcall:
mov ax, 0
mov ah, 0x10
int 0x16
mov ah, 0x0e
mov al, 65 ; backspace
int 0x10 ; print char
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
print:
@ -69,4 +79,7 @@ os_clear_screen:
int 0x10
popa
ret
ret
test_string db "Hello", 13, 0
times 2048-($-$$) db 0

+ 9
- 8
lib/svim.nasm Ver ficheiro

@ -138,9 +138,9 @@ svim:
mov bx, [.buffer_for_svim_base]
call lsfs_read_file
mov bx, [.buffer_for_svim_base]
add bx, svim_magic_buffer_size - 2
mov ax, [bx]
;mov bx, [.buffer_for_svim_base]
;add bx, svim_magic_buffer_size - 2
;mov ax, [bx]
mov [.buffer_counter_svim], ax
; print buffer
mov si, [.buffer_for_svim_base]
@ -194,13 +194,14 @@ svim:
int 0x10 ; print char
jmp .svim_loop
.end_svim:
mov ax, [.buffer_counter_svim]
mov bx, [.buffer_for_svim_base]
add bx, svim_magic_buffer_size - 2
mov [bx], ax
;mov bx, [.buffer_for_svim_base]
;add bx, svim_magic_buffer_size - 2
;mov [bx], ax
mov ax, [.fileindex_for_open_file]
mov bx, [.buffer_for_svim_base]
mov cx, [.buffer_counter_svim]
call lsfs_write_file
call os_clear_screen
@ -243,7 +244,7 @@ svim:
.debug_buffer_counter db 'Buffer count: %d', 13, 10, 0
.welcome_svim db 'Vim like text editor for SingOS, ESC to exit', 0
.welcome_svim_select_file db 'svim v0.0.3 - Open file: ', 0
.welcome_svim_select_file db 'svim v0.0.5 - Open file: ', 0
.welcome_svim_enter_fileindex db 'Enter fileindex: ', 0
.seperate_line db '________________________________________________________________________________', 0
.fileindex_for_open_file dw 0

+ 226
- 0
vbr.nasm Ver ficheiro

@ -0,0 +1,226 @@
BITS 16
%define DISK_SERVICE 0x0050:0x0256
%define KERNEL 0x0050:0x0512
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
vbr_lfsf:
; Volume Boot Record
; This will start SingOS from the disk
; The disk format has to be LessSimpleFileSystem
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; loading essentials for SingOS to run
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SYSTEM CALL TABLE STARTING AT POSITION 0x0050:0x0000
; To already support 64-bit, the entries is 64-bit
; But in 16-bit, the adresses is only 16-bit
; These are stored in the first 16-bits
; There is reserved 2 sectors to the table witch means that we have room for
; 128 System Calls
; |----|----------------------------------------------------------------------------|
; | 1 | Master Table| call [0x0050:0x0000] Pointer to the Master File Table |
; |----|----------------------------------------------------------------------------|
; | 2 | FILE SYSTEM | call [0x0050:0x0008] for arguments see under the file system |
; |----|----------------------------------------------------------------------------|
; | 3 | OS_LIB | call [0x0050:0x0016] for arguments see under the file system |
; |----|----------------------------------------------------------------------------|
; | 1 | FILE SYSTEM | call [0x0050:0x0000] for arguments see under the file system |
; |----|----------------------------------------------------------------------------|
; | 2 | OS_LIB | call [0x0050:0x0008] for arguments see under the file system |
; |----|----------------------------------------------------------------------------|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov [vbr_disk_identifier], dl ; saving disk_identifier, this is the number the disk that we are booting from.
; This number is set by the bios
xor ax, ax
mov al, dl
mov al, [vbr_disk_identifier]
mov [vbr_lba_position_at_disk], ax ; From the MBR we need information of where we are located at the disk.
; If this fails, we could lookup our self, in the MBR where we are located.
;mov ax, 0x50
;mov cs, ax
;mov ds, ax
;mov ax, 0x8fc0
;mov ss, ax ; Set 'ss' to this location (the beginning of our stack region)
;mov sp, 0xffff ; Set 'ss:sp' to the top of our 8K stack
;mov bp, sp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The system has to support int13 bios extended system calls, otherwise is SingOS not supporting the hardware.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov ah, 0x41 ;Set AH = 0x41
mov bx, 0x55aa ;BX = 0x55AA
mov dl, [vbr_disk_identifier] ;DL = disk_id
int 0x13 ;Issue an INT 0x13.
jc .is_not_supported
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The system is suportted
; We are now loading the filesystem
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;mov WORD bx, [vbr_lba_position_at_disk]
mov WORD [DAPACK.lba_addr_dw_low], 89
mov WORD [DAPACK.blkcnt], 0x08 ; Read to sectors, that is what the space is for the buffer in svim
mov WORD [DAPACK.db_addr_segment], 0x50
mov WORD [DAPACK.db_addr_offset], 0x256
mov si, DAPACK ; address of "disk address packet"
mov ah, 0x42 ; READ
mov dl, [vbr_disk_identifier]
int 0x13
;call dumpax
;call DISK_SERVICE
mov [vbr_disk_identifier], dl
mov al, dl
;call DISK_SERVICE
;mov ax, 0
;mov ah, 0x10
;int 0x16
;mov ah, 0x0e
;mov al, 66 ; backspace
;int 0x10 ; print char
;call DISK_SERVICE
;mov ax, 0
;mov ah, 0x10
;int 0x16
;mov ah, 0x0e
;mov al, 66 ; backspace
;int 0x10 ; print char
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The disk service is now loaded.
; Now we are going to load the Master table.
;
; We are now loading the filesystem
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov WORD [DAPACK.lba_addr_dw_low], 97
mov WORD [DAPACK.blkcnt], 0x1f
mov WORD [DAPACK.db_addr_segment], 0x50
mov WORD [DAPACK.db_addr_offset], 0x0512
mov si, DAPACK ; address of "disk address packet"
mov ah, 0x42 ; READ
mov dl, [vbr_disk_identifier]
int 0x13
;call dumpax
xor ax, ax
mov dl, [vbr_disk_identifier]
mov al, dl
;call dumpax
mov dl, [vbr_disk_identifier]
jmp KERNEL
nop
cli
hlt
.is_not_supported:
; The System does support exented read write
mov si, lsfs_disk_error_msg
;call print
;Routine for printing a 'ax' as hex
dumpax:
pusha ; save registers
mov bx, ax
mov ah, 0xE ; Teletype output
mov cx, 4 ; 4 nipples in a 16 bit word
.loop:
rol bx, 4 ; rotate to next nipple
mov al, bl ; we copy to al because we need to mask only the low 4 bits
and al, 1111b ; Do the masking
add al, '0' ; convert to ASCII
cmp al, '9' ; If we are greater than 9 ascii, we add 7 to make digit 10 be represented as 'A'
jbe .skip ; -|-
add al, 7 ; -|-
.skip: ; -|-
int 0x10 ; BIOS call 'output'
loop .loop
popa ; restore registers
ret
vbr_disk_identifier db 0
vbr_lba_position_at_disk dw 0
lsfs_disk_error_msg db 'The system does not support disk operations,', 13, 10, 0
DAPACK:
.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_low: dd 0x0 ; put the lba to read in this spot
.lba_addr_dw_high: dd 0x0 ; more storage bytes only for big lba's ( > 4 bytes )
times 4096-($-$$) db 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; HERE START THE FILE SYSTEM
; This is the Master Table
; This is the fixed entries when the system is compilet
; DEFAULT SIZE IS 64 FILES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Entry one:
;.filename:
db 'File_System_Control_information', 0
times 224 db 0
;.file_id:
dw 0x0, 0x0, 0x0, 0x00 ; 64-bits
;.file_size
dw 512, 0x0, 0x0, 0x0 ; 64-bits Should be the actual number of bytes.
;.ext_file_data 64-bits (Extended data about the file, timestamps etc.)
dw 0x0, 0x0, 0x0, 0x0
;control_bits 64-bits
dw 0x0, 0x0, 0x0, 0x0
;.file_data_pointers
dw 88, 0x0, 0x0, 0x0
times 216 db 0
; Entry Two:
db 'LessSimpelFileSystem', 0
times 235 db 0
;.file_id:
dw 0x01, 0x0, 0x0, 0x0
;.file_size
dw 4096, 0x0, 0x0, 0x0
;.ext_file_data 64-bits (Extended data about the file, timestamps etc.)
dw 0x0, 0x0, 0x0, 0x0
;control_bits 64-bits
dw 0x0, 0x0, 0x0, 0x0
;.file_data_pointers
dw 89, 0x0, 0x0, 0x0
times 216 db 0
; Entry Three:
db 'kernel', 0
times 249 db 0
;.file_id:
dw 0x02, 0x0, 0x0, 0x0
;.file_size
dw 0x00, 0x10, 0x0, 0x0
;.ext_file_data 64-bits (Extended data about the file, timestamps etc.)
dw 0x0, 0x0, 0x0, 0x0
;control_bits 64-bits
dw 0x0, 0x0, 0x0, 0x0
;.file_data_pointers
dw 97, 0x0, 0x0, 0x0
times 216 db 0
times 4096 + (32768-($-$$)) db 0

Carregando…
Cancelar
Guardar