Update to use 64-bit timer when available

This commit is contained in:
Gregory Nutt
2016-01-21 11:54:26 -06:00
parent cb7bbdfed4
commit f348e68069
41 changed files with 182 additions and 165 deletions
+33 -16
View File
@@ -1,7 +1,8 @@
/****************************************************************************
* include/nuttx/clock.h
*
* Copyright (C) 2007-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011-2012, 2014, 2016 Gregory Nutt.
All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -164,6 +165,14 @@
#define TICK2DSEC(tick) (((tick)+(TICK_PER_DSEC/2))/TICK_PER_DSEC) /* Rounds */
#define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */
/* Select the access to the system timer using its natural with */
#ifdef CONFIG_SYSTEM_TIME64
# define clock_systimer() clock_systimer64()
#else
# define clock_systimer() clock_systimer32()
#endif
/****************************************************************************
* Public Types
****************************************************************************/
@@ -177,10 +186,26 @@ struct cpuload_s
};
#endif
/* This type is the natural with of the system timer */
#ifdef CONFIG_SYSTEM_TIME64
typedef uint64_t systime_t;
#else
typedef uint32_t systime_t;
#endif
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/* Access to raw system clock ***********************************************/
/* Direct access to the system timer/counter is supported only if (1) the
* system timer counter is available (i.e., we are not configured to use
@@ -191,14 +216,14 @@ struct cpuload_s
#ifdef __HAVE_KERNEL_GLOBALS
# ifdef CONFIG_SYSTEM_TIME64
extern volatile uint64_t g_system_timer;
#define clock_systimer() (uint32_t)(g_system_timer & 0x00000000ffffffff)
EXTERN volatile uint64_t g_system_timer;
#define clock_systimer32() (uint32_t)(g_system_timer & 0x00000000ffffffff)
#define clock_systimer64() g_system_timer
# else
extern volatile uint32_t g_system_timer;
#define clock_systimer() g_system_timer
EXTERN volatile uint32_t g_system_timer;
#define clock_systimer32() g_system_timer
# endif
#endif
@@ -207,14 +232,6 @@ extern volatile uint32_t g_system_timer;
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Function: clock_synchronize
*
@@ -248,7 +265,7 @@ void clock_synchronize(void);
#endif
/****************************************************************************
* Function: clock_systimer
* Function: clock_systimer32
*
* Description:
* Return the current value of the 32-bit system timer counter. Indirect
@@ -268,9 +285,9 @@ void clock_synchronize(void);
#ifndef __HAVE_KERNEL_GLOBALS
# ifdef CONFIG_SYSTEM_TIME64
# define clock_systimer() (uint32_t)(clock_systimer64() & 0x00000000ffffffff)
# define clock_systimer32() (uint32_t)(clock_systimer64() & 0x00000000ffffffff)
# else
uint32_t clock_systimer(void);
uint32_t clock_systimer32(void);
# endif
#endif
+10 -9
View File
@@ -1,7 +1,7 @@
/********************************************************************************
* include/nuttx/sched.h
*
* Copyright (C) 2007-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,7 @@
#include <mqueue.h>
#include <time.h>
#include <nuttx/clock.h>
#include <nuttx/irq.h>
#include <nuttx/wdog.h>
#include <nuttx/mm/shm.h>
@@ -273,14 +274,14 @@ struct replenishment_s
struct sporadic_s
{
bool suspended; /* Thread is currently suspended */
uint8_t hi_priority; /* Sporadic high priority */
uint8_t low_priority; /* Sporadic low priority */
uint8_t max_repl; /* Maximum number of replenishments */
uint8_t nrepls; /* Number of active replenishments */
uint32_t repl_period; /* Sporadic replenishment period */
uint32_t budget; /* Sporadic execution budget period */
uint32_t eventtime; /* Time thread suspended or [re-]started */
bool suspended; /* Thread is currently suspended */
uint8_t hi_priority; /* Sporadic high priority */
uint8_t low_priority; /* Sporadic low priority */
uint8_t max_repl; /* Maximum number of replenishments */
uint8_t nrepls; /* Number of active replenishments */
uint32_t repl_period; /* Sporadic replenishment period */
uint32_t budget; /* Sporadic execution budget period */
systime_t eventtime; /* Time thread suspended or [re-]started */
/* This is the last interval timer activated */
+3 -2
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/semaphore.h
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,7 @@
#include <semaphore.h>
#include <nuttx/clock.h>
#include <nuttx/fs/fs.h>
/****************************************************************************
@@ -110,7 +111,7 @@ extern "C"
*
****************************************************************************/
int sem_tickwait(FAR sem_t *sem, uint32_t start, uint32_t delay);
int sem_tickwait(FAR sem_t *sem, systime_t start, uint32_t delay);
#undef EXTERN
#ifdef __cplusplus
+5 -3
View File
@@ -47,6 +47,8 @@
#include <semaphore.h>
#include <queue.h>
#include <nuttx/clock.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -290,8 +292,8 @@ struct work_s
struct dq_entry_s dq; /* Implements a doubly linked list */
worker_t worker; /* Work callback */
FAR void *arg; /* Callback argument */
uint32_t qtime; /* Time work queued */
uint32_t delay; /* Delay until work performed */
systime_t qtime; /* Time work queued */
systime_t delay; /* Delay until work performed */
};
/****************************************************************************
@@ -359,7 +361,7 @@ int work_usrstart(void);
****************************************************************************/
int work_queue(int qid, FAR struct work_s *work, worker_t worker,
FAR void *arg, uint32_t delay);
FAR void *arg, systime_t delay);
/****************************************************************************
* Name: work_cancel
+5 -1
View File
@@ -211,7 +211,11 @@
* NuttX configuration.
*/
#define SYS_clock_systimer (__SYS_clock+0)
#ifdef CONFIG_SYSTEM_TIME64
# define SYS_clock_systimer64 (__SYS_clock+0)
#endif
# define SYS_clock_systimer32 (__SYS_clock+0)
#endif
#define SYS_clock_getres (__SYS_clock+1)
#define SYS_clock_gettime (__SYS_clock+2)
#define SYS_clock_settime (__SYS_clock+3)