1/*
2 *                   XFree86 int10 module
3 *   execute BIOS int 10h calls in x86 real mode environment
4 *                 Copyright 1999 Egbert Eich
5 */
6#ifdef HAVE_XORG_CONFIG_H
7#include <xorg-config.h>
8#endif
9
10#include "xf86.h"
11#include "xf86_OSproc.h"
12#include "xf86Pci.h"
13#define _INT10_PRIVATE
14#include "xf86int10.h"
15#include "int10Defines.h"
16#include <x86emu.h>
17
18#define M _X86EMU_env
19
20static void
21x86emu_do_int(int num)
22{
23    Int10Current->num = num;
24
25    if (!int_handler(Int10Current)) {
26        X86EMU_halt_sys();
27    }
28}
29
30void
31xf86ExecX86int10(xf86Int10InfoPtr pInt)
32{
33    int sig = setup_int(pInt);
34
35    if (sig < 0)
36        return;
37
38    if (int_handler(pInt)) {
39        X86EMU_exec();
40    }
41
42    finish_int(pInt, sig);
43}
44
45Bool
46xf86Int10ExecSetup(xf86Int10InfoPtr pInt)
47{
48    int i;
49    X86EMU_intrFuncs intFuncs[256];
50
51    X86EMU_pioFuncs pioFuncs = {
52        .inb = x_inb,
53        .inw = x_inw,
54        .inl = x_inl,
55        .outb = x_outb,
56        .outw = x_outw,
57        .outl = x_outl
58    };
59
60    X86EMU_memFuncs memFuncs = {
61        (&Mem_rb),
62        (&Mem_rw),
63        (&Mem_rl),
64        (&Mem_wb),
65        (&Mem_ww),
66        (&Mem_wl)
67    };
68
69    X86EMU_setupMemFuncs(&memFuncs);
70
71    pInt->cpuRegs = &M;
72    M.mem_base = 0;
73    M.mem_size = 1024 * 1024 + 1024;
74    X86EMU_setupPioFuncs(&pioFuncs);
75
76    for (i = 0; i < 256; i++)
77        intFuncs[i] = x86emu_do_int;
78    X86EMU_setupIntrFuncs(intFuncs);
79    return TRUE;
80}
81
82void
83printk(const char *fmt, ...)
84{
85    va_list argptr;
86
87    va_start(argptr, fmt);
88    VErrorF(fmt, argptr);
89    va_end(argptr);
90}
91