aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-06-21 15:58:57 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-06-21 15:58:57 -0700
commit859ead0a2ef7dfd0b5622ad4878dda1b26c22e29 (patch)
treec0fabd0496ceeba176e464f1b912a592c1787649
parent316baa765d85a91cd89585ea5cf913bcd2e478a5 (diff)
downloadsyslinux-859ead0a2ef7dfd0b5622ad4878dda1b26c22e29.tar.gz
syslinux-859ead0a2ef7dfd0b5622ad4878dda1b26c22e29.tar.xz
syslinux-859ead0a2ef7dfd0b5622ad4878dda1b26c22e29.zip
com32: make __farcall() IF-preserving
Make __farcall preserve the current value of IF. If we need to we can create a __raw_farcall() operation which does not. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--com32/lib/sys/farcall.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/com32/lib/sys/farcall.c b/com32/lib/sys/farcall.c
index 7d195f10..988ee6d2 100644
--- a/com32/lib/sys/farcall.c
+++ b/com32/lib/sys/farcall.c
@@ -4,8 +4,21 @@
#include <com32.h>
+static inline uint32_t eflags(void)
+{
+ uint32_t v;
+
+ asm volatile("pushfl ; popl %0" : "=rm" (v));
+ return v;
+}
+
void __farcall(uint16_t cs, uint16_t ip,
const com32sys_t * ireg, com32sys_t * oreg)
{
- __com32.cs_farcall((cs << 16) + ip, ireg, oreg);
+ com32sys_t xreg = *ireg;
+
+ /* Enable interrupts if and only if they are enabled in the caller */
+ xreg.eflags.l = (xreg.eflags.l & ~EFLAGS_IF) | (eflags() & EFLAGS_IF);
+
+ __com32.cs_farcall((cs << 16) + ip, &xreg, oreg);
}