NeKernel dev
Loading...
Searching...
No Matches
Kernel::HAL Namespace Reference

Hardware Abstraction Layer. More...

Namespaces

namespace  Detail

Classes

struct  HAL_HARDWARE_THREAD
struct  LAPIC
struct  SDT_OBJECT
 Multiple APIC Descriptor Table. More...
struct  StackFrame
 Stack frame (as retrieved from assembly.) More...

Typedefs

typedef UInt32 PageTableIndex
typedef UIntPtr Reg
typedef StackFrameStackFramePtr

Functions

auto mm_is_bitmap (VoidPtr ptr) -> Bool
 Check whether this pointer is a bitmap object.
EXTERN_C Void sched_jump_to_task (StackFramePtr stack_frame)
Void hal_send_ipi_msg (UInt32 target, UInt32 apic_id, UInt8 vector)
 Send end IPI for CPU.
EXTERN_C HAL::StackFramePtr mp_get_current_task (ThreadID thrdid)
 Get current stack frame for a thread.
EXTERN_C BOOL mp_register_task (HAL::StackFramePtr stack_frame, ThreadID thrdid)
 Register current stack frame for a thread.
Bool mp_is_smp (Void) noexcept
 Is the current config SMP aware?
Void mp_init_cores (VoidPtr vendor_ptr) noexcept
 Fetch and enable SMP scheduler.
STATIC Void mmi_page_status (Detail::PTE *pte)
 Retrieve the page status of a PTE.
EXTERN_C UIntPtr mm_get_page_addr (VoidPtr virt)
 Gets a physical address from a virtual address.
EXTERN_C Int32 mm_memory_fence (VoidPtr virtual_address)
 clflush+mfence helper function.
EXTERN_C Int32 mm_map_page (VoidPtr virtual_address, VoidPtr physical_address, UInt32 flags, UInt32 level)
 Maps or allocates a page from virtual_address.
Bool hal_has_msr () noexcept
Void hal_get_msr (UInt32 msr, UInt32 *lo, UInt32 *hi) noexcept
Void hal_set_msr (UInt32 msr, UInt32 lo, UInt32 hi) noexcept
Void lrt_hal_out8 (UInt16 port, UInt8 value)
Void lrt_hal_out16 (UInt16 port, UInt16 value)
Void lrt_hal_out32 (UInt16 port, UInt32 value)
UInt8 lrt_hal_in8 (UInt16 port)
UInt16 lrt_hal_in16 (UInt16 port)
UInt32 lrt_hal_in32 (UInt16 port)
Void rt_halt ()
Void rt_cli ()
Void rt_sti ()
Void rt_cld ()
Void rt_std ()
auto mm_alloc_bitmap (Boolean wr, Boolean user, SizeT size, Bool is_page, SizeT pad) -> VoidPtr
 Allocate a new page to be used by the OS.
auto mm_free_bitmap (VoidPtr ptr) -> Bool
 Free Bitmap, and mark it as absent.

Variables

STATIC HAL_APIC_MADT * kSMPBlock = nullptr
STATIC Bool kSMPAware = false
STATIC Int64 kSMPCount = 0
EXTERN_C UIntPtr kApicBaseAddress
STATIC Int32 kSMPInterrupt = 0
STATIC UInt64 kAPICLocales [kMaxAPInsideSched] = {0}
STATIC VoidPtr kRawMADT = nullptr
STATIC HAL_HARDWARE_THREAD kHWThread [kSchedProcessLimitPerTeam] = {{}}

Detailed Description

Hardware Abstraction Layer.

The HAL namespace.

Note
: _hal_switch_context is internal

Typedef Documentation

◆ PageTableIndex

◆ Reg

◆ StackFramePtr

Function Documentation

◆ hal_get_msr()

Void Kernel::HAL::hal_get_msr ( UInt32 msr,
UInt32 * lo,
UInt32 * hi )
noexcept

◆ hal_has_msr()

Bool Kernel::HAL::hal_has_msr ( )
inlinenoexcept

◆ hal_send_ipi_msg()

Void Kernel::HAL::hal_send_ipi_msg ( UInt32 target,
UInt32 apic_id,
UInt8 vector )

Send end IPI for CPU.

Parameters
apic_id
vector
target
Returns

◆ hal_set_msr()

Void Kernel::HAL::hal_set_msr ( UInt32 msr,
UInt32 lo,
UInt32 hi )
noexcept

◆ lrt_hal_in16()

UInt16 Kernel::HAL::lrt_hal_in16 ( UInt16 port)

◆ lrt_hal_in32()

UInt32 Kernel::HAL::lrt_hal_in32 ( UInt16 port)

◆ lrt_hal_in8()

UInt8 Kernel::HAL::lrt_hal_in8 ( UInt16 port)

◆ lrt_hal_out16()

Void Kernel::HAL::lrt_hal_out16 ( UInt16 port,
UInt16 value )

◆ lrt_hal_out32()

Void Kernel::HAL::lrt_hal_out32 ( UInt16 port,
UInt32 value )

◆ lrt_hal_out8()

Void Kernel::HAL::lrt_hal_out8 ( UInt16 port,
UInt8 value )

◆ mm_alloc_bitmap()

auto Kernel::HAL::mm_alloc_bitmap ( Boolean wr,
Boolean user,
SizeT size,
Bool is_page,
SizeT pad ) -> VoidPtr

Allocate a new page to be used by the OS.

Parameters
wrread/write bit.
useruser bit.
Returns
a new bitmap allocated pointer.

◆ mm_free_bitmap()

auto Kernel::HAL::mm_free_bitmap ( VoidPtr ptr) -> Bool

Free Bitmap, and mark it as absent.

Parameters
ptrthe pointer to free.

◆ mm_get_page_addr()

EXTERN_C UIntPtr Kernel::HAL::mm_get_page_addr ( VoidPtr virt)

Gets a physical address from a virtual address.

Parameters
virta valid virtual address.
Returns
Physical address.

◆ mm_is_bitmap()

auto Kernel::HAL::mm_is_bitmap ( VoidPtr ptr) -> Bool

Check whether this pointer is a bitmap object.

Parameters
ptrargument to verify.
whethersuccessful or not.

◆ mm_map_page()

EXTERN_C Int32 Kernel::HAL::mm_map_page ( VoidPtr virtual_address,
VoidPtr physical_address,
UInt32 flags,
UInt32 level )

Maps or allocates a page from virtual_address.

Parameters
virtual_addressa valid virtual address.
phys_addrpoint to physical address.
flagsthe flags to put on the page.
Returns
Status code of page manipulation process.
Todo
support PML4, and PDPT levels.

◆ mm_memory_fence()

EXTERN_C Int32 Kernel::HAL::mm_memory_fence ( VoidPtr virtual_address)

clflush+mfence helper function.

◆ mmi_page_status()

STATIC Void Kernel::HAL::mmi_page_status ( Detail::PTE * pte)

Retrieve the page status of a PTE.

Parameters
ptePage Table Entry pointer.

◆ mp_get_current_task()

EXTERN_C HAL::StackFramePtr Kernel::HAL::mp_get_current_task ( ThreadID thrdid)

Get current stack frame for a thread.

Parameters
thrdidThe thread ID.

◆ mp_init_cores()

Void Kernel::HAL::mp_init_cores ( VoidPtr vendor_ptr)
noexcept

Fetch and enable SMP scheduler.

Parameters
vendor_ptrSMP containing structure.

◆ mp_is_smp()

Bool Kernel::HAL::mp_is_smp ( Void )
noexcept

Is the current config SMP aware?

Returns
True if YES, False if not.

◆ mp_register_task()

EXTERN_C BOOL Kernel::HAL::mp_register_task ( HAL::StackFramePtr stack_frame,
ThreadID thrdid )

Register current stack frame for a thread.

Parameters
stack_frameThe current stack frame.
thrdidThe thread ID.

◆ rt_cld()

Void Kernel::HAL::rt_cld ( )

◆ rt_cli()

void Kernel::HAL::rt_cli ( )
inline

◆ rt_halt()

void Kernel::HAL::rt_halt ( )
inline

◆ rt_std()

Void Kernel::HAL::rt_std ( )

◆ rt_sti()

Void Kernel::HAL::rt_sti ( )

◆ sched_jump_to_task()

EXTERN_C Void Kernel::HAL::sched_jump_to_task ( StackFramePtr stack_frame)

Variable Documentation

◆ kApicBaseAddress

EXTERN_C UIntPtr Kernel::HAL::kApicBaseAddress

◆ kAPICLocales

STATIC UInt64 Kernel::HAL::kAPICLocales[kMaxAPInsideSched] = {0}

◆ kHWThread

STATIC HAL_HARDWARE_THREAD Kernel::HAL::kHWThread[kSchedProcessLimitPerTeam] = {{}}

◆ kRawMADT

STATIC VoidPtr Kernel::HAL::kRawMADT = nullptr

◆ kSMPAware

STATIC Bool Kernel::HAL::kSMPAware = false

◆ kSMPBlock

STATIC HAL_APIC_MADT* Kernel::HAL::kSMPBlock = nullptr

◆ kSMPCount

STATIC Int64 Kernel::HAL::kSMPCount = 0

◆ kSMPInterrupt

STATIC Int32 Kernel::HAL::kSMPInterrupt = 0