44#ifdef LOSCFG_FS_FAT_CACHE
55#define MAX_DIVIDE_PART_PER_DISK 16
56#define MAX_PRIMARY_PART_PER_DISK 4
57#define SYS_MAX_PART (SYS_MAX_DISK * MAX_DIVIDE_PART_PER_DISK)
59#define DISK_MAX_SECTOR_SIZE 512
63#define BS_FILSYSTEMTYPE32 82
65#define BS_FILSYSTYPE 0x36
66#define BS_SIG55AA_VALUE 0xAA55
68#define PAR_TYPE_OFFSET 4
69#define PAR_START_OFFSET 8
70#define PAR_COUNT_OFFSET 12
71#define PAR_TABLE_SIZE 16
72#define EXTENDED_PAR 0x0F
73#define EXTENDED_8G 0x05
77#define BS_FS_TYPE_MASK 0xFFFFFF
78#define BS_FS_TYPE_VALUE 0x544146
79#define BS_FS_TYPE_FAT 0x0B
80#define BS_FS_TYPE_NTFS 0x07
89#define LD_WORD_DISK(ptr) (UINT16)(((UINT16)*((UINT8 *)(ptr) + FIRST_BYTE) << (BIT_FOR_BYTE * FIRST_BYTE)) | \
90 (UINT16)*(UINT8 *)(ptr))
91#define LD_DWORD_DISK(ptr) (UINT32)(((UINT32)*((UINT8 *)(ptr) + THIRD_BYTE) << (BIT_FOR_BYTE * THIRD_BYTE)) | \
92 ((UINT32)*((UINT8 *)(ptr) + SECOND_BYTE) << (BIT_FOR_BYTE * SECOND_BYTE)) | \
93 ((UINT16)*((UINT8 *)(ptr) + FIRST_BYTE) << (BIT_FOR_BYTE * FIRST_BYTE)) | \
96#define LD_QWORD_DISK(ptr) ((UINT64)(((UINT64)LD_DWORD_DISK(&(ptr)[FOURTH_BYTE]) << (BIT_FOR_BYTE * FOURTH_BYTE)) | \
100#define VERIFY_FS(ptr) (((LD_DWORD_DISK(&(ptr)[BS_FILSYSTEMTYPE32]) & BS_FS_TYPE_MASK) == BS_FS_TYPE_VALUE) || \
101 !strncmp(&(ptr)[BS_FILSYSTYPE], "FAT", strlen("FAT")) || \
102 !strncmp(&(ptr)[BS_JMPBOOT], "\xEB\x52\x90" "NTFS ", \
103 strlen("\xEB\x52\x90" "NTFS ")))
105#define PARTION_MODE_BTYE (PAR_OFFSET + PAR_TYPE_OFFSET)
106#define PARTION_MODE_GPT 0xEE
107#define SIGNATURE_OFFSET 0
108#define SIGNATURE_LEN 8
109#define HEADER_SIZE_OFFSET 12
110#define TABLE_SIZE_OFFSET 84
111#define TABLE_NUM_OFFSET 80
112#define TABLE_START_SECTOR 2
113#define TABLE_MAX_NUM 128
114#define TABLE_SIZE 128
115#define GPT_PAR_START_OFFSET 32
116#define GPT_PAR_END_OFFSET 40
117#define PAR_ENTRY_NUM_PER_SECTOR 4
118#define HEADER_SIZE_MASK 0xFFFFFFFF
119#define HEADER_SIZE 0x5C
120#define HARD_DISK_GUID_OFFSET 56
121#define HARD_DISK_GUID_FOR_ESP 0x0020004900460045
122#define HARD_DISK_GUID_FOR_MSP 0x007200630069004D
123#define PAR_VALID_OFFSET0 0
124#define PAR_VALID_OFFSET1 4
125#define PAR_VALID_OFFSET2 8
126#define PAR_VALID_OFFSET3 12
128#define VERIFY_GPT(ptr) ((!strncmp(&(ptr)[SIGNATURE_OFFSET], "EFI PART", SIGNATURE_LEN)) && \
129 ((LD_DWORD_DISK(&(ptr)[HEADER_SIZE_OFFSET]) & HEADER_SIZE_MASK) == HEADER_SIZE))
131#define VERITY_PAR_VALID(ptr) ((LD_DWORD_DISK(&(ptr)[PAR_VALID_OFFSET0]) + \
132 LD_DWORD_DISK(&(ptr)[PAR_VALID_OFFSET1]) + \
133 LD_DWORD_DISK(&(ptr)[PAR_VALID_OFFSET2]) + \
134 LD_DWORD_DISK(&(ptr)[PAR_VALID_OFFSET3])) != 0)
137#define VERITY_AVAILABLE_PAR(ptr) ((LD_QWORD_DISK(&(ptr)[HARD_DISK_GUID_OFFSET]) != HARD_DISK_GUID_FOR_ESP) && \
138 (LD_QWORD_DISK(&(ptr)[HARD_DISK_GUID_OFFSET]) != HARD_DISK_GUID_FOR_MSP))
142#define DISK_CTRL_SYNC 0
143#define DISK_GET_SECTOR_COUNT 1
144#define DISK_GET_SECTOR_SIZE 2
145#define DISK_GET_BLOCK_SIZE 3
146#define DISK_CTRL_TRIM 4
149#define DISK_CTRL_POWER 5
150#define DISK_CTRL_LOCK 6
151#define DISK_CTRL_EJECT 7
152#define DISK_CTRL_FORMAT 8
155#define DISK_MMC_GET_TYPE 10
156#define DISK_MMC_GET_CSD 11
157#define DISK_MMC_GET_CID 12
158#define DISK_MMC_GET_OCR 13
159#define DISK_MMC_GET_SDSTAT 14
162#define DISK_ATA_GET_REV 20
163#define DISK_ATA_GET_MODEL 21
164#define DISK_ATA_GET_SN 22
166#ifndef LOSCFG_FS_FAT_CACHE
167#define DISK_DIRECT_BUFFER_SIZE 4
182#ifdef LOSCFG_FS_FAT_CACHE
192#ifndef LOSCFG_FS_FAT_CACHE
268 VOID *priv,
INT32 diskID, VOID *info);
los_disk * los_get_mmcdisk_bytype(UINT8 type)
struct _los_part_ los_part
struct _los_disk_ los_disk
enum _disk_status_ disk_status_e
INT32 add_mmc_partition(struct disk_divide_info *info, size_t sectorStart, size_t sectorCount)
Add a new mmc partition.
INT32 los_disk_write(INT32 drvID, const VOID *buf, UINT64 sector, UINT32 count)
Write data to a disk driver.
INT32 los_disk_read(INT32 drvID, VOID *buf, UINT64 sector, UINT32 count, BOOL useRead)
Read data from disk driver.
INT32 los_disk_cache_clear(INT32 drvID)
Clear the bcache data
INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops, VOID *priv, INT32 diskID, VOID *info)
Disk driver initialization.
INT32 los_part_read(INT32 pt, VOID *buf, UINT64 sector, UINT32 count, BOOL useRead)
Read data from chosen partition.
los_disk * get_disk(INT32 id)
Find disk driver.
INT32 los_disk_set_bcache(INT32 drvID, UINT32 sectorPerBlock, UINT32 blockNum)
Set blib cache for the disk driver.
INT32 los_get_diskid_byname(const CHAR *diskName)
get the INUSED disk id.
INT32 los_disk_deinit(INT32 diskID)
Destroy a disk driver.
VOID show_part(los_part *part)
Print partition information.
los_part * get_part(INT32 id)
Find disk partition.
los_part * los_part_find(struct Vnode *blkDriver)
Find disk partition.
INT32 los_part_access(const CHAR *dev, mode_t mode)
Decide the chosen partition is exist or not.
INT32 los_disk_ioctl(INT32 drvID, INT32 cmd, VOID *buf)
Get information of disk driver.
INT32 los_alloc_diskid_byname(const CHAR *diskName)
alloc a new UNUSED disk id.
INT32 los_part_write(INT32 pt, const VOID *buf, UINT64 sector, UINT32 count)
Write data to chosen partition.
INT32 los_part_ioctl(INT32 pt, INT32 cmd, VOID *buf)
Get information of chosen partition.
INT32 los_disk_sync(INT32 drvID)
Sync blib cache.
struct pthread_mutex disk_mutex
vnode并不包含文件名,因为 vnode和文件名是 1:N 的关系
struct partition_info part[MAX_DIVIDE_PART_PER_DISK+MAX_PRIMARY_PART_PER_DISK]
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 ARG_NUM_0 ARG_NUM_2 ARG_NUM_1 ARG_NUM_2 ARG_NUM_3 ARG_NUM_7 ARG_NUM_2 ARG_NUM_3 ARG_NUM_2 ARG_NUM_4 ARG_NUM_5 ARG_NUM_6 ARG_NUM_3 ARG_NUM_5 ARG_NUM_7 ARG_NUM_1 ARG_NUM_4 ARG_NUM_5 ARG_NUM_4 ARG_NUM_7 ARG_NUM_2 ARG_NUM_3 ARG_NUM_7 ARG_NUM_7 ARG_NUM_3 ARG_NUM_3 ARG_NUM_3 ARG_NUM_7 ARG_NUM_3 ARG_NUM_2 char ARG_NUM_2 ARG_NUM_1 ARG_NUM_0 ARG_NUM_0 ARG_NUM_3 void ARG_NUM_1 ARG_NUM_0 unsigned ARG_NUM_0 ARG_NUM_2 ARG_NUM_3 ARG_NUM_2 ARG_NUM_5 ARG_NUM_3 ARG_NUM_3 ARG_NUM_4 ARG_NUM_1 ARG_NUM_1 ARG_NUM_3 ARG_NUM_2 mode_t