Add suspend_interrupts() and resume_interrupts()
This commit is contained in:
parent
aa5ca83889
commit
bb4404df23
@ -135,6 +135,37 @@ enum uint CPUID_1_ECX_RDRND = 0x4000_0000u;
|
||||
enum uint CPUID_1_ECX_HYPERVISOR = 0x8000_0000u;
|
||||
/** @} */
|
||||
|
||||
/** Interrupt suspend level (0 when interrupts are enabled). */
|
||||
private __gshared size_t intr_suspend_level;
|
||||
|
||||
/**
|
||||
* Suspend interrupts.
|
||||
*
|
||||
* This function disables interrupts. Calls can be nested and interrupts will
|
||||
* be enabled only when the outermost pair of
|
||||
* suspend_interrupts()/resume_interrupts() is complete.
|
||||
*/
|
||||
void suspend_interrupts()
|
||||
{
|
||||
cli();
|
||||
intr_suspend_level++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume interrupts.
|
||||
*
|
||||
* Calls can be nested and interrupts will be enabled only when the outermost
|
||||
* pair of suspend_interrupts()/resume_interrupts() is complete.
|
||||
*/
|
||||
void resume_interrupts()
|
||||
{
|
||||
intr_suspend_level--;
|
||||
if (intr_suspend_level == 0)
|
||||
{
|
||||
sti();
|
||||
}
|
||||
}
|
||||
|
||||
void cli()
|
||||
{
|
||||
__asm("cli", "");
|
||||
|
@ -58,7 +58,8 @@ private void initialize_cpu()
|
||||
*/
|
||||
void hulk_start()
|
||||
{
|
||||
cli();
|
||||
suspend_interrupts();
|
||||
|
||||
initialize_cpu();
|
||||
Serial.initialize();
|
||||
Gdt.initialize();
|
||||
@ -86,7 +87,8 @@ void hulk_start()
|
||||
Pit.initialize();
|
||||
Pci.initialize();
|
||||
Usb.initialize();
|
||||
sti();
|
||||
|
||||
resume_interrupts();
|
||||
|
||||
/* Check that PIT millisecond interrupt is firing. */
|
||||
size_t uptime = Time.uptime();
|
||||
|
Loading…
x
Reference in New Issue
Block a user