5 Copyright (C) 2006 by Michal Schulz
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.
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>
35 #include <dos/dosextens.h>
37 #include <proto/exec.h>
39 #include <aros/libcall.h>
40 #include <aros/asmcall.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
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
;
68 uint32_t dCBWDataTransferLength
;
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
;
82 uint32_t dCSWDataResidue
;
86 #define CSW_SIGNATURE 0x53425355
87 #define CSW_STATUS_OK 0x00
88 #define CSW_STATUS_FAIL 0x01
89 #define CSW_STATUS_PHASE 0x02
94 uint32_t msu_blockSize
;
95 uint32_t msu_blockCount
;
96 uint32_t msu_changeNum
;
97 uint8_t msu_blockShift
;
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];
108 struct mss_staticdata
110 struct SignalSemaphore Lock
;
114 struct MinList unitList
;
115 struct MinList unitCache
;
120 OOP_AttrBase HiddPCIDeviceAB
;
121 OOP_AttrBase HiddUSBDeviceAB
;
122 OOP_AttrBase HiddUSBHubAB
;
123 OOP_AttrBase HiddUSBDrvAB
;
124 OOP_AttrBase HiddUSBAB
;
125 OOP_AttrBase HiddUSBStorageAB
;
136 char *manufacturerName
;
142 typedef struct MSSData
{
143 struct SignalSemaphore lock
;
146 struct mss_staticdata
*sd
;
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
;
158 struct Task
*handler
[16];
159 mss_unit_t
*unit
[16];
161 uint32_t blocksize
[16];
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
)
187 Disable(); id
= sd
->tid
++; Enable();
191 /* exec device interface */
194 struct Device mss_device
;
195 struct mss_staticdata
*mss_static
;
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_ */