1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
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 |
|
|
/**************************************************************************/ |
69 |
|
51 |
VOID _fx_system_initialize(VOID) |
70 |
|
|
{ |
71 |
|
|
|
72 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
73 |
|
|
FX_TRACE_IN_LINE_INSERT(FX_TRACE_SYSTEM_INITIALIZE, 0, 0, 0, 0, FX_TRACE_INTERNAL_EVENTS, 0, 0) |
74 |
|
|
|
75 |
|
|
/* Initialize the head pointer of the opened media list and the |
76 |
|
|
number of opened media. */ |
77 |
|
51 |
_fx_system_media_opened_ptr = FX_NULL; |
78 |
|
51 |
_fx_system_media_opened_count = 0; |
79 |
|
|
|
80 |
|
|
/* Initialize the time and date fields with their default values. */ |
81 |
|
51 |
_fx_system_date = FX_INITIAL_DATE; |
82 |
|
51 |
_fx_system_time = FX_INITIAL_TIME; |
83 |
|
|
|
84 |
|
|
/* Initialize the sector and FAT cache sizes. */ |
85 |
|
51 |
_fx_system_media_max_sector_cache = FX_MAX_SECTOR_CACHE; |
86 |
|
51 |
_fx_system_media_max_fat_cache = FX_MAX_FAT_CACHE; |
87 |
|
|
|
88 |
|
|
/* Create the FileX system timer. This is responsible for updating |
89 |
|
|
the specified date and time at the rate specified by |
90 |
|
|
FX_UPDATE_RATE_IN_TICKS. Note that the timer is not necessary for |
91 |
|
|
regular FileX operation - it is only needed for accurate system |
92 |
|
|
date and time stamps on files. */ |
93 |
|
|
|
94 |
|
|
#ifndef FX_NO_TIMER |
95 |
|
51 |
tx_timer_create(&_fx_system_timer, "FileX System Timer", _fx_system_timer_entry, FX_TIMER_ID, |
96 |
|
|
FX_UPDATE_RATE_IN_TICKS, FX_UPDATE_RATE_IN_TICKS, TX_AUTO_ACTIVATE); |
97 |
|
|
#endif |
98 |
|
|
|
99 |
|
|
#ifndef FX_DISABLE_BUILD_OPTIONS |
100 |
|
|
/* Setup the build options variables. */ |
101 |
|
|
|
102 |
|
|
/* Setup the first build options variable. */ |
103 |
|
|
if (FX_MAX_LONG_NAME_LEN > 0xFF) |
104 |
|
|
{ |
105 |
|
51 |
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)0xFF) << 24); |
106 |
|
|
} |
107 |
|
|
else |
108 |
|
|
{ |
109 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)(FX_MAX_LONG_NAME_LEN & 0xFF)) << 24); |
110 |
|
|
} |
111 |
|
|
if (FX_MAX_LAST_NAME_LEN > 0xFF) |
112 |
|
|
{ |
113 |
|
51 |
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)0xFF) << 16); |
114 |
|
|
} |
115 |
|
|
else |
116 |
|
|
{ |
117 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)(FX_MAX_LAST_NAME_LEN & 0xFF)) << 24); |
118 |
|
|
} |
119 |
|
|
|
120 |
|
|
#ifdef FX_NO_TIMER |
121 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 10); |
122 |
|
|
#endif |
123 |
|
|
#ifdef FX_SINGLE_THREAD |
124 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 9); |
125 |
|
|
#endif |
126 |
|
|
#ifdef FX_DONT_UPDATE_OPEN_FILES |
127 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 8); |
128 |
|
|
#endif |
129 |
|
|
#ifdef FX_MEDIA_DISABLE_SEARCH_CACHE |
130 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 7); |
131 |
|
|
#endif |
132 |
|
|
#ifdef FX_MEDIA_STATISTICS_DISABLE |
133 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 6); |
134 |
|
|
#endif |
135 |
|
|
|
136 |
|
|
#ifdef FX_SINGLE_OPEN_LEGACY |
137 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 4); |
138 |
|
|
#endif |
139 |
|
|
#ifdef FX_RENAME_PATH_INHERIT |
140 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 3); |
141 |
|
|
#endif |
142 |
|
|
#ifdef FX_NO_LOCAL_PATH |
143 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 2); |
144 |
|
|
#endif |
145 |
|
|
#ifdef FX_FAULT_TOLERANT_DATA |
146 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | (((ULONG)1) << 1); |
147 |
|
|
#endif |
148 |
|
|
#ifdef FX_FAULT_TOLERANT |
149 |
|
|
_fx_system_build_options_1 = _fx_system_build_options_1 | ((ULONG)1); |
150 |
|
|
#endif |
151 |
|
|
|
152 |
|
|
/* Setup the second build options variable. */ |
153 |
|
|
if (FX_MAX_SECTOR_CACHE > ((ULONG)0xFFFF)) |
154 |
|
|
{ |
155 |
|
|
_fx_system_build_options_2 = _fx_system_build_options_2 | (((ULONG)0xFFFF) << 16); |
156 |
|
|
} |
157 |
|
|
else |
158 |
|
|
{ |
159 |
|
51 |
_fx_system_build_options_2 = _fx_system_build_options_2 | (((ULONG)FX_MAX_SECTOR_CACHE) << 16); |
160 |
|
|
} |
161 |
|
|
if (FX_FAT_MAP_SIZE > 0xFF) |
162 |
|
|
{ |
163 |
|
|
_fx_system_build_options_2 = _fx_system_build_options_2 | (((ULONG)0xFF) << 8); |
164 |
|
|
} |
165 |
|
|
else |
166 |
|
|
{ |
167 |
|
51 |
_fx_system_build_options_2 = _fx_system_build_options_2 | (((ULONG)FX_FAT_MAP_SIZE) << 8); |
168 |
|
|
} |
169 |
|
|
if (FX_MAX_FAT_CACHE > 0xFF) |
170 |
|
|
{ |
171 |
|
|
_fx_system_build_options_2 = _fx_system_build_options_2 | ((ULONG)0xFF); |
172 |
|
|
} |
173 |
|
|
else |
174 |
|
|
{ |
175 |
|
51 |
_fx_system_build_options_2 = _fx_system_build_options_2 | ((ULONG)FX_MAX_FAT_CACHE); |
176 |
|
|
} |
177 |
|
|
|
178 |
|
|
/* Setup the third build options variable. */ |
179 |
|
|
if (FX_UPDATE_RATE_IN_SECONDS > 0xFF) |
180 |
|
|
{ |
181 |
|
|
_fx_system_build_options_3 = _fx_system_build_options_3 | (((ULONG)0xFF) << 16); |
182 |
|
|
} |
183 |
|
|
else |
184 |
|
|
{ |
185 |
|
51 |
_fx_system_build_options_3 = _fx_system_build_options_3 | (((ULONG)FX_UPDATE_RATE_IN_SECONDS) << 16); |
186 |
|
|
} |
187 |
|
|
if (FX_UPDATE_RATE_IN_TICKS > ((ULONG)0xFFFF)) |
188 |
|
|
{ |
189 |
|
|
_fx_system_build_options_3 = _fx_system_build_options_3 | ((ULONG)0xFFFF); |
190 |
|
|
} |
191 |
|
|
else |
192 |
|
|
{ |
193 |
|
51 |
_fx_system_build_options_3 = _fx_system_build_options_3 | ((ULONG)FX_UPDATE_RATE_IN_TICKS); |
194 |
|
|
} |
195 |
|
|
#endif /* FX_DISABLE_BUILD_OPTIONS */ |
196 |
|
51 |
} |
197 |
|
|
|