ReactOS 0.4.16-dev-1946-g52006dd
int10.c File Reference
#include "videoprt.h"
#include <ndk/kefuncs.h>
#include <ndk/mmfuncs.h>
#include <debug.h>
#include <ndk/halfuncs.h>
Include dependency graph for int10.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define INT10(func)   IntInt10##func##Emu
 

Functions

static BOOLEAN IntInitializeX86Emu (VOID)
 
static VP_STATUS NTAPI IntInt10AllocateBufferEmu (_In_ PVOID Context, _Out_ PUSHORT Seg, _Out_ PUSHORT Off, _Inout_ PULONG Length)
 
VP_STATUS NTAPI IntInt10AllocateBuffer (_In_ PVOID Context, _Out_ PUSHORT Seg, _Out_ PUSHORT Off, _Inout_ PULONG Length)
 
static VP_STATUS NTAPI IntInt10FreeBufferEmu (_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off)
 
VP_STATUS NTAPI IntInt10FreeBuffer (_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off)
 
static VP_STATUS NTAPI IntInt10ReadMemoryEmu (_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
VP_STATUS NTAPI IntInt10ReadMemory (_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
static VP_STATUS NTAPI IntInt10WriteMemoryEmu (_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
VP_STATUS NTAPI IntInt10WriteMemory (_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
static VP_STATUS NTAPI IntInt10CallBiosEmu (_In_ PVOID Context, _Inout_ PINT10_BIOS_ARGUMENTS BiosArguments)
 
VP_STATUS NTAPI IntInt10CallBios (_In_ PVOID Context, _Inout_ PINT10_BIOS_ARGUMENTS BiosArguments)
 
NTSTATUS IntInitializeInt10 (VOID)
 
VP_STATUS NTAPI VideoPortInt10 (IN PVOID HwDeviceExtension, IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments)
 

Variables

KMUTEX VideoPortInt10Mutex
 

Macro Definition Documentation

◆ INT10

#define INT10 (   func)    IntInt10##func##Emu

Definition at line 290 of file int10.c.

◆ NDEBUG

#define NDEBUG

Definition at line 27 of file int10.c.

Function Documentation

◆ IntInitializeInt10()

NTSTATUS IntInitializeInt10 ( VOID  )

Definition at line 737 of file int10.c.

738{
739#ifdef _M_IX86
740 /* We should only do that for CSRSS */
742
743 /* Initialize the x86 emulator if necessary, otherwise fall back to V86 mode */
744 if (!VideoPortDisableX86Emulator)
745 {
746 /* Use the emulation routines */
747 //Int10Vtbl = &Int10IFace[0];
749 return STATUS_SUCCESS;
750 DPRINT1("Could not initialize the x86 emulator; falling back to V86 mode\n");
751 VideoPortDisableX86Emulator = TRUE;
752 }
753
754 /* Fall back to the V86 routines */
755 Int10Vtbl = &Int10IFace[1];
756 return IntInitializeVideoAddressSpace();
757#else
758 /* Initialize the x86 emulator */
760#endif
761}
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define TRUE
Definition: types.h:120
static BOOLEAN IntInitializeX86Emu(VOID)
Definition: int10.c:84
#define ASSERT(a)
Definition: mode.c:44
#define STATUS_SUCCESS
Definition: shellext.h:65
PKPROCESS CsrProcess
Definition: videoprt.c:39
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by IntVideoPortDispatchOpen().

◆ IntInitializeX86Emu()

static BOOLEAN IntInitializeX86Emu ( VOID  )
static

Definition at line 84 of file int10.c.

85{
86#if (NTDDI_VERSION < NTDDI_VISTA) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA)
87 UNICODE_STRING ImportName;
88#define LOAD_IMPORT(func) \
89 (RtlInitUnicodeString(&ImportName, L ## #func), \
90 (func) = MmGetSystemRoutineAddress(&ImportName))
91
92 if (!LOAD_IMPORT(x86BiosCall)) // Check also HalInitializeBios ?
93 return FALSE; /* No emulator available */
94 if (!LOAD_IMPORT(x86BiosAllocateBuffer))
95 return FALSE;
96 if (!LOAD_IMPORT(x86BiosFreeBuffer))
97 return FALSE;
98 if (!LOAD_IMPORT(x86BiosReadMemory))
99 return FALSE;
100 if (!LOAD_IMPORT(x86BiosWriteMemory))
101 return FALSE;
102#undef LOAD_IMPORT
103#endif
104
105 return TRUE;
106}
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI x86BiosAllocateBuffer(_Inout_ ULONG *Size, _Out_ USHORT *Segment, _Out_ USHORT *Offset)
Definition: x86bios.c:151
NTSTATUS NTAPI x86BiosFreeBuffer(_In_ USHORT Segment, _In_ USHORT Offset)
Definition: x86bios.c:180
NTSTATUS NTAPI x86BiosReadMemory(_In_ USHORT Segment, _In_ USHORT Offset, _Out_writes_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:204
BOOLEAN NTAPI x86BiosCall(_In_ ULONG InterruptNumber, _Inout_ PX86_BIOS_REGISTERS Registers)
Definition: x86bios.c:410
NTSTATUS NTAPI x86BiosWriteMemory(_In_ USHORT Segment, _In_ USHORT Offset, _In_reads_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:231

Referenced by IntInitializeInt10().

◆ IntInt10AllocateBuffer()

VP_STATUS NTAPI IntInt10AllocateBuffer ( _In_ PVOID  Context,
_Out_ PUSHORT  Seg,
_Out_ PUSHORT  Off,
_Inout_ PULONG  Length 
)

Definition at line 370 of file int10.c.

375{
377
378 TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
379
380 Status = INT10(AllocateBuffer)(Context, Seg, Off, Length);
381 if (Status == NO_ERROR)
382 {
383 INFO_(VIDEOPRT, "- Segment: 0x%x\n", *Seg);
384 INFO_(VIDEOPRT, "- Offset : 0x%x\n", *Off);
385 INFO_(VIDEOPRT, "- Length : 0x%x\n", *Length);
386 }
387 return Status;
388}
#define NO_ERROR
Definition: dderror.h:5
#define TRACE_(x)
Definition: compat.h:76
Status
Definition: gdiplustypes.h:25
#define INT10(func)
Definition: int10.c:290
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
LONG VP_STATUS
Definition: video.h:153
#define INFO_(ch,...)
Definition: debug.h:159

Referenced by VideoPortQueryServices().

◆ IntInt10AllocateBufferEmu()

static VP_STATUS NTAPI IntInt10AllocateBufferEmu ( _In_ PVOID  Context,
_Out_ PUSHORT  Seg,
_Out_ PUSHORT  Off,
_Inout_ PULONG  Length 
)
static

Definition at line 296 of file int10.c.

301{
303
305
308}
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329

◆ IntInt10CallBios()

VP_STATUS NTAPI IntInt10CallBios ( _In_ PVOID  Context,
_Inout_ PINT10_BIOS_ARGUMENTS  BiosArguments 
)

Definition at line 708 of file int10.c.

711{
712 return INT10(CallBios)(Context, BiosArguments);
713}

Referenced by VideoPortInt10(), and VideoPortQueryServices().

◆ IntInt10CallBiosEmu()

static VP_STATUS NTAPI IntInt10CallBiosEmu ( _In_ PVOID  Context,
_Inout_ PINT10_BIOS_ARGUMENTS  BiosArguments 
)
static

Definition at line 588 of file int10.c.

591{
594
596
597 /* Clear the context and fill out the BIOS arguments */
599 BiosContext.Eax = BiosArguments->Eax;
600 BiosContext.Ebx = BiosArguments->Ebx;
601 BiosContext.Ecx = BiosArguments->Ecx;
602 BiosContext.Edx = BiosArguments->Edx;
603 BiosContext.Esi = BiosArguments->Esi;
604 BiosContext.Edi = BiosArguments->Edi;
605 BiosContext.Ebp = BiosArguments->Ebp;
606 BiosContext.SegDs = BiosArguments->SegDs;
607 BiosContext.SegEs = BiosArguments->SegEs;
608
609 /* Do the ROM BIOS call */
611 Executive,
613 FALSE,
614 NULL);
615
617
619
620 /* Return the arguments */
621 BiosArguments->Eax = BiosContext.Eax;
622 BiosArguments->Ebx = BiosContext.Ebx;
623 BiosArguments->Ecx = BiosContext.Ecx;
624 BiosArguments->Edx = BiosContext.Edx;
625 BiosArguments->Esi = BiosContext.Esi;
626 BiosArguments->Edi = BiosContext.Edi;
627 BiosArguments->Ebp = BiosContext.Ebp;
628 BiosArguments->SegDs = (USHORT)BiosContext.SegDs;
629 BiosArguments->SegEs = (USHORT)BiosContext.SegEs;
630
632}
unsigned char BOOLEAN
CALLBACK16 BiosContext
Definition: bios32.c:45
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
@ Success
Definition: eventcreate.c:712
KMUTEX VideoPortInt10Mutex
Definition: int10.c:38
#define KernelMode
Definition: asm.h:38
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
unsigned short USHORT
Definition: pedump.c:61
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define KeWaitForMutexObject
Definition: kefuncs.h:543
@ Executive
Definition: ketypes.h:467

◆ IntInt10FreeBuffer()

VP_STATUS NTAPI IntInt10FreeBuffer ( _In_ PVOID  Context,
_In_ USHORT  Seg,
_In_ USHORT  Off 
)

Definition at line 439 of file int10.c.

443{
444 TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
445 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
446 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
447
448 return INT10(FreeBuffer)(Context, Seg, Off);
449}

Referenced by VideoPortQueryServices().

◆ IntInt10FreeBufferEmu()

static VP_STATUS NTAPI IntInt10FreeBufferEmu ( _In_ PVOID  Context,
_In_ USHORT  Seg,
_In_ USHORT  Off 
)
static

Definition at line 393 of file int10.c.

397{
399
401
402 Status = x86BiosFreeBuffer(Seg, Off);
404}

◆ IntInt10ReadMemory()

VP_STATUS NTAPI IntInt10ReadMemory ( _In_ PVOID  Context,
_In_ USHORT  Seg,
_In_ USHORT  Off,
_Out_writes_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Length 
)

Definition at line 502 of file int10.c.

508{
509 TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
510 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
511 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
512 INFO_(VIDEOPRT, "- Buffer : 0x%x\n", Buffer);
513 INFO_(VIDEOPRT, "- Length : 0x%x\n", Length);
514
515 return INT10(ReadMemory)(Context, Seg, Off, Buffer, Length);
516}
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFUSBPIPE _In_ WDFREQUEST _In_opt_ WDFMEMORY ReadMemory
Definition: wdfusb.h:2000

Referenced by VideoPortQueryServices().

◆ IntInt10ReadMemoryEmu()

static VP_STATUS NTAPI IntInt10ReadMemoryEmu ( _In_ PVOID  Context,
_In_ USHORT  Seg,
_In_ USHORT  Off,
_Out_writes_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Length 
)
static

Definition at line 454 of file int10.c.

◆ IntInt10WriteMemory()

VP_STATUS NTAPI IntInt10WriteMemory ( _In_ PVOID  Context,
_In_ USHORT  Seg,
_In_ USHORT  Off,
_In_reads_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Length 
)

Definition at line 569 of file int10.c.

575{
576 TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
577 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
578 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
579 INFO_(VIDEOPRT, "- Buffer : 0x%x\n", Buffer);
580 INFO_(VIDEOPRT, "- Length : 0x%x\n", Length);
581
582 return INT10(WriteMemory)(Context, Seg, Off, Buffer, Length);
583}
_Must_inspect_result_ _In_ WDFUSBPIPE _In_ WDFREQUEST _In_opt_ WDFMEMORY WriteMemory
Definition: wdfusb.h:1918

Referenced by VideoPortQueryServices().

◆ IntInt10WriteMemoryEmu()

static VP_STATUS NTAPI IntInt10WriteMemoryEmu ( _In_ PVOID  Context,
_In_ USHORT  Seg,
_In_ USHORT  Off,
_In_reads_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Length 
)
static

Definition at line 521 of file int10.c.

◆ VideoPortInt10()

VP_STATUS NTAPI VideoPortInt10 ( IN PVOID  HwDeviceExtension,
IN PVIDEO_X86_BIOS_ARGUMENTS  BiosArguments 
)

Definition at line 771 of file int10.c.

774{
776 INT10_BIOS_ARGUMENTS Int10BiosArguments;
777
778 /* Copy arguments to other format */
779 RtlCopyMemory(&Int10BiosArguments, BiosArguments, sizeof(*BiosArguments));
780 Int10BiosArguments.SegDs = 0;
781 Int10BiosArguments.SegEs = 0;
782
783 /* Do the BIOS call */
784 Status = IntInt10CallBios(NULL, &Int10BiosArguments);
785
786 /* Copy results back */
787 RtlCopyMemory(BiosArguments, &Int10BiosArguments, sizeof(*BiosArguments));
788
789 return Status;
790}
VP_STATUS NTAPI IntInt10CallBios(_In_ PVOID Context, _Inout_ PINT10_BIOS_ARGUMENTS BiosArguments)
Definition: int10.c:708
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by VbeSetMode().

Variable Documentation

◆ VideoPortInt10Mutex

KMUTEX VideoPortInt10Mutex

Definition at line 38 of file int10.c.

Referenced by IntInt10CallBiosEmu(), and VideoPortInitialize().