From c0daede46df4f546639bd2d3e11dcf064d554966 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 16 May 2020 09:53:58 -0400 Subject: starting over --- src/kernel/files.c | 115 ----------------------------------------------------- 1 file changed, 115 deletions(-) delete mode 100644 src/kernel/files.c (limited to 'src/kernel/files.c') diff --git a/src/kernel/files.c b/src/kernel/files.c deleted file mode 100644 index 9747688..0000000 --- a/src/kernel/files.c +++ /dev/null @@ -1,115 +0,0 @@ -/* -Copyright 2019 Benji Dial - -Permission to use, copy, modify, and/or distribute this -software for any purpose with or without fee is hereby -granted, provided that the above copyright notice and this -permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS -ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO -EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER -RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -OF THIS SOFTWARE. -*/ - -#include "files.h" -#include "diskio.h" -#include "iso9660.h" -#include "mem.h" - -bool (*const parse_pts[N_PT_FORMATS])(uint8_t dn, uint8_t *buffer) = { - //&gpt_parse_pt, - //&mbr_parse_pt -}; - -bool (*const parse_phs[N_FS_FORMATS])(uint8_t dn, uint8_t pn, uint32_t sector, uint8_t *buffer) = { - &iso_9660_parse_ph -}; - -uint8_t working_drive; -uint8_t working_part; -uint8_t buffer[2048]; - -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 -} - -void close_file(uint16_t handle) { - file_table[handle].first_sector = 0; -} - -uint32_t read_file(uint16_t handle, uint32_t length, void *buffer) { - //TODO -} - -void write_file(uint16_t handle, uint32_t length, void *buffer) { - //TODO -} - -void seek_file(uint16_t handle, int32_t by) { - //TODO -} - -uint32_t get_size(uint16_t handle) { - return 0;//TODO -} - -uint32_t read_line_file(uint16_t handle, uint32_t max, void *buffer) { - uint8_t *i = (uint8_t *)buffer; - while (i < (uint8_t *)buffer + max) { - if (!read_file(handle, 1, i) || (*i == (uint8_t)'\n')) { - *i = 0; - return i - (uint8_t *)buffer; - } - ++i; - } -} - -void detect_disk_parts(uint8_t drive) { - if ((drive >= (uint8_t)'a') && (drive <= (uint8_t)'z')) { - uint8_t dn = (drive & 0x1f) - 1; - for (uint8_t i = 0; i < part_info[dn].n_partitions; ++i) - if (part_info[dn].partition_cache[i]) - deallocate_block(part_info[dn].partition_cache[i]); - update_status(dn); - if (drives[dn].flags & (PRESENT | DISK_IN)) { - /*ISO 9660 often comes with a dummy MBR*/ - if (iso_9660_parse_ph(dn, 0, 0, buffer)) { - part_info[dn].format = DIRECT; - part_info[dn].n_partitions = 1; - return; - } - for (uint8_t ptt = 0; ptt < N_PT_FORMATS; ++ptt) - if (parse_pts[ptt](dn, buffer)) - return; - for (uint8_t fst = 0; fst < N_FS_FORMATS; ++fst) - if (parse_phs[fst](dn, 0, 0, buffer)) { - part_info[dn].format = DIRECT; - part_info[dn].n_partitions = 1; - return; - } - part_info[dn].format = UNKNOWN; - part_info[dn].n_partitions = 0; - } - else { - part_info[dn].format = NOT_PRESENT; - part_info[dn].n_partitions = 0; - } - } -} \ No newline at end of file -- cgit v1.2.3