My Project
Loading...
Searching...
No Matches
me.h
Go to the documentation of this file.
1#ifndef MATANEL_EXECUTIVE_H
2#define MATANEL_EXECUTIVE_H
3
4/*++
5
6Module Name:
7
8 me.h
9
10Purpose:
11
12 This module contains the header files & prototypes required for the executive layer of MatanelOS.
13
14Author:
15
16 slep (Matanel) 2025.
17
18Revision History:
19
20--*/
21
22#define MSR_IA32_DEBUGCTL 0x1D9
23#define MSR_LASTBRANCH_TOS 0x1C9
24#define MSR_LASTBRANCH_FROM0 0x680
25#define MSR_LASTBRANCH_TO0 0x6C0
26#define DPC_TARGET_CURRENT 0xFF
27
28#include <stdint.h>
29#include <stdbool.h>
30#include "annotations.h"
31#include "macros.h"
32#include "../mtstatus.h"
35
36// Other includes:
37#include "mm.h"
38#include "mh.h"
39#include "ms.h"
40#include "core.h"
41// ------------------ UNIONS ------------------
42
43// ------------------ ENUMERATORS ------------------
44
45#define TICK_MS 4
51
56
64
65
66// DEPRECATED - New list should be in BUGCODES.H explaining each with its parameters. TODO
67// Bugcheck error code enums, use same exception list from CPU.
68typedef enum _BUGCHECK_CODES {
89 MEMORY_MAP_SIZE_OVERRUN = 0xBEEF, // The memory map has grown beyond the limit (unused).
90 MANUALLY_INITIATED_CRASH = 0xBABE, // A function has manually initiated a bugcheck for testing/unknown reasons with this specific code.
91 BAD_PAGING = 0xBAD, // A paging function that fails when it shouldn't.
92 BLOCK_DEVICE_LIMIT_REACHED = 0x420, // Something tried to register a block device, but the limit has been reached, bugcheck system.
93 NULL_POINTER_DEREFERENCE = 0xDEAD, // Attempted dereference of a null pointer.
94 FILESYSTEM_PANIC = 0xFA11, // FileSystem PANIC, usually something wrong has happened
95 UNABLE_TO_INIT_TRACELASTFUNC = 0xACE, // TraceLastFunc init failed in kernel_main
96 FRAME_LIMIT_REACHED = 0xBADA55, // frame limit reached when trying to allocate a physical frame.
97 IRQL_NOT_LESS_OR_EQUAL = 0x1337, // Access to functions while going over the max IRQL set for them. Or lowering to higher IRQL than current IRQL.
98 IRQL_NOT_GREATER_OR_EQUAL = 0x1338, // Raising IRQL to an IRQL level that is lower than the current one.
99 INVALID_IRQL_SUPPLIED = 0x69420, // Invalid IRQL supplied to raising / lowering IRQL.
100 NULL_CTX_RECEIVED = 0xF1FA, // A null context frame has been received to a function.
101 THREAD_EXIT_FAILURE = 0x123123FF, // A thread exitted but did not schedule (somehow).
102 BAD_AHCI_COUNT, // AHCI Count has went over the required limit
103 AHCI_INIT_FAILED, // Initialization of AHCI has failed..
104 MEMORY_LIMIT_REACHED, // The amount of physical memory has reached its maximum, allocation has failed.
105 HEAP_ALLOCATION_FAILED, // Allocating from the HEAP failed for an unknown reason.
106 NULL_THREAD, // A thread given to the scheduler is NULL.
107 FATAL_IRQL_CORRUPTION, // IRQL Has been corrupted, somehow. Probably a buffer overflow.
108 THREAD_ID_CREATION_FAILURE, // Creation of a TID (Thread ID) has failed due to reaching maximum TIDs in use by the system.
109 FRAME_ALLOCATION_FAILED, // Allocating a physical frame from the frame bitmap has failed.
110 FRAME_BITMAP_CREATION_FAILURE, // Creating the frame bitmap resulted in a failure.
111 ASSERTION_FAILURE, // Runtime Assertion Failure (assert())
116 GUARD_PAGE_DEREFERENCE, // A guard page has been dereferenced.
117 KERNEL_STACK_OVERFLOWN, // A kernel stack has been overflown (and didnt hit the guard page) (detected by canary)
118 KMODE_EXCEPTION_NOT_HANDLED, // A kernel mode exception hasn't been handled (an __except block hasn't been handled)
136
137// ------------------ STRUCTURES ------------------
138
139typedef void (*DebugCallback)(void*);
140
145
146typedef struct _WAIT_BLOCK {
147 struct _SINGLE_LINKED_LIST WaitBlockList; // List entry of the current wait block of the thread.
148 void* Object; // Pointer to the object it is currently waiting on (indicated which one by WaitReason)
149 enum _WAIT_REASON WaitReason; // Defines which object the thread is currently waiting on (indicated by the _WAIT_REASON Enumerator)
151
152typedef struct _TRAP_FRAME {
153 uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
154 uint64_t rbp, rdi, rsi, rdx, rcx, rbx, rax;
155 uint64_t vector;
156 uint64_t error_code;
157 uint64_t rip;
158 uint64_t cs;
159 uint64_t rflags;
160 uint64_t rsp;
161 uint64_t ss;
163
164typedef enum _DEBUG_ACCESS_MODE {
165 DEBUG_ACCESS_EXECUTE = 0b00, // Break on instruction execution
166 DEBUG_ACCESS_WRITE = 0b01, // Break on data writes
167 DEBUG_ACCESS_IO = 0b10, // Break on I/O read or write (legacy)
168 DEBUG_ACCESS_READWRITE = 0b11 // Break on data reads or writes
170
171typedef enum _DEBUG_LENGTH {
174 DEBUG_LEN_QWORD = 0b10, // Only valid in long mode
177
178typedef struct _DBG_CALLBACK_INFO {
179 void* Address; /* breakpoint address (DRx) */
180 PTRAP_FRAME trap; /* trap frame captured */
181 int BreakIdx; /* which DRx (0..3) fired */
182 uint64_t Dr6; /* raw DR6 value at time of trap */
184
185// Forward declaration
186struct _DPC;
187
188typedef void (DEFERRED_ROUTINE)(
189 struct _DPC* Dpc,
190 void* DeferredContext,
191 void* SystemArgument1,
192 void* SystemArgument2
193 );
194
196
197typedef struct _DPC {
198 // Next/Prev pointers for doubly linked list of DPCs.
200
201 // Pointer to deferred routine.
206
207 // Points to the DPC_DATA struct of the current processor when queued
208 // If NULL, the DPC is NOT queued.
209 volatile void* DpcData;
210
211 // Determines if it goes to tail or head of queue.
213
214 // Determines to which CPU this DPC is supposed to be executed on, this allows multiple re-entracy.
215 uint8_t CpuNumber; // 0xFF means current CPU, else its per lapic id.
217
218typedef enum _CPU_FLAGS {
219 CPU_ONLINE = 1 << 0, // 0b0001
220 CPU_HALTED = 1 << 1, // 0b0010
221 CPU_DOING_IPI = 1 << 2, // 0b0100
222 CPU_UNAVAILABLE = 1 << 3 // 0b1000
224
225// DPC Embedded struct into CPU.
226typedef struct _DPC_DATA {
229 volatile uint32_t DpcQueueDepth;
230 volatile uint32_t DpcCount; // Statistics
232
233#define LASTFUNC_BUFFER_SIZE 128
234#define LASTFUNC_HISTORY_SIZE 25
235// Default timeslice for a new thread.
236#define DEFAULT_TIMESLICE 1
237
238#define KERNEL_CS 0x08 // Entry 1: Kernel Code
239#define KERNEL_DS 0x10 // Entry 2: Kernel Data
240#define KERNEL_SS 0x10 // Same as KERNEL_DS (data segment used for stack)
241#define USER_CS 0x1B // Entry 3: User Code (for future)
242#define USER_DS 0x23 // Entry 4: User Data (for future)
243#define USER_SS 0x23 // Same as USER_DS (for future)
244#define INITIAL_RFLAGS 0x202
245#define USER_RFLAGS 0x246 // IF=1, IOPL=0, CPL=3
246
253
254typedef struct _IPROCESS {
255 uintptr_t PageDirectoryPhysical; // Physical Address of the PML4 of the process.
256 uint64_t* PageDirectoryVirtual; // Virtual Address of the PML4 of the process. (accessible in kernel pages)
257 struct _SPINLOCK ProcessLock; // Internal Spinlock for process field manipulation safety.
258 uint32_t ProcessState; // Current process state.
260
261typedef struct _ITHREAD {
262 struct _TRAP_FRAME TrapRegisters; // Trap Registers used for context switching, saving, and alternation.
263 uint32_t ThreadState; // Current thread state, presented by the THREAD_STATE enumerator.
264 void* StackBase; // Base of the thread's stack (allocated), used for also freeing it by the memory manager (Mm).
265 bool IsLargeStack; // Indicates if the stack allocated to the thread is a LargeStack or not. (Kernel stack only)
266 void* KernelStack; // The threads stack when in kernel space.
267 enum _TimeSliceTicks TimeSlice; // Current timeslice remaining until thread's forceful pre-emption.
268 enum _TimeSliceTicks TimeSliceAllocated; // Original timeslice given to the thread, used for restoration when it's current one is over.
269 enum _PRIVILEGE_MODE PreviousMode; // Previous mode of the thread (used to indicate whether it called a kernel service in kernel mode, or in user mode)
270 struct _APC_STATE ApcState; // Current thread's APC State.
271 struct _WAIT_BLOCK WaitBlock; // Wait block of the current thread, defines a list of which events the thread is waiting on (mutex event, general sleeping)
273
274typedef struct _PROCESSOR {
275 struct _PROCESSOR* self; // A pointer to the current CPU Struct, used internally by functions, see MtStealThread in scheduler.c, or MeGetCurrentProcessor.
276 enum _IRQL currentIrql; // An integer that represents the current interrupt request level of the CPU. Declares which LAPIC & IOAPIC interrupts are masked
277 volatile bool schedulerEnabled; // A boolean value that indicates if the scheduler is allowed to be called after an interrupt.
278 struct _ITHREAD* currentThread; // Current thread that is being executed in the CPU.
279 struct _Queue readyQueue; // Queue of thread pointers to be scheduled.
280 uint32_t ID; // ID is also the index for cpus (e.g cpus[3] so .ID is 3)
281 uint32_t lapic_ID; // Internal APIC id of the CPU.
282 void* VirtStackTop; // Pointer to top of CPU Stack.
283 void* tss; // Task State Segment ptr.
284 void* Rsp0; // General RSP for interrupts & syscalls (entry only) & exceptions.
285 void* IstPFStackTop; // Page Fault IST Stack
286 void* IstDFStackTop; // Double Fault IST Stack
287 volatile uint64_t flags; // CPU Flags (CPU_FLAGS enum), contains the current state of the CPU, in bitfields.
288 bool schedulePending; // A boolean value that indicates if a schedule is currently pending on the CPU
289 uint64_t* gdt; // A pointer to the current GDT of the CPU (set in the CPUs AP entry), does not include BSP GDT.
290 struct _DPC* CurrentDeferredRoutine; // Current deferred routine that is executed by the CPU.
291 struct _ETHREAD* idleThread; // Idle thread for the current CPU.
292 volatile uint64_t IpiSeq;
293 volatile enum _CPU_ACTION IpiAction; // IPI Action specified in the function.
294 volatile IPI_PARAMS IpiParameter; // Optional parameter for IPI's, usually used for functions, primarily TLB Shootdowns.
295 volatile uint32_t* LapicAddressVirt; // Virtual address of the Local APIC MMIO Address (mapped)
296 uintptr_t LapicAddressPhys; // Physical address of the Local APIC MMIO
297
298 /* Statically Special Allocated DPCs */
301 /* End Statically Special Allocated DPCs */
302
303 // Additional DPC Fields
304 DPC_DATA DpcData; // The main DPC queue
305 volatile bool DpcRoutineActive; // TRUE if inside MeRetireDPCs
306 volatile uint32_t TimerRequest; // Non-zero if timers need processing (unused)
307 uintptr_t TimerHand; // Context for timer expiration (unused)
308
309 // Additional APC Fields
310 volatile bool ApcRoutineActive; // True if inside MeRetireAPCs
311
312 // Fields for depth and performance analysis
316
317 // Interrupt requests
318 volatile bool DpcInterruptRequested; // True if we requested an interrupt to handle deferred procedure calls.
319 volatile bool ApcInterruptRequested; // (Undeveloped yet) True if we requested an interrupt for APCs.
320
321 // Scheduler Lock
323
324 // Per CPU Lookaside pools
326
327 struct _DEBUG_ENTRY DebugEntry[4]; // Per CPU Structure that contains debug entries for each debug register.
330
331 // Zombie Thread (for deferred reference deletion)
334
335// ------------------ FUNCTIONS ------------------
336
337
339void
341 IN enum _BUGCHECK_CODES BugCheckCode
342);
343
345void
347 IN enum _BUGCHECK_CODES BugCheckCode,
348 IN void* BugCheckParameter1,
349 IN void* BugCheckParameter2,
350 IN void* BugCheckParameter3,
351 IN void* BugCheckParameter4
352);
353
357 // Routine Description:
358 // This function returns the current address of the PROCESSOR struct. - Note this should only be used in kernel mode with the appropriate GS value.
359{
360 return (PPROCESSOR)__readgsqword(0); // Only works because we have a self pointer at offset 0 in the struct.
361}
362
364void
366
367{
369 // Acquire the spinlock. (FIXME MsAcquireSpinlockAtSynchLevel(&cpu->SchedulerLock)
370 while (__sync_lock_test_and_set(&cpu->SchedulerLock.locked, 1)) {
371 __asm__ volatile("pause" ::: "memory"); /* x86 pause — CPU relax hint */
372 }
373 // Memory barrier to prevent instruction reordering
374 __asm__ volatile("" ::: "memory");
375 cpu->schedulerEnabled = false;
376}
377
379void
381
382{
384 cpu->schedulerEnabled = true;
385 // Release the spinlock. (FIXME MsReleaseSpinlockFromSynchLevel(&cpu->SchedulerLock)
386 __asm__ volatile("" ::: "memory");
387 __sync_lock_release(&cpu->SchedulerLock.locked);
388}
389
390extern uint32_t g_cpuCount;
391
393uint8_t
395
396{
397 return (uint8_t)g_cpuCount; // The reason we cast to uint8_t is because we would never have more than 255 Cpus in the system, not guranteed, though, :)
398}
399
401IRQL
403
404/*++
405
406 Routine description : Retrieves the IRQL of the current processor.
407
408 Arguments:
409
410 None.
411
412 Return Values:
413
414 Current IRQL at time of call.
415
416--*/
417
418{
419#ifdef DEBUG
420 IRQL returningIrql = (IRQL)__readgsqword(FIELD_OFFSET(PROCESSOR, currentIrql));
421 if (returningIrql > HIGH_LEVEL) MeBugCheck(INVALID_IRQL_SUPPLIED);
422 return returningIrql;
423#else
424 return (IRQL)__readgsqword(FIELD_OFFSET(PROCESSOR, currentIrql));
425#endif
426}
427
428
432
433/*++
434
435 Routine description : Retrieves the current running thread on the processor.
436
437 Arguments:
438
439 None.
440
441 Return Values:
442
443 Current thread running on time of call (this thread)
444
445--*/
446
447{
448 return (PITHREAD)__readgsqword(FIELD_OFFSET(PROCESSOR, currentThread));
449}
450
452bool
454
455{
456 return (bool)__readgsqword(FIELD_OFFSET(PROCESSOR, DpcRoutineActive));
457}
458
459void
461 IN PPROCESSOR CPU,
462 IN bool InitializeStandardRoutine,
463 IN bool AreYouAP
464);
465
466void
468 IN IRQL NewIrql,
469 OUT PIRQL OldIrql
470);
471
472void
474 IN IRQL NewIrql
475);
476
477void
479 IN IRQL NewIrql
480);
481
482void
484 IN PDPC Dpc,
485 IN uint32_t CpuNumber
486);
487
488void
490 IN PDPC DpcAllocated,
491 IN PDEFERRED_ROUTINE DeferredRoutine,
492 IN void* DeferredContext,
493 IN DPC_PRIORITY DeferredPriority
494);
495
496bool
498 IN PDPC Dpc,
499 IN void* SystemArgument1,
500 IN void* SystemArgument2
501);
502
503bool
505 IN PDPC Dpc
506);
507
508void
510 void
511);
512
513void CleanStacks(DPC* dpc, void* thread, void* allocatedDPC, void* arg4);
514void ReapOb(DPC* dpc, void* DeferredContext, void* SystemArgument1, void* SystemArgument2);
515void InitScheduler(void);
516
517void
519 IN PIPROCESS Process,
520 OUT PAPC_STATE ApcState
521);
522
523void
525 IN PAPC_STATE ApcState
526);
527
529void
530Schedule(void);
531
535 void
536)
537
538{
539 PITHREAD CurrentThread = MeGetCurrentThread();
540 if (CurrentThread) {
541 return CurrentThread->PreviousMode;
542 }
543 else {
544 // No thread is active on the current processor (not even a kernel one), this is early init.
545 return KernelMode;
546 }
547}
548
549void
551 IN bool EnabledBefore
552);
553
554bool
556 void
557);
558
559bool
561 void
562);
563
564// smp.c
565PPROCESSOR MeGetProcessorBlock(uint8_t ProcessorNumber);
566
567#endif
#define FORCEINLINE
Definition annotations.h:22
#define NORETURN
Definition annotations.h:13
#define IN
Definition annotations.h:7
#define OUT
Definition annotations.h:8
struct _TRAP_FRAME TRAP_FRAME
Definition core.h:53
struct _IPROCESS IPROCESS
Definition core.h:37
struct _ITHREAD ITHREAD
Definition core.h:33
IPROCESS * PIPROCESS
Definition core.h:38
struct _PROCESSOR PROCESSOR
Definition core.h:45
_IRQL
Definition core.h:12
@ HIGH_LEVEL
Definition core.h:20
PROCESSOR * PPROCESSOR
Definition core.h:46
enum _IRQL IRQL
enum _IRQL * PIRQL
EPROCESS * PEPROCESS
Definition core.h:50
ITHREAD * PITHREAD
Definition core.h:34
TRAP_FRAME * PTRAP_FRAME
Definition core.h:54
struct _DOUBLY_LINKED_LIST DOUBLY_LINKED_LIST
FORCEINLINE uint64_t __readgsqword(uint64_t offset)
Definition intrin.h:228
#define FIELD_OFFSET(t, f)
Definition macros.h:52
NORETURN void Schedule(void)
Definition scheduler.c:105
struct _WAIT_BLOCK * PWAIT_BLOCK
enum _TimeSliceTicks * PTimeSliceTicks
bool MeDisableInterrupts(void)
Definition irql.c:186
void MeDetachProcess(IN PAPC_STATE ApcState)
Definition attach.c:86
NORETURN void MeBugCheck(IN enum _BUGCHECK_CODES BugCheckCode)
Definition bugcheck.c:214
struct _ITHREAD * PITHREAD
void MeRetireDPCs(void)
Definition dpc.c:222
struct _APC_STATE APC_STATE
_BUGCHECK_CODES
Definition me.h:68
@ MANUALLY_INITIATED_CRASH
Definition me.h:90
@ NULL_POINTER_DEREFERENCE
Definition me.h:93
@ OVERFLOW
Definition me.h:73
@ FILESYSTEM_PANIC
Definition me.h:94
@ BAD_POOL_CALLER
Definition me.h:122
@ MEMORY_LIMIT_REACHED
Definition me.h:104
@ SEVERE_MACHINE_CHECK
Definition me.h:87
@ ATTEMPTED_WRITE_TO_READONLY_MEMORY
Definition me.h:123
@ COPROCESSOR_SEGMENT_OVERRUN
Definition me.h:78
@ FRAME_LIMIT_REACHED
Definition me.h:96
@ HEAP_ALLOCATION_FAILED
Definition me.h:105
@ NO_COPROCESSOR
Definition me.h:76
@ CID_TABLE_NULL
Definition me.h:133
@ MEMORY_CORRUPT_HEADER
Definition me.h:113
@ PAGE_FAULT
Definition me.h:83
@ PAGE_FAULT_IN_FREED_NONPAGED_POOL
Definition me.h:125
@ PSMGR_INIT_FAILED
Definition me.h:130
@ FLOATING_POINT_ERROR
Definition me.h:85
@ GUARD_PAGE_DEREFERENCE
Definition me.h:116
@ MEMORY_INVALID_FREE
Definition me.h:112
@ IRQL_NOT_GREATER_OR_EQUAL
Definition me.h:98
@ THREAD_EXIT_FAILURE
Definition me.h:101
@ ASSERTION_FAILURE
Definition me.h:111
@ PFN_DATABASE_INIT_FAILURE
Definition me.h:119
@ MEMORY_MAP_SIZE_OVERRUN
Custom ones.
Definition me.h:89
@ ATTEMPTED_SWITCH_FROM_DPC
Definition me.h:127
@ SINGLE_STEP
Definition me.h:70
@ KMODE_EXCEPTION_NOT_HANDLED
Definition me.h:118
@ DIVIDE_BY_ZERO
Definition me.h:69
@ NULL_THREAD
Definition me.h:106
@ KERNEL_STACK_OVERFLOWN
Definition me.h:117
@ BREAKPOINT
Definition me.h:72
@ ALIGNMENT_CHECK
Definition me.h:86
@ BAD_PAGING
Definition me.h:91
@ BLOCK_DEVICE_LIMIT_REACHED
Definition me.h:92
@ NON_MASKABLE_INTERRUPT
Definition me.h:71
@ INVALID_OPCODE
Definition me.h:75
@ POOL_INIT_FAILURE
Definition me.h:121
@ INVALID_TSS
Definition me.h:79
@ FRAME_BITMAP_CREATION_FAILURE
Definition me.h:110
@ BAD_AHCI_COUNT
Definition me.h:102
@ NULL_CTX_RECEIVED
Definition me.h:100
@ MEMORY_DOUBLE_FREE
Definition me.h:114
@ INVALID_INTERRUPT_REQUEST
Definition me.h:128
@ FRAME_ALLOCATION_FAILED
Definition me.h:109
@ DPC_NOT_INITIALIZED
Definition me.h:132
@ UNABLE_TO_INIT_TRACELASTFUNC
Definition me.h:95
@ INVALID_INITIALIZATION_PHASE
Definition me.h:124
@ THREAD_ID_CREATION_FAILURE
Definition me.h:108
@ PAGE_FAULT_IN_FREED_PAGED_POOL
Definition me.h:126
@ PSWORKER_INIT_FAILED
Definition me.h:131
@ DOUBLE_FAULT
Definition me.h:77
@ MANUALLY_INITIATED_CRASH2
Definition me.h:129
@ STACK_SEGMENT_OVERRUN
Definition me.h:81
@ GENERAL_PROTECTION_FAULT
Definition me.h:82
@ VA_SPACE_INIT_FAILURE
Definition me.h:120
@ SEGMENT_SELECTOR_NOTPRESENT
Definition me.h:80
@ AHCI_INIT_FAILED
Definition me.h:103
@ INVALID_PROCESS_ATTACH_ATTEMPT
Definition me.h:134
@ IRQL_NOT_LESS_OR_EQUAL
Definition me.h:97
@ BOUNDS_CHECK
Definition me.h:74
@ INVALID_IRQL_SUPPLIED
Definition me.h:99
@ FATAL_IRQL_CORRUPTION
Definition me.h:107
@ RESERVED
Definition me.h:84
@ MEMORY_CORRUPT_FOOTER
Definition me.h:115
void MeRaiseIrql(IN IRQL NewIrql, OUT PIRQL OldIrql)
Definition irql.c:57
FORCEINLINE PITHREAD MeGetCurrentThread(void)
Definition me.h:431
FORCEINLINE bool MeIsExecutingDpc(void)
Definition me.h:453
bool MeAreInterruptsEnabled(void)
Definition irql.c:210
bool MeRemoveQueueDpc(IN PDPC Dpc)
Definition dpc.c:167
enum _DEBUG_ACCESS_MODE DEBUG_ACCESS_MODE
void DEFERRED_ROUTINE(struct _DPC *Dpc, void *DeferredContext, void *SystemArgument1, void *SystemArgument2)
Definition me.h:188
bool MeInsertQueueDpc(IN PDPC Dpc, IN void *SystemArgument1, IN void *SystemArgument2)
Definition dpc.c:47
PPROCESSOR MeGetProcessorBlock(uint8_t ProcessorNumber)
Definition smp.c:196
FORCEINLINE IRQL MeGetCurrentIrql(void)
Definition me.h:402
NORETURN void MeBugCheckEx(IN enum _BUGCHECK_CODES BugCheckCode, IN void *BugCheckParameter1, IN void *BugCheckParameter2, IN void *BugCheckParameter3, IN void *BugCheckParameter4)
Definition bugcheck.c:305
enum _DPC_PRIORITY DPC_PRIORITY
struct _DPC_DATA * PDPC_DATA
void(* DebugCallback)(void *)
Definition me.h:139
struct _TRAP_FRAME * PTRAP_FRAME
_WAIT_REASON
Definition me.h:52
@ Sleeping
Definition me.h:54
@ Mutex
Definition me.h:53
void MeEnableInterrupts(IN bool EnabledBefore)
Definition irql.c:199
struct _DBG_CALLBACK_INFO DBG_CALLBACK_INFO
DEFERRED_ROUTINE * PDEFERRED_ROUTINE
Definition me.h:195
_DEBUG_LENGTH
Definition me.h:171
@ DEBUG_LEN_QWORD
Definition me.h:174
@ DEBUG_LEN_WORD
Definition me.h:173
@ DEBUG_LEN_BYTE
Definition me.h:172
@ DEBUG_LEN_DWORD
Definition me.h:175
void MeInitializeDpc(IN PDPC DpcAllocated, IN PDEFERRED_ROUTINE DeferredRoutine, IN void *DeferredContext, IN DPC_PRIORITY DeferredPriority)
Definition dpc.c:384
FORCEINLINE void MeReleaseSchedulerLock(void)
Definition me.h:380
void MeInitializeProcessor(IN PPROCESSOR CPU, IN bool InitializeStandardRoutine, IN bool AreYouAP)
Definition meinit.c:164
enum _DEBUG_LENGTH DEBUG_LENGTH
_DPC_PRIORITY
Definition me.h:57
@ SYSTEM_PRIORITY
Definition me.h:62
@ MEDIUM_PRIORITY
Definition me.h:60
@ NO_PRIORITY
Definition me.h:58
@ HIGH_PRIORITY
Definition me.h:61
@ LOW_PRIORITY
Definition me.h:59
struct _DPC DPC
void MeSetTargetProcessorDpc(IN PDPC Dpc, IN uint32_t CpuNumber)
Definition dpc.c:350
void CleanStacks(DPC *dpc, void *thread, void *allocatedDPC, void *arg4)
struct _APC_STATE * PAPC_STATE
FORCEINLINE uint8_t MeGetActiveProcessorCount(void)
Definition me.h:394
struct _DEBUG_ENTRY DEBUG_ENTRY
void ReapOb(DPC *dpc, void *DeferredContext, void *SystemArgument1, void *SystemArgument2)
Definition dpc.c:18
void MeAttachProcess(IN PIPROCESS Process, OUT PAPC_STATE ApcState)
Definition attach.c:23
void _MeSetIrql(IN IRQL NewIrql)
Definition irql.c:153
struct _DPC_DATA DPC_DATA
void MeLowerIrql(IN IRQL NewIrql)
Definition irql.c:97
enum _CPU_FLAGS CPU_FLAGS
FORCEINLINE void MeAcquireSchedulerLock(void)
Definition me.h:365
FORCEINLINE PPROCESSOR MeGetCurrentProcessor(void)
Definition me.h:356
enum _TimeSliceTicks TimeSliceTicks
FORCEINLINE PRIVILEGE_MODE MeGetPreviousMode(void)
Definition me.h:534
struct _WAIT_BLOCK WAIT_BLOCK
_CPU_FLAGS
Definition me.h:218
@ CPU_ONLINE
Definition me.h:219
@ CPU_UNAVAILABLE
Definition me.h:222
@ CPU_HALTED
Definition me.h:220
@ CPU_DOING_IPI
Definition me.h:221
enum _BUGCHECK_CODES BUGCHECK_CODES
_DEBUG_ACCESS_MODE
Definition me.h:164
@ DEBUG_ACCESS_READWRITE
Definition me.h:168
@ DEBUG_ACCESS_EXECUTE
Definition me.h:165
@ DEBUG_ACCESS_IO
Definition me.h:167
@ DEBUG_ACCESS_WRITE
Definition me.h:166
enum _WAIT_REASON WAIT_REASON
void InitScheduler(void)
Definition scheduler.c:26
struct _DPC * PDPC
_TimeSliceTicks
Definition me.h:46
@ HIGH_TIMESLICE_TICKS
Definition me.h:49
@ LOW_TIMESLICE_TICKS
Definition me.h:47
@ DEFAULT_TIMESLICE_TICKS
Definition me.h:48
#define TICK_MS
Definition me.h:45
_CPU_ACTION
Definition mh.h:91
struct _IPI_PARAMS IPI_PARAMS
#define MAX_POOL_DESCRIPTORS
Definition mm.h:151
struct _POOL_DESCRIPTOR POOL_DESCRIPTOR
enum _PRIVILEGE_MODE PRIVILEGE_MODE
_PRIVILEGE_MODE
Definition mm.h:332
@ KernelMode
Definition mm.h:333
struct _SPINLOCK SPINLOCK
uint32_t g_cpuCount
Definition smp.c:128
bool AttachedToProcess
Definition me.h:250
IRQL PreviousIrql
Definition me.h:251
uint64_t SavedCr3
Definition me.h:248
PEPROCESS SavedApcProcess
Definition me.h:249
PTRAP_FRAME trap
Definition me.h:180
uint64_t Dr6
Definition me.h:182
void * Address
Definition me.h:179
DebugCallback Callback
Definition me.h:143
void * Address
Definition me.h:142
volatile uint32_t DpcQueueDepth
Definition me.h:229
SPINLOCK DpcLock
Definition me.h:228
DOUBLY_LINKED_LIST DpcListHead
Definition me.h:227
volatile uint32_t DpcCount
Definition me.h:230
Definition me.h:197
DOUBLY_LINKED_LIST DpcListEntry
Definition me.h:199
void * SystemArgument1
Definition me.h:204
volatile void * DpcData
Definition me.h:209
void * DeferredContext
Definition me.h:203
void * SystemArgument2
Definition me.h:205
enum _DPC_PRIORITY priority
Definition me.h:212
uint8_t CpuNumber
Definition me.h:215
PDEFERRED_ROUTINE DeferredRoutine
Definition me.h:202
Definition ps.h:121
struct _SPINLOCK ProcessLock
Definition me.h:257
uint32_t ProcessState
Definition me.h:258
uint64_t * PageDirectoryVirtual
Definition me.h:256
uintptr_t PageDirectoryPhysical
Definition me.h:255
Definition me.h:261
uint32_t ThreadState
Definition me.h:263
void * StackBase
Definition me.h:264
bool IsLargeStack
Definition me.h:265
enum _PRIVILEGE_MODE PreviousMode
Definition me.h:269
enum _TimeSliceTicks TimeSlice
Definition me.h:267
void * KernelStack
Definition me.h:266
struct _WAIT_BLOCK WaitBlock
Definition me.h:271
struct _TRAP_FRAME TrapRegisters
Definition me.h:262
enum _TimeSliceTicks TimeSliceAllocated
Definition me.h:268
struct _APC_STATE ApcState
Definition me.h:270
struct _DPC ReaperDPC
Definition me.h:300
uint32_t DpcRequestRate
Definition me.h:315
struct _DPC * CurrentDeferredRoutine
Definition me.h:290
struct _Queue readyQueue
Definition me.h:279
volatile IPI_PARAMS IpiParameter
Definition me.h:294
volatile bool schedulerEnabled
Definition me.h:277
struct _DEBUG_ENTRY DebugEntry[4]
Definition me.h:327
PITHREAD ZombieThread
Definition me.h:332
void * IstIpiStackTop
Definition me.h:329
SPINLOCK SchedulerLock
Definition me.h:322
uint32_t MinimumDpcRate
Definition me.h:314
uint32_t ID
Definition me.h:280
uintptr_t TimerHand
Definition me.h:307
struct _ETHREAD * idleThread
Definition me.h:291
enum _IRQL currentIrql
Definition me.h:276
uint32_t lapic_ID
Definition me.h:281
volatile bool DpcRoutineActive
Definition me.h:305
struct _ITHREAD * currentThread
Definition me.h:278
volatile uint64_t flags
Definition me.h:287
uint32_t MaximumDpcQueueDepth
Definition me.h:313
uint64_t * gdt
Definition me.h:289
volatile bool DpcInterruptRequested
Definition me.h:318
DPC_DATA DpcData
Definition me.h:304
void * IstTimerStackTop
Definition me.h:328
void * Rsp0
Definition me.h:284
volatile uint32_t TimerRequest
Definition me.h:306
void * tss
Definition me.h:283
volatile uint64_t IpiSeq
Definition me.h:292
enum _CPU_ACTION IpiAction
Definition me.h:293
struct _DPC TimerExpirationDPC
Definition me.h:299
POOL_DESCRIPTOR LookasidePools[MAX_POOL_DESCRIPTORS]
Definition me.h:325
struct _PROCESSOR * self
Definition me.h:275
bool schedulePending
Definition me.h:288
volatile bool ApcRoutineActive
Definition me.h:310
uintptr_t LapicAddressPhys
Definition me.h:296
void * VirtStackTop
Definition me.h:282
void * IstDFStackTop
Definition me.h:286
void * IstPFStackTop
Definition me.h:285
volatile uint32_t * LapicAddressVirt
Definition me.h:295
volatile bool ApcInterruptRequested
Definition me.h:319
Definition ms.h:51
Definition ms.h:36
volatile uint32_t locked
Definition ms.h:37
uint64_t r14
Definition me.h:153
uint64_t r8
Definition me.h:153
uint64_t r9
Definition me.h:153
uint64_t rbx
Definition me.h:154
uint64_t ss
Definition me.h:161
uint64_t rdi
Definition me.h:154
uint64_t r10
Definition me.h:153
uint64_t vector
Definition me.h:155
uint64_t r13
Definition me.h:153
uint64_t rdx
Definition me.h:154
uint64_t r12
Definition me.h:153
uint64_t r15
Definition me.h:153
uint64_t rsp
Definition me.h:160
uint64_t rip
Definition me.h:157
uint64_t rcx
Definition me.h:154
uint64_t rbp
Definition me.h:154
uint64_t r11
Definition me.h:153
uint64_t error_code
Definition me.h:156
uint64_t rflags
Definition me.h:159
uint64_t rsi
Definition me.h:154
uint64_t cs
Definition me.h:158
uint64_t rax
Definition me.h:154
void * Object
Definition me.h:148
struct _SINGLE_LINKED_LIST WaitBlockList
Definition me.h:147
enum _WAIT_REASON WaitReason
Definition me.h:149