您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

176 行
5.1 KiB

5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
  1. // Adress to dump ax, 7C2A
  2. // Address to print 7C47
  3. //
  4. //
  5. #include "std_singos/string.h"
  6. #include "std_singos/stdio.h"
  7. #include "driver/disk.h"
  8. #define SPACE_MBR_RECORD 2048 // Sectors
  9. #define SPACE_VBR_RECORD 2048 // Sectors
  10. #define SIZE_FSCI_RECORD 1 // Sectors
  11. #define DEFAULT_ENTRY_SIZE 1 // Sectors
  12. #define SECTOR_SIZE 512 // BYTES
  13. #define NUMBER_OF_MBR_PARTITIONS 4
  14. #define DEFAULT_FILE_SIZE 4 // This is in sectors
  15. #define DEFAULT_DATA_POINTER_SIZE 4 // This is in sectors
  16. #define DEFAULT_TABLE_SIZE 16
  17. #define NUM_DATA_POINTERS 27
  18. void dump_ax(input);
  19. void print_stack(argument);
  20. void print_newline();
  21. typedef struct Directory_Table Directory_Table;
  22. typedef struct Struct_Table_Entry Table_Entry;
  23. typedef struct struct_partition_control partition_control;
  24. typedef struct File_System_Control_Information FSCI;
  25. typedef struct meta_information_format mif;
  26. typedef struct tag_record tag_record;
  27. typedef struct lsfs_file lsfs_file;
  28. typedef struct Parameter_Struct Parameter_Struct;
  29. typedef enum Table_Entry_Kind
  30. {
  31. // These are specific values since, is has to corrospond to the implementation in assembly
  32. ENTRY_EMPTY = 0,
  33. ENTRY_FILE = 1,
  34. ENTRY_DIRECTORY = 2,
  35. } Table_Entry_Kind;
  36. typedef enum Service_Action
  37. {
  38. SERIVCE_LOAD_DISK = 1,
  39. SERVICE_FIND_ENTRY = 2,
  40. SERIVCE_READ_DATA = 3,
  41. SERIVCE_WRITE_DATA = 4,
  42. } Service_Action;
  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. struct Parameter_Struct
  76. {
  77. char* path;
  78. char* new_path;
  79. int buffer_segment;
  80. int buffer_address;
  81. int buffer_size;
  82. int data_length;
  83. int byte_offset_into_file;
  84. Table_Entry_Kind entry_kind;
  85. };
  86. int main(selector, pointer_parameter_segment, pointer_parameter_struct)
  87. int selector;
  88. void* pointer_parameter_segment;
  89. void* pointer_parameter_struct;
  90. {
  91. // selectot should be a "selector" for which disk service
  92. // one wnats to use.
  93. // 0 should not be used, to try to ensure that a value has been set explicitly.
  94. FSCI fsci;
  95. Service_Action service_action;
  96. Directory_Table current_table;
  97. Parameter_Struct parameter_struct;
  98. int local_segment = 0x7e0;
  99. int stack_segment = 0x8fc0;
  100. long index_as_long;
  101. 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";
  102. service_action = selector;
  103. switch (service_action)
  104. {
  105. case SERIVCE_LOAD_DISK:
  106. {
  107. /*
  108. What do we need to know:
  109. Index of FSCI
  110. */
  111. index_as_long = pointer_parameter_struct;
  112. disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment);
  113. print("File System has been loaded: ");
  114. print_newline();
  115. print_stack(fsci.filesystem_information);
  116. print_newline();
  117. } break;
  118. case SERVICE_FIND_ENTRY:
  119. {
  120. memcpy(&parameter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct));
  121. dump_ax(parameter_struct.buffer_size);
  122. print_newline();
  123. disk_service_read_data_from_disk(fsci.master_table_index[0], DEFAULT_TABLE_SIZE, &current_table, stack_segment);
  124. print("Current table: ");
  125. print_newline();
  126. print_stack(current_table.entries[0].filename);
  127. print_newline();
  128. print_stack(current_table.entries[1].filename);
  129. print_newline();
  130. print_stack(current_table.entries[2].filename);
  131. print_newline();
  132. } break;
  133. case SERIVCE_READ_DATA:
  134. {
  135. /*
  136. What do we need to know:
  137. path
  138. // Buffer:
  139. destination_segment
  140. destination_address
  141. buffer_size
  142. offset_into_file
  143. */
  144. print("Hit READ case");
  145. } break;
  146. case SERIVCE_WRITE_DATA:
  147. {
  148. print("Hit WRITE case");
  149. } break;
  150. default:
  151. {
  152. print("Default case");
  153. }
  154. }
  155. return 0;
  156. }
  157. //void load_