mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Make syscall names closer to libc
This commit is contained in:
parent
1b868adf87
commit
6735b159ac
17 changed files with 103 additions and 79 deletions
|
|
@ -1,11 +1,11 @@
|
|||
// Definitions needed by both host and target
|
||||
|
||||
// syscalls for exposed host functions, start at 0
|
||||
#define UVM32_SYSCALL_PRINTC 0x00000000
|
||||
#define UVM32_SYSCALL_PUTC 0x00000000
|
||||
#define UVM32_SYSCALL_GETC 0x00000001
|
||||
#define UVM32_SYSCALL_PRINT 0x00000002
|
||||
#define UVM32_SYSCALL_PRINTLN 0x00000003
|
||||
#define UVM32_SYSCALL_PRINTD 0x00000004
|
||||
#define UVM32_SYSCALL_PRINTX 0x00000005
|
||||
#define UVM32_SYSCALL_PRINTDEC 0x00000004
|
||||
#define UVM32_SYSCALL_PRINTHEX 0x00000005
|
||||
#define UVM32_SYSCALL_MILLIS 0x00000006
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,36 @@
|
|||
|
||||
#include "uvm32_sys.h"
|
||||
|
||||
// Basic types
|
||||
typedef long uint32_t;
|
||||
typedef char uint8_t;
|
||||
typedef int bool;
|
||||
// <stdint>
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef unsigned long uint32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef long long int64_t;
|
||||
typedef long int32_t;
|
||||
typedef short int16_t;
|
||||
typedef char int8_t;
|
||||
|
||||
// <stdbool>
|
||||
typedef unsigned char bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#ifndef size_assert
|
||||
#define size_assert( what, howmuch ) \
|
||||
typedef char what##_size_wrong_[( !!(sizeof(what) == howmuch) )*2-1 ]
|
||||
#endif
|
||||
|
||||
// sanity check
|
||||
size_assert(uint64_t, 8);
|
||||
size_assert(uint32_t, 4);
|
||||
size_assert(uint16_t, 2);
|
||||
size_assert(uint8_t, 1);
|
||||
size_assert(int64_t, 8);
|
||||
size_assert(int32_t, 4);
|
||||
size_assert(int16_t, 2);
|
||||
size_assert(int8_t, 1);
|
||||
|
||||
static uint32_t syscall(uint32_t id, uint32_t param) {
|
||||
register uint32_t a0 asm("a0") = (uint32_t)(param);
|
||||
register uint32_t a1 asm("a1");
|
||||
|
|
@ -24,14 +47,15 @@ static uint32_t syscall(uint32_t id, uint32_t param) {
|
|||
}
|
||||
|
||||
#define syscall_cast(id, x) syscall((uint32_t)id, (uint32_t)x)
|
||||
#define println(x) syscall_cast(UVM32_SYSCALL_PRINTLN, x)
|
||||
#define print(x) syscall_cast(UVM32_SYSCALL_PRINT, x)
|
||||
#define printd(x) syscall_cast(UVM32_SYSCALL_PRINTD, x)
|
||||
#define printx(x) syscall_cast(UVM32_SYSCALL_PRINTX, x)
|
||||
#define millis() syscall_cast(UVM32_SYSCALL_MILLIS, 0)
|
||||
#define printc() syscall_cast(UVM32_SYSCALL_PRINTC, 0)
|
||||
#define getc() syscall_cast(UVM32_SYSCALL_GETC, 0)
|
||||
#define yield() syscall_cast(UVM32_SYSCALL_YIELD, 0)
|
||||
|
||||
#define println(x) syscall_cast(UVM32_SYSCALL_PRINTLN, x)
|
||||
#define print(x) syscall_cast(UVM32_SYSCALL_PRINT, x)
|
||||
#define printdec(x) syscall_cast(UVM32_SYSCALL_PRINTDEC, x)
|
||||
#define printhex(x) syscall_cast(UVM32_SYSCALL_PRINTHEX, x)
|
||||
#define millis() syscall_cast(UVM32_SYSCALL_MILLIS, 0)
|
||||
#define putc() syscall_cast(UVM32_SYSCALL_PUTC, 0)
|
||||
#define getc() syscall_cast(UVM32_SYSCALL_GETC, 0)
|
||||
#define yield() syscall_cast(UVM32_SYSCALL_YIELD, 0)
|
||||
|
||||
#include "uvm32_common_custom.h"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue