xref: /haiku/src/add-ons/kernel/drivers/disk/mmc/mmc_disk.h (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
1 /*
2  * Copyright 2018-2020 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		B Krishnan Iyer, krishnaniyer97@gmail.com
7  *		Adrien Destugues, pulkomandy@pulkomandy.tk
8  */
9 #ifndef _MMC_DISK_H
10 #define _MMC_DISK_H
11 
12 
13 #include <device_manager.h>
14 #include <KernelExport.h>
15 
16 #include <stdint.h>
17 
18 #include <mmc.h>
19 
20 #include "IOSchedulerSimple.h"
21 
22 
23 enum MMCDiskFlags {
24 	kIoCommandOffsetAsSectors = 1,
25 		// IO commands use sector offsets instead of byte offsets
26 };
27 
28 
29 // This is the device info structure, allocated once per device
30 typedef struct {
31 	device_node* node;
32 	device_node* parent;
33 	void* parentCookie;
34 	mmc_device_interface* mmc;
35 	uint16_t rca;
36 	uint32_t flags;
37 
38 	device_geometry geometry;
39 
40 	DMAResource* dmaResource;
41 	IOScheduler* scheduler;
42 
43 	off_t DeviceSize() const {
44 		return (off_t)geometry.bytes_per_sector * geometry.sectors_per_track
45 			* geometry.cylinder_count * geometry.head_count;
46 	}
47 } mmc_disk_driver_info;
48 
49 
50 // This is allocated once per open() call on the device (there can be multiple
51 // open file descriptors for the same device)
52 typedef struct {
53 	mmc_disk_driver_info* info;
54 } mmc_disk_handle;
55 
56 
57 #endif /*_MMC_DISK_H*/
58