A little more USB host logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3178 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
54141b1b7c
commit
b2c56a0d80
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/mmcsd/mmcsd_sdio.c
|
||||
*
|
||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -37,5 +37,5 @@ USBHOST_ASRCS =
|
||||
USBHOST_CSRCS =
|
||||
|
||||
ifeq ($(CONFIG_USBHOST),y)
|
||||
USBHOST_CSRCS += usbhost_registerclass.c usbhost_findclass.c
|
||||
USBHOST_CSRCS += usbhost_registry.c usbhost_registerclass.c usbhost_findclass.c
|
||||
endif
|
||||
|
@ -38,8 +38,21 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/usb/usb.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "usbhost_registry.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
@ -53,6 +66,58 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_idmatch
|
||||
*
|
||||
* Description:
|
||||
* Check if the class ID matches what the host controller found.
|
||||
*
|
||||
* Input Parameters:
|
||||
* classid - ID info for the class under consideration.
|
||||
* devid - ID info reported by the device.
|
||||
*
|
||||
* Returned Values:
|
||||
* TRUE - the class will support this device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static bool usbhost_ismatch(const struct usbhost_id_s *classid,
|
||||
const struct usbhost_id_s *devid)
|
||||
{
|
||||
/* The base class ID, subclass and protocol have to match up in any event */
|
||||
|
||||
if (devid->base == classid->base &&
|
||||
devid->subclass == classid->subclass &&
|
||||
devid->proto == clsssid->proto)
|
||||
{
|
||||
/* If this is a vendor-specific class ID, then the VID and PID have to
|
||||
* match as well.
|
||||
*/
|
||||
|
||||
if (devid->base == USB_CLASS_VENDOR_SPEC)
|
||||
{
|
||||
/* Vendor specific... do the VID and PID also match? */
|
||||
|
||||
if (devid->vid == classid->vid && devid->pid == classid->pid)
|
||||
{
|
||||
/* Yes.. then we have a match */
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not vendor specific? Then we have a match */
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* No match.. not supported */
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -80,7 +145,43 @@
|
||||
|
||||
const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id)
|
||||
{
|
||||
#warning "Not Implemented"
|
||||
return NULL;
|
||||
struct usbhost_registry_s *class;
|
||||
irqstate_t flags;
|
||||
int ndx;
|
||||
|
||||
/* g_classregistry is a singly-linkedlist of class ID information added by
|
||||
* calls to usbhost_registerclass(). Since this list is accessed from USB
|
||||
* host controller interrupt handling logic, accesses to this list must be
|
||||
* protected by disabling interrupts.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
|
||||
/* Examine each register class in the linked list */
|
||||
|
||||
for (class = g_classregistry; class; class = class->flink)
|
||||
{
|
||||
/* If the registered class supports more than one ID, subclass, or
|
||||
* protocol, then try each.
|
||||
*/
|
||||
|
||||
for (ndx = 0; ndx < class->nids; ndx++)
|
||||
{
|
||||
/* Did we find a matching ID? */
|
||||
|
||||
if (usbhost_idmatch(&class->id[ndx], id))
|
||||
{
|
||||
/* Yes.. restore interrupts and return the class info */
|
||||
|
||||
irqrestore(flags);
|
||||
return class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Not found... restore interrupts and return NULL */
|
||||
|
||||
irqrestore(flags);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,17 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "usbhost_registry.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
@ -81,7 +92,22 @@
|
||||
|
||||
int usbhost_registerclass(struct usbhost_registry_s *class)
|
||||
{
|
||||
#warning "Not Implemented"
|
||||
return -ENOSYS;
|
||||
irqstate_t flags;
|
||||
|
||||
/* g_classregistry is a singly-linkedlist of class ID information added by
|
||||
* calls to usbhost_registerclass(). Since this list is accessed from USB
|
||||
* host controller interrupt handling logic, accesses to this list must be
|
||||
* protected by disabling interrupts.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
|
||||
/* Add the new class ID info to the head of the list */
|
||||
|
||||
class->flink = g_classregistry;
|
||||
g_classregistry = class;
|
||||
|
||||
irqrestore(flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
80
drivers/usbhost/usbhost_registry.c
Normal file
80
drivers/usbhost/usbhost_registry.c
Normal file
@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
* drivers/usbhost/usbhost_registry.c
|
||||
*
|
||||
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
|
||||
#include "usbhost_registry.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* g_classregistry is a singly-linkedlist of class ID information added by
|
||||
* calls to usbhost_registerclass(). Since this list is accessed from USB
|
||||
* host controller interrupt handling logic, accesses to this list must be
|
||||
* protected by disabling interrupts.
|
||||
*/
|
||||
|
||||
struct usbhost_registry_s *g_classregistry;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
87
drivers/usbhost/usbhost_registry.h
Normal file
87
drivers/usbhost/usbhost_registry.h
Normal file
@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
* drivers/usbhost/usbdev_registry.h
|
||||
*
|
||||
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __DRIVERS_USBHOST_USBHOST_REGISTRY_H
|
||||
#define __DRIVERS_USBHOST_USBHOST_REGISTRY_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
# define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* g_classregistry is a singly-linkedlist of class ID information added by
|
||||
* calls to usbhost_registerclass(). Since this list is accessed from USB
|
||||
* host controller interrupt handling logic, accesses to this list must be
|
||||
* protected by disabling interrupts.
|
||||
*/
|
||||
|
||||
EXTERN struct usbhost_registry_s *g_classregistry;
|
||||
|
||||
/************************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #define __DRIVERS_USBHOST_USBHOST_REGISTRY_H */
|
@ -39,39 +39,105 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/fs.h>
|
||||
#include <nuttx/usb/usb.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structur contains the internal, private state of the USB host mass
|
||||
* storage class.
|
||||
*/
|
||||
|
||||
struct usbhost_state_s
|
||||
{
|
||||
/* This is the externally visible portion of the state */
|
||||
|
||||
struct usbhost_class_s class;
|
||||
|
||||
/* The remainder of the fields are provide o the mass storage class */
|
||||
|
||||
int crefs; /* Reference count on the driver instance */
|
||||
uint16_t blocksize; /* Block size of USB mass storage device */
|
||||
uint32_t nblocks; /* Number of blocks on the USB mass storage device */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static struct usbhost_class_s *usbhost_create(struct usbhost_driver_s *drvr);
|
||||
/* struct usbhost_registry_s methods */
|
||||
|
||||
static struct usbhost_class_s *usbhost_create(struct usbhost_driver_s *drvr);
|
||||
|
||||
/* struct block_operations methods */
|
||||
|
||||
static int usbhost_open(FAR struct inode *inode);
|
||||
static int usbhost_close(FAR struct inode *inode);
|
||||
static ssize_t usbhost_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
||||
size_t startsector, unsigned int nsectors);
|
||||
#ifdef CONFIG_FS_WRITABLE
|
||||
static ssize_t usbhost_write(FAR struct inode *inode,
|
||||
FAR const unsigned char *buffer, size_t startsector,
|
||||
unsigned int nsectors);
|
||||
#endif
|
||||
static int usbhost_geometry(FAR struct inode *inode,
|
||||
FAR struct geometry *geometry);
|
||||
static int usbhost_ioctl(FAR struct inode *inode, int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
struct usbhost_registry_s g_storage =
|
||||
static const const struct usbhost_id_s g_id =
|
||||
{
|
||||
NULL, /* flink */
|
||||
usbhost_create, /* create */
|
||||
1, /* nids */
|
||||
{
|
||||
{
|
||||
USB_CLASS_MASS_STORAGE, /* id[0].base */
|
||||
SUBSTRG_SUBCLASS_SCSI, /* id[0].subclass */
|
||||
USBSTRG_PROTO_BULKONLY, /* id[0].proto */
|
||||
0, /* id[0].vid */
|
||||
0 /* id[0].pid */
|
||||
}
|
||||
}
|
||||
USB_CLASS_MASS_STORAGE, /* base */
|
||||
SUBSTRG_SUBCLASS_SCSI, /* subclass */
|
||||
USBSTRG_PROTO_BULKONLY, /* proto */
|
||||
0, /* vid */
|
||||
0 /* pid */
|
||||
};
|
||||
|
||||
static struct usbhost_registry_s g_storage =
|
||||
{
|
||||
NULL, /* flink */
|
||||
usbhost_create, /* create */
|
||||
1, /* nids */
|
||||
&g_id /* id[] */
|
||||
};
|
||||
|
||||
static const struct block_operations g_bops =
|
||||
{
|
||||
usbhost_open, /* open */
|
||||
usbhost_close, /* close */
|
||||
usbhost_read, /* read */
|
||||
#ifdef CONFIG_FS_WRITABLE
|
||||
usbhost_write, /* write */
|
||||
#else
|
||||
NULL, /* write */
|
||||
#endif
|
||||
usbhost_geometry, /* geometry */
|
||||
usbhost_ioctl /* ioctl */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* struct usbhost_registry_s methods
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_create
|
||||
*
|
||||
@ -106,6 +172,193 @@ static struct usbhost_class_s *usbhost_create(struct usbhost_driver_s *drvr,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* struct block_operations methods
|
||||
****************************************************************************/
|
||||
/****************************************************************************
|
||||
* Name: usbhost_open
|
||||
*
|
||||
* Description: Open the block device
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int usbhost_open(FAR struct inode *inode)
|
||||
{
|
||||
FAR struct usbhost_state_s *priv;
|
||||
|
||||
uvdbg("Entry\n");
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
priv = (FAR struct usbhost_state_s *)inode->i_private;
|
||||
|
||||
/* Just increment the reference count on the driver */
|
||||
|
||||
DEBUGASSERT(priv->crefs < MAX_CREFS);
|
||||
usbhost_takesem(priv);
|
||||
priv->crefs++;
|
||||
usbhost_givesem(priv);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_close
|
||||
*
|
||||
* Description: close the block device
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int usbhost_close(FAR struct inode *inode)
|
||||
{
|
||||
FAR struct usbhost_state_s *priv;
|
||||
|
||||
uvdbg("Entry\n");
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
priv = (FAR struct usbhost_state_s *)inode->i_private;
|
||||
|
||||
/* Decrement the reference count on the block driver */
|
||||
|
||||
DEBUGASSERT(priv->crefs > 0);
|
||||
usbhost_takesem(priv);
|
||||
priv->crefs--;
|
||||
usbhost_givesem(priv);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_read
|
||||
*
|
||||
* Description:
|
||||
* Read the specified numer of sectors from the read-ahead buffer or from
|
||||
* the physical device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t usbhost_read(FAR struct inode *inode, unsigned char *buffer,
|
||||
size_t startsector, unsigned int nsectors)
|
||||
{
|
||||
FAR struct usbhost_state_s *priv;
|
||||
ssize_t ret = 0;
|
||||
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
priv = (FAR struct usbhost_state_s *)inode->i_private;
|
||||
uvdbg("startsector: %d nsectors: %d sectorsize: %d\n",
|
||||
startsector, nsectors, priv->blocksize);
|
||||
|
||||
if (nsectors > 0)
|
||||
{
|
||||
usbhost_takesem(priv);
|
||||
#warning "Missing logic"
|
||||
usbhost_givesem(priv);
|
||||
}
|
||||
|
||||
/* On success, return the number of blocks read */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_write
|
||||
*
|
||||
* Description:
|
||||
* Write the specified number of sectors to the write buffer or to the
|
||||
* physical device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_FS_WRITABLE
|
||||
static ssize_t usbhost_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||
size_t startsector, unsigned int nsectors)
|
||||
{
|
||||
FAR struct usbhost_state_s *priv;
|
||||
int ret;
|
||||
|
||||
uvdbg("sector: %d nsectors: %d sectorsize: %d\n");
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
priv = (FAR struct usbhost_state_s *)inode->i_private;
|
||||
|
||||
usbhost_takesem(priv);
|
||||
#warning "Missing logic"
|
||||
usbhost_givesem(priv);
|
||||
|
||||
/* On success, return the number of blocks written */
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_geometry
|
||||
*
|
||||
* Description: Return device geometry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int usbhost_geometry(FAR struct inode *inode, struct geometry *geometry)
|
||||
{
|
||||
FAR struct usbhost_state_s *priv;
|
||||
int ret = -EINVAL;
|
||||
|
||||
uvdbg("Entry\n");
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
|
||||
if (geometry)
|
||||
{
|
||||
/* Return the geometry of the USB mass storage device */
|
||||
|
||||
priv = (FAR struct usbhost_state_s *)inode->i_private;
|
||||
usbhost_takesem(priv);
|
||||
|
||||
geometry->geo_available = true;
|
||||
geometry->geo_mediachanged = false;
|
||||
#ifdef CONFIG_FS_WRITABLE
|
||||
geometry->geo_writeenabled = true;
|
||||
#else
|
||||
geometry->geo_writeenabled = false;
|
||||
#endif
|
||||
geometry->geo_nsectors = priv->nblocks;
|
||||
geometry->geo_sectorsize = priv->blocksize;
|
||||
usbhost_givesem(priv);
|
||||
|
||||
uvdbg("nsectors: %ld sectorsize: %d\n",
|
||||
(long)geometry->geo_nsectors, geometry->geo_sectorsize);
|
||||
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_ioctl
|
||||
*
|
||||
* Description: Return device geometry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int usbhost_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct usbhost_state_s *priv;
|
||||
int ret;
|
||||
|
||||
uvdbg("Entry\n");
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
priv = (FAR struct usbhost_state_s *)inode->i_private;
|
||||
|
||||
/* Process the IOCTL by command */
|
||||
|
||||
usbhost_takesem(priv);
|
||||
switch (cmd)
|
||||
{
|
||||
/* Add support for ioctl commands here */
|
||||
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
usbhost_givesem(priv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -134,7 +134,40 @@ struct usbhost_registry_s
|
||||
*/
|
||||
|
||||
uint8_t nids; /* Number of IDs in the id[] array */
|
||||
struct usbhost_id_s id[1]; /* Actual dimension is nids */
|
||||
const struct usbhost_id_s *id; /* An array of ID info. Actual dimension is nids */
|
||||
};
|
||||
|
||||
/* struct usbhost_class_s provides access from the USB host driver to the USB host
|
||||
* class implementation.
|
||||
*/
|
||||
|
||||
struct usbhost_class_s
|
||||
{
|
||||
/* Provides the configuration descripor to the class. The configuration
|
||||
* descriptor contains critical information needed by the class in order to
|
||||
* initialize properly (such as endpoint selections).
|
||||
*/
|
||||
|
||||
int (*configdesc)(struct usbhost_class_s *class, const uint8_t *confidesc, int desclen);
|
||||
};
|
||||
|
||||
/* struct usbhost_driver_s provides access to the USB host driver from the USB host
|
||||
* class implementation.
|
||||
*/
|
||||
|
||||
struct usbhost_driver_s
|
||||
{
|
||||
/* Receive a process a transfer descriptor */
|
||||
|
||||
int (*transfer)();
|
||||
|
||||
/* Enumerate the connected device */
|
||||
|
||||
int (*enumerate)();
|
||||
|
||||
/* Receive control information */
|
||||
|
||||
int (*rcvctrl)();
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user