summaryrefslogtreecommitdiff
path: root/src/kernel/files.c
diff options
context:
space:
mode:
authorBenji Dial <Benji3.141@gmail.com>2019-12-27 17:19:51 -0500
committerBenji Dial <Benji3.141@gmail.com>2019-12-27 17:19:51 -0500
commit58b5c8ba417fe99c01d9a48731b887ce434e797e (patch)
treea09f7d0a6543328d70f8c02be8a37c320be5ef71 /src/kernel/files.c
parent3f3f9a806dc63ad827fe28724dabe694f6e67f1e (diff)
downloadportland-os-58b5c8ba417fe99c01d9a48731b887ce434e797e.tar.gz
lots of new stuff. new memory manager, some stuff on file plumbing
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