-
Notifications
You must be signed in to change notification settings - Fork 0
System functions
David de Rosier edited this page Jan 31, 2025
·
10 revisions
By convention (ABI), the function ID must be in the highest a-register (a5).
Registers a0 to a4 are for function arguments.
Then you can invoke the function either with ecall operation or
with the syscall macro (recommended).
The result is returned in a0 registry (sometimes there is an extra information in a1).
Error code is returned in a5.
Examples:
.include "consts.s" # include constants with function names
li a0, '!' # load function argument
li a5, SYSFN_PRINT_CHAR # set function ID
ecall # call the function
bnez a5, handle_error # handle error.include "consts.s" # include constants with function names
.include "macros.s" # include macros
li a0, '!' # load function argument
syscall SYSFN_PRINT_CHAR # call the function with macro
bnez a5, handle_error # handle error| ID | Name | Const | Description | Status | Ticket |
|---|---|---|---|---|---|
| 1 | sleep |
SYSFN_SLEEP | Sleep for n milliseconds | ✖ | |
| 2 | idle |
SYSFN_IDLE | wait until next event or irq | ✅ | |
| 3 | run |
SYSFN_RUN | runs program from disc/rom | ✅ | #53 |
| 4 | exit |
SYSFN_EXIT | exits a program and returns to the system | ✅ | #53 |
| 5 | get_cfg |
SYSFN_GET_CFG | returns single entry from system config | ✅ | |
| 6 | get_drv_cfg |
SYSFN_GET_DRV_CFG | returns config of a given driver | ✅ | |
| 10 | get_secs_from_epoch |
SYSFN_GET_SECS_FROM_EPOCH | Returns number of seconds from 1970/01/01 | ✅ | #8 |
| 11 | get_date |
SYSFN_GET_DATE | Returns current date | ✅ | #8 |
| 12 | set_date |
SYSFN_SET_DATE | Sets current date | ✖ | |
| 13 | get_time |
SYSFN_GET_TIME | Returns current time | ✅ | |
| 14 | set_time |
SYSFN_SET_TIME | Sets current time | ✖ | #8 |
| 20 | get_char |
SYSFN_GET_CHAR | Get's character from the standard input | ✅ | |
| 21 | print_char |
SYSFN_PRINT_CHAR | Sends character to a standard output | ✅ | |
| 22 | print_str |
SYSFN_PRINT_STR | Sends a string to a standard output | ✅ |