user: implement mlibc as the libc, finally.
It's finally done.. Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#ifndef MLIBC_ARCH_DEFS_HPP
|
||||
#define MLIBC_ARCH_DEFS_HPP
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace mlibc {
|
||||
|
||||
inline constexpr size_t page_size = 0x1000;
|
||||
|
||||
} // namespace mlibc
|
||||
|
||||
#endif // MLIBC_ARCH_DEFS_HPP
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <mlibc/tcb.hpp>
|
||||
|
||||
namespace mlibc {
|
||||
|
||||
inline Tcb *get_current_tcb() {
|
||||
uintptr_t ptr;
|
||||
asm volatile ("movl %%gs:0, %0" : "=r"(ptr));
|
||||
return reinterpret_cast<Tcb *>(ptr);
|
||||
}
|
||||
|
||||
inline uintptr_t get_sp() {
|
||||
uintptr_t esp;
|
||||
asm volatile ("mov %%esp, %0" : "=r"(esp));
|
||||
return esp;
|
||||
}
|
||||
|
||||
} // namespace mlibc
|
||||
|
||||
Reference in New Issue
Block a user