// This file is part of noxos and licensed under the MIT open source license #ifndef NOXOS_DRIVE_MANAGER_H #define NOXOS_DRIVE_MANAGER_H #include "drivers/builtin/fs/vfs.h" #include "utils/stdtypes.h" #include "utils/bitmap.h" #define DRIVE_CHUNK_SIZE 16 #define DRIVE_PARTITION_CHUNK_SIZE 16 typedef enum { DRIVE_CONTROLLER_AHCI } drive_controller_types_E; typedef struct drive_chunk_T drive_chunk_T; typedef struct drive_partition_chunk_T drive_partition_chunk_T; typedef struct drive_partition_T drive_partition_T; typedef struct drive_T drive_T; struct drive_partition_T{ drive_partition_chunk_T* chunk; uint32_t id_in_chunk; uint32_t id; drive_T* drive; fs_T filesystem; uint32_t start_sector; uint32_t end_sector; }; struct drive_T { drive_chunk_T* chunk; uint32_t id_in_chunk; uint32_t id; drive_partition_chunk_T* partitions_chunks; drive_controller_types_E controller_type; void* controller; void* device; }; struct drive_chunk_T { drive_T drives [DRIVE_CHUNK_SIZE]; bitmap_T drives_bitmap; uint32_t num_drives; drive_chunk_T* prev; drive_chunk_T* next; }; struct drive_partition_chunk_T { drive_partition_T partitions [DRIVE_PARTITION_CHUNK_SIZE]; bitmap_T partitions_bitmap; uint32_t num_partitions; drive_partition_chunk_T* prev; drive_partition_chunk_T* next; }; typedef struct { drive_chunk_T* chunks; } drive_manager_T; drive_chunk_T* drive_chunk_alloc (drive_chunk_T* prev); drive_partition_chunk_T* drive_partition_chunk_alloc (drive_partition_chunk_T* prev); void drive_partition_chunk_destruct (drive_partition_chunk_T* chunk); void drive_manager_init (); drive_T* drive_manager_add_drive (drive_controller_types_E controller_type, void* controller, void* device); void drive_manager_remove_drive (drive_T* drive); drive_partition_T* drive_manager_add_partition (drive_T* drive, uint32_t start_sector, uint32_t end_sector); void drive_manager_remove_partition (drive_partition_T* partition); #endif //NOXOS_DRIVE_MANAGER_H