Skip to content

Commit c2ffa8b

Browse files
haesbaertbluerise
authored andcommitted
Introduce intr_state_t and MI "API" for blocking interrupts.
The fact that disabling/enabling real interrupts is totally MD makes writing portable code harder, here I propose the following API: enable_intr(void) Enables "all" hw interrupts. disable_intr(void) Disables "all" hw interrupts. intr_state_t state_intr(void) Reads hw interrupts state. restore_intr(intr_state_t) Restore hw interrupts state. I think this should map easily to arm or any other future platform, intr_state_t should be defined to whatever is convenient to the arch. Switch crit_rundeferred() to use it, when we port stuff to arm, we just need to mimick the API.
1 parent c2c7734 commit c2ffa8b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

sys/arch/amd64/include/cpufunc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ void setidt(int idx, /*XXX*/caddr_t func, int typ, int dpl);
190190

191191

192192
/* XXXX ought to be in psl.h with spl() functions */
193+
typedef u_long intr_state_t;
193194

194195
static __inline void
195196
disable_intr(void)
@@ -218,6 +219,9 @@ write_rflags(u_long ef)
218219
__asm volatile("pushq %0; popfq" : : "r" (ef));
219220
}
220221

222+
#define state_intr read_rflags
223+
#define restore_intr write_rflags
224+
221225
static __inline u_int64_t
222226
rdmsr(u_int msr)
223227
{

sys/kern/kern_crit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ crit_rundeferred(void)
8787
{
8888
struct cpu_info *ci = curcpu();
8989
int i;
90-
long rf;
90+
intr_state_t ist;
9191

9292
KASSERT(CRIT_DEPTH == 0);
9393

94-
rf = read_rflags(); /* XXX or psl ? */
94+
ist = state_intr();
9595
disable_intr();
9696

9797
ci->ci_idepth++;
@@ -104,5 +104,5 @@ crit_rundeferred(void)
104104
disable_intr();
105105
}
106106
ci->ci_idepth--;
107-
write_rflags(rf);
107+
restore_intr(ist);
108108
}

0 commit comments

Comments
 (0)