You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
3.4 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  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. typedef struct Directory_Table Directory_Table;
  20. typedef struct struct_table_entry struct_table_entry;
  21. typedef struct struct_partition_control partition_control;
  22. typedef struct File_System_Control_Information FSCI;
  23. typedef struct meta_information_format mif;
  24. typedef struct tag_record tag_record;
  25. typedef struct lsfs_file lsfs_file;
  26. typedef enum Table_Entry_Kind
  27. {
  28. // These are specific values since, is has to corrospond to the implementation in assembly
  29. ENTRY_EMPTY = 0,
  30. ENTRY_FILE = 1,
  31. ENTRY_DIRECTORY = 2,
  32. } Table_Entry_Kind;
  33. int number_low;
  34. int selector;
  35. struct File_System_Control_Information
  36. {
  37. char filesystem_information[256];
  38. long master_table_index[2];
  39. long this_partition_offset_on_disk[2];
  40. long next_free_sector[2];
  41. long next_uniqe_id[2]; // both files and directories gets this.
  42. long next_sector_reuse_pointer[2];
  43. long last_sector_index_on_partition[2];
  44. long maximum_sectors_on_disk[2];
  45. long sector_size_on_disk[2];
  46. long not_used[48];
  47. };
  48. struct test
  49. {
  50. char* first;
  51. char* second;
  52. };
  53. int argument;
  54. void print(argument);
  55. int main(selector, path, path_segment, fsci_lba_index)
  56. int path_segment;
  57. int fsci_lba_index;
  58. char path[256];
  59. {
  60. // selectot should be a "selector" for which disk service
  61. // one wnats to use.
  62. // 0 should not be used, to try to ensure that a value has been set explicitly.
  63. int local_segment = 0x7e0;
  64. 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";
  65. struct test my_struct;
  66. char *fs_info;
  67. char *hello = "LessSimpleFileSystem_Hello";
  68. char *yes = "Read file: ";
  69. int nubmer;
  70. my_struct.first = hello;
  71. my_struct.second = yes;
  72. if (selector == 1)
  73. {
  74. // SERVICE: READ FILE
  75. FSCI fsci;
  76. print(my_struct.first);
  77. print(my_struct.second);
  78. //strcpy(local_path, local_segment, path, path_segment);
  79. print(local_path);
  80. fsci.master_table_index[0] = 42;
  81. nubmer = 0x55;
  82. //dump_ax(fsci.master_table_index[0]);
  83. //dump_ax(nubmer);
  84. //fsci_lba_index = 0x1000;
  85. fsci.filesystem_information[0] = 'i';
  86. fsci.filesystem_information[1] = '\0';
  87. dump_ax(fsci_lba_index);
  88. stub(fsci_lba_index, 1, &fsci, 0x8fc0);
  89. //fs_info = fsci.filesystem_information;
  90. //dump_ax(&fsci);
  91. print_stack(fsci.filesystem_information);
  92. dump_ax(fsci.master_table_index[0]);
  93. }
  94. else
  95. {
  96. print(my_struct.first);
  97. return 0;
  98. }
  99. return 0;
  100. }
  101. void print(argument)
  102. {
  103. #asm
  104. push bp
  105. mov bp,sp
  106. mov si,4[bp]
  107. call 0x0000:0x7C47
  108. pop bp
  109. #endasm
  110. }
  111. void print_stack(argument)
  112. {
  113. #asm
  114. push bp
  115. mov bp,sp
  116. push ds
  117. push ax
  118. mov ax, ss
  119. mov ds, ax
  120. mov si,4[bp]
  121. call 0x0000:0x7C47
  122. pop ax
  123. pop ds
  124. pop bp
  125. #endasm
  126. }
  127. dump_ax_return(input)
  128. void* input;
  129. {
  130. return input;
  131. }
  132. void dump_ax(input)
  133. void* input;
  134. {
  135. // Force the variable in ax
  136. dump_ax_return(input)
  137. #asm
  138. push bp
  139. mov bp,sp
  140. call 0x000:0x7C2A
  141. pop bp
  142. #endasm
  143. }