Merge branch 'master' into pca9555

This commit is contained in:
Sebastien Lorquet
2015-11-17 14:12:03 +01:00
32 changed files with 1205 additions and 891 deletions
+9
View File
@@ -11087,4 +11087,13 @@
* drivers/serial/serial.c, serialirq.c and include/nuttx/serial/serial.h:
Implement high level DMA infrastructure for serial devices. From
Max Neklyudov (2015-11-12).
* arch/arm/src/samv7 and arch/arm/include/samv7: Add support for the
SAME70 family of chips (2015-11-14).
* configs/stm32f429i-disco: configs/stm32f429i-disco/src/stm32_nsh.c
file calculated partition boundries based on page block sizes but
mtd_partition() is expecting calculations based on erase block size.
From Alan Carvalho de Assis (2015-11-16).
* Move rivers/wireless/cc3000/security.c to crypto/aes.c; move
include/nuttx/wireless/cc3000/security.h to include/nuttx/crypto/aes.h
(2015-11-16).
+1 -1
Submodule arch updated: 24f87df3fa...cce873c460
+1 -1
View File
@@ -46,7 +46,7 @@ CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(TOPDIR)$(DELIM)sched"}
BINFMT_ASRCS =
BINFMT_CSRCS = binfmt_globals.c binfmt_register.c binfmt_unregister.c
BINFMT_CSRCS += binfmt_loadmodule.c binfmt_unloadmodule.c binfmt_execmodule.c
BINFMT_CSRCS += binfmt_exec.c binfmt_dumpmodule.c
BINFMT_CSRCS += binfmt_exec.c binfmt_copyargv.c binfmt_dumpmodule.c
ifeq ($(CONFIG_BINFMT_EXEPATH),y)
BINFMT_CSRCS += binfmt_exepath.c
+24 -4
View File
@@ -1,5 +1,5 @@
/****************************************************************************
* binfmt/binfmt_internal.h
* binfmt/binfmt.h
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __BINFMT_BINFMT_INTERNAL_H
#define __BINFMT_BINFMT_INTERNAL_H
#ifndef __BINFMT_BINFMT_H
#define __BINFMT_BINFMT_H
/****************************************************************************
* Included Files
@@ -92,6 +92,26 @@ int dump_module(FAR const struct binary_s *bin);
# define dump_module(bin)
#endif
/****************************************************************************
* Name: binfmt_copyargv
*
* Description:
* In the kernel build, the argv list will likely lie in the caller's
* address environment and, hence, by inaccessible when we swith to the
* address environment of the new process address environment. So we
* do not have any real option other than to copy the callers argv[] list.
*
* Input Parameter:
* bin - Load structure
* argv - Argument list
*
* Returned Value:
* Zero (OK) on sucess; a negater erro value on failure.
*
****************************************************************************/
int binfmt_copyargv(FAR struct binary_s *bin, FAR char * const *argv);
/****************************************************************************
* Name: binfmt_freeargv
*
@@ -117,5 +137,5 @@ void binfmt_freeargv(FAR struct binary_s *bin);
}
#endif
#endif /* __BINFMT_BINFMT_INTERNAL_H */
#endif /* __BINFMT_BINFMT_H */
+197
View File
@@ -0,0 +1,197 @@
/****************************************************************************
* binfmt/binfmt_copyargv.c
*
* Copyright (C) 2009, 2013-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <string.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/binfmt.h>
#include "binfmt.h"
#ifndef CONFIG_BINFMT_DISABLE
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* This is an artificial limit to detect error conditions where an argv[]
* list is not properly terminated.
*/
#define MAX_EXEC_ARGS 256
/****************************************************************************
* Public Function
****************************************************************************/
/****************************************************************************
* Name: binfmt_copyargv
*
* Description:
* In the kernel build, the argv list will likely lie in the caller's
* address environment and, hence, by inaccessible when we switch to the
* address environment of the new process address environment. So we
* do not have any real option other than to copy the callers argv[] list.
*
* Input Parameter:
* bin - Load structure
* argv - Argument list
*
* Returned Value:
* Zero (OK) on sucess; a negater erro value on failure.
*
****************************************************************************/
int binfmt_copyargv(FAR struct binary_s *bin, FAR char * const *argv)
{
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
FAR char *ptr;
size_t argvsize;
size_t argsize;
int nargs;
int i;
/* Get the number of arguments and the size of the argument list */
bin->argv = (FAR char **)NULL;
bin->argbuffer = (FAR char *)NULL;
if (argv)
{
argsize = 0;
nargs = 0;
for (i = 0; argv[i]; i++)
{
/* Increment the size of the allocation with the size of the next string */
argsize += (strlen(argv[i]) + 1);
nargs++;
/* This is a sanity check to prevent running away with an unterminated
* argv[] list. MAX_EXEC_ARGS should be sufficiently large that this
* never happens in normal usage.
*/
if (nargs > MAX_EXEC_ARGS)
{
bdbg("ERROR: Too many arguments: %lu\n", (unsigned long)argvsize);
return -E2BIG;
}
}
bvdbg("args=%d argsize=%lu\n", nargs, (unsigned long)argsize);
/* Allocate the argv array and an argument buffer */
if (argsize > 0)
{
argvsize = (nargs + 1) * sizeof(FAR char *);
bin->argbuffer = (FAR char *)kmm_malloc(argvsize + argsize);
if (!bin->argbuffer)
{
bdbg("ERROR: Failed to allocate the argument buffer\n");
return -ENOMEM;
}
/* Copy the argv list */
bin->argv = (FAR char **)bin->argbuffer;
ptr = bin->argbuffer + argvsize;
for (i = 0; argv[i]; i++)
{
bin->argv[i] = ptr;
argsize = strlen(argv[i]) + 1;
memcpy(ptr, argv[i], argsize);
ptr += argsize;
}
/* Terminate the argv[] list */
bin->argv[i] = (FAR char *)NULL;
}
}
return OK;
#else
/* Just save the caller's argv pointer */
bin->argv = argv;
return OK;
#endif
}
/****************************************************************************
* Name: binfmt_freeargv
*
* Description:
* Release the copied argv[] list.
*
* Input Parameter:
* binp - Load structure
*
* Returned Value:
* None
*
****************************************************************************/
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
void binfmt_freeargv(FAR struct binary_s *binp)
{
/* Is there an allocated argument buffer */
if (binp->argbuffer)
{
/* Free the argument buffer */
kmm_free(binp->argbuffer);
}
/* Nullify the allocated argv[] array and the argument buffer pointers */
binp->argbuffer = (FAR char *)NULL;
binp->argv = (FAR char **)NULL;
}
#endif
#endif /* !CONFIG_BINFMT_DISABLE */
+1 -1
View File
@@ -45,7 +45,7 @@
#include <nuttx/binfmt/binfmt.h>
#include "binfmt_internal.h"
#include "binfmt.h"
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_BINFMT) && !defined(CONFIG_BINFMT_DISABLE)
+1 -120
View File
@@ -46,129 +46,10 @@
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/binfmt.h>
#include "binfmt_internal.h"
#include "binfmt.h"
#ifndef CONFIG_BINFMT_DISABLE
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* This is an artificial limit to detect error conditions where an argv[]
* list is not properly terminated.
*/
#define MAX_EXEC_ARGS 256
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: binfmt_copyargv
*
* Description:
* In the kernel build, the argv list will likely lie in the caller's
* address environment and, hence, by inaccessible when we swith to the
* address environment of the new process address environment. So we
* do not have any real option other than to copy the callers argv[] list.
*
* Input Parameter:
* bin - Load structure
* argv - Argument list
*
* Returned Value:
* Zero (OK) on sucess; a negater erro value on failure.
*
****************************************************************************/
static inline int binfmt_copyargv(FAR struct binary_s *bin, FAR char * const *argv)
{
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
FAR char *ptr;
size_t argvsize;
size_t argsize;
int nargs;
int i;
/* Get the number of arguments and the size of the argument list */
bin->argv = (FAR char **)NULL;
bin->argbuffer = (FAR char *)NULL;
if (argv)
{
argsize = 0;
nargs = 0;
for (i = 0; argv[i]; i++)
{
/* Increment the size of the allocation with the size of the next string */
argsize += (strlen(argv[i]) + 1);
nargs++;
/* This is a sanity check to prevent running away with an unterminated
* argv[] list. MAX_EXEC_ARGS should be sufficiently large that this
* never happens in normal usage.
*/
if (nargs > MAX_EXEC_ARGS)
{
bdbg("ERROR: Too many arguments: %lu\n", (unsigned long)argvsize);
return -E2BIG;
}
}
bvdbg("args=%d argsize=%lu\n", nargs, (unsigned long)argsize);
/* Allocate the argv array and an argument buffer */
if (argsize > 0)
{
argvsize = (nargs + 1) * sizeof(FAR char *);
bin->argbuffer = (FAR char *)kmm_malloc(argvsize + argsize);
if (!bin->argbuffer)
{
bdbg("ERROR: Failed to allocate the argument buffer\n");
return -ENOMEM;
}
/* Copy the argv list */
bin->argv = (FAR char **)bin->argbuffer;
ptr = bin->argbuffer + argvsize;
for (i = 0; argv[i]; i++)
{
bin->argv[i] = ptr;
argsize = strlen(argv[i]) + 1;
memcpy(ptr, argv[i], argsize);
ptr += argsize;
}
/* Terminate the argv[] list */
bin->argv[i] = (FAR char *)NULL;
}
}
return OK;
#else
/* Just save the caller's argv pointer */
bin->argv = argv;
return OK;
#endif
}
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
+1 -1
View File
@@ -53,7 +53,7 @@
#include <nuttx/binfmt/binfmt.h>
#include "sched/sched.h"
#include "binfmt_internal.h"
#include "binfmt.h"
#ifndef CONFIG_BINFMT_DISABLE
+1 -1
View File
@@ -46,7 +46,7 @@
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/binfmt.h>
#include "binfmt_internal.h"
#include "binfmt.h"
#ifndef CONFIG_BINFMT_DISABLE
+1 -1
View File
@@ -46,7 +46,7 @@
#include <nuttx/binfmt/binfmt.h>
#include "binfmt_internal.h"
#include "binfmt.h"
#ifndef CONFIG_BINFMT_DISABLE
+1 -1
View File
@@ -46,7 +46,7 @@
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/binfmt.h>
#include "binfmt_internal.h"
#include "binfmt.h"
#if !defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_SCHED_HAVE_PARENT)
+1 -34
View File
@@ -48,7 +48,7 @@
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/binfmt.h>
#include "binfmt_internal.h"
#include "binfmt.h"
#ifndef CONFIG_BINFMT_DISABLE
@@ -211,38 +211,5 @@ int unload_module(FAR struct binary_s *binp)
return OK;
}
/****************************************************************************
* Name: binfmt_freeargv
*
* Description:
* Release the copied argv[] list.
*
* Input Parameter:
* binp - Load structure
*
* Returned Value:
* None
*
****************************************************************************/
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
void binfmt_freeargv(FAR struct binary_s *binp)
{
/* Is there an allocated argument buffer */
if (binp->argbuffer)
{
/* Free the argument buffer */
kmm_free(binp->argbuffer);
}
/* Nullify the allocated argv[] array and the argument buffer pointers */
binp->argbuffer = (FAR char *)NULL;
binp->argv = (FAR char **)NULL;
}
#endif
#endif /* CONFIG_BINFMT_DISABLE */
+1 -1
View File
@@ -46,7 +46,7 @@
#include <nuttx/binfmt/binfmt.h>
#include "binfmt_internal.h"
#include "binfmt.h"
#ifndef CONFIG_BINFMT_DISABLE
+1 -1
Submodule configs updated: 2a4b5e665a...174b30da6b
+12 -1
View File
@@ -39,4 +39,15 @@ config CRYPTO_CRYPTODEV
bool "cryptodev support"
default n
endif
config CRYPTO_SW_AES
bool "Software AES library"
default n
---help---
Enable the software AES library as described in
include/nuttx/crypto/aes.h
TODO: Adapt interfaces so that they are consistent with H/W AES
implemenations. This needs to support up_aesinitialize() and
aes_cypher() per include/nuttx/crypto/crypto.h.
endif # CRYPTO
+19 -11
View File
@@ -35,33 +35,41 @@
-include $(TOPDIR)/Make.defs
CRYPTO_ASRCS =
CRYPTO_CSRCS =
ifeq ($(CONFIG_CRYPTO),y)
# Basic
CRYPTO_ASRCS =
CRYPTO_CSRCS = crypto.c testmngr.c
CRYPTO_CSRCS += crypto.c testmngr.c
# cryptodev support
ifeq ($(CONFIG_CRYPTO_CRYPTODEV),y)
CRYPTO_CSRCS += cryptodev.c
CRYPTO_CSRCS += cryptodev.c
endif
# Sofware AES library
ifeq ($(CONFIG_CRYPTO_SW_AES),y)
CRYPTO_CSRCS += aes.c
endif
endif # CONFIG_CRYPTO
ASRCS = $(CRYPTO_ASRCS)
AOBJS = $(ASRCS:.S=$(OBJEXT))
ASRCS = $(CRYPTO_ASRCS)
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = $(CRYPTO_CSRCS)
COBJS = $(CSRCS:.c=$(OBJEXT))
CSRCS = $(CRYPTO_CSRCS)
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
BIN = libcrypto$(LIBEXT)
BIN = libcrypto$(LIBEXT)
all: $(BIN)
all: $(BIN)
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
File diff suppressed because it is too large Load Diff
+45 -35
View File
@@ -50,6 +50,16 @@
#include <nuttx/crypto/crypto.h>
#include <nuttx/crypto/cryptodev.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_CRYPTO_AES
# define AES_CYPHER(mode) \
aes_cypher(op->dst, op->src, op->len, op->iv, ses->key, ses->keylen, \
mode, encrypt)
#endif
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
@@ -69,13 +79,18 @@ static int cryptodev_ioctl(FAR struct file *filep, int cmd,
static const struct file_operations g_cryptodevops =
{
0, /* open */
0, /* close */
cryptodev_read, /* read */
cryptodev_write, /* write */
0, /* seek */
cryptodev_ioctl, /* ioctl */
0, /* poll */
0, /* open */
0, /* close */
cryptodev_read, /* read */
cryptodev_write, /* write */
0, /* seek */
cryptodev_ioctl /* ioctl */
#ifndef CONFIG_DISABLE_POLL
, 0 /* poll */
#endif
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
, 0 /* unlink */
#endif
};
/****************************************************************************
@@ -110,6 +125,7 @@ static int cryptodev_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
return OK;
}
#ifdef CONFIG_CRYPTO_AES
case CIOCCRYPT:
{
FAR struct crypt_op *op = (FAR struct crypt_op *)arg;
@@ -117,44 +133,38 @@ static int cryptodev_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
int encrypt;
switch (op->op)
{
case COP_ENCRYPT:
encrypt = 1;
break;
{
case COP_ENCRYPT:
encrypt = 1;
break;
case COP_DECRYPT:
encrypt = 0;
break;
case COP_DECRYPT:
encrypt = 0;
break;
default:
return -EINVAL;
}
default:
return -EINVAL;
}
switch (ses->cipher)
{
{
case CRYPTO_AES_ECB:
return AES_CYPHER(AES_MODE_ECB);
#if defined(CONFIG_CRYPTO_AES)
# define AES_CYPHER(mode) aes_cypher(op->dst, op->src, op->len, op->iv, ses->key, ses->keylen, mode, encrypt)
case CRYPTO_AES_CBC:
return AES_CYPHER(AES_MODE_CBC);
case CRYPTO_AES_ECB:
return AES_CYPHER(AES_MODE_ECB);
case CRYPTO_AES_CTR:
return AES_CYPHER(AES_MODE_CTR);
case CRYPTO_AES_CBC:
return AES_CYPHER(AES_MODE_CBC);
case CRYPTO_AES_CTR:
return AES_CYPHER(AES_MODE_CTR);
# undef AES_CYPHER
default:
return -EINVAL;
}
}
#endif
default:
return -EINVAL;
}
}
default:
return -EINVAL;
return -ENOTTY;
}
}
+16
View File
@@ -128,6 +128,7 @@ config CAN_NPENDINGRTR
config CAN_TXREADY
bool "can_txready interface"
default n
select SCHED_WORKQUEUE
---help---
This selection enables the can_txready() interface. This interface
is needed only for CAN hardware that supports queing of outgoing
@@ -173,6 +174,21 @@ config CAN_TXREADY
no longer full. can_txready() will then awaken the
can_write() logic and the hang condition is avoided.
choice
prompt "TX Ready Work Queue"
default CAN_TXREADY_HIPRI
depends on CAN_TXREADY
config CAN_TXREADY_LOPRI
bool "Low-priority work queue"
select SCHED_LPWORK
config CAN_TXREADY_HIPRI
bool "High-priority work queue"
select SCHED_HPWORK
endchoice # TX Ready Work Queue
config CAN_LOOPBACK
bool "CAN loopback mode"
default n
+129 -21
View File
@@ -54,6 +54,10 @@
#include <nuttx/arch.h>
#include <nuttx/can.h>
#ifdef CONFIG_CAN_TXREADY
# include <nuttx/wqueue.h>
#endif
#include <arch/irq.h>
#ifdef CONFIG_CAN
@@ -61,6 +65,37 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifdef CONFIG_CAN_TXREADY
# if !defined(CONFIG_SCHED_WORKQUEUE)
# error Work queue support required in this configuration
# undef CONFIG_CAN_TXREADY
# undef CONFIG_CAN_TXREADY_LOPRI
# undef CONFIG_CAN_TXREADY_HIPRI
# elif defined(CONFIG_CAN_TXREADY_LOPRI)
# undef CONFIG_CAN_TXREADY_HIPRI
# ifdef CONFIG_SCHED_LPWORK
# define CANWORK LPWORK
# else
# error Low priority work queue support required in this configuration
# undef CONFIG_CAN_TXREADY
# undef CONFIG_CAN_TXREADY_LOPRI
# endif
# elif defined(CONFIG_CAN_TXREADY_HIPRI)
# ifdef CONFIG_SCHED_HPWORK
# define CANWORK HPWORK
# else
# error High priority work queue support required in this configuration
# undef CONFIG_CAN_TXREADY
# undef CONFIG_CAN_TXREADY_HIPRI
# endif
# else
# error No work queue selection
# undef CONFIG_CAN_TXREADY
# endif
#endif
/* Debug ********************************************************************/
/* Non-standard debug that may be enabled just for testing CAN */
@@ -95,6 +130,9 @@ static uint8_t can_dlc2bytes(uint8_t dlc);
#if 0 /* Not used */
static uint8_t can_bytes2dlc(uint8_t nbytes);
#endif
#ifdef CONFIG_CAN_TXREADY
static void can_txready_work(FAR void *arg);
#endif
/* Character driver methods */
@@ -246,6 +284,59 @@ static uint8_t can_bytes2dlc(FAR struct sam_can_s *priv, uint8_t nbytes)
}
#endif
/****************************************************************************
* Name: can_txready_work
*
* Description:
* This function performs deferred processing from can_txready. See the
* discription of can_txready below for additionla information.
*
****************************************************************************/
#ifdef CONFIG_CAN_TXREADY
static void can_txready_work(FAR void *arg)
{
FAR struct can_dev_s *dev = (FAR struct can_dev_s *)arg;
irqstate_t flags;
int ret;
canllvdbg("xmit head: %d queue: %d tail: %d\n",
dev->cd_xmit.tx_head, dev->cd_xmit.tx_queue,
dev->cd_xmit.tx_tail);
/* Verify that the xmit FIFO is not empty. The following operations must
* be performed with interrupt disabled.
*/
flags = irqsave();
if (dev->cd_xmit.tx_head != dev->cd_xmit.tx_tail)
{
/* Send the next message in the FIFO. */
ret = can_xmit(dev);
/* If the message was successfully queued in the H/W FIFO, then
* can_txdone() should have been called. If the S/W FIFO were
* full before then there should now be free space in the S/W FIFO.
*/
if (ret >= 0)
{
/* Are there any threads waiting for space in the TX FIFO? */
if (dev->cd_ntxwaiters > 0)
{
/* Yes.. Inform them that new xmit space is available */
(void)sem_post(&dev->cd_xmit.tx_sem);
}
}
}
irqrestore(flags);
}
#endif
/****************************************************************************
* Name: can_open
*
@@ -532,12 +623,12 @@ static int can_xmit(FAR struct can_dev_s *dev)
{
DEBUGASSERT(dev->cd_xmit.tx_queue == dev->cd_xmit.tx_head);
#ifndef CONFIG_CAN_TXREADY
/* We can disable CAN TX interrupts -- unless there is a H/W FIFO. In
* that case, TX interrupts must stay enabled until the H/W FIFO is
* fully emptied.
*/
#ifndef CONFIG_CAN_TXREADY
dev_txint(dev, false);
#endif
return -EIO;
@@ -663,7 +754,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const char *buffer,
if (inactive)
{
can_xmit(dev);
(void)can_xmit(dev);
}
/* Wait for a message to be sent */
@@ -712,7 +803,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const char *buffer,
if (inactive)
{
can_xmit(dev);
(void)can_xmit(dev);
}
/* Return the number of bytes that were sent */
@@ -1036,9 +1127,11 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
* 2b. H/W TX FIFO (CONFIG_CAN_TXREADY=y) and S/W TX FIFO full
*
* In this case, the thread calling can_write() is blocked waiting for
* space in the S/W TX FIFO.
* space in the S/W TX FIFO. can_txdone() will be called, indirectly,
* from can_txready_work() running on the thread of the work queue.
*
* CAN interrupt -> can_txready() -> can_xmit() -> dev_send() -> can_txdone()
* CAN interrupt -> can_txready() -> Schedule can_txready_work()
* can_txready_work() -> can_xmit() -> dev_send() -> can_txdone()
*
* The call dev_send() should not fail in this case and the subsequent
* call to can_txdone() will make space in the S/W TX FIFO and will
@@ -1158,8 +1251,8 @@ int can_txdone(FAR struct can_dev_s *dev)
* OK on success; a negated errno on failure.
*
* Assumptions:
* Interrupts are disabled. This is required by can_xmit() which is called
* by this function.
* Interrupts are disabled. This function may execute in the context of
* and interrupt handler.
*
****************************************************************************/
@@ -1179,34 +1272,49 @@ int can_txready(FAR struct can_dev_s *dev)
if (dev->cd_xmit.tx_head != dev->cd_xmit.tx_tail)
{
/* Are there any threads waiting for space in the xmit FIFO? */
/* Is work already scheduled? */
if (dev->cd_ntxwaiters > 0)
if (work_available(&dev->cd_work))
{
/* Inform one waiter that space is now available in the S/W
* TX FIFO.
/* Yes... schedule to perform can_txready() work on the worker
* thread. Although data structures are protected by disabling
* interrupts, the can_xmit() operations may involve semaphore
* operations and, hence, should not be done at the interrupt
* level.
*/
ret = sem_post(&dev->cd_xmit.tx_sem);
ret = work_queue(CANWORK, &dev->cd_work, can_txready_work, dev, 0);
}
else
{
ret = -EBUSY;
}
}
#if 0 /* REVISIT */
/* REVISIT: Does the fact that the S/W FIFO is empty also mean that the
* H/W FIFO is also empty? If we really want this to work this way, then
* we would probably need and additional parameter to tell us if the H/W
* FIFO is empty.
*/
else
{
/* There should not be any threads waiting for space in the S/W TX
* FIFO is it is empty.
*
* REVISIT: Assertion can fire in certain race conditions, i.e, when
* all waiters have been awakened but have not yet had a chance to
* decrement cd_ntxwaiters.
*/
//DEBUGASSERT(dev->cd_ntxwaiters == 0);
#if 0 /* REVISIT */
/* When the H/W FIFO has been emptied, we can disable further TX
* interrupts.
*
* REVISIT: The fact that the S/W FIFO is empty does not mean that
* the H/W FIFO is also empty. If we really want this to work this
* way, then we would probably need and additional parameter to tell
* us if the H/W FIFO is empty.
*/
dev_txint(dev, false);
}
#endif
}
return ret;
}
+1 -1
View File
@@ -329,7 +329,7 @@ static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
buffer += dev->geo.erasesize;
}
/* Finally, handler any partial blocks after the last full erase block */
/* Finally, handle any partial blocks after the last full erase block */
if (remaining > 0)
{
+2 -3
View File
@@ -41,6 +41,7 @@
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
@@ -199,15 +200,13 @@ static ssize_t progmem_bread(FAR struct mtd_dev_s *dev, off_t startblock,
{
FAR struct progmem_dev_s *priv = (FAR struct progmem_dev_s *)dev;
FAR const uint8_t *src;
size_t offset;
/* Read the specified blocks into the provided user buffer and return
* status (The positive, number of blocks actually read or a negated
* errno).
*/
offset = startblock << priv->blkshift;
src = (FAR const uint8_t *)up_progmem_getaddress(offset);
src = (FAR const uint8_t *)up_progmem_getaddress(startblock);
memcpy(buffer, src, nblocks << priv->blkshift);
return nblocks;
}
+5 -1
View File
@@ -37,7 +37,11 @@ ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
# Include serial drivers
CSRCS += serial.c serialirq.c lowconsole.c
CSRCS += serial.c serial_io.c lowconsole.c
ifeq ($(CONFIG_SERIAL_DMA),y)
CSRCS += serial_dma.c
endif
ifeq ($(CONFIG_16550_UART),y)
CSRCS += uart_16550.c
@@ -1,8 +1,8 @@
/************************************************************************************
* drivers/serial/serialirq.c
* drivers/serial/serial_dma.c
*
* Copyright (C) 2007-2009, 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Max Neklyudov <macscomp@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -43,96 +43,10 @@
#include <stdint.h>
#include <semaphore.h>
#include <debug.h>
#include <nuttx/serial/serial.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Private Types
************************************************************************************/
/************************************************************************************
* Private Function Prototypes
************************************************************************************/
/************************************************************************************
* Private Variables
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Name: uart_dorxflowcontrol
*
* Description:
* Handle RX flow control using watermark levels or not
*
************************************************************************************/
#ifdef CONFIG_SERIAL_IFLOWCONTROL
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
static inline bool uart_dorxflowcontrol(FAR uart_dev_t *dev,
FAR struct uart_buffer_s *rxbuf,
unsigned int watermark)
{
unsigned int nbuffered;
/* How many bytes are buffered */
if (rxbuf->head >= rxbuf->tail)
{
nbuffered = rxbuf->head - rxbuf->tail;
}
else
{
nbuffered = rxbuf->size - rxbuf->tail + rxbuf->head;
}
/* Is the level now above the watermark level that we need to report? */
if (nbuffered >= watermark)
{
/* Let the lower level driver know that the watermark level has been
* crossed. It will probably activate RX flow control.
*/
if (uart_rxflowcontrol(dev, nbuffered, true))
{
/* Low-level driver activated RX flow control, exit loop now. */
return true;
}
}
return false;
}
#else
static inline bool uart_dorxflowcontrol(FAR uart_dev_t *dev,
FAR struct uart_buffer_s *rxbuf,
bool is_full)
{
/* Check if RX buffer is full and allow serial low-level driver to pause
* processing. This allows proper utilization of hardware flow control.
*/
if (is_full)
{
if (uart_rxflowcontrol(dev, rxbuf->size, true))
{
/* Low-level driver activated RX flow control, exit loop now. */
return true;
}
}
return false;
}
#endif
#endif
#ifdef CONFIG_SERIAL_DMA
/************************************************************************************
* Public Functions
@@ -146,7 +60,6 @@ static inline bool uart_dorxflowcontrol(FAR uart_dev_t *dev,
*
************************************************************************************/
#ifdef CONFIG_SERIAL_DMA
void uart_xmitchars_dma(FAR uart_dev_t *dev)
{
FAR struct uart_dmaxfer_s *xfer = &dev->dmatx;
@@ -175,7 +88,6 @@ void uart_xmitchars_dma(FAR uart_dev_t *dev)
uart_dmasend(dev);
}
#endif /* CONFIG_SERIAL_DMA */
/************************************************************************************
* Name: uart_xmitchars_done
@@ -187,7 +99,6 @@ void uart_xmitchars_dma(FAR uart_dev_t *dev)
*
************************************************************************************/
#ifdef CONFIG_SERIAL_DMA
void uart_xmitchars_done(FAR uart_dev_t *dev)
{
FAR struct uart_dmaxfer_s *xfer = &dev->dmatx;
@@ -209,7 +120,6 @@ void uart_xmitchars_done(FAR uart_dev_t *dev)
uart_datasent(dev);
}
}
#endif /* CONFIG_SERIAL_DMA */
/************************************************************************************
* Name: uart_recvchars_dma
@@ -219,12 +129,12 @@ void uart_xmitchars_done(FAR uart_dev_t *dev)
*
************************************************************************************/
#ifdef CONFIG_SERIAL_DMA
void uart_recvchars_dma(FAR uart_dev_t *dev)
{
FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
FAR struct uart_buffer_s *rxbuf = &dev->recv;
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
unsigned int nbuffered;
unsigned int watermark;
#endif
bool is_full;
@@ -245,14 +155,46 @@ void uart_recvchars_dma(FAR uart_dev_t *dev)
#ifdef CONFIG_SERIAL_IFLOWCONTROL
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
if (uart_dorxflowcontrol(dev, rxbuf, watermark))
/* How many bytes are buffered */
if (rxbuf->head >= rxbuf->tail)
{
return;
nbuffered = rxbuf->head - rxbuf->tail;
}
#else
if (uart_dorxflowcontrol(dev, rxbuf, is_full))
else
{
return;
nbuffered = rxbuf->size - rxbuf->tail + rxbuf->head;
}
/* Is the level now above the watermark level that we need to report? */
if (nbuffered >= watermark)
{
/* Let the lower level driver know that the watermark level has been
* crossed. It will probably activate RX flow control.
*/
if (uart_rxflowcontrol(dev, nbuffered, true))
{
/* Low-level driver activated RX flow control, return now. */
return;
}
}
#else
/* Check if RX buffer is full and allow serial low-level driver to pause
* processing. This allows proper utilization of hardware flow control.
*/
if (is_full)
{
if (uart_rxflowcontrol(dev, rxbuf->size, true))
{
/* Low-level driver activated RX flow control, return now. */
return;
}
}
#endif
#endif
@@ -292,7 +234,6 @@ void uart_recvchars_dma(FAR uart_dev_t *dev)
uart_dmareceive(dev);
}
#endif /* CONFIG_SERIAL_DMA */
/************************************************************************************
* Name: uart_recvchars_done
@@ -304,7 +245,6 @@ void uart_recvchars_dma(FAR uart_dev_t *dev)
*
************************************************************************************/
#ifdef CONFIG_SERIAL_DMA
void uart_recvchars_done(FAR uart_dev_t *dev)
{
FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
@@ -326,153 +266,5 @@ void uart_recvchars_done(FAR uart_dev_t *dev)
uart_datareceived(dev);
}
}
#endif /* CONFIG_SERIAL_DMA */
/************************************************************************************
* Name: uart_xmitchars
*
* Description:
* This function is called from the UART interrupt handler when an interrupt
* is received indicating that there is more space in the transmit FIFO. This
* function will send characters from the tail of the xmit buffer while the driver
* write() logic adds data to the head of the xmit buffer.
*
************************************************************************************/
void uart_xmitchars(FAR uart_dev_t *dev)
{
uint16_t nbytes = 0;
/* Send while we still have data in the TX buffer & room in the fifo */
while (dev->xmit.head != dev->xmit.tail && uart_txready(dev))
{
/* Send the next byte */
uart_send(dev, dev->xmit.buffer[dev->xmit.tail]);
nbytes++;
/* Increment the tail index */
if (++(dev->xmit.tail) >= dev->xmit.size)
{
dev->xmit.tail = 0;
}
}
/* When all of the characters have been sent from the buffer disable the TX
* interrupt.
*
* Potential bug? If nbytes == 0 && (dev->xmit.head == dev->xmit.tail) &&
* dev->xmitwaiting == true, then disabling the TX interrupt will leave
* the uart_write() logic waiting to TX to complete with no TX interrupts.
* Can that happen?
*/
if (dev->xmit.head == dev->xmit.tail)
{
uart_disabletxint(dev);
}
/* If any bytes were removed from the buffer, inform any waiters there there is
* space available.
*/
if (nbytes)
{
uart_datasent(dev);
}
}
/************************************************************************************
* Name: uart_receivechars
*
* Description:
* This function is called from the UART interrupt handler when an interrupt
* is received indicating that are bytes available in the receive fifo. This
* function will add chars to head of receive buffer. Driver read() logic will
* take characters from the tail of the buffer.
*
************************************************************************************/
void uart_recvchars(FAR uart_dev_t *dev)
{
FAR struct uart_buffer_s *rxbuf = &dev->recv;
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
unsigned int watermark;
#endif
unsigned int status;
int nexthead = rxbuf->head + 1;
uint16_t nbytes = 0;
bool is_full;
if (nexthead >= rxbuf->size)
{
nexthead = 0;
}
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
/* Pre-calcuate the watermark level that we will need to test against. */
watermark = (CONFIG_SERIAL_IFLOWCONTROL_UPPER_WATERMARK * rxbuf->size) / 100;
#endif
/* Loop putting characters into the receive buffer until there are no further
* characters to available.
*/
while (uart_rxavailable(dev))
{
is_full = (nexthead == rxbuf->tail);
char ch;
#ifdef CONFIG_SERIAL_IFLOWCONTROL
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
if (uart_dorxflowcontrol(dev, rxbuf, watermark))
{
break;
}
#else
if (uart_dorxflowcontrol(dev, rxbuf, is_full))
{
break;
}
#endif
#endif
ch = uart_receive(dev, &status);
/* If the RX buffer becomes full, then the serial data is discarded. This is
* necessary because on most serial hardware, you must read the data in order
* to clear the RX interrupt. An option on some hardware might be to simply
* disable RX interrupts until the RX buffer becomes non-FULL. However, that
* would probably just cause the overrun to occur in hardware (unless it has
* some large internal buffering).
*/
if (!is_full)
{
/* Add the character to the buffer */
rxbuf->buffer[rxbuf->head] = ch;
nbytes++;
/* Increment the head index */
rxbuf->head = nexthead;
if (++nexthead >= rxbuf->size)
{
nexthead = 0;
}
}
}
/* If any bytes were added to the buffer, inform any waiters there is new
* incoming data available.
*/
if (nbytes)
{
uart_datareceived(dev);
}
}
+232
View File
@@ -0,0 +1,232 @@
/************************************************************************************
* drivers/serial/serial_io.c
*
* Copyright (C) 2007-2009, 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <semaphore.h>
#include <debug.h>
#include <nuttx/serial/serial.h>
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: uart_xmitchars
*
* Description:
* This function is called from the UART interrupt handler when an interrupt
* is received indicating that there is more space in the transmit FIFO. This
* function will send characters from the tail of the xmit buffer while the driver
* write() logic adds data to the head of the xmit buffer.
*
************************************************************************************/
void uart_xmitchars(FAR uart_dev_t *dev)
{
uint16_t nbytes = 0;
/* Send while we still have data in the TX buffer & room in the fifo */
while (dev->xmit.head != dev->xmit.tail && uart_txready(dev))
{
/* Send the next byte */
uart_send(dev, dev->xmit.buffer[dev->xmit.tail]);
nbytes++;
/* Increment the tail index */
if (++(dev->xmit.tail) >= dev->xmit.size)
{
dev->xmit.tail = 0;
}
}
/* When all of the characters have been sent from the buffer disable the TX
* interrupt.
*
* Potential bug? If nbytes == 0 && (dev->xmit.head == dev->xmit.tail) &&
* dev->xmitwaiting == true, then disabling the TX interrupt will leave
* the uart_write() logic waiting to TX to complete with no TX interrupts.
* Can that happen?
*/
if (dev->xmit.head == dev->xmit.tail)
{
uart_disabletxint(dev);
}
/* If any bytes were removed from the buffer, inform any waiters there there is
* space available.
*/
if (nbytes)
{
uart_datasent(dev);
}
}
/************************************************************************************
* Name: uart_receivechars
*
* Description:
* This function is called from the UART interrupt handler when an interrupt
* is received indicating that are bytes available in the receive fifo. This
* function will add chars to head of receive buffer. Driver read() logic will
* take characters from the tail of the buffer.
*
************************************************************************************/
void uart_recvchars(FAR uart_dev_t *dev)
{
FAR struct uart_buffer_s *rxbuf = &dev->recv;
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
unsigned int watermark;
#endif
unsigned int status;
int nexthead = rxbuf->head + 1;
uint16_t nbytes = 0;
if (nexthead >= rxbuf->size)
{
nexthead = 0;
}
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
/* Pre-calcuate the watermark level that we will need to test against. */
watermark = (CONFIG_SERIAL_IFLOWCONTROL_UPPER_WATERMARK * rxbuf->size) / 100;
#endif
/* Loop putting characters into the receive buffer until there are no further
* characters to available.
*/
while (uart_rxavailable(dev))
{
bool is_full = (nexthead == rxbuf->tail);
char ch;
#ifdef CONFIG_SERIAL_IFLOWCONTROL
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
unsigned int nbuffered;
/* How many bytes are buffered */
if (rxbuf->head >= rxbuf->tail)
{
nbuffered = rxbuf->head - rxbuf->tail;
}
else
{
nbuffered = rxbuf->size - rxbuf->tail + rxbuf->head;
}
/* Is the level now above the watermark level that we need to report? */
if (nbuffered >= watermark)
{
/* Let the lower level driver know that the watermark level has been
* crossed. It will probably activate RX flow control.
*/
if (uart_rxflowcontrol(dev, nbuffered, true))
{
/* Low-level driver activated RX flow control, exit loop now. */
break;
}
}
#else
/* Check if RX buffer is full and allow serial low-level driver to pause
* processing. This allows proper utilization of hardware flow control.
*/
if (is_full)
{
if (uart_rxflowcontrol(dev, rxbuf->size, true))
{
/* Low-level driver activated RX flow control, exit loop now. */
break;
}
}
#endif
#endif
ch = uart_receive(dev, &status);
/* If the RX buffer becomes full, then the serial data is discarded. This is
* necessary because on most serial hardware, you must read the data in order
* to clear the RX interrupt. An option on some hardware might be to simply
* disable RX interrupts until the RX buffer becomes non-FULL. However, that
* would probably just cause the overrun to occur in hardware (unless it has
* some large internal buffering).
*/
if (!is_full)
{
/* Add the character to the buffer */
rxbuf->buffer[rxbuf->head] = ch;
nbytes++;
/* Increment the head index */
rxbuf->head = nexthead;
if (++nexthead >= rxbuf->size)
{
nexthead = 0;
}
}
}
/* If any bytes were added to the buffer, inform any waiters there is new
* incoming data available.
*/
if (nbytes)
{
uart_datareceived(dev);
}
}
+2
View File
@@ -8,6 +8,8 @@ config WL_CC3000
default n
select SPI
select ARCH_HAVE_NET
select CRYPTO
select CRYPTO_SW_AES
---help---
Enable support for the TI CC3000 Wifi Module
+1 -1
View File
@@ -38,7 +38,7 @@ ifeq ($(CONFIG_WL_CC3000),y)
# Include cc3000 drivers
CSRCS += cc3000.c cc3000_common.c cc3000drv.c evnt_handler.c hci.c netapp.c
CSRCS += nvmem.c security.c socket.c socket_imp.c wlan.c
CSRCS += nvmem.c socket.c socket_imp.c wlan.c
# Include wireless devices build support
+54 -1
View File
@@ -43,11 +43,12 @@
#include <string.h>
#include <debug.h>
#include <nuttx/crypto/aes.h>
#include <nuttx/wireless/cc3000/cc3000_common.h>
#include <nuttx/wireless/cc3000/wlan.h>
#include <nuttx/wireless/cc3000/hci.h>
#include <nuttx/wireless/cc3000/nvmem.h>
#include <nuttx/wireless/cc3000/security.h>
#include <nuttx/wireless/cc3000/evnt_handler.h>
#include "cc3000.h"
@@ -1204,6 +1205,58 @@ long wlan_smart_config_set_prefix(FAR char *cNewPrefix)
return ret;
}
/****************************************************************************
* Name: aes_read_key
*
* Description:
* Reads AES128 key from EEPROM. Reads the AES128 key from fileID #12 in
* EEPROM returns an error if the key does not exist.
*
* Input Parameters:
* key AES128 key of size 16 bytes
*
* Returned Value
* On success 0, error otherwise.
*
****************************************************************************/
#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
signed long aes_read_key(uint8_t *key)
{
signed long returnValue;
returnValue = nvmem_read(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
return returnValue;
}
#endif
/****************************************************************************
* Name: aes_write_key
*
* Description:
* Writes AES128 key from EEPROM Writes the AES128 key to fileID #12 in
* EEPROM
*
* Input Parameters:
* key AES128 key of size 16 bytes
*
* Returned Value
* On success 0, error otherwise.
*
****************************************************************************/
#if 0 //#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
signed long aes_write_key(uint8_t *key)
{
signed long returnValue;
returnValue = nvmem_write(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
return returnValue;
}
#endif
/****************************************************************************
* Name: wlan_smart_config_process
*
+56 -29
View File
@@ -51,6 +51,10 @@
#include <nuttx/fs/fs.h>
#include <nuttx/fs/ioctl.h>
#ifdef CONFIG_CAN_TXREADY
# include <nuttx/wqueue.h>
#endif
#ifdef CONFIG_CAN
/************************************************************************************
@@ -70,6 +74,12 @@
* CONFIG_CAN_LOOPBACK - A CAN driver may or may not support a loopback
* mode for testing. If the driver does support loopback mode, the setting
* will enable it. (If the driver does not, this setting will have no effect).
* CONFIG_CAN_TXREADY - Add support for the can_txready() callback. This is needed
* only for CAN hardware the supports an separate H/W TX message FIFO. The call
* back is needed to keep the S/W FIFO and the H/W FIFO in sync. Work queue
* support is needed for this feature.
* CONFIG_CAN_TXREADY_HIPRI or CONFIG_CAN_TXREADY_LOPRI - Selects which work queue
* will be used for the can_txready() processing.
*/
/* Default configuration settings that may be overridden in the NuttX configuration
@@ -405,6 +415,9 @@ struct can_dev_s
sem_t cd_closesem; /* Locks out new opens while close is in progress */
struct can_txfifo_s cd_xmit; /* Describes transmit FIFO */
struct can_rxfifo_s cd_recv; /* Describes receive FIFO */
#ifdef CONFIG_CAN_TXREADY
struct work_s cd_work; /* Use to manage can_txready() work */
#endif
/* List of pending RTR requests */
struct can_rtrwait_s cd_rtr[CONFIG_CAN_NPENDINGRTR];
FAR const struct can_ops_s *cd_ops; /* Arch-specific operations */
@@ -508,7 +521,7 @@ int can_register(FAR const char *path, FAR struct can_dev_s *dev);
int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
FAR uint8_t *data);
/****************************************************************************
/************************************************************************************
* Name: can_txdone
*
* Description:
@@ -541,8 +554,8 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
*
* 2a. H/W TX FIFO (CONFIG_CAN_TXREADY=y) and S/W TX FIFO not full
*
* This function will be back from can_xmit immediately when a new CAN
* message is added to H/W TX FIFO:
* This function will be called back from dev_send() immediately when a
* new CAN message is added to H/W TX FIFO:
*
* can_write() -> can_xmit() -> dev_send() -> can_txdone()
*
@@ -554,9 +567,11 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
* 2b. H/W TX FIFO (CONFIG_CAN_TXREADY=y) and S/W TX FIFO full
*
* In this case, the thread calling can_write() is blocked waiting for
* space in the S/W TX FIFO.
* space in the S/W TX FIFO. can_txdone() will be called, indirectly,
* from can_txready_work() running on the thread of the work queue.
*
* CAN interrupt -> can_txready() -> can_xmit() -> dev_send() -> can_txdone()
* CAN interrupt -> can_txready() -> Schedule can_txready_work()
* can_txready_work() -> can_xmit() -> dev_send() -> can_txdone()
*
* The call dev_send() should not fail in this case and the subsequent
* call to can_txdone() will make space in the S/W TX FIFO and will
@@ -570,7 +585,13 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
* Returned Value:
* OK on success; a negated errno on failure.
*
****************************************************************************/
* Assumptions:
* Interrupts are disabled. This is required by can_xmit() which is called
* by this function. Interrupts are explicitly disabled when called
* through can_write(). Interrupts are expected be disabled when called
* from the CAN interrupt handler.
*
************************************************************************************/
int can_txdone(FAR struct can_dev_s *dev);
@@ -578,37 +599,39 @@ int can_txdone(FAR struct can_dev_s *dev);
* Name: can_txready
*
* Description:
* Called from the CAN interrupt handler at the completion of a send operation.
* This interface is needed only for CAN hardware that supports queing of
* outgoing messages in a H/W FIFO.
* Called from the CAN interrupt handler at the completion of a send
* operation. This interface is needed only for CAN hardware that
* supports queing of outgoing messages in a H/W FIFO.
*
* The CAN upper half driver also supports a queue of output messages in a S/W
* FIFO. Messages are added to that queue when when can_write() is called and
* removed from the queue in can_txdone() when each TX message is complete.
* The CAN upper half driver also supports a queue of output messages in a
* S/W FIFO. Messages are added to that queue when when can_write() is
* called and removed from the queue in can_txdone() when each TX message
* is complete.
*
* After each message is added to the S/W FIFO, the CAN upper half driver will
* attempt to send the message by calling into the lower half driver. That send
* will not be performed if the lower half driver is busy, i.e., if dev_txready()
* returns false. In that case, the number of messages in the S/W FIFO can grow.
* If the S/W FIFO becomes full, then can_write() will wait for space in the
* S/W FIFO.
* After each message is added to the S/W FIFO, the CAN upper half driver
* will attempt to send the message by calling into the lower half driver.
* That send will not be performed if the lower half driver is busy, i.e.,
* if dev_txready() returns false. In that case, the number of messages in
* the S/W FIFO can grow. If the S/W FIFO becomes full, then can_write()
* will wait for space in the S/W FIFO.
*
* If the CAN hardware does not support a H/W FIFO then busy means that the
* hardware is actively sending the message and is guaranteed to become non-
* busy (i.e, dev_txready()) when the send transfer completes and can_txdone()
* is called. So the call to can_txdone() means that the transfer has
* completed and also that the hardware is ready to accept another transfer.
* If the CAN hardware does not support a H/W FIFO then busy means that
* the hardware is actively sending the message and is guaranteed to
* become non-busy (i.e, dev_txready()) when the send transfer completes
* and can_txdone() is called. So the call to can_txdone() means that the
* transfer has completed and also that the hardware is ready to accept
* another transfer.
*
* If the CAN hardware supports a H/W FIFO, can_txdone() is not called when
* the tranfer is complete, but rather when the transfer is queued in the
* H/W FIFO. When the H/W FIFO becomes full, then dev_txready() will report
* false and the number of queued messages in the S/W FIFO will grow.
* If the CAN hardware supports a H/W FIFO, can_txdone() is not called
* when the tranfer is complete, but rather when the transfer is queued in
* the H/W FIFO. When the H/W FIFO becomes full, then dev_txready() will
* report false and the number of queued messages in the S/W FIFO will grow.
*
* There is no mechanism in this case to inform the upper half driver when
* the hardware is again available, when there is again space in the H/W
* FIFO. can_txdone() will not be called again. If the S/W FIFO becomes
* full, then the upper half driver will wait for space to become available,
* but there is no event to awaken it and the driver will hang.
* full, then the upper half driver will wait for space to become
* available, but there is no event to awaken it and the driver will hang.
*
* Enabling this feature adds support for the can_txready() interface.
* This function is called from the lower half driver's CAN interrupt
@@ -622,6 +645,10 @@ int can_txdone(FAR struct can_dev_s *dev);
* Returned Value:
* OK on success; a negated errno on failure.
*
* Assumptions:
* Interrupts are disabled. This function may execute in the context of
* and interrupt handler.
*
************************************************************************************/
#ifdef CONFIG_CAN_TXREADY
+108
View File
@@ -0,0 +1,108 @@
/****************************************************************************
* include/nuttx/crypto/aes.h
*
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* Extracted from the CC3000 Host Driver Implementation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_CRYPTO_AES_H
#define __INCLUDE_NUTTX_CRYPTO_AES_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define AES128_KEY_SIZE 16
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Function Prototypes
/****************************************************************************
/****************************************************************************
* Name: aes_encrypt
*
* Description:
* AES128 encryption: Given AES128 key and 16 bytes plain text, cipher
* text of 16 bytes is computed. The AES implementation is in mode ECB
* (Electronic Code Book).
*
* Input Parameters:
* key AES128 key of size 16 bytes
* state 16 bytes of plain text and cipher text
*
* Returned Value
* None
*
****************************************************************************/
void aes_encrypt(FAR uint8_t *state, FAR const uint8_t *key);
/****************************************************************************
* Name: aes_decrypt
*
* Description:
* AES128 decryption: Given AES128 key and 16 bytes cipher text, plain
* text of 16 bytes is computed The AES implementation is in mode ECB
* (Electronic Code Book).
*
* Input Parameters:
* key AES128 key of size 16 bytes
* state 16 bytes of plain text and cipher text
*
* Returned Value
* None
*
****************************************************************************/
void aes_decrypt(FAR uint8_t *state, FAR const uint8_t *key);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __INCLUDE_NUTTX_CRYPTO_AES_H */
-142
View File
@@ -1,142 +0,0 @@
/****************************************************************************
* security.h - CC3000 Host Driver Implementation.
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_SECURITY_H
#define _INCLUDE_NUTTX_WIRELESS_CC3000_SECURITY_H
/****************************************************************************
* Included Files
****************************************************************************/
#include "nvmem.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define AES128_KEY_SIZE 16
#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Function Prototypes
/****************************************************************************
/****************************************************************************
* Name: aes_encrypt
*
* Description:
* AES128 encryption: Given AES128 key and 16 bytes plain text, cipher
* text of 16 bytes is computed. The AES implementation is in mode ECB
* (Electronic Code Book).
*
* Input Parameters:
* key AES128 key of size 16 bytes
* state 16 bytes of plain text and cipher text
*
* Returned Value
* None
*
****************************************************************************/
void aes_encrypt(uint8_t *state, uint8_t *key);
/****************************************************************************
* Name: aes_decrypt
*
* Description:
* AES128 decryption: Given AES128 key and 16 bytes cipher text, plain
* text of 16 bytes is computed The AES implementation is in mode ECB
* (Electronic Code Book).
*
* Input Parameters:
* key AES128 key of size 16 bytes
* state 16 bytes of plain text and cipher text
*
* Returned Value
* None
*
****************************************************************************/
void aes_decrypt(uint8_t *state, uint8_t *key);
/****************************************************************************
* Name: aes_read_key
*
* Description:
* Reads AES128 key from EEPROM. Reads the AES128 key from fileID #12 in
* EEPROM returns an error if the key does not exist.
*
* Input Parameters:
* key AES128 key of size 16 bytes
*
* Returned Value
* On success 0, error otherwise.
*
****************************************************************************/
signed long aes_read_key(uint8_t *key);
/****************************************************************************
* Name: aes_write_key
*
* Description:
* Writes AES128 key from EEPROM Writes the AES128 key to fileID #12 in
* EEPROM
*
* Input Parameters:
* key AES128 key of size 16 bytes
*
* Returned Value
* On success 0, error otherwise.
*
****************************************************************************/
signed long aes_write_key(uint8_t *key);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CC3000_UNENCRYPTED_SMART_CONFIG */
#endif /* _INCLUDE_NUTTX_WIRELESS_CC3000_SECURITY_H */
+34
View File
@@ -489,6 +489,40 @@ long wlan_smart_config_stop(void);
long wlan_smart_config_set_prefix(char* cNewPrefix);
/****************************************************************************
* Name: aes_read_key
*
* Description:
* Reads AES128 key from EEPROM. Reads the AES128 key from fileID #12 in
* EEPROM returns an error if the key does not exist.
*
* Input Parameters:
* key AES128 key of size 16 bytes
*
* Returned Value
* On success 0, error otherwise.
*
****************************************************************************/
signed long aes_read_key(FAR uint8_t *key);
/****************************************************************************
* Name: aes_write_key
*
* Description:
* Writes AES128 key from EEPROM Writes the AES128 key to fileID #12 in
* EEPROM
*
* Input Parameters:
* key AES128 key of size 16 bytes
*
* Returned Value
* On success 0, error otherwise.
*
****************************************************************************/
signed long aes_write_key(FAR uint8_t *key);
/****************************************************************************
* Name: wlan_smart_config_process
*