XHCI big clean up, #define necessary bits for readability, change .clang-format options
This commit is contained in:
@@ -426,8 +426,10 @@ typedef unsigned int uint32;
|
||||
#define MAX_LONGFILENAME_ENTRIES 20
|
||||
#define MAX_LFN_ENTRY_LENGTH 13
|
||||
#define GET_32BIT_WORD(buffer, location) \
|
||||
(((uint32)buffer[location + 3] << 24) + ((uint32)buffer[location + 2] << 16) + \
|
||||
((uint32)buffer[location + 1] << 8) + (uint32)buffer[location + 0])
|
||||
(((uint32)buffer[location + 3] << 24) + \
|
||||
((uint32)buffer[location + 2] << 16) + \
|
||||
((uint32)buffer[location + 1] << 8) + \
|
||||
(uint32)buffer[location + 0])
|
||||
#define GET_16BIT_WORD(buffer, location) \
|
||||
(((uint16)buffer[location + 1] << 8) + (uint16)buffer[location + 0])
|
||||
#define SET_32BIT_WORD(buffer, location, value) \
|
||||
@@ -511,23 +513,30 @@ int fatfs_entry_lfn_text (struct fat_dir_entry* entry) {
|
||||
return 0;
|
||||
}
|
||||
int fatfs_entry_lfn_invalid (struct fat_dir_entry* entry) {
|
||||
if ((entry->Name[0] == FILE_HEADER_BLANK) || (entry->Name[0] == FILE_HEADER_DELETED) ||
|
||||
(entry->Attr == FILE_ATTR_VOLUME_ID) || (entry->Attr & FILE_ATTR_SYSHID))
|
||||
if ((entry->Name[0] == FILE_HEADER_BLANK) ||
|
||||
(entry->Name[0] == FILE_HEADER_DELETED) ||
|
||||
(entry->Attr == FILE_ATTR_VOLUME_ID) ||
|
||||
(entry->Attr & FILE_ATTR_SYSHID))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
int fatfs_entry_lfn_exists (struct lfn_cache* lfn, struct fat_dir_entry* entry) {
|
||||
if ((entry->Attr != FILE_ATTR_LFN_TEXT) && (entry->Name[0] != FILE_HEADER_BLANK) &&
|
||||
(entry->Name[0] != FILE_HEADER_DELETED) && (entry->Attr != FILE_ATTR_VOLUME_ID) &&
|
||||
(!(entry->Attr & FILE_ATTR_SYSHID)) && (lfn->no_of_strings))
|
||||
if ((entry->Attr != FILE_ATTR_LFN_TEXT) &&
|
||||
(entry->Name[0] != FILE_HEADER_BLANK) &&
|
||||
(entry->Name[0] != FILE_HEADER_DELETED) &&
|
||||
(entry->Attr != FILE_ATTR_VOLUME_ID) &&
|
||||
(!(entry->Attr & FILE_ATTR_SYSHID)) &&
|
||||
(lfn->no_of_strings))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
int fatfs_entry_sfn_only (struct fat_dir_entry* entry) {
|
||||
if ((entry->Attr != FILE_ATTR_LFN_TEXT) && (entry->Name[0] != FILE_HEADER_BLANK) &&
|
||||
(entry->Name[0] != FILE_HEADER_DELETED) && (entry->Attr != FILE_ATTR_VOLUME_ID) &&
|
||||
if ((entry->Attr != FILE_ATTR_LFN_TEXT) &&
|
||||
(entry->Name[0] != FILE_HEADER_BLANK) &&
|
||||
(entry->Name[0] != FILE_HEADER_DELETED) &&
|
||||
(entry->Attr != FILE_ATTR_VOLUME_ID) &&
|
||||
(!(entry->Attr & FILE_ATTR_SYSHID)))
|
||||
return 1;
|
||||
else
|
||||
@@ -1278,7 +1287,8 @@ int fatfs_init (struct fatfs_ctx* ctx, struct fatfs* fs) {
|
||||
total_sectors = GET_32BIT_WORD (fs->currentsector.sector, BPB_TOTSEC32);
|
||||
data_sectors = total_sectors -
|
||||
(GET_16BIT_WORD (fs->currentsector.sector, BPB_RSVDSECCNT) +
|
||||
(fs->currentsector.sector[BPB_NUMFATS] * FATSz) + root_dir_sectors);
|
||||
(fs->currentsector.sector[BPB_NUMFATS] * FATSz) +
|
||||
root_dir_sectors);
|
||||
if (fs->sectors_per_cluster != 0) {
|
||||
count_of_clusters = data_sectors / fs->sectors_per_cluster;
|
||||
if (count_of_clusters < 4085)
|
||||
@@ -1296,7 +1306,8 @@ int fatfs_init (struct fatfs_ctx* ctx, struct fatfs* fs) {
|
||||
}
|
||||
uint32 fatfs_lba_of_cluster (struct fatfs* fs, uint32 Cluster_Number) {
|
||||
if (fs->fat_type == FAT_TYPE_16)
|
||||
return (fs->cluster_begin_lba + (fs->root_entry_count * 32 / FAT_SECTOR_SIZE) +
|
||||
return (fs->cluster_begin_lba +
|
||||
(fs->root_entry_count * 32 / FAT_SECTOR_SIZE) +
|
||||
((Cluster_Number - 2) * fs->sectors_per_cluster));
|
||||
else
|
||||
return ((fs->cluster_begin_lba + ((Cluster_Number - 2) * fs->sectors_per_cluster)));
|
||||
|
||||
@@ -215,8 +215,10 @@ int fatfs_format_fat32 (struct fatfs_ctx* ctx, struct fatfs* fs, uint32 volume_s
|
||||
#define MAX_LONGFILENAME_ENTRIES 20
|
||||
#define MAX_LFN_ENTRY_LENGTH 13
|
||||
#define GET_32BIT_WORD(buffer, location) \
|
||||
(((uint32)buffer[location + 3] << 24) + ((uint32)buffer[location + 2] << 16) + \
|
||||
((uint32)buffer[location + 1] << 8) + (uint32)buffer[location + 0])
|
||||
(((uint32)buffer[location + 3] << 24) + \
|
||||
((uint32)buffer[location + 2] << 16) + \
|
||||
((uint32)buffer[location + 1] << 8) + \
|
||||
(uint32)buffer[location + 0])
|
||||
#define GET_16BIT_WORD(buffer, location) \
|
||||
(((uint16)buffer[location + 1] << 8) + (uint16)buffer[location + 0])
|
||||
#define SET_32BIT_WORD(buffer, location, value) \
|
||||
|
||||
Reference in New Issue
Block a user