|
| 1 | +/* |
| 2 | + * PIOS system call definitions. |
| 3 | + * |
| 4 | + * Copyright (C) 2010 Yale University. |
| 5 | + * See section "MIT License" in the file LICENSES for licensing terms. |
| 6 | + * |
| 7 | + * Primary author: Bryan Ford |
| 8 | + */ |
| 9 | + |
| 10 | +#ifndef PIOS_INC_SYSCALL_H |
| 11 | +#define PIOS_INC_SYSCALL_H |
| 12 | + |
| 13 | +#include <inc/trap.h> |
| 14 | + |
| 15 | + |
| 16 | +// System call command codes (passed in EAX) |
| 17 | +#define SYS_TYPE 0x00000003 // Basic operation type |
| 18 | +#define SYS_CPUTS 0x00000000 // Write debugging string to console |
| 19 | +#define SYS_PUT 0x00000001 // Push data to child and start it |
| 20 | +#define SYS_PUT 0x00000001 // Push data to child and start it |
| 21 | +#define SYS_GET 0x00000002 // Pull results from child |
| 22 | +#define SYS_RET 0x00000003 // Return to parent |
| 23 | + |
| 24 | +#define SYS_START 0x00000010 // Put: start child running |
| 25 | + |
| 26 | +#define SYS_REGS 0x00001000 // Get/put register state |
| 27 | +#define SYS_FPU 0x00002000 // Get/put FPU state |
| 28 | + |
| 29 | + |
| 30 | +// Register conventions for CPUTS system call: |
| 31 | +// EAX: System call command |
| 32 | +// EBX: User pointer to string to output to console |
| 33 | +#define SYS_CPUTS_MAX 256 // Max buffer length cputs will accept |
| 34 | + |
| 35 | + |
| 36 | +// Register conventions on GET/PUT system call entry: |
| 37 | +// EAX: System call command/flags (SYS_*) |
| 38 | +// EDX: bits 7-0: Child process number to get/put |
| 39 | +// EBX: Get/put CPU state pointer for SYS_REGS and/or SYS_FPU) |
| 40 | +// ECX: Get/put memory region size |
| 41 | +// ESI: Get/put local memory region start |
| 42 | +// EDI: Get/put child memory region start |
| 43 | +// EBP: reserved |
| 44 | + |
| 45 | + |
| 46 | +#ifndef __ASSEMBLER__ |
| 47 | + |
| 48 | +// CPU state save area format for GET/PUT with SYS_REGS flags |
| 49 | +typedef struct cpustate { |
| 50 | + trapframe tf; // general registers |
| 51 | + fxsave fx; // x87/MMX/XMM registers |
| 52 | +} cpustate; |
| 53 | + |
| 54 | + |
| 55 | +// Prototypes for user-level syscalls stubs defined in lib/syscall.c |
| 56 | +void sys_cputs(const char *s); |
| 57 | +void sys_put(uint32_t flags, uint16_t child, cpustate *cpu, |
| 58 | + void *localsrc, void *childdest, size_t size); |
| 59 | +void sys_get(uint32_t flags, uint16_t child, cpustate *cpu, |
| 60 | + void *childsrc, void *localdest, size_t size); |
| 61 | +void sys_ret(void); |
| 62 | + |
| 63 | +#endif /* !__ASSEMBLER__ */ |
| 64 | + |
| 65 | +#endif /* !PIOS_INC_SYSCALL_H */ |
0 commit comments