diff options
| author | Alastair Reid | 2018-06-26 15:46:57 +0100 |
|---|---|---|
| committer | Alastair Reid | 2018-06-26 15:50:19 +0100 |
| commit | 68703bf244a10e5281625b0cb1d620d78d6c5cbb (patch) | |
| tree | a55530063bea7fca5ea85e94eeabe55411498c39 /lib | |
| parent | 23f4e803332f4cbbab356f580f09beb4fb8be656 (diff) | |
RTS: implement sleep primitives
Note that an alternative implementation choice is just to implement
them as SAIL functions manipulating a global variable.
Not sure which is better.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rts.c | 18 | ||||
| -rw-r--r-- | lib/rts.h | 16 |
2 files changed, 29 insertions, 5 deletions
@@ -25,12 +25,27 @@ unit sail_exit(unit u) return UNIT; } +bool g_sleeping = false; + unit sleep_request(const unit u) { - fprintf(stderr, "Sail model going to sleep\n"); + fprintf(stderr, "Sail CPU model going to sleep\n"); + g_sleeping = true; + return UNIT; +} + +unit wakeup_request(const unit u) +{ + fprintf(stderr, "Sail CPU model waking up\n"); + g_sleeping = false; return UNIT; } +bool sleeping(const unit u) +{ + return g_sleeping; +} + /* ***** Sail memory builtins ***** */ /* @@ -448,7 +463,6 @@ int process_arguments(int argc, char *argv[]) g_elf_entry = elf_entry; } - fprintf(stderr, "Parsed all command line options\n"); return 0; } @@ -21,12 +21,22 @@ unit sail_assert(bool b, sail_string msg); unit sail_exit(unit); /* - * ASL->Sail model has an EnterLowPowerState() function that calls a - * sleep request builtin. If it gets called we print a message and - * exit the model. + * Put processor to sleep until an external device calls wakeup_request(). */ unit sleep_request(const unit u); +/* + * Stop processor sleeping. + * (Typically called when a device generates an interrupt.) + */ +unit wakeup_request(const unit u); + +/* + * Test whether processor is sleeping. + * (Typically used to disable execution of instructions.) + */ +bool sleeping(const unit u); + /* ***** Memory builtins ***** */ void write_mem(uint64_t, uint64_t); |
