Kernel, libc: Remove the rand() system call

That's why we now have a VFS and a /dev pseudo-filesystem. To provide that kind of things.

Remember, everything is a file!!

The new way to ask the kernel for random numbers is to read from /dev/random.
This commit is contained in:
apio 2022-10-15 13:04:48 +02:00
parent 225284a6ca
commit 3a9dddaa57
5 changed files with 21 additions and 33 deletions

View File

@ -7,17 +7,16 @@
#define SYS_sleep 2
#define SYS_write 3
#define SYS_paint 4
#define SYS_rand 5
#define SYS_gettid 6
#define SYS_mmap 7
#define SYS_munmap 8
#define SYS_open 9
#define SYS_read 10
#define SYS_close 11
#define SYS_seek 12
#define SYS_exec 13
#define SYS_fcntl 14
#define SYS_mprotect 15
#define SYS_gettid 5
#define SYS_mmap 6
#define SYS_munmap 7
#define SYS_open 8
#define SYS_read 9
#define SYS_close 10
#define SYS_seek 11
#define SYS_exec 12
#define SYS_fcntl 13
#define SYS_mprotect 14
namespace Syscall
{
@ -31,7 +30,6 @@ void sys_yield(Context* context);
void sys_sleep(Context* context, uint64_t ms);
void sys_write(Context* context, int fd, size_t size, const char* addr);
void sys_paint(Context* context, uint64_t x, uint64_t y, uint64_t w, uint64_t h, uint64_t col);
void sys_rand(Context* context);
void sys_gettid(Context* context);
void sys_mmap(Context* context, void* address, size_t size, int prot);
void sys_munmap(Context* context, void* address, size_t size);

View File

@ -16,7 +16,6 @@ void Syscall::entry(Context* context)
case SYS_sleep: sys_sleep(context, context->rdi); break;
case SYS_write: sys_write(context, (int)context->rdi, context->rsi, (const char*)context->rdx); break;
case SYS_paint: sys_paint(context, context->rdi, context->rsi, context->rdx, context->r10, context->r8); break;
case SYS_rand: sys_rand(context); break;
case SYS_gettid: sys_gettid(context); break;
case SYS_mmap: sys_mmap(context, (void*)context->rdi, context->rsi, (int)context->rdx); break;
case SYS_munmap: sys_munmap(context, (void*)context->rdi, context->rsi); break;

View File

@ -1,7 +0,0 @@
#include "interrupts/Context.h"
#include "rand/Mersenne.h"
void sys_rand(Context* context)
{
context->rax = Mersenne::get();
}

View File

@ -6,17 +6,16 @@
#define SYS_sleep 2
#define SYS_write 3
#define SYS_paint 4
#define SYS_rand 5
#define SYS_gettid 6
#define SYS_mmap 7
#define SYS_munmap 8
#define SYS_open 9
#define SYS_read 10
#define SYS_close 11
#define SYS_seek 12
#define SYS_exec 13
#define SYS_fcntl 14
#define SYS_mprotect 15
#define SYS_gettid 5
#define SYS_mmap 6
#define SYS_munmap 7
#define SYS_open 8
#define SYS_read 9
#define SYS_close 10
#define SYS_seek 11
#define SYS_exec 12
#define SYS_fcntl 13
#define SYS_mprotect 14
#ifndef __want_syscalls
#ifdef __cplusplus

View File

@ -33,8 +33,7 @@ extern "C"
switch (number)
{
case SYS_yield:
case SYS_gettid:
case SYS_rand: result = __luna_syscall0(number); break;
case SYS_gettid: result = __luna_syscall0(number); break;
case SYS_exit:
case SYS_close:
case SYS_exec: