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 /**   Media                                                               */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    fx_media.h                                          PORTABLE C      */
28 /*                                                           6.1          */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    William E. Lamie, Microsoft Corporation                             */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the FileX Media component constants, data         */
36 /*    definitions, and external references.  It is assumed that fx_api.h  */
37 /*    (and fx_port.h) have already been included.                         */
38 /*                                                                        */
39 /*  RELEASE HISTORY                                                       */
40 /*                                                                        */
41 /*    DATE              NAME                      DESCRIPTION             */
42 /*                                                                        */
43 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
44 /*  09-30-2020     William E. Lamie         Modified comment(s),          */
45 /*                                            resulting in version 6.1    */
46 /*                                                                        */
47 /**************************************************************************/
48 
49 #ifndef FX_MEDIA_H
50 #define FX_MEDIA_H
51 
52 
53 /* Define the external Media component function prototypes.  */
54 
55 UINT _fx_media_abort(FX_MEDIA *media_ptr);
56 UINT _fx_media_cache_invalidate(FX_MEDIA *media_ptr);
57 UINT _fx_media_check(FX_MEDIA *media_ptr, UCHAR *scratch_memory_ptr, ULONG scratch_memory_size, ULONG error_correction_option, ULONG *errors_detected);
58 UINT _fx_media_close(FX_MEDIA *media_ptr);
59 UINT _fx_media_flush(FX_MEDIA *media_ptr);
60 UINT _fx_media_format(FX_MEDIA *media_ptr, VOID (*driver)(FX_MEDIA *media), VOID *driver_info_ptr, UCHAR *memory_ptr, UINT memory_size,
61                       CHAR *volume_name, UINT number_of_fats, UINT directory_entries, UINT hidden_sectors,
62                       ULONG total_sectors, UINT bytes_per_sector, UINT sectors_per_cluster,
63                       UINT heads, UINT sectors_per_track);
64 UINT _fx_media_open(FX_MEDIA *media_ptr, CHAR *media_name,
65                     VOID (*media_driver)(FX_MEDIA *), VOID *driver_info_ptr,
66                     VOID *memory_ptr, ULONG memory_size);
67 UINT _fx_media_read(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
68 UINT _fx_media_space_available(FX_MEDIA *media_ptr, ULONG *available_bytes_ptr);
69 UINT _fx_media_volume_get(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_source);
70 UINT _fx_media_volume_get_extended(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_name_buffer_length, UINT volume_source);
71 UINT _fx_media_volume_set(FX_MEDIA *media_ptr, CHAR *volume_name);
72 UINT _fx_media_write(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
73 UINT _fx_media_open_notify_set(FX_MEDIA *media_ptr, VOID (*media_open_notify)(FX_MEDIA *));
74 UINT _fx_media_close_notify_set(FX_MEDIA *media_ptr, VOID (*media_close_notify)(FX_MEDIA *));
75 UINT _fx_media_extended_space_available(FX_MEDIA *media_ptr, ULONG64 *available_bytes_ptr);
76 
77 
78 UINT _fxe_media_abort(FX_MEDIA *media_ptr);
79 UINT _fxe_media_cache_invalidate(FX_MEDIA *media_ptr);
80 UINT _fxe_media_check(FX_MEDIA *media_ptr, UCHAR *scratch_memory_ptr, ULONG scratch_memory_size, ULONG error_correction_option, ULONG *errors_detected);
81 UINT _fxe_media_close(FX_MEDIA *media_ptr);
82 UINT _fxe_media_flush(FX_MEDIA *media_ptr);
83 UINT _fxe_media_format(FX_MEDIA *media_ptr, VOID (*driver)(FX_MEDIA *media), VOID *driver_info_ptr, UCHAR *memory_ptr, UINT memory_size,
84                        CHAR *volume_name, UINT number_of_fats, UINT directory_entries, UINT hidden_sectors,
85                        ULONG total_sectors, UINT bytes_per_sector, UINT sectors_per_cluster,
86                        UINT heads, UINT sectors_per_track);
87 UINT _fxe_media_open(FX_MEDIA *media_ptr, CHAR *media_name,
88                      VOID (*media_driver)(FX_MEDIA *), VOID *driver_info_ptr,
89                      VOID *memory_ptr, ULONG memory_size, UINT media_control_block_size);
90 UINT _fxe_media_read(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
91 UINT _fxe_media_space_available(FX_MEDIA *media_ptr, ULONG *available_bytes_ptr);
92 UINT _fxe_media_volume_get(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_source);
93 UINT _fxe_media_volume_get_extended(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_name_buffer_length, UINT volume_source);
94 UINT _fxe_media_volume_set(FX_MEDIA *media_ptr, CHAR *volume_name);
95 UINT _fxe_media_write(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
96 UINT _fxe_media_open_notify_set(FX_MEDIA *media_ptr, VOID (*media_open_notify)(FX_MEDIA *));
97 UINT _fxe_media_close_notify_set(FX_MEDIA *media_ptr, VOID (*media_close_notify)(FX_MEDIA *));
98 UINT _fxe_media_extended_space_available(FX_MEDIA *media_ptr, ULONG64 *available_bytes_ptr);
99 
100 
101 /* Define the internal Media component function prototypes.  */
102 
103 ULONG _fx_media_check_FAT_chain_check(FX_MEDIA *media_ptr, ULONG starting_cluster, ULONG *last_valid_cluster, ULONG *total_valid_clusters, UCHAR *logical_fat);
104 ULONG _fx_media_check_lost_cluster_check(FX_MEDIA *media_ptr, UCHAR *logical_fat, ULONG total_clusters, ULONG error_correction_option);
105 UINT  _fx_media_boot_info_extract(FX_MEDIA *media_ptr);
106 
107 #endif
108 
109