mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 07:19:20 +00:00
Updated kernel (tl;dr: improved filesystem, tasking, loading files, etc..)
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include <filesystem.hpp>
|
||||
#include <task.hpp>
|
||||
#include <elf.h>
|
||||
|
||||
@ -21,9 +22,10 @@ namespace Execute
|
||||
|
||||
enum ExStatus
|
||||
{
|
||||
OK,
|
||||
Unknown,
|
||||
OK,
|
||||
Unsupported,
|
||||
GenericError,
|
||||
InvalidFile,
|
||||
InvalidFileFormat,
|
||||
InvalidFileHeader,
|
||||
@ -39,21 +41,78 @@ namespace Execute
|
||||
Tasking::TCB *Thread;
|
||||
};
|
||||
|
||||
struct SharedLibraries
|
||||
{
|
||||
char Identifier[256];
|
||||
uint64_t Timeout;
|
||||
long RefCount;
|
||||
|
||||
void *Address;
|
||||
void *MemoryImage;
|
||||
size_t Length;
|
||||
};
|
||||
|
||||
struct ELFBaseLoad
|
||||
{
|
||||
bool Success;
|
||||
SpawnData sd;
|
||||
Tasking::IP InstructionPointer;
|
||||
|
||||
/* This should be deleted after copying the allocated pages to the thread
|
||||
Intended to be used only inside BaseLoad.cpp */
|
||||
Memory::MemMgr *TmpMem;
|
||||
|
||||
/* Same as above, for BaseLoad.cpp only */
|
||||
Vector<AuxiliaryVector> auxv;
|
||||
};
|
||||
|
||||
BinaryType GetBinaryType(void *Image);
|
||||
BinaryType GetBinaryType(char *Path);
|
||||
|
||||
SpawnData Spawn(char *Path, const char **argv, const char **envp);
|
||||
|
||||
void *ELFLoadRel(Elf64_Ehdr *Header);
|
||||
void ELFLoadExec(void *BaseImage,
|
||||
size_t Length,
|
||||
Elf64_Ehdr *ELFHeader,
|
||||
Memory::Virtual &pva,
|
||||
SpawnData *ret,
|
||||
char *Path,
|
||||
Tasking::PCB *Process,
|
||||
const char **argv,
|
||||
const char **envp,
|
||||
Tasking::TaskArchitecture Arch,
|
||||
Tasking::TaskCompatibility Comp);
|
||||
ELFBaseLoad ELFLoad(char *Path, const char **argv, const char **envp,
|
||||
Tasking::TaskCompatibility Compatibility = Tasking::TaskCompatibility::Native);
|
||||
|
||||
Elf64_Shdr *GetELFSheader(Elf64_Ehdr *Header);
|
||||
Elf64_Shdr *GetELFSection(Elf64_Ehdr *Header, uint64_t Index);
|
||||
char *GetELFStringTable(Elf64_Ehdr *Header);
|
||||
char *ELFLookupString(Elf64_Ehdr *Header, uintptr_t Offset);
|
||||
void *ELFLookupSymbol(Elf64_Ehdr *Header, const char *Name);
|
||||
uintptr_t ELFGetSymbolValue(Elf64_Ehdr *Header, uint64_t Table, uint64_t Index);
|
||||
Elf64_Dyn *ELFGetDynamicTag(void *ElfFile, enum DynamicArrayTags Tag);
|
||||
|
||||
/**
|
||||
* @brief Create a ELF Memory Image
|
||||
*
|
||||
* @param mem The memory manager to use
|
||||
* @param pV Memory::Virtual object to use
|
||||
* @param ElfFile ELF file loaded in memory (FULL FILE)
|
||||
* @param Length Length of @p ElfFile
|
||||
* @return void* The Memory Image
|
||||
*/
|
||||
void *ELFCreateMemoryImage(Memory::MemMgr *mem, Memory::Virtual &pV, void *ElfFile, size_t Length);
|
||||
|
||||
uintptr_t LoadELFInterpreter(Memory::MemMgr *mem, Memory::Virtual &pV, const char *Interpreter);
|
||||
|
||||
ELFBaseLoad ELFLoadRel(void *ElfFile,
|
||||
VirtualFileSystem::File *ExFile,
|
||||
Tasking::PCB *Process);
|
||||
|
||||
ELFBaseLoad ELFLoadExec(void *ElfFile,
|
||||
VirtualFileSystem::File *ExFile,
|
||||
Tasking::PCB *Process);
|
||||
|
||||
ELFBaseLoad ELFLoadDyn(void *ElfFile,
|
||||
VirtualFileSystem::File *ExFile,
|
||||
Tasking::PCB *Process);
|
||||
|
||||
void StartExecuteService();
|
||||
SharedLibraries *AddLibrary(char *Identifier,
|
||||
void *ElfImage,
|
||||
size_t Length,
|
||||
const Memory::Virtual &pV = Memory::Virtual());
|
||||
void SearchLibrary(char *Identifier);
|
||||
}
|
||||
|
||||
#endif // !__FENNIX_KERNEL_FILE_EXECUTE_H__
|
||||
|
Reference in New Issue
Block a user