diff options
-rw-r--r-- | nuttx/ChangeLog | 11 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/lpc17xx/lpc17_lowputc.c | 4 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/lpc17xx/lpc17_serial.c | 12 | ||||
-rwxr-xr-x | nuttx/configs/lpcxpresso-lpc1768/README.txt | 70 | ||||
-rwxr-xr-x | nuttx/configs/lpcxpresso-lpc1768/include/board.h | 10 | ||||
-rwxr-xr-x | nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig | 8 | ||||
-rwxr-xr-x | nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig | 8 | ||||
-rwxr-xr-x | nuttx/configs/lpcxpresso-lpc1768/tools/flash.sh | 65 | ||||
-rw-r--r-- | nuttx/include/errno.h | 2 | ||||
-rw-r--r-- | nuttx/include/nuttx/clock.h | 24 | ||||
-rw-r--r-- | nuttx/include/sys/syscall.h | 11 | ||||
-rw-r--r-- | nuttx/sched/Makefile | 17 | ||||
-rw-r--r-- | nuttx/sched/clock_systime32.c | 83 | ||||
-rw-r--r-- | nuttx/syscall/stub_lookup.c | 1 | ||||
-rw-r--r-- | nuttx/syscall/stub_lookup.h | 1 | ||||
-rw-r--r-- | nuttx/syscall/syscall.csv | 1 |
16 files changed, 224 insertions, 104 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 875ddb834..b5e54083d 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -1673,5 +1673,16 @@ make will fail with an obscure error about not being able to stat pass2. * configs/lpcxpresso-lpc1768/nsh: Add an NSH configuration for the LPCXpresso board. + * configs/*/ld.script: Removed 'sh_link not set for section .ARM.edix' for + a few of the builds. In you have this warning, it can be removed with the + following change to the ld.script file: + + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + - __exidx_start = ABSOLUTE(.); + *(.ARM.exidx*) + - __exidx_end = ABSOLUTE(.); + } >sram + + __exidx_end = ABSOLUTE(.); diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_lowputc.c b/nuttx/arch/arm/src/lpc17xx/lpc17_lowputc.c index 83dbd709c..47746ef26 100755 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_lowputc.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_lowputc.c @@ -1,7 +1,7 @@ /************************************************************************** * arch/arm/src/lpc17xx/lpc17_lowputc.c * - * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -340,7 +340,7 @@ void lpc17_lowsetup(void) #elif defined(CONFIG_UART1_SERIAL_CONSOLE) lpc17_configgpio(GPIO_UART1_TXD); lpc17_configgpio(GPIO_UART1_RXD); -#ifdef CONFIG_UART0_FLOWCONTROL +#ifdef CONFIG_UART1_FLOWCONTROL lpc17_configgpio(GPIO_UART1_CTS); lpc17_configgpio(GPIO_UART1_DCD); lpc17_configgpio(GPIO_UART1_DSR); diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c index 63687038f..f5c20aca6 100755 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c @@ -141,12 +141,12 @@ static char g_uart1rxbuffer[CONFIG_UART1_RXBUFSIZE]; static char g_uart1txbuffer[CONFIG_UART1_TXBUFSIZE]; #endif #ifdef CONFIG_LPC17_UART2 -static char g_uart2rxbuffer[CONFIG_UART1_RXBUFSIZE]; -static char g_uart2txbuffer[CONFIG_UART1_TXBUFSIZE]; +static char g_uart2rxbuffer[CONFIG_UART2_RXBUFSIZE]; +static char g_uart2txbuffer[CONFIG_UART2_TXBUFSIZE]; #endif #ifdef CONFIG_LPC17_UART3 -static char g_uart3rxbuffer[CONFIG_UART1_RXBUFSIZE]; -static char g_uart3txbuffer[CONFIG_UART1_TXBUFSIZE]; +static char g_uart3rxbuffer[CONFIG_UART3_RXBUFSIZE]; +static char g_uart3txbuffer[CONFIG_UART3_TXBUFSIZE]; #endif /* This describes the state of the LPC17xx uart0 port. */ @@ -694,7 +694,7 @@ static inline void lpc17_uart2config(uint32_t clkdiv) /* Step 2: Enable clocking on UART */ regval = getreg32(LPC17_SYSCON_PCLKSEL1); - regval &= ~SYSCON_PCLKSEL0_UART2_MASK; + regval &= ~SYSCON_PCLKSEL1_UART2_MASK; regval |= (clkdiv << SYSCON_PCLKSEL1_UART2_SHIFT); putreg32(regval, LPC17_SYSCON_PCLKSEL1); @@ -722,7 +722,7 @@ static inline void lpc17_uart3config(uint32_t clkdiv) /* Step 2: Enable clocking on UART */ regval = getreg32(LPC17_SYSCON_PCLKSEL1); - regval &= ~SYSCON_PCLKSEL0_UART3_MASK; + regval &= ~SYSCON_PCLKSEL1_UART3_MASK; regval |= (clkdiv << SYSCON_PCLKSEL1_UART3_SHIFT); putreg32(regval, LPC17_SYSCON_PCLKSEL1); diff --git a/nuttx/configs/lpcxpresso-lpc1768/README.txt b/nuttx/configs/lpcxpresso-lpc1768/README.txt index 403864aa6..dfa875fa6 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/README.txt +++ b/nuttx/configs/lpcxpresso-lpc1768/README.txt @@ -23,7 +23,7 @@ LCPXpresso LPC1768 Board -------------------------------- --------- -------------- ---------------------
P0[0]/RD1/TXD3/SDA1 J6-9 I2C E2PROM SDA TXD3/SDA1
- P0[1]/TD1/RXD3/SCL J6-10 RXD2/SCL1
+ P0[1]/TD1/RXD3/SCL J6-10 RXD3/SCL1
P0[2]/TXD0/AD0[7] J6-21
P0[3]/RXD0/AD0[6] J6-22
P0[4]/I2SRX-CLK/RD2/CAP2.0 J6-38 CAN_RX2
@@ -45,7 +45,7 @@ LCPXpresso LPC1768 Board P0[23]/AD0[0]/I2SRX_CLK/CAP3[0] J6-15 AD0.0
P0[24]/AD0[1]/I2SRX_WS/CAP3[1] J6-16 AD0.1
P0[25]/AD0[2]/I2SRX_SDA/TXD3 J6-17 AD0.2
- P0[26]/AD0[3]/AOUT/RXD3 J6-18 AD0.3/AOUT
+ P0[26]/AD0[3]/AOUT/RXD3 J6-18 AD0.3/AOUT / RGB LED
P0[27]/SDA0/USB_SDA J6-25
P0[28]/SCL0 J6-26
P0[29]/USB_D+ J6-37 USB_D+
@@ -76,8 +76,8 @@ LCPXpresso LPC1768 Board P1[30]/VBUS/AD0[4] J6-19 AD0.4
P1[31]/SCK1/AD0[5] J6-20 AD0.5
- P2[0]/PWM1.1/TXD1 J6-42 PWM1.1
- P2[1]/PWM1.2/RXD1 J6-43 PWM1.2
+ P2[0]/PWM1.1/TXD1 J6-42 PWM1.1 / RGB LED / RS422 RX
+ P2[1]/PWM1.2/RXD1 J6-43 PWM1.2 / OLED voltage / RGB LED
P2[2]/PWM1.3/CTS1/TRACEDATA[3] J6-44 PWM1.3
P2[3]/PWM1.4/DCD1/TRACEDATA[2] J6-45 PWM1.4
P2[4]/PWM1.5/DSR1/TRACEDATA[1] J6-46 PWM1.5
@@ -321,44 +321,30 @@ LEDs - configs/lpcxpresso-lpc1768/src/up_leds.c - LED control logic.
- The LPCXpresso has 3 LEDs... two on the Babel CAN board and a "heartbeat" LED."
- The LEDs on the Babel CAN board are capabl of OFF/GREEN/RED/AMBER status.
- In normal usage, the two LEDs on the Babel CAN board would show CAN status, but if
- CONFIG_ARCH_LEDS is defined, these LEDs will be controlled as follows for NuttX
- debug functionality (where NC means "No Change").
-
- During the boot phases. LED1 and LED2 will show boot status.
-
- /* LED1 LED2 HEARTBEAT */
- #define LED_STARTED 0 /* OFF OFF OFF */
- #define LED_HEAPALLOCATE 1 /* GREEN OFF OFF */
- #define LED_IRQSENABLED 2 /* OFF GREEN OFF */
- #define LED_STACKCREATED 3 /* OFF OFF OFF */
-
- #define LED_INIRQ 4 /* NC NC ON (momentary) */
- #define LED_SIGNAL 5 /* NC NC ON (momentary) */
- #define LED_ASSERTION 6 /* NC NC ON (momentary) */
- #define LED_PANIC 7 /* NC NC ON (0.5Hz flashing) */
- #undef LED_IDLE /* Sleep mode indication not supported */
-
- After the system is booted, this logic will no longer use LEDs 1 and 2. They
- are then available for use the application software using lpc17_led1() and
- lpc17_led2():
-
- enum lpc17_ledstate_e
- {
- LPC17_LEDSTATE_OFF = 0,
- LPC17_LEDSTATE_GREEN = 1,
- LPC17_LEDSTATE_RED = 2,
- LPC17_LEDSTATE_AMBER = (LPC17_LEDSTATE_GREEN|LPC17_LEDSTATE_RED),
- };
-
- EXTERN void lpc17_led1(enum lpc17_ledstate_e state);
- EXTERN void lpc17_led2(enum lpc17_ledstate_e state);
-
- The heartbeat LED is illuminated during all interrupt and signal procressing.
- Normally, it will glow dimly to inicate that the LPC17xx is taking interrupts.
- On an assertion PANIC, it will flash at 1Hz.
+ The LPCXpresso LPC1768 has a single LEDs (there are more on the Embedded Artists
+ base board, but those are not controlled by NuttX). Usage this single LED by NuttX
+ is as follows:
+
+ - The LED is not illuminated until the LPCXpresso completes initialization.
+
+ If the LED is stuck in the OFF state, this means that the LPCXpresso did not
+ complete intialization.
+
+ - Each time the OS enters an interrupt (or a signal) it will turn the LED OFF and
+ restores its previous stated upon return from the interrupt (or signal).
+
+ The normal state, after initialization will be a dull glow. The brightness of
+ the glow will be inversely related to the proportion of time spent within interrupt
+ handling logic. The glow may decrease in brightness when the system is very
+ busy handling device interrupts and increase in brightness as the system becomes
+ idle.
+
+ Stuck in the OFF state suggests that that the system never completed
+ initialization; Stuck in the ON state would indicated that the system
+ intialialized, but is not takint interrupts.
+
+ - If a fatal assertion or a fatal unhandled exception occurs, the LED will flash
+ strongly as a slow, 1Hz rate.
LPCXpresso Configuration Options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/nuttx/configs/lpcxpresso-lpc1768/include/board.h b/nuttx/configs/lpcxpresso-lpc1768/include/board.h index 5229c1732..b2b3dcaa6 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/include/board.h +++ b/nuttx/configs/lpcxpresso-lpc1768/include/board.h @@ -146,7 +146,7 @@ /* Pin Description Connector On Board Base Board * -------------------------------- --------- -------------- --------------------- * P0[0]/RD1/TXD3/SDA1 J6-9 I2C E2PROM SDA TXD3/SDA1 - * P0[1]/TD1/RXD3/SCL J6-10 RXD2/SCL1 + * P0[1]/TD1/RXD3/SCL J6-10 RXD3/SCL1 * P0[2]/TXD0/AD0[7] J6-21 * P0[3]/RXD0/AD0[6] J6-22 * P0[4]/I2SRX-CLK/RD2/CAP2.0 J6-38 CAN_RX2 @@ -168,14 +168,16 @@ * P0[23]/AD0[0]/I2SRX_CLK/CAP3[0] J6-15 AD0.0 * P0[24]/AD0[1]/I2SRX_WS/CAP3[1] J6-16 AD0.1 * P0[25]/AD0[2]/I2SRX_SDA/TXD3 J6-17 AD0.2 - * P0[26]/AD0[3]/AOUT/RXD3 J6-18 AD0.3/AOUT + * P0[26]/AD0[3]/AOUT/RXD3 J6-18 AD0.3/AOUT / RGB LED * P0[27]/SDA0/USB_SDA J6-25 * P0[28]/SCL0 J6-26 * P0[29]/USB_D+ J6-37 USB_D+ * P0[30]/USB_D- J6-36 USB_D- */ +#define GPIO_UART3_TXD GPIO_UART3_TXD_1 #define GPIO_I2C1_SDA GPIO_I2C1_SDA_1 +#define GPIO_UART3_RXD GPIO_UART3_RXD_1 #define GPIO_I2C1_SCL GPIO_I2C1_SCL_1 #define GPIO_SSP1_SCK GPIO_SSP1_SCK_1 #define GPIO_UART2_TXD GPIO_UART2_TXD_1 @@ -216,8 +218,8 @@ #define GPIO_ENET_MDC GPIO_ENET_MDC_1 #define GPIO_ENET_MDIO GPIO_ENET_MDIO_1 -/* P2[0]/PWM1.1/TXD1 J6-42 PWM1.1 - * P2[1]/PWM1.2/RXD1 J6-43 PWM1.2 +/* P2[0]/PWM1.1/TXD1 J6-42 PWM1.1 / RGB LED / RS422 RX + * P2[1]/PWM1.2/RXD1 J6-43 PWM1.2 / RGB LED / RS422 RX * P2[2]/PWM1.3/CTS1/TRACEDATA[3] J6-44 PWM1.3 * P2[3]/PWM1.4/DCD1/TRACEDATA[2] J6-45 PWM1.4 * P2[4]/PWM1.5/DSR1/TRACEDATA[1] J6-46 PWM1.5 diff --git a/nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig b/nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig index 6cc69bbd0..fbcceabfe 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig +++ b/nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig @@ -108,10 +108,10 @@ CONFIG_LPC17_ETHERNET=y CONFIG_LPC17_USBHOST=n CONFIG_LPC17_USBOTG=n CONFIG_LPC17_USBDEV=n -CONFIG_LPC17_UART0=y +CONFIG_LPC17_UART0=n CONFIG_LPC17_UART1=n CONFIG_LPC17_UART2=n -CONFIG_LPC17_UART3=n +CONFIG_LPC17_UART3=y CONFIG_LPC17_CAN1=n CONFIG_LPC17_CAN2=n CONFIG_LPC17_SPI=n @@ -148,10 +148,10 @@ CONFIG_LPC17_GPDMA=n # CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity # CONFIG_UARTn_2STOP - Two stop bits # -CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_UART0_SERIAL_CONSOLE=n CONFIG_UART1_SERIAL_CONSOLE=n CONFIG_UART2_SERIAL_CONSOLE=n -CONFIG_UART3_SERIAL_CONSOLE=n +CONFIG_UART3_SERIAL_CONSOLE=y CONFIG_UART0_TXBUFSIZE=256 CONFIG_UART1_TXBUFSIZE=256 diff --git a/nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig b/nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig index 3753766d4..d711f7eb1 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig +++ b/nuttx/configs/lpcxpresso-lpc1768/ostest/defconfig @@ -108,10 +108,10 @@ CONFIG_LPC17_ETHERNET=n CONFIG_LPC17_USBHOST=n CONFIG_LPC17_USBOTG=n CONFIG_LPC17_USBDEV=n -CONFIG_LPC17_UART0=y +CONFIG_LPC17_UART0=n CONFIG_LPC17_UART1=n CONFIG_LPC17_UART2=n -CONFIG_LPC17_UART3=n +CONFIG_LPC17_UART3=y CONFIG_LPC17_CAN1=n CONFIG_LPC17_CAN2=n CONFIG_LPC17_SPI=n @@ -148,10 +148,10 @@ CONFIG_LPC17_GPDMA=n # CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity # CONFIG_UARTn_2STOP - Two stop bits # -CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_UART0_SERIAL_CONSOLE=n CONFIG_UART1_SERIAL_CONSOLE=n CONFIG_UART2_SERIAL_CONSOLE=n -CONFIG_UART3_SERIAL_CONSOLE=n +CONFIG_UART3_SERIAL_CONSOLE=y CONFIG_UART0_TXBUFSIZE=256 CONFIG_UART1_TXBUFSIZE=256 diff --git a/nuttx/configs/lpcxpresso-lpc1768/tools/flash.sh b/nuttx/configs/lpcxpresso-lpc1768/tools/flash.sh index 4d9f0b777..6d3f890a7 100755 --- a/nuttx/configs/lpcxpresso-lpc1768/tools/flash.sh +++ b/nuttx/configs/lpcxpresso-lpc1768/tools/flash.sh @@ -44,34 +44,32 @@ echo " - LPC17xx" echo "" echo "You will need to edit this is any of the above are false" -# This is the default install location for binaries on Linux -#BINDIR=/usr/local/LPCXpresso/bin/dfu-util - # This is the default install location for binaries on Windows (note that this -# path could change with the Code Red version number -BINDIR=/cygdrive/c/nxp/lpcxpresso_3.6/bin - -# This is the default install location for DFUAPP.exe on Windows -DFUAPP="$BINDIR/DFUAPP.exe" - -# ROM image for resetting LPC-Link -# ROM=LPCXpressoWIN.enc # WinUSB -# ROM=LPCXpressoFS.enc # Win2000 -# ROM=LPCXpressoFS.enc # WinXP -# ROM=LPCXpressoFS.enc # Win2003 -# ROM=LPCXpressoHS.enc # WinVista -ROM=LPCXpressoHS.enc # Win7 - -ROMPATH=`cygpath -w "$BINDIR/$ROM"` - -# FLASHUTIL="$BINDIR/crt_emu_lpc11_13" # for LPC11xx or LPC13xx parts) -FLASHUTIL="$BINDIR/crt_emu_cm3_nxp" # for LPC17xx parts -# FLASHUTIL="$BINDIR/crt_emu_a7_nxp" # for LPC21/22/23/24 parts) -# FLASHUTIL="$BINDIR/crt_emu_a9_nxp" # for LPC31/32 and LPC29xx parts) -# FLASHUTIL="$BINDIR/crt_emu_cm3_lmi" # for TI Stellaris LM3S parts - -if [ ! -x "$FLASHUTIL" ]; then - echo "No executable file at ${FLASHUTIL}" +# path could change with the Code Red version number) +BINDIR="/cygdrive/c/nxp/lpcxpresso_3.6/bin" +if [ ! -d "${BINDIR}" ]; then + echo "Directory ${BINDIR} does not exist" + exit 1 +fi + +# This is the relative path to the booLPCXpresso utility +BOOTLPC="Scripts/bootLPCXpresso.cmd" +if [ ! -x "${BINDIR}/$BOOTLPC" ]; then + echo "No executable at ${BINDIR}/${BOOTLPC}" + exit 1 +fi + +# BOOTLPC_ARG=winusb # WinXP +BOOTLPC_ARG=hid # Win7 + +# FLASHUTIL="crt_emu_lpc11_13" # for LPC11xx or LPC13xx parts) +FLASHUTIL="crt_emu_cm3_nxp" # for LPC17xx parts +# FLASHUTIL="crt_emu_a7_nxp" # for LPC21/22/23/24 parts) +# FLASHUTIL="crt_emu_a9_nxp" # for LPC31/32 and LPC29xx parts) +# FLASHUTIL="crt_emu_cm3_lmi" # for TI Stellaris LM3S parts + +if [ ! -x "${BINDIR}/${FLASHUTIL}" ]; then + echo "No executable file at ${BINDIR}/${FLASHUTIL}" exit 1 fi @@ -79,10 +77,9 @@ fi # WIRE="-wire=hi" # for RDB1768v2 without upgraded firmware) # WIRE="-wire=winusb" # for RDB1768v2 with upgraded firmware) # WIRE="-wire=winusb" # for LPC-Link on Windows XP) -WIRE="-wire=hid" # for LPC-Link on Windows Vista/ Windows 7) +WIRE="-wire=hid" # for LPC-Link on Windows Vista/Windows 7) TARGET=LPC1768 -#TARGET=NXP_dir_part_LPC17 # The nuttx directory must be provided as an argument @@ -115,13 +112,15 @@ else mv ${NUTTX}/nuttx ${NUTTX}/nuttx.axf fi fi +NUTTXPATH=`cygpath -w "${NUTTX}/nuttx.axf"` # First of all boot the LPC-Link using the script: -#${DFUAPP} /f ${ROMPATH} /tl 250 dfuapp.log +cd ${BINDIR} || \ + { echo "Failed to CD to ${BINDIR}"; exit 1; } +./${BOOTLPC} ${BOOTLPC_ARG} || \ + { echo "'${BOOTLPC} ${BOOTLPC_ARG}' Failed"; } # Then program the FLASH -#${FLASHUTIL} ${WIRE} -p${TARGET} -flash-load="${NUTTX}/nuttx.axf" -${FLASHUTIL} -p${TARGET} -flash-load="${NUTTX}/nuttx.axf" - +./${FLASHUTIL} ${WIRE} -p${TARGET} -flash-load-exec="${NUTTXPATH}" diff --git a/nuttx/include/errno.h b/nuttx/include/errno.h index d0c80975a..94a8b669c 100644 --- a/nuttx/include/errno.h +++ b/nuttx/include/errno.h @@ -346,7 +346,7 @@ extern "C" { #define EXTERN extern #endif -/* Return a pointer to the thread specifid errno. NOTE: When doing a +/* Return a pointer to the thread specific errno. NOTE: When doing a * kernel-/user-mode build, this function can only be used within the * kernel-mode space. * diff --git a/nuttx/include/nuttx/clock.h b/nuttx/include/nuttx/clock.h index 68f3a46f2..3cd3e36f8 100644 --- a/nuttx/include/nuttx/clock.h +++ b/nuttx/include/nuttx/clock.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/clock.h * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -96,15 +96,24 @@ #define TICK2DSEC(tick) (((tick)+(TICK_PER_DSEC/2))/TICK_PER_DSEC) /* Rounds */ #define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */ - /**************************************************************************** * Global Data ****************************************************************************/ /* Access to raw system clock ***********************************************/ +/* Direct access to the system timer/counter is supported only if (1) the + * system clock is not disabled and (2) the executation environement has + * direct access to kernel global data. + * + * The code in this execution context can access the kernel global data + * directly if: (1) this is an un-protected, non-kernel build, or (2) + * this code is being built for execution within the kernel. + */ -#ifndef CONFIG_DISABLE_CLOCK +#if !defined(CONFIG_DISABLE_CLOCK) && \ + (!defined(CONFIG_NUTTX_KERNEL) || defined(__KERNEL__)) extern volatile uint32_t g_system_timer; +#define os_systime32() g_system_timer #endif /**************************************************************************** @@ -122,6 +131,15 @@ extern "C" { #define EXTERN extern #endif +/* If direct access to the system timer/counter is not supported (see above), + * then the value can be obtained via os_systime32 through a system call. + */ + +#if !defined(CONFIG_DISABLE_CLOCK) && \ + defined(CONFIG_NUTTX_KERNEL) && !defined(__KERNEL__) +EXTERN uint32_t os_systime32(void); +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/nuttx/include/sys/syscall.h b/nuttx/include/sys/syscall.h index d1f123bd8..1f1e37f36 100644 --- a/nuttx/include/sys/syscall.h +++ b/nuttx/include/sys/syscall.h @@ -134,11 +134,12 @@ */ #ifndef CONFIG_DISABLE_CLOCK -# define SYS_clock_getres (__SYS_clock+0) -# define SYS_clock_gettime (__SYS_clock+1) -# define SYS_clock_settime (__SYS_clock+2) -# define SYS_gettimeofday (__SYS_clock+3) -# define __SYS_timers (__SYS_clock+4) +# define SYS_os_systime32 (__SYS_clock+0) +# define SYS_clock_getres (__SYS_clock+1) +# define SYS_clock_gettime (__SYS_clock+2) +# define SYS_clock_settime (__SYS_clock+3) +# define SYS_gettimeofday (__SYS_clock+4) +# define __SYS_timers (__SYS_clock+5) #else # define __SYS_timers __SYS_clock #endif diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile index 93807b695..9cd8e5588 100644 --- a/nuttx/sched/Makefile +++ b/nuttx/sched/Makefile @@ -54,9 +54,11 @@ SCHED_SRCS = sched_setparam.c sched_setpriority.c sched_getparam.c \ sched_setscheduler.c sched_getscheduler.c \ sched_yield.c sched_rrgetinterval.c sched_foreach.c \ sched_lock.c sched_unlock.c sched_lockcount.c sched_self.c + ifeq ($(CONFIG_PRIORITY_INHERITANCE),y) SCHED_SRCS += sched_reprioritize.c endif + ifeq ($(CONFIG_SCHED_WAITPID),y) SCHED_SRCS += sched_waitpid.c endif @@ -73,10 +75,15 @@ TIME_SRCS = sched_processtimer.c ifneq ($(CONFIG_DISABLE_SIGNALS),y) TIME_SRCS += sleep.c usleep.c endif + CLOCK_SRCS = clock_initialize.c clock_settime.c clock_gettime.c clock_getres.c \ clock_time2ticks.c clock_abstime2ticks.c clock_ticks2time.c \ clock_gettimeofday.c +ifeq ($(CONFIG_NUTTX_KERNEL),y) +CLOCK_SRCS += clock_systime32.c +endif + SIGNAL_SRCS = sig_initialize.c \ sig_action.c sig_procmask.c sig_pending.c sig_suspend.c \ sig_kill.c sig_queue.c sig_waitinfo.c sig_timedwait.c \ @@ -88,9 +95,11 @@ SIGNAL_SRCS = sig_initialize.c \ MQUEUE_SRCS = mq_open.c mq_close.c mq_unlink.c mq_send.c mq_timedsend.c\ mq_sndinternal.c mq_receive.c mq_timedreceive.c mq_rcvinternal.c \ mq_initialize.c mq_descreate.c mq_findnamed.c mq_msgfree.c mq_msgqfree.c + ifneq ($(CONFIG_DISABLE_SIGNALS),y) MQUEUE_SRCS += mq_waitirq.c endif + ifneq ($(CONFIG_DISABLE_SIGNALS),y) MQUEUE_SRCS += mq_notify.c endif @@ -106,15 +115,18 @@ PTHREAD_SRCS = pthread_create.c pthread_exit.c pthread_join.c pthread_detach.c \ pthread_keycreate.c pthread_setspecific.c pthread_getspecific.c pthread_keydelete.c \ pthread_initialize.c pthread_completejoin.c pthread_findjoininfo.c \ pthread_removejoininfo.c pthread_once.c pthread_setschedprio.c + ifneq ($(CONFIG_DISABLE_SIGNALS),y) PTHREAD_SRCS += pthread_condtimedwait.c pthread_kill.c pthread_sigmask.c endif SEM_SRCS = sem_initialize.c sem_destroy.c sem_open.c sem_close.c sem_unlink.c \ sem_wait.c sem_trywait.c sem_post.c sem_findnamed.c + ifneq ($(CONFIG_DISABLE_SIGNALS),y) SEM_SRCS += sem_waitirq.c endif + ifeq ($(CONFIG_PRIORITY_INHERITANCE),y) SEM_SRCS += sem_holder.c endif @@ -143,18 +155,23 @@ CSRCS = $(MISC_SRCS) $(TSK_SRCS) $(SCHED_SRCS) $(WDOG_SRCS) $(TIME_SRCS) \ ifneq ($(CONFIG_DISABLE_CLOCK),y) CSRCS += $(CLOCK_SRCS) endif + ifneq ($(CONFIG_DISABLE_PTHREAD),y) CSRCS += $(PTHREAD_SRCS) endif + ifneq ($(CONFIG_DISABLE_SIGNALS),y) CSRCS += $(SIGNAL_SRCS) endif + ifneq ($(CONFIG_DISABLE_MQUEUE),y) CSRCS += $(MQUEUE_SRCS) endif + ifneq ($(CONFIG_DISABLE_ENVIRON),y) CSRCS += $(ENV_SRCS) endif + ifeq ($(CONFIG_NUTTX_KERNEL),y) CSRCS += $(KMM_SRCS) endif diff --git a/nuttx/sched/clock_systime32.c b/nuttx/sched/clock_systime32.c new file mode 100644 index 000000000..f8709e551 --- /dev/null +++ b/nuttx/sched/clock_systime32.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * sched/clock_systime32.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdint.h> +#include <nuttx/clock.h> + +#if !defined(CONFIG_DISABLE_CLOCK) && \ + defined(CONFIG_NUTTX_KERNEL) && !defined(__KERNEL__) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#undef os_systime32 + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Function: os_systime32 + * + * Description: + * Return the current value of the system timer counter + * + * Parameters: + * None + * + * Return Value: + * The current value of the system timer counter + * + * Assumptions: + * + ****************************************************************************/ + +uint32_t os_systime32(void) +{ + return g_system_timer; +} +#endif + diff --git a/nuttx/syscall/stub_lookup.c b/nuttx/syscall/stub_lookup.c index 8743e2fda..e46127b14 100644 --- a/nuttx/syscall/stub_lookup.c +++ b/nuttx/syscall/stub_lookup.c @@ -107,6 +107,7 @@ extern uintptr_t STUB_usleep(uintptr_t parm1); * NuttX configuration. */ +extern uintptr_t STUB_os_systime32(void); extern uintptr_t STUB_clock_getres(uintptr_t parm1, uintptr_t parm2); extern uintptr_t STUB_clock_gettime(uintptr_t parm1, uintptr_t parm2); extern uintptr_t STUB_clock_settime(uintptr_t parm1, uintptr_t parm2); diff --git a/nuttx/syscall/stub_lookup.h b/nuttx/syscall/stub_lookup.h index 31b4c755d..9a56d0d41 100644 --- a/nuttx/syscall/stub_lookup.h +++ b/nuttx/syscall/stub_lookup.h @@ -102,6 +102,7 @@ STUB_LOOKUP(3, STUB_up_assert_code) /* SYS_up_assert_code */ */ #ifndef CONFIG_DISABLE_CLOCK + STUB_LOOKUP(0, STUB_os_systime32) /* SYS_os_systime32 */ STUB_LOOKUP(2, STUB_clock_getres) /* SYS_clock_getres */ STUB_LOOKUP(2, STUB_clock_gettime) /* SYS_clock_gettime */ STUB_LOOKUP(2, STUB_clock_settime) /* SYS_clock_settime */ diff --git a/nuttx/syscall/syscall.csv b/nuttx/syscall/syscall.csv index 2510f87d8..a6db07397 100644 --- a/nuttx/syscall/syscall.csv +++ b/nuttx/syscall/syscall.csv @@ -39,6 +39,7 @@ "open","fcntl.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","int","..." "opendir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR DIR*","FAR const char*" "pipe","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int [2]|int*" +"os_systime32","nuttx/clock.h","!defined(CONFIG_DISABLE_CLOCK)","uint32_t" "poll","poll.h","!defined(CONFIG_DISABLE_POLL) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","FAR struct pollfd*","nfds_t","int" "pthread_barrier_destroy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_barrier_t*" "pthread_barrier_init","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_barrier_t*","FAR const pthread_barrierattr_t*","unsigned int" |