source: rtems/c/src/lib/libbsp/shared/clock_driver_simidle.c @ 9f5754b5

Last change on this file since 9f5754b5 was 9f5754b5, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 4, 2016 at 2:13:45 PM

bsps: Avoid Giant lock in simulator clock driver

Update #2555.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  Instantiate the clock driver shell.
3 *
4 *  Since there is no clock source on the simulator, we fake
5 *  it with a special IDLE task.
6 */
7
8#include <rtems.h>
9#include <rtems/score/percpu.h>
10#include <rtems/score/threaddispatch.h>
11
12#define CLOCK_VECTOR 0
13
14#define Clock_driver_support_install_isr( _new, _old ) \
15  do { _old = 0; } while(0)
16
17volatile bool clock_driver_enabled;
18
19#define Clock_driver_support_initialize_hardware() \
20  do { \
21    clock_driver_enabled = true; \
22  } while (0)
23
24#define Clock_driver_support_shutdown_hardware() \
25  do { \
26    clock_driver_enabled = false; \
27  } while (0)
28
29#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
30
31#include "clockdrv_shell.h"
32
33/*
34 * If this is defined, then the BSP has defined a delay of some sort so
35 * time passage appears somewhat correctly. Otherwise, it runs extremely
36 * fast with no delays.
37 */
38#ifndef BSP_CLOCK_DRIVER_DELAY
39#define BSP_CLOCK_DRIVER_DELAY()
40#endif
41
42/*
43 *  Since there is no interrupt on this simulator, let's just
44 *  fake time passing.  This will not let preemption from an
45 *  interrupt work but is enough for many tests.
46 */
47void *clock_driver_sim_idle_body(
48  uintptr_t   ignored
49)
50{
51  for( ; ; ) {
52    if ( clock_driver_enabled ) {
53      Per_CPU_Control *cpu = _Thread_Dispatch_disable();
54      _ISR_Nest_level++;
55      rtems_clock_tick();
56      _ISR_Nest_level--;
57      _Thread_Dispatch_enable( cpu );
58      BSP_CLOCK_DRIVER_DELAY();
59    }
60  }
61  return 0;   /* to avoid warning */
62}
Note: See TracBrowser for help on using the repository browser.