From d743c154ccca54cfec6236f40f2783c171d63f05 Mon Sep 17 00:00:00 2001 From: Sven Peter Date: Fri, 2 May 2008 13:43:36 +0200 Subject: [PATCH] looks like it actually is working and i forgot to add the bswap16 function (probably because i was too tired) --- usbstorage.c | 5 +++ usbstorage.h~ | 99 ----------------------------------------------------------- 2 files changed, 5 insertions(+), 99 deletions(-) delete mode 100644 usbstorage.h~ diff --git a/usbstorage.c b/usbstorage.c index 5454577..8998fdd 100644 --- a/usbstorage.c +++ b/usbstorage.c @@ -64,6 +64,11 @@ static inline s32 __usb_getdesc(s32 fd, u8 *buffer, u8 type, u8 index, u8 size) return USB_WriteCtrlMsg(fd, USB_ENDPOINT_IN, USB_REQ_GETDESCRIPTOR, (type << 8) | index, 0, size, buffer); } +static inline u16 bswap16(u16 s) +{ + return (s >> 8) | ((s & 0xFF) << 8); +} + s32 USB_GetDescriptors(s32 fd, _usb_devdesc *udd) { u8 *buffer = NULL; diff --git a/usbstorage.h~ b/usbstorage.h~ deleted file mode 100644 index 9cc895d..0000000 --- a/usbstorage.h~ +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef __USBSTORAGE_H -#define __USBSTORAGE_H 1 - -#include - -#pragma pack(1) -typedef struct _usbendpointdesc -{ - u8 bLength; - u8 bDescriptorType; - u8 bEndpointAddress; - u8 bmAttributes; - u16 wMaxPacketSize; - u8 bInterval; -} usb_endpointdesc; - -typedef struct _usbinterfacedesc -{ - u8 bLength; - u8 bDescriptorType; - u8 bInterfaceNumber; - u8 bAlternateSetting; - u8 bNumEndpoints; - u8 bInterfaceClass; - u8 bInterfaceSubClass; - u8 bInterfaceProtocol; - u8 iInterface; - struct _usbendpointdesc *endpoints; -} usb_interfacedesc; - -typedef struct _usbconfdesc -{ - u8 bLength; - u8 bDescriptorType; - u16 wTotalLength; - u8 bNumInterfaces; - u8 bConfigurationValue; - u8 iConfiguration; - u8 bmAttributes; - u8 bMaxPower; - struct _usbinterfacedesc *interfaces; -} usb_configurationdesc; - -typedef struct __usbdevdesc -{ - u8 bLength; - u8 bDescriptorType; - u16 bcdUSB; - u8 bDeviceClass; - u8 bDeviceSubClass; - u8 bDeviceProtocol; - u8 bMaxPacketSize0; - u16 idVendor; - u16 idProduct; - u16 bcdDevice; - u8 iManufacturer; - u8 iProduct; - u8 iSerialNumber; - u8 bNumConfigurations; - struct _usbconfdesc *configurations; -} _usb_devdesc; -#pragma pack() - -typedef struct -{ - u8 configuration; - u32 interface; - u32 altInterface; - - u8 ep_in; - u8 ep_out; - - u32 ep_in_size; - u32 ep_out_size; - - u32 sector_size; - u32 n_sectors; - - s32 usb_fd; - - mutex_t lock; - - u32 tag; -} usbstorage_handle; - -s32 USB_GetDescriptors(s32 fd, _usb_devdesc *udd); - -s32 USBStorage_Initialize(); -s32 USBStorage_Deinitialize(); - -usbstorage_handle *USBStorage_Open(const char *bus, u16 vid, u16 pid); -s32 USBStorage_Close(usbstorage_handle *dev); - -s32 USBStorage_ReadCapacity(usbstorage_handle *dev, u32 *sector_size, u32 *n_sectors); - -s32 USBStorage_Read(usbstorage_handle *dev, u32 sector, u8 *buffer, u16 n_sectors); -s32 USBStorage_Write(usbstorage_handle *dev, u32 sector, const u8 *buffer, u16 n_sectors); - -#endif -- 2.11.4.GIT