Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

224 righe
5.1 KiB

5 anni fa
5 anni fa
5 anni fa
5 anni fa
  1. // Adress to dump ax, 7C2A
  2. // Address to print 7C47
  3. //
  4. //
  5. #include "std_singos/string.h"
  6. #include "driver/disk.h"
  7. #define SPACE_MBR_RECORD 2048 // Sectors
  8. #define SPACE_VBR_RECORD 2048 // Sectors
  9. #define SIZE_FSCI_RECORD 1 // Sectors
  10. #define DEFAULT_ENTRY_SIZE 1 // Sectors
  11. #define SECTOR_SIZE 512 // BYTES
  12. #define NUMBER_OF_MBR_PARTITIONS 4
  13. #define DEFAULT_FILE_SIZE 4 // This is in sectors
  14. #define DEFAULT_DATA_POINTER_SIZE 4 // This is in sectors
  15. #define DEFAULT_TABLE_SIZE 16
  16. #define NUM_DATA_POINTERS 27
  17. void dump_ax(input);
  18. void print_stack(argument);
  19. void print_newline();
  20. typedef struct Directory_Table Directory_Table;
  21. typedef struct Struct_Table_Entry Table_Entry;
  22. typedef struct struct_partition_control partition_control;
  23. typedef struct File_System_Control_Information FSCI;
  24. typedef struct meta_information_format mif;
  25. typedef struct tag_record tag_record;
  26. typedef struct lsfs_file lsfs_file;
  27. typedef enum Table_Entry_Kind
  28. {
  29. // These are specific values since, is has to corrospond to the implementation in assembly
  30. ENTRY_EMPTY = 0,
  31. ENTRY_FILE = 1,
  32. ENTRY_DIRECTORY = 2,
  33. } Table_Entry_Kind;
  34. typedef enum Service_Action
  35. {
  36. SERIVCE_LOAD_DISK = 1,
  37. SERVICE_FIND_ENTRY = 2,
  38. SERIVCE_READ_DATA = 3,
  39. SERIVCE_WRITE_DATA = 4,
  40. } Service_Action;
  41. int number_low;
  42. int selector;
  43. struct Struct_Table_Entry
  44. {
  45. char filename[256];
  46. long file_id[2];
  47. long file_size[2];
  48. void* ext_file_data_low;
  49. void* ext_file_data_high;
  50. long number_sector_s; // <- Just try to remove the last undercore and compile .
  51. short entry_kind;
  52. short extra_control_bits1;
  53. short extra_control_bits2;
  54. short extra_control_bits3;
  55. long table_entry_sector_index[2];
  56. long data_pointer[NUM_DATA_POINTERS * 2]; // if it is a directory, the first pointer will be to the next table.
  57. };
  58. struct File_System_Control_Information
  59. {
  60. char filesystem_information[256];
  61. long master_table_index[2];
  62. long this_partition_offset_on_disk[2];
  63. long next_free_sector[2];
  64. long next_uniqe_id[2]; // both files and directories gets this.
  65. long next_sector_reuse_pointer[2];
  66. long last_sector_index_on_partition[2];
  67. long maximum_sectors_on_disk[2];
  68. long sector_size_on_disk[2];
  69. long not_used[48];
  70. };
  71. typedef struct Directory_Table
  72. {
  73. Table_Entry entries[DEFAULT_TABLE_SIZE];
  74. };
  75. void print(string);
  76. int main(selector, parameter_struct)
  77. int selector;
  78. void* parameter_struct;
  79. {
  80. // selectot should be a "selector" for which disk service
  81. // one wnats to use.
  82. // 0 should not be used, to try to ensure that a value has been set explicitly.
  83. FSCI fsci;
  84. Service_Action service_action;
  85. Directory_Table current_table;
  86. int local_segment = 0x7e0;
  87. int stack_segment = 0x8fc0;
  88. long index_as_long;
  89. 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";
  90. service_action = selector;
  91. switch (service_action)
  92. {
  93. case SERIVCE_LOAD_DISK:
  94. {
  95. /*
  96. What do we need to know:
  97. Index of FSCI
  98. */
  99. index_as_long = parameter_struct;
  100. disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment);
  101. print("File System has been loaded: ");
  102. print_newline();
  103. print_stack(fsci.filesystem_information);
  104. print_newline();
  105. } break;
  106. case SERVICE_FIND_ENTRY:
  107. {
  108. disk_service_read_data_from_disk(fsci.master_table_index[0], DEFAULT_TABLE_SIZE, &current_table, stack_segment);
  109. print("Current table: ");
  110. print_newline();
  111. print_stack(current_table.entries[0].filename);
  112. print_newline();
  113. print_stack(current_table.entries[1].filename);
  114. print_newline();
  115. print_stack(current_table.entries[2].filename);
  116. print_newline();
  117. } break;
  118. case SERIVCE_READ_DATA:
  119. {
  120. /*
  121. What do we need to know:
  122. path
  123. // Buffer:
  124. destination_segment
  125. destination_address
  126. */
  127. print("Hit READ case");
  128. } break;
  129. case SERIVCE_WRITE_DATA:
  130. {
  131. print("Hit WRITE case");
  132. } break;
  133. default:
  134. {
  135. print("Default case");
  136. }
  137. }
  138. return 0;
  139. }
  140. //void load_
  141. void print(string)
  142. char* string;
  143. {
  144. #asm
  145. push bp
  146. mov bp,sp
  147. mov si,4[bp]
  148. call 0x0000:0x7C47
  149. pop bp
  150. #endasm
  151. }
  152. void print_stack(argument)
  153. {
  154. #asm
  155. push bp
  156. mov bp,sp
  157. push ds
  158. push ax
  159. mov ax, ss
  160. mov ds, ax
  161. mov si,4[bp]
  162. call 0x0000:0x7C47
  163. pop ax
  164. pop ds
  165. pop bp
  166. #endasm
  167. }
  168. dump_ax_return(input)
  169. void* input;
  170. {
  171. return input;
  172. }
  173. void dump_ax(input)
  174. void* input;
  175. {
  176. // Force the variable in ax
  177. dump_ax_return(input)
  178. #asm
  179. push bp
  180. mov bp,sp
  181. call 0x000:0x7C2A
  182. pop bp
  183. #endasm
  184. }
  185. void print_newline()
  186. {
  187. #asm
  188. printCRLF:
  189. mov ah, #0xE
  190. mov al, #13
  191. int #0x10
  192. mov al, #10
  193. int #0x10
  194. ret
  195. #endasm
  196. }