GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_system_initialize.c Lines: 16 16 100.0 %
Date: 2024-03-11 05:15:45 Branches: 0 0 - %

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