this is probably not going to work...
[svpe-wii.git] / usbstorage.h~
blob9cc895d280ebe6c08e731e730010cd47ecefda78
1 #ifndef __USBSTORAGE_H
2 #define __USBSTORAGE_H  1
4 #include <gctypes.h>
6 #pragma pack(1)
7 typedef struct _usbendpointdesc
9         u8 bLength;
10         u8 bDescriptorType;
11         u8 bEndpointAddress;
12         u8 bmAttributes;
13         u16 wMaxPacketSize;
14         u8 bInterval;
15 } usb_endpointdesc;
17 typedef struct _usbinterfacedesc
19         u8 bLength;
20         u8 bDescriptorType;
21         u8 bInterfaceNumber;
22         u8 bAlternateSetting;
23         u8 bNumEndpoints;
24         u8 bInterfaceClass;
25         u8 bInterfaceSubClass;
26         u8 bInterfaceProtocol;
27         u8 iInterface;
28         struct _usbendpointdesc *endpoints;
29 } usb_interfacedesc;
31 typedef struct _usbconfdesc
33         u8 bLength;
34         u8 bDescriptorType;
35         u16 wTotalLength;
36         u8 bNumInterfaces;
37         u8 bConfigurationValue;
38         u8 iConfiguration;
39         u8 bmAttributes;
40         u8 bMaxPower;
41         struct _usbinterfacedesc *interfaces;
42 } usb_configurationdesc;
44 typedef struct __usbdevdesc
46         u8  bLength;
47         u8  bDescriptorType;
48         u16 bcdUSB;
49         u8  bDeviceClass;
50         u8  bDeviceSubClass;
51         u8  bDeviceProtocol;
52         u8  bMaxPacketSize0;
53         u16 idVendor;
54         u16 idProduct;
55         u16 bcdDevice;
56         u8  iManufacturer;
57         u8  iProduct;
58         u8  iSerialNumber;
59         u8  bNumConfigurations;
60         struct _usbconfdesc *configurations;
61 } _usb_devdesc;
62 #pragma pack()
64 typedef struct
66         u8 configuration;
67         u32 interface;
68         u32 altInterface;
70         u8 ep_in;
71         u8 ep_out;
73         u32 ep_in_size;
74         u32 ep_out_size;
76         u32 sector_size;
77         u32 n_sectors;
79         s32 usb_fd;
81         mutex_t lock;
83         u32 tag;
84 } usbstorage_handle;
86 s32 USB_GetDescriptors(s32 fd, _usb_devdesc *udd);
88 s32 USBStorage_Initialize();
89 s32 USBStorage_Deinitialize();
91 usbstorage_handle *USBStorage_Open(const char *bus, u16 vid, u16 pid);
92 s32 USBStorage_Close(usbstorage_handle *dev);
94 s32 USBStorage_ReadCapacity(usbstorage_handle *dev, u32 *sector_size, u32 *n_sectors);
96 s32 USBStorage_Read(usbstorage_handle *dev, u32 sector, u8 *buffer, u16 n_sectors);
97 s32 USBStorage_Write(usbstorage_handle *dev, u32 sector, const u8 *buffer, u16 n_sectors);
99 #endif