1- /*UNCRUSTIFY-OFF*/
2- /**
3- * @file block_driver.h
4- * @author Manny Peterson <manny@heliosproj.org>
5- * @brief Block device driver header
6- * @details
7- * Defines structures, commands, and function prototypes for block device drivers supporting SD cards, MMC, and eMMC storage with sector-based I/O.
8- *
9- * @copyright
10- * HeliOS Embedded Operating System Copyright (C) 2020-2026 Manny Peterson <manny@heliosproj.org>
11- *
12- * SPDX-License-Identifier: GPL-2.0-or-later
13- *
14- */
15- /*UNCRUSTIFY-ON*/
16-
17-
181#ifndef BLOCK_DRIVER_H_
19-
20-
212 #define BLOCK_DRIVER_H_
22-
23-
243 #include "config.h"
25-
26-
274 #include "defines.h"
28-
29-
305 #include "types.h"
31-
32-
336 #if defined(CONFIG_ENABLE_IO_SUBSYSTEM )
34-
35-
367 #include "console.h"
37-
38-
398 #include "device.h"
40-
41-
429 #include "fat.h"
43-
44-
4510 #include "fs.h"
46-
47-
48- #endif /* if defined(CONFIG_ENABLE_IO_SUBSYSTEM) */
49-
50-
11+ #endif
5112 #include "mem.h"
52-
53-
5413 #include "port.h"
55-
56-
5714 #include "posix.h"
58-
59-
6015 #include "queue.h"
61-
62-
6316 #include "streams.h"
64-
65-
6617 #include "sys.h"
67-
68-
6918 #include "task.h"
70-
71-
7219 #include "timer.h"
73-
74-
7520 #include "block_io_interface.h"
76-
77-
7821 #define DEVICE_NAME BLOCKDEV
79-
80-
8122 #define DEVICE_UID 0x1000u
82-
83-
8423 #define DEVICE_MODE DeviceModeReadWrite
85-
86-
8724 #define DEVICE_STATE DeviceStateRunning
88-
89-
9025 #define BLOCK_CMD_CONFIG 0x01u
91-
92-
9326 #define BLOCK_CMD_SET_ADDRESS 0x02u
94-
95-
9627 #define BLOCK_CMD_GET_INFO 0x03u
97-
98-
9928 #define BLOCK_PROTOCOL_SD_CARD 0x01u
100-
101-
10229 #define BLOCK_PROTOCOL_MMC 0x02u
103-
104-
10530 #define BLOCK_PROTOCOL_EMMC 0x03u
106-
107-
10831 #define BLOCK_PROTOCOL_RAW 0xFFu
109-
110-
11132 #define BLOCK_CMD_READ_SINGLE 0x01u
112-
113-
11433 #define BLOCK_CMD_READ_MULTIPLE 0x02u
115-
116-
11734 #define BLOCK_CMD_WRITE_SINGLE 0x03u
118-
119-
12035 #define BLOCK_CMD_WRITE_MULTIPLE 0x04u
121-
122-
12336 #define BLOCK_DEFAULT_SECTOR_SIZE 512u
124-
125-
126- /**
127- * @brief Block device configuration structure
128- * @details Configuration command structure for initializing block device parameters including protocol and geometry.
129- */
13037 typedef struct BlockDeviceConfig_s {
131-
132-
133- Byte_t command ; /**< Command type identifier (BLOCK_CMD_CONFIG) */
134- HalfWord_t ioDriverUID ; /**< UID of underlying I/O driver */
135- Byte_t protocol ; /**< Storage protocol (SD card, MMC, eMMC, or raw) */
136- HalfWord_t blockSize ; /**< Block size in bytes */
137- Word_t totalBlocks ; /**< Total number of blocks on device */
38+ Byte_t command ;
39+ HalfWord_t ioDriverUID ;
40+ Byte_t protocol ;
41+ HalfWord_t blockSize ;
42+ Word_t totalBlocks ;
13843 } BlockDeviceConfig_t ;
139-
140-
141- /**
142- * @brief Block device information structure
143- * @details Returned information about block device capabilities, geometry, and current state.
144- */
14544 typedef struct BlockDeviceInfo_s {
146-
147-
148- Byte_t command ; /**< Command type identifier (BLOCK_CMD_GET_INFO) */
149- HalfWord_t blockSize ; /**< Block size in bytes */
150- Word_t totalBlocks ; /**< Total number of blocks on device */
151- Word_t totalBytes ; /**< Total device capacity in bytes */
152- Byte_t protocol ; /**< Storage protocol in use */
153- Base_t isWriteProtected ; /**< Flag indicating if device is write-protected
154- */
155- Base_t isInitialized ; /**< Flag indicating if device is initialized */
45+ Byte_t command ;
46+ HalfWord_t blockSize ;
47+ Word_t totalBlocks ;
48+ Word_t totalBytes ;
49+ Byte_t protocol ;
50+ Base_t isWriteProtected ;
51+ Base_t isInitialized ;
15652 } BlockDeviceInfo_t ;
157-
158-
15953 #ifdef __cplusplus
160-
161-
16254 extern "C" {
163-
164-
165- #endif /* ifdef __cplusplus */
166-
167-
55+ #endif
16856 Return_t TO_FUNCTION (DEVICE_NAME , _self_register )(void );
169-
170-
17157 Return_t TO_FUNCTION (DEVICE_NAME , _init )(Device_t * device_ );
172-
173-
17458 Return_t TO_FUNCTION (DEVICE_NAME , _config )(Device_t * device_ , Size_t * size_ , Addr_t * config_ );
175-
176-
17759 Return_t TO_FUNCTION (DEVICE_NAME , _read )(Device_t * device_ , Size_t * size_ , Addr_t * * data_ );
178-
179-
18060 Return_t TO_FUNCTION (DEVICE_NAME , _write )(Device_t * device_ , Size_t * size_ , Addr_t * data_ );
181-
182-
18361 Return_t TO_FUNCTION (DEVICE_NAME , _simple_read )(Device_t * device_ , Byte_t * data_ );
184-
185-
18662 Return_t TO_FUNCTION (DEVICE_NAME , _simple_write )(Device_t * device_ , Byte_t data_ );
187-
188-
18963 #if defined(POSIX_ARCH_OTHER )
19064 void __BlockDeviceStateClear__ (void );
191-
192-
193- #endif /* if defined(POSIX_ARCH_OTHER) */
194-
195-
65+ #endif
19666 #ifdef __cplusplus
197-
198-
19967 }
200-
201-
202- #endif /* ifdef __cplusplus */
203-
204-
205- #endif /* ifndef BLOCK_DRIVER_H_ */
68+ #endif
69+ #endif
0 commit comments