Adding upstream version 6.00+dfgs.
[syslinux-debian/hramrach.git] / com32 / lib / sys / farcall.c
blob2749083e257ed5303e337e8bb7262a2b98110296
1 /*
2 * farcall.c
3 */
5 #include <com32.h>
7 static inline uint32_t eflags(void)
9 //uint32_t v;
11 #if __SIZEOF_POINTER__ == 4
12 uint32_t v;
13 asm volatile("pushfl ; popl %0" : "=rm" (v));
14 #elif __SIZEOF_POINTER__ == 8
15 uint64_t v;
16 asm volatile("pushfq ; pop %0" : "=rm" (v));
17 #else
18 #error "Unable to build for to-be-defined architecture type"
19 #endif
20 return v;
23 void __farcall(uint16_t cs, uint16_t ip,
24 const com32sys_t * ireg, com32sys_t * oreg)
26 com32sys_t xreg = *ireg;
28 /* Enable interrupts if and only if they are enabled in the caller */
29 xreg.eflags.l = (xreg.eflags.l & ~EFLAGS_IF) | (eflags() & EFLAGS_IF);
31 __com32.cs_farcall((cs << 16) + ip, &xreg, oreg);