1 #ifndef _IPXE_BLOCKDEV_H
2 #define _IPXE_BLOCKDEV_H
3 
4 /**
5  * @file
6  *
7  * Block devices
8  *
9  */
10 
11 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12 
13 #include <stdint.h>
14 #include <ipxe/uaccess.h>
15 #include <ipxe/interface.h>
16 
17 /** Block device capacity */
18 struct block_device_capacity {
19 	/** Total number of blocks */
20 	uint64_t blocks;
21 	/** Block size */
22 	size_t blksize;
23 	/** Maximum number of blocks per single transfer */
24 	unsigned int max_count;
25 };
26 
27 extern int block_read ( struct interface *control, struct interface *data,
28 			uint64_t lba, unsigned int count,
29 			userptr_t buffer, size_t len );
30 #define block_read_TYPE( object_type )					\
31 	typeof ( int ( object_type, struct interface *data,		\
32 		       uint64_t lba, unsigned int count,		\
33 		       userptr_t buffer, size_t len ) )
34 
35 extern int block_write ( struct interface *control, struct interface *data,
36 			 uint64_t lba, unsigned int count,
37 			 userptr_t buffer, size_t len );
38 #define block_write_TYPE( object_type )					\
39 	typeof ( int ( object_type, struct interface *data,		\
40 		       uint64_t lba, unsigned int count,		\
41 		       userptr_t buffer, size_t len ) )
42 
43 extern int block_read_capacity ( struct interface *control,
44 				 struct interface *data );
45 #define block_read_capacity_TYPE( object_type )				\
46 	typeof ( int ( object_type, struct interface *data ) )
47 
48 extern void block_capacity ( struct interface *intf,
49 			     struct block_device_capacity *capacity );
50 #define block_capacity_TYPE( object_type )				\
51 	typeof ( void ( object_type,					\
52 			struct block_device_capacity *capacity ) )
53 
54 
55 #endif /* _IPXE_BLOCKDEV_H */
56