mirror of
https://github.com/Fennix-Project/Userspace.git
synced 2025-07-10 22:59:22 +00:00
Updated userspace
This commit is contained in:
21
libs/include/sysbase.h
Normal file
21
libs/include/sysbase.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __FENNIX_LIBS_BASE_H__
|
||||
#define __FENNIX_LIBS_BASE_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
enum KCtl
|
||||
{
|
||||
KCTL_NULL,
|
||||
KCTL_GET_PID,
|
||||
KCTL_GET_TID,
|
||||
KCTL_GET_UID,
|
||||
KCTL_GET_GID,
|
||||
KCTL_GET_PAGE_SIZE,
|
||||
};
|
||||
|
||||
long DoCtl(uint64_t Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4);
|
||||
|
||||
uintptr_t KrnlRequestPages(size_t Count);
|
||||
void KrnlFreePages(uintptr_t Address, size_t Count);
|
||||
|
||||
#endif // !__FENNIX_LIBS_BASE_H__
|
32
libs/include/sysfile.h
Normal file
32
libs/include/sysfile.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef __FENNIX_LIBS_SYS_FILE_H__
|
||||
#define __FENNIX_LIBS_SYS_FILE_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *KernelPrivate;
|
||||
} File;
|
||||
|
||||
enum FileFlags
|
||||
{
|
||||
FILE_READ = 1,
|
||||
FILE_WRITE = 2,
|
||||
FILE_APPEND = 4,
|
||||
FILE_CREATE = 8,
|
||||
FILE_TRUNCATE = 16,
|
||||
FILE_EXCLUSIVE = 32,
|
||||
FILE_DIRECTORY = 64,
|
||||
FILE_SYMLINK = 128,
|
||||
FILE_NONBLOCK = 256,
|
||||
FILE_CLOEXEC = 512,
|
||||
};
|
||||
|
||||
File *FileOpen(const char *Path, uint64_t Flags);
|
||||
void FileClose(File *File);
|
||||
uint64_t FileRead(File *File, uint8_t *Buffer, uint64_t Size);
|
||||
uint64_t FileWrite(File *File, uint8_t *Buffer, uint64_t Size);
|
||||
uint64_t FileSeek(File *File, uint64_t Offset, uint64_t Whence);
|
||||
uint64_t FileStatus(File *File);
|
||||
|
||||
#endif // !__FENNIX_LIBS_SYS_FILE_H__
|
@ -1,17 +0,0 @@
|
||||
#ifndef __FENNIX_LIBS_SYS_H__
|
||||
#define __FENNIX_LIBS_SYS_H__
|
||||
|
||||
#include <types.h>
|
||||
|
||||
enum KCtl
|
||||
{
|
||||
KCTL_NULL,
|
||||
KCTL_GETPID,
|
||||
KCTL_GETTID,
|
||||
KCTL_GETUID,
|
||||
KCTL_GETGID,
|
||||
};
|
||||
|
||||
long DoCtl(uint64_t Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4);
|
||||
|
||||
#endif // !__FENNIX_LIBS_SYS_H__
|
122
libs/include/sysproc.h
Normal file
122
libs/include/sysproc.h
Normal file
@ -0,0 +1,122 @@
|
||||
#ifndef __FENNIX_LIBS_SYS_PROC_H__
|
||||
#define __FENNIX_LIBS_SYS_PROC_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
enum ProcessState
|
||||
{
|
||||
PROCESS_STATE_READY,
|
||||
PROCESS_STATE_RUNNING,
|
||||
PROCESS_STATE_SLEEPING,
|
||||
PROCESS_STATE_WAITING,
|
||||
PROCESS_STATE_STOPPED,
|
||||
PROCESS_STATE_TERMINATED
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char Name[256];
|
||||
unsigned long ID;
|
||||
enum ProcessState State;
|
||||
void *KernelPrivate;
|
||||
} Process;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char Name[256];
|
||||
unsigned long ID;
|
||||
enum ProcessState State;
|
||||
void *KernelPrivate;
|
||||
} Thread;
|
||||
|
||||
/**
|
||||
* @brief Create a new process from a path
|
||||
*
|
||||
* @param Path Path to the executable
|
||||
* @return Process* Pointer to the process structure
|
||||
*/
|
||||
Process *Spawn(const char *Path);
|
||||
|
||||
/**
|
||||
* @brief Create a new thread
|
||||
*
|
||||
* @param EntryPoint Entry point of the thread
|
||||
* @return Thread* Pointer to the thread structure
|
||||
*/
|
||||
Thread *SpawnThread(uintptr_t EntryPoint);
|
||||
|
||||
/**
|
||||
* @brief Get list of threads
|
||||
*
|
||||
* @param Process Process to get the threads from
|
||||
* @return Thread** Pointer to the thread list (NULL terminated)
|
||||
*/
|
||||
Thread **GetThreadList(Process *Process);
|
||||
|
||||
/**
|
||||
* @brief Get process by ID
|
||||
*
|
||||
* @param ID Process ID
|
||||
* @return Process* Pointer to the process structure
|
||||
*/
|
||||
Process *GetProcessByID(unsigned long ID);
|
||||
|
||||
/**
|
||||
* @brief Get thread by ID
|
||||
*
|
||||
* @param ID Thread ID
|
||||
* @return Thread* Pointer to the thread structure
|
||||
*/
|
||||
Thread *GetThreadByID(unsigned long ID);
|
||||
|
||||
/**
|
||||
* @brief Get current process
|
||||
*
|
||||
* @return Process* Pointer to the process structure
|
||||
*/
|
||||
Process *GetCurrentProcess();
|
||||
|
||||
/**
|
||||
* @brief Get current thread
|
||||
*
|
||||
* @return Thread* Pointer to the thread structure
|
||||
*/
|
||||
Thread *GetCurrentThread();
|
||||
|
||||
/**
|
||||
* @brief [SYSTEM] Create a new empty process
|
||||
*
|
||||
* @param KernelPrivate Process parent
|
||||
* @param Name Process name
|
||||
* @param TrustLevel Process trust level [RESERVED FOR TRUSTED PROCESSES]
|
||||
* @param Image Process file image already loaded in memory
|
||||
* @return Process* Pointer to the process structure
|
||||
*/
|
||||
Process *KrnlCreateProcess(void *KernelPrivate,
|
||||
const char *Name,
|
||||
long TrustLevel,
|
||||
void *Image);
|
||||
|
||||
/**
|
||||
* @brief [SYSTEM] Create a new thread
|
||||
*
|
||||
* @param KernelPrivate Process parent
|
||||
* @param EntryPoint Entry point of the thread
|
||||
* @param argv Arguments
|
||||
* @param envp Environment variables
|
||||
* @param auxv Auxiliary variables
|
||||
* @param Offset Offset of the entry point
|
||||
* @param Architecture Architecture of the thread
|
||||
* @param Compatibility Compatibility of the thread
|
||||
* @return Thread* Pointer to the thread structure
|
||||
*/
|
||||
Thread *KrnlCreateThread(void *KernelPrivate,
|
||||
unsigned long EntryPoint,
|
||||
const char **argv,
|
||||
const char **envp,
|
||||
void *auxv,
|
||||
unsigned long Offset,
|
||||
long Architecture,
|
||||
long Compatibility);
|
||||
|
||||
#endif // !__FENNIX_LIBS_SYS_PROC_H__
|
Reference in New Issue
Block a user