9_Static_assert(
sizeof(
void*) == 8,
"This Kernel is 64 bit only! The 32bit version is deprecated.");
32#define MAX_AHCI_CONTROLLERS 32
41#define MAX_MEMORY_MAP_SIZE 0x8000
46 if (!boot_info || !boot_info->
MemoryMap)
return;
73 if (!boot_info)
return;
80 for (uint32_t i = 0; i < boot_info->
AhciCount; i++) {
91static inline bool interrupts_enabled(
void) {
93 __asm__ __volatile__(
"pushfq; popq %0"
97 return (
flags & (1UL << 9)) != 0;
101 gop_printf(0xFF000FF0,
"Reached the scheduler!\n");
103 if (!interrupts_enabled()) {
117static void test(
MUTEX* mut) {
122 volatile uint64_t z = 0;
124 for (uint64_t i = 0; i < 0xA; i++) {
126 for (uint64_t i = 0; i < 0xFFFFFFF; i++) {
135static void MeCreateInitialUserModeProcess(
void) {
152volatile uintptr_t __stack_chk_guard;
155void __stack_chk_fail(
void) {
164static void InitSystemProcess(
void) {
226 uint64_t temp_canary = 0;
227 bool rdrand_ok =
false;
228 for (
int n = 0; n < 64; n++) {
236 __stack_chk_guard = temp_canary;
244 if (__stack_chk_guard == 0) {
245 __stack_chk_guard = 0xDEADC0DEDEADC0DE;
253 "lea 1f(%%rip), %0\n\t"
278 gop_printf_forced(0xFF964B00,
"buf4 addr (should reside after buf3, allocated 2048 bytes): %p\n", buf4);
280 gop_printf_forced(0xFF964B00,
"buf5 addr (should be a larger addr): %p\n", buf5);
282 gop_printf_forced(0xFFFFFF00,
"buf6 addr (should use dynamic memory): %p\n", buf6);
284 gop_printf_forced(0xFFFFFF00,
"buf7 addr (should use dynamic memory, extremely larger): %p\n", buf7);
299#define ISRAEL_UTC_OFFSET 3
302 status =
vfs_listdir(
"/", listings,
sizeof(listings));
320 gop_printf(
COLOR_RED,
"**[MTSTATUS-FAILURE]** ParseLAPICs status returned: %x, continuing in UP mode.\n", status);
334 __builtin_unreachable();
BOOT_INFO boot_info_local
MTSTATUS MhParseLAPICs(uint8_t *buffer, size_t maxCPUs, uint32_t *cpuCount, uint32_t *lapicAddress)
MTSTATUS MhInitializeACPI(void)
void lapic_timer_calibrate(void)
int init_lapic_timer(uint32_t hz)
void lapic_init_cpu(void)
NORETURN void MeBugCheck(IN enum _BUGCHECK_CODES BugCheckCode)
NORETURN void MeBugCheckEx(IN enum _BUGCHECK_CODES BugCheckCode, IN void *BugCheckParameter1, IN void *BugCheckParameter2, IN void *BugCheckParameter3, IN void *BugCheckParameter4)
struct _EPROCESS EPROCESS
struct _PROCESSOR PROCESSOR
struct _GOP_PARAMS GOP_PARAMS
struct _BOOT_INFO BOOT_INFO
struct _EFI_MEMORY_DESCRIPTOR EFI_MEMORY_DESCRIPTOR
void gop_printf(uint32_t color, const char *fmt,...)
char * kstrncpy(char *dst, const char *src, size_t n)
void gop_clear_screen(GOP_PARAMS *gop, uint32_t color)
PHANDLE_TABLE HtCreateHandleTable(IN PEPROCESS Process)
FORCEINLINE void __writemsr(uint32_t msr, uint64_t value)
FORCEINLINE uint64_t __rdtsc(void)
FORCEINLINE bool __rdrand64(uint64_t *out)
FORCEINLINE void __hlt(void)
#define UNREFERENCED_PARAMETER(x)
FORCEINLINE void __cli(void)
FORCEINLINE uint64_t __read_cr3(void)
void _MeSetIrql(IN IRQL NewIrql)
void init_boot_info(BOOT_INFO *boot_info)
void copy_memory_map(BOOT_INFO *boot_info)
#define ISRAEL_UTC_OFFSET
uint64_t ahci_bases_local[MAX_AHCI_CONTROLLERS]
uint8_t apic_list[MAX_CPUS]
void copy_gop(BOOT_INFO *boot_info)
void kernel_idle_checks(void)
#define MAX_AHCI_CONTROLLERS
#define MAX_MEMORY_MAP_SIZE
void kernel_main(BOOT_INFO *boot_info)
#define gop_printf_forced(color, fmt,...)
@ MEMORY_MAP_SIZE_OVERRUN
Custom ones.
FORCEINLINE PPROCESSOR MeGetCurrentProcessor(void)
@ DEFAULT_TIMESLICE_TICKS
void MeInitializeProcessor(IN PPROCESSOR CPU, IN bool InitializeStandardRoutine, IN bool AreYouAP)
#define COLOR_RED
Colors definitions for easier access.
struct _IPI_PARAMS IPI_PARAMS
FORCEINLINE void getCpuName(char *name)
@ SYSTEM_PHASE_INITIALIZE_ALL
FORCEINLINE void * kmemcpy(void *dest, const void *src, size_t len)
void MiMoveUefiDataToHigherHalf(IN PBOOT_INFO BootInfo)
bool MmInitSystem(IN uint8_t Phase, IN PBOOT_INFO BootInformation)
FORCEINLINE void InitializeListHead(PDOUBLY_LINKED_LIST Head)
#define MT_FAILURE(Status)
#define MT_SUCCEEDED(Status)
Macros to test status.
MTSTATUS MsReleaseMutexObject(IN PMUTEX mut)
MTSTATUS MsInitializeMutexObject(IN PMUTEX mut)
MTSTATUS MsAcquireMutexObject(IN PMUTEX mut)
void MmFreePool(IN void *buf)
void * MmAllocatePoolWithTag(IN enum _POOL_TYPE PoolType, IN size_t NumberOfBytes, IN uint32_t Tag)
MTSTATUS PsCreateProcess(IN const char *ExecutablePath, OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, _In_Opt HANDLE ParentProcess)
@ PS_PHASE_INITIALIZE_SYSTEM
@ PS_PHASE_INITIALIZE_WORKER_THREADS
void(* ThreadEntry)(THREAD_PARAMETER)
#define MT_PROCESS_ALL_ACCESS
MTSTATUS PsInitializeSystem(IN enum _PS_PHASE_ROUTINE Phase)
FORCEINLINE void RtlZeroMemory(IN void *Destination, IN size_t Length)
NORETURN void Schedule(void)
EPROCESS PsInitialSystemProcess
void MhInitializeSMP(uint8_t *apic_list, uint32_t cpu_count, uint32_t lapicAddress)
void MhSendActionToCpusAndWait(CPU_ACTION action, IPI_PARAMS parameter)
EFI_MEMORY_DESCRIPTOR * MemoryMap
uint64_t AhciBarBases[32]
uint32_t DescriptorVersion
struct _ETHREAD * idleThread
MTSTATUS PsCreateSystemThread(ThreadEntry entry, THREAD_PARAMETER parameter, TimeSliceTicks TIMESLICE)
PETHREAD PsGetCurrentThread(void)
MTSTATUS vfs_listdir(const char *path, char *listings, size_t max_len)
Lists the directory given.
bool vfs_is_dir_empty(const char *path)
This function returns if the directory given to the function is empty (e.g, has only '....
MTSTATUS vfs_init(void)
Initialize the Virtual File System (initializes other filesystem needed services as well)