mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Add syscalls test
This commit is contained in:
parent
d472fddb61
commit
39c3d4e2f2
@ -16,6 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
#ifdef DEBUG
|
||||||
|
#include "Tests/t.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <filesystem/ustar.hpp>
|
#include <filesystem/ustar.hpp>
|
||||||
#include <power.hpp>
|
#include <power.hpp>
|
||||||
@ -127,15 +130,24 @@ uint64_t GetUsage(uint64_t OldSystemTime, Tasking::TaskInfo *Info)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ShowTaskManager = 0;
|
||||||
|
|
||||||
void TaskMgr()
|
void TaskMgr()
|
||||||
{
|
{
|
||||||
TaskManager->GetCurrentThread()->Rename("Debug Task Manager");
|
TaskManager->GetCurrentThread()->Rename("Debug Task Manager");
|
||||||
TaskManager->GetCurrentThread()->SetPriority(Tasking::Low);
|
TaskManager->GetCurrentThread()->SetPriority(Tasking::Low);
|
||||||
|
|
||||||
|
while (ShowTaskManager == 0)
|
||||||
|
CPU::Pause();
|
||||||
|
|
||||||
TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)TaskMgr_Dummy100Usage)->Rename("Dummy 100% Usage");
|
TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)TaskMgr_Dummy100Usage)->Rename("Dummy 100% Usage");
|
||||||
TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)TaskMgr_Dummy0Usage)->Rename("Dummy 0% Usage");
|
TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)TaskMgr_Dummy0Usage)->Rename("Dummy 0% Usage");
|
||||||
|
|
||||||
while (1)
|
while (true)
|
||||||
{
|
{
|
||||||
|
while (ShowTaskManager == 0)
|
||||||
|
CPU::Pause();
|
||||||
|
|
||||||
static int sanity = 0;
|
static int sanity = 0;
|
||||||
Video::ScreenBuffer *sb = Display->GetBuffer(0);
|
Video::ScreenBuffer *sb = Display->GetBuffer(0);
|
||||||
for (short i = 0; i < 1000; i++)
|
for (short i = 0; i < 1000; i++)
|
||||||
@ -191,6 +203,48 @@ void TaskMgr()
|
|||||||
TaskManager->Sleep(100);
|
TaskManager->Sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestSyscallsKernel()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
KPrint("Testing syscalls...");
|
||||||
|
Tasking::PCB *SyscallsTestProcess = TaskManager->CreateProcess(TaskManager->GetCurrentProcess(),
|
||||||
|
"Syscalls Test",
|
||||||
|
Tasking::TaskTrustLevel::User,
|
||||||
|
KernelSymbolTable);
|
||||||
|
|
||||||
|
Tasking::TCB *SyscallsTestThread = TaskManager->CreateThread(SyscallsTestProcess,
|
||||||
|
(Tasking::IP)TestSyscalls,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
std::vector<AuxiliaryVector>(),
|
||||||
|
0,
|
||||||
|
Tasking::TaskArchitecture::x64,
|
||||||
|
Tasking::TaskCompatibility::Native,
|
||||||
|
true);
|
||||||
|
SyscallsTestThread->SetCritical(true);
|
||||||
|
TaskManager->GetSecurityManager()->TrustToken(SyscallsTestThread->Security.UniqueToken, Tasking::TTL::FullTrust);
|
||||||
|
|
||||||
|
Memory::Virtual va = Memory::Virtual(SyscallsTestProcess->PageTable);
|
||||||
|
|
||||||
|
// va.Remap((void *)TestSyscalls, va.GetPhysical((void *)TestSyscalls), Memory::P | Memory::RW | Memory::US);
|
||||||
|
|
||||||
|
// for (uintptr_t k = (uintptr_t)&_kernel_start; k < (uintptr_t)&_kernel_end; k += PAGE_SIZE)
|
||||||
|
// {
|
||||||
|
// va.Remap((void *)k, (void *)va.GetPhysical((void *)k), Memory::P | Memory::RW | Memory::US);
|
||||||
|
// debug("Remapped %#lx %#lx", k, va.GetPhysical((void *)k));
|
||||||
|
// }
|
||||||
|
|
||||||
|
for (uintptr_t k = (uintptr_t)TestSyscalls - PAGE_SIZE; k < (uintptr_t)TestSyscalls + FROM_PAGES(5); k += PAGE_SIZE)
|
||||||
|
{
|
||||||
|
va.Remap((void *)k, (void *)va.GetPhysical((void *)k), Memory::P | Memory::RW | Memory::US);
|
||||||
|
debug("Remapped %#lx %#lx", k, va.GetPhysical((void *)k));
|
||||||
|
}
|
||||||
|
|
||||||
|
SyscallsTestThread->Status = Tasking::TaskStatus::Ready;
|
||||||
|
TaskManager->WaitForThread(SyscallsTestThread);
|
||||||
|
KPrint("Test complete");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Execute::SpawnData SpawnInit()
|
Execute::SpawnData SpawnInit()
|
||||||
@ -363,8 +417,9 @@ void KernelMainThread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Tasking::TCB *tskMgr = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)TaskMgr);
|
Tasking::TCB *tskMgr = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)TaskMgr);
|
||||||
TreeFS(vfs->GetRootNode(), 0);
|
TreeFS(vfs->GetRootNode(), 0);
|
||||||
|
TestSyscallsKernel();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KPrint("Kernel Compiled at: %s %s with C++ Standard: %d", __DATE__, __TIME__, CPP_LANGUAGE_STANDARD);
|
KPrint("Kernel Compiled at: %s %s with C++ Standard: %d", __DATE__, __TIME__, CPP_LANGUAGE_STANDARD);
|
||||||
|
47
Tests/TestSyscalls.c
Normal file
47
Tests/TestSyscalls.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
#include "../syscalls.h"
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
|
||||||
|
__aligned(0x1000) __no_stack_protector void TestSyscalls()
|
||||||
|
{
|
||||||
|
__asm__ __volatile__("syscall"
|
||||||
|
:
|
||||||
|
: "a"(_Print), "D"('H'), "S"(0)
|
||||||
|
: "rcx", "r11", "memory");
|
||||||
|
|
||||||
|
int fork_id = -0xda;
|
||||||
|
|
||||||
|
__asm__ __volatile__("syscall"
|
||||||
|
: "=a"(fork_id)
|
||||||
|
: "a"(_Fork)
|
||||||
|
: "rcx", "r11", "memory");
|
||||||
|
|
||||||
|
__asm__ __volatile__("syscall"
|
||||||
|
:
|
||||||
|
: "a"(_Exit), "D"(fork_id)
|
||||||
|
: "rcx", "r11", "memory");
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
void TestString();
|
void TestString();
|
||||||
void TestMemoryAllocation();
|
void TestMemoryAllocation();
|
||||||
|
EXTERNC void TestSyscalls();
|
||||||
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
#endif // !__FENNIX_KERNEL_non_constructor_tests_H__
|
#endif // !__FENNIX_KERNEL_non_constructor_tests_H__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user