mirror of
https://github.com/Fennix-Project/Userspace.git
synced 2025-07-11 15:19:21 +00:00
Updated userspace
This commit is contained in:
18
libs/libsys/Base.c
Normal file
18
libs/libsys/Base.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include <sysbase.h>
|
||||
|
||||
#include "../../../Kernel/syscalls.h"
|
||||
|
||||
long DoCtl(uint64_t Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4)
|
||||
{
|
||||
return syscall5(_KernelCTL, Command, Arg1, Arg2, Arg3, Arg4);
|
||||
}
|
||||
|
||||
uintptr_t KrnlRequestPages(size_t Count)
|
||||
{
|
||||
return syscall1(_RequestPages, Count);
|
||||
}
|
||||
|
||||
void KrnlFreePages(uintptr_t Address, size_t Count)
|
||||
{
|
||||
syscall2(_FreePages, Address, Count);
|
||||
}
|
45
libs/libsys/File.c
Normal file
45
libs/libsys/File.c
Normal file
@ -0,0 +1,45 @@
|
||||
#include <sysbase.h>
|
||||
#include <sysfile.h>
|
||||
|
||||
#include "../../../Kernel/syscalls.h"
|
||||
|
||||
long __FILE_GetPageSize()
|
||||
{
|
||||
static long PageSize = 0;
|
||||
if (PageSize == 0)
|
||||
PageSize = DoCtl(KCTL_GET_PAGE_SIZE, 0, 0, 0, 0);
|
||||
return PageSize;
|
||||
}
|
||||
|
||||
File *FileOpen(const char *Path, uint64_t Flags)
|
||||
{
|
||||
File *FilePtr = (File *)KrnlRequestPages(sizeof(File) / __FILE_GetPageSize() + 1);
|
||||
FilePtr->KernelPrivate = (void *)syscall2(_FileOpen, (uint64_t)Path, Flags);
|
||||
return FilePtr;
|
||||
}
|
||||
|
||||
void FileClose(File *File)
|
||||
{
|
||||
syscall1(_FileClose, (uint64_t)File->KernelPrivate);
|
||||
KrnlFreePages((uintptr_t)File, sizeof(File) / __FILE_GetPageSize() + 1);
|
||||
}
|
||||
|
||||
uint64_t FileRead(File *File, uint8_t *Buffer, uint64_t Size)
|
||||
{
|
||||
return syscall3(_FileRead, (uint64_t)File->KernelPrivate, (uint64_t)Buffer, Size);
|
||||
}
|
||||
|
||||
uint64_t FileWrite(File *File, uint8_t *Buffer, uint64_t Size)
|
||||
{
|
||||
return syscall3(_FileWrite, (uint64_t)File->KernelPrivate, (uint64_t)Buffer, Size);
|
||||
}
|
||||
|
||||
uint64_t FileSeek(File *File, uint64_t Offset, uint64_t Whence)
|
||||
{
|
||||
return syscall3(_FileSeek, (uint64_t)File->KernelPrivate, Offset, Whence);
|
||||
}
|
||||
|
||||
uint64_t FileStatus(File *File)
|
||||
{
|
||||
return syscall1(_FileStatus, (uint64_t)File->KernelPrivate);
|
||||
}
|
@ -4,7 +4,7 @@ include ../../../Makefile.conf
|
||||
NAME=sys
|
||||
|
||||
OBJECT_NAME=lib$(NAME).so
|
||||
SO_NAME=libsys
|
||||
SO_NAME=$(OBJECT_NAME)
|
||||
|
||||
OUTPUT_DIR=../../out/system/lib/
|
||||
SYSROOT = --sysroot=../../out/system/
|
||||
|
6
libs/libsys/Process.c
Normal file
6
libs/libsys/Process.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <sysbase.h>
|
||||
#include <sysproc.h>
|
||||
|
||||
#include "../../../Kernel/syscalls.h"
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
#include <syslib.h>
|
||||
|
||||
#include "../../../Kernel/syscalls.h"
|
||||
|
||||
long DoCtl(uint64_t Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4)
|
||||
{
|
||||
return syscall5(_KernelCTL, Command, Arg1, Arg2, Arg3, Arg4);
|
||||
}
|
Reference in New Issue
Block a user