Rename ioreq to syscall

This commit is contained in:
Toby Jaffey 2025-12-08 12:26:47 +00:00
parent b79a107a3d
commit 61fe0e8647
20 changed files with 187 additions and 190 deletions

View file

@ -67,7 +67,7 @@ bool uvm32_load(uvm32_state_t *vmst, uint8_t *rom, int len) {
}
// Read C-string up to terminator and return len,ptr
static void get_safeptr_terminated(uvm32_state_t *vmst, uint32_t addr, uint8_t terminator, uvm32_evt_ioreq_buf_t *buf) {
static void get_safeptr_terminated(uvm32_state_t *vmst, uint32_t addr, uint8_t terminator, uvm32_evt_syscall_buf_t *buf) {
uint32_t ptrstart = addr - MINIRV32_RAM_IMAGE_OFFSET;
uint32_t p = ptrstart;
if (p >= UVM32_MEMORY_SIZE) {
@ -90,7 +90,7 @@ static void get_safeptr_terminated(uvm32_state_t *vmst, uint32_t addr, uint8_t t
}
#if 0
static void get_safeptr(uvm32_state_t *vmst, uint32_t addr, uint32_t len, uvm32_evt_ioreq_buf_t *buf) {
static void get_safeptr(uvm32_state_t *vmst, uint32_t addr, uint32_t len, uvm32_evt_syscall_buf_t *buf) {
uint32_t ptrstart = addr - MINIRV32_RAM_IMAGE_OFFSET;
if (ptrstart + len >= UVM32_MEMORY_SIZE) {
setStatusErr(vmst, UVM32_ERR_MEM_RD);
@ -103,7 +103,7 @@ static void get_safeptr(uvm32_state_t *vmst, uint32_t addr, uint32_t len, uvm32_
uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter) {
uint32_t num_instr = 0;
// uvm32_evt_ioreq_buf_t b;
// uvm32_evt_syscall_buf_t b;
if (vmst->status != UVM32_STATUS_PAUSED) {
setStatusErr(vmst, UVM32_ERR_NOTREADY);
@ -127,11 +127,11 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter)
vmst->core->pc += 4;
switch(syscall) {
// inbuilt syscalls
case IOREQ_HALT:
case UVM32_SYSCALL_HALT:
setStatus(vmst, UVM32_STATUS_ENDED);
syscall_valid = true;
break;
case IOREQ_YIELD:
case UVM32_SYSCALL_YIELD:
vmst->ioevt.typ = UVM32_EVT_YIELD;
setStatus(vmst, UVM32_STATUS_PAUSED);
syscall_valid = true;
@ -144,22 +144,22 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter)
if (syscall == vmst->mappings[i].syscall) {
// setup ioevt.data according to mapping typ
switch(vmst->mappings[i].typ) {
case IOREQ_TYP_VOID:
case UVM32_SYSCALL_TYP_VOID:
break;
case IOREQ_TYP_U32_WR:
vmst->ioevt.data.ioreq.val.u32 = value;
case UVM32_SYSCALL_TYP_U32_WR:
vmst->ioevt.data.syscall.val.u32 = value;
break;
case IOREQ_TYP_BUF_TERMINATED_WR:
get_safeptr_terminated(vmst, value, 0x00, &vmst->ioevt.data.ioreq.val.buf);
case UVM32_SYSCALL_TYP_BUF_TERMINATED_WR:
get_safeptr_terminated(vmst, value, 0x00, &vmst->ioevt.data.syscall.val.buf);
break;
case IOREQ_TYP_U32_RD:
case UVM32_SYSCALL_TYP_U32_RD:
// pass link to r1 for user function to update
vmst->ioevt.data.ioreq.val.u32p = &vmst->core->regs[11];
vmst->ioevt.data.syscall.val.u32p = &vmst->core->regs[11];
break;
}
vmst->ioevt.typ = UVM32_EVT_IOREQ;
vmst->ioevt.data.ioreq.code = vmst->mappings[i].code;
vmst->ioevt.data.ioreq.typ = vmst->mappings[i].typ;
vmst->ioevt.typ = UVM32_EVT_UVM32_SYSCALL;
vmst->ioevt.data.syscall.code = vmst->mappings[i].code;
vmst->ioevt.data.syscall.typ = vmst->mappings[i].typ;
setStatus(vmst, UVM32_STATUS_PAUSED);
syscall_valid = true;
break; // stop searching

View file

@ -4,9 +4,9 @@
#include <stdint.h>
#include <stdbool.h>
// "well-known" system IOREQ functions
#define IOREQ_HALT 0x138
#define IOREQ_YIELD 0x139
// "well-known" system UVM32_SYSCALL functions
#define UVM32_SYSCALL_HALT 0x138
#define UVM32_SYSCALL_YIELD 0x139
#define LIST_OF_UVM32_ERRS \
X(UVM32_ERR_NONE) \
@ -26,41 +26,41 @@ typedef enum {
typedef enum {
UVM32_EVT_ERR,
UVM32_EVT_IOREQ,
UVM32_EVT_UVM32_SYSCALL,
UVM32_EVT_YIELD,
UVM32_EVT_END,
} uvm32_evt_typ_t;
typedef enum {
IOREQ_TYP_BUF_TERMINATED_WR, // data write from vm, NULL terminated string of bytes, in uvm32_evt_ioreq_t.val.buf
IOREQ_TYP_VOID, // no data
IOREQ_TYP_U32_WR, // data write from vm, in uvm32_evt_ioreq_t.val.u32
IOREQ_TYP_U32_RD, // data read from vm, expects response in uvm32_evt_ioreq_t.val.u32p
} uvm32_ioreq_typ_t;
UVM32_SYSCALL_TYP_BUF_TERMINATED_WR, // data write from vm, NULL terminated string of bytes, in uvm32_evt_syscall_t.val.buf
UVM32_SYSCALL_TYP_VOID, // no data
UVM32_SYSCALL_TYP_U32_WR, // data write from vm, in uvm32_evt_syscall_t.val.u32
UVM32_SYSCALL_TYP_U32_RD, // data read from vm, expects response in uvm32_evt_syscall_t.val.u32p
} uvm32_syscall_typ_t;
typedef uint32_t uvm32_user_ioreq_code_t;
typedef uint32_t uvm32_user_syscall_code_t;
// user supplied mapping from syscall to typed ioreq
// user supplied mapping from syscall to typed syscall
typedef struct {
uint32_t syscall;
uvm32_user_ioreq_code_t code;
uvm32_ioreq_typ_t typ;
uvm32_user_syscall_code_t code;
uvm32_syscall_typ_t typ;
} uvm32_mapping_t;
typedef struct {
uint8_t *ptr;
uint32_t len;
} uvm32_evt_ioreq_buf_t;
} uvm32_evt_syscall_buf_t;
typedef struct {
uvm32_ioreq_typ_t typ;
uvm32_user_ioreq_code_t code;
uvm32_syscall_typ_t typ;
uvm32_user_syscall_code_t code;
union {
uvm32_evt_ioreq_buf_t buf;
uvm32_evt_syscall_buf_t buf;
uint32_t u32;
uint32_t *u32p;
} val;
} uvm32_evt_ioreq_t;
} uvm32_evt_syscall_t;
typedef struct {
uvm32_err_t errcode;
@ -70,7 +70,7 @@ typedef struct {
typedef struct {
uvm32_evt_typ_t typ;
union {
uvm32_evt_ioreq_t ioreq;
uvm32_evt_syscall_t syscall;
uvm32_evt_err_t err;
} data;
} uvm32_evt_t;