You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
265 lines
9.8 KiB
265 lines
9.8 KiB
BITS 16 |
|
%define DISK_SERVICE 0x0050:0x0256 |
|
%define KERNEL 0x0050:0x0512 |
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
jmp short vbr_lfsf |
|
nop ; Used later as a FLAG byte for extended INT 13 Disk Func.'s (See instruction at: 7CADh). |
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
; Disk description table, to make it a valid floppy |
|
; Note: some of these values are hard-coded in the source! |
|
; Values are those used by IBM for 1.44 MB, 3.5" diskette |
|
; NOTE(jakob): From MikeOS |
|
; Why do we need this... damn BIOS |
|
;times 71 - ($-$$) db 0 |
|
OEMLabel db "SingOs " ; Disk label |
|
; BytesPerSector dw 512 ; Bytes per sector |
|
; SectorsPerCluster db 1 ; Sectors per cluster |
|
; ReservedForBoot dw 1 ; Reserved sectors for boot record |
|
; NumberOfFats db 2 ; Number of copies of the FAT |
|
; RootDirEntries dw 224 ; Number of entries in root dir |
|
; ; (224 * 32 = 7168 = 14 sectors to read) |
|
; LogicalSectors dw 0x4000 ; Number of logical sectors |
|
; MediumByte db 0xF0 ; Medium descriptor byte |
|
; SectorsPerFat dw 9 ; Sectors per FAT |
|
; SectorsPerTrack dw 18 ; Sectors per track (36/cylinder) |
|
; Sides dw 2 ; Number of sides/heads |
|
; HiddenSectors dd 0 ; Number of hidden sectors |
|
; LargeSectors dd 0 ; Number of LBA sectors |
|
; DriveNo dw 0 ; Drive No: 0 |
|
; Signature db 0 ; Drive signature: 41 for floppy |
|
; VolumeID dd 0x00000000 ; Volume ID: any number |
|
; VolumeLabel db "SingOs "; Volume Label: any 11 chars |
|
; FileSystem db "VSFS " ; File system type: don't change! |
|
|
|
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 'LSFS v0.1.2-exp', 13, 10, '(LessSimpelFileSystem)', 13, 10, 'Developed to SingOS', 13, 10, 'by Jorn Guldberg', 13, 10, 0 ; 66 chars + 8 bytes |
|
times 163 db 0 ; 256 bytes file system informaiton |
|
dw 23, 0x00, 0x00, 0x00 ; offset on disk asb LBA address |
|
dw 2306, 0x00, 0x00, 0x00 ; Next free LBA partition index free |
|
dw 0x00, 0x00, 0x00, 0x00 ; next_sector_reuse_pointer |
|
dw 0x00, 0x00, 0x00, 0x00 ; last_sector_index_on_partition |
|
dw 0x00, 0x00, 0x00, 0x00 ; sectors_size_on_disk |
|
times 208 db 0 |
|
|
|
;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.module', 0 |
|
times 228 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 |