Add rand() syscall

This commit is contained in:
2025-10-11 21:54:06 +02:00
parent d92a652024
commit ee93463c64
4 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,8 @@
#include <stdint.h>
#include <stddef.h>
#include "hal/hal.h"
#include "syscall.h"
int32_t SYSCALL0(sys_rand) {
return hal_randnum();
}

View File

@ -0,0 +1,8 @@
#ifndef SYSCALL_RANDCRYPTO_H_
#define SYSCALL_RANDCRYPTO_H_
#include "syscall.h"
int32_t SYSCALL0(sys_rand);
#endif // SYSCALL_RANDCRYPTO_H_

View File

@ -9,6 +9,7 @@
#include "mman.h" #include "mman.h"
#include "sched.h" #include "sched.h"
#include "devctl.h" #include "devctl.h"
#include "randcrypto.h"
int32_t SYSCALL1(sys_debugprint, string) { int32_t SYSCALL1(sys_debugprint, string) {
char *p = (char *)string; char *p = (char *)string;
@ -25,4 +26,5 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
[SYS_MMAN_UNMAP] = &sys_mman_unmap, [SYS_MMAN_UNMAP] = &sys_mman_unmap,
[SYS_SCHEDRELEASE] = &sys_schedrelease, [SYS_SCHEDRELEASE] = &sys_schedrelease,
[SYS_DEVCTL] = &sys_devctl, [SYS_DEVCTL] = &sys_devctl,
[SYS_RAND] = &sys_rand,
}; };

View File

@ -9,5 +9,6 @@
#define SYS_MMAN_UNMAP 6 #define SYS_MMAN_UNMAP 6
#define SYS_SCHEDRELEASE 7 #define SYS_SCHEDRELEASE 7
#define SYS_DEVCTL 8 #define SYS_DEVCTL 8
#define SYS_RAND 9
#endif // SHARE_HDRS_SYSCALL_H_ #endif // SHARE_HDRS_SYSCALL_H_