From 0452b1555b99cacd7d0393a818499c567ca8a485 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 6 Aug 2014 18:26:16 -0600 Subject: [PATCH] if CONFIG_SCHED_TICKLESS is defined, then the global variable g_system_timer does not exist --- arch/sim/src/up_internal.h | 56 +++++++++++++++++++++----------------- include/nuttx/clock.h | 22 +++++++++------ sched/clock_initialize.c | 12 +++++++- 3 files changed, 55 insertions(+), 35 deletions(-) diff --git a/arch/sim/src/up_internal.h b/arch/sim/src/up_internal.h index 3d004f4d0e..9287b6b672 100644 --- a/arch/sim/src/up_internal.h +++ b/arch/sim/src/up_internal.h @@ -150,60 +150,66 @@ extern volatile int g_eventloop; /* up_setjmp.S ************************************************************/ -extern int up_setjmp(int *jb); -extern void up_longjmp(int *jb, int val) noreturn_function; +int up_setjmp(int *jb); +void up_longjmp(int *jb, int val) noreturn_function; + +/* up_tickless.c **********************************************************/ + +#ifdef CONFIG_SCHED_TICKLESS +void up_timer_update(void); +#endif /* up_devconsole.c ********************************************************/ -extern void up_devconsole(void); -extern void up_registerblockdevice(void); +void up_devconsole(void); +void up_registerblockdevice(void); /* up_deviceimage.c *******************************************************/ -extern char *up_deviceimage(void); +char *up_deviceimage(void); /* up_stdio.c *************************************************************/ -extern size_t up_hostread(void *buffer, size_t len); -extern size_t up_hostwrite(const void *buffer, size_t len); +size_t up_hostread(void *buffer, size_t len); +size_t up_hostwrite(const void *buffer, size_t len); /* up_netdev.c ************************************************************/ #ifdef CONFIG_NET -extern unsigned long up_getwalltime( void ); +unsigned long up_getwalltime( void ); #endif /* up_x11framebuffer.c ******************************************************/ #ifdef CONFIG_SIM_X11FB -extern int up_x11initialize(unsigned short width, unsigned short height, - void **fbmem, unsigned int *fblen, unsigned char *bpp, - unsigned short *stride); +int up_x11initialize(unsigned short width, unsigned short height, + void **fbmem, unsigned int *fblen, unsigned char *bpp, + unsigned short *stride); #ifdef CONFIG_FB_CMAP -extern int up_x11cmap(unsigned short first, unsigned short len, - unsigned char *red, unsigned char *green, - unsigned char *blue, unsigned char *transp); +int up_x11cmap(unsigned short first, unsigned short len, + unsigned char *red, unsigned char *green, + unsigned char *blue, unsigned char *transp); #endif #endif /* up_eventloop.c ***********************************************************/ #if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN) -extern void up_x11events(void); +void up_x11events(void); #endif /* up_eventloop.c ***********************************************************/ #if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN) -extern int up_buttonevent(int x, int y, int buttons); +int up_buttonevent(int x, int y, int buttons); #endif /* up_tapdev.c ************************************************************/ #if defined(CONFIG_NET) && !defined(__CYGWIN__) -extern void tapdev_init(void); -extern unsigned int tapdev_read(unsigned char *buf, unsigned int buflen); -extern void tapdev_send(unsigned char *buf, unsigned int buflen); +void tapdev_init(void); +unsigned int tapdev_read(unsigned char *buf, unsigned int buflen); +void tapdev_send(unsigned char *buf, unsigned int buflen); #define netdev_init() tapdev_init() #define netdev_read(buf,buflen) tapdev_read(buf,buflen) @@ -213,9 +219,9 @@ extern void tapdev_send(unsigned char *buf, unsigned int buflen); /* up_wpcap.c *************************************************************/ #if defined(CONFIG_NET) && defined(__CYGWIN__) -extern void wpcap_init(void); -extern unsigned int wpcap_read(unsigned char *buf, unsigned int buflen); -extern void wpcap_send(unsigned char *buf, unsigned int buflen); +void wpcap_init(void); +unsigned int wpcap_read(unsigned char *buf, unsigned int buflen); +void wpcap_send(unsigned char *buf, unsigned int buflen); #define netdev_init() wpcap_init() #define netdev_read(buf,buflen) wpcap_read(buf,buflen) @@ -225,9 +231,9 @@ extern void wpcap_send(unsigned char *buf, unsigned int buflen); /* up_netdriver.c *********************************************************/ #ifdef CONFIG_NET -extern int netdriver_init(void); -extern int netdriver_setmacaddr(unsigned char *macaddr); -extern void netdriver_loop(void); +int netdriver_init(void); +int netdriver_setmacaddr(unsigned char *macaddr); +void netdriver_loop(void); #endif #endif /* __ASSEMBLY__ */ diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index d1315fbbab..ed460d1d2e 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -53,12 +53,15 @@ /* 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. + * directly if: (1) we are not running tick-less (in which case there is + * no global timer data), (2) this is an un-protected, non-kernel build, or + * (2) this is a protectd build, but this code is being built for execution + * within the kernel space. */ #undef __HAVE_KERNEL_GLOBALS -#if !defined(CONFIG_NUTTX_KERNEL) || defined(__KERNEL__) +#if !defined(CONFIG_SCHED_TICKLESS) && \ + (!defined(CONFIG_NUTTX_KERNEL) || defined(__KERNEL__)) # define __HAVE_KERNEL_GLOBALS 1 #else # define __HAVE_KERNEL_GLOBALS 0 @@ -85,12 +88,13 @@ #define USEC_PER_MSEC 1000 #define NSEC_PER_USEC 1000 -/* The interrupt interval of the system timer is given by MSEC_PER_TICK. - * This is the expected number of milliseconds between calls from the - * processor-specific logic to sched_process_timer(). The default value - * of MSEC_PER_TICK is 10 milliseconds (100KHz). However, this default - * setting can be overridden by defining the interval in milliseconds as - * CONFIG_MSEC_PER_TICK in the board configuration file. +/* If CONFIG_SCHED_TICKLESS is not defined, then the interrupt interval of + * the system timer is given by MSEC_PER_TICK. This is the expected number + * of milliseconds between calls from the processor-specific logic to + * sched_process_timer(). The default value of MSEC_PER_TICK is 10 + * milliseconds (100KHz). However, this default setting can be overridden + * by defining the interval in milliseconds as CONFIG_MSEC_PER_TICK in the + * board configuration file. * * The following calculations are only accurate when (1) there is no * truncation involved and (2) the underlying system timer is an even diff --git a/sched/clock_initialize.c b/sched/clock_initialize.c index 85a7294abb..0b21fd56ae 100644 --- a/sched/clock_initialize.c +++ b/sched/clock_initialize.c @@ -80,11 +80,17 @@ * Public Variables ****************************************************************************/ +#ifndef CONFIG_SCHED_TICKLESS #ifdef CONFIG_SYSTEM_TIME64 volatile uint64_t g_system_timer; -uint64_t g_tickbias; #else volatile uint32_t g_system_timer; +#endif +#endif + +#ifdef CONFIG_SYSTEM_TIME64 +uint64_t g_tickbias; +#else uint32_t g_tickbias; #endif @@ -182,7 +188,9 @@ static void clock_inittime(void) /* (Re-)initialize the time value to match the RTC */ clock_basetime(&g_basetime); +#ifndef CONFIG_SCHED_TICKLESS g_system_timer = 0; +#endif g_tickbias = 0; } @@ -262,9 +270,11 @@ void clock_synchronize(void) * ****************************************************************************/ +#ifndef CONFIG_SCHED_TICKLESS void clock_timer(void) { /* Increment the per-tick system counter */ g_system_timer++; } +#endif \ No newline at end of file