From 2e6908b384a475898f2ba10b740eeb7872cc9b24 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 27 Apr 2017 16:58:30 -0600 Subject: [PATCH] IOCTLS. Separate wireless character driver IOCTL commands from wireless network driver IOCTL commands. Move from wireless.h to ioctl.h. --- arch/arm/src/stm32f0/chip/stm32f0_flash.h | 2 +- configs/nucleo-f4x1re/src/stm32_wireless.c | 1 - configs/nucleo-l476rg/src/stm32_cc3000.c | 1 - configs/spark/src/stm32_cc3000.c | 1 - drivers/wireless/cc3000/cc3000.c | 2 +- drivers/wireless/cc3000/cc3000.h | 3 +- drivers/wireless/nrf24l01.h | 1 - include/nuttx/fs/ioctl.h | 47 ++++---- include/nuttx/wireless/cc3000.h | 2 +- .../wireless/cc3000/include/cc3000_upif.h | 1 - include/nuttx/wireless/ioctl.h | 108 ++++++++++++++++++ include/nuttx/wireless/nrf24l01.h | 2 +- include/nuttx/wireless/wireless.h | 49 +------- 13 files changed, 147 insertions(+), 73 deletions(-) create mode 100644 include/nuttx/wireless/ioctl.h diff --git a/arch/arm/src/stm32f0/chip/stm32f0_flash.h b/arch/arm/src/stm32f0/chip/stm32f0_flash.h index 9a6e668346..82a9442156 100644 --- a/arch/arm/src/stm32f0/chip/stm32f0_flash.h +++ b/arch/arm/src/stm32f0/chip/stm32f0_flash.h @@ -1,5 +1,5 @@ /************************************************************************************ - * arch/arm/src/stm32/chip/stm32fo_flash.h + * arch/arm/src/stm32/chip/stm32f0_flash.h * * Copyright (C) 20017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/configs/nucleo-f4x1re/src/stm32_wireless.c b/configs/nucleo-f4x1re/src/stm32_wireless.c index c5012f0438..b868cad46c 100644 --- a/configs/nucleo-f4x1re/src/stm32_wireless.c +++ b/configs/nucleo-f4x1re/src/stm32_wireless.c @@ -47,7 +47,6 @@ #include #include -#include #include #include diff --git a/configs/nucleo-l476rg/src/stm32_cc3000.c b/configs/nucleo-l476rg/src/stm32_cc3000.c index d1c94b338e..ac935e929f 100644 --- a/configs/nucleo-l476rg/src/stm32_cc3000.c +++ b/configs/nucleo-l476rg/src/stm32_cc3000.c @@ -47,7 +47,6 @@ #include #include -#include #include #include diff --git a/configs/spark/src/stm32_cc3000.c b/configs/spark/src/stm32_cc3000.c index 7f384213e4..92d255d6d9 100644 --- a/configs/spark/src/stm32_cc3000.c +++ b/configs/spark/src/stm32_cc3000.c @@ -47,7 +47,6 @@ #include #include -#include #include #include diff --git a/drivers/wireless/cc3000/cc3000.c b/drivers/wireless/cc3000/cc3000.c index dfb312fb68..6f335c99fd 100644 --- a/drivers/wireless/cc3000/cc3000.c +++ b/drivers/wireless/cc3000/cc3000.c @@ -73,7 +73,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/wireless/cc3000/cc3000.h b/drivers/wireless/cc3000/cc3000.h index ddcd4f5163..d969a1e5f6 100644 --- a/drivers/wireless/cc3000/cc3000.h +++ b/drivers/wireless/cc3000/cc3000.h @@ -53,9 +53,10 @@ #include #include #include + #include #include -#include +#include #include #include diff --git a/drivers/wireless/nrf24l01.h b/drivers/wireless/nrf24l01.h index caaf67f566..108591feea 100644 --- a/drivers/wireless/nrf24l01.h +++ b/drivers/wireless/nrf24l01.h @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/include/nuttx/fs/ioctl.h b/include/nuttx/fs/ioctl.h index ce31d599ce..674eafc1d7 100644 --- a/include/nuttx/fs/ioctl.h +++ b/include/nuttx/fs/ioctl.h @@ -68,25 +68,26 @@ #define _QEIOCBASE (0x0f00) /* Quadrature encoder ioctl commands */ #define _AUDIOIOCBASE (0x1000) /* Audio ioctl commands */ #define _SLCDIOCBASE (0x1100) /* Segment LCD ioctl commands */ -#define _WLIOCBASE (0x1200) /* Wireless modules ioctl commands */ -#define _CFGDIOCBASE (0x1300) /* Config Data device (app config) ioctl commands */ -#define _TCIOCBASE (0x1400) /* Timer ioctl commands */ -#define _DJOYBASE (0x1500) /* Discrete joystick ioctl commands */ -#define _AJOYBASE (0x1600) /* Analog joystick ioctl commands */ -#define _PIPEBASE (0x1700) /* FIFO/pipe ioctl commands */ -#define _RTCBASE (0x1800) /* RTC ioctl commands */ -#define _RELAYBASE (0x1900) /* Relay devices ioctl commands */ -#define _CANBASE (0x1a00) /* CAN ioctl commands */ -#define _BTNBASE (0x1b00) /* Button ioctl commands */ -#define _ULEDBASE (0x1c00) /* User LED ioctl commands */ -#define _ZCBASE (0x1d00) /* Zero Cross ioctl commands */ -#define _LOOPBASE (0x1e00) /* Loop device commands */ -#define _MODEMBASE (0x1f00) /* Modem ioctl commands */ -#define _I2CBASE (0x2000) /* I2C driver commands */ -#define _SPIBASE (0x2100) /* SPI driver commands */ -#define _GPIOBASE (0x2200) /* GPIO driver commands */ -#define _CLIOCBASE (0x2300) /* Contactless modules ioctl commands */ -#define _USBCBASE (0x2400) /* USB-C controller ioctl commands */ +#define _WLIOCBASE (0x1200) /* Wireless modules ioctl network commands */ +#define _WLCIOCBASE (0x1300) /* Wireless modules ioctl character driver commands */ +#define _CFGDIOCBASE (0x1400) /* Config Data device (app config) ioctl commands */ +#define _TCIOCBASE (0x1500) /* Timer ioctl commands */ +#define _DJOYBASE (0x1600) /* Discrete joystick ioctl commands */ +#define _AJOYBASE (0x1700) /* Analog joystick ioctl commands */ +#define _PIPEBASE (0x1800) /* FIFO/pipe ioctl commands */ +#define _RTCBASE (0x1900) /* RTC ioctl commands */ +#define _RELAYBASE (0x1a00) /* Relay devices ioctl commands */ +#define _CANBASE (0x1b00) /* CAN ioctl commands */ +#define _BTNBASE (0x1c00) /* Button ioctl commands */ +#define _ULEDBASE (0x1d00) /* User LED ioctl commands */ +#define _ZCBASE (0x1e00) /* Zero Cross ioctl commands */ +#define _LOOPBASE (0x1f00) /* Loop device commands */ +#define _MODEMBASE (0x2000) /* Modem ioctl commands */ +#define _I2CBASE (0x2100) /* I2C driver commands */ +#define _SPIBASE (0x2200) /* SPI driver commands */ +#define _GPIOBASE (0x2300) /* GPIO driver commands */ +#define _CLIOCBASE (0x2400) /* Contactless modules ioctl commands */ +#define _USBCBASE (0x2500) /* USB-C controller ioctl commands */ /* boardctl() commands share the same number space */ @@ -294,12 +295,18 @@ #define _SLCDIOCVALID(c) (_IOC_TYPE(c)==_SLCDIOCBASE) #define _SLCDIOC(nr) _IOC(_SLCDIOCBASE,nr) -/* Wireless driver ioctl definitions ****************************************/ +/* Wireless driver networki ioctl definitions *******************************/ /* (see nuttx/include/wireless/wireless.h */ #define _WLIOCVALID(c) (_IOC_TYPE(c)==_WLIOCBASE) #define _WLIOC(nr) _IOC(_WLIOCBASE,nr) +/* Wireless driver character driver ioctl definitions ***********************/ +/* (see nuttx/include/wireless/ioctl.h */ + +#define _WLCIOCVALID(c) (_IOC_TYPE(c)==_WLCIOCBASE) +#define _WLCIOC(nr) _IOC(_WLCIOCBASE,nr) + /* Application Config Data driver ioctl definitions *************************/ /* (see nuttx/include/configdata.h */ diff --git a/include/nuttx/wireless/cc3000.h b/include/nuttx/wireless/cc3000.h index 6aa234ed56..47348d2653 100644 --- a/include/nuttx/wireless/cc3000.h +++ b/include/nuttx/wireless/cc3000.h @@ -50,7 +50,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/include/nuttx/wireless/cc3000/include/cc3000_upif.h b/include/nuttx/wireless/cc3000/include/cc3000_upif.h index e24d572b00..e44a2cf45c 100644 --- a/include/nuttx/wireless/cc3000/include/cc3000_upif.h +++ b/include/nuttx/wireless/cc3000/include/cc3000_upif.h @@ -54,7 +54,6 @@ #include #include #include -#include #if defined(CONFIG_DRIVERS_WIRELESS) && defined(CONFIG_WL_CC3000) diff --git a/include/nuttx/wireless/ioctl.h b/include/nuttx/wireless/ioctl.h new file mode 100644 index 0000000000..f21d589f36 --- /dev/null +++ b/include/nuttx/wireless/ioctl.h @@ -0,0 +1,108 @@ +/************************************************************************************ + * include/nuttx/wireless/ioctl.h + * Wireless character driver IOCTL commands + * + * Copyright (C) 2011-2013, 2017 Gregory Nutt. All rights reserved. + * Author: Laurent Latil + * + * 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. + * + ************************************************************************************/ + +/* This file includes common definitions to be used in all wireless character drivers + * (when applicable). + */ + +#ifndef __INCLUDE_NUTTX_WIRELESS_IOCTL_H +#define __INCLUDE_NUTTX_WIRELESS_IOCTL_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include +#include + +#ifdef CONFIG_DRIVERS_WIRELESS + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +/* Character Driver IOCTL commands *************************************************/ +/* Non-compatible, NuttX only IOCTL definitions for use with low-level wireless + * drivers that are accessed via a character device. Use of these IOCTL commands + * requires a file descriptor created by the open() interface. + */ + +#define WLIOC_SETRADIOFREQ _WLCIOC(0x0001) /* arg: Pointer to uint32_t, frequency + * value (in Mhz) */ +#define WLIOC_GETRADIOFREQ _WLCIOC(0x0002) /* arg: Pointer to uint32_t, frequency + * value (in Mhz) */ +#define WLIOC_SETADDR _WLCIOC(0x0003) /* arg: Pointer to address value, format + * of the address is driver specific */ +#define WLIOC_GETADDR _WLCIOC(0x0004) /* arg: Pointer to address value, format + * of the address is driver specific */ +#define WLIOC_SETTXPOWER _WLCIOC(0x0005) /* arg: Pointer to int32_t, output power + * (in dBm) */ +#define WLIOC_GETTXPOWER _WLCIOC(0x0006) /* arg: Pointer to int32_t, output power + * (in dBm) */ + +/* Device-specific IOCTL commands **************************************************/ + +#define WL_FIRST 0x0001 /* First common command */ +#define WL_NCMDS 0x0006 /* Number of common commands */ + +/* User defined ioctl commands are also supported. These will be forwarded + * by the upper-half QE driver to the lower-half QE driver via the ioctl() + * method fo the QE lower-half interface. However, the lower-half driver + * must reserve a block of commands as follows in order prevent IOCTL + * command numbers from overlapping. + */ + +/* See include/nuttx/wireless/cc3000.h */ + +#define CC3000_FIRST (WL_FIRST + WL_NCMDS) +#define CC3000_NCMDS 7 + +/* See include/nuttx/wireless/nrf24l01.h */ + +#define NRF24L01_FIRST (CC3000_FIRST + CC3000_NCMDS) +#define NRF24L01_NCMDS 14 + +/* See include/nuttx/wireless/ieee802154/ieee802154_ioctl.h */ + +#define IEEE802154_FIRST (NRF24L01_FIRST + NRF24L01_NCMDS) +#define IEEE802154_NCMDS 2 + +/************************************************************************************ + * Public Types + ************************************************************************************/ + + #endif /* CONFIG_DRIVERS_WIRELESS */ +#endif /* __INCLUDE_NUTTX_WIRELESS_IOCTL_H */ diff --git a/include/nuttx/wireless/nrf24l01.h b/include/nuttx/wireless/nrf24l01.h index 610b3c3682..d8b37aeeab 100644 --- a/include/nuttx/wireless/nrf24l01.h +++ b/include/nuttx/wireless/nrf24l01.h @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/nuttx/wireless/wireless.h b/include/nuttx/wireless/wireless.h index a09c2bb148..b21135f2fe 100644 --- a/include/nuttx/wireless/wireless.h +++ b/include/nuttx/wireless/wireless.h @@ -1,5 +1,6 @@ /************************************************************************************ * include/nuttx/wireless/wireless.h + * Wireless network IOCTL commands * * Copyright (C) 2011-2013, 2017 Gregory Nutt. All rights reserved. * Author: Laurent Latil @@ -33,7 +34,7 @@ * ************************************************************************************/ -/* This file includes common definitions to be used in all wireless drivers +/* This file includes common definitions to be used in all wireless network drivers * (when applicable). */ @@ -153,49 +154,11 @@ #define SIOCSIWPMKSA _WLIOC(0x0032) /* PMKSA cache operation */ -#define WL_FIRSTCHAR 0x0033 -#define WL_NNETCMDS 0x0032 +/* Device-specific network IOCTL commands ******************************************/ -/* Character Driver IOCTL commands *************************************************/ -/* Non-compatible, NuttX only IOCTL definitions for use with low-level wireless - * drivers that are accessed via a character device. Use of these IOCTL commands - * requires a file descriptor created by the open() interface. - */ - -#define WLIOC_SETRADIOFREQ _WLIOC(0x0033) /* arg: Pointer to uint32_t, frequency - * value (in Mhz) */ -#define WLIOC_GETRADIOFREQ _WLIOC(0x0034) /* arg: Pointer to uint32_t, frequency - * value (in Mhz) */ -#define WLIOC_SETADDR _WLIOC(0x0035) /* arg: Pointer to address value, format - * of the address is driver specific */ -#define WLIOC_GETADDR _WLIOC(0x0036) /* arg: Pointer to address value, format - * of the address is driver specific */ -#define WLIOC_SETTXPOWER _WLIOC(0x0037) /* arg: Pointer to int32_t, output power - * (in dBm) */ -#define WLIOC_GETTXPOWER _WLIOC(0x0038) /* arg: Pointer to int32_t, output power - * (in dBm) */ - -/* Device-specific IOCTL commands **************************************************/ - -#define WL_FIRST 0x0001 /* First common command */ -#define WL_NCMDS 0x0038 /* Number of common commands */ - -/* User defined ioctl commands are also supported. These will be forwarded - * by the upper-half QE driver to the lower-half QE driver via the ioctl() - * method fo the QE lower-half interface. However, the lower-half driver - * must reserve a block of commands as follows in order prevent IOCTL - * command numbers from overlapping. - */ - -/* See include/nuttx/wireless/cc3000.h */ - -#define CC3000_FIRST (WL_FIRST + WL_NCMDS) -#define CC3000_NCMDS 7 - -/* See include/nuttx/wireless/nrf24l01.h */ - -#define NRF24L01_FIRST (CC3000_FIRST + CC3000_NCMDS) -#define NRF24L01_NCMDS 14 +#define WL_NETFIRST 0x0001 /* First network command */ +#define WL_NNETCMDS 0x0032 /* Number of network commands */ +#define WL_USERFIRST (WL_NETFIRST + WL_NNETCMDS) /* Other Common Wireless Definitions ***********************************************/