ReactOS  0.4.14-dev-358-gbef841c
int10.c File Reference
#include "videoprt.h"
#include <ndk/kefuncs.h>
#include <ndk/halfuncs.h>
#include <debug.h>
Include dependency graph for int10.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI IntInitializeVideoAddressSpace (VOID)
 
VP_STATUS NTAPI IntInt10AllocateBuffer (IN PVOID Context, OUT PUSHORT Seg, OUT PUSHORT Off, IN OUT PULONG Length)
 
VP_STATUS NTAPI IntInt10FreeBuffer (IN PVOID Context, IN USHORT Seg, IN USHORT Off)
 
VP_STATUS NTAPI IntInt10ReadMemory (IN PVOID Context, IN USHORT Seg, IN USHORT Off, OUT PVOID Buffer, IN ULONG Length)
 
VP_STATUS NTAPI IntInt10WriteMemory (IN PVOID Context, IN USHORT Seg, IN USHORT Off, IN PVOID Buffer, IN ULONG Length)
 
VP_STATUS NTAPI IntInt10CallBios (IN PVOID Context, IN OUT PINT10_BIOS_ARGUMENTS BiosArguments)
 
VP_STATUS NTAPI VideoPortInt10 (IN PVOID HwDeviceExtension, IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 27 of file int10.c.

Function Documentation

◆ IntInitializeVideoAddressSpace()

NTSTATUS NTAPI IntInitializeVideoAddressSpace ( VOID  )

Definition at line 146 of file int10.c.

147 {
149  NT_ASSERT(FALSE);
150  return STATUS_NOT_IMPLEMENTED;
151 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by IntVideoPortDispatchOpen().

◆ IntInt10AllocateBuffer()

VP_STATUS NTAPI IntInt10AllocateBuffer ( IN PVOID  Context,
OUT PUSHORT  Seg,
OUT PUSHORT  Off,
IN OUT PULONG  Length 
)

Definition at line 156 of file int10.c.

161 {
163 #ifdef _M_IX86
164  PVOID MemoryAddress;
165  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
167  SIZE_T Size;
168 
169  TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
170 
171  IntAttachToCSRSS(&CallingProcess, &ApcState);
172 
173  Size = *Length;
174  MemoryAddress = (PVOID)0x20000;
175  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
176  &MemoryAddress,
177  0,
178  &Size,
179  MEM_COMMIT,
181  if (!NT_SUCCESS(Status))
182  {
183  WARN_(VIDEOPRT, "- ZwAllocateVirtualMemory failed\n");
184  IntDetachFromCSRSS(&CallingProcess, &ApcState);
186  }
187 
188  if (MemoryAddress > (PVOID)(0x100000 - Size))
189  {
190  ZwFreeVirtualMemory(NtCurrentProcess(),
191  &MemoryAddress,
192  &Size,
193  MEM_RELEASE);
194  WARN_(VIDEOPRT, "- Unacceptable memory allocated\n");
195  IntDetachFromCSRSS(&CallingProcess, &ApcState);
197  }
198 
199  *Length = (ULONG)Size;
200  *Seg = (USHORT)((ULONG_PTR)MemoryAddress >> 4);
201  *Off = (USHORT)((ULONG_PTR)MemoryAddress & 0xF);
202 
203  INFO_(VIDEOPRT, "- Segment: %x\n", (ULONG_PTR)MemoryAddress >> 4);
204  INFO_(VIDEOPRT, "- Offset: %x\n", (ULONG_PTR)MemoryAddress & 0xF);
205  INFO_(VIDEOPRT, "- Length: %x\n", *Length);
206 
207  IntDetachFromCSRSS(&CallingProcess, &ApcState);
208 
209  return NO_ERROR;
210 #else
211  Status = x86BiosAllocateBuffer(Length, Seg, Off);
213 #endif
214 }
KAPC_STATE
Definition: ketypes.h:1273
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define MEM_COMMIT
Definition: nt_native.h:1313
uint32_t ULONG_PTR
Definition: typedefs.h:63
NTSTATUS NTAPI x86BiosAllocateBuffer(_In_ ULONG *Size, _In_ USHORT *Segment, _In_ USHORT *Offset)
Definition: x86bios.c:116
#define PsGetCurrentProcess
Definition: psfuncs.h:17
void * PVOID
Definition: retypes.h:9
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define TRACE_(x)
Definition: compat.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:425
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:199
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:438
unsigned int ULONG
Definition: retypes.h:1
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by VideoPortQueryServices().

◆ IntInt10CallBios()

VP_STATUS NTAPI IntInt10CallBios ( IN PVOID  Context,
IN OUT PINT10_BIOS_ARGUMENTS  BiosArguments 
)

Definition at line 315 of file int10.c.

318 {
319 #ifdef _M_AMD64
320  X86_BIOS_REGISTERS BiosContext;
321 #else
323 #endif
325  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
327 
328  /* Attach to CSRSS */
329  IntAttachToCSRSS(&CallingProcess, &ApcState);
330 
331  /* Clear the context */
333 
334  /* Fill out the bios arguments */
335  BiosContext.Eax = BiosArguments->Eax;
336  BiosContext.Ebx = BiosArguments->Ebx;
337  BiosContext.Ecx = BiosArguments->Ecx;
338  BiosContext.Edx = BiosArguments->Edx;
339  BiosContext.Esi = BiosArguments->Esi;
340  BiosContext.Edi = BiosArguments->Edi;
341  BiosContext.Ebp = BiosArguments->Ebp;
342  BiosContext.SegDs = BiosArguments->SegDs;
343  BiosContext.SegEs = BiosArguments->SegEs;
344 
345  /* Do the ROM BIOS call */
347  Executive,
348  KernelMode,
349  FALSE,
350  NULL);
351 
352 #ifdef _M_AMD64
354 #else
355  Status = Ke386CallBios(0x10, &BiosContext);
356 #endif
357 
359 
360  /* Return the arguments */
361  BiosArguments->Eax = BiosContext.Eax;
362  BiosArguments->Ebx = BiosContext.Ebx;
363  BiosArguments->Ecx = BiosContext.Ecx;
364  BiosArguments->Edx = BiosContext.Edx;
365  BiosArguments->Esi = BiosContext.Esi;
366  BiosArguments->Edi = BiosContext.Edi;
367  BiosArguments->Ebp = BiosContext.Ebp;
368  BiosArguments->SegDs = (USHORT)BiosContext.SegDs;
369  BiosArguments->SegEs = (USHORT)BiosContext.SegEs;
370 
371  /* Detach and return status */
372  IntDetachFromCSRSS(&CallingProcess, &ApcState);
373 
374  if (NT_SUCCESS(Status))
375  {
376  return NO_ERROR;
377  }
378 
380 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
KAPC_STATE
Definition: ketypes.h:1273
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define KeWaitForMutexObject
Definition: kefuncs.h:568
LONG NTSTATUS
Definition: precomp.h:26
KMUTEX VideoPortInt10Mutex
Definition: videoprt.c:36
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
#define NO_ERROR
Definition: dderror.h:5
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CALLBACK16 BiosContext
Definition: bios32.c:45
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI Ke386CallBios(IN ULONG Int, OUT PCONTEXT Context)
Definition: v86vdm.c:613
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:425
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:199
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:438
BOOLEAN NTAPI x86BiosCall(_In_ ULONG InterruptNumber, _Inout_ PX86_BIOS_REGISTERS Registers)
Definition: x86bios.c:367
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by VideoPortInt10(), and VideoPortQueryServices().

◆ IntInt10FreeBuffer()

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

Definition at line 218 of file int10.c.

222 {
224 #ifdef _M_IX86
225  PVOID MemoryAddress = (PVOID)((ULONG_PTR)(Seg << 4) | Off);
226  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
228  SIZE_T Size = 0;
229 
230  TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
231  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
232  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
233 
234  IntAttachToCSRSS(&CallingProcess, &ApcState);
235  Status = ZwFreeVirtualMemory(NtCurrentProcess(),
236  &MemoryAddress,
237  &Size,
238  MEM_RELEASE);
239 
240  IntDetachFromCSRSS(&CallingProcess, &ApcState);
241 
242  return Status;
243 #else
244  Status = x86BiosFreeBuffer(Seg, Off);
246 #endif
247 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
KAPC_STATE
Definition: ketypes.h:1273
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:63
NTSTATUS NTAPI x86BiosFreeBuffer(_In_ USHORT Segment, _In_ USHORT Offset)
Definition: x86bios.c:145
#define PsGetCurrentProcess
Definition: psfuncs.h:17
void * PVOID
Definition: retypes.h:9
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define TRACE_(x)
Definition: compat.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:425
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:199
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:438

Referenced by VideoPortQueryServices().

◆ IntInt10ReadMemory()

VP_STATUS NTAPI IntInt10ReadMemory ( IN PVOID  Context,
IN USHORT  Seg,
IN USHORT  Off,
OUT PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 251 of file int10.c.

257 {
258 #ifdef _M_IX86
259  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
261 
262  TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
263  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
264  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
265  INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
266  INFO_(VIDEOPRT, "- Length: %x\n", Length);
267 
268  IntAttachToCSRSS(&CallingProcess, &ApcState);
269  RtlCopyMemory(Buffer, (PVOID)((ULONG_PTR)(Seg << 4) | Off), Length);
270  IntDetachFromCSRSS(&CallingProcess, &ApcState);
271 
272  return NO_ERROR;
273 #else
275 
276  Status = x86BiosReadMemory(Seg, Off, Buffer, Length);
278 #endif
279 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
KAPC_STATE
Definition: ketypes.h:1273
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PsGetCurrentProcess
Definition: psfuncs.h:17
Definition: bufpool.h:45
NTSTATUS NTAPI x86BiosReadMemory(_In_ USHORT Segment, _In_ USHORT Offset, _Out_writes_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:169
#define TRACE_(x)
Definition: compat.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:425
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:199
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:438

Referenced by VideoPortQueryServices().

◆ IntInt10WriteMemory()

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

Definition at line 283 of file int10.c.

289 {
290 #ifdef _M_IX86
291  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
293 
294  TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
295  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
296  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
297  INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
298  INFO_(VIDEOPRT, "- Length: %x\n", Length);
299 
300  IntAttachToCSRSS(&CallingProcess, &ApcState);
301  RtlCopyMemory((PVOID)((ULONG_PTR)(Seg << 4) | Off), Buffer, Length);
302  IntDetachFromCSRSS(&CallingProcess, &ApcState);
303 
304  return NO_ERROR;
305 #else
307 
308  Status = x86BiosWriteMemory(Seg, Off, Buffer, Length);
310 #endif
311 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
KAPC_STATE
Definition: ketypes.h:1273
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PsGetCurrentProcess
Definition: psfuncs.h:17
Definition: bufpool.h:45
#define TRACE_(x)
Definition: compat.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:425
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:199
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:438
NTSTATUS NTAPI x86BiosWriteMemory(_In_ USHORT Segment, _In_ USHORT Offset, _In_reads_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:196

Referenced by VideoPortQueryServices().

◆ VideoPortInt10()

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

Definition at line 389 of file int10.c.

392 {
393  INT10_BIOS_ARGUMENTS Int10BiosArguments;
395 
396  if (!CsrssInitialized)
397  {
399  }
400 
401  /* Copy arguments to other format */
402  RtlCopyMemory(&Int10BiosArguments, BiosArguments, sizeof(*BiosArguments));
403  Int10BiosArguments.SegDs = 0;
404  Int10BiosArguments.SegEs = 0;
405 
406  /* Do the BIOS call */
407  Status = IntInt10CallBios(NULL, &Int10BiosArguments);
408 
409  /* Copy results back */
410  RtlCopyMemory(BiosArguments, &Int10BiosArguments, sizeof(*BiosArguments));
411 
412  return Status;
413 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
smooth NULL
Definition: ftsmooth.c:416
VP_STATUS NTAPI IntInt10CallBios(IN PVOID Context, IN OUT PINT10_BIOS_ARGUMENTS BiosArguments)
Definition: int10.c:315
Status
Definition: gdiplustypes.h:24
ULONG CsrssInitialized
Definition: videoprt.c:33
LONG VP_STATUS
Definition: video.h:153

Referenced by VbeSetMode().