mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-19 01:25:05 -04:00
Move implementation to source file
This commit is contained in:
parent
ac602e40ed
commit
7321fbfa44
@ -9,50 +9,16 @@
|
||||
#define USER_SYSTEM_HPP
|
||||
|
||||
#include <types.hpp>
|
||||
#include <expected.hpp>
|
||||
|
||||
void exit(size_t return_code) __attribute__((noreturn));
|
||||
|
||||
void exit(size_t return_code) {
|
||||
asm volatile("mov rax, 0x666; int 50"
|
||||
: //No outputs
|
||||
: "b" (return_code)
|
||||
: "rax");
|
||||
int64_t exec(const char* executable);
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
void await_termination(size_t pid);
|
||||
|
||||
size_t exec(const char* executable) {
|
||||
size_t pid;
|
||||
asm volatile("mov rax, 5; int 50; mov %0, rax"
|
||||
: "=m" (pid)
|
||||
: "b" (reinterpret_cast<size_t>(executable))
|
||||
: "rax");
|
||||
return pid;
|
||||
}
|
||||
int64_t exec_and_wait(const char* executable);
|
||||
|
||||
void await_termination(size_t pid) {
|
||||
asm volatile("mov rax, 6; int 50;"
|
||||
: //No outputs
|
||||
: "b" (pid)
|
||||
: "rax");
|
||||
}
|
||||
|
||||
int64_t exec_and_wait(const char* executable){
|
||||
int64_t pid = exec(executable);
|
||||
|
||||
if(pid < 0){
|
||||
return pid;
|
||||
} else {
|
||||
await_termination(pid);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void sleep_ms(size_t ms){
|
||||
asm volatile("mov rax, 4; int 50"
|
||||
: //No outputs
|
||||
: "b" (ms)
|
||||
: "rax");
|
||||
}
|
||||
void sleep_ms(size_t ms);
|
||||
|
||||
#endif
|
||||
|
51
tlib/src/system.cpp
Normal file
51
tlib/src/system.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
//=======================================================================
|
||||
// Copyright Baptiste Wicht 2013-2014.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include <system.hpp>
|
||||
|
||||
void exit(size_t return_code) {
|
||||
asm volatile("mov rax, 0x666; int 50"
|
||||
: //No outputs
|
||||
: "b" (return_code)
|
||||
: "rax");
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
int64_t exec(const char* executable) {
|
||||
int64_t pid;
|
||||
asm volatile("mov rax, 5; int 50; mov %0, rax"
|
||||
: "=m" (pid)
|
||||
: "b" (reinterpret_cast<size_t>(executable))
|
||||
: "rax");
|
||||
return pid;
|
||||
}
|
||||
|
||||
void await_termination(size_t pid) {
|
||||
asm volatile("mov rax, 6; int 50;"
|
||||
: //No outputs
|
||||
: "b" (pid)
|
||||
: "rax");
|
||||
}
|
||||
|
||||
int64_t exec_and_wait(const char* executable){
|
||||
int64_t pid = exec(executable);
|
||||
|
||||
if(pid < 0){
|
||||
return pid;
|
||||
} else {
|
||||
await_termination(pid);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void sleep_ms(size_t ms){
|
||||
asm volatile("mov rax, 4; int 50"
|
||||
: //No outputs
|
||||
: "b" (ms)
|
||||
: "rax");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user