1 /* 2 * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef FSM_DEVICE_H 13 #define FSM_DEVICE_H 14 15 #include <chcore-internal/procmgr_defs.h> 16 17 #define SD_PARTITION_INFO_OFFSET 446 18 #define SD_PARTITION_INFO_SIZE 16 19 20 #define MAX_DEVICE_PARTITION 16 21 22 #define FAT32_PARTITION 0xc 23 #define EXT4_PARTITION 0x83 24 #define LITTLEFS_PARTITION 0x85 25 26 typedef struct { 27 unsigned char boot; 28 unsigned char head; 29 unsigned char sector; 30 unsigned char cylinder; 31 unsigned char fs_id; 32 unsigned char head_end; 33 unsigned char sector_end; 34 unsigned char cylinder_end; 35 unsigned int lba; 36 unsigned int total_sector; 37 } partition_struct_t; 38 39 typedef struct { 40 char device_name[256]; 41 int partition_type; 42 bool valid; 43 int server_id; 44 int partition_index; 45 bool mounted; 46 unsigned int partition_lba; 47 } device_partition_t; 48 49 int mount_storage_device(const char *device_name); 50 device_partition_t *chcore_get_server(const char *device_name); 51 int chcore_initial_fat_partition(cap_t fs_cap, int partition); 52 void print_partition(partition_struct_t *p); 53 void print_devices(void); 54 55 #endif /* FSM_DEVICE_H */