Changing NuttX fixed size type names to C99 standard names -- things will be broken for awhile

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2343 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2009-12-15 14:25:14 +00:00
parent 2f0e15334b
commit 9634f25391
41 changed files with 1168 additions and 1149 deletions
+16 -13
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/bch/bch_internal.h * drivers/bch/bch_internal.h
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software * used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
@@ -41,16 +41,19 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <semaphore.h> #include <semaphore.h>
#include <nuttx/fs.h> #include <nuttx/fs.h>
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#define bchlib_semgive(d) sem_post(&(d)->sem) /* To match bchlib_semtake */ #define bchlib_semgive(d) sem_post(&(d)->sem) /* To match bchlib_semtake */
#define MAX_OPENCNT (255) /* Limit of ubyte */ #define MAX_OPENCNT (255) /* Limit of uint8_t */
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
@@ -58,15 +61,15 @@
struct bchlib_s struct bchlib_s
{ {
struct inode *inode; /* I-node of the block driver */ struct inode *inode; /* I-node of the block driver */
sem_t sem; /* For atomic accesses to this structure */ sem_t sem; /* For atomic accesses to this structure */
size_t nsectors; /* Number of sectors supported by the device */ size_t nsectors; /* Number of sectors supported by the device */
size_t sector; /* The current sector in the buffer */ size_t sector; /* The current sector in the buffer */
uint16 sectsize; /* The size of one sector on the device */ uint16_t sectsize; /* The size of one sector on the device */
ubyte refs; /* Number of references */ uint8_t refs; /* Number of references */
boolean dirty; /* Data has been written to the buffer */ bool dirty; /* Data has been written to the buffer */
boolean readonly; /* TRUE: Only read operations are supported */ bool readonly; /* true: Only read operations are supported */
FAR ubyte *buffer; /* One sector buffer */ FAR uint8_t *buffer; /* One sector buffer */
}; };
/**************************************************************************** /****************************************************************************
+4 -9
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/bch/bchdev_register.c * drivers/bch/bchdev_register.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -33,18 +33,13 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <stdbool.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
#include <debug.h> #include <debug.h>
@@ -52,7 +47,7 @@
#include "bch_internal.h" #include "bch_internal.h"
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
@@ -80,7 +75,7 @@
* *
****************************************************************************/ ****************************************************************************/
int bchdev_register(const char *blkdev, const char *chardev, boolean readonly) int bchdev_register(const char *blkdev, const char *chardev, bool readonly)
{ {
FAR void *handle; FAR void *handle;
int ret; int ret;
+1 -6
View File
@@ -33,17 +33,12 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@@ -60,7 +55,7 @@
#include "bch_internal.h" #include "bch_internal.h"
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
+3 -7
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/bch/bchlib_cache.c * drivers/bch/bchlib_cache.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@@ -44,7 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdbool.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
#include <debug.h> #include <debug.h>
@@ -97,7 +93,7 @@ int bchlib_flushsector(FAR struct bchlib_s *bch)
{ {
fdbg("Write failed: %d\n"); fdbg("Write failed: %d\n");
} }
bch->dirty = FALSE; bch->dirty = false;
} }
return (int)ret; return (int)ret;
} }
+8 -12
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/bch/bchlib_read.c * drivers/bch/bchlib_read.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@@ -44,7 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
@@ -86,12 +82,12 @@
ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t len) ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t len)
{ {
FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle; FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle;
size_t nsectors; size_t nsectors;
size_t sector; size_t sector;
uint16 sectoffset; uint16_t sectoffset;
size_t nbytes; size_t nbytes;
size_t bytesread; size_t bytesread;
int ret; int ret;
/* Get rid of this special case right away */ /* Get rid of this special case right away */
+2 -8
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/bch/bchlib_sem.c * drivers/bch/bchlib_sem.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -33,18 +33,12 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
#include <debug.h> #include <debug.h>
@@ -52,7 +46,7 @@
#include "bch_internal.h" #include "bch_internal.h"
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
+5 -7
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/bch/bchlib_setup.c * drivers/bch/bchlib_setup.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@@ -46,6 +42,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
@@ -84,7 +82,7 @@
* *
****************************************************************************/ ****************************************************************************/
int bchlib_setup(const char *blkdev, boolean readonly, FAR void **handle) int bchlib_setup(const char *blkdev, bool readonly, FAR void **handle)
{ {
FAR struct bchlib_s *bch; FAR struct bchlib_s *bch;
struct geometry geo; struct geometry geo;
@@ -143,7 +141,7 @@ int bchlib_setup(const char *blkdev, boolean readonly, FAR void **handle)
/* Allocate the sector I/O buffer */ /* Allocate the sector I/O buffer */
bch->buffer = (FAR ubyte *)malloc(bch->sectsize); bch->buffer = (FAR uint8_t *)malloc(bch->sectsize);
if (!bch->buffer) if (!bch->buffer)
{ {
fdbg("Failed to allocate sector buffer\n"); fdbg("Failed to allocate sector buffer\n");
+1 -7
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/bch/bchlib_teardown.c * drivers/bch/bchlib_teardown.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -33,18 +33,12 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
+11 -14
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/bch/bchlib_write.c * drivers/bch/bchlib_write.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@@ -44,7 +40,8 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
@@ -86,12 +83,12 @@
ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, size_t len) ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, size_t len)
{ {
FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle; FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle;
size_t nsectors; size_t nsectors;
size_t sector; size_t sector;
uint16 sectoffset; uint16_t sectoffset;
size_t nbytes; size_t nbytes;
size_t byteswritten; size_t byteswritten;
int ret; int ret;
/* Get rid of this special case right away */ /* Get rid of this special case right away */
@@ -131,7 +128,7 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si
} }
memcpy(&bch->buffer[sectoffset], buffer, nbytes); memcpy(&bch->buffer[sectoffset], buffer, nbytes);
bch->dirty = TRUE; bch->dirty = true;
/* Adjust pointers and counts */ /* Adjust pointers and counts */
@@ -195,7 +192,7 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si
/* Copy the head end of the sector from the user buffer */ /* Copy the head end of the sector from the user buffer */
memcpy(bch->buffer, buffer, len); memcpy(bch->buffer, buffer, len);
bch->dirty = TRUE; bch->dirty = true;
/* Adjust counts */ /* Adjust counts */
+13 -11
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/can.c * drivers/can.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,8 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <semaphore.h> #include <semaphore.h>
@@ -58,7 +60,7 @@
#include <arch/irq.h> #include <arch/irq.h>
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#define HALF_SECOND_MSEC 500 #define HALF_SECOND_MSEC 500
@@ -113,7 +115,7 @@ static int can_open(FAR struct file *filep)
{ {
FAR struct inode *inode = filep->f_inode; FAR struct inode *inode = filep->f_inode;
FAR struct can_dev_s *dev = inode->i_private; FAR struct can_dev_s *dev = inode->i_private;
ubyte tmp; uint8_t tmp;
int ret = OK; int ret = OK;
/* If the port is the middle of closing, wait until the close is finished */ /* If the port is the middle of closing, wait until the close is finished */
@@ -132,7 +134,7 @@ static int can_open(FAR struct file *filep)
tmp = dev->cd_ocount + 1; tmp = dev->cd_ocount + 1;
if (tmp == 0) if (tmp == 0)
{ {
/* More than 255 opens; ubyte overflows to zero */ /* More than 255 opens; uint8_t overflows to zero */
ret = -EMFILE; ret = -EMFILE;
} }
@@ -157,7 +159,7 @@ static int can_open(FAR struct file *filep)
/* Finally, Enable the CAN RX interrupt */ /* Finally, Enable the CAN RX interrupt */
dev_rxint(dev, TRUE); dev_rxint(dev, true);
/* Save the new open count on success */ /* Save the new open count on success */
@@ -210,7 +212,7 @@ static int can_close(FAR struct file *filep)
/* Stop accepting input */ /* Stop accepting input */
dev_rxint(dev, FALSE); dev_rxint(dev, false);
/* Now we wait for the transmit FIFO to clear */ /* Now we wait for the transmit FIFO to clear */
@@ -347,7 +349,7 @@ return_with_irqdisabled:
static int can_xmit(FAR struct can_dev_s *dev) static int can_xmit(FAR struct can_dev_s *dev)
{ {
boolean enable = FALSE; bool enable = false;
int ret = OK; int ret = OK;
/* Check if the xmit FIFO is empty */ /* Check if the xmit FIFO is empty */
@@ -360,7 +362,7 @@ static int can_xmit(FAR struct can_dev_s *dev)
/* Make sure the TX done interrupts are enabled */ /* Make sure the TX done interrupts are enabled */
enable = (ret == OK ? TRUE : FALSE); enable = (ret == OK ? true : false);
} }
dev_txint(dev, enable); dev_txint(dev, enable);
return ret; return ret;
@@ -376,7 +378,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const char *buffer, size_t
FAR struct can_dev_s *dev = inode->i_private; FAR struct can_dev_s *dev = inode->i_private;
FAR struct can_fifo_s *fifo = &dev->cd_xmit; FAR struct can_fifo_s *fifo = &dev->cd_xmit;
FAR struct can_msg_s *msg; FAR struct can_msg_s *msg;
boolean empty = FALSE; bool empty = false;
ssize_t nsent = 0; ssize_t nsent = 0;
irqstate_t flags; irqstate_t flags;
int nexttail; int nexttail;
@@ -632,10 +634,10 @@ int can_register(FAR const char *path, FAR struct can_dev_s *dev)
* *
************************************************************************************/ ************************************************************************************/
int can_receive(FAR struct can_dev_s *dev, uint16 hdr, FAR ubyte *data) int can_receive(FAR struct can_dev_s *dev, uint16_t hdr, FAR uint8_t *data)
{ {
FAR struct can_fifo_s *fifo = &dev->cd_recv; FAR struct can_fifo_s *fifo = &dev->cd_recv;
FAR ubyte *dest; FAR uint8_t *dest;
int nexttail; int nexttail;
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
+3 -6
View File
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@@ -44,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#include <poll.h> #include <poll.h>
#include <errno.h> #include <errno.h>
@@ -57,7 +54,7 @@ static ssize_t devnull_read(FAR struct file *, FAR char *, size_t);
static ssize_t devnull_write(FAR struct file *, FAR const char *, size_t); static ssize_t devnull_write(FAR struct file *, FAR const char *, size_t);
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds, static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds,
boolean setup); bool setup);
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -105,7 +102,7 @@ static ssize_t devnull_write(FAR struct file *filp, FAR const char *buffer, size
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds, static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds,
boolean setup) bool setup)
{ {
if (setup) if (setup)
{ {
+4 -7
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/dev_null.c * drivers/dev_null.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@@ -44,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#include <poll.h> #include <poll.h>
#include <errno.h> #include <errno.h>
@@ -57,7 +54,7 @@ static ssize_t devzero_read(FAR struct file *, FAR char *, size_t);
static ssize_t devzero_write(FAR struct file *, FAR const char *, size_t); static ssize_t devzero_write(FAR struct file *, FAR const char *, size_t);
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds, static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds,
boolean setup); bool setup);
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -106,7 +103,7 @@ static ssize_t devzero_write(FAR struct file *filp, FAR const char *buffer, size
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds, static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds,
boolean setup) bool setup)
{ {
if (setup) if (setup)
{ {
+16 -14
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/loop.c * drivers/loop.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,8 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@@ -57,11 +59,11 @@
#include <nuttx/fs.h> #include <nuttx/fs.h>
/**************************************************************************** /****************************************************************************
* Private Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#define loop_semgive(d) sem_post(&(d)->sem) /* To match loop_semtake */ #define loop_semgive(d) sem_post(&(d)->sem) /* To match loop_semtake */
#define MAX_OPENCNT (255) /* Limit of ubyte */ #define MAX_OPENCNT (255) /* Limit of uint8_t */
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
@@ -70,12 +72,12 @@
struct loop_struct_s struct loop_struct_s
{ {
sem_t sem; /* For safe read-modify-write operations */ sem_t sem; /* For safe read-modify-write operations */
uint32 nsectors; /* Number of sectors on device */ uint32_t nsectors; /* Number of sectors on device */
off_t offset; /* Offset (in bytes) to the first sector */ off_t offset; /* Offset (in bytes) to the first sector */
uint16 sectsize; /* The size of one sector */ uint16_t sectsize; /* The size of one sector */
ubyte opencnt; /* Count of open references to the loop device */ uint8_t opencnt; /* Count of open references to the loop device */
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
boolean writeenabled; /* TRUE: can write to device */ bool writeenabled; /* true: can write to device */
#endif #endif
int fd; /* Descriptor of char device/file */ int fd; /* Descriptor of char device/file */
}; };
@@ -313,12 +315,12 @@ static int loop_geometry(FAR struct inode *inode, struct geometry *geometry)
if (geometry) if (geometry)
{ {
dev = (FAR struct loop_struct_s *)inode->i_private; dev = (FAR struct loop_struct_s *)inode->i_private;
geometry->geo_available = TRUE; geometry->geo_available = true;
geometry->geo_mediachanged = FALSE; geometry->geo_mediachanged = false;
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
geometry->geo_writeenabled = dev->writeenabled; geometry->geo_writeenabled = dev->writeenabled;
#else #else
geometry->geo_writeenabled = FALSE; geometry->geo_writeenabled = false;
#endif #endif
geometry->geo_nsectors = dev->nsectors; geometry->geo_nsectors = dev->nsectors;
geometry->geo_sectorsize = dev->sectsize; geometry->geo_sectorsize = dev->sectsize;
@@ -340,8 +342,8 @@ static int loop_geometry(FAR struct inode *inode, struct geometry *geometry)
* *
****************************************************************************/ ****************************************************************************/
int losetup(const char *devname, const char *filename, uint16 sectsize, int losetup(const char *devname, const char *filename, uint16_t sectsize,
off_t offset, boolean readonly) off_t offset, bool readonly)
{ {
FAR struct loop_struct_s *dev; FAR struct loop_struct_s *dev;
struct stat sb; struct stat sb;
@@ -391,7 +393,7 @@ int losetup(const char *devname, const char *filename, uint16 sectsize,
/* Open the file. */ /* Open the file. */
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
dev->writeenabled = FALSE; /* Assume failure */ dev->writeenabled = false; /* Assume failure */
dev->fd = -1; dev->fd = -1;
/* First try to open the device R/W access (unless we are asked /* First try to open the device R/W access (unless we are asked
@@ -405,7 +407,7 @@ int losetup(const char *devname, const char *filename, uint16 sectsize,
if (dev->fd >= 0) if (dev->fd >= 0)
{ {
dev->writeenabled = TRUE; /* Success */ dev->writeenabled = true; /* Success */
} }
else else
#endif #endif
+2 -2
View File
@@ -41,7 +41,7 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <stdint.h>
/**************************************************************************** /****************************************************************************
* Pre-Processor Definitions * Pre-Processor Definitions
@@ -252,7 +252,7 @@
/* CCC 84-95 = Card command classes */ /* CCC 84-95 = Card command classes */
#define MMCSD_CSD_CCC(csd) (((uint16)csd[4] << 4) | ((uint16)csd[5] >> 4)) #define MMCSD_CSD_CCC(csd) (((uint16_t)csd[4] << 4) | ((uint16_t)csd[5] >> 4))
#define SD20_CSD_CCC(csd) MMCSD_CSD_CCC(csd) #define SD20_CSD_CCC(csd) MMCSD_CSD_CCC(csd)
/* READ_BL_LEN 80-83 = Max. read data block length */ /* READ_BL_LEN 80-83 = Max. read data block length */
+6 -6
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/mmcsd/mmcsd_debug.c * drivers/mmcsd/mmcsd_debug.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -39,8 +39,8 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <stdint.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
@@ -90,10 +90,10 @@
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS)
void mmcsd_dmpcsd(FAR const ubyte *csd, ubyte cardtype) void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype)
{ {
boolean mmc = (cardtype == MMCSD_CARDTYPE_MMC); bool mmc = (cardtype == MMCSD_CARDTYPE_MMC);
boolean sd2 = (MMCSD_CSD_CSDSTRUCT(csd) == 1); bool sd2 = (MMCSD_CSD_CSDSTRUCT(csd) == 1);
fvdbg("CSD\n"); fvdbg("CSD\n");
fvdbg(" CSD_STRUCTURE: 1.%d\n", MMCSD_CSD_CSDSTRUCT(csd)); fvdbg(" CSD_STRUCTURE: 1.%d\n", MMCSD_CSD_CSDSTRUCT(csd));
+2 -2
View File
@@ -41,7 +41,7 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <stdint.h>
#include <debug.h> #include <debug.h>
/**************************************************************************** /****************************************************************************
@@ -93,7 +93,7 @@ extern "C" {
#endif #endif
#if defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS)
EXTERN void mmcsd_dmpcsd(FAR const ubyte *csd, ubyte cardtype); EXTERN void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype);
#else #else
# define mmcsd_dmpcsd(csd,cadtype) # define mmcsd_dmpcsd(csd,cadtype)
#endif #endif
+111 -105
View File
File diff suppressed because it is too large Load Diff
+332 -332
View File
File diff suppressed because it is too large Load Diff
+118 -110
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -41,7 +41,6 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
/**************************************************************************** /****************************************************************************
* Pre-Processor Definitions * Pre-Processor Definitions
+16 -14
View File
@@ -41,6 +41,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -71,9 +73,9 @@ struct ftl_struct_s
#ifdef CONFIG_FTL_RWBUFFER #ifdef CONFIG_FTL_RWBUFFER
struct rwbuffer_s rwb; /* Read-ahead/write buffer support */ struct rwbuffer_s rwb; /* Read-ahead/write buffer support */
#endif #endif
uint16 blkper; /* R/W blocks per erase block */ uint16_t blkper; /* R/W blocks per erase block */
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
FAR ubyte *eblock; /* One, in-memory erase block */ FAR uint8_t *eblock; /* One, in-memory erase block */
#endif #endif
}; };
@@ -83,12 +85,12 @@ struct ftl_struct_s
static int ftl_open(FAR struct inode *inode); static int ftl_open(FAR struct inode *inode);
static int ftl_close(FAR struct inode *inode); static int ftl_close(FAR struct inode *inode);
static ssize_t ftl_reload(FAR void *priv, FAR ubyte *buffer, static ssize_t ftl_reload(FAR void *priv, FAR uint8_t *buffer,
off_t startblock, size_t nblocks); off_t startblock, size_t nblocks);
static ssize_t ftl_read(FAR struct inode *inode, unsigned char *buffer, static ssize_t ftl_read(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, unsigned int nsectors); size_t start_sector, unsigned int nsectors);
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
static ssize_t ftl_flush(FAR void *priv, FAR const ubyte *buffer, static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
off_t startblock, size_t nblocks); off_t startblock, size_t nblocks);
static ssize_t ftl_write(FAR struct inode *inode, const unsigned char *buffer, static ssize_t ftl_write(FAR struct inode *inode, const unsigned char *buffer,
size_t start_sector, unsigned int nsectors); size_t start_sector, unsigned int nsectors);
@@ -151,7 +153,7 @@ static int ftl_close(FAR struct inode *inode)
* *
****************************************************************************/ ****************************************************************************/
static ssize_t ftl_reload(FAR void *priv, FAR ubyte *buffer, static ssize_t ftl_reload(FAR void *priv, FAR uint8_t *buffer,
off_t startblock, size_t nblocks) off_t startblock, size_t nblocks)
{ {
struct ftl_struct_s *dev = (struct ftl_struct_s *)priv; struct ftl_struct_s *dev = (struct ftl_struct_s *)priv;
@@ -199,7 +201,7 @@ static ssize_t ftl_read(FAR struct inode *inode, unsigned char *buffer,
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
static ssize_t ftl_flush(FAR void *priv, FAR const ubyte *buffer, static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
off_t startblock, size_t nblocks) off_t startblock, size_t nblocks)
{ {
struct ftl_struct_s *dev = (struct ftl_struct_s *)priv; struct ftl_struct_s *dev = (struct ftl_struct_s *)priv;
@@ -387,18 +389,18 @@ static int ftl_geometry(FAR struct inode *inode, struct geometry *geometry)
if (geometry) if (geometry)
{ {
dev = (struct ftl_struct_s *)inode->i_private; dev = (struct ftl_struct_s *)inode->i_private;
geometry->geo_available = TRUE; geometry->geo_available = true;
geometry->geo_mediachanged = FALSE; geometry->geo_mediachanged = false;
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
geometry->geo_writeenabled = TRUE; geometry->geo_writeenabled = true;
#else #else
geometry->geo_writeenabled = FALSE; geometry->geo_writeenabled = false;
#endif #endif
geometry->geo_nsectors = dev->geo.neraseblocks * dev->blkper; geometry->geo_nsectors = dev->geo.neraseblocks * dev->blkper;
geometry->geo_sectorsize = dev->geo.blocksize; geometry->geo_sectorsize = dev->geo.blocksize;
fvdbg("available: TRUE mediachanged: FALSE writeenabled: %s\n", fvdbg("available: true mediachanged: false writeenabled: %s\n",
geometry->geo_writeenabled ? "TRUE" : "FALSE"); geometry->geo_writeenabled ? "true" : "false");
fvdbg("nsectors: %d sectorsize: %d\n", fvdbg("nsectors: %d sectorsize: %d\n",
geometry->geo_nsectors, geometry->geo_sectorsize); geometry->geo_nsectors, geometry->geo_sectorsize);
@@ -449,7 +451,7 @@ static int ftl_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
* *
****************************************************************************/ ****************************************************************************/
int ftl_initialize(int minor, ubyte *buffer, FAR struct mtd_dev_s *mtd) int ftl_initialize(int minor, uint8_t *buffer, FAR struct mtd_dev_s *mtd)
{ {
struct ftl_struct_s *dev; struct ftl_struct_s *dev;
char devname[16]; char devname[16];
@@ -489,7 +491,7 @@ int ftl_initialize(int minor, ubyte *buffer, FAR struct mtd_dev_s *mtd)
/* Allocate one, in-memory erase block buffer */ /* Allocate one, in-memory erase block buffer */
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
dev->eblock = (FAR ubyte *)malloc(dev->geo.erasesize); dev->eblock = (FAR uint8_t *)malloc(dev->geo.erasesize);
if (!dev->eblock) if (!dev->eblock)
{ {
fdbg("Failed to allocate an erase block buffer\n"); fdbg("Failed to allocate an erase block buffer\n");
+35 -33
View File
@@ -41,6 +41,8 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
@@ -127,10 +129,10 @@ struct m25p_dev_s
{ {
struct mtd_dev_s mtd; /* MTD interface */ struct mtd_dev_s mtd; /* MTD interface */
FAR struct spi_dev_s *dev; /* Saved SPI interface instance */ FAR struct spi_dev_s *dev; /* Saved SPI interface instance */
ubyte sectorshift; /* 16 or 18 */ uint8_t sectorshift; /* 16 or 18 */
ubyte pageshift; /* 8 */ uint8_t pageshift; /* 8 */
uint16 nsectors; /* 128 or 64 */ uint16_t nsectors; /* 128 or 64 */
uint32 npages; /* 32,768 or 65,536 */ uint32_t npages; /* 32,768 or 65,536 */
}; };
/************************************************************************************ /************************************************************************************
@@ -146,18 +148,18 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv);
static void m25p_writeenable(struct m25p_dev_s *priv); static void m25p_writeenable(struct m25p_dev_s *priv);
static inline void m25p_sectorerase(struct m25p_dev_s *priv, off_t offset); static inline void m25p_sectorerase(struct m25p_dev_s *priv, off_t offset);
static inline int m25p_bulkerase(struct m25p_dev_s *priv); static inline int m25p_bulkerase(struct m25p_dev_s *priv);
static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const ubyte *buffer, static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const uint8_t *buffer,
off_t offset); off_t offset);
/* MTD driver methods */ /* MTD driver methods */
static int m25p_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks); static int m25p_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks);
static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock,
size_t nblocks, FAR ubyte *buf); size_t nblocks, FAR uint8_t *buf);
static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
size_t nblocks, FAR const ubyte *buf); size_t nblocks, FAR const uint8_t *buf);
static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
FAR ubyte *buffer); FAR uint8_t *buffer);
static int m25p_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg); static int m25p_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
/************************************************************************************ /************************************************************************************
@@ -182,7 +184,7 @@ static void m25p_lock(FAR struct spi_dev_s *dev)
* the SPI buss. We will retain that exclusive access until the bus is unlocked. * the SPI buss. We will retain that exclusive access until the bus is unlocked.
*/ */
(void)SPI_LOCK(dev, TRUE); (void)SPI_LOCK(dev, true);
/* After locking the SPI bus, the we also need call the setfrequency, setbits, and /* After locking the SPI bus, the we also need call the setfrequency, setbits, and
* setmode methods to make sure that the SPI is properly configured for the device. * setmode methods to make sure that the SPI is properly configured for the device.
@@ -201,7 +203,7 @@ static void m25p_lock(FAR struct spi_dev_s *dev)
static inline void m25p_unlock(FAR struct spi_dev_s *dev) static inline void m25p_unlock(FAR struct spi_dev_s *dev)
{ {
(void)SPI_LOCK(dev, FALSE); (void)SPI_LOCK(dev, false);
} }
/************************************************************************************ /************************************************************************************
@@ -210,16 +212,16 @@ static inline void m25p_unlock(FAR struct spi_dev_s *dev)
static inline int m25p_readid(struct m25p_dev_s *priv) static inline int m25p_readid(struct m25p_dev_s *priv)
{ {
uint16 manufacturer; uint16_t manufacturer;
uint16 memory; uint16_t memory;
uint16 capacity; uint16_t capacity;
fvdbg("priv: %p\n", priv); fvdbg("priv: %p\n", priv);
/* Lock the SPI bus, configure the bus, and select this FLASH part. */ /* Lock the SPI bus, configure the bus, and select this FLASH part. */
m25p_lock(priv->dev); m25p_lock(priv->dev);
SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send the "Read ID (RDID)" command and read the first three ID bytes */ /* Send the "Read ID (RDID)" command and read the first three ID bytes */
@@ -230,7 +232,7 @@ static inline int m25p_readid(struct m25p_dev_s *priv)
/* Deselect the FLASH and unlock the bus */ /* Deselect the FLASH and unlock the bus */
SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
m25p_unlock(priv->dev); m25p_unlock(priv->dev);
fvdbg("manufacturer: %02x memory: %02x capacity: %02x\n", fvdbg("manufacturer: %02x memory: %02x capacity: %02x\n",
@@ -271,11 +273,11 @@ static inline int m25p_readid(struct m25p_dev_s *priv)
static void m25p_waitwritecomplete(struct m25p_dev_s *priv) static void m25p_waitwritecomplete(struct m25p_dev_s *priv)
{ {
ubyte status; uint8_t status;
/* Select this FLASH part */ /* Select this FLASH part */
SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send "Read Status Register (RDSR)" command */ /* Send "Read Status Register (RDSR)" command */
@@ -293,7 +295,7 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv)
/* Deselect the FLASH */ /* Deselect the FLASH */
SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
fvdbg("Complete\n"); fvdbg("Complete\n");
} }
@@ -305,7 +307,7 @@ static void m25p_writeenable(struct m25p_dev_s *priv)
{ {
/* Select this FLASH part */ /* Select this FLASH part */
SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send "Write Enable (WREN)" command */ /* Send "Write Enable (WREN)" command */
@@ -313,7 +315,7 @@ static void m25p_writeenable(struct m25p_dev_s *priv)
/* Deselect the FLASH */ /* Deselect the FLASH */
SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
fvdbg("Enabled\n"); fvdbg("Enabled\n");
} }
@@ -341,7 +343,7 @@ static inline void m25p_sectorerase(struct m25p_dev_s *priv, off_t sector)
/* Select this FLASH part */ /* Select this FLASH part */
SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send the "Sector Erase (SE)" instruction */ /* Send the "Sector Erase (SE)" instruction */
@@ -358,7 +360,7 @@ static inline void m25p_sectorerase(struct m25p_dev_s *priv, off_t sector)
/* Deselect the FLASH */ /* Deselect the FLASH */
SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
fvdbg("Erased\n"); fvdbg("Erased\n");
} }
@@ -384,7 +386,7 @@ static inline int m25p_bulkerase(struct m25p_dev_s *priv)
/* Select this FLASH part */ /* Select this FLASH part */
SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send the "Bulk Erase (BE)" instruction */ /* Send the "Bulk Erase (BE)" instruction */
@@ -392,7 +394,7 @@ static inline int m25p_bulkerase(struct m25p_dev_s *priv)
/* Deselect the FLASH */ /* Deselect the FLASH */
SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
fvdbg("Return: OK\n"); fvdbg("Return: OK\n");
return OK; return OK;
} }
@@ -401,7 +403,7 @@ static inline int m25p_bulkerase(struct m25p_dev_s *priv)
* Name: m25p_pagewrite * Name: m25p_pagewrite
************************************************************************************/ ************************************************************************************/
static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const ubyte *buffer, static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const uint8_t *buffer,
off_t page) off_t page)
{ {
off_t offset = page << priv->pageshift; off_t offset = page << priv->pageshift;
@@ -422,7 +424,7 @@ static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const ubyte *buff
/* Select this FLASH part */ /* Select this FLASH part */
SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send "Page Program (PP)" command */ /* Send "Page Program (PP)" command */
@@ -440,7 +442,7 @@ static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const ubyte *buff
/* Deselect the FLASH: Chip Select high */ /* Deselect the FLASH: Chip Select high */
SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
fvdbg("Written\n"); fvdbg("Written\n");
} }
@@ -474,7 +476,7 @@ static int m25p_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblock
************************************************************************************/ ************************************************************************************/
static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
FAR ubyte *buffer) FAR uint8_t *buffer)
{ {
FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev; FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev;
ssize_t nbytes; ssize_t nbytes;
@@ -496,7 +498,7 @@ static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nb
************************************************************************************/ ************************************************************************************/
static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
FAR const ubyte *buffer) FAR const uint8_t *buffer)
{ {
FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev; FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev;
size_t blocksleft = nblocks; size_t blocksleft = nblocks;
@@ -521,7 +523,7 @@ static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t n
************************************************************************************/ ************************************************************************************/
static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
FAR ubyte *buffer) FAR uint8_t *buffer)
{ {
FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev; FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev;
@@ -538,7 +540,7 @@ static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
/* Lock the SPI bus and select this FLASH part */ /* Lock the SPI bus and select this FLASH part */
m25p_lock(priv->dev); m25p_lock(priv->dev);
SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send "Read from Memory " instruction */ /* Send "Read from Memory " instruction */
@@ -556,7 +558,7 @@ static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
/* Deselect the FLASH and unlock the SPI bus */ /* Deselect the FLASH and unlock the SPI bus */
SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
m25p_unlock(priv->dev); m25p_unlock(priv->dev);
fvdbg("return nbytes: %d\n", (int)nbytes); fvdbg("return nbytes: %d\n", (int)nbytes);
return nbytes; return nbytes;
@@ -662,7 +664,7 @@ FAR struct mtd_dev_s *m25p_initialize(FAR struct spi_dev_s *dev)
/* Deselect the FLASH */ /* Deselect the FLASH */
SPI_SELECT(dev, SPIDEV_FLASH, FALSE); SPI_SELECT(dev, SPIDEV_FLASH, false);
/* Identify the FLASH chip and get its capacity */ /* Identify the FLASH chip and get its capacity */
+7 -6
View File
@@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <errno.h> #include <errno.h>
#include <nuttx/ioctl.h> #include <nuttx/ioctl.h>
@@ -73,11 +74,11 @@ struct skel_dev_s
static int skel_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks); static int skel_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks);
static ssize_t skel_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, static ssize_t skel_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
FAR ubyte *buf); FAR uint8_t *buf);
static ssize_t skel_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, static ssize_t skel_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
FAR const ubyte *buf); FAR const uint8_t *buf);
static ssize_t skel_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, static ssize_t skel_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
FAR ubyte *buffer); FAR uint8_t *buffer);
static int skel_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg); static int skel_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
/**************************************************************************** /****************************************************************************
@@ -117,7 +118,7 @@ static int skel_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblock
****************************************************************************/ ****************************************************************************/
static ssize_t skel_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, static ssize_t skel_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
FAR ubyte *buf) FAR uint8_t *buf)
{ {
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
@@ -138,7 +139,7 @@ static ssize_t skel_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nb
****************************************************************************/ ****************************************************************************/
static ssize_t skel_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, static ssize_t skel_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
FAR const ubyte *buf) FAR const uint8_t *buf)
{ {
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
@@ -159,7 +160,7 @@ static ssize_t skel_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t n
****************************************************************************/ ****************************************************************************/
static ssize_t skel_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, static ssize_t skel_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
FAR ubyte *buffer) FAR uint8_t *buffer)
{ {
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
+36 -34
View File
@@ -40,6 +40,8 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#if defined(CONFIG_NET) && defined(CONFIG_NET_CS89x0) #if defined(CONFIG_NET) && defined(CONFIG_NET_CS89x0)
#include <stdint.h>
#include <stdbool.h>
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#include <debug.h> #include <debug.h>
@@ -104,12 +106,12 @@ static FAR struct cs89x0_driver_s *g_cs89x0[CONFIG_CS89x0_NINTERFACES];
/* CS89x0 register access */ /* CS89x0 register access */
static uint16 cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset); static uint16_t cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset);
static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset,
uint16 value); uint16_t value);
static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr); static uint16_t cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr);
static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr,
uint16 value); uint16_t value);
/* Common TX logic */ /* Common TX logic */
@@ -119,7 +121,7 @@ static int cs89x0_uiptxpoll(struct uip_driver_s *dev);
/* Interrupt handling */ /* Interrupt handling */
static void cs89x0_receive(struct cs89x0_driver_s *cs89x0); static void cs89x0_receive(struct cs89x0_driver_s *cs89x0);
static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16 isq); static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16_t isq);
#if CONFIG_CS89x0_NINTERFACES > 1 #if CONFIG_CS89x0_NINTERFACES > 1
static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq); static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq);
#endif #endif
@@ -127,8 +129,8 @@ static int cs89x0_interrupt(int irq, FAR void *context);
/* Watchdog timer expirations */ /* Watchdog timer expirations */
static void cs89x0_polltimer(int argc, uint32 arg, ...); static void cs89x0_polltimer(int argc, uint32_t arg, ...);
static void cs89x0_txtimeout(int argc, uint32 arg, ...); static void cs89x0_txtimeout(int argc, uint32_t arg, ...);
/* NuttX callback functions */ /* NuttX callback functions */
@@ -157,21 +159,21 @@ static int cs89x0_txavail(struct uip_driver_s *dev);
* *
****************************************************************************/ ****************************************************************************/
static uint16 cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset) static uint16_t cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset)
{ {
#ifdef CONFIG_CS89x0_ALIGN16 #ifdef CONFIG_CS89x0_ALIGN16
return getreg16(s89x0->cs_base + offset); return getreg16(s89x0->cs_base + offset);
#else #else
return (uint16)getreg32(s89x0->cs_base + offset); return (uint16_t)getreg32(s89x0->cs_base + offset);
#endif #endif
} }
static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, uint16 value) static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, uint16_t value)
{ {
#ifdef CONFIG_CS89x0_ALIGN16 #ifdef CONFIG_CS89x0_ALIGN16
return putreg16(value, s89x0->cs_base + offset); return putreg16(value, s89x0->cs_base + offset);
#else #else
return (uint16)putreg32((uint32)value, s89x0->cs_base + offset); return (uint16_t)putreg32((uint32_t)value, s89x0->cs_base + offset);
#endif #endif
} }
@@ -192,7 +194,7 @@ static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, uint16 val
* *
****************************************************************************/ ****************************************************************************/
static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr) static uint16_t cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr)
{ {
/* In memory mode, the CS89x0's internal registers and frame buffers are mapped /* In memory mode, the CS89x0's internal registers and frame buffers are mapped
* into a contiguous 4kb block providing direct access to the internal registers * into a contiguous 4kb block providing direct access to the internal registers
@@ -205,7 +207,7 @@ static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr)
#ifdef CONFIG_CS89x0_ALIGN16 #ifdef CONFIG_CS89x0_ALIGN16
return getreg16(s89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); return getreg16(s89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??));
#else #else
return (uint16)getreg32(s89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); return (uint16_t)getreg32(s89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??));
#endif #endif
} }
@@ -217,16 +219,16 @@ static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr)
#endif #endif
{ {
#ifdef CONFIG_CS89x0_ALIGN16 #ifdef CONFIG_CS89x0_ALIGN16
putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); putreg16((uint16_t)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET);
return getreg16(s89x0->cs_base + CS89x0_PDATA_OFFSET); return getreg16(s89x0->cs_base + CS89x0_PDATA_OFFSET);
#else #else
putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); putreg32((uint32_t)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET);
return (uint16)getreg32(s89x0->cs_base + CS89x0_PDATA_OFFSET); return (uint16_t)getreg32(s89x0->cs_base + CS89x0_PDATA_OFFSET);
#endif #endif
} }
} }
static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16 value) static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16_t value)
{ {
/* In memory mode, the CS89x0's internal registers and frame buffers are mapped /* In memory mode, the CS89x0's internal registers and frame buffers are mapped
* into a contiguous 4kb block providing direct access to the internal registers * into a contiguous 4kb block providing direct access to the internal registers
@@ -239,7 +241,7 @@ static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16 val
#ifdef CONFIG_CS89x0_ALIGN16 #ifdef CONFIG_CS89x0_ALIGN16
putreg16(value), cs89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); putreg16(value), cs89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??));
#else #else
putreg32((uint32)value, cs89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); putreg32((uint32_t)value, cs89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??));
#endif #endif
} }
@@ -251,11 +253,11 @@ static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16 val
#endif #endif
{ {
#ifdef CONFIG_CS89x0_ALIGN16 #ifdef CONFIG_CS89x0_ALIGN16
putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); putreg16((uint16_t)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET);
putreg16(value, cs89x0->cs_base + CS89x0_PDATA_OFFSET); putreg16(value, cs89x0->cs_base + CS89x0_PDATA_OFFSET);
#else #else
putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); putreg32((uint32_t)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET);
putreg32((uint32)value, cs89x0->cs_base + CS89x0_PDATA_OFFSET); putreg32((uint32_t)value, cs89x0->cs_base + CS89x0_PDATA_OFFSET);
#endif #endif
} }
} }
@@ -296,7 +298,7 @@ static int cs89x0_transmit(struct cs89x0_driver_s *cs89x0)
/* Setup the TX timeout watchdog (perhaps restarting the timer) */ /* Setup the TX timeout watchdog (perhaps restarting the timer) */
(void)wd_start(cs89x0->cs_txtimeout, CS89x0_TXTIMEOUT, cs89x0_txtimeout, 1, (uint32)cs89x0); (void)wd_start(cs89x0->cs_txtimeout, CS89x0_TXTIMEOUT, cs89x0_txtimeout, 1, (uint32_t)cs89x0);
return OK; return OK;
} }
@@ -364,10 +366,10 @@ static int cs89x0_uiptxpoll(struct uip_driver_s *dev)
* *
****************************************************************************/ ****************************************************************************/
static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16 isq) static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq)
{ {
uint16 *dest; uint16_t *dest;
uint16 rxlength; uint16_t rxlength;
int nbytes; int nbytes;
/* Check for errors and update statistics */ /* Check for errors and update statistics */
@@ -415,8 +417,8 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16 isq)
* amount of data in cs89x0->cs_dev.d_len * amount of data in cs89x0->cs_dev.d_len
*/ */
dest = (uint16*)cs89x0->cs_dev.d_buf; dest = (uint16_t*)cs89x0->cs_dev.d_buf;
for (nbytes = 0; nbytes < rxlength; nbytes += sizeof(uint16)) for (nbytes = 0; nbytes < rxlength; nbytes += sizeof(uint16_t))
{ {
*dest++ = cs89x0_getreg(PPR_RXFRAMELOCATION); *dest++ = cs89x0_getreg(PPR_RXFRAMELOCATION);
} }
@@ -476,7 +478,7 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16 isq)
* *
****************************************************************************/ ****************************************************************************/
static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16 isq) static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16_t isq)
{ {
/* Check for errors and update statistics. The lower 6-bits of the ISQ /* Check for errors and update statistics. The lower 6-bits of the ISQ
* hold the register address causing the interrupt. We got here because * hold the register address causing the interrupt. We got here because
@@ -569,7 +571,7 @@ static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq)
static int cs89x0_interrupt(int irq, FAR void *context) static int cs89x0_interrupt(int irq, FAR void *context)
{ {
register struct cs89x0_driver_s *cs89x0 = s89x0_mapirq(irq); register struct cs89x0_driver_s *cs89x0 = s89x0_mapirq(irq);
uint16 isq; uint16_t isq;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!cs89x0) if (!cs89x0)
@@ -645,7 +647,7 @@ static int cs89x0_interrupt(int irq, FAR void *context)
* *
****************************************************************************/ ****************************************************************************/
static void cs89x0_txtimeout(int argc, uint32 arg, ...) static void cs89x0_txtimeout(int argc, uint32_t arg, ...)
{ {
struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)arg; struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)arg;
@@ -677,7 +679,7 @@ static void cs89x0_txtimeout(int argc, uint32 arg, ...)
* *
****************************************************************************/ ****************************************************************************/
static void cs89x0_polltimer(int argc, uint32 arg, ...) static void cs89x0_polltimer(int argc, uint32_t arg, ...)
{ {
struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)arg; struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)arg;
@@ -723,11 +725,11 @@ static int cs89x0_ifup(struct uip_driver_s *dev)
/* Set and activate a timer process */ /* Set and activate a timer process */
(void)wd_start(cs89x0->cs_txpoll, CS89x0_WDDELAY, cs89x0_polltimer, 1, (uint32)cs89x0); (void)wd_start(cs89x0->cs_txpoll, CS89x0_WDDELAY, cs89x0_polltimer, 1, (uint32_t)cs89x0);
/* Enable the Ethernet interrupt */ /* Enable the Ethernet interrupt */
cs89x0->cs_bifup = TRUE; cs89x0->cs_bifup = true;
up_enable_irq(CONFIG_CS89x0_IRQ); up_enable_irq(CONFIG_CS89x0_IRQ);
return OK; return OK;
} }
@@ -765,7 +767,7 @@ static int cs89x0_ifdown(struct uip_driver_s *dev)
/* Reset the device */ /* Reset the device */
cs89x0->cs_bifup = FALSE; cs89x0->cs_bifup = false;
irqrestore(flags); irqrestore(flags);
return OK; return OK;
} }
-2
View File
@@ -40,8 +40,6 @@
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <sys/types.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
+74 -72
View File
@@ -52,6 +52,8 @@
#undef CONFIG_DM9X_NINTERFACES #undef CONFIG_DM9X_NINTERFACES
#define CONFIG_DM9X_NINTERFACES 1 #define CONFIG_DM9X_NINTERFACES 1
#include <stdint.h>
#include <stdbool.h>
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#include <debug.h> #include <debug.h>
@@ -237,14 +239,14 @@
*/ */
#if defined(CONFIG_DM9X_BUSWIDTH8) #if defined(CONFIG_DM9X_BUSWIDTH8)
# define DM9X_INDEX *(volatile uint8*)(CONFIG_DM9X_BASE) # define DM9X_INDEX *(volatile uint8_t*)(CONFIG_DM9X_BASE)
# define DM9X_DATA *(volatile uint8*)(CONFIG_DM9X_BASE + 2) # define DM9X_DATA *(volatile uint8_t*)(CONFIG_DM9X_BASE + 2)
#elif defined(CONFIG_DM9X_BUSWIDTH16) #elif defined(CONFIG_DM9X_BUSWIDTH16)
# define DM9X_INDEX *(volatile uint16*)(CONFIG_DM9X_BASE) # define DM9X_INDEX *(volatile uint16_t*)(CONFIG_DM9X_BASE)
# define DM9X_DATA *(volatile uint16*)(CONFIG_DM9X_BASE + 2) # define DM9X_DATA *(volatile uint16_t*)(CONFIG_DM9X_BASE + 2)
#elif defined(CONFIG_DM9X_BUSWIDTH32) #elif defined(CONFIG_DM9X_BUSWIDTH32)
# define DM9X_INDEX *(volatile uint32*)(CONFIG_DM9X_BASE) # define DM9X_INDEX *(volatile uint32_t*)(CONFIG_DM9X_BASE)
# define DM9X_DATA *(volatile uint32*)(CONFIG_DM9X_BASE + 2) # define DM9X_DATA *(volatile uint32_t*)(CONFIG_DM9X_BASE + 2)
#endif #endif
/* Phy operating mode. Default is AUTO, but this setting can be overridden /* Phy operating mode. Default is AUTO, but this setting can be overridden
@@ -285,7 +287,7 @@ union rx_desc_u
{ {
uint8 rx_byte; uint8 rx_byte;
uint8 rx_status; uint8 rx_status;
uint16 rx_len; uint16_t rx_len;
} desc; } desc;
}; };
@@ -295,12 +297,12 @@ union rx_desc_u
struct dm9x_driver_s struct dm9x_driver_s
{ {
boolean dm_bifup; /* TRUE:ifup FALSE:ifdown */ bool dm_bifup; /* true:ifup false:ifdown */
boolean dm_b100M; /* TRUE:speed == 100M; FALSE:speed == 10M */ bool dm_b100M; /* true:speed == 100M; false:speed == 10M */
WDOG_ID dm_txpoll; /* TX poll timer */ WDOG_ID dm_txpoll; /* TX poll timer */
WDOG_ID dm_txtimeout; /* TX timeout timer */ WDOG_ID dm_txtimeout; /* TX timeout timer */
uint8 dm_ntxpending; /* Count of packets pending transmission */ uint8_t dm_ntxpending; /* Count of packets pending transmission */
uint8 ncrxpackets; /* Number of continuous rx packets */ uint8_t ncrxpackets; /* Number of continuous rx packets */
/* Mode-dependent function to move data in 8/16/32 I/O modes */ /* Mode-dependent function to move data in 8/16/32 I/O modes */
@@ -309,17 +311,17 @@ struct dm9x_driver_s
void (*dm_discard)(int len); void (*dm_discard)(int len);
#if defined(CONFIG_DM9X_STATS) #if defined(CONFIG_DM9X_STATS)
uint32 dm_ntxpackets; /* Count of packets sent */ uint32_t dm_ntxpackets; /* Count of packets sent */
uint32 dm_ntxbytes; /* Count of bytes sent */ uint32_t dm_ntxbytes; /* Count of bytes sent */
uint32 dm_ntxerrors; /* Count of TX errors */ uint32_t dm_ntxerrors; /* Count of TX errors */
uint32 dm_nrxpackets; /* Count of packets received */ uint32_t dm_nrxpackets; /* Count of packets received */
uint32 dm_nrxbytes; /* Count of bytes received */ uint32_t dm_nrxbytes; /* Count of bytes received */
uint32 dm_nrxfifoerrors; /* Count of RX FIFO overflow errors */ uint32_t dm_nrxfifoerrors; /* Count of RX FIFO overflow errors */
uint32 dm_nrxcrcerrors; /* Count of RX CRC errors */ uint32_t dm_nrxcrcerrors; /* Count of RX CRC errors */
uint32 dm_nrxlengtherrors; /* Count of RX length errors */ uint32_t dm_nrxlengtherrors; /* Count of RX length errors */
uint32 dm_nphyserrors; /* Count of physical layer errors */ uint32_t dm_nphyserrors; /* Count of physical layer errors */
uint32 dm_nresets; /* Counts number of resets */ uint32_t dm_nresets; /* Counts number of resets */
uint32 dm_ntxtimeouts; /* Counts resets caused by TX timeouts */ uint32_t dm_ntxtimeouts; /* Counts resets caused by TX timeouts */
#endif #endif
/* This holds the information visible to uIP/NuttX */ /* This holds the information visible to uIP/NuttX */
@@ -353,9 +355,9 @@ static void write8(const uint8 *ptr, int len);
static void write16(const uint8 *ptr, int len); static void write16(const uint8 *ptr, int len);
static void write32(const uint8 *ptr, int len); static void write32(const uint8 *ptr, int len);
/* static uint16 dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset); */ /* static uint16_t dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset); */
static uint16 dm9x_phyread(struct dm9x_driver_s *dm9x, int reg); static uint16_t dm9x_phyread(struct dm9x_driver_s *dm9x, int reg);
static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16 value); static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16_t value);
#if defined(CONFIG_DM9X_STATS) #if defined(CONFIG_DM9X_STATS)
static void dm9x_resetstatistics(struct dm9x_driver_s *dm9x); static void dm9x_resetstatistics(struct dm9x_driver_s *dm9x);
@@ -370,7 +372,7 @@ static void dm9x_dumpstatistics(struct dm9x_driver_s *dm9x);
#endif #endif
#if defined(CONFIG_DM9X_CHECKSUM) #if defined(CONFIG_DM9X_CHECKSUM)
static boolean dm9x_rxchecksumready(uint8); static bool dm9x_rxchecksumready(uint8_t);
#else #else
# define dm9x_rxchecksumready(a) ((a) == 0x01) # define dm9x_rxchecksumready(a) ((a) == 0x01)
#endif #endif
@@ -388,8 +390,8 @@ static int dm9x_interrupt(int irq, FAR void *context);
/* Watchdog timer expirations */ /* Watchdog timer expirations */
static void dm9x_polltimer(int argc, uint32 arg, ...); static void dm9x_polltimer(int argc, uint32_t arg, ...);
static void dm9x_txtimeout(int argc, uint32 arg, ...); static void dm9x_txtimeout(int argc, uint32_t arg, ...);
/* NuttX callback functions */ /* NuttX callback functions */
@@ -463,9 +465,9 @@ static void read8(uint8 *ptr, int len)
static void read16(uint8 *ptr, int len) static void read16(uint8 *ptr, int len)
{ {
register uint16 *ptr16 = (uint16*)ptr; register uint16_t *ptr16 = (uint16_t*)ptr;
nvdbg("Read %d bytes (16-bit mode)\n", len); nvdbg("Read %d bytes (16-bit mode)\n", len);
for (; len > 0; len -= sizeof(uint16)) for (; len > 0; len -= sizeof(uint16_t))
{ {
*ptr16++ = DM9X_DATA; *ptr16++ = DM9X_DATA;
} }
@@ -473,9 +475,9 @@ static void read16(uint8 *ptr, int len)
static void read32(uint8 *ptr, int len) static void read32(uint8 *ptr, int len)
{ {
register uint32 *ptr32 = (uint32*)ptr; register uint32_t *ptr32 = (uint32_t*)ptr;
nvdbg("Read %d bytes (32-bit mode)\n", len); nvdbg("Read %d bytes (32-bit mode)\n", len);
for (; len > 0; len -= sizeof(uint32)) for (; len > 0; len -= sizeof(uint32_t))
{ {
*ptr32++ = DM9X_DATA; *ptr32++ = DM9X_DATA;
} }
@@ -510,7 +512,7 @@ static void discard8(int len)
static void discard16(int len) static void discard16(int len)
{ {
nvdbg("Discard %d bytes (16-bit mode)\n", len); nvdbg("Discard %d bytes (16-bit mode)\n", len);
for (; len > 0; len -= sizeof(uint16)) for (; len > 0; len -= sizeof(uint16_t))
{ {
DM9X_DATA; DM9X_DATA;
} }
@@ -519,7 +521,7 @@ static void discard16(int len)
static void discard32(int len) static void discard32(int len)
{ {
nvdbg("Discard %d bytes (32-bit mode)\n", len); nvdbg("Discard %d bytes (32-bit mode)\n", len);
for (; len > 0; len -= sizeof(uint32)) for (; len > 0; len -= sizeof(uint32_t))
{ {
DM9X_DATA; DM9X_DATA;
} }
@@ -553,10 +555,10 @@ static void write8(const uint8 *ptr, int len)
static void write16(const uint8 *ptr, int len) static void write16(const uint8 *ptr, int len)
{ {
register uint16 *ptr16 = (uint16*)ptr; register uint16_t *ptr16 = (uint16_t*)ptr;
nvdbg("Write %d bytes (16-bit mode)\n", len); nvdbg("Write %d bytes (16-bit mode)\n", len);
for (; len > 0; len -= sizeof(uint16)) for (; len > 0; len -= sizeof(uint16_t))
{ {
DM9X_DATA = *ptr16++; DM9X_DATA = *ptr16++;
} }
@@ -564,9 +566,9 @@ static void write16(const uint8 *ptr, int len)
static void write32(const uint8 *ptr, int len) static void write32(const uint8 *ptr, int len)
{ {
register uint32 *ptr32 = (uint32*)ptr; register uint32_t *ptr32 = (uint32_t*)ptr;
nvdbg("Write %d bytes (32-bit mode)\n", len); nvdbg("Write %d bytes (32-bit mode)\n", len);
for (; len > 0; len -= sizeof(uint32)) for (; len > 0; len -= sizeof(uint32_t))
{ {
DM9X_DATA = *ptr32++; DM9X_DATA = *ptr32++;
} }
@@ -590,7 +592,7 @@ static void write32(const uint8 *ptr, int len)
****************************************************************************/ ****************************************************************************/
#if 0 /* Not used */ #if 0 /* Not used */
static uint16 dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset) static uint16_t dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset)
{ {
putreg(DM9X_EEPHYA, offset); putreg(DM9X_EEPHYA, offset);
putreg(DM9X_EEPHYC, DM9X_EEPHYC_ERPRR); putreg(DM9X_EEPHYC, DM9X_EEPHYC_ERPRR);
@@ -618,7 +620,7 @@ static uint16 dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset)
* *
****************************************************************************/ ****************************************************************************/
static uint16 dm9x_phyread(struct dm9x_driver_s *dm9x, int reg) static uint16_t dm9x_phyread(struct dm9x_driver_s *dm9x, int reg)
{ {
/* Setup DM9X_EEPHYA, the EEPROM/PHY address register */ /* Setup DM9X_EEPHYA, the EEPROM/PHY address register */
@@ -632,10 +634,10 @@ static uint16 dm9x_phyread(struct dm9x_driver_s *dm9x, int reg)
/* Return the data from the EEPROM/PHY data register pair */ /* Return the data from the EEPROM/PHY data register pair */
return (((uint16)getreg(DM9X_EEPHYDH)) << 8) | (uint16)getreg(DM9X_EEPHYDL); return (((uint16_t)getreg(DM9X_EEPHYDH)) << 8) | (uint16_t)getreg(DM9X_EEPHYDL);
} }
static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16 value) static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16_t value)
{ {
/* Setup DM9X_EEPHYA, the EEPROM/PHY address register */ /* Setup DM9X_EEPHYA, the EEPROM/PHY address register */
@@ -723,24 +725,24 @@ static void dm9x_dumpstatistics(struct dm9x_driver_s *dm9x)
* Function: dm9x_rxchecksumready * Function: dm9x_rxchecksumready
* *
* Description: * Description:
* Return TRUE if the RX checksum is available * Return true if the RX checksum is available
* *
* Parameters: * Parameters:
* rxbyte * rxbyte
* *
* Returned Value: * Returned Value:
* TRUE: checksum is ready * true: checksum is ready
* *
* Assumptions: * Assumptions:
* *
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_DM9X_CHECKSUM) #if defined(CONFIG_DM9X_CHECKSUM)
static inline boolean dm9x_rxchecksumready(uint8 rxbyte) static inline bool dm9x_rxchecksumready(uint8 rxbyte)
{ {
if ((rxbyte & 0x01) == 0) if ((rxbyte & 0x01) == 0)
{ {
return FALSE; return false;
} }
return ((rxbyte >> 4) | 0x01) != 0; return ((rxbyte >> 4) | 0x01) != 0;
@@ -810,7 +812,7 @@ static int dm9x_transmit(struct dm9x_driver_s *dm9x)
/* Setup the TX timeout watchdog (perhaps restarting the timer) */ /* Setup the TX timeout watchdog (perhaps restarting the timer) */
(void)wd_start(dm9x->dm_txtimeout, DM6X_TXTIMEOUT, dm9x_txtimeout, 1, (uint32)dm9x); (void)wd_start(dm9x->dm_txtimeout, DM6X_TXTIMEOUT, dm9x_txtimeout, 1, (uint32_t)dm9x);
return OK; return OK;
} }
return -EBUSY; return -EBUSY;
@@ -888,10 +890,10 @@ static int dm9x_uiptxpoll(struct uip_driver_s *dev)
static void dm9x_receive(struct dm9x_driver_s *dm9x) static void dm9x_receive(struct dm9x_driver_s *dm9x)
{ {
union rx_desc_u rx; union rx_desc_u rx;
boolean bchecksumready; bool bchecksumready;
uint8 mdrah; uint8_t mdrah;
uint8 mdral; uint8_t mdral;
uint8 rxbyte; uint8_t rxbyte;
nvdbg("Packet received\n"); nvdbg("Packet received\n");
@@ -903,7 +905,7 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x)
mdral = getreg(DM9X_MDRAL); mdral = getreg(DM9X_MDRAL);
getreg(DM9X_MRCMDX); /* Dummy read */ getreg(DM9X_MRCMDX); /* Dummy read */
rxbyte = (uint8)DM9X_DATA; /* Get the most up-to-date data */ rxbyte = (uint8_t)DM9X_DATA; /* Get the most up-to-date data */
/* Packet ready for receive check */ /* Packet ready for receive check */
@@ -919,7 +921,7 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x)
/* Read packet status & length */ /* Read packet status & length */
dm9x->dm_read((uint8*)&rx, 4); dm9x->dm_read((uint8_t*)&rx, 4);
/* Check if any errors were reported by the hardware */ /* Check if any errors were reported by the hardware */
@@ -1117,7 +1119,7 @@ static int dm9x_interrupt(int irq, FAR void *context)
/* Save previous register address */ /* Save previous register address */
save = (uint8)DM9X_INDEX; save = (uint8_t)DM9X_INDEX;
/* Disable all DM90x0 interrupts */ /* Disable all DM90x0 interrupts */
@@ -1151,11 +1153,11 @@ static int dm9x_interrupt(int irq, FAR void *context)
if (dm9x_phyread(dm9x, 0) & 0x2000) if (dm9x_phyread(dm9x, 0) & 0x2000)
{ {
dm9x->dm_b100M = TRUE; dm9x->dm_b100M = true;
} }
else else
{ {
dm9x->dm_b100M = FALSE; dm9x->dm_b100M = false;
} }
break; break;
} }
@@ -1219,7 +1221,7 @@ static int dm9x_interrupt(int irq, FAR void *context)
* *
****************************************************************************/ ****************************************************************************/
static void dm9x_txtimeout(int argc, uint32 arg, ...) static void dm9x_txtimeout(int argc, uint32_t arg, ...)
{ {
struct dm9x_driver_s *dm9x = (struct dm9x_driver_s *)arg; struct dm9x_driver_s *dm9x = (struct dm9x_driver_s *)arg;
@@ -1267,7 +1269,7 @@ static void dm9x_txtimeout(int argc, uint32 arg, ...)
* *
****************************************************************************/ ****************************************************************************/
static void dm9x_polltimer(int argc, uint32 arg, ...) static void dm9x_polltimer(int argc, uint32_t arg, ...)
{ {
struct dm9x_driver_s *dm9x = (struct dm9x_driver_s *)arg; struct dm9x_driver_s *dm9x = (struct dm9x_driver_s *)arg;
@@ -1315,8 +1317,8 @@ static void dm9x_polltimer(int argc, uint32 arg, ...)
static inline void dm9x_phymode(struct dm9x_driver_s *dm9x) static inline void dm9x_phymode(struct dm9x_driver_s *dm9x)
{ {
uint16 phyreg0; uint16_t phyreg0;
uint16 phyreg4; uint16_t phyreg4;
#if CONFIG_DM9X_MODE == DM9X_MODE_AUTO #if CONFIG_DM9X_MODE == DM9X_MODE_AUTO
phyreg0 = 0x1200; /* Auto-negotiation & Restart Auto-negotiation */ phyreg0 = 0x1200; /* Auto-negotiation & Restart Auto-negotiation */
@@ -1374,7 +1376,7 @@ static int dm9x_ifup(struct uip_driver_s *dev)
/* Check link state and media speed (waiting up to 3s for link OK) */ /* Check link state and media speed (waiting up to 3s for link OK) */
dm9x->dm_b100M = FALSE; dm9x->dm_b100M = false;
for (i = 0; i < 3000; i++) for (i = 0; i < 3000; i++)
{ {
netstatus = getreg(DM9X_NETS); netstatus = getreg(DM9X_NETS);
@@ -1386,7 +1388,7 @@ static int dm9x_ifup(struct uip_driver_s *dev)
netstatus = getreg(DM9X_NETS); netstatus = getreg(DM9X_NETS);
if ((netstatus & DM9X_NETS_SPEED) == 0) if ((netstatus & DM9X_NETS_SPEED) == 0)
{ {
dm9x->dm_b100M = TRUE; dm9x->dm_b100M = true;
} }
break; break;
} }
@@ -1398,11 +1400,11 @@ static int dm9x_ifup(struct uip_driver_s *dev)
/* Set and activate a timer process */ /* Set and activate a timer process */
(void)wd_start(dm9x->dm_txpoll, DM6X_WDDELAY, dm9x_polltimer, 1, (uint32)dm9x); (void)wd_start(dm9x->dm_txpoll, DM6X_WDDELAY, dm9x_polltimer, 1, (uint32_t)dm9x);
/* Enable the DM9X interrupt */ /* Enable the DM9X interrupt */
dm9x->dm_bifup = TRUE; dm9x->dm_bifup = true;
up_enable_irq(CONFIG_DM9X_IRQ); up_enable_irq(CONFIG_DM9X_IRQ);
return OK; return OK;
} }
@@ -1448,7 +1450,7 @@ static int dm9x_ifdown(struct uip_driver_s *dev)
putreg(DM9X_RXC, 0x00); /* Disable RX */ putreg(DM9X_RXC, 0x00); /* Disable RX */
putreg(DM9X_ISR, DM9X_INT_ALL); /* Clear interrupt status */ putreg(DM9X_ISR, DM9X_INT_ALL); /* Clear interrupt status */
dm9x->dm_bifup = FALSE; dm9x->dm_bifup = false;
irqrestore(flags); irqrestore(flags);
/* Dump statistics */ /* Dump statistics */
@@ -1629,7 +1631,7 @@ static void dm9x_reset(struct dm9x_driver_s *dm9x)
/* Save previous register address */ /* Save previous register address */
save = (uint8)DM9X_INDEX; save = (uint8_t)DM9X_INDEX;
#if defined(CONFIG_DM9X_STATS) #if defined(CONFIG_DM9X_STATS)
dm9x->dm_nresets++; dm9x->dm_nresets++;
@@ -1638,14 +1640,14 @@ static void dm9x_reset(struct dm9x_driver_s *dm9x)
/* Wait up to 1 second for the link to be OK */ /* Wait up to 1 second for the link to be OK */
dm9x->dm_b100M = FALSE; dm9x->dm_b100M = false;
for (i = 0; i < 1000; i++) for (i = 0; i < 1000; i++)
{ {
if (dm9x_phyread(dm9x,0x1) & 0x4) if (dm9x_phyread(dm9x,0x1) & 0x4)
{ {
if (dm9x_phyread(dm9x, 0) &0x2000) if (dm9x_phyread(dm9x, 0) &0x2000)
{ {
dm9x->dm_b100M = TRUE; dm9x->dm_b100M = true;
} }
break; break;
} }
@@ -1682,15 +1684,15 @@ static void dm9x_reset(struct dm9x_driver_s *dm9x)
int dm9x_initialize(void) int dm9x_initialize(void)
{ {
uint8 *mptr; uint8 *mptr;
uint16 vid; uint16_t vid;
uint16 pid; uint16_t pid;
int i; int i;
int j; int j;
/* Get the chip vendor ID and product ID */ /* Get the chip vendor ID and product ID */
vid = (((uint16)getreg(DM9X_VIDH)) << 8) | (uint16)getreg(DM9X_VIDL); vid = (((uint16_t)getreg(DM9X_VIDH)) << 8) | (uint16_t)getreg(DM9X_VIDL);
pid = (((uint16)getreg(DM9X_PIDH)) << 8) | (uint16)getreg(DM9X_PIDL); pid = (((uint16_t)getreg(DM9X_PIDH)) << 8) | (uint16_t)getreg(DM9X_PIDL);
nlldbg("I/O base: %08x VID: %04x PID: %04x\n", CONFIG_DM9X_BASE, vid, pid); nlldbg("I/O base: %08x VID: %04x PID: %04x\n", CONFIG_DM9X_BASE, vid, pid);
/* Check if a DM90x0 chip is recognized at this I/O base */ /* Check if a DM90x0 chip is recognized at this I/O base */
+11 -9
View File
@@ -40,6 +40,8 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#if defined(CONFIG_NET) && defined(CONFIG_skeleton_NET) #if defined(CONFIG_NET) && defined(CONFIG_skeleton_NET)
#include <stdint.h>
#include <stdbool.h>
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#include <debug.h> #include <debug.h>
@@ -88,7 +90,7 @@
struct skel_driver_s struct skel_driver_s
{ {
boolean sk_bifup; /* TRUE:ifup FALSE:ifdown */ bool sk_bifup; /* true:ifup false:ifdown */
WDOG_ID sk_txpoll; /* TX poll timer */ WDOG_ID sk_txpoll; /* TX poll timer */
WDOG_ID sk_txtimeout; /* TX timeout timer */ WDOG_ID sk_txtimeout; /* TX timeout timer */
@@ -120,8 +122,8 @@ static int skel_interrupt(int irq, FAR void *context);
/* Watchdog timer expirations */ /* Watchdog timer expirations */
static void skel_polltimer(int argc, uint32 arg, ...); static void skel_polltimer(int argc, uint32_t arg, ...);
static void skel_txtimeout(int argc, uint32 arg, ...); static void skel_txtimeout(int argc, uint32_t arg, ...);
/* NuttX callback functions */ /* NuttX callback functions */
@@ -164,7 +166,7 @@ static int skel_transmit(struct skel_driver_s *skel)
/* Setup the TX timeout watchdog (perhaps restarting the timer) */ /* Setup the TX timeout watchdog (perhaps restarting the timer) */
(void)wd_start(skel->sk_txtimeout, skeleton_TXTIMEOUT, skel_txtimeout, 1, (uint32)skel); (void)wd_start(skel->sk_txtimeout, skeleton_TXTIMEOUT, skel_txtimeout, 1, (uint32_t)skel);
return OK; return OK;
} }
@@ -370,7 +372,7 @@ static int skel_interrupt(int irq, FAR void *context)
* *
****************************************************************************/ ****************************************************************************/
static void skel_txtimeout(int argc, uint32 arg, ...) static void skel_txtimeout(int argc, uint32_t arg, ...)
{ {
struct skel_driver_s *skel = (struct skel_driver_s *)arg; struct skel_driver_s *skel = (struct skel_driver_s *)arg;
@@ -400,7 +402,7 @@ static void skel_txtimeout(int argc, uint32 arg, ...)
* *
****************************************************************************/ ****************************************************************************/
static void skel_polltimer(int argc, uint32 arg, ...) static void skel_polltimer(int argc, uint32_t arg, ...)
{ {
struct skel_driver_s *skel = (struct skel_driver_s *)arg; struct skel_driver_s *skel = (struct skel_driver_s *)arg;
@@ -444,11 +446,11 @@ static int skel_ifup(struct uip_driver_s *dev)
/* Set and activate a timer process */ /* Set and activate a timer process */
(void)wd_start(skel->sk_txpoll, skeleton_WDDELAY, skel_polltimer, 1, (uint32)skel); (void)wd_start(skel->sk_txpoll, skeleton_WDDELAY, skel_polltimer, 1, (uint32_t)skel);
/* Enable the Ethernet interrupt */ /* Enable the Ethernet interrupt */
skel->sk_bifup = TRUE; skel->sk_bifup = true;
up_enable_irq(CONFIG_skeleton_IRQ); up_enable_irq(CONFIG_skeleton_IRQ);
return OK; return OK;
} }
@@ -486,7 +488,7 @@ static int skel_ifdown(struct uip_driver_s *dev)
/* Reset the device */ /* Reset the device */
skel->sk_bifup = FALSE; skel->sk_bifup = false;
irqrestore(flags); irqrestore(flags);
return OK; return OK;
} }
+2 -5
View File
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@@ -44,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <nuttx/fs.h> #include <nuttx/fs.h>
#include <errno.h> #include <errno.h>
@@ -52,7 +49,7 @@
#if CONFIG_DEV_PIPE_SIZE > 0 #if CONFIG_DEV_PIPE_SIZE > 0
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
+3 -3
View File
@@ -88,9 +88,9 @@ static const struct file_operations pipe_fops =
#endif #endif
}; };
static sem_t g_pipesem = { 1 }; static sem_t g_pipesem = { 1 };
static uint32 g_pipeset = 0; static uint32_t g_pipeset = 0;
static uint32 g_pipecreated = 0; static uint32_t g_pipecreated = 0;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
+8 -6
View File
@@ -38,9 +38,11 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sched.h> #include <sched.h>
@@ -198,7 +200,7 @@ int pipecommon_open(FAR struct file *filep)
if (dev->d_refs == 0) if (dev->d_refs == 0)
{ {
dev->d_buffer = (ubyte*)malloc(CONFIG_DEV_PIPE_SIZE); dev->d_buffer = (uint8_t*)malloc(CONFIG_DEV_PIPE_SIZE);
if (!dev->d_buffer) if (!dev->d_buffer)
{ {
(void)sem_post(&dev->d_bfsem); (void)sem_post(&dev->d_bfsem);
@@ -330,7 +332,7 @@ ssize_t pipecommon_read(FAR struct file *filep, FAR char *buffer, size_t len)
struct inode *inode = filep->f_inode; struct inode *inode = filep->f_inode;
struct pipe_dev_s *dev = inode->i_private; struct pipe_dev_s *dev = inode->i_private;
#ifdef CONFIG_DEV_PIPEDUMP #ifdef CONFIG_DEV_PIPEDUMP
FAR ubyte *start = (ubyte*)buffer; FAR uint8_t *start = (uint8_t*)buffer;
#endif #endif
ssize_t nread = 0; ssize_t nread = 0;
int sval; int sval;
@@ -434,7 +436,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t
return -ENODEV; return -ENODEV;
} }
#endif #endif
pipe_dumpbuffer("To PIPE:", (ubyte*)buffer, len); pipe_dumpbuffer("To PIPE:", (uint8_t*)buffer, len);
/* At present, this method cannot be called from interrupt handlers. That is /* At present, this method cannot be called from interrupt handlers. That is
* because it calls sem_wait (via pipecommon_semtake below) and sem_wait cannot * because it calls sem_wait (via pipecommon_semtake below) and sem_wait cannot
@@ -448,7 +450,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t
* of taking semaphores so that pipes can be written from interupt handlers * of taking semaphores so that pipes can be written from interupt handlers
*/ */
DEBUGASSERT(up_interrupt_context() == FALSE) DEBUGASSERT(up_interrupt_context() == false)
/* Make sure that we have exclusive access to the device structure */ /* Make sure that we have exclusive access to the device structure */
@@ -544,7 +546,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds,
boolean setup) bool setup)
{ {
FAR struct inode *inode = filep->f_inode; FAR struct inode *inode = filep->f_inode;
FAR struct pipe_dev_s *dev = inode->i_private; FAR struct pipe_dev_s *dev = inode->i_private;
+4 -3
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/pipe/pipe_common.h * drivers/pipe/pipe_common.h
* *
* Copyright (C) 2008i-2009 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
#include <poll.h> #include <poll.h>
#ifndef CONFIG_DEV_PIPE_SIZE #ifndef CONFIG_DEV_PIPE_SIZE
@@ -53,7 +54,7 @@
#if CONFIG_DEV_PIPE_SIZE > 0 #if CONFIG_DEV_PIPE_SIZE > 0
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Maximum number of threads than can be waiting for POLL events */ /* Maximum number of threads than can be waiting for POLL events */
@@ -126,7 +127,7 @@ EXTERN ssize_t pipecommon_read(FAR struct file *, FAR char *, size_t);
EXTERN ssize_t pipecommon_write(FAR struct file *, FAR const char *, size_t); EXTERN ssize_t pipecommon_write(FAR struct file *, FAR const char *, size_t);
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
EXTERN int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, EXTERN int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds,
boolean setup); bool setup);
#endif #endif
#undef EXTERN #undef EXTERN
+18 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/ramdisk.c * drivers/ramdisk.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -60,13 +62,13 @@
struct rd_struct_s struct rd_struct_s
{ {
uint32 rd_nsectors; /* Number of sectors on device */ uint32_t rd_nsectors; /* Number of sectors on device */
uint16 rd_sectsize; /* The size of one sector */ uint16_t rd_sectsize; /* The size of one sector */
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
boolean rd_writeenabled; /* TRUE: can write to ram disk */ bool rd_writeenabled; /* true: can write to ram disk */
ubyte *rd_buffer; /* RAM disk backup memory */ uint8_t *rd_buffer; /* RAM disk backup memory */
#else #else
const ubyte *rd_buffer; /* ROM disk backup memory */ const uint8_t *rd_buffer; /* ROM disk backup memory */
#endif #endif
}; };
@@ -218,18 +220,18 @@ static int rd_geometry(FAR struct inode *inode, struct geometry *geometry)
if (geometry) if (geometry)
{ {
dev = (struct rd_struct_s *)inode->i_private; dev = (struct rd_struct_s *)inode->i_private;
geometry->geo_available = TRUE; geometry->geo_available = true;
geometry->geo_mediachanged = FALSE; geometry->geo_mediachanged = false;
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
geometry->geo_writeenabled = dev->rd_writeenabled; geometry->geo_writeenabled = dev->rd_writeenabled;
#else #else
geometry->geo_writeenabled = FALSE; geometry->geo_writeenabled = false;
#endif #endif
geometry->geo_nsectors = dev->rd_nsectors; geometry->geo_nsectors = dev->rd_nsectors;
geometry->geo_sectorsize = dev->rd_sectsize; geometry->geo_sectorsize = dev->rd_sectsize;
fvdbg("available: TRUE mediachanged: FALSE writeenabled: %s\n", fvdbg("available: true mediachanged: false writeenabled: %s\n",
geometry->geo_writeenabled ? "TRUE" : "FALSE"); geometry->geo_writeenabled ? "true" : "false");
fvdbg("nsectors: %d sectorsize: %d\n", fvdbg("nsectors: %d sectorsize: %d\n",
geometry->geo_nsectors, geometry->geo_sectorsize); geometry->geo_nsectors, geometry->geo_sectorsize);
@@ -279,10 +281,11 @@ static int rd_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
int ramdisk_register(int minor, ubyte *buffer, uint32 nsectors, uint16 sectsize, int ramdisk_register(int minor, uint8_t *buffer, uint32_t nsectors,
boolean writeenabled) uint16_t sectsize, bool writeenabled)
#else #else
int romdisk_register(int minor, ubyte *buffer, uint32 nsectors, uint16 sectsize) int romdisk_register(int minor, uint8_t *buffer, uint32_t nsectors,
uint16_t sectsize)
#endif #endif
{ {
struct rd_struct_s *dev; struct rd_struct_s *dev;
@@ -310,7 +313,7 @@ int romdisk_register(int minor, ubyte *buffer, uint32 nsectors, uint16 sectsize)
dev->rd_nsectors = nsectors; /* Number of sectors on device */ dev->rd_nsectors = nsectors; /* Number of sectors on device */
dev->rd_sectsize = sectsize; /* The size of one sector */ dev->rd_sectsize = sectsize; /* The size of one sector */
#ifdef CONFIG_FS_WRITABLE #ifdef CONFIG_FS_WRITABLE
dev->rd_writeenabled = writeenabled; /* TRUE: can write to ram disk */ dev->rd_writeenabled = writeenabled; /* true: can write to ram disk */
#endif #endif
dev->rd_buffer = buffer; /* RAM disk backup memory */ dev->rd_buffer = buffer; /* RAM disk backup memory */
+16 -14
View File
@@ -38,8 +38,10 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
@@ -111,8 +113,8 @@ static void rwb_semtake(sem_t *sem)
* Name: rwb_overlap * Name: rwb_overlap
****************************************************************************/ ****************************************************************************/
static inline boolean rwb_overlap(off_t blockstart1, size_t nblocks1, static inline bool rwb_overlap(off_t blockstart1, size_t nblocks1,
off_t blockstart2, size_t nblocks2) off_t blockstart2, size_t nblocks2)
{ {
off_t blockend1 = blockstart1 + nblocks1; off_t blockend1 = blockstart1 + nblocks1;
off_t blockend2 = blockstart2 + nblocks2; off_t blockend2 = blockstart2 + nblocks2;
@@ -122,11 +124,11 @@ static inline boolean rwb_overlap(off_t blockstart1, size_t nblocks1,
if ((blockend1 < blockstart2) || /* Wholly "below" */ if ((blockend1 < blockstart2) || /* Wholly "below" */
(blockstart1 > blockend2)) /* Wholly "above" */ (blockstart1 > blockend2)) /* Wholly "above" */
{ {
return FALSE; return false;
} }
else else
{ {
return TRUE; return true;
} }
} }
@@ -228,8 +230,8 @@ static inline void rwb_wrcanceltimeout(struct rwbuffer_s *rwb)
#ifdef CONFIG_FS_WRITEBUFFER #ifdef CONFIG_FS_WRITEBUFFER
static ssize_t rwb_writebuffer(FAR struct rwbuffer_s *rwb, static ssize_t rwb_writebuffer(FAR struct rwbuffer_s *rwb,
off_t startblock, uint32 nblocks, off_t startblock, uint32_t nblocks,
FAR const ubyte *wrbuffer) FAR const uint8_t *wrbuffer)
{ {
int ret; int ret;
@@ -304,7 +306,7 @@ static inline void rwb_resetrhbuffer(struct rwbuffer_s *rwb)
#ifdef CONFIG_FS_READAHEAD #ifdef CONFIG_FS_READAHEAD
static inline void static inline void
rwb_bufferread(struct rwbuffer_s *rwb, off_t startblock, rwb_bufferread(struct rwbuffer_s *rwb, off_t startblock,
size_t nblocks, ubyte **rdbuffer) size_t nblocks, uint8_t **rdbuffer)
{ {
/* We assume that (1) the caller holds the readAheadBufferSemphore, and (2) /* We assume that (1) the caller holds the readAheadBufferSemphore, and (2)
* that the caller already knows that all of the blocks are in the * that the caller already knows that all of the blocks are in the
@@ -319,7 +321,7 @@ rwb_bufferread(struct rwbuffer_s *rwb, off_t startblock,
/* Get the byte address in the read-ahead buffer */ /* Get the byte address in the read-ahead buffer */
ubyte *rhbuffer = rwb->rhbuffer + byteoffset; uint8_t *rhbuffer = rwb->rhbuffer + byteoffset;
/* Copy the data from the read-ahead buffer into the IO buffer */ /* Copy the data from the read-ahead buffer into the IO buffer */
@@ -386,7 +388,7 @@ static int rwb_rhreload(struct rwbuffer_s *rwb, off_t startblock)
int rwb_initialize(FAR struct rwbuffer_s *rwb) int rwb_initialize(FAR struct rwbuffer_s *rwb)
{ {
uint32 allocsize; uint32_t allocsize;
/* Sanity checking */ /* Sanity checking */
@@ -492,10 +494,10 @@ void rwb_uninitialize(FAR struct rwbuffer_s *rwb)
* Name: rwb_read * Name: rwb_read
****************************************************************************/ ****************************************************************************/
int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32 nblocks, int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32_t nblocks,
FAR ubyte *rdbuffer) FAR uint8_t *rdbuffer)
{ {
uint32 remaining; uint32_t remaining;
fvdbg("startblock=%ld nblocks=%ld rdbuffer=%p\n", fvdbg("startblock=%ld nblocks=%ld rdbuffer=%p\n",
(long)startblock, (long)nblocks, rdbuffer); (long)startblock, (long)nblocks, rdbuffer);
@@ -593,7 +595,7 @@ int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32 nblocks,
****************************************************************************/ ****************************************************************************/
int rwb_write(FAR struct rwbuffer_s *rwb, off_t startblock, int rwb_write(FAR struct rwbuffer_s *rwb, off_t startblock,
size_t nblocks, FAR const ubyte *wrbuffer) size_t nblocks, FAR const uint8_t *wrbuffer)
{ {
int ret; int ret;
+10 -8
View File
@@ -40,6 +40,8 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <semaphore.h> #include <semaphore.h>
#include <string.h> #include <string.h>
@@ -82,7 +84,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, size_t buflen);
static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg); static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup); static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup);
#endif #endif
/************************************************************************************ /************************************************************************************
@@ -179,7 +181,7 @@ static void uart_putxmitchar(FAR uart_dev_t *dev, int ch)
{ {
/* Inform the interrupt level logic that we are waiting */ /* Inform the interrupt level logic that we are waiting */
dev->xmitwaiting = TRUE; dev->xmitwaiting = true;
/* Wait for some characters to be sent from the buffer /* Wait for some characters to be sent from the buffer
* with the TX interrupt enabled. When the TX interrupt * with the TX interrupt enabled. When the TX interrupt
@@ -374,7 +376,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
* with the TX interrupt re-enabled. * with the TX interrupt re-enabled.
*/ */
dev->recvwaiting = TRUE; dev->recvwaiting = true;
uart_enablerxint(dev); uart_enablerxint(dev);
uart_takesem(&dev->recvsem); uart_takesem(&dev->recvsem);
uart_disablerxint(dev); uart_disablerxint(dev);
@@ -403,7 +405,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup) int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
{ {
FAR struct inode *inode = filep->f_inode; FAR struct inode *inode = filep->f_inode;
FAR uart_dev_t *dev = inode->i_private; FAR uart_dev_t *dev = inode->i_private;
@@ -589,7 +591,7 @@ static int uart_open(FAR struct file *filep)
{ {
struct inode *inode = filep->f_inode; struct inode *inode = filep->f_inode;
uart_dev_t *dev = inode->i_private; uart_dev_t *dev = inode->i_private;
ubyte tmp; uint8_t tmp;
int ret = OK; int ret = OK;
/* If the port is the middle of closing, wait until the close is finished */ /* If the port is the middle of closing, wait until the close is finished */
@@ -602,7 +604,7 @@ static int uart_open(FAR struct file *filep)
tmp = dev->open_count + 1; tmp = dev->open_count + 1;
if (tmp == 0) if (tmp == 0)
{ {
/* More than 255 opens; ubyte overflows to zero */ /* More than 255 opens; uint8_t overflows to zero */
ret = -EMFILE; ret = -EMFILE;
goto errout_with_sem; goto errout_with_sem;
@@ -707,7 +709,7 @@ void uart_datareceived(FAR uart_dev_t *dev)
if (dev->recvwaiting) if (dev->recvwaiting)
{ {
dev->recvwaiting = FALSE; dev->recvwaiting = false;
(void)sem_post(&dev->recvsem); (void)sem_post(&dev->recvsem);
} }
@@ -732,7 +734,7 @@ void uart_datasent(FAR uart_dev_t *dev)
{ {
if (dev->xmitwaiting) if (dev->xmitwaiting)
{ {
dev->xmitwaiting = FALSE; dev->xmitwaiting = false;
(void)sem_post(&dev->xmitsem); (void)sem_post(&dev->xmitsem);
} }
+6 -4
View File
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* drivers/serial/serialirq.c * drivers/serial/serialirq.c
* *
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -38,13 +38,15 @@
************************************************************************************/ ************************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <semaphore.h> #include <semaphore.h>
#include <debug.h> #include <debug.h>
#include <nuttx/serial.h> #include <nuttx/serial.h>
/************************************************************************************ /************************************************************************************
* Definitions * Pre-processor Definitions
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
@@ -80,7 +82,7 @@
void uart_xmitchars(FAR uart_dev_t *dev) void uart_xmitchars(FAR uart_dev_t *dev)
{ {
uint16 nbytes = 0; uint16_t nbytes = 0;
/* Send while we still have data & room in the fifo */ /* Send while we still have data & room in the fifo */
@@ -133,7 +135,7 @@ void uart_recvchars(FAR uart_dev_t *dev)
{ {
unsigned int status; unsigned int status;
int nexthead = dev->recv.head + 1; int nexthead = dev->recv.head + 1;
uint16 nbytes = 0; uint16_t nbytes = 0;
if (nexthead >= dev->recv.size) if (nexthead >= dev->recv.size)
{ {
+83 -80
View File
@@ -56,8 +56,10 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h> #include <pthread.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
@@ -73,7 +75,7 @@
#include "usbdev_storage.h" #include "usbdev_storage.h"
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
@@ -87,58 +89,59 @@
/* Debug ********************************************************************/ /* Debug ********************************************************************/
#if defined(CONFIG_DEBUG_VERBOSE) && defined (CONFIG_DEBUG_USB) #if defined(CONFIG_DEBUG_VERBOSE) && defined (CONFIG_DEBUG_USB)
static void usbstrg_dumpdata(const char *msg, const ubyte *buf, int buflen); static void usbstrg_dumpdata(const char *msg, const uint8_t *buf,
int buflen);
#else #else
# define usbstrg_dumpdata(msg, buf, len) # define usbstrg_dumpdata(msg, buf, len)
#endif #endif
/* Utility Support Functions ************************************************/ /* Utility Support Functions ************************************************/
static uint16 usbstrg_getbe16(ubyte *buf); static uint16_t usbstrg_getbe16(uint8_t *buf);
static uint32 usbstrg_getbe32(ubyte *buf); static uint32_t usbstrg_getbe32(uint8_t *buf);
static void usbstrg_putbe16(ubyte * buf, uint16 val); static void usbstrg_putbe16(uint8_t * buf, uint16_t val);
static void usbstrg_putbe24(ubyte *buf, uint32 val); static void usbstrg_putbe24(uint8_t *buf, uint32_t val);
static void usbstrg_putbe32(ubyte *buf, uint32 val); static void usbstrg_putbe32(uint8_t *buf, uint32_t val);
#if 0 /* not used */ #if 0 /* not used */
static uint16 usbstrg_getle16(ubyte *buf); static uint16_t usbstrg_getle16(uint8_t *buf);
#endif #endif
static uint32 usbstrg_getle32(ubyte *buf); static uint32_t usbstrg_getle32(uint8_t *buf);
#if 0 /* not used */ #if 0 /* not used */
static void usbstrg_putle16(ubyte * buf, uint16 val); static void usbstrg_putle16(uint8_t * buf, uint16_t val);
#endif #endif
static void usbstrg_putle32(ubyte *buf, uint32 val); static void usbstrg_putle32(uint8_t *buf, uint32_t val);
/* SCSI Command Processing **************************************************/ /* SCSI Command Processing **************************************************/
static inline int usbstrg_cmdtestunitready(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdtestunitready(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdrequestsense(FAR struct usbstrg_dev_s *priv, static inline int usbstrg_cmdrequestsense(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf); FAR uint8_t *buf);
static inline int usbstrg_cmdread6(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdread6(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdwrite6(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdwrite6(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdinquiry(FAR struct usbstrg_dev_s *priv, static inline int usbstrg_cmdinquiry(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf); FAR uint8_t *buf);
static inline int usbstrg_cmdmodeselect6(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdmodeselect6(FAR struct usbstrg_dev_s *priv);
static int usbstrg_modepage(FAR struct usbstrg_dev_s *priv, static int usbstrg_modepage(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf, ubyte pcpgcode, int *mdlen); FAR uint8_t *buf, uint8_t pcpgcode, int *mdlen);
static inline int usbstrg_cmdmodesense6(FAR struct usbstrg_dev_s *priv, static inline int usbstrg_cmdmodesense6(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf); FAR uint8_t *buf);
static inline int usbstrg_cmdstartstopunit(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdstartstopunit(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdpreventmediumremoval(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdpreventmediumremoval(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdreadformatcapacity(FAR struct usbstrg_dev_s *priv, static inline int usbstrg_cmdreadformatcapacity(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf); FAR uint8_t *buf);
static inline int usbstrg_cmdreadcapacity10(FAR struct usbstrg_dev_s *priv, static inline int usbstrg_cmdreadcapacity10(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf); FAR uint8_t *buf);
static inline int usbstrg_cmdread10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdread10(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdwrite10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdwrite10(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdverify10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdverify10(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdsynchronizecache10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdsynchronizecache10(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdmodeselect10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdmodeselect10(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdmodesense10(FAR struct usbstrg_dev_s *priv, static inline int usbstrg_cmdmodesense10(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf); FAR uint8_t *buf);
static inline int usbstrg_cmdread12(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdread12(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_cmdwrite12(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdwrite12(FAR struct usbstrg_dev_s *priv);
static inline int usbstrg_setupcmd(FAR struct usbstrg_dev_s *priv, ubyte cdblen, static inline int usbstrg_setupcmd(FAR struct usbstrg_dev_s *priv,
ubyte flags); uint8_t cdblen, uint8_t flags);
/* SCSI Worker Thread *******************************************************/ /* SCSI Worker Thread *******************************************************/
@@ -166,7 +169,7 @@ static int usbstrg_cmdstatusstate(FAR struct usbstrg_dev_s *priv);
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_DEBUG_VERBOSE) && defined (CONFIG_DEBUG_USB) #if defined(CONFIG_DEBUG_VERBOSE) && defined (CONFIG_DEBUG_USB)
static void usbstrg_dumpdata(const char *msg, const ubyte *buf, int buflen) static void usbstrg_dumpdata(const char *msg, const uint8_t *buf, int buflen)
{ {
int i; int i;
@@ -191,9 +194,9 @@ static void usbstrg_dumpdata(const char *msg, const ubyte *buf, int buflen)
* *
****************************************************************************/ ****************************************************************************/
static uint16 usbstrg_getbe16(ubyte *buf) static uint16_t usbstrg_getbe16(uint8_t *buf)
{ {
return ((uint16)buf[0] << 8) | ((uint16)buf[1]); return ((uint16_t)buf[0] << 8) | ((uint16_t)buf[1]);
} }
/**************************************************************************** /****************************************************************************
@@ -204,10 +207,10 @@ static uint16 usbstrg_getbe16(ubyte *buf)
* *
****************************************************************************/ ****************************************************************************/
static uint32 usbstrg_getbe32(ubyte *buf) static uint32_t usbstrg_getbe32(uint8_t *buf)
{ {
return ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | return ((uint32_t)buf[0] << 24) | ((uint32_t)buf[1] << 16) |
((uint32)buf[2] << 8) | ((uint32)buf[3]); ((uint32_t)buf[2] << 8) | ((uint32_t)buf[3]);
} }
/**************************************************************************** /****************************************************************************
@@ -219,7 +222,7 @@ static uint32 usbstrg_getbe32(ubyte *buf)
* *
****************************************************************************/ ****************************************************************************/
static void usbstrg_putbe16(ubyte * buf, uint16 val) static void usbstrg_putbe16(uint8_t * buf, uint16_t val)
{ {
buf[0] = val >> 8; buf[0] = val >> 8;
buf[1] = val; buf[1] = val;
@@ -234,7 +237,7 @@ static void usbstrg_putbe16(ubyte * buf, uint16 val)
* *
****************************************************************************/ ****************************************************************************/
static void usbstrg_putbe24(ubyte *buf, uint32 val) static void usbstrg_putbe24(uint8_t *buf, uint32_t val)
{ {
buf[0] = val >> 16; buf[0] = val >> 16;
buf[1] = val >> 8; buf[1] = val >> 8;
@@ -250,7 +253,7 @@ static void usbstrg_putbe24(ubyte *buf, uint32 val)
* *
****************************************************************************/ ****************************************************************************/
static void usbstrg_putbe32(ubyte *buf, uint32 val) static void usbstrg_putbe32(uint8_t *buf, uint32_t val)
{ {
buf[0] = val >> 24; buf[0] = val >> 24;
buf[1] = val >> 16; buf[1] = val >> 16;
@@ -267,9 +270,9 @@ static void usbstrg_putbe32(ubyte *buf, uint32 val)
****************************************************************************/ ****************************************************************************/
#if 0 /* not used */ #if 0 /* not used */
static uint16 usbstrg_getle16(ubyte *buf) static uint16_t usbstrg_getle16(uint8_t *buf)
{ {
return ((uint16)buf[1] << 8) | ((uint16)buf[0]); return ((uint16_t)buf[1] << 8) | ((uint16_t)buf[0]);
} }
#endif #endif
@@ -281,10 +284,10 @@ static uint16 usbstrg_getle16(ubyte *buf)
* *
****************************************************************************/ ****************************************************************************/
static uint32 usbstrg_getle32(ubyte *buf) static uint32_t usbstrg_getle32(uint8_t *buf)
{ {
return ((uint32)buf[3] << 24) | ((uint32)buf[2] << 16) | return ((uint32_t)buf[3] << 24) | ((uint32_t)buf[2] << 16) |
((uint32)buf[1] << 8) | ((uint32)buf[0]); ((uint32_t)buf[1] << 8) | ((uint32_t)buf[0]);
} }
/**************************************************************************** /****************************************************************************
@@ -297,7 +300,7 @@ static uint32 usbstrg_getle32(ubyte *buf)
****************************************************************************/ ****************************************************************************/
#if 0 /* not used */ #if 0 /* not used */
static void usbstrg_putle16(ubyte * buf, uint16 val) static void usbstrg_putle16(uint8_t * buf, uint16_t val)
{ {
buf[0] = val; buf[0] = val;
buf[1] = val >> 8; buf[1] = val >> 8;
@@ -313,7 +316,7 @@ static void usbstrg_putle16(ubyte * buf, uint16 val)
* *
****************************************************************************/ ****************************************************************************/
static void usbstrg_putle32(ubyte *buf, uint32 val) static void usbstrg_putle32(uint8_t *buf, uint32_t val)
{ {
buf[0] = val; buf[0] = val;
buf[1] = val >> 8; buf[1] = val >> 8;
@@ -351,15 +354,15 @@ static inline int usbstrg_cmdtestunitready(FAR struct usbstrg_dev_s *priv)
****************************************************************************/ ****************************************************************************/
static inline int usbstrg_cmdrequestsense(FAR struct usbstrg_dev_s *priv, static inline int usbstrg_cmdrequestsense(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf) FAR uint8_t *buf)
{ {
FAR struct scsicmd_requestsense_s *request = (FAR struct scsicmd_requestsense_s *)priv->cdb; FAR struct scsicmd_requestsense_s *request = (FAR struct scsicmd_requestsense_s *)priv->cdb;
FAR struct scsiresp_fixedsensedata_s *response = (FAR struct scsiresp_fixedsensedata_s *)buf; FAR struct scsiresp_fixedsensedata_s *response = (FAR struct scsiresp_fixedsensedata_s *)buf;
FAR struct usbstrg_lun_s *lun; FAR struct usbstrg_lun_s *lun;
uint32 sd; uint32_t sd;
uint32 sdinfo; uint32_t sdinfo;
ubyte cdblen; uint8_t cdblen;
int ret; int ret;
/* Extract the host allocation length */ /* Extract the host allocation length */
@@ -406,11 +409,11 @@ static inline int usbstrg_cmdrequestsense(FAR struct usbstrg_dev_s *priv,
memset(response, 0, SCSIRESP_FIXEDSENSEDATA_SIZEOF); memset(response, 0, SCSIRESP_FIXEDSENSEDATA_SIZEOF);
response->code = SCSIRESP_SENSEDATA_RESPVALID|SCSIRESP_SENSEDATA_CURRENTFIXED; response->code = SCSIRESP_SENSEDATA_RESPVALID|SCSIRESP_SENSEDATA_CURRENTFIXED;
response->flags = (ubyte)(sd >> 16); response->flags = (uint8_t)(sd >> 16);
usbstrg_putbe32(response->info, sdinfo); usbstrg_putbe32(response->info, sdinfo);
response->len = SCSIRESP_FIXEDSENSEDATA_SIZEOF - 7; response->len = SCSIRESP_FIXEDSENSEDATA_SIZEOF - 7;
response->code2 = (ubyte)(sd >> 8); response->code2 = (uint8_t)(sd >> 8);
response->qual2 = (ubyte)sd; response->qual2 = (uint8_t)sd;
priv->nreqbytes = SCSIRESP_FIXEDSENSEDATA_SIZEOF; priv->nreqbytes = SCSIRESP_FIXEDSENSEDATA_SIZEOF;
ret = OK; ret = OK;
@@ -433,7 +436,7 @@ static inline int usbstrg_cmdread6(FAR struct usbstrg_dev_s *priv)
FAR struct usbstrg_lun_s *lun = priv->lun; FAR struct usbstrg_lun_s *lun = priv->lun;
int ret; int ret;
priv->u.xfrlen = (uint16)read6->xfrlen; priv->u.xfrlen = (uint16_t)read6->xfrlen;
if (priv->u.xfrlen == 0) if (priv->u.xfrlen == 0)
{ {
priv->u.xfrlen = 256; priv->u.xfrlen = 256;
@@ -489,7 +492,7 @@ static inline int usbstrg_cmdwrite6(FAR struct usbstrg_dev_s *priv)
FAR struct usbstrg_lun_s *lun = priv->lun; FAR struct usbstrg_lun_s *lun = priv->lun;
int ret; int ret;
priv->u.xfrlen = (uint16)write6->xfrlen; priv->u.xfrlen = (uint16_t)write6->xfrlen;
if (priv->u.xfrlen == 0) if (priv->u.xfrlen == 0)
{ {
priv->u.xfrlen = 256; priv->u.xfrlen = 256;
@@ -549,7 +552,7 @@ static inline int usbstrg_cmdwrite6(FAR struct usbstrg_dev_s *priv)
****************************************************************************/ ****************************************************************************/
static inline int usbstrg_cmdinquiry(FAR struct usbstrg_dev_s *priv, static inline int usbstrg_cmdinquiry(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf) FAR uint8_t *buf)
{ {
FAR struct scscicmd_inquiry_s *inquiry = (FAR struct scscicmd_inquiry_s *)priv->cdb; FAR struct scscicmd_inquiry_s *inquiry = (FAR struct scscicmd_inquiry_s *)priv->cdb;
FAR struct scsiresp_inquiry_s *response = (FAR struct scsiresp_inquiry_s *)buf; FAR struct scsiresp_inquiry_s *response = (FAR struct scsiresp_inquiry_s *)buf;
@@ -633,8 +636,8 @@ static inline int usbstrg_cmdmodeselect6(FAR struct usbstrg_dev_s *priv)
* *
****************************************************************************/ ****************************************************************************/
static int usbstrg_modepage(FAR struct usbstrg_dev_s *priv, FAR ubyte *buf, static int usbstrg_modepage(FAR struct usbstrg_dev_s *priv, FAR uint8_t *buf,
ubyte pcpgcode, int *mdlen) uint8_t pcpgcode, int *mdlen)
{ {
FAR struct scsiresp_cachingmodepage_s *cmp = (FAR struct scsiresp_cachingmodepage_s *)buf; FAR struct scsiresp_cachingmodepage_s *cmp = (FAR struct scsiresp_cachingmodepage_s *)buf;
@@ -691,7 +694,7 @@ static int usbstrg_modepage(FAR struct usbstrg_dev_s *priv, FAR ubyte *buf,
****************************************************************************/ ****************************************************************************/
static int inline usbstrg_cmdmodesense6(FAR struct usbstrg_dev_s *priv, static int inline usbstrg_cmdmodesense6(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf) FAR uint8_t *buf)
{ {
FAR struct scsicmd_modesense6_s *modesense = (FAR struct scsicmd_modesense6_s *)priv->cdb; FAR struct scsicmd_modesense6_s *modesense = (FAR struct scsicmd_modesense6_s *)priv->cdb;
FAR struct scsiresp_modeparameterhdr6_s *mph = (FAR struct scsiresp_modeparameterhdr6_s *)buf; FAR struct scsiresp_modeparameterhdr6_s *mph = (FAR struct scsiresp_modeparameterhdr6_s *)buf;
@@ -809,7 +812,7 @@ static inline int usbstrg_cmdpreventmediumremoval(FAR struct usbstrg_dev_s *priv
****************************************************************************/ ****************************************************************************/
static inline int usbstrg_cmdreadformatcapacity(FAR struct usbstrg_dev_s *priv, static inline int usbstrg_cmdreadformatcapacity(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf) FAR uint8_t *buf)
{ {
FAR struct scsicmd_readformatcapcacities_s *rfc = (FAR struct scsicmd_readformatcapcacities_s *)priv->cdb; FAR struct scsicmd_readformatcapcacities_s *rfc = (FAR struct scsicmd_readformatcapcacities_s *)priv->cdb;
FAR struct scsiresp_readformatcapacities_s *hdr; FAR struct scsiresp_readformatcapacities_s *hdr;
@@ -843,12 +846,12 @@ static inline int usbstrg_cmdreadformatcapacity(FAR struct usbstrg_dev_s *priv,
****************************************************************************/ ****************************************************************************/
static int inline usbstrg_cmdreadcapacity10(FAR struct usbstrg_dev_s *priv, static int inline usbstrg_cmdreadcapacity10(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf) FAR uint8_t *buf)
{ {
FAR struct scsicmd_readcapacity10_s *rcc = (FAR struct scsicmd_readcapacity10_s *)priv->cdb; FAR struct scsicmd_readcapacity10_s *rcc = (FAR struct scsicmd_readcapacity10_s *)priv->cdb;
FAR struct scsiresp_readcapacity10_s *rcr = (FAR struct scsiresp_readcapacity10_s *)buf; FAR struct scsiresp_readcapacity10_s *rcr = (FAR struct scsiresp_readcapacity10_s *)buf;
FAR struct usbstrg_lun_s *lun = priv->lun; FAR struct usbstrg_lun_s *lun = priv->lun;
uint32 lba; uint32_t lba;
int ret; int ret;
priv->u.alloclen = SCSIRESP_READCAPACITY10_SIZEOF; /* Fake the allocation length */ priv->u.alloclen = SCSIRESP_READCAPACITY10_SIZEOF; /* Fake the allocation length */
@@ -1017,8 +1020,8 @@ static inline int usbstrg_cmdverify10(FAR struct usbstrg_dev_s *priv)
{ {
FAR struct scsicmd_verify10_s *verf = (FAR struct scsicmd_verify10_s *)priv->cdb; FAR struct scsicmd_verify10_s *verf = (FAR struct scsicmd_verify10_s *)priv->cdb;
FAR struct usbstrg_lun_s *lun = priv->lun; FAR struct usbstrg_lun_s *lun = priv->lun;
uint32 lba; uint32_t lba;
uint16 blocks; uint16_t blocks;
size_t sector; size_t sector;
ssize_t nread; ssize_t nread;
int ret; int ret;
@@ -1142,7 +1145,7 @@ static inline int usbstrg_cmdmodeselect10(FAR struct usbstrg_dev_s *priv)
****************************************************************************/ ****************************************************************************/
static int inline usbstrg_cmdmodesense10(FAR struct usbstrg_dev_s *priv, static int inline usbstrg_cmdmodesense10(FAR struct usbstrg_dev_s *priv,
FAR ubyte *buf) FAR uint8_t *buf)
{ {
FAR struct scsicmd_modesense10_s *modesense = (FAR struct scsicmd_modesense10_s *)priv->cdb; FAR struct scsicmd_modesense10_s *modesense = (FAR struct scsicmd_modesense10_s *)priv->cdb;
FAR struct scsiresp_modeparameterhdr10_s *mph = (FAR struct scsiresp_modeparameterhdr10_s *)buf; FAR struct scsiresp_modeparameterhdr10_s *mph = (FAR struct scsiresp_modeparameterhdr10_s *)buf;
@@ -1330,11 +1333,11 @@ static inline int usbstrg_cmdwrite12(FAR struct usbstrg_dev_s *priv)
* *
****************************************************************************/ ****************************************************************************/
static int inline usbstrg_setupcmd(FAR struct usbstrg_dev_s *priv, ubyte cdblen, ubyte flags) static int inline usbstrg_setupcmd(FAR struct usbstrg_dev_s *priv, uint8_t cdblen, uint8_t flags)
{ {
FAR struct usbstrg_lun_s *lun = NULL; FAR struct usbstrg_lun_s *lun = NULL;
uint32 datlen; uint32_t datlen;
ubyte dir = flags & USBSTRG_FLAGS_DIRMASK; uint8_t dir = flags & USBSTRG_FLAGS_DIRMASK;
int ret = OK; int ret = OK;
/* Verify the LUN and set up the current LUN reference in the /* Verify the LUN and set up the current LUN reference in the
@@ -1525,7 +1528,7 @@ static int usbstrg_idlestate(FAR struct usbstrg_dev_s *priv)
/* Handle the CBW */ /* Handle the CBW */
usbstrg_dumpdata("SCSCI CBW", (ubyte*)cbw, USBSTRG_CBW_SIZEOF - USBSTRG_MAXCDBLEN); usbstrg_dumpdata("SCSCI CBW", (uint8_t*)cbw, USBSTRG_CBW_SIZEOF - USBSTRG_MAXCDBLEN);
usbstrg_dumpdata(" CDB", cbw->cdb, min(cbw->cdblen, USBSTRG_MAXCDBLEN)); usbstrg_dumpdata(" CDB", cbw->cdb, min(cbw->cdblen, USBSTRG_MAXCDBLEN));
/* Check for properly formatted CBW? */ /* Check for properly formatted CBW? */
@@ -1609,7 +1612,7 @@ static int usbstrg_idlestate(FAR struct usbstrg_dev_s *priv)
if (EP_SUBMIT(priv->epbulkout, req) != OK) if (EP_SUBMIT(priv->epbulkout, req) != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_IDLERDSUBMIT), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_IDLERDSUBMIT), (uint16_t)-ret);
} }
/* Change to the CMDPARSE state and return success */ /* Change to the CMDPARSE state and return success */
@@ -1642,7 +1645,7 @@ static int usbstrg_idlestate(FAR struct usbstrg_dev_s *priv)
static int usbstrg_cmdparsestate(FAR struct usbstrg_dev_s *priv) static int usbstrg_cmdparsestate(FAR struct usbstrg_dev_s *priv)
{ {
FAR struct usbstrg_req_s *privreq; FAR struct usbstrg_req_s *privreq;
FAR ubyte *buf; FAR uint8_t *buf;
int ret = -EINVAL; int ret = -EINVAL;
usbstrg_dumpdata("SCSCI CDB", priv->cdb, priv->cdblen); usbstrg_dumpdata("SCSCI CDB", priv->cdb, priv->cdblen);
@@ -1959,8 +1962,8 @@ static int usbstrg_cmdreadstate(FAR struct usbstrg_dev_s *priv)
FAR struct usbdev_req_s *req; FAR struct usbdev_req_s *req;
irqstate_t flags; irqstate_t flags;
ssize_t nread; ssize_t nread;
ubyte *src; uint8_t *src;
ubyte *dest; uint8_t *dest;
int nbytes; int nbytes;
int ret; int ret;
@@ -2053,7 +2056,7 @@ static int usbstrg_cmdreadstate(FAR struct usbstrg_dev_s *priv)
ret = EP_SUBMIT(priv->epbulkin, req); ret = EP_SUBMIT(priv->epbulkin, req);
if (ret != OK) if (ret != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDREADSUBMIT), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDREADSUBMIT), (uint16_t)-ret);
lun->sd = SCSI_KCQME_UNRRE1; lun->sd = SCSI_KCQME_UNRRE1;
lun->sdinfo = priv->sector; lun->sdinfo = priv->sector;
break; break;
@@ -2104,9 +2107,9 @@ static int usbstrg_cmdwritestate(FAR struct usbstrg_dev_s *priv)
FAR struct usbstrg_req_s *privreq; FAR struct usbstrg_req_s *privreq;
FAR struct usbdev_req_s *req; FAR struct usbdev_req_s *req;
ssize_t nwritten; ssize_t nwritten;
uint16 xfrd; uint16_t xfrd;
ubyte *src; uint8_t *src;
ubyte *dest; uint8_t *dest;
int nbytes; int nbytes;
int ret; int ret;
@@ -2195,7 +2198,7 @@ static int usbstrg_cmdwritestate(FAR struct usbstrg_dev_s *priv)
ret = EP_SUBMIT(priv->epbulkout, req); ret = EP_SUBMIT(priv->epbulkout, req);
if (ret != OK) if (ret != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDWRITERDSUBMIT), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDWRITERDSUBMIT), (uint16_t)-ret);
} }
/* Did the host decide to stop early? */ /* Did the host decide to stop early? */
@@ -2289,7 +2292,7 @@ static int usbstrg_cmdfinishstate(FAR struct usbstrg_dev_s *priv)
ret = EP_SUBMIT(priv->epbulkin, privreq->req); ret = EP_SUBMIT(priv->epbulkin, privreq->req);
if (ret < 0) if (ret < 0)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSUBMIT), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSUBMIT), (uint16_t)-ret);
} }
} }
@@ -2297,7 +2300,7 @@ static int usbstrg_cmdfinishstate(FAR struct usbstrg_dev_s *priv)
if (priv->residue > 0) if (priv->residue > 0)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHRESIDUE), (uint16)priv->residue); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHRESIDUE), (uint16_t)priv->residue);
(void)EP_STALL(priv->epbulkin); (void)EP_STALL(priv->epbulkin);
} }
} }
@@ -2313,14 +2316,14 @@ static int usbstrg_cmdfinishstate(FAR struct usbstrg_dev_s *priv)
flags = irqsave(); flags = irqsave();
if (priv->shortpacket) if (priv->shortpacket)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSHORTPKT), (uint16)priv->residue); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSHORTPKT), (uint16_t)priv->residue);
} }
/* Unprocessed incoming data: STALL and cancel requests. */ /* Unprocessed incoming data: STALL and cancel requests. */
else else
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINSHSUBMIT), (uint16)priv->residue); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINSHSUBMIT), (uint16_t)priv->residue);
EP_STALL(priv->epbulkout); EP_STALL(priv->epbulkout);
} }
@@ -2365,8 +2368,8 @@ static int usbstrg_cmdstatusstate(FAR struct usbstrg_dev_s *priv)
FAR struct usbdev_req_s *req; FAR struct usbdev_req_s *req;
FAR struct usbstrg_csw_s *csw; FAR struct usbstrg_csw_s *csw;
irqstate_t flags; irqstate_t flags;
uint32 sd; uint32_t sd;
ubyte status = USBSTRG_CSWSTATUS_PASS; uint8_t status = USBSTRG_CSWSTATUS_PASS;
int ret; int ret;
/* Take a request from the wrreqlist */ /* Take a request from the wrreqlist */
@@ -2425,7 +2428,7 @@ static int usbstrg_cmdstatusstate(FAR struct usbstrg_dev_s *priv)
usbstrg_putle32(csw->residue, priv->residue); usbstrg_putle32(csw->residue, priv->residue);
csw->status = status; csw->status = status;
usbstrg_dumpdata("SCSCI CSW", (ubyte*)csw, USBSTRG_CSW_SIZEOF); usbstrg_dumpdata("SCSCI CSW", (uint8_t*)csw, USBSTRG_CSW_SIZEOF);
req->len = USBSTRG_CSW_SIZEOF; req->len = USBSTRG_CSW_SIZEOF;
req->callback = usbstrg_wrcomplete; req->callback = usbstrg_wrcomplete;
@@ -2435,7 +2438,7 @@ static int usbstrg_cmdstatusstate(FAR struct usbstrg_dev_s *priv)
ret = EP_SUBMIT(priv->epbulkin, req); ret = EP_SUBMIT(priv->epbulkin, req);
if (ret < 0) if (ret < 0)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_SNDSTATUSSUBMIT), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_SNDSTATUSSUBMIT), (uint16_t)-ret);
flags = irqsave(); flags = irqsave();
(void)sq_addlast((sq_entry_t*)privreq, &priv->wrreqlist); (void)sq_addlast((sq_entry_t*)privreq, &priv->wrreqlist);
irqrestore(flags); irqrestore(flags);
@@ -2465,7 +2468,7 @@ void *usbstrg_workerthread(void *arg)
{ {
struct usbstrg_dev_s *priv = (struct usbstrg_dev_s *)arg; struct usbstrg_dev_s *priv = (struct usbstrg_dev_s *)arg;
irqstate_t flags; irqstate_t flags;
uint16 eventset; uint16_t eventset;
int ret; int ret;
/* This thread is started before the USB storage class is fully initialized. /* This thread is started before the USB storage class is fully initialized.
@@ -2555,7 +2558,7 @@ void *usbstrg_workerthread(void *arg)
if ((eventset & (USBSTRG_EVENT_RESET|USBSTRG_EVENT_CFGCHANGE|USBSTRG_EVENT_IFCHANGE)) != 0) if ((eventset & (USBSTRG_EVENT_RESET|USBSTRG_EVENT_CFGCHANGE|USBSTRG_EVENT_IFCHANGE)) != 0)
{ {
usbstrg_deferredresponse(priv, FALSE); usbstrg_deferredresponse(priv, false);
} }
/* For all of these events... terminate any transactions in progress */ /* For all of these events... terminate any transactions in progress */
+83 -79
View File
@@ -40,8 +40,10 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@@ -58,7 +60,7 @@
#include <nuttx/usbdev_trace.h> #include <nuttx/usbdev_trace.h>
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
@@ -249,13 +251,13 @@ struct usbser_dev_s
FAR struct uart_dev_s serdev; /* Serial device structure */ FAR struct uart_dev_s serdev; /* Serial device structure */
FAR struct usbdev_s *usbdev; /* usbdev driver pointer */ FAR struct usbdev_s *usbdev; /* usbdev driver pointer */
ubyte config; /* Configuration number */ uint8_t config; /* Configuration number */
ubyte nwrq; /* Number of queue write requests (in reqlist)*/ uint8_t nwrq; /* Number of queue write requests (in reqlist)*/
ubyte nrdq; /* Number of queue read requests (in epbulkout) */ uint8_t nrdq; /* Number of queue read requests (in epbulkout) */
ubyte open : 1; /* 1: Driver has been opened */ uint8_t open : 1; /* 1: Driver has been opened */
ubyte rxenabled : 1; /* 1: UART RX "interrupts" enabled */ uint8_t rxenabled : 1; /* 1: UART RX "interrupts" enabled */
ubyte linest[7]; /* Fake line status */ uint8_t linest[7]; /* Fake line status */
sint16 rxhead; /* Working head; used when rx int disabled */ int16_t rxhead; /* Working head; used when rx int disabled */
FAR struct usbdev_ep_s *epintin; /* Interrupt IN endpoint structure */ FAR struct usbdev_ep_s *epintin; /* Interrupt IN endpoint structure */
FAR struct usbdev_ep_s *epbulkin; /* Bulk IN endpoint structure */ FAR struct usbdev_ep_s *epbulkin; /* Bulk IN endpoint structure */
@@ -299,32 +301,32 @@ struct usbser_alloc_s
/* Transfer helpers *********************************************************/ /* Transfer helpers *********************************************************/
static uint16 usbclass_fillrequest(FAR struct usbser_dev_s *priv, static uint16_t usbclass_fillrequest(FAR struct usbser_dev_s *priv,
ubyte *reqbuf, uint16 reqlen); uint8_t *reqbuf, uint16_t reqlen);
static int usbclass_sndpacket(FAR struct usbser_dev_s *priv); static int usbclass_sndpacket(FAR struct usbser_dev_s *priv);
static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv, static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv,
ubyte *reqbuf, uint16 reqlen); uint8_t *reqbuf, uint16_t reqlen);
/* Request helpers *********************************************************/ /* Request helpers *********************************************************/
static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep, static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep,
uint16 len); uint16_t len);
static void usbclass_freereq(FAR struct usbdev_ep_s *ep, static void usbclass_freereq(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *req); FAR struct usbdev_req_s *req);
/* Configuration ***********************************************************/ /* Configuration ***********************************************************/
static int usbclass_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc); static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc);
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
static void usbclass_mkepbulkdesc(const struct up_epdesc *indesc, static void usbclass_mkepbulkdesc(const struct up_epdesc *indesc,
uint16 mxpacket, struct usb_epdesc_s *outdesc) uint16_t mxpacket, struct usb_epdesc_s *outdesc)
static sint16 usbclass_mkcfgdesc(ubyte *buf, ubyte speed); static int16_t usbclass_mkcfgdesc(uint8_t *buf, uint8_t speed);
#else #else
static sint16 usbclass_mkcfgdesc(ubyte *buf); static int16_t usbclass_mkcfgdesc(uint8_t *buf);
#endif #endif
static void usbclass_resetconfig(FAR struct usbser_dev_s *priv); static void usbclass_resetconfig(FAR struct usbser_dev_s *priv);
static int usbclass_setconfig(FAR struct usbser_dev_s *priv, static int usbclass_setconfig(FAR struct usbser_dev_s *priv,
ubyte config); uint8_t config);
/* Completion event handlers ***********************************************/ /* Completion event handlers ***********************************************/
@@ -350,9 +352,9 @@ static int usbser_setup(FAR struct uart_dev_s *dev);
static void usbser_shutdown(FAR struct uart_dev_s *dev); static void usbser_shutdown(FAR struct uart_dev_s *dev);
static int usbser_attach(FAR struct uart_dev_s *dev); static int usbser_attach(FAR struct uart_dev_s *dev);
static void usbser_detach(FAR struct uart_dev_s *dev); static void usbser_detach(FAR struct uart_dev_s *dev);
static void usbser_rxint(FAR struct uart_dev_s *dev, boolean enable); static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable);
static void usbser_txint(FAR struct uart_dev_s *dev, boolean enable); static void usbser_txint(FAR struct uart_dev_s *dev, bool enable);
static boolean usbser_txempty(FAR struct uart_dev_s *dev); static bool usbser_txempty(FAR struct uart_dev_s *dev);
/**************************************************************************** /****************************************************************************
* Private Variables * Private Variables
@@ -502,12 +504,13 @@ static const struct usb_qualdesc_s g_qualdesc =
* *
************************************************************************************/ ************************************************************************************/
static uint16 usbclass_fillrequest(FAR struct usbser_dev_s *priv, ubyte *reqbuf, uint16 reqlen) static uint16_t usbclass_fillrequest(FAR struct usbser_dev_s *priv, uint8_t *reqbuf,
uint16_t reqlen)
{ {
FAR uart_dev_t *serdev = &priv->serdev; FAR uart_dev_t *serdev = &priv->serdev;
FAR struct uart_buffer_s *xmit = &serdev->xmit; FAR struct uart_buffer_s *xmit = &serdev->xmit;
irqstate_t flags; irqstate_t flags;
uint16 nbytes = 0; uint16_t nbytes = 0;
/* Disable interrupts */ /* Disable interrupts */
@@ -618,7 +621,7 @@ static int usbclass_sndpacket(FAR struct usbser_dev_s *priv)
ret = EP_SUBMIT(ep, req); ret = EP_SUBMIT(ep, req);
if (ret != OK) if (ret != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL), (uint16_t)-ret);
break; break;
} }
} }
@@ -646,13 +649,13 @@ static int usbclass_sndpacket(FAR struct usbser_dev_s *priv)
************************************************************************************/ ************************************************************************************/
static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv, static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv,
ubyte *reqbuf, uint16 reqlen) uint8_t *reqbuf, uint16_t reqlen)
{ {
FAR uart_dev_t *serdev = &priv->serdev; FAR uart_dev_t *serdev = &priv->serdev;
FAR struct uart_buffer_s *recv = &serdev->recv; FAR struct uart_buffer_s *recv = &serdev->recv;
uint16 currhead; uint16_t currhead;
uint16 nexthead; uint16_t nexthead;
uint16 nbytes = 0; uint16_t nbytes = 0;
/* Get the next head index. During the time that RX interrupts are disabled, the /* Get the next head index. During the time that RX interrupts are disabled, the
* the serial driver will be extracting data from the circular buffer and modifying * the serial driver will be extracting data from the circular buffer and modifying
@@ -748,7 +751,8 @@ static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv,
* *
****************************************************************************/ ****************************************************************************/
static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep, uint16 len) static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep,
uint16_t len)
{ {
FAR struct usbdev_req_s *req; FAR struct usbdev_req_s *req;
@@ -795,7 +799,7 @@ static void usbclass_freereq(FAR struct usbdev_ep_s *ep,
* *
****************************************************************************/ ****************************************************************************/
static int usbclass_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc) static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
{ {
const char *str; const char *str;
int len; int len;
@@ -861,7 +865,7 @@ static int usbclass_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc)
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
static inline void usbclass_mkepbulkdesc(const FAR struct up_epdesc *indesc, static inline void usbclass_mkepbulkdesc(const FAR struct up_epdesc *indesc,
uint16 mxpacket, uint16_t mxpacket,
FAR struct usb_epdesc_s *outdesc) FAR struct usb_epdesc_s *outdesc)
{ {
/* Copy the canned descriptor */ /* Copy the canned descriptor */
@@ -884,17 +888,17 @@ static inline void usbclass_mkepbulkdesc(const FAR struct up_epdesc *indesc,
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
static sint16 usbclass_mkcfgdesc(ubyte *buf, ubyte speed) static int16_t usbclass_mkcfgdesc(uint8_t *buf, uint8_t speed)
#else #else
static sint16 usbclass_mkcfgdesc(ubyte *buf) static int16_t usbclass_mkcfgdesc(uint8_t *buf)
#endif #endif
{ {
FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf; FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf;
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
boolean highspeed = (speed == USB_SPEED_HIGH); bool highspeed = (speed == USB_SPEED_HIGH);
uint16 bulkmxpacket; uint16_t bulkmxpacket;
#endif #endif
uint16 totallen; uint16_t totallen;
/* This is the total length of the configuration (not necessarily the /* This is the total length of the configuration (not necessarily the
* size that we will be sending now. * size that we will be sending now.
@@ -991,12 +995,12 @@ static void usbclass_resetconfig(FAR struct usbser_dev_s *priv)
* *
****************************************************************************/ ****************************************************************************/
static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config) static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config)
{ {
FAR struct usbdev_req_s *req; FAR struct usbdev_req_s *req;
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
struct usb_epdesc_s epdesc; struct usb_epdesc_s epdesc;
uint16 bulkmxpacket; uint16_t bulkmxpacket;
#endif #endif
int i; int i;
int ret = 0; int ret = 0;
@@ -1039,7 +1043,7 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config)
/* Configure the IN interrupt endpoint */ /* Configure the IN interrupt endpoint */
ret = EP_CONFIGURE(priv->epintin, &g_epintindesc, FALSE); ret = EP_CONFIGURE(priv->epintin, &g_epintindesc, false);
if (ret < 0) if (ret < 0)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINCONFIGFAIL), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINCONFIGFAIL), 0);
@@ -1060,9 +1064,9 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config)
} }
usbclass_mkepbulkdesc(&g_epbulkindesc, bulkmxpacket, &epdesc); usbclass_mkepbulkdesc(&g_epbulkindesc, bulkmxpacket, &epdesc);
ret = EP_CONFIGURE(priv->epbulkin, &epdesc, FALSE); ret = EP_CONFIGURE(priv->epbulkin, &epdesc, false);
#else #else
ret = EP_CONFIGURE(priv->epbulkin, &g_epbulkindesc, FALSE); ret = EP_CONFIGURE(priv->epbulkin, &g_epbulkindesc, false);
#endif #endif
if (ret < 0) if (ret < 0)
{ {
@@ -1076,9 +1080,9 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config)
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
usbclass_mkepbulkdesc(&g_epbulkoutdesc, bulkmxpacket, &epdesc); usbclass_mkepbulkdesc(&g_epbulkoutdesc, bulkmxpacket, &epdesc);
ret = EP_CONFIGURE(priv->epbulkout, &epdesc, TRUE); ret = EP_CONFIGURE(priv->epbulkout, &epdesc, true);
#else #else
ret = EP_CONFIGURE(priv->epbulkout, &g_epbulkoutdesc, TRUE); ret = EP_CONFIGURE(priv->epbulkout, &g_epbulkoutdesc, true);
#endif #endif
if (ret < 0) if (ret < 0)
{ {
@@ -1098,7 +1102,7 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config)
ret = EP_SUBMIT(priv->epbulkout, req); ret = EP_SUBMIT(priv->epbulkout, req);
if (ret != OK) if (ret != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-ret);
goto errout; goto errout;
} }
priv->nrdq++; priv->nrdq++;
@@ -1125,7 +1129,7 @@ static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep,
{ {
if (req->result || req->xfrd != req->len) if (req->result || req->xfrd != req->len)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT), (uint16)-req->result); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT), (uint16_t)-req->result);
} }
} }
@@ -1176,7 +1180,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep,
return; return;
default: /* Some other error occurred */ default: /* Some other error occurred */
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), (uint16)-req->result); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), (uint16_t)-req->result);
break; break;
}; };
@@ -1191,7 +1195,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep,
ret = EP_SUBMIT(ep, req); ret = EP_SUBMIT(ep, req);
if (ret != OK) if (ret != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16)-req->result); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result);
} }
irqrestore(flags); irqrestore(flags);
} }
@@ -1250,7 +1254,7 @@ static void usbclass_wrcomplete(FAR struct usbdev_ep_s *ep,
break; break;
default: /* Some other error occurred */ default: /* Some other error occurred */
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRUNEXPECTED), (uint16)-req->result); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRUNEXPECTED), (uint16_t)-req->result);
break; break;
} }
} }
@@ -1272,7 +1276,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver
FAR struct usbser_dev_s *priv = ((struct usbser_driver_s*)driver)->dev; FAR struct usbser_dev_s *priv = ((struct usbser_driver_s*)driver)->dev;
FAR struct usbser_req_s *reqcontainer; FAR struct usbser_req_s *reqcontainer;
irqstate_t flags; irqstate_t flags;
uint16 reqlen; uint16_t reqlen;
int ret; int ret;
int i; int i;
@@ -1303,7 +1307,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver
/* Pre-allocate the IN interrupt endpoint */ /* Pre-allocate the IN interrupt endpoint */
priv->epintin = DEV_ALLOCEP(dev, USBSER_EPINTIN_ADDR, TRUE, USB_EP_ATTR_XFER_INT); priv->epintin = DEV_ALLOCEP(dev, USBSER_EPINTIN_ADDR, true, USB_EP_ATTR_XFER_INT);
if (!priv->epintin) if (!priv->epintin)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINALLOCFAIL), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINALLOCFAIL), 0);
@@ -1314,7 +1318,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver
/* Pre-allocate the IN bulk endpoint */ /* Pre-allocate the IN bulk endpoint */
priv->epbulkin = DEV_ALLOCEP(dev, USBSER_EPINBULK_ADDR, TRUE, USB_EP_ATTR_XFER_BULK); priv->epbulkin = DEV_ALLOCEP(dev, USBSER_EPINBULK_ADDR, true, USB_EP_ATTR_XFER_BULK);
if (!priv->epbulkin) if (!priv->epbulkin)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKINALLOCFAIL), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKINALLOCFAIL), 0);
@@ -1325,7 +1329,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver
/* Pre-allocate the OUT bulk endpoint */ /* Pre-allocate the OUT bulk endpoint */
priv->epbulkout = DEV_ALLOCEP(dev, USBSER_EPOUTBULK_ADDR, FALSE, USB_EP_ATTR_XFER_BULK); priv->epbulkout = DEV_ALLOCEP(dev, USBSER_EPOUTBULK_ADDR, false, USB_EP_ATTR_XFER_BULK);
if (!priv->epbulkout) if (!priv->epbulkout)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKOUTALLOCFAIL), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKOUTALLOCFAIL), 0);
@@ -1531,9 +1535,9 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *
{ {
FAR struct usbser_dev_s *priv; FAR struct usbser_dev_s *priv;
FAR struct usbdev_req_s *ctrlreq; FAR struct usbdev_req_s *ctrlreq;
uint16 value; uint16_t value;
uint16 index; uint16_t index;
uint16 len; uint16_t len;
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
@@ -1643,7 +1647,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *
{ {
if (ctrl->type == USB_DIR_IN) if (ctrl->type == USB_DIR_IN)
{ {
*(ubyte*)ctrlreq->buf = priv->config; *(uint8_t*)ctrlreq->buf = priv->config;
ret = 1; ret = 1;
} }
} }
@@ -1676,7 +1680,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *
} }
else else
{ {
*(ubyte*) ctrlreq->buf = USBSER_ALTINTERFACEID; *(uint8_t*) ctrlreq->buf = USBSER_ALTINTERFACEID;
ret = 1; ret = 1;
} }
} }
@@ -1738,7 +1742,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *
{ {
if ((ctrl->type & USB_DIR_IN) != 0) if ((ctrl->type & USB_DIR_IN) != 0)
{ {
*(uint32*)ctrlreq->buf = 0xdeadbeef; *(uint32_t*)ctrlreq->buf = 0xdeadbeef;
ret = 4; ret = 4;
} }
else else
@@ -1770,7 +1774,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *
ret = EP_SUBMIT(dev->ep0, ctrlreq); ret = EP_SUBMIT(dev->ep0, ctrlreq);
if (ret < 0) if (ret < 0)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPRESPQ), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPRESPQ), (uint16_t)-ret);
ctrlreq->result = OK; ctrlreq->result = OK;
usbclass_ep0incomplete(dev->ep0, ctrlreq); usbclass_ep0incomplete(dev->ep0, ctrlreq);
} }
@@ -1881,7 +1885,7 @@ static int usbser_setup(FAR struct uart_dev_s *dev)
* This method is called when the serial port is closed. This operation * This method is called when the serial port is closed. This operation
* is very simple for the USB serial backend because the serial driver * is very simple for the USB serial backend because the serial driver
* has already assured that the TX data has full drained -- it calls * has already assured that the TX data has full drained -- it calls
* usbser_txempty() until that function returns TRUE before calling this * usbser_txempty() until that function returns true before calling this
* function. * function.
* *
****************************************************************************/ ****************************************************************************/
@@ -1959,22 +1963,22 @@ static void usbser_detach(FAR struct uart_dev_s *dev)
* course, have no RX interrupts but must behave consistently. This method * course, have no RX interrupts but must behave consistently. This method
* is called under the conditions: * is called under the conditions:
* *
* 1. With enable==TRUE when the port is opened (just after usbser_setup * 1. With enable==true when the port is opened (just after usbser_setup
* and usbser_attach are called called) * and usbser_attach are called called)
* 2. With enable==FALSE while transferring data from the RX buffer * 2. With enable==false while transferring data from the RX buffer
* 2. With enable==TRUE while waiting for more incoming data * 2. With enable==true while waiting for more incoming data
* 3. With enable==FALSE when the port is closed (just before usbser_detach * 3. With enable==false when the port is closed (just before usbser_detach
* and usbser_shutdown are called). * and usbser_shutdown are called).
* *
****************************************************************************/ ****************************************************************************/
static void usbser_rxint(FAR struct uart_dev_s *dev, boolean enable) static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable)
{ {
FAR struct usbser_dev_s *priv; FAR struct usbser_dev_s *priv;
FAR uart_dev_t *serdev; FAR uart_dev_t *serdev;
irqstate_t flags; irqstate_t flags;
usbtrace(USBSER_CLASSAPI_RXINT, (uint16)enable); usbtrace(USBSER_CLASSAPI_RXINT, (uint16_t)enable);
/* Sanity check */ /* Sanity check */
@@ -2055,17 +2059,17 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, boolean enable)
* course, have no TX interrupts but must behave consistently. Initially, * course, have no TX interrupts but must behave consistently. Initially,
* TX interrupts are disabled. This method is called under the conditions: * TX interrupts are disabled. This method is called under the conditions:
* *
* 1. With enable==FALSE while transferring data into the TX buffer * 1. With enable==false while transferring data into the TX buffer
* 2. With enable==TRUE when data may be taken from the buffer. * 2. With enable==true when data may be taken from the buffer.
* 3. With enable==FALSE when the TX buffer is empty * 3. With enable==false when the TX buffer is empty
* *
****************************************************************************/ ****************************************************************************/
static void usbser_txint(FAR struct uart_dev_s *dev, boolean enable) static void usbser_txint(FAR struct uart_dev_s *dev, bool enable)
{ {
FAR struct usbser_dev_s *priv; FAR struct usbser_dev_s *priv;
usbtrace(USBSER_CLASSAPI_TXINT, (uint16)enable); usbtrace(USBSER_CLASSAPI_TXINT, (uint16_t)enable);
/* Sanity checks */ /* Sanity checks */
@@ -2098,15 +2102,15 @@ static void usbser_txint(FAR struct uart_dev_s *dev, boolean enable)
* Name: usbser_txempty * Name: usbser_txempty
* *
* Description: * Description:
* Return TRUE when all data has been sent. This is called from the * Return true when all data has been sent. This is called from the
* serial driver when the driver is closed. It will call this API * serial driver when the driver is closed. It will call this API
* periodically until it reports TRUE. NOTE that the serial driver takes all * periodically until it reports true. NOTE that the serial driver takes all
* responsibility for flushing TX data through the hardware so we can be * responsibility for flushing TX data through the hardware so we can be
* a bit sloppy about that. * a bit sloppy about that.
* *
****************************************************************************/ ****************************************************************************/
static boolean usbser_txempty(FAR struct uart_dev_s *dev) static bool usbser_txempty(FAR struct uart_dev_s *dev)
{ {
FAR struct usbser_dev_s *priv = (FAR struct usbser_dev_s*)dev->priv; FAR struct usbser_dev_s *priv = (FAR struct usbser_dev_s*)dev->priv;
@@ -2116,7 +2120,7 @@ static boolean usbser_txempty(FAR struct uart_dev_s *dev)
if (!priv) if (!priv)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0);
return TRUE; return true;
} }
#endif #endif
@@ -2200,18 +2204,18 @@ int usbdev_serialinitialize(int minor)
ret = usbdev_register(&drvr->drvr); ret = usbdev_register(&drvr->drvr);
if (ret) if (ret)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_DEVREGISTER), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_DEVREGISTER), (uint16_t)-ret);
goto errout_with_alloc; goto errout_with_alloc;
} }
/* Register the USB serial console */ /* Register the USB serial console */
#ifdef CONFIG_USBSER_CONSOLE #ifdef CONFIG_USBSER_CONSOLE
g_usbserialport.isconsole = TRUE; g_usbserialport.isconsole = true;
ret = uart_register("/dev/console", &pri->serdev); ret = uart_register("/dev/console", &pri->serdev);
if (ret < 0) if (ret < 0)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_CONSOLEREGISTER), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_CONSOLEREGISTER), (uint16_t)-ret);
goto errout_with_class; goto errout_with_class;
} }
#endif #endif
@@ -2222,7 +2226,7 @@ int usbdev_serialinitialize(int minor)
ret = uart_register(devname, &priv->serdev); ret = uart_register(devname, &priv->serdev);
if (ret) if (ret)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UARTREGISTER), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UARTREGISTER), (uint16_t)-ret);
goto errout_with_class; goto errout_with_class;
} }
return OK; return OK;
+54 -43
View File
@@ -59,8 +59,10 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@@ -80,7 +82,7 @@
#include "usbdev_storage.h" #include "usbdev_storage.h"
/**************************************************************************** /****************************************************************************
* Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
@@ -112,14 +114,14 @@ struct usbstrg_alloc_s
static void usbstrg_ep0incomplete(FAR struct usbdev_ep_s *ep, static void usbstrg_ep0incomplete(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *req); FAR struct usbdev_req_s *req);
static struct usbdev_req_s *usbstrg_allocreq(FAR struct usbdev_ep_s *ep, static struct usbdev_req_s *usbstrg_allocreq(FAR struct usbdev_ep_s *ep,
uint16 len); uint16_t len);
static void usbstrg_freereq(FAR struct usbdev_ep_s *ep, static void usbstrg_freereq(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *req); FAR struct usbdev_req_s *req);
static int usbstrg_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc); static int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc);
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
static sint16 usbstrg_mkcfgdesc(ubyte *buf, ubyte speed); static int16_t usbstrg_mkcfgdesc(uint8_t *buf, uint8_t speed);
#else #else
static sint16 usbstrg_mkcfgdesc(ubyte *buf); static int16_t usbstrg_mkcfgdesc(uint8_t *buf);
#endif #endif
/* Class Driver Operations (most at interrupt level) ************************/ /* Class Driver Operations (most at interrupt level) ************************/
@@ -296,7 +298,8 @@ static void usbstrg_ep0incomplete(FAR struct usbdev_ep_s *ep,
{ {
if (req->result || req->xfrd != req->len) if (req->result || req->xfrd != req->len)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_REQRESULT), (uint16)-req->result); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_REQRESULT),
(uint16_t)-req->result);
} }
} }
@@ -308,7 +311,8 @@ static void usbstrg_ep0incomplete(FAR struct usbdev_ep_s *ep,
* *
****************************************************************************/ ****************************************************************************/
static struct usbdev_req_s *usbstrg_allocreq(FAR struct usbdev_ep_s *ep, uint16 len) static struct usbdev_req_s *usbstrg_allocreq(FAR struct usbdev_ep_s *ep,
uint16_t len)
{ {
FAR struct usbdev_req_s *req; FAR struct usbdev_req_s *req;
@@ -354,7 +358,7 @@ static void usbstrg_freereq(FAR struct usbdev_ep_s *ep, struct usbdev_req_s *req
* *
****************************************************************************/ ****************************************************************************/
static int usbstrg_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc) static int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
{ {
const char *str; const char *str;
int len; int len;
@@ -419,18 +423,18 @@ static int usbstrg_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
static sint16 usbstrg_mkcfgdesc(ubyte *buf, ubyte speed) static int16_t usbstrg_mkcfgdesc(uint8_t *buf, uint8_t speed)
#else #else
static sint16 usbstrg_mkcfgdesc(ubyte *buf) static int16_t usbstrg_mkcfgdesc(uint8_t *buf)
#endif #endif
{ {
FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf; FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf;
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
FAR struct usb_epdesc_s *epdesc; FAR struct usb_epdesc_s *epdesc;
boolean hispeed = (speed == USB_SPEED_HIGH); bool hispeed = (speed == USB_SPEED_HIGH);
uint16 bulkmxpacket; uint16_t bulkmxpacket;
#endif #endif
uint16 totallen; uint16_t totallen;
/* This is the total length of the configuration (not necessarily the /* This is the total length of the configuration (not necessarily the
* size that we will be sending now. * size that we will be sending now.
@@ -534,7 +538,7 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_
/* Pre-allocate the IN bulk endpoint */ /* Pre-allocate the IN bulk endpoint */
priv->epbulkin = DEV_ALLOCEP(dev, USBSTRG_EPINBULK_ADDR, TRUE, USB_EP_ATTR_XFER_BULK); priv->epbulkin = DEV_ALLOCEP(dev, USBSTRG_EPINBULK_ADDR, true, USB_EP_ATTR_XFER_BULK);
if (!priv->epbulkin) if (!priv->epbulkin)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPBULKINALLOCFAIL), 0); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPBULKINALLOCFAIL), 0);
@@ -545,7 +549,7 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_
/* Pre-allocate the OUT bulk endpoint */ /* Pre-allocate the OUT bulk endpoint */
priv->epbulkout = DEV_ALLOCEP(dev, USBSTRG_EPOUTBULK_ADDR, FALSE, USB_EP_ATTR_XFER_BULK); priv->epbulkout = DEV_ALLOCEP(dev, USBSTRG_EPOUTBULK_ADDR, false, USB_EP_ATTR_XFER_BULK);
if (!priv->epbulkout) if (!priv->epbulkout)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPBULKOUTALLOCFAIL), 0); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPBULKOUTALLOCFAIL), 0);
@@ -562,7 +566,8 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_
reqcontainer->req = usbstrg_allocreq(priv->epbulkout, CONFIG_USBSTRG_BULKOUTREQLEN); reqcontainer->req = usbstrg_allocreq(priv->epbulkout, CONFIG_USBSTRG_BULKOUTREQLEN);
if (reqcontainer->req == NULL) if (reqcontainer->req == NULL)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDALLOCREQ), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDALLOCREQ),
(uint16_t)-ret);
ret = -ENOMEM; ret = -ENOMEM;
goto errout; goto errout;
} }
@@ -578,7 +583,8 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_
reqcontainer->req = usbstrg_allocreq(priv->epbulkin, CONFIG_USBSTRG_BULKINREQLEN); reqcontainer->req = usbstrg_allocreq(priv->epbulkin, CONFIG_USBSTRG_BULKINREQLEN);
if (reqcontainer->req == NULL) if (reqcontainer->req == NULL)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_WRALLOCREQ), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_WRALLOCREQ),
(uint16_t)-ret);
ret = -ENOMEM; ret = -ENOMEM;
goto errout; goto errout;
} }
@@ -723,13 +729,14 @@ static void usbstrg_unbind(FAR struct usbdev_s *dev)
* *
****************************************************************************/ ****************************************************************************/
static int usbstrg_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ctrl) static int usbstrg_setup(FAR struct usbdev_s *dev,
FAR const struct usb_ctrlreq_s *ctrl)
{ {
FAR struct usbstrg_dev_s *priv; FAR struct usbstrg_dev_s *priv;
FAR struct usbdev_req_s *ctrlreq; FAR struct usbdev_req_s *ctrlreq;
uint16 value; uint16_t value;
uint16 index; uint16_t index;
uint16 len; uint16_t len;
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
@@ -980,7 +987,7 @@ static int usbstrg_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *c
ret = EP_SUBMIT(dev->ep0, ctrlreq); ret = EP_SUBMIT(dev->ep0, ctrlreq);
if (ret < 0) if (ret < 0)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPRESPQ), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPRESPQ), (uint16_t)-ret);
#if 0 /* Not necessary */ #if 0 /* Not necessary */
ctrlreq->result = OK; ctrlreq->result = OK;
usbstrg_ep0incomplete(dev->ep0, ctrlreq); usbstrg_ep0incomplete(dev->ep0, ctrlreq);
@@ -1077,13 +1084,13 @@ static void usbstrg_lununinitialize(struct usbstrg_lun_s *lun)
* *
****************************************************************************/ ****************************************************************************/
int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config) int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, uint8_t config)
{ {
FAR struct usbstrg_req_s *privreq; FAR struct usbstrg_req_s *privreq;
FAR struct usbdev_req_s *req; FAR struct usbdev_req_s *req;
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
struct usb_epdesc_s *epdesc; struct usb_epdesc_s *epdesc;
uint16 bulkmxpacket; uint16_t bulkmxpacket;
#endif #endif
int i; int i;
int ret = 0; int ret = 0;
@@ -1129,9 +1136,9 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config)
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
bulkmxpacket = USBSTRG_BULKMAXPACKET(hispeed); bulkmxpacket = USBSTRG_BULKMAXPACKET(hispeed);
epdesc = USBSTRG_EPBULKINDESC(hispeed); epdesc = USBSTRG_EPBULKINDESC(hispeed);
ret = EP_CONFIGURE(priv->epbulkin, epdesc, FALSE); ret = EP_CONFIGURE(priv->epbulkin, epdesc, false);
#else #else
ret = EP_CONFIGURE(priv->epbulkin, &g_fsepbulkindesc, FALSE); ret = EP_CONFIGURE(priv->epbulkin, &g_fsepbulkindesc, false);
#endif #endif
if (ret < 0) if (ret < 0)
{ {
@@ -1145,9 +1152,9 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config)
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
epdesc = USBSTRG_EPBULKINDESC(hispeed); epdesc = USBSTRG_EPBULKINDESC(hispeed);
ret = EP_CONFIGURE(priv->epbulkout, epdesc, TRUE); ret = EP_CONFIGURE(priv->epbulkout, epdesc, true);
#else #else
ret = EP_CONFIGURE(priv->epbulkout, &g_fsepbulkoutdesc, TRUE); ret = EP_CONFIGURE(priv->epbulkout, &g_fsepbulkoutdesc, true);
#endif #endif
if (ret < 0) if (ret < 0)
{ {
@@ -1169,7 +1176,7 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config)
ret = EP_SUBMIT(priv->epbulkout, req); ret = EP_SUBMIT(priv->epbulkout, req);
if (ret < 0) if (ret < 0)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDSUBMIT), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDSUBMIT), (uint16_t)-ret);
goto errout; goto errout;
} }
} }
@@ -1258,7 +1265,8 @@ void usbstrg_wrcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req
break; break;
default: /* Some other error occurred */ default: /* Some other error occurred */
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_WRUNEXPECTED), (uint16)-req->result); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_WRUNEXPECTED),
(uint16_t)-req->result);
break; break;
}; };
@@ -1330,7 +1338,8 @@ void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req
default: /* Some other error occurred */ default: /* Some other error occurred */
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDUNEXPECTED), (uint16)-req->result); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDUNEXPECTED),
(uint16_t)-req->result);
/* Return the read request to the bulk out endpoint for re-filling */ /* Return the read request to the bulk out endpoint for re-filling */
@@ -1341,7 +1350,8 @@ void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req
ret = EP_SUBMIT(priv->epbulkout, req); ret = EP_SUBMIT(priv->epbulkout, req);
if (ret != OK) if (ret != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDCOMPLETERDSUBMIT), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDCOMPLETERDSUBMIT),
(uint16_t)-ret);
} }
} }
break; break;
@@ -1366,11 +1376,11 @@ void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req
* *
* Input parameters: * Input parameters:
* priv - Private state structure for this USB storage instance * priv - Private state structure for this USB storage instance
* stall - TRUE is the action failed and a stall is required * stall - true is the action failed and a stall is required
* *
****************************************************************************/ ****************************************************************************/
void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, boolean failed) void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, bool failed)
{ {
FAR struct usbdev_s *dev; FAR struct usbdev_s *dev;
FAR struct usbdev_req_s *ctrlreq; FAR struct usbdev_req_s *ctrlreq;
@@ -1398,7 +1408,8 @@ void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, boolean failed)
ret = EP_SUBMIT(dev->ep0, ctrlreq); ret = EP_SUBMIT(dev->ep0, ctrlreq);
if (ret < 0) if (ret < 0)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEFERREDRESPSUBMIT), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEFERREDRESPSUBMIT),
(uint16_t)-ret);
#if 0 /* Not necessary */ #if 0 /* Not necessary */
ctrlreq->result = OK; ctrlreq->result = OK;
usbstrg_ep0incomplete(dev->ep0, ctrlreq); usbstrg_ep0incomplete(dev->ep0, ctrlreq);
@@ -1526,7 +1537,7 @@ errout:
int usbstrg_bindlun(FAR void *handle, FAR const char *drvrpath, int usbstrg_bindlun(FAR void *handle, FAR const char *drvrpath,
unsigned int lunno, off_t startsector, size_t nsectors, unsigned int lunno, off_t startsector, size_t nsectors,
boolean readonly) bool readonly)
{ {
FAR struct usbstrg_alloc_s *alloc = (FAR struct usbstrg_alloc_s *)handle; FAR struct usbstrg_alloc_s *alloc = (FAR struct usbstrg_alloc_s *)handle;
FAR struct usbstrg_dev_s *priv; FAR struct usbstrg_dev_s *priv;
@@ -1616,7 +1627,7 @@ int usbstrg_bindlun(FAR void *handle, FAR const char *drvrpath,
if (!priv->iobuffer) if (!priv->iobuffer)
{ {
priv->iobuffer = (ubyte*)malloc(geo.geo_sectorsize); priv->iobuffer = (uint8_t*)malloc(geo.geo_sectorsize);
if (!priv->iobuffer) if (!priv->iobuffer)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_ALLOCIOBUFFER), geo.geo_sectorsize); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_ALLOCIOBUFFER), geo.geo_sectorsize);
@@ -1627,14 +1638,14 @@ int usbstrg_bindlun(FAR void *handle, FAR const char *drvrpath,
else if (priv->iosize < geo.geo_sectorsize) else if (priv->iosize < geo.geo_sectorsize)
{ {
void *tmp; void *tmp;
tmp = (ubyte*)realloc(priv->iobuffer, geo.geo_sectorsize); tmp = (uint8_t*)realloc(priv->iobuffer, geo.geo_sectorsize);
if (!tmp) if (!tmp)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_REALLOCIOBUFFER), geo.geo_sectorsize); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_REALLOCIOBUFFER), geo.geo_sectorsize);
return -ENOMEM; return -ENOMEM;
} }
priv->iobuffer = (ubyte*)tmp; priv->iobuffer = (uint8_t*)tmp;
priv->iosize = geo.geo_sectorsize; priv->iosize = geo.geo_sectorsize;
} }
@@ -1647,7 +1658,7 @@ int usbstrg_bindlun(FAR void *handle, FAR const char *drvrpath,
if (!inode->u.i_bops->write) if (!inode->u.i_bops->write)
{ {
lun->readonly = TRUE; lun->readonly = true;
} }
return OK; return OK;
} }
@@ -1772,7 +1783,7 @@ int usbstrg_exportluns(FAR void *handle)
#endif #endif
if (ret != OK) if (ret != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_THREADCREATE), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_THREADCREATE), (uint16_t)-ret);
goto errout_with_mutex; goto errout_with_mutex;
} }
@@ -1781,7 +1792,7 @@ int usbstrg_exportluns(FAR void *handle)
ret = usbdev_register(&drvr->drvr); ret = usbdev_register(&drvr->drvr);
if (ret != OK) if (ret != OK)
{ {
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEVREGISTER), (uint16)-ret); usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEVREGISTER), (uint16_t)-ret);
goto errout_with_mutex; goto errout_with_mutex;
} }
+34 -32
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/usbdev/usbdev_storage.h * drivers/usbdev/usbdev_storage.h
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Mass storage class device. Bulk-only with SCSI subclass. * Mass storage class device. Bulk-only with SCSI subclass.
@@ -43,8 +43,10 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h> #include <pthread.h>
#include <queue.h> #include <queue.h>
@@ -351,12 +353,12 @@ struct usbstrg_req_s
struct usbstrg_lun_s struct usbstrg_lun_s
{ {
struct inode *inode; /* Inode structure of open'ed block driver */ struct inode *inode; /* Inode structure of open'ed block driver */
ubyte readonly:1; /* Media is read-only */ uint8_t readonly:1; /* Media is read-only */
ubyte locked:1; /* Media removal is prevented */ uint8_t locked:1; /* Media removal is prevented */
uint16 sectorsize; /* The size of one sector */ uint16_t sectorsize; /* The size of one sector */
uint32 sd; /* Sense data */ uint32_t sd; /* Sense data */
uint32 sdinfo; /* Sense data information */ uint32_t sdinfo; /* Sense data information */
uint32 uad; /* Unit needs attention data */ uint32_t uad; /* Unit needs attention data */
off_t startsector; /* Sector offset to start of partition */ off_t startsector; /* Sector offset to start of partition */
size_t nsectors; /* Number of sectors in the partition */ size_t nsectors; /* Number of sectors in the partition */
}; };
@@ -372,14 +374,14 @@ struct usbstrg_dev_s
pthread_t thread; /* The worker thread */ pthread_t thread; /* The worker thread */
pthread_mutex_t mutex; /* Mutually exclusive access to resources*/ pthread_mutex_t mutex; /* Mutually exclusive access to resources*/
pthread_cond_t cond; /* Used to signal worker thread */ pthread_cond_t cond; /* Used to signal worker thread */
volatile ubyte thstate; /* State of the worker thread */ volatile uint8_t thstate; /* State of the worker thread */
volatile uint16 theventset; /* Set of pending events signaled to worker thread */ volatile uint16_t theventset; /* Set of pending events signaled to worker thread */
volatile ubyte thvalue; /* Value passed with the event (must persist) */ volatile uint8_t thvalue; /* Value passed with the event (must persist) */
/* Storage class configuration and state */ /* Storage class configuration and state */
ubyte nluns:4; /* Number of LUNs */ uint8_t nluns:4; /* Number of LUNs */
ubyte config; /* Configuration number */ uint8_t config; /* Configuration number */
/* Endpoints */ /* Endpoints */
@@ -391,25 +393,25 @@ struct usbstrg_dev_s
struct usbstrg_lun_s *lun; /* Currently selected LUN */ struct usbstrg_lun_s *lun; /* Currently selected LUN */
struct usbstrg_lun_s *luntab; /* Allocated table of all LUNs */ struct usbstrg_lun_s *luntab; /* Allocated table of all LUNs */
ubyte cdb[USBSTRG_MAXCDBLEN]; /* Command data (cdb[]) from CBW */ uint8_t cdb[USBSTRG_MAXCDBLEN]; /* Command data (cdb[]) from CBW */
ubyte phaseerror:1; /* Need to send phase sensing status */ uint8_t phaseerror:1; /* Need to send phase sensing status */
ubyte shortpacket:1; /* Host transmission stopped unexpectedly */ uint8_t shortpacket:1; /* Host transmission stopped unexpectedly */
ubyte cbwdir:2; /* Direction from CBW. See USBSTRG_FLAGS_DIR* definitions */ uint8_t cbwdir:2; /* Direction from CBW. See USBSTRG_FLAGS_DIR* definitions */
ubyte cdblen; /* Length of cdb[] from CBW */ uint8_t cdblen; /* Length of cdb[] from CBW */
ubyte cbwlun; /* LUN from the CBW */ uint8_t cbwlun; /* LUN from the CBW */
uint16 nsectbytes; /* Bytes buffered in iobuffer[] */ uint16_t nsectbytes; /* Bytes buffered in iobuffer[] */
uint16 nreqbytes; /* Bytes buffered in head write requests */ uint16_t nreqbytes; /* Bytes buffered in head write requests */
uint16 iosize; /* Size of iobuffer[] */ uint16_t iosize; /* Size of iobuffer[] */
uint32 cbwlen; /* Length of data from CBW */ uint32_t cbwlen; /* Length of data from CBW */
uint32 cbwtag; /* Tag from the CBW */ uint32_t cbwtag; /* Tag from the CBW */
union union
{ {
uint32 xfrlen; /* Read/Write: Sectors remaining to be transferred */ uint32_t xfrlen; /* Read/Write: Sectors remaining to be transferred */
uint32 alloclen; /* Other device-to-host: Host allocation length */ uint32_t alloclen; /* Other device-to-host: Host allocation length */
} u; } u;
uint32 sector; /* Current sector (relative to lun->startsector) */ uint32_t sector; /* Current sector (relative to lun->startsector) */
uint32 residue; /* Untransferred amount reported in the CSW */ uint32_t residue; /* Untransferred amount reported in the CSW */
ubyte *iobuffer; /* Buffer for data transfers */ uint8_t *iobuffer; /* Buffer for data transfers */
/* Write request list */ /* Write request list */
@@ -468,7 +470,7 @@ EXTERN void *usbstrg_workerthread(void *arg);
* *
****************************************************************************/ ****************************************************************************/
EXTERN int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config); EXTERN int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, uint8_t config);
/**************************************************************************** /****************************************************************************
* Name: usbstrg_resetconfig * Name: usbstrg_resetconfig
@@ -522,11 +524,11 @@ EXTERN void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep,
* *
* Input parameters: * Input parameters:
* priv - Private state structure for this USB storage instance * priv - Private state structure for this USB storage instance
* stall - TRUE is the action failed and a stall is required * stall - true is the action failed and a stall is required
* *
****************************************************************************/ ****************************************************************************/
EXTERN void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, boolean failed); EXTERN void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, bool failed);
#undef EXTERN #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
+6 -5
View File
@@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
@@ -75,8 +76,8 @@
#ifdef CONFIG_USBDEV_TRACE #ifdef CONFIG_USBDEV_TRACE
static struct usbtrace_s g_trace[CONFIG_USBDEV_TRACE_NRECORDS]; static struct usbtrace_s g_trace[CONFIG_USBDEV_TRACE_NRECORDS];
static uint16 g_head = 0; static uint16_t g_head = 0;
static uint16 g_tail = 0; static uint16_t g_tail = 0;
#endif #endif
#if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB)) #if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB))
@@ -137,7 +138,7 @@ usbtrace_idset_t usbtrace_enable(usbtrace_idset_t idset)
*******************************************************************************/ *******************************************************************************/
#if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB)) #if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB))
void usbtrace(uint16 event, uint16 value) void usbtrace(uint16_t event, uint16_t value)
{ {
irqstate_t flags; irqstate_t flags;
@@ -190,8 +191,8 @@ void usbtrace(uint16 event, uint16 value)
#ifdef CONFIG_USBDEV_TRACE #ifdef CONFIG_USBDEV_TRACE
int usbtrace_enumerate(trace_callback_t callback, void *arg) int usbtrace_enumerate(trace_callback_t callback, void *arg)
{ {
uint16 ndx; uint16_t ndx;
uint32 idset; uint32_t idset;
int ret = OK; int ret = OK;
/* Temporarily disable tracing */ /* Temporarily disable tracing */
+4 -3
View File
@@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <debug.h> #include <debug.h>
#include <nuttx/usbdev_trace.h> #include <nuttx/usbdev_trace.h>
@@ -76,7 +77,7 @@
* *
*******************************************************************************/ *******************************************************************************/
void usbtrace_trprintf(trprintf_t trprintf, uint16 event, uint16 value) void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value)
{ {
switch (event) switch (event)
{ {
@@ -129,11 +130,11 @@ void usbtrace_trprintf(trprintf_t trprintf, uint16 event, uint16 value)
break; break;
case TRACE_EPSTALL: case TRACE_EPSTALL:
trprintf("Endpoint stall(TRUE): %04x\n", value); trprintf("Endpoint stall(true): %04x\n", value);
break; break;
case TRACE_EPRESUME: case TRACE_EPRESUME:
trprintf("Endpoint stall(FALSE): %04x\n", value); trprintf("Endpoint stall(false): %04x\n", value);
break; break;
case TRACE_DEVALLOCEP: case TRACE_DEVALLOCEP: