diff --git a/c/src/lib/libbsp/shared/ChangeLog b/c/src/lib/libbsp/shared/ChangeLog index 0b5e3b338e..d47e485540 100644 --- a/c/src/lib/libbsp/shared/ChangeLog +++ b/c/src/lib/libbsp/shared/ChangeLog @@ -1,3 +1,15 @@ +2008-09-24 Joel Sherrill + + * clock_driver_simidle.c: New file. + This implementation is for BSPs for simulators without a clock tick + ISR. It provides a special IDLE task that calls rtems_clock_tick() + repeatedly when the application ends up in the IDLE task. This + simulates time advancing. It is enough to run many tests but + will not result in the correct behavior when you want timeslicing. + This is because timeslicing assumes that a tick ISR determines + that the currently executing thread must be switched out. Without + a clock tick ISR, this will not occur. + 2008-09-23 Joel Sherrill * bootcard.c, include/bootcard.h: Make letting boot_card() handle work diff --git a/c/src/lib/libbsp/shared/clock_driver_simidle.c b/c/src/lib/libbsp/shared/clock_driver_simidle.c new file mode 100644 index 0000000000..4aeb7f467c --- /dev/null +++ b/c/src/lib/libbsp/shared/clock_driver_simidle.c @@ -0,0 +1,47 @@ +/* + * Instantiate the clock driver shell. + * + * Since there is no clock source on the simulator, we fake + * it with a special IDLE task. + * + * $Id$ + */ + +#include + +#define CLOCK_VECTOR 0 + +#define Clock_driver_support_at_tick() + +#define Clock_driver_support_install_isr( _new, _old ) \ + do { _old = 0; } while(0) + +volatile bool clock_driver_enabled; + +#define Clock_driver_support_initialize_hardware() \ + do { \ + clock_driver_enabled = true; \ + } while (0) + +#define Clock_driver_support_shutdown_hardware() \ + do { \ + clock_driver_enabled = false; \ + } while (0) + +#include "clockdrv_shell.c" + +/* + * Since there is no interrupt on this simulator, let's just + * fake time passing. This will not let preemption from an + * interrupt work but is enough for many tests. + */ +Thread clock_driver_sim_idle_body( + uintptr_t ignored +) +{ + for( ; ; ) { + if ( clock_driver_enabled ) + rtems_clock_tick(); + } + return 0; /* to avoid warning */ +}