[db1424c9] | 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> |
---|
[0c3edbf] | 9 | #include <rtems/score/percpu.h> |
---|
| 10 | #include <rtems/score/threaddispatch.h> |
---|
[db1424c9] | 11 | |
---|
| 12 | #define CLOCK_VECTOR 0 |
---|
| 13 | |
---|
| 14 | #define Clock_driver_support_install_isr( _new, _old ) \ |
---|
| 15 | do { _old = 0; } while(0) |
---|
| 16 | |
---|
| 17 | volatile 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 | |
---|
[75acd9e] | 29 | #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER |
---|
| 30 | |
---|
[df7f158e] | 31 | #include "clockdrv_shell.h" |
---|
[db1424c9] | 32 | |
---|
[1ae7baf] | 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 | |
---|
[db1424c9] | 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 | */ |
---|
[ccd5434] | 47 | void *clock_driver_sim_idle_body( |
---|
[db1424c9] | 48 | uintptr_t ignored |
---|
| 49 | ) |
---|
| 50 | { |
---|
| 51 | for( ; ; ) { |
---|
[0846740] | 52 | if ( clock_driver_enabled ) { |
---|
[9f5754b5] | 53 | Per_CPU_Control *cpu = _Thread_Dispatch_disable(); |
---|
[0846740] | 54 | _ISR_Nest_level++; |
---|
[9f5754b5] | 55 | rtems_clock_tick(); |
---|
[0846740] | 56 | _ISR_Nest_level--; |
---|
[9f5754b5] | 57 | _Thread_Dispatch_enable( cpu ); |
---|
[1ae7baf] | 58 | BSP_CLOCK_DRIVER_DELAY(); |
---|
[0846740] | 59 | } |
---|
[db1424c9] | 60 | } |
---|
| 61 | return 0; /* to avoid warning */ |
---|
| 62 | } |
---|