1 /* 2 * farcall.c 3 */ 4 5 #include <com32.h> 6 eflags(void)7static inline uint32_t eflags(void) 8 { 9 //uint32_t v; 10 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; 21 } 22 __farcall(uint16_t cs,uint16_t ip,const com32sys_t * ireg,com32sys_t * oreg)23void __farcall(uint16_t cs, uint16_t ip, 24 const com32sys_t * ireg, com32sys_t * oreg) 25 { 26 com32sys_t xreg = *ireg; 27 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); 30 31 __com32.cs_farcall((cs << 16) + ip, &xreg, oreg); 32 } 33