1 |
|
|
/**************************************************************************/ |
2 |
|
|
/* */ |
3 |
|
|
/* Copyright (c) Microsoft Corporation. All rights reserved. */ |
4 |
|
|
/* */ |
5 |
|
|
/* This software is licensed under the Microsoft Software License */ |
6 |
|
|
/* Terms for Microsoft Azure RTOS. Full text of the license can be */ |
7 |
|
|
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ |
8 |
|
|
/* and in the root directory of this software. */ |
9 |
|
|
/* */ |
10 |
|
|
/**************************************************************************/ |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/**************************************************************************/ |
15 |
|
|
/** */ |
16 |
|
|
/** FileX Component */ |
17 |
|
|
/** */ |
18 |
|
|
/** System */ |
19 |
|
|
/** */ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
/**************************************************************************/ |
22 |
|
|
|
23 |
|
|
#define FX_SOURCE_CODE |
24 |
|
|
|
25 |
|
|
|
26 |
|
|
/* Locate FileX control component data in this file. */ |
27 |
|
|
|
28 |
|
|
#define FX_SYSTEM_INIT |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
/* Include necessary system files. */ |
32 |
|
|
|
33 |
|
|
#include "fx_api.h" |
34 |
|
|
#include "fx_system.h" |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
/**************************************************************************/ |
38 |
|
|
/* */ |
39 |
|
|
/* FUNCTION RELEASE */ |
40 |
|
|
/* */ |
41 |
|
|
/* _fx_system_initialize PORTABLE C */ |
42 |
|
|
/* 6.1 */ |
43 |
|
|
/* AUTHOR */ |
44 |
|
|
/* */ |
45 |
|
|
/* William E. Lamie, Microsoft Corporation */ |
46 |
|
|
/* */ |
47 |
|
|
/* DESCRIPTION */ |
48 |
|
|
/* */ |
49 |
|
|
/* This function initializes the various control data structures for */ |
50 |
|
|
/* the FileX System component. */ |
51 |
|
|
/* */ |
52 |
|
|
/* INPUT */ |
53 |
|
|
/* */ |
54 |
|
|
/* None */ |
55 |
|
|
/* */ |
56 |
|
|
/* OUTPUT */ |
57 |
|
|
/* */ |
58 |
|
|
/* None */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLS */ |
61 |
|
|
/* */ |
62 |
|
|
/* tx_timer_create Create system timer */ |
63 |
|
|
/* */ |
64 |
|
|
/* CALLED BY */ |
65 |
|
|
/* */ |
66 |
|
|
/* Application Initialization */ |
67 |
|
|
/* */ |
68 |
|
|
/* RELEASE HISTORY */ |
69 |
|
|
/* */ |
70 |
|
|
/* DATE NAME DESCRIPTION */ |
71 |
|
|
/* */ |
72 |
|
|
/* 05-19-2020 William E. Lamie Initial Version 6.0 */ |
73 |
|
|
/* 09-30-2020 William E. Lamie Modified comment(s), and */ |
74 |
|
|
/* added conditional to */ |
75 |
|
|
/* disable build options, */ |
76 |
|
|
/* resulting in version 6.1 */ |
77 |
|
|
/* */ |
78 |
|
|
/**************************************************************************/ |
79 |
|
51 |
VOID _fx_system_initialize(VOID) |
80 |
|
|
{ |
81 |
|
|
|
82 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
83 |
|
|
FX_TRACE_IN_LINE_INSERT(FX_TRACE_SYSTEM_INITIALIZE, 0, 0, 0, 0, FX_TRACE_INTERNAL_EVENTS, 0, 0) |
84 |
|
|
|
85 |
|
|
/* Initialize the head pointer of the opened media list and the |
86 |
|
|
number of opened media. */ |
87 |
|
51 |
_fx_system_media_opened_ptr = FX_NULL; |
88 |
|
51 |
_fx_system_media_opened_count = 0; |
89 |
|
|
|
90 |
|
|
/* Initialize the time and date fields with their default values. */ |
91 |
|
51 |
_fx_system_date = FX_INITIAL_DATE; |
92 |
|
51 |
_fx_system_time = FX_INITIAL_TIME; |
93 |
|
|
|
94 |
|
|
/* Initialize the sector and FAT cache sizes. */ |
95 |
|
51 |
_fx_system_media_max_sector_cache = FX_MAX_SECTOR_CACHE; |
96 |
|
51 |
_fx_system_media_max_fat_cache = FX_MAX_FAT_CACHE; |
97 |
|
|
|
98 |
|
|
/* Create the FileX system timer. This is responsible for updating |
99 |
|
|
the specified date and time at the rate specified by |
100 |
|
|
FX_UPDATE_RATE_IN_TICKS. Note that the timer is not necessary for |
101 |
|
|
regular FileX operation - it is only needed for accurate system |
102 |
|
|
date and time stamps on files. */ |
103 |
|
|
|
104 |
|
|
#ifndef FX_NO_TIMER |
105 |
|
51 |
tx_timer_create(&_fx_system_timer, "FileX System Timer", _fx_system_timer_entry, FX_TIMER_ID, |
106 |
|
|
FX_UPDATE_RATE_IN_TICKS, FX_UPDATE_RATE_IN_TICKS, TX_AUTO_ACTIVATE); |
107 |
|
|
#endif |
108 |
|
|
|
109 |
|
|
#ifndef FX_DISABLE_BUILD_OPTIONS |
110 |
|
|
/* Setup the build options variables. */ |
111 |
|
|
|
112 |
|
|
/* Setup the first build options variable. */ |
113 |
|
|
if (FX_MAX_LONG_NAME_LEN > 0xFF) |
114 |
|
|
{ |
115 |
|
51 |
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)0xFF) << 24); |
116 |
|
|
} |
117 |
|
|
else |
118 |
|
|
{ |
119 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)(FX_MAX_LONG_NAME_LEN & 0xFF)) << 24); |
120 |
|
|
} |
121 |
|
|
if (FX_MAX_LAST_NAME_LEN > 0xFF) |
122 |
|
|
{ |
123 |
|
51 |
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)0xFF) << 16); |
124 |
|
|
} |
125 |
|
|
else |
126 |
|
|
{ |
127 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)(FX_MAX_LAST_NAME_LEN & 0xFF)) << 24); |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
#ifdef FX_NO_TIMER |
131 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 10); |
132 |
|
|
#endif |
133 |
|
|
#ifdef FX_SINGLE_THREAD |
134 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 9); |
135 |
|
|
#endif |
136 |
|
|
#ifdef FX_DONT_UPDATE_OPEN_FILES |
137 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 8); |
138 |
|
|
#endif |
139 |
|
|
#ifdef FX_MEDIA_DISABLE_SEARCH_CACHE |
140 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 7); |
141 |
|
|
#endif |
142 |
|
|
#ifdef FX_MEDIA_STATISTICS_DISABLE |
143 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 6); |
144 |
|
|
#endif |
145 |
|
|
|
146 |
|
|
#ifdef FX_SINGLE_OPEN_LEGACY |
147 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 4); |
148 |
|
|
#endif |
149 |
|
|
#ifdef FX_RENAME_PATH_INHERIT |
150 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 3); |
151 |
|
|
#endif |
152 |
|
|
#ifdef FX_NO_LOCAL_PATH |
153 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 2); |
154 |
|
|
#endif |
155 |
|
|
#ifdef FX_FAULT_TOLERANT_DATA |
156 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 1); |
157 |
|
|
#endif |
158 |
|
|
#ifdef FX_FAULT_TOLERANT |
159 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | ((ULONG)1); |
160 |
|
|
#endif |
161 |
|
|
|
162 |
|
|
/* Setup the second build options variable. */ |
163 |
|
|
if (FX_MAX_SECTOR_CACHE > ((ULONG)0xFFFF)) |
164 |
|
|
{ |
165 |
|
|
_fx_system_build_options_2 = _fx_system_build_options_2 | (((ULONG)0xFFFF) << 16); |
166 |
|
|
} |
167 |
|
|
else |
168 |
|
|
{ |
169 |
|
51 |
_fx_system_build_options_2 = _fx_system_build_options_2 | (((ULONG)FX_MAX_SECTOR_CACHE) << 16); |
170 |
|
|
} |
171 |
|
|
if (FX_FAT_MAP_SIZE > 0xFF) |
172 |
|
|
{ |
173 |
|
|
_fx_system_build_options_2 = _fx_system_build_options_2 | (((ULONG)0xFF) << 8); |
174 |
|
|
} |
175 |
|
|
else |
176 |
|
|
{ |
177 |
|
51 |
_fx_system_build_options_2 = _fx_system_build_options_2 | (((ULONG)FX_FAT_MAP_SIZE) << 8); |
178 |
|
|
} |
179 |
|
|
if (FX_MAX_FAT_CACHE > 0xFF) |
180 |
|
|
{ |
181 |
|
|
_fx_system_build_options_2 = _fx_system_build_options_2 | ((ULONG)0xFF); |
182 |
|
|
} |
183 |
|
|
else |
184 |
|
|
{ |
185 |
|
51 |
_fx_system_build_options_2 = _fx_system_build_options_2 | ((ULONG)FX_MAX_FAT_CACHE); |
186 |
|
|
} |
187 |
|
|
|
188 |
|
|
/* Setup the third build options variable. */ |
189 |
|
|
if (FX_UPDATE_RATE_IN_SECONDS > 0xFF) |
190 |
|
|
{ |
191 |
|
|
_fx_system_build_options_3 = _fx_system_build_options_3 | (((ULONG)0xFF) << 16); |
192 |
|
|
} |
193 |
|
|
else |
194 |
|
|
{ |
195 |
|
51 |
_fx_system_build_options_3 = _fx_system_build_options_3 | (((ULONG)FX_UPDATE_RATE_IN_SECONDS) << 16); |
196 |
|
|
} |
197 |
|
|
if (FX_UPDATE_RATE_IN_TICKS > ((ULONG)0xFFFF)) |
198 |
|
|
{ |
199 |
|
|
_fx_system_build_options_3 = _fx_system_build_options_3 | ((ULONG)0xFFFF); |
200 |
|
|
} |
201 |
|
|
else |
202 |
|
|
{ |
203 |
|
51 |
_fx_system_build_options_3 = _fx_system_build_options_3 | ((ULONG)FX_UPDATE_RATE_IN_TICKS); |
204 |
|
|
} |
205 |
|
|
#endif /* FX_DISABLE_BUILD_OPTIONS */ |
206 |
|
51 |
} |
207 |
|
|
|