diff options
-rw-r--r-- | apps/nshlib/nsh_parse.c | 16 | ||||
-rw-r--r-- | nuttx/Makefile | 4 | ||||
-rwxr-xr-x | nuttx/configs/sam3u-ek/README.txt | 11 | ||||
-rwxr-xr-x | nuttx/configs/sam3u-ek/kernel/Makefile | 12 | ||||
-rwxr-xr-x | nuttx/configs/sam3u-ek/knsh/defconfig | 4 | ||||
-rw-r--r-- | nuttx/include/nuttx/clock.h | 68 | ||||
-rwxr-xr-x | nuttx/include/nuttx/ptimer.h (renamed from nuttx/include/nuttx/rtc.h) | 49 | ||||
-rw-r--r-- | nuttx/include/sys/syscall.h | 16 | ||||
-rw-r--r-- | nuttx/lib/time/lib_time.c | 90 | ||||
-rw-r--r-- | nuttx/sched/Makefile | 3 | ||||
-rw-r--r-- | nuttx/sched/clock_initialize.c | 77 | ||||
-rw-r--r-- | nuttx/sched/clock_systimer.c | 8 | ||||
-rw-r--r-- | nuttx/sched/clock_uptime.c | 84 | ||||
-rw-r--r-- | nuttx/syscall/stub_lookup.c | 1 | ||||
-rw-r--r-- | nuttx/syscall/stub_lookup.h | 3 | ||||
-rw-r--r-- | nuttx/syscall/syscall.csv | 1 |
16 files changed, 393 insertions, 54 deletions
diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c index fe7423f66..a4c3c893d 100644 --- a/apps/nshlib/nsh_parse.c +++ b/apps/nshlib/nsh_parse.c @@ -52,6 +52,8 @@ #include <errno.h> #include <debug.h> +#include <nuttx/version.h> + #ifndef CONFIG_NSH_DISABLEBG # include <pthread.h> #endif @@ -341,8 +343,22 @@ static const struct cmdmap_s g_cmdmap[] = * Public Data ****************************************************************************/ +/* If NuttX versioning information is available, Include that information + * in the NSH greeting. + */ + +#if CONFIG_VERSION_MAJOR != 0 || CONFIG_VERSION_MINOR != 0 +const char g_nshgreeting[] = "\nNuttShell (NSH) NuttX-" CONFIG_VERSION_STRING "\n +#else const char g_nshgreeting[] = "\nNuttShell (NSH)\n"; +#endif + +/* The NSH prompt */ + const char g_nshprompt[] = "nsh> "; + +/* Common, message formats */ + const char g_nshsyntax[] = "nsh: %s: syntax error\n"; const char g_fmtargrequired[] = "nsh: %s: missing required argument(s)\n"; const char g_fmtarginvalid[] = "nsh: %s: argument invalid\n"; diff --git a/nuttx/Makefile b/nuttx/Makefile index f7e85369f..fc8d6ac28 100644 --- a/nuttx/Makefile +++ b/nuttx/Makefile @@ -414,18 +414,22 @@ pass2: pass2deps cp -f $(BIN) /tftpboot/$(BIN).${CONFIG_ARCH}; \ fi ifeq ($(CONFIG_RRLOAD_BINARY),y) + @echo "MK: $(BIN).rr" @$(TOPDIR)/tools/mkimage.sh --Prefix $(CROSSDEV) $(BIN) $(BIN).rr @if [ -w /tftpboot ] ; then \ cp -f $(BIN).rr /tftpboot/$\(BIN).rr.$(CONFIG_ARCH); \ fi endif ifeq ($(CONFIG_INTELHEX_BINARY),y) + @echo "CP: $(BIN).ihx" @$(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) $(BIN).ihx endif ifeq ($(CONFIG_MOTOROLA_SREC),y) + @echo "CP: $(BIN).srec" @$(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) $(BIN).srec endif ifeq ($(CONFIG_RAW_BINARY),y) + @echo "CP: $(BIN).bin" @$(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(BIN).bin endif diff --git a/nuttx/configs/sam3u-ek/README.txt b/nuttx/configs/sam3u-ek/README.txt index ba8c18dad..a350c72d7 100755 --- a/nuttx/configs/sam3u-ek/README.txt +++ b/nuttx/configs/sam3u-ek/README.txt @@ -332,6 +332,17 @@ must be is one of the following: This specall make command ('make pass1 pass2') will make the dependencies separately for each pass. + At there end of the build, there four files will top-level build + directory: + + nuttx_user.elf - The pass1 ELF file + nuttx - The pass2 ELF file + nuttx_user.ihx - The pass1 Intel HEX format file + nuttx.ihx - The pass2 Intel HEX file + + The J-Link program will except files in .hex, .mot, .srec, and .bin + formats. + nsh: Configures the NuttShell (nsh) located at examples/nsh. The Configuration enables both the serial and telnetd NSH interfaces. diff --git a/nuttx/configs/sam3u-ek/kernel/Makefile b/nuttx/configs/sam3u-ek/kernel/Makefile index c51271cc3..f9903b157 100755 --- a/nuttx/configs/sam3u-ek/kernel/Makefile +++ b/nuttx/configs/sam3u-ek/kernel/Makefile @@ -71,6 +71,18 @@ nuttx_user.elf: $(TOPDIR)/nuttx_user.elf: nuttx_user.elf @echo "LD: nuttx_user.elf" @cp -a nuttx_user.elf $(TOPDIR)/nuttx_user.elf +ifeq ($(CONFIG_INTELHEX_BINARY),y) + @echo "CP: nuttx_user.ihx" + @$(OBJCOPY) $(OBJCOPYARGS) -O ihex nuttx_user.elf $(TOPDIR)/nuttx_user.ihx +endif +ifeq ($(CONFIG_MOTOROLA_SREC),y) + @echo "CP: nuttx_user.srec" + @$(OBJCOPY) $(OBJCOPYARGS) -O srec nuttx_user.elf $(TOPDIR)/nuttx_user.srec +endif +ifeq ($(CONFIG_RAW_BINARY),y) + @echo "CP: nuttx_user.bin" + @$(OBJCOPY) $(OBJCOPYARGS) -O binary nuttx_user.elf $(TOPDIR)/nuttx_user.bin +endif $(TOPDIR)/User.map: nuttx_user.elf @echo "MK: User.map" diff --git a/nuttx/configs/sam3u-ek/knsh/defconfig b/nuttx/configs/sam3u-ek/knsh/defconfig index 551817c56..677cb548a 100755 --- a/nuttx/configs/sam3u-ek/knsh/defconfig +++ b/nuttx/configs/sam3u-ek/knsh/defconfig @@ -202,9 +202,9 @@ CONFIG_USART3_2STOP=0 # CONFIG_HAVE_LIBM - toolchain supports libm.a # CONFIG_RRLOAD_BINARY=n -CONFIG_INTELHEX_BINARY=n +CONFIG_INTELHEX_BINARY=y CONFIG_MOTOROLA_SREC=n -CONFIG_RAW_BINARY=y +CONFIG_RAW_BINARY=n CONFIG_HAVE_LIBM=n # diff --git a/nuttx/include/nuttx/clock.h b/nuttx/include/nuttx/clock.h index 9a9523a2e..e06d2c0dd 100644 --- a/nuttx/include/nuttx/clock.h +++ b/nuttx/include/nuttx/clock.h @@ -41,13 +41,42 @@ ****************************************************************************/ #include <nuttx/config.h> + #include <stdint.h> +#include <time.h> /**************************************************************************** * Pro-processor Definitions ****************************************************************************/ +/* Configuration ************************************************************/ +/* Access to raw system clock ***********************************************/ +/* The system timer/counter is supported only if (1) the system clock is not + * disabled and (2) we are not configured to use a hardware periodic timer + * for system time. + */ + +#undef __HAVE_SYSTEM_COUNTER +#if !defined(CONFIG_DISABLE_CLOCK) && !defined(CONFIG_PTIMER) +# define __HAVE_SYSTEM_COUNTER 1 +#else +# define __HAVE_SYSTEM_COUNTER 0 +#endif + +/* Efficient, direct access to OS global timer variables will be supported + * if the execution environment 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. + */ + +#undef __HAVE_KERNEL_GLOBALS +#if !defined(CONFIG_NUTTX_KERNEL) || defined(__KERNEL__) +# define __HAVE_KERNEL_GLOBALS 1 +#else +# define __HAVE_KERNEL_GLOBALS 0 +#endif -/* Timing constants */ +/* Timing constants *********************************************************/ #define NSEC_PER_SEC 1000000000 #define USEC_PER_SEC 1000000 @@ -100,22 +129,30 @@ * Global Data ****************************************************************************/ +#if !defined(CONFIG_DISABLE_CLOCK) + /* 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. + * system timer counter is available (i.e., we are not configured to use + * a hardware periodic timer), and (2) the execution environment has direct + * access to kernel global data */ -#if !defined(CONFIG_DISABLE_CLOCK) && \ - (!defined(CONFIG_NUTTX_KERNEL) || defined(__KERNEL__)) +#if !defined(CONFIG_PTIMER) && __HAVE_KERNEL_GLOBALS extern volatile uint32_t g_system_timer; #define clock_systimer() g_system_timer #endif +/* System uptime (in seconds) is only supported by periodic timer hardware */ + +#if defined(CONFIG_UPTIME) +extern volatile uint32_t g_uptime; + +#if __HAVE_KERNEL_GLOBALS +# define clock_uptime() g_uptime +#endif +#endif + /**************************************************************************** * Global Function Prototypes ****************************************************************************/ @@ -131,18 +168,23 @@ 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 clock_systimer through a system call. +/* Indirect access to the system time is required if (1) we are using a + * hardware periodic timer, OR (2) the execution environment does not have + * direct access to kernel global data */ -#if !defined(CONFIG_DISABLE_CLOCK) && \ - defined(CONFIG_NUTTX_KERNEL) && !defined(__KERNEL__) +#if defined(CONFIG_PTIMER) || !__HAVE_KERNEL_GLOBALS EXTERN uint32_t clock_systimer(void); #endif +#if defined(CONFIG_UPTIME) && !__HAVE_KERNEL_GLOBALS +EXTERN time_t clock_uptime(void); +#endif + #undef EXTERN #ifdef __cplusplus } #endif +#endif /* !CONFIG_DISABLE_CLOCK */ #endif /* __NUTTX_CLOCK_H */ diff --git a/nuttx/include/nuttx/rtc.h b/nuttx/include/nuttx/ptimer.h index 7c3028053..b5b5d65ae 100755 --- a/nuttx/include/nuttx/rtc.h +++ b/nuttx/include/nuttx/ptimer.h @@ -1,5 +1,5 @@ /****************************************************************************
- * include/nuttx/rtc.h
+ * include/nuttx/ptimer.h
*
* Copyright(C) 2011 Uros Platise. All rights reserved.
* Author: Uros Platise <uros.platise@isotel.eu>
@@ -33,8 +33,8 @@ *
****************************************************************************/
-#ifndef __INCLUDE_NUTTX_RTC_H
-#define __INCLUDE_NUTTX_RTC_H
+#ifndef __INCLUDE_NUTTX_PTIMER_H
+#define __INCLUDE_NUTTX_PTIMER_H
/****************************************************************************
* Included Files
@@ -62,32 +62,32 @@ * Public Types
****************************************************************************/
-/* The type of the RTC callback function */
+/* The type of the periodic timer callback function */
-typedef void (*rtc_handler_t)(FAR void *arg);
+typedef void (*ptimer_handler_t)(FAR void *arg);
-/* The RTC vtable */
+/* The periodic timer vtable */
-struct rtc_dev_s;
-struct rtc_ops_s
+struct ptimer_dev_s;
+struct ptimer_ops_s
{
- int (*trigger)(FAR struct rtc_dev_s *dev, FAR void *arg);
- int (*add)(FAR struct rtc_dev_s *dev, FAR void *arg, clock_t period);
- int (*set)(FAR struct rtc_dev_s *dev, FAR void *arg, clock_t period);
- int (*clear)(FAR struct rtc_dev_s *dev, FAR void *arg);
- clock_t (*remainder)(FAR struct rtc_dev_s *dev, FAR void *arg);
- clock_t (*overrun)(FAR struct rtc_dev_s *dev, FAR void *arg);
- int (*exec)(FAR struct rtc_dev_s *dev, clock_t timeout);
+ int (*trigger)(FAR struct ptimer_dev_s *dev, FAR void *arg);
+ int (*add)(FAR struct ptimer_dev_s *dev, FAR void *arg, clock_t period);
+ int (*set)(FAR struct ptimer_dev_s *dev, FAR void *arg, clock_t period);
+ int (*clear)(FAR struct ptimer_dev_s *dev, FAR void *arg);
+ clock_t (*remainder)(FAR struct ptimer_dev_s *dev, FAR void *arg);
+ clock_t (*overrun)(FAR struct ptimer_dev_s *dev, FAR void *arg);
+ int (*exec)(FAR struct ptimer_dev_s *dev, clock_t timeout);
};
-/* RTC private data. This structure only defines the initial fields of the
+/* PTIMER private data. This structure only defines the initial fields of the
* structure visible to the SPI client. The specific implementation may
* add additional, device specific fields
*/
-struct rtc_dev_s
+struct ptimer_dev_s
{
- FAR const struct rtc_ops_s *ops;
+ FAR const struct ptimer_ops_s *ops;
};
/****************************************************************************
@@ -103,22 +103,21 @@ extern "C" { #endif
/****************************************************************************
- * Name: up_rtcinitialize
+ * Name: up_ptimerinitialize
*
* Description:
- * Initialize the RTC interface. This function may be called to obtain
- * multiple instances of the interface
+ * Initialize the periodic timer interface. This function may be called to
+ * obtian multiple instances of the interface
*
* Returned Value:
- * Valid RTC device structre reference on succcess; a NULL on failure
+ * Valid peridic timer device structre reference on succcess; a NULL on failure
*
****************************************************************************/
-EXTERN FAR struct rtc_dev_s *up_rtcinitialize(void);
-
+EXTERN FAR struct ptimer_dev_s *up_ptimerinitialize(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
-#endif /* __INCLUDE_NUTTX_RTC_H */
+#endif /* __INCLUDE_NUTTX_PTIMER_H */
diff --git a/nuttx/include/sys/syscall.h b/nuttx/include/sys/syscall.h index 616c39546..5c1570c53 100644 --- a/nuttx/include/sys/syscall.h +++ b/nuttx/include/sys/syscall.h @@ -135,11 +135,17 @@ #ifndef CONFIG_DISABLE_CLOCK # define SYS_clock_systimer (__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) +# define SYS_clock_uptime (__SYS_clock+1) +# define SYS_clock_getres (__SYS_clock+2) +# define SYS_clock_gettime (__SYS_clock+3) +# define SYS_clock_settime (__SYS_clock+4) +# define SYS_gettimeofday (__SYS_clock+5) +# ifdef CONFIG_UPTIME +# define SYS_clock_uptime (__SYS_clock+6) +# define __SYS_timers (__SYS_clock+7) +# else +# define __SYS_timers (__SYS_clock+6) +#endif #else # define __SYS_timers __SYS_clock #endif diff --git a/nuttx/lib/time/lib_time.c b/nuttx/lib/time/lib_time.c new file mode 100644 index 000000000..95352f133 --- /dev/null +++ b/nuttx/lib/time/lib_time.c @@ -0,0 +1,90 @@ +/**************************************************************************** + * lib/time/lib_time.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 <time.h> + +#include <nuttx/clock.h> + +#if !defined(CONFIG_DISABLE_CLOCK) && defined(CONFIG_UPTIME) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Function: time + * + * Description: + * Return the current system up-time. + * + * Parameters: + * The tloc argument points to an area where the return value is + * also stored. If tloc is a null pointer, no value is stored. + * + * Return Value: + * The current system up time + * + ****************************************************************************/ + +time_t time(time_t *tloc) +{ + /* Get the current uptime from the system */ + + time_t uptime = clock_uptime(); + + /* Return the uptime */ + + if (tloc) + { + *tloc = uptime; + } + return uptime; +} + +#endif /* !CONFIG_DISABLE_CLOCK && CONFIG_UPTIME */ diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile index 3c89a5c32..20e3522d0 100644 --- a/nuttx/sched/Makefile +++ b/nuttx/sched/Makefile @@ -82,6 +82,9 @@ CLOCK_SRCS = clock_initialize.c clock_settime.c clock_gettime.c clock_getres.c \ ifeq ($(CONFIG_NUTTX_KERNEL),y) CLOCK_SRCS += clock_systimer.c +ifeq ($(CONFIG_UPTIME),y) +CLOCK_SRCS += clock_uptime.c +endif endif SIGNAL_SRCS = sig_initialize.c \ diff --git a/nuttx/sched/clock_initialize.c b/nuttx/sched/clock_initialize.c index baddc3136..e18b819fa 100644 --- a/nuttx/sched/clock_initialize.c +++ b/nuttx/sched/clock_initialize.c @@ -43,6 +43,8 @@ #include <time.h> #include <errno.h> #include <debug.h> + +#include <nuttx/clock.h> #include <nuttx/time.h> #include "clock_internal.h" @@ -55,6 +57,12 @@ #define SEC_PER_HOUR ((time_t)60 * SEC_PER_MIN) #define SEC_PER_DAY ((time_t)24 * SEC_PER_HOUR) +#if __HAVE_SYSTEM_COUNTER +# define incr_systimer() g_system_timer++ +#else +# define incr_systimer() +#endif + /**************************************************************************** * Private Type Declarations ****************************************************************************/ @@ -71,14 +79,63 @@ * Public Variables ****************************************************************************/ -volatile uint32_t g_system_timer = 0; -struct timespec g_basetime = {0,0}; -uint32_t g_tickbias = 0; +#if __HAVE_SYSTEM_COUNTER +volatile clock_t g_system_timer = 0; +#endif + +#if CONFIG_UPTIME +volatile time_t g_uptime = 0; +#endif + +struct timespec g_basetime = {0,0}; +uint32_t g_tickbias = 0; /************************************************************************** * Private Variables **************************************************************************/ +/* This variable is used to count ticks and to increment the one-second + * uptime variable. + */ + +#if CONFIG_UPTIME +#if TICK_PER_SEC > 32767 +static uint32_t g_tickcount = 0; +#elif TICK_PER_SEC > 255 +static uint16_t g_tickcount = 0; +#else +static uint8_t g_tickcount = 0; +#endif +#endif /* CONFIG_UPTIME */ + +/************************************************************************** + * Private Functions + **************************************************************************/ +/**************************************************************************** + * Function: clock_timer + * + * Description: + * This function must be called once every time the real + * time clock interrupt occurs. The interval of this + * clock interrupt must be MSEC_PER_TICK + * + ****************************************************************************/ + +#if CONFIG_UPTIME +static inline void incr_uptime(void) +{ + g_tickcount++; + + if (g_tickcount >= TICK_PER_SEC) + { + g_uptime++; + g_tickcount -= TICK_PER_SEC; + } +} +#else +# define incr_uptime() +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -101,14 +158,20 @@ void clock_initialize(void) /* Initialize the real time close */ +#if __HAVE_SYSTEM_COUNTER g_system_timer = 0; +#endif /* Get the EPOCH-relative julian date from the calendar year, * month, and date */ +#ifndef CONFIG_PTIMER jdn = clock_calendar2utc(CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY); +#else /* use UTC as starting date */ + jdn = clock_calendar2utc(1970, 1, 1); +#endif /* Set the base time as seconds into this julian day. */ @@ -132,5 +195,11 @@ void clock_initialize(void) void clock_timer(void) { - g_system_timer++; + /* Increment the per-tick system counter */ + + incr_systimer(); + + /* Increment the per-second uptime counter */ + + incr_uptime(); } diff --git a/nuttx/sched/clock_systimer.c b/nuttx/sched/clock_systimer.c index 921f9ebc5..5e18f53fd 100644 --- a/nuttx/sched/clock_systimer.c +++ b/nuttx/sched/clock_systimer.c @@ -42,15 +42,12 @@ #include <stdint.h> #include <nuttx/clock.h> -#if !defined(CONFIG_DISABLE_CLOCK) && \ - defined(CONFIG_NUTTX_KERNEL) && !defined(__KERNEL__) +#if __HAVE_SYSTEM_COUNTER && !defined(clock_systimer) /* See nuttx/clock.h */ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -#undef clock_systimer - /**************************************************************************** * Private Data ****************************************************************************/ @@ -79,5 +76,6 @@ uint32_t clock_systimer(void) { return g_system_timer; } -#endif + +#endif /* __HAVE_SYSTEM_COUNTER */ diff --git a/nuttx/sched/clock_uptime.c b/nuttx/sched/clock_uptime.c new file mode 100644 index 000000000..ae580ed17 --- /dev/null +++ b/nuttx/sched/clock_uptime.c @@ -0,0 +1,84 @@ +/**************************************************************************** + * sched/clock_uptime.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> +#include <nuttx/time.h> + +#if !defined(CONFIG_DISABLE_CLOCK) && defined(CONFIG_UPTIME) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#undef clock_uptime + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Function: clock_uptime + * + * Description: + * Return the current value of the system timer counter, which is only + * enabled when system is in active mode. + * + * Parameters: + * None + * + * Return Value: + * The current value of the system time counter + * + * Assumptions: + * + ****************************************************************************/ + +time_t clock_uptime(void) +{ + return g_uptime; +} + +#endif /* CONFIG_DISABLE_CLOCK && CONFIG_UPTIME */ diff --git a/nuttx/syscall/stub_lookup.c b/nuttx/syscall/stub_lookup.c index 0c4f4451c..d56364bfe 100644 --- a/nuttx/syscall/stub_lookup.c +++ b/nuttx/syscall/stub_lookup.c @@ -112,6 +112,7 @@ 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); extern uintptr_t STUB_gettimeofday(uintptr_t parm1, uintptr_t parm2); +extern uintptr_t STUB_clock_uptime(void); /* The following are defined only if POSIX timers are supported */ diff --git a/nuttx/syscall/stub_lookup.h b/nuttx/syscall/stub_lookup.h index f9b33938b..16792aefc 100644 --- a/nuttx/syscall/stub_lookup.h +++ b/nuttx/syscall/stub_lookup.h @@ -107,6 +107,9 @@ STUB_LOOKUP(3, STUB_up_assert_code) /* SYS_up_assert_code */ STUB_LOOKUP(2, STUB_clock_gettime) /* SYS_clock_gettime */ STUB_LOOKUP(2, STUB_clock_settime) /* SYS_clock_settime */ STUB_LOOKUP(2, STUB_gettimeofday) /* SYS_gettimeofday */ +# ifdef CONFIG_UPTIME + STUB_LOOKUP(0, STUB_clock_uptime) /* SYS_clock_uptime */ +# endif #endif /* The following are defined only if POSIX timers are supported */ diff --git a/nuttx/syscall/syscall.csv b/nuttx/syscall/syscall.csv index 2499cd4ab..6998e89b0 100644 --- a/nuttx/syscall/syscall.csv +++ b/nuttx/syscall/syscall.csv @@ -6,6 +6,7 @@ "clock_getres","time.h","!defined(CONFIG_DISABLE_CLOCK)","int","clockid_t","struct timespec*" "clock_gettime","time.h","!defined(CONFIG_DISABLE_CLOCK)","int","clockid_t","struct timespec*" "clock_settime","time.h","!defined(CONFIG_DISABLE_CLOCK)","int","clockid_t","const struct timespec*" +"clock_uptime","nuttx/clock.h","!defined(CONFIG_DISABLE_CLOCK) && defined(CONFIG_UPTIME)","time_t" "close","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","int","int" "closedir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR DIR*" "connect","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","FAR const struct sockaddr*","socklen_t" |