Mon 16 Mar 11:09:06 CET 2026
This commit is contained in:
parent
83952948c6
commit
ab7820fda5
49
src/vm.h
Normal file
49
src/vm.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#ifndef _VM_H
|
||||
#define _VM_H
|
||||
|
||||
|
||||
/*
|
||||
PIDLE
|
||||
PRUNNING
|
||||
PRUNNING|PHANDLER
|
||||
PSUSPENDED
|
||||
PSUSPENDED|PHANDLER
|
||||
PTIMEOUT|PINTERRUPT
|
||||
PTIMEOUT|PINTERRUPT|PEVENTPEND
|
||||
...
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
PIDLE = 1, // Nothing todo
|
||||
PRUNNING = 2, // Running in main program
|
||||
PSUSPENDED = 4, // Suspended (stopped, but still servicing events)
|
||||
PTIMEOUT = 8, // Delay (if not EVENTPEND) or awaiting event with timeout
|
||||
PAWAIT = 16, // awaiting event, internal (e.g. blocke IN/OUT op) or external event
|
||||
PINTERRUPT = 32, // Main program is interrupted by delay/await, but not stopped
|
||||
PHANDLER = 64, // Running in (event) handler
|
||||
PERROR = 128, // Processing error (or in error state) and running error handler
|
||||
PEVENTPEND = 256 // pending events to be handled
|
||||
} vm_states_t;
|
||||
|
||||
|
||||
#include "mem.h"
|
||||
#include "reg.h"
|
||||
#include "stack.h"
|
||||
#include "context.h"
|
||||
|
||||
/*
|
||||
A reason to enter VM run?
|
||||
*/
|
||||
#define RUNNABLE(R) (R->state&(PRUNNING|PHANDLER|PEVENTPEND))
|
||||
/*
|
||||
Execute at least one VM instruction?
|
||||
*/
|
||||
#define RUNNABLE1(R) (R->state&(PRUNNING|PHANDLER))
|
||||
|
||||
int Run(context_t *C);
|
||||
void CodeCleanUp(context_t *C);
|
||||
int Start(context_t *C);
|
||||
int Stop(context_t *C);
|
||||
int Suspend(context_t *C, index_t type, index_t io, index_t tinmeout);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user