GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_media_space_available.c Lines: 7 7 100.0 %
Date: 2024-01-10 21:53:23 Branches: 4 4 100.0 %

Line Branch Exec Source
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
/**   Media                                                               */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
#define FX_SOURCE_CODE
24
25
26
/* Include necessary system files.  */
27
28
#include "fx_api.h"
29
#include "fx_system.h"
30
#include "fx_media.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _fx_media_space_available                           PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    William E. Lamie, Microsoft Corporation                             */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function returns the number of bytes available in the          */
46
/*    specified media.                                                    */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    media_ptr                             Media control block pointer   */
51
/*    available_bytes_ptr                   Pointer to available bytes    */
52
/*                                            destination                 */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    return status                                                       */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    None                                                                */
61
/*                                                                        */
62
/*    _fx_media_extended_space_available    Actual space available service*/
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    Application Code                                                    */
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),          */
74
/*                                            resulting in version 6.1    */
75
/*                                                                        */
76
/**************************************************************************/
77
162
UINT  _fx_media_space_available(FX_MEDIA *media_ptr, ULONG *available_bytes_ptr)
78
{
79
80
UINT    status;
81
ULONG64 available_bytes;
82
83
    /* Call actual media space available service.  */
84
162
    status = _fx_media_extended_space_available(media_ptr, &available_bytes);
85
86
    /* Check status.  */
87
162
    if (status == FX_SUCCESS)
88
    {
89
90
        /* Determine if more than 4GB available.  */
91
26
        if (available_bytes > 0x00000000FFFFFFFF)
92
        {
93
94
            /* Yes, we must have more than 4GB available... report the maximum we can fit
95
               in 32bits, which is 4GB.  */
96
1
            *available_bytes_ptr = 0xFFFFFFFF;
97
        }
98
        else
99
        {
100
25
            *available_bytes_ptr = (ULONG)(available_bytes);
101
        }
102
    }
103
104
    /* Return status to the caller.  */
105
162
    return(status);
106
}
107