diff options
Diffstat (limited to 'contrib/syslinux-4.02/core/call16.c')
-rw-r--r-- | contrib/syslinux-4.02/core/call16.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/core/call16.c b/contrib/syslinux-4.02/core/call16.c new file mode 100644 index 0000000..095f814 --- /dev/null +++ b/contrib/syslinux-4.02/core/call16.c @@ -0,0 +1,41 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston MA 02110-1301, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * call16.c + * + * Simple wrapper to call 16-bit core functions from 32-bit code + */ + +#include <stddef.h> +#include <stdio.h> +#include "core.h" + +const com32sys_t zero_regs; /* Common all-zero register set */ + +static inline uint32_t eflags(void) +{ + uint32_t v; + + asm volatile("pushfl ; popl %0" : "=rm" (v)); + return v; +} + +void call16(void (*func)(void), const com32sys_t *ireg, com32sys_t *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); + + core_farcall((size_t)func, &xreg, oreg); +} |