|
Revision 4e7d836b8cdc0e785ac6e0a78b258c4e193d2222, 1.2 KB
(checked in by H. Peter Anvin <hpa@…>, 2 years ago)
|
|
core: Preserve IF through call16()
An intcall should always be invoked with interrupts off, but that is
not necessarily the case for a near or far call; in fact it is quite
the exception. As such, do not filter IF in our register image, and
for our own internal call16() interface, propagate the protected-mode
IF value into real mode, just as we do for the pm_call interface.
Signed-off-by: H. Peter Anvin <hpa@…>
|
-
Property mode set to
100644
|
| Line | |
|---|
| 1 | /* ----------------------------------------------------------------------- * |
|---|
| 2 | * |
|---|
| 3 | * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin |
|---|
| 4 | * |
|---|
| 5 | * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | * it under the terms of the GNU General Public License as published by |
|---|
| 7 | * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
|---|
| 8 | * Boston MA 02110-1301, USA; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version; incorporated herein by reference. |
|---|
| 10 | * |
|---|
| 11 | * ----------------------------------------------------------------------- */ |
|---|
| 12 | |
|---|
| 13 | /* |
|---|
| 14 | * call16.c |
|---|
| 15 | * |
|---|
| 16 | * Simple wrapper to call 16-bit core functions from 32-bit code |
|---|
| 17 | */ |
|---|
| 18 | |
|---|
| 19 | #include <stddef.h> |
|---|
| 20 | #include <stdio.h> |
|---|
| 21 | #include "core.h" |
|---|
| 22 | |
|---|
| 23 | const com32sys_t zero_regs; /* Common all-zero register set */ |
|---|
| 24 | |
|---|
| 25 | static inline uint32_t eflags(void) |
|---|
| 26 | { |
|---|
| 27 | uint32_t v; |
|---|
| 28 | |
|---|
| 29 | asm volatile("pushfl ; popl %0" : "=rm" (v)); |
|---|
| 30 | return v; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | void call16(void (*func)(void), const com32sys_t *ireg, com32sys_t *oreg) |
|---|
| 34 | { |
|---|
| 35 | com32sys_t xreg = *ireg; |
|---|
| 36 | |
|---|
| 37 | /* Enable interrupts if and only if they are enabled in the caller */ |
|---|
| 38 | xreg.eflags.l = (xreg.eflags.l & ~EFLAGS_IF) | (eflags() & EFLAGS_IF); |
|---|
| 39 | |
|---|
| 40 | core_farcall((size_t)func, &xreg, oreg); |
|---|
| 41 | } |
|---|