Previously, futex code of McKerenl was called by mccontrol, but there ware some problems with this method. (Mainly, location of McKernel image on memory) Call futex code in mcctrl instead of the one in McKernel image, giving the following benefits: 1. Not relying on shared kernel virtual address space with Linux any more 2. The cpu id store / retrieve is not needed and resulting in the code Change-Id: Ic40929b64a655b270c435859fa287fedb713ee5c refe: #1428
52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
/* This is copy of the necessary part from McKernel, for uti-futex */
|
|
|
|
#include <cpu.h>
|
|
|
|
/*@
|
|
@ assigns \nothing;
|
|
@ behavior to_enabled:
|
|
@ assumes flags & RFLAGS_IF;
|
|
@ ensures \interrupt_disabled == 0;
|
|
@ behavior to_disabled:
|
|
@ assumes !(flags & RFLAGS_IF);
|
|
@ ensures \interrupt_disabled > 0;
|
|
@*/
|
|
void cpu_restore_interrupt(unsigned long flags)
|
|
{
|
|
asm volatile("push %0; popf" : : "g"(flags) : "memory", "cc");
|
|
}
|
|
|
|
void cpu_pause(void)
|
|
{
|
|
asm volatile("pause" ::: "memory");
|
|
}
|
|
|
|
/*@
|
|
@ assigns \nothing;
|
|
@ ensures \interrupt_disabled > 0;
|
|
@ behavior from_enabled:
|
|
@ assumes \interrupt_disabled == 0;
|
|
@ ensures \result & RFLAGS_IF;
|
|
@ behavior from_disabled:
|
|
@ assumes \interrupt_disabled > 0;
|
|
@ ensures !(\result & RFLAGS_IF);
|
|
@*/
|
|
unsigned long cpu_disable_interrupt_save(void)
|
|
{
|
|
unsigned long flags;
|
|
|
|
asm volatile("pushf; pop %0; cli" : "=r"(flags) : : "memory", "cc");
|
|
|
|
return flags;
|
|
}
|
|
|
|
unsigned long cpu_enable_interrupt_save(void)
|
|
{
|
|
unsigned long flags;
|
|
|
|
asm volatile("pushf; pop %0; sti" : "=r"(flags) : : "memory", "cc");
|
|
|
|
return flags;
|
|
}
|
|
|