Não pode escolher mais do que 25 tópicos
			Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
		
		
		
		
		
			
		
			
				
					
					
						
							225 linhas
						
					
					
						
							5.1 KiB
						
					
					
				
			
		
		
	
	
							225 linhas
						
					
					
						
							5.1 KiB
						
					
					
				// 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); | 
						|
void print_stack(argument); | 
						|
void print_newline(); | 
						|
 | 
						|
typedef struct Directory_Table Directory_Table; | 
						|
typedef struct Struct_Table_Entry 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; | 
						|
 | 
						|
typedef enum Service_Action | 
						|
{ | 
						|
    SERIVCE_LOAD_DISK  = 1, | 
						|
    SERVICE_FIND_ENTRY = 2, | 
						|
    SERIVCE_READ_DATA  = 3, | 
						|
    SERIVCE_WRITE_DATA = 4, | 
						|
 | 
						|
} Service_Action; | 
						|
 | 
						|
int number_low; | 
						|
int selector; | 
						|
 | 
						|
struct Struct_Table_Entry  | 
						|
{ | 
						|
    char    filename[256];  | 
						|
    long    file_id[2]; | 
						|
    long    file_size[2]; | 
						|
    void*   ext_file_data_low; | 
						|
    void*   ext_file_data_high; | 
						|
    long    number_sector_s; // <- Just try to remove the last undercore and compile .           | 
						|
    short   entry_kind; | 
						|
    short   extra_control_bits1; | 
						|
    short   extra_control_bits2; | 
						|
    short   extra_control_bits3; | 
						|
    long    table_entry_sector_index[2]; | 
						|
    long    data_pointer[NUM_DATA_POINTERS * 2]; // if it is a directory, the first pointer will be to the next table.  | 
						|
};  | 
						|
 | 
						|
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]; | 
						|
 | 
						|
}; | 
						|
 | 
						|
typedef struct Directory_Table  | 
						|
{ | 
						|
    Table_Entry entries[DEFAULT_TABLE_SIZE]; | 
						|
 | 
						|
};  | 
						|
 | 
						|
 | 
						|
void print(string); | 
						|
 | 
						|
int main(selector, parameter_struct)  | 
						|
int selector; | 
						|
void* parameter_struct; | 
						|
{ | 
						|
    // 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.   | 
						|
    FSCI fsci; | 
						|
    Service_Action service_action; | 
						|
    Directory_Table current_table; | 
						|
    int local_segment = 0x7e0; | 
						|
    int stack_segment = 0x8fc0; | 
						|
    long index_as_long;  | 
						|
 | 
						|
    char local_path[256]; //= "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"; | 
						|
    service_action = selector; | 
						|
 | 
						|
    switch (service_action) | 
						|
    { | 
						|
        case SERIVCE_LOAD_DISK:  | 
						|
        { | 
						|
            /* | 
						|
                What do we need to know:  | 
						|
                Index of FSCI | 
						|
            */ | 
						|
            index_as_long = parameter_struct; | 
						|
            disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment); | 
						|
            print("File System has been loaded: "); | 
						|
            print_newline(); | 
						|
            print_stack(fsci.filesystem_information); | 
						|
            print_newline(); | 
						|
        } break; | 
						|
        case SERVICE_FIND_ENTRY: | 
						|
        { | 
						|
            disk_service_read_data_from_disk(fsci.master_table_index[0], DEFAULT_TABLE_SIZE, ¤t_table, stack_segment); | 
						|
            print("Current table: "); | 
						|
            print_newline(); | 
						|
            print_stack(current_table.entries[0].filename); | 
						|
            print_newline(); | 
						|
            print_stack(current_table.entries[1].filename); | 
						|
            print_newline(); | 
						|
            print_stack(current_table.entries[2].filename); | 
						|
            print_newline(); | 
						|
        } break; | 
						|
        case SERIVCE_READ_DATA:  | 
						|
        { | 
						|
            /* | 
						|
                What do we need to know:  | 
						|
                    path | 
						|
                    // Buffer:  | 
						|
                    destination_segment | 
						|
                    destination_address | 
						|
            */ | 
						|
            print("Hit READ case"); | 
						|
        } break; | 
						|
        case SERIVCE_WRITE_DATA: | 
						|
        { | 
						|
            print("Hit WRITE case"); | 
						|
        } break; | 
						|
        default:  | 
						|
        { | 
						|
            print("Default case"); | 
						|
        } | 
						|
    }  | 
						|
     | 
						|
    return 0; | 
						|
 | 
						|
} | 
						|
 | 
						|
//void load_ | 
						|
 | 
						|
 | 
						|
void print(string) | 
						|
char* string; | 
						|
{ | 
						|
#asm  | 
						|
    push bp | 
						|
    mov bp,sp | 
						|
    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; | 
						|
{ | 
						|
    return input; | 
						|
} | 
						|
 | 
						|
void dump_ax(input) | 
						|
void* input; | 
						|
{ | 
						|
    // Force the variable in ax  | 
						|
    dump_ax_return(input) | 
						|
#asm | 
						|
    push bp | 
						|
    mov bp,sp | 
						|
    call 0x000:0x7C2A | 
						|
    pop bp | 
						|
#endasm | 
						|
} | 
						|
 | 
						|
void print_newline() | 
						|
{ | 
						|
    #asm  | 
						|
    printCRLF: | 
						|
    mov ah, #0xE | 
						|
    mov al, #13 | 
						|
    int #0x10 | 
						|
    mov al, #10 | 
						|
    int #0x10 | 
						|
    ret | 
						|
    #endasm | 
						|
} |