ReactOS 0.4.16-dev-2354-g16de117
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 295 of file int10.c.

◆ NDEBUG

#define NDEBUG

Definition at line 27 of file int10.c.

Function Documentation

◆ IntInitializeInt10()

NTSTATUS IntInitializeInt10 ( VOID  )

Definition at line 766 of file int10.c.

767{
768 static BOOLEAN FirstInitialization = FALSE;
769
770 if (!FirstInitialization)
771 {
772 FirstInitialization = TRUE;
773#ifdef _M_IX86
774 /* Initialize the x86 emulator if necessary, otherwise fall back to V86 mode */
775 if (!VideoPortDisableX86Emulator)
776 {
777 /* Use the emulation routines */
778 //Int10Vtbl = &Int10IFace[0];
780 return STATUS_SUCCESS;
781 DPRINT1("Could not initialize the x86 emulator; falling back to V86 mode\n");
782 VideoPortDisableX86Emulator = TRUE;
783 }
784
785 /* Fall back to the V86 routines */
786 Int10Vtbl = &Int10IFace[1];
787 return STATUS_SUCCESS;
788#else
789 /* Initialize the x86 emulator */
791#endif
792 }
793
794 /* We should only do that for CSRSS */
796#ifdef _M_IX86
797 return IntInitializeVideoAddressSpace();
798#else
799 return STATUS_SUCCESS;
800#endif
801}
unsigned char BOOLEAN
Definition: actypes.h:127
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static BOOLEAN IntInitializeX86Emu(VOID)
Definition: int10.c:87
#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(), and VideoPortInitialize().

◆ IntInitializeX86Emu()

static BOOLEAN IntInitializeX86Emu ( VOID  )
static

Definition at line 87 of file int10.c.

88{
89#if (NTDDI_VERSION < NTDDI_VISTA) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA)
90 UNICODE_STRING ImportName;
91#define LOAD_IMPORT(func) \
92 (RtlInitUnicodeString(&ImportName, L ## #func), \
93 (func) = MmGetSystemRoutineAddress(&ImportName))
94
95 if (!LOAD_IMPORT(x86BiosCall)) // Check also HalInitializeBios ?
96 return FALSE; /* No emulator available */
97 if (!LOAD_IMPORT(x86BiosAllocateBuffer))
98 return FALSE;
99 if (!LOAD_IMPORT(x86BiosFreeBuffer))
100 return FALSE;
101 if (!LOAD_IMPORT(x86BiosReadMemory))
102 return FALSE;
103 if (!LOAD_IMPORT(x86BiosWriteMemory))
104 return FALSE;
105#undef LOAD_IMPORT
106#endif
107
108 return TRUE;
109}
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 375 of file int10.c.

380{
382
383 TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
384
385 Status = INT10(AllocateBuffer)(Context, Seg, Off, Length);
386 if (Status == NO_ERROR)
387 {
388 INFO_(VIDEOPRT, "- Segment: 0x%x\n", *Seg);
389 INFO_(VIDEOPRT, "- Offset : 0x%x\n", *Off);
390 INFO_(VIDEOPRT, "- Length : 0x%x\n", *Length);
391 }
392 return Status;
393}
#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:295
_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
_In_ PVOID Context
Definition: storport.h:2269

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 301 of file int10.c.

306{
308
310
313}
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 737 of file int10.c.

740{
741 return INT10(CallBios)(Context, BiosArguments);
742}

Referenced by VideoPortInt10(), and VideoPortQueryServices().

◆ IntInt10CallBiosEmu()

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

Definition at line 593 of file int10.c.

596{
599
601
602#ifdef _M_IX86
603 if (!VDMAddressSpaceInitialized)
604 {
605 /* There are buggy 3rd-party miniport drivers that invoke the Int10 service
606 * in their initialization routine, before the VDM address space has been
607 * mapped and Ke386CallBios() can be called. They would therefore hit this
608 * ASSERT. Instead, disable it, log an error and bail out. */
609 //ASSERT(FALSE);
610 ERR_(VIDEOPRT, "Warning: Attempt to call %s before Int10 support is initialized.\n", __FUNCTION__);
612 }
613#endif
614
615 /* Clear the context and fill out the BIOS arguments */
617 BiosContext.Eax = BiosArguments->Eax;
618 BiosContext.Ebx = BiosArguments->Ebx;
619 BiosContext.Ecx = BiosArguments->Ecx;
620 BiosContext.Edx = BiosArguments->Edx;
621 BiosContext.Esi = BiosArguments->Esi;
622 BiosContext.Edi = BiosArguments->Edi;
623 BiosContext.Ebp = BiosArguments->Ebp;
624 BiosContext.SegDs = BiosArguments->SegDs;
625 BiosContext.SegEs = BiosArguments->SegEs;
626
627 /* Do the ROM BIOS call */
629 Executive,
631 FALSE,
632 NULL);
633
635
637
638 /* Return the arguments */
639 BiosArguments->Eax = BiosContext.Eax;
640 BiosArguments->Ebx = BiosContext.Ebx;
641 BiosArguments->Ecx = BiosContext.Ecx;
642 BiosArguments->Edx = BiosContext.Edx;
643 BiosArguments->Esi = BiosContext.Esi;
644 BiosArguments->Edi = BiosContext.Edi;
645 BiosArguments->Ebp = BiosContext.Ebp;
646 BiosArguments->SegDs = (USHORT)BiosContext.SegDs;
647 BiosArguments->SegEs = (USHORT)BiosContext.SegEs;
648
650}
CALLBACK16 BiosContext
Definition: bios32.c:45
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define __FUNCTION__
Definition: types.h:116
@ Success
Definition: eventcreate.c:712
KMUTEX VideoPortInt10Mutex
Definition: int10.c:41
#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 ERR_(ch,...)
Definition: debug.h:156
#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 444 of file int10.c.

448{
449 TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
450 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
451 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
452
453 return INT10(FreeBuffer)(Context, Seg, Off);
454}

Referenced by VideoPortQueryServices().

◆ IntInt10FreeBufferEmu()

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

Definition at line 398 of file int10.c.

402{
404
406
407 Status = x86BiosFreeBuffer(Seg, Off);
409}

◆ 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 507 of file int10.c.

513{
514 TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
515 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
516 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
517 INFO_(VIDEOPRT, "- Buffer : 0x%x\n", Buffer);
518 INFO_(VIDEOPRT, "- Length : 0x%x\n", Length);
519
520 return INT10(ReadMemory)(Context, Seg, Off, Buffer, Length);
521}
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 459 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 574 of file int10.c.

580{
581 TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
582 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
583 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
584 INFO_(VIDEOPRT, "- Buffer : 0x%x\n", Buffer);
585 INFO_(VIDEOPRT, "- Length : 0x%x\n", Length);
586
587 return INT10(WriteMemory)(Context, Seg, Off, Buffer, Length);
588}
_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 526 of file int10.c.

◆ VideoPortInt10()

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

Definition at line 811 of file int10.c.

814{
816 INT10_BIOS_ARGUMENTS Int10BiosArguments;
817
818 /* Copy arguments to other format */
819 RtlCopyMemory(&Int10BiosArguments, BiosArguments, sizeof(*BiosArguments));
820 Int10BiosArguments.SegDs = 0;
821 Int10BiosArguments.SegEs = 0;
822
823 /* Do the BIOS call */
824 Status = IntInt10CallBios(NULL, &Int10BiosArguments);
825
826 /* Copy results back */
827 RtlCopyMemory(BiosArguments, &Int10BiosArguments, sizeof(*BiosArguments));
828
829 return Status;
830}
VP_STATUS NTAPI IntInt10CallBios(_In_ PVOID Context, _Inout_ PINT10_BIOS_ARGUMENTS BiosArguments)
Definition: int10.c:737
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by VbeSetMode().

Variable Documentation

◆ VideoPortInt10Mutex

KMUTEX VideoPortInt10Mutex

Definition at line 41 of file int10.c.

Referenced by IntInt10CallBiosEmu(), and VideoPortInitialize().