1 /*
2  * Minix3 USB mass storage driver definitions
3  */
4 
5 #ifndef _USB_STORAGE_H_
6 #define _USB_STORAGE_H_
7 
8 #include <minix/driver.h>		/* struct device */
9 #include <minix/type.h>			/* vir_bytes */
10 /* TODO: no header for ddekit_usb_dev */
11 
12 #include "urb_helper.h"
13 
14 /* Number of handled peripherals (USB devices) */
15 #define MAX_PERIPHS			(1)
16 /* Number of handled disks per driver */
17 #define MAX_DRIVES			(4)
18 /* 4 partitions per disk */
19 #define PART_PER_DISK			(4)
20 /* 4 sub partitions per partition */
21 #define SUBPART_PER_PART		(4)
22 /* 16 sub partitions per disk */
23 #define SUBPART_PER_DISK		(PART_PER_DISK * SUBPART_PER_PART)
24 
25 /*---------------------------*
26  *    declared types         *
27  *---------------------------*/
28 /* Information on opened mass storage drives */
29 typedef struct mass_storage_drive {
30 
31 	struct device disk;			/* disk device */
32 	struct device part[PART_PER_DISK];	/* partition devices */
33 	struct device subpart[SUBPART_PER_DISK];/* sub-partition devices */
34 	unsigned long open_ct;			/* opening counter */
35 	int drive_idx;				/* Index of this drive */
36 }
37 mass_storage_drive;
38 
39 /* Information on attached peripherals (USB devices) */
40 typedef struct mass_storage_periph {
41 
42 	mass_storage_drive drives[MAX_DRIVES];	/* Possible drive info */
43 	struct ddekit_usb_dev * dev;		/* DDEKit device handler */
44 	unsigned int interfaces;		/* Interfaces bitmap */
45 	urb_ep_config ep_in;			/* Bulk IN endpoint */
46 	urb_ep_config ep_out;			/* Bulk OUT endpoint */
47 }
48 mass_storage_periph;
49 
50 /* Structure for the information on current state of driver */
51 typedef struct mass_storage_state {
52 
53 	/* DDEKit device handlers */
54 	mass_storage_periph periph[MAX_PERIPHS];
55 
56 	/* Currently used peripheral */
57 	mass_storage_periph * cur_periph;
58 
59 	/* Currently used drive */
60 	mass_storage_drive * cur_drive;
61 
62 	/* Currently used device (drive/partition/sub-partition) */
63 	struct device * cur_device;
64 
65 	/* Driver instance */
66 	long instance;
67 }
68 mass_storage_state;
69 
70 /* State of current IO vector array for transfer operations */
71 typedef struct iov_state {
72 
73 	vir_bytes base_addr;		/* Address to read/write or grant ID */
74 	vir_bytes remaining_bytes;	/* How many bytes remain in vector */
75 	vir_bytes offset;		/* How many bytes were copied */
76 	unsigned int iov_idx;		/* Index of currently selected vector */
77 }
78 iov_state;
79 
80 #endif /* !_USB_STORAGE_H_ */
81