summaryrefslogtreecommitdiff
path: root/src/kernel/files.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/files.c')
-rw-r--r--src/kernel/files.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/kernel/files.c b/src/kernel/files.c
index 78fe664..b8a9061 100644
--- a/src/kernel/files.c
+++ b/src/kernel/files.c
@@ -18,6 +18,23 @@ OF THIS SOFTWARE.
*/
#include "files.h"
+#include "diskio.h"
+#include "gpt.h"
+
+uint8_t working_drive;
+uint8_t working_part;
+uint8_t buffer[1024];
+
+void set_working_drive(uint8_t name, uint8_t part) {
+ if ((name >= (uint8_t)'a') && (name <= (uint8_t)'z') &&
+ (drives[name - (uint8_t)'a'].flags & PRESENT))
+ working_drive = name - (uint8_t)'a';
+ if (part_info[working_drive].format & ~DIRECT)
+ working_part =
+ (part >= (uint8_t)'0') && (name <= (uint8_t)'9') &&
+ (part_info[working_drive].n_partitions > part) ?
+ (part & 0x0f) : 0;
+}
uint16_t open_file(uint8_t *name) {
return 0;//TODO
@@ -52,4 +69,22 @@ uint32_t read_line_file(uint16_t handle, uint32_t max, void *buffer) {
}
++i;
}
+}
+
+void detect_disk_parts(uint8_t drive) {
+ if ((drive >= (uint8_t)'a') && (drive <= (uint8_t)'z')) {
+ uint8_t dn = (drive & 0x1f) - 1;
+ update_status(dn);
+ if (drives[dn].flags & (PRESENT | DISK_IN)) {
+ read_sectors(dn, 0, 2, buffer);
+ if ((*(uint32_t *)&buffer[0x200] == 0x20494645) &&//EFI
+ (*(uint32_t *)&buffer[0x204] == 0x54524150)) //PART
+ part_info[dn].format = gpt_parse_pt(dn, buffer) ? GPT : UNKNOWN;
+ ;
+ }
+ else {
+ part_info[dn].format = NOT_PRESENT;
+ part_info[dn].n_partitions = 0;
+ }
+ }
} \ No newline at end of file