First commit: files added, very first step on first edition c std-lib, and the lsfs implemenation
This commit is contained in:
commit
a5ac220a12
4 files changed
+222
No files matched your search
@@ -0,0 +1,6 @@
|
||||
bcc -S main.c
|
||||
echo -e "jmp _main\n$(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
|
||||
as86 -b disk.out main.s
|
||||
@@ -0,0 +1,33 @@
|
||||
|
||||
int disk_service_read_data_from_disk(index, file_block_size, data_buffer, data_buffer_segment)
|
||||
long* index;
|
||||
long file_block_size;
|
||||
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
|
||||
|
||||
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 )
|
||||
#endasm
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// Adress to dump ax, 7C2A
|
||||
// Address to print 7C47
|
||||
//
|
||||
//
|
||||
|
||||
#include "std_singos/string.h"
|
||||
#include "driver/disk.h"
|
||||
|
||||
#define SPACE_MBR_RECORD 2048 // Sectors
|
||||
#define SPACE_VBR_RECORD 2048 // Sectors
|
||||
#define SIZE_FSCI_RECORD 1 // Sectors
|
||||
#define DEFAULT_ENTRY_SIZE 1 // Sectors
|
||||
#define SECTOR_SIZE 512 // BYTES
|
||||
#define NUMBER_OF_MBR_PARTITIONS 4
|
||||
#define DEFAULT_FILE_SIZE 4 // This is in sectors
|
||||
#define DEFAULT_DATA_POINTER_SIZE 4 // This is in sectors
|
||||
#define DEFAULT_TABLE_SIZE 16
|
||||
#define NUM_DATA_POINTERS 27
|
||||
|
||||
void dump_ax(input);
|
||||
|
||||
typedef struct Directory_Table Directory_Table;
|
||||
typedef struct struct_table_entry struct_table_entry;
|
||||
typedef struct struct_partition_control partition_control;
|
||||
typedef struct File_System_Control_Information FSCI;
|
||||
typedef struct meta_information_format mif;
|
||||
typedef struct tag_record tag_record;
|
||||
typedef struct lsfs_file lsfs_file;
|
||||
|
||||
typedef enum Table_Entry_Kind
|
||||
{
|
||||
// These are specific values since, is has to corrospond to the implementation in assembly
|
||||
ENTRY_EMPTY = 0,
|
||||
ENTRY_FILE = 1,
|
||||
ENTRY_DIRECTORY = 2,
|
||||
} Table_Entry_Kind;
|
||||
|
||||
int number_low;
|
||||
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];
|
||||
|
||||
};
|
||||
|
||||
struct test
|
||||
{
|
||||
char* first;
|
||||
char* second;
|
||||
};
|
||||
|
||||
int argument;
|
||||
void print(argument);
|
||||
|
||||
int main(selector, path, path_segment)
|
||||
int path_segment;
|
||||
char path[256];
|
||||
{
|
||||
// selectot should be a "selector" for which disk service
|
||||
// one wnats to use.
|
||||
// 0 should not be used, to try to ensure that a value has been set explicitly.
|
||||
|
||||
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 *yes = "Read file: ";
|
||||
|
||||
|
||||
my_struct.first = hello;
|
||||
my_struct.second = yes;
|
||||
|
||||
if (selector == 1)
|
||||
{
|
||||
// SERVICE: READ FILE
|
||||
FSCI fsci;
|
||||
print(my_struct.first);
|
||||
print(my_struct.second);
|
||||
strcpy(local_path, local_segment, path, path_segment);
|
||||
print(local_path);
|
||||
fsci.master_table_index[0] = 32;
|
||||
dump_ax(fsci.master_table_index[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
print(my_struct.first);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void print(argument)
|
||||
{
|
||||
#asm
|
||||
push bp
|
||||
mov bp,sp
|
||||
mov si,4[bp]
|
||||
call 0x0000:0x7C47
|
||||
pop bp
|
||||
#endasm
|
||||
}
|
||||
|
||||
dump_ax_return(input)
|
||||
void* input;
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
void dump_ax(input)
|
||||
void* input;
|
||||
{
|
||||
// Force the variable in ax
|
||||
dump_ax_return(input)
|
||||
#asm
|
||||
call 0x000:0x7C2A
|
||||
#endasm
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
void strcpy (destination, destination_segment, source, source_segment );
|
||||
|
||||
void strcpy (destination, destination_segment, source, source_segment )
|
||||
char *destination;
|
||||
int destination_segment;
|
||||
char *source;
|
||||
int source_segment;
|
||||
{
|
||||
#asm
|
||||
; copy two strings
|
||||
; IN si: the first (zero terminated) string
|
||||
; IN di: the second (zero terminated) string
|
||||
; OUT SF and ZF (same semantics as cmp)
|
||||
|
||||
#define DESTINATION 4[bp];
|
||||
#define DESTINATION_SEGMENT 6[bp];
|
||||
#define SOURCE 8[bp];
|
||||
#define SOURCE_SEGMENT 10[bp];
|
||||
|
||||
push bp
|
||||
mov bp,sp
|
||||
stringcompare:
|
||||
push ax
|
||||
push bx
|
||||
push di
|
||||
push es
|
||||
push si
|
||||
push ds
|
||||
mov ax, DESTINATION;
|
||||
mov di, ax
|
||||
mov ax, DESTINATION_SEGMENT;
|
||||
mov es, ax
|
||||
mov ax, SOURCE;
|
||||
mov si, ax
|
||||
mov ax, SOURCE_SEGMENT;
|
||||
mov ds, ax
|
||||
mov cx, 0x050
|
||||
.loop:
|
||||
movsb
|
||||
cmp cx, 0x0
|
||||
je .end
|
||||
dec cx
|
||||
jmp .loop
|
||||
.end:
|
||||
pop ds
|
||||
pop si
|
||||
pop es
|
||||
pop di
|
||||
pop bx
|
||||
pop ax
|
||||
pop bp
|
||||
|
||||
#endasm
|
||||
}
|
||||
Reference in new issue
Block a user