Releasing debian version 4.04+dfsg-9.
[syslinux-debian/hramrach.git] / core / call16.c
blob095f814fdeb6bfe155c8f6dfcbf0ad1a6e47c9ea
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
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.
11 * ----------------------------------------------------------------------- */
14 * call16.c
16 * Simple wrapper to call 16-bit core functions from 32-bit code
19 #include <stddef.h>
20 #include <stdio.h>
21 #include "core.h"
23 const com32sys_t zero_regs; /* Common all-zero register set */
25 static inline uint32_t eflags(void)
27 uint32_t v;
29 asm volatile("pushfl ; popl %0" : "=rm" (v));
30 return v;
33 void call16(void (*func)(void), const com32sys_t *ireg, com32sys_t *oreg)
35 com32sys_t xreg = *ireg;
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);
40 core_farcall((size_t)func, &xreg, oreg);