SayoriOS 0.3.3

fat32.h
1
9 #pragma once
10
11 #include <common.h>
12 #include <io/ports.h>
13 #include <fs/fsm.h>
14 #include "../../src/lib/libvector/include/vector.h"
15
16 #define FAT32_LINEAR_OPTIMIZATION 1
17
18 typedef struct {
19 char bootcode[3];
20 char OEM[8];
21 uint16_t bytes_per_sector;
22 uint8_t sectors_per_cluster;
23 uint16_t reserved_sectors;
24 uint8_t copies;
25 uint16_t root_entries;
26 uint16_t small_sectors_number;
27 uint8_t descriptor;
28 uint16_t sectors_per_fat;
29 uint16_t sectors_per_track;
30 uint16_t heads;
31 uint32_t hidden_sectors;
32 uint32_t sectors_in_partition;
33 uint32_t fat_size_in_sectors;
34 uint16_t flags;
35 uint16_t version_num;
36 uint32_t root_directory_offset_in_clusters;
37 uint16_t fsinfo_sector;
38 uint16_t _;
39 char reserved1[12];
40 uint8_t disk_number;
41 uint8_t flags1;
42 uint8_t extended_boot_signature;
43 uint32_t volume_serial_number;
44 char volume_label[11];
45 char fs_type[8];
46 } __attribute__((packed)) fat_info_t;
47
48 typedef struct {
49 char short_file_name[11]; // 8.3
50 uint8_t attributes;
51 uint8_t register_sign;
52
53 uint8_t create_millis;
54 uint16_t create_time;
55 uint16_t create_date;
56 uint16_t last_access_date;
57
58 uint16_t first_cluster_high;
59 uint16_t last_modif_time;
60 uint16_t last_modif_date;
61 uint16_t first_cluster_low;
62 uint32_t file_size_in_bytes;
63 } __attribute__((packed)) fat_object_info_t;
64
65 typedef struct {
66 uint8_t attr_number;
67 uint16_t first_name_chunk[5];
68 uint8_t attribute;
69 uint8_t reserved;
70 uint8_t checksum;
71 uint16_t second_name_chunk[6];
72 uint16_t reserved2;
73 uint16_t third_name_chunk[2];
74 } __attribute__((packed)) LFN_t;
75
76 typedef struct {
77 fat_info_t info;
78
79 uint32_t cluster_size;
80 uint32_t fat_offset;
81 uint32_t fat_size;
82 uint32_t reserved_fat_offset;
83 uint32_t root_directory_offset;
84
85 uint32_t* fat_table;
86 } fat_description_t; // This structure never used in data parsing and represents all needed data for FAT32 driver.
87
88 #define LFN_LAST_ENTRY 0x40
89 #define ATTR_READ_ONLY 0x01
90 #define ATTR_HIDDEN 0x02
91 #define ATTR_SYSTEM 0x04
92 #define ATTR_VOLUME_ID 0x08
93 #define ATTR_DIRECTORY 0x10
94 #define ATTR_ARCHIVE 0x20
95 #define ATTR_LONG_FILE_NAME 0x0F
96
97 typedef struct {
98 char filename[256];
99 size_t size;
100
101 size_t starting_cluster;
102
103 fat_object_info_t advanced_info;
104
105 bool is_lfn;
106 } fat_file_info_t;
107
108 size_t fs_fat32_read(char Disk,const char* Path, size_t Offset, size_t Size,void* Buffer);
109 size_t fs_fat32_write(char Disk,const char* Path,size_t Offset,size_t Size,void* Buffer);
110 FSM_FILE fs_fat32_info(char Disk,const char* Path);
111 FSM_DIR* fs_fat32_dir(char Disk,const char* Path);
112 int fs_fat32_create(char Disk,const char* Path,int Mode);
113 int fs_fat32_delete(char Disk,const char* Path,int Mode);
114 void fs_fat32_label(char Disk, char* Label);
115 int fs_fat32_detect(char Disk);
116 vector_t* fs_fat32_get_clusters(char Disk, size_t cluster_number);
117 size_t fs_fat32_get_cluster_count(char Disk, size_t cluster_number);
118 void fs_fat32_read_clusters_to_memory(char Disk, size_t cluster_number, void* buffer);
119 fat_file_info_t fs_fat32_read_file_info(char* data);
120 void fs_fat32_read_entire_fat(char Disk);
121 fat_file_info_t fs_fat32_get_object_info(char Disk, const char* filename, size_t directory_cluster);
122 size_t fs_fat32_evaluate(char Disk, const char* path, bool error_on_file);
123 void fs_fat32_read_file_from_dir(char Disk, size_t directory_cluster, size_t byte_offset, size_t length, char *filename,
124 char *out);
common.h
Основные определения ядра
__attribute__
struct registers __attribute__((packed))
Структура данных пакета от мыши
Definition: psf.h:19
fat_description_t
Definition: fat32.h:76
fat_file_info_t
Definition: fat32.h:97
vector
Definition: vector.h:7