mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
Move timer tick handling into Scheduler.
This commit is contained in:
parent
27fded7002
commit
ac1d12465f
3 changed files with 56 additions and 59 deletions
|
@ -258,3 +258,50 @@ void Scheduler::initialize()
|
|||
current = nullptr;
|
||||
load_task_register(s_redirection.selector);
|
||||
}
|
||||
|
||||
void Scheduler::timer_tick(RegisterDump& regs)
|
||||
{
|
||||
if (!current)
|
||||
return;
|
||||
|
||||
system.uptime++;
|
||||
|
||||
if (current->tick())
|
||||
return;
|
||||
|
||||
current->tss().gs = regs.gs;
|
||||
current->tss().fs = regs.fs;
|
||||
current->tss().es = regs.es;
|
||||
current->tss().ds = regs.ds;
|
||||
current->tss().edi = regs.edi;
|
||||
current->tss().esi = regs.esi;
|
||||
current->tss().ebp = regs.ebp;
|
||||
current->tss().ebx = regs.ebx;
|
||||
current->tss().edx = regs.edx;
|
||||
current->tss().ecx = regs.ecx;
|
||||
current->tss().eax = regs.eax;
|
||||
current->tss().eip = regs.eip;
|
||||
current->tss().cs = regs.cs;
|
||||
current->tss().eflags = regs.eflags;
|
||||
|
||||
// Compute process stack pointer.
|
||||
// Add 12 for CS, EIP, EFLAGS (interrupt mechanic)
|
||||
current->tss().esp = regs.esp + 12;
|
||||
current->tss().ss = regs.ss;
|
||||
|
||||
if ((current->tss().cs & 3) != 0) {
|
||||
current->tss().ss = regs.ss_if_crossRing;
|
||||
current->tss().esp = regs.esp_if_crossRing;
|
||||
}
|
||||
|
||||
if (!pick_next())
|
||||
return;
|
||||
prepare_for_iret_to_new_process();
|
||||
|
||||
// Set the NT (nested task) flag.
|
||||
asm(
|
||||
"pushf\n"
|
||||
"orl $0x00004000, (%esp)\n"
|
||||
"popf\n"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue