Update userspace

This commit is contained in:
Alex
2023-08-06 04:52:48 +03:00
parent 0f8cb900cb
commit 2fd23205db
49 changed files with 437 additions and 525 deletions

View File

@ -1,11 +0,0 @@
#ifndef __FENNIX_LIBS_BASE_H__
#define __FENNIX_LIBS_BASE_H__
#include <stddef.h>
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__

View File

@ -1,32 +0,0 @@
#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, uint64_t Offset, uint8_t *Buffer, uint64_t Size);
uint64_t FileWrite(File *File, uint64_t Offset, 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__

View File

@ -1,122 +0,0 @@
#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__

View File

@ -1,6 +0,0 @@
#ifndef __FENNIX_LIBS_SSP_H__
#define __FENNIX_LIBS_SSP_H__
#include <types.h>
#endif // !__FENNIX_LIBS_SSP_H__