diff --git a/build.sh b/build.sh index ff5e461..87ed891 100644 --- a/build.sh +++ b/build.sh @@ -1,6 +1,15 @@ bcc -S main.c -echo -e "jmp _main\n$(cat main.s)" > main.s +echo -e "push bp + mov bp,sp + push 12[bp] + push 10[bp] + push 8[bp] + push 6[bp] + call _main + add sp, 0x4 + pop bp + retf $(cat main.s)" > main.s sed -i '/.globl ___mkargv/d' ./main.s sed -i '/.globl _environ/d' ./main.s -sed -i '/.data/d' ./main.s +sed -i '/^.data$/d' ./main.s as86 -b disk.out main.s diff --git a/disk.out b/disk.out new file mode 100644 index 0000000..bf68117 Binary files /dev/null and b/disk.out differ diff --git a/driver/disk.h b/driver/disk.h index 84e1af5..e2f01ec 100644 --- a/driver/disk.h +++ b/driver/disk.h @@ -1,33 +1,64 @@ +int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); +int sec_stub(); +int stub(index, number_sectors, data_buffer, data_buffer_segment); -int disk_service_read_data_from_disk(index, file_block_size, data_buffer, data_buffer_segment) +int stub(index, number_sectors, data_buffer, data_buffer_segment) long* index; -long file_block_size; +long number_sectors; void* data_buffer; int data_buffer_segment; { - //fseek ( disk, (index * SECTOR_SIZE ), SEEK_SET ); // SEEK_SET start offset at index 0 and move 1 * SECTOR_SIZE, and write here. - //int read = fread(data_buffer, 1, (file_block_size * SECTOR_SIZE), disk); - //return read; + #asm - lsfs_load_data: - mov dl, [global_disk_identifier] - mov WORD [DAPACK.lba_addr_dw_low], ax - mov WORD [DAPACK.blkcnt], 0x01 - mov WORD [DAPACK.db_addr_segment], bx - mov WORD [DAPACK.db_addr_offset], FSCI - mov si, DAPACK ; address of "disk address packet" - mov ah, 0x42 ; READ - mov dl, [global_disk_identifier] - int 0x13 + #define index 4[bp]; + #define number_sectors 6[bp]; + #define data_buffer 8[bp]; + #define data_buffer_segment 10[bp]; + push bp + mov bp,sp + pusha + //mov ax, ds + //call 0x0000:0x7C2A + //mov ax, DAPACK + //call 0x0000:0x7C2A + mov ax, #DAPACK + call 0x0000:0x7C2A + + lsfs_load_data: + mov ax, index + mov WORD [DAPACK.lba_addr_dw_low], ax + mov bx, number_sectors + mov WORD [DAPACK.blkcnt], bx + mov cx, data_buffer_segment + mov WORD [DAPACK.db_addr_segment], cx + mov dx, data_buffer; + mov WORD [DAPACK.db_addr_offset], dx + mov si, #DAPACK ; address of + mov ah, #0x42 ; READ + mov dl, [global_disk_identifier] + int #0x13 + call 0x0000:0x7C2A + popa + pop bp + ret + + 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 ) + DAPACK.dap_Size: db 0x10 + DAPACK.rev_byte: db 0x0 + DAPACK.blkcnt: dw 0x0 + DAPACK.db_addr_offset: dw 0x0 + DAPACK.db_addr_segment: dw 0x0 + DAPACK.lba_addr_dw_low: dd 0x0 + DAPACK.lba_addr_dw_high: dd 0x0 + + global_disk_identifier: db 0x80 + #endasm +} +int sec_stub() +{ + return 42; } \ No newline at end of file diff --git a/main.c b/main.c index d7521e7..bd09681 100644 --- a/main.c +++ b/main.c @@ -18,6 +18,7 @@ #define NUM_DATA_POINTERS 27 void dump_ax(input); +void print_stack(argument); typedef struct Directory_Table Directory_Table; typedef struct struct_table_entry struct_table_entry; @@ -40,16 +41,16 @@ int selector; struct File_System_Control_Information { - char filesystem_information[256]; - long master_table_index[2]; - long this_partition_offset_on_disk[2]; - long next_free_sector[2]; - long next_uniqe_id[2]; // both files and directories gets this. - long next_sector_reuse_pointer[2]; - long last_sector_index_on_partition[2]; - long maximum_sectors_on_disk[2]; - long sector_size_on_disk[2]; - long not_used[48]; + char filesystem_information[256]; + long master_table_index[2]; + long this_partition_offset_on_disk[2]; + long next_free_sector[2]; + long next_uniqe_id[2]; // both files and directories gets this. + long next_sector_reuse_pointer[2]; + long last_sector_index_on_partition[2]; + long maximum_sectors_on_disk[2]; + long sector_size_on_disk[2]; + long not_used[48]; }; @@ -62,8 +63,9 @@ struct test int argument; void print(argument); -int main(selector, path, path_segment) +int main(selector, path, path_segment, fsci_lba_index) int path_segment; +int fsci_lba_index; char path[256]; { // selectot should be a "selector" for which disk service @@ -73,8 +75,10 @@ char path[256]; int local_segment = 0x7e0; char* local_path = "Hello world\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; struct test my_struct; - char *hello = "LessSimpleFileSystem"; + char *fs_info; + char *hello = "LessSimpleFileSystem_Hello"; char *yes = "Read file: "; + int nubmer; my_struct.first = hello; @@ -86,10 +90,19 @@ char path[256]; FSCI fsci; print(my_struct.first); print(my_struct.second); - strcpy(local_path, local_segment, path, path_segment); + //strcpy(local_path, local_segment, path, path_segment); print(local_path); - fsci.master_table_index[0] = 32; - dump_ax(fsci.master_table_index[0]); + fsci.master_table_index[0] = 42; + nubmer = 0x55; + //dump_ax(fsci.master_table_index[0]); + dump_ax(nubmer); + fsci.filesystem_information[0] = 'i'; + fsci.filesystem_information[1] = '\0'; + stub(fsci_lba_index, 1, &fsci, 0x8fc0); + fs_info = fsci.filesystem_information; + //dump_ax(&fsci); + print_stack( fs_info ); + //dump_ax(fsci.master_table_index[0]); } else { @@ -106,12 +119,31 @@ void print(argument) #asm push bp mov bp,sp - mov si,4[bp] + mov si,4[bp] call 0x0000:0x7C47 pop bp #endasm } +void print_stack(argument) +{ +#asm + push bp + mov bp,sp + push ds + push ax + + mov ax, ss + mov ds, ax + mov si,4[bp] + call 0x0000:0x7C47 + + pop ax + pop ds + pop bp +#endasm +} + dump_ax_return(input) void* input; { @@ -124,6 +156,9 @@ void* input; // Force the variable in ax dump_ax_return(input) #asm + push bp + mov bp,sp call 0x000:0x7C2A + pop bp #endasm } diff --git a/main.s b/main.s new file mode 100644 index 0000000..5707315 Binary files /dev/null and b/main.s differ diff --git a/std_singos/string.h b/std_singos/string.h index 7a3c49c..e9b8a22 100644 --- a/std_singos/string.h +++ b/std_singos/string.h @@ -34,7 +34,7 @@ int source_segment; mov si, ax mov ax, SOURCE_SEGMENT; mov ds, ax - mov cx, 0x050 + mov cx, 0x050 // TODO(Jørn) Hardcded number of bytes to copy .loop: movsb cmp cx, 0x0