Browse Source

Save work

pull/2/head
Jørn Guldberg 6 years ago
parent
commit
ded978bb38
  1. 13
      build.sh
  2. BIN
      disk.out
  3. 69
      driver/disk.h
  4. 45
      main.c
  5. BIN
      main.s
  6. 2
      std_singos/string.h

13
build.sh

@ -1,6 +1,15 @@
bcc -S main.c 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 ___mkargv/d' ./main.s
sed -i '/.globl _environ/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 as86 -b disk.out main.s

BIN
disk.out

Binary file not shown.

69
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* index;
long file_block_size; long number_sectors;
void* data_buffer; void* data_buffer;
int data_buffer_segment; 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 #asm
#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: lsfs_load_data:
mov dl, [global_disk_identifier] mov ax, index
mov WORD [DAPACK.lba_addr_dw_low], ax mov WORD [DAPACK.lba_addr_dw_low], ax
mov WORD [DAPACK.blkcnt], 0x01 mov bx, number_sectors
mov WORD [DAPACK.db_addr_segment], bx mov WORD [DAPACK.blkcnt], bx
mov WORD [DAPACK.db_addr_offset], FSCI mov cx, data_buffer_segment
mov si, DAPACK ; address of "disk address packet" mov WORD [DAPACK.db_addr_segment], cx
mov ah, 0x42 ; READ 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] mov dl, [global_disk_identifier]
int 0x13 int #0x13
call 0x0000:0x7C2A
popa
pop bp
ret
DAPACK: DAPACK:
.dap_Size: db 0x10 ; This is always 16 bytes (0x10) DAPACK.dap_Size: db 0x10
.rev_byte: db 0x0 ; reserved byte, should always be zero DAPACK.rev_byte: db 0x0
.blkcnt: dw 0x0 ; int 13 resets this to # of blocks actually read/written DAPACK.blkcnt: dw 0x0
.db_addr_offset: dw 0x0 ; memory buffer destination address (0:7c00) DAPACK.db_addr_offset: dw 0x0
.db_addr_segment: dw 0x0 ; in memory page zero DAPACK.db_addr_segment: dw 0x0
.lba_addr_dw_low: dd 0x0 ; put the lba to read in this spot DAPACK.lba_addr_dw_low: dd 0x0
.lba_addr_dw_high: dd 0x0 ; more storage bytes only for big lba's ( > 4 bytes ) DAPACK.lba_addr_dw_high: dd 0x0
global_disk_identifier: db 0x80
#endasm #endasm
}
int sec_stub()
{
return 42;
} }

45
main.c

@ -18,6 +18,7 @@
#define NUM_DATA_POINTERS 27 #define NUM_DATA_POINTERS 27
void dump_ax(input); void dump_ax(input);
void print_stack(argument);
typedef struct Directory_Table Directory_Table; typedef struct Directory_Table Directory_Table;
typedef struct struct_table_entry struct_table_entry; typedef struct struct_table_entry struct_table_entry;
@ -62,8 +63,9 @@ struct test
int argument; int argument;
void print(argument); void print(argument);
int main(selector, path, path_segment) int main(selector, path, path_segment, fsci_lba_index)
int path_segment; int path_segment;
int fsci_lba_index;
char path[256]; char path[256];
{ {
// selectot should be a "selector" for which disk service // selectot should be a "selector" for which disk service
@ -73,8 +75,10 @@ char path[256];
int local_segment = 0x7e0; 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"; 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; struct test my_struct;
char *hello = "LessSimpleFileSystem"; char *fs_info;
char *hello = "LessSimpleFileSystem_Hello";
char *yes = "Read file: "; char *yes = "Read file: ";
int nubmer;
my_struct.first = hello; my_struct.first = hello;
@ -86,10 +90,19 @@ char path[256];
FSCI fsci; FSCI fsci;
print(my_struct.first); print(my_struct.first);
print(my_struct.second); print(my_struct.second);
strcpy(local_path, local_segment, path, path_segment); //strcpy(local_path, local_segment, path, path_segment);
print(local_path); print(local_path);
fsci.master_table_index[0] = 32; fsci.master_table_index[0] = 42;
dump_ax(fsci.master_table_index[0]); 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 else
{ {
@ -112,6 +125,25 @@ void print(argument)
#endasm #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) dump_ax_return(input)
void* input; void* input;
{ {
@ -124,6 +156,9 @@ void* input;
// Force the variable in ax // Force the variable in ax
dump_ax_return(input) dump_ax_return(input)
#asm #asm
push bp
mov bp,sp
call 0x000:0x7C2A call 0x000:0x7C2A
pop bp
#endasm #endasm
} }

BIN
main.s

Binary file not shown.

2
std_singos/string.h

@ -34,7 +34,7 @@ int source_segment;
mov si, ax mov si, ax
mov ax, SOURCE_SEGMENT; mov ax, SOURCE_SEGMENT;
mov ds, ax mov ds, ax
mov cx, 0x050 mov cx, 0x050 // TODO(Jørn) Hardcded number of bytes to copy
.loop: .loop:
movsb movsb
cmp cx, 0x0 cmp cx, 0x0

Loading…
Cancel
Save