usb - wake up drive before attempting read/write/mount (tueidj)
[libogc.git] / gc / ogc / usbstorage.h
blob4a50fd1626480172b09e17f5049b7ec9c3eb51eb
1 #ifndef __USBSTORAGE_H__
2 #define __USBSTORAGE_H__
4 #if defined(HW_RVL)
6 #include <gctypes.h>
7 #include <ogc/mutex.h>
8 #include <ogc/disc_io.h>
10 #ifdef __cplusplus
11 extern "C" {
12 #endif /* __cplusplus */
14 #define USBSTORAGE_OK 0
15 #define USBSTORAGE_ENOINTERFACE -10000
16 #define USBSTORAGE_ESENSE -10001
17 #define USBSTORAGE_ESHORTWRITE -10002
18 #define USBSTORAGE_ESHORTREAD -10003
19 #define USBSTORAGE_ESIGNATURE -10004
20 #define USBSTORAGE_ETAG -10005
21 #define USBSTORAGE_ESTATUS -10006
22 #define USBSTORAGE_EDATARESIDUE -10007
23 #define USBSTORAGE_ETIMEDOUT -10008
24 #define USBSTORAGE_EINIT -10009
25 #define USBSTORAGE_PROCESSING -10010
27 typedef struct
29 u8 configuration;
30 u32 interface;
31 u32 altInterface;
33 u8 ep_in;
34 u8 ep_out;
36 u8 max_lun;
37 u32 *sector_size;
39 s32 usb_fd;
41 mutex_t lock;
42 syswd_t alarm;
43 s32 retval;
45 u32 tag;
46 u8 suspended;
48 u8 *buffer;
49 } usbstorage_handle;
51 s32 USBStorage_Initialize();
53 s32 USBStorage_Open(usbstorage_handle *dev, s32 device_id, u16 vid, u16 pid);
54 s32 USBStorage_Close(usbstorage_handle *dev);
55 s32 USBStorage_Reset(usbstorage_handle *dev);
57 s32 USBStorage_GetMaxLUN(usbstorage_handle *dev);
58 s32 USBStorage_MountLUN(usbstorage_handle *dev, u8 lun);
59 s32 USBStorage_Suspend(usbstorage_handle *dev);
61 s32 USBStorage_ReadCapacity(usbstorage_handle *dev, u8 lun, u32 *sector_size, u32 *n_sectors);
62 s32 USBStorage_Read(usbstorage_handle *dev, u8 lun, u32 sector, u16 n_sectors, u8 *buffer);
63 s32 USBStorage_Write(usbstorage_handle *dev, u8 lun, u32 sector, u16 n_sectors, const u8 *buffer);
64 s32 USBStorage_StartStop(usbstorage_handle *dev, u8 lun, u8 lo_ej, u8 start, u8 imm);
66 #define DEVICE_TYPE_WII_USB (('W'<<24)|('U'<<16)|('S'<<8)|'B')
68 extern DISC_INTERFACE __io_usbstorage;
70 #ifdef __cplusplus
72 #endif /* __cplusplus */
74 #endif /* HW_RVL */
76 #endif /* __USBSTORAGE_H__ */