Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
#define FX_SOURCE_CODE
#include "fx_api.h"
#include "fx_system.h"
#include "fx_media.h"
#include "fx_utility.h"
#include "fx_directory_exFAT.h"
...
Files
filex
common
drivers
inc
src
ports
threadx
levelx
SourceVuSTM32 Libraries and Samplesfilexcommon/src/fx_utility_exFAT_size_calculate.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** FileX Component */ /** */ /** Utility */ /** */... /**************************************************************************/ /**************************************************************************/ #define FX_SOURCE_CODE /* Include necessary system files. */ #include "fx_api.h" #ifdef FX_ENABLE_EXFAT #include "fx_system.h" #include "fx_media.h" #include "fx_utility.h" #include "fx_directory_exFAT.h" /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _fx_utility_exFAT_size_calculate PORTABLE C */ /* 6.1.10 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function calculates FAT size according to given parameters. */ /* */ /* INPUT */ /* */ /* boundary_unit Data area alignment in sectors*/ /* size_in_sectors Partition size in sectors */ /* sectors_per_cluster Number of sectors per cluster */ /* sectors_per_fat_ptr Pointer to sector per FAT */ /* fat_offset_ptr Pointer to offset of FAT */ /* cluster_heap_offset_ptr Pointer to offset of cluster */ /* heap */ /* */ /* OUTPUT */ /* */ /* NONE */ /* */ /* CALLS */ /* */ /* None */ /* */ /* CALLED BY */ /* */ /* _fx_media_exFAT_format */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 William E. Lamie Initial Version 6.0 */ /* 09-30-2020 William E. Lamie Modified comment(s), */ /* resulting in version 6.1 */ /* 03-02-2021 William E. Lamie Modified comment(s), fixed */ /* FAT size calculation issue, */ /* resulting in version 6.1.5 */ /* 01-31-2022 Bhupendra Naphade Modified comment(s), and */ /* replaced sector size */ /* constant, */ /* resulting in version 6.1.10 */ /* */... /**************************************************************************/ VOID _fx_utility_exFAT_size_calculate(UINT bytes_per_sector, ULONG boundary_unit, ULONG64 size_in_sectors, ULONG sectors_per_cluster, ULONG *sectors_per_fat_ptr, ULONG *fat_offset_ptr, ULONG *cluster_heap_offset_ptr) { ULONG system_area_sectors = 0; /* Number of sectors for exFTA system area (from partition begining) */ ULONG64 total_cluster_heap_sectors; /* Align the boundary unit. If zero supplied, then set to default value. */ boundary_unit = ALIGN_UP(boundary_unit, 128); /* Align System Area according Boundary Unit. */ while (system_area_sectors < (EXFAT_BOOT_REGION_SIZE + EXFAT_MIN_NUM_OF_RESERVED_SECTORS)) { system_area_sectors += boundary_unit; }while (system_area_sectors < (EXFAT_BOOT_REGION_SIZE + EXFAT_MIN_NUM_OF_RESERVED_SECTORS)) { ... } /* Save preliminary FAT offset. */ *fat_offset_ptr = system_area_sectors; /* Save preliminary Clusters Heap offset. */ *cluster_heap_offset_ptr = *fat_offset_ptr; /* Calculate number of available sectors without system sectors. */ total_cluster_heap_sectors = size_in_sectors - system_area_sectors; /* Calculate required number of FAT sectors. */ *sectors_per_fat_ptr = (ULONG)DIVIDE_TO_CEILING(((total_cluster_heap_sectors / sectors_per_cluster) * EXFAT_FAT_BITS), (bytes_per_sector * BITS_PER_BYTE)); *sectors_per_fat_ptr = ALIGN_UP(*sectors_per_fat_ptr, boundary_unit >> 1); /* Check is it possible to allocate FAT inside calculated System Area sectors or not. */ if (system_area_sectors > (EXFAT_BOOT_REGION_SIZE + EXFAT_MIN_NUM_OF_RESERVED_SECTORS + *sectors_per_fat_ptr)) { /* We able allocate FAT inside calculated logical_system_area_sectors. */ *fat_offset_ptr -= *sectors_per_fat_ptr; }if (system_area_sectors > (EXFAT_BOOT_REGION_SIZE + EXFAT_MIN_NUM_OF_RESERVED_SECTORS + *sectors_per_fat_ptr)) { ... } else /* Recalculate FAT size since System Area will be increased on FAT size. */ { do { /* Increase System Area size on number of FAT sectors aligned according BU. */ system_area_sectors = *fat_offset_ptr + *sectors_per_fat_ptr; /* Decrease sectors available for clusters heap. */ total_cluster_heap_sectors = size_in_sectors - system_area_sectors; /* Re-calculate number of sectors per FAT. */ *sectors_per_fat_ptr = (ULONG)DIVIDE_TO_CEILING(((total_cluster_heap_sectors / sectors_per_cluster) * EXFAT_FAT_BITS), (bytes_per_sector * BITS_PER_BYTE)); *sectors_per_fat_ptr = ALIGN_UP(*sectors_per_fat_ptr, boundary_unit >> 1); /* Increase Cluster Heap offset according new FAT size. */ *cluster_heap_offset_ptr = *fat_offset_ptr + *sectors_per_fat_ptr; /* Loop until we find a FAT size that can hold all the clusters. */ ...}while (*sectors_per_fat_ptr * bytes_per_sector * BITS_PER_BYTE / EXFAT_FAT_BITS < ((size_in_sectors - *cluster_heap_offset_ptr) / sectors_per_cluster)); }else { ... } }_fx_utility_exFAT_size_calculate (UINT bytes_per_sector, ULONG boundary_unit, ULONG64 size_in_sectors, ULONG sectors_per_cluster, ULONG *sectors_per_fat_ptr, ULONG *fat_offset_ptr, ULONG *cluster_heap_offset_ptr) { ... } /* ... */ #endif /* FX_ENABLE_EXFAT */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.