redo boot around an explicit system volume and fixed kernel/HAL images, redo volumes and filesystem paths around capabilities instead of drive numbers and kernel CWD state, add a capability/security model with derived and revocable handles and security contexts, add port IPC and rssrv to manage the userspace resource namespace and publish the system volume, move process, dll and path loading to userspace and add process builder syscalls, init now supervises rssrv and the session process, redo the syscall ABI around request structs and four arguments, add a volume manager and proper partition arrival/removal handling so FAT and NTFS mount dynamically, clean up the HAL/DDK boundary so drivers don't depend on HAL internals, save fpu state properly now, the serial driver doesn't hang on a missing port, fix AHCI startup races, fix timeout accounting, fix shared mmap writeback, more smoke tests
This commit is contained in:
1 parent
4add6789ba
commit
f882d339fb
232 files changed
+20934
-8898
No files matched your search
+28
-38
@@ -4,7 +4,7 @@
|
||||
#include <kernel/ke_list.h>
|
||||
#include <string.h>
|
||||
#include <kernel/ke_timer.h>
|
||||
#include <kernel/ke_sched.h>
|
||||
#include <kernel/ke_time.h>
|
||||
#include <kernel/ob_object.h>
|
||||
|
||||
#define TIMER_SIGNAL_BATCH 32u
|
||||
@@ -23,29 +23,19 @@ static void KiTimerEnsureInitialized(void) {
|
||||
gTimerInitialized = 1;
|
||||
}
|
||||
|
||||
// Reads the scheduler tick value used by timer deadlines.
|
||||
static uint64_t KiTimerReadSchedulerTick(void) {
|
||||
KE_SCHED_STATS stats;
|
||||
KeGetSchedulerStats(&stats);
|
||||
return stats.Ticks;
|
||||
// Converts a millisecond interval to microseconds with saturation.
|
||||
static uint64_t KiTimerMillisecondsToMicroseconds(uint64_t milliseconds) {
|
||||
if (milliseconds > UINT64_MAX / 1000ull)
|
||||
return UINT64_MAX;
|
||||
return milliseconds * 1000ull;
|
||||
}
|
||||
|
||||
// Converts a millisecond interval to at least one scheduler tick.
|
||||
static uint64_t KiTimerMillisecondsToTicks(uint64_t milliseconds) {
|
||||
if (milliseconds == 0)
|
||||
return 0;
|
||||
|
||||
uint64_t ticks = milliseconds / SCHED_TICK_MS;
|
||||
if ((milliseconds % SCHED_TICK_MS) != 0)
|
||||
ticks++;
|
||||
return ticks ? ticks : 1;
|
||||
}
|
||||
|
||||
// Adds a tick interval to the current scheduler tick with saturation.
|
||||
static uint64_t KiTimerDeadlineFromNow(uint64_t intervalTicks) {
|
||||
uint64_t now = KiTimerReadSchedulerTick();
|
||||
uint64_t due = now + intervalTicks;
|
||||
return due < now ? UINT64_MAX : due;
|
||||
// Adds a monotonic interval to the current time with saturation.
|
||||
static uint64_t KiTimerDeadlineFromNow(uint64_t intervalMicroseconds) {
|
||||
uint64_t now = KeQueryMonotonicTicks();
|
||||
if (intervalMicroseconds > UINT64_MAX - now)
|
||||
return UINT64_MAX;
|
||||
return now + intervalMicroseconds;
|
||||
}
|
||||
|
||||
// Removes an active timer from the global deadline list while the timer lock is held.
|
||||
@@ -56,8 +46,8 @@ static uint8_t KiTimerRemoveLocked(KTIMER* timer) {
|
||||
KeListRemoveChecked(&timer->Link);
|
||||
timer->Linked = 0;
|
||||
timer->Active = 0;
|
||||
timer->DueTick = 0;
|
||||
timer->PeriodTicks = 0;
|
||||
timer->DueMicroseconds = 0;
|
||||
timer->PeriodMicroseconds = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -110,27 +100,27 @@ KSTATUS KeTimerSet(KTIMER* timer, uint64_t dueTimeMilliseconds, uint64_t periodM
|
||||
|
||||
KiTimerEnsureInitialized();
|
||||
|
||||
uint64_t dueTicks = KiTimerMillisecondsToTicks(dueTimeMilliseconds);
|
||||
uint64_t periodTicks = KiTimerMillisecondsToTicks(periodMilliseconds);
|
||||
uint64_t dueMicroseconds = KiTimerMillisecondsToMicroseconds(dueTimeMilliseconds);
|
||||
uint64_t periodMicroseconds = KiTimerMillisecondsToMicroseconds(periodMilliseconds);
|
||||
uint8_t dropListReference = 0;
|
||||
uint8_t addListReference = 0;
|
||||
uint8_t signalNow = dueTicks == 0;
|
||||
uint8_t signalNow = dueMicroseconds == 0;
|
||||
EVENT* event = timer->Event;
|
||||
ObReferenceObject(&event->Header);
|
||||
|
||||
uintptr_t flags = KeAcquireSpinlock(&gTimerLock);
|
||||
|
||||
if (timer->Linked) {
|
||||
if (signalNow && periodTicks == 0) {
|
||||
if (signalNow && periodMicroseconds == 0) {
|
||||
dropListReference = KiTimerRemoveLocked(timer);
|
||||
} else {
|
||||
timer->DueTick = KiTimerDeadlineFromNow(signalNow ? periodTicks : dueTicks);
|
||||
timer->PeriodTicks = periodTicks;
|
||||
timer->DueMicroseconds = KiTimerDeadlineFromNow(signalNow ? periodMicroseconds : dueMicroseconds);
|
||||
timer->PeriodMicroseconds = periodMicroseconds;
|
||||
timer->Active = 1;
|
||||
}
|
||||
} else if (!signalNow || periodTicks != 0) {
|
||||
timer->DueTick = KiTimerDeadlineFromNow(signalNow ? periodTicks : dueTicks);
|
||||
timer->PeriodTicks = periodTicks;
|
||||
} else if (!signalNow || periodMicroseconds != 0) {
|
||||
timer->DueMicroseconds = KiTimerDeadlineFromNow(signalNow ? periodMicroseconds : dueMicroseconds);
|
||||
timer->PeriodMicroseconds = periodMicroseconds;
|
||||
timer->Active = 1;
|
||||
timer->Linked = 1;
|
||||
KeListInsertTailChecked(&gTimerList, &timer->Link);
|
||||
@@ -183,7 +173,7 @@ void KeTimerTick(void) {
|
||||
KTIMER* listReferencesToDrop[TIMER_SIGNAL_BATCH];
|
||||
uint32_t count = 0;
|
||||
uint32_t dropCount = 0;
|
||||
uint64_t now = KiTimerReadSchedulerTick();
|
||||
uint64_t now = KeQueryMonotonicTicks();
|
||||
|
||||
uintptr_t flags = KeAcquireSpinlock(&gTimerLock);
|
||||
LIST_ENTRY* node = gTimerList.Fwd;
|
||||
@@ -191,15 +181,15 @@ void KeTimerTick(void) {
|
||||
LIST_ENTRY* next = node->Fwd;
|
||||
KTIMER* timer = CONTAINING_RECORD(node, KTIMER, Link);
|
||||
|
||||
if (timer->Active && timer->DueTick <= now) {
|
||||
if (timer->Active && timer->DueMicroseconds <= now) {
|
||||
if (timer->Event) {
|
||||
ObReferenceObject(&timer->Event->Header);
|
||||
events[count++] = timer->Event;
|
||||
}
|
||||
|
||||
if (timer->PeriodTicks != 0) {
|
||||
uint64_t due = now + timer->PeriodTicks;
|
||||
timer->DueTick = due < now ? UINT64_MAX : due;
|
||||
if (timer->PeriodMicroseconds != 0) {
|
||||
uint64_t due = now + timer->PeriodMicroseconds;
|
||||
timer->DueMicroseconds = due < now ? UINT64_MAX : due;
|
||||
} else {
|
||||
if (KiTimerRemoveLocked(timer))
|
||||
listReferencesToDrop[dropCount++] = timer;
|
||||
|
||||
Reference in new issue
Block a user