Added a test for MUIA_Listview_SelectChange.
[AROS.git] / workbench / devs / USB / classes / MassStorage / storage.h
blob344e7e8145438485441df8a4da465190d0570da4
1 #ifndef STORAGE_H_
2 #define STORAGE_H_
4 /*
5 Copyright (C) 2006 by Michal Schulz
6 $Id$
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Library General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with this program; if not, write to the
20 Free Software Foundation, Inc.,
21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <stdint.h>
26 #include <exec/libraries.h>
27 #include <exec/execbase.h>
28 #include <exec/nodes.h>
29 #include <exec/lists.h>
30 #include <exec/semaphores.h>
31 #include <exec/ports.h>
32 #include <exec/devices.h>
33 #include <exec/interrupts.h>
34 #include <dos/bptr.h>
35 #include <dos/dosextens.h>
37 #include <proto/exec.h>
39 #include <aros/libcall.h>
40 #include <aros/asmcall.h>
42 #include <oop/oop.h>
44 #include <aros/arossupportbase.h>
45 #include <exec/execbase.h>
47 #include LC_LIBDEFS_FILE
49 #undef HiddPCIDeviceAttrBase
50 #undef HiddUSBDeviceAttrBase
51 #undef HiddUSBHubAttrBase
52 #undef HiddUSBDrvAttrBase
53 #undef HiddUSBAttrBase
54 #undef HiddUSBStorageAttrBase
55 #undef HiddAttrBase
57 #define HiddPCIDeviceAttrBase (SD(cl)->HiddPCIDeviceAB)
58 #define HiddUSBDeviceAttrBase (SD(cl)->HiddUSBDeviceAB)
59 #define HiddUSBHubAttrBase (SD(cl)->HiddUSBHubAB)
60 #define HiddUSBDrvAttrBase (SD(cl)->HiddUSBDrvAB)
61 #define HiddAttrBase (SD(cl)->HiddAB)
62 #define HiddUSBAttrBase (SD(cl)->HiddUSBAB)
63 #define HiddUSBStorageAttrBase (SD(cl)->HiddUSBStorageAB)
65 typedef struct __attribute__((packed)) {
66 uint32_t dCBWSignature;
67 uint32_t dCBWTag;
68 uint32_t dCBWDataTransferLength;
69 uint8_t bmCBWFlags;
70 uint8_t bCBWLUN;
71 uint8_t bCBWCBLength;
72 uint8_t CBWCB[16];
73 } cbw_t;
75 #define CBW_SIGNATURE 0x43425355
76 #define CBW_FLAGS_IN 0x80
77 #define CBW_FLAGS_OUT 0x00
79 typedef struct __attribute__((packed)) {
80 uint32_t dCSWSignature;
81 uint32_t dCSWTag;
82 uint32_t dCSWDataResidue;
83 uint8_t bCSWStatus;
84 } csw_t;
86 #define CSW_SIGNATURE 0x53425355
87 #define CSW_STATUS_OK 0x00
88 #define CSW_STATUS_FAIL 0x01
89 #define CSW_STATUS_PHASE 0x02
91 typedef struct {
92 struct Unit msu_unit;
93 uint32_t msu_unitNum;
94 uint32_t msu_blockSize;
95 uint32_t msu_blockCount;
96 uint32_t msu_changeNum;
97 uint8_t msu_blockShift;
98 uint8_t msu_flags;
99 uint8_t msu_lun;
100 OOP_Class *msu_class;
101 OOP_Object *msu_object;
102 struct Interrupt *msu_removeInt;
103 struct List msu_diskChangeList;
104 struct Task *msu_handler;
105 uint8_t msu_inquiry[8];
106 } mss_unit_t;
108 struct mss_staticdata
110 struct SignalSemaphore Lock;
111 void *MemPool;
112 OOP_Class *mssClass;
114 struct MinList unitList;
115 struct MinList unitCache;
117 uint32_t tid;
118 uint32_t unitNum;
120 OOP_AttrBase HiddPCIDeviceAB;
121 OOP_AttrBase HiddUSBDeviceAB;
122 OOP_AttrBase HiddUSBHubAB;
123 OOP_AttrBase HiddUSBDrvAB;
124 OOP_AttrBase HiddUSBAB;
125 OOP_AttrBase HiddUSBStorageAB;
126 OOP_AttrBase HiddAB;
129 typedef struct {
130 struct MinNode node;
131 struct List units;
133 uint16_t productID;
134 uint16_t vendorID;
135 char *productName;
136 char *manufacturerName;
137 char *serialNumber;
139 uint32_t unitNumber;
140 } unit_cache_t;
142 typedef struct MSSData {
143 struct SignalSemaphore lock;
144 unit_cache_t *cache;
146 struct mss_staticdata *sd;
147 OOP_Object *o;
149 usb_config_descriptor_t *cdesc;
150 usb_device_descriptor_t ddesc;
151 usb_interface_descriptor_t *iface;
153 usb_endpoint_descriptor_t *ep_in;
154 usb_endpoint_descriptor_t *ep_out;
156 void *pipe_in;
157 void *pipe_out;
158 struct Task *handler[16];
159 mss_unit_t *unit[16];
161 uint32_t blocksize[16];
162 uint8_t maxLUN;
163 uint32_t unitNum;
164 } StorageData;
169 struct mssbase
171 struct Library LibNode;
172 struct mss_staticdata sd;
175 #define METHOD(base, id, name) \
176 base ## __ ## id ## __ ## name (OOP_Class *cl, OOP_Object *o, struct p ## id ## _ ## name *msg)
178 #define BASE(lib)((struct mssbase*)(lib))
179 #define SD(cl) (&BASE(cl->UserData)->sd)
181 #define IOStdReq(io) ((struct IOStdReq *)io)
184 static inline volatile uint32_t getTID(struct mss_staticdata *sd)
186 uint32_t id;
187 Disable(); id = sd->tid++; Enable();
188 return id;
191 /* exec device interface */
193 typedef struct {
194 struct Device mss_device;
195 struct mss_staticdata *mss_static;
196 } mss_device_t;
199 #define MSF_DiskChanged 1
200 #define MSF_DiskPresent 2
201 #define MSF_DeviceRemoved 4
203 extern void StorageTask(OOP_Class *cl, OOP_Object *o, uint32_t unitnum, struct Task *parent);
204 extern void HandleIO(struct IORequest *io, mss_device_t *device, mss_unit_t *unit);
206 #endif /* STORAGE_H_ */