ReactOS 0.4.15-dev-7889-g76290a6
halfuncs.h File Reference
#include <umtypes.h>
#include <haltypes.h>
#include <ketypes.h>
#include <section_attribs.h>
Include dependency graph for halfuncs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HalHandlerForBus   HALPRIVATEDISPATCH->HalHandlerForBus
 
#define HalHandlerForConfigSpace   HALPRIVATEDISPATCH->HalHandlerForConfigSpace
 
#define HalLocateHiberRanges   HALPRIVATEDISPATCH->HalLocateHiberRanges
 
#define HalRegisterBusHandler   HALPRIVATEDISPATCH->HalRegisterBusHandler
 
#define HalSetWakeEnable   HALPRIVATEDISPATCH->HalSetWakeEnable
 
#define HalSetWakeAlarm   HALPRIVATEDISPATCH->HalSetWakeAlarm
 
#define HalPciTranslateBusAddress   HALPRIVATEDISPATCH->HalPciTranslateBusAddress
 
#define HalPciAssignSlotResources   HALPRIVATEDISPATCH->HalPciAssignSlotResources
 
#define HalHaltSystem   HALPRIVATEDISPATCH->HalHaltSystem
 
#define HalFindBusAddressTranslation   HALPRIVATEDISPATCH->HalFindBusAddressTranslation
 
#define HalResetDisplay   HALPRIVATEDISPATCH->HalResetDisplay
 
#define HalAllocateMapRegisters   HALPRIVATEDISPATCH->HalAllocateMapRegisters
 
#define KdSetupPciDeviceForDebugging   HALPRIVATEDISPATCH->KdSetupPciDeviceForDebugging
 
#define KdReleasePciDeviceforDebugging   HALPRIVATEDISPATCH->KdReleasePciDeviceforDebugging
 
#define KdGetAcpiTablePhase0   HALPRIVATEDISPATCH->KdGetAcpiTablePhase0
 
#define KdCheckPowerButton   HALPRIVATEDISPATCH->KdCheckPowerButton
 
#define HalVectorToIDTEntry   HALPRIVATEDISPATCH->HalVectorToIDTEntry
 
#define KdMapPhysicalMemory64   HALPRIVATEDISPATCH->KdMapPhysicalMemory64
 
#define KdUnmapVirtualAddress   HALPRIVATEDISPATCH->KdUnmapVirtualAddress
 

Functions

NTHALAPI VOID NTAPI HalDisplayString (_In_ PCHAR String)
 
NTHALAPI BOOLEAN NTAPI HalAllProcessorsStarted (VOID)
 
NTHALAPI VOID NTAPI HalReturnToFirmware (_In_ FIRMWARE_REENTRY Action)
 
NTHALAPI VOID NTAPI HalProcessorIdle (VOID)
 
NTHALAPI BOOLEAN NTAPI HalBeginSystemInterrupt (_In_ KIRQL Irql, _In_ ULONG Vector, _Out_ PKIRQL OldIrql)
 
VOID FASTCALL HalClearSoftwareInterrupt (_In_ KIRQL Request)
 
NTHALAPI VOID NTAPI HalDisableSystemInterrupt (_In_ ULONG Vector, _In_ KIRQL Irql)
 
NTHALAPI BOOLEAN NTAPI HalEnableSystemInterrupt (_In_ ULONG Vector, _In_ KIRQL Irql, _In_ KINTERRUPT_MODE InterruptMode)
 
NTHALAPI VOID NTAPI HalEndSystemInterrupt (_In_ KIRQL Irql, _In_ UCHAR Vector)
 
NTHALAPI VOID NTAPI HalReportResourceUsage (VOID)
 
NTHALAPI VOID FASTCALL HalRequestSoftwareInterrupt (_In_ KIRQL SoftwareInterruptRequested)
 
NTHALAPI VOID NTAPI HalRequestIpi (_In_ KAFFINITY TargetSet)
 
NTHALAPI VOID NTAPI HalHandleNMI (PVOID NmiInfo)
 
NTHALAPI UCHAR FASTCALL HalSystemVectorDispatchEntry (_In_ ULONG Vector, _Out_ PKINTERRUPT_ROUTINE **FlatDispatch, _Out_ PKINTERRUPT_ROUTINE *NoConnection)
 
NTHALAPI NTSTATUS NTAPI HalAdjustResourceList (_Inout_ PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList)
 
VOID NTAPI HalStartProfileInterrupt (_In_ KPROFILE_SOURCE ProfileSource)
 
NTHALAPI VOID NTAPI HalStopProfileInterrupt (_In_ KPROFILE_SOURCE ProfileSource)
 
NTHALAPI ULONG_PTR NTAPI HalSetProfileInterval (_In_ ULONG_PTR Interval)
 
NTHALAPI BOOLEAN NTAPI HalQueryRealTimeClock (_In_ PTIME_FIELDS RtcTime)
 
NTHALAPI BOOLEAN NTAPI HalSetRealTimeClock (_In_ PTIME_FIELDS RtcTime)
 
NTHALAPI ULONG NTAPI HalSetTimeIncrement (_In_ ULONG Increment)
 
NTSTATUS NTAPI x86BiosAllocateBuffer (_In_ ULONG *Size, _In_ USHORT *Segment, _In_ USHORT *Offset)
 
NTSTATUS NTAPI x86BiosFreeBuffer (_In_ USHORT Segment, _In_ USHORT Offset)
 
NTSTATUS NTAPI x86BiosReadMemory (_In_ USHORT Segment, _In_ USHORT Offset, _Out_writes_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
 
NTSTATUS NTAPI x86BiosWriteMemory (_In_ USHORT Segment, _In_ USHORT Offset, _In_reads_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
 
BOOLEAN NTAPI x86BiosCall (_In_ ULONG InterruptNumber, _Inout_ PX86_BIOS_REGISTERS Registers)
 

Macro Definition Documentation

◆ HalAllocateMapRegisters

#define HalAllocateMapRegisters   HALPRIVATEDISPATCH->HalAllocateMapRegisters

Definition at line 46 of file halfuncs.h.

◆ HalFindBusAddressTranslation

#define HalFindBusAddressTranslation   HALPRIVATEDISPATCH->HalFindBusAddressTranslation

Definition at line 44 of file halfuncs.h.

◆ HalHaltSystem

#define HalHaltSystem   HALPRIVATEDISPATCH->HalHaltSystem

Definition at line 43 of file halfuncs.h.

◆ HalHandlerForBus

#define HalHandlerForBus   HALPRIVATEDISPATCH->HalHandlerForBus

Definition at line 35 of file halfuncs.h.

◆ HalHandlerForConfigSpace

#define HalHandlerForConfigSpace   HALPRIVATEDISPATCH->HalHandlerForConfigSpace

Definition at line 36 of file halfuncs.h.

◆ HalLocateHiberRanges

#define HalLocateHiberRanges   HALPRIVATEDISPATCH->HalLocateHiberRanges

Definition at line 37 of file halfuncs.h.

◆ HalPciAssignSlotResources

#define HalPciAssignSlotResources   HALPRIVATEDISPATCH->HalPciAssignSlotResources

Definition at line 42 of file halfuncs.h.

◆ HalPciTranslateBusAddress

#define HalPciTranslateBusAddress   HALPRIVATEDISPATCH->HalPciTranslateBusAddress

Definition at line 41 of file halfuncs.h.

◆ HalRegisterBusHandler

#define HalRegisterBusHandler   HALPRIVATEDISPATCH->HalRegisterBusHandler

Definition at line 38 of file halfuncs.h.

◆ HalResetDisplay

#define HalResetDisplay   HALPRIVATEDISPATCH->HalResetDisplay

Definition at line 45 of file halfuncs.h.

◆ HalSetWakeAlarm

#define HalSetWakeAlarm   HALPRIVATEDISPATCH->HalSetWakeAlarm

Definition at line 40 of file halfuncs.h.

◆ HalSetWakeEnable

#define HalSetWakeEnable   HALPRIVATEDISPATCH->HalSetWakeEnable

Definition at line 39 of file halfuncs.h.

◆ HalVectorToIDTEntry

#define HalVectorToIDTEntry   HALPRIVATEDISPATCH->HalVectorToIDTEntry

Definition at line 51 of file halfuncs.h.

◆ KdCheckPowerButton

#define KdCheckPowerButton   HALPRIVATEDISPATCH->KdCheckPowerButton

Definition at line 50 of file halfuncs.h.

◆ KdGetAcpiTablePhase0

#define KdGetAcpiTablePhase0   HALPRIVATEDISPATCH->KdGetAcpiTablePhase0

Definition at line 49 of file halfuncs.h.

◆ KdMapPhysicalMemory64

#define KdMapPhysicalMemory64   HALPRIVATEDISPATCH->KdMapPhysicalMemory64

Definition at line 52 of file halfuncs.h.

◆ KdReleasePciDeviceforDebugging

#define KdReleasePciDeviceforDebugging   HALPRIVATEDISPATCH->KdReleasePciDeviceforDebugging

Definition at line 48 of file halfuncs.h.

◆ KdSetupPciDeviceForDebugging

#define KdSetupPciDeviceForDebugging   HALPRIVATEDISPATCH->KdSetupPciDeviceForDebugging

Definition at line 47 of file halfuncs.h.

◆ KdUnmapVirtualAddress

#define KdUnmapVirtualAddress   HALPRIVATEDISPATCH->KdUnmapVirtualAddress

Definition at line 53 of file halfuncs.h.

Function Documentation

◆ HalAdjustResourceList()

NTHALAPI NTSTATUS NTAPI HalAdjustResourceList ( _Inout_ PIO_RESOURCE_REQUIREMENTS_LIST pResourceList)

◆ HalAllProcessorsStarted()

NTHALAPI BOOLEAN NTAPI HalAllProcessorsStarted ( VOID  )

Definition at line 60 of file processor.c.

61{
62 /* Do nothing */
63 return TRUE;
64}
#define TRUE
Definition: types.h:120

Referenced by Phase1InitializationDiscard().

◆ HalBeginSystemInterrupt()

NTHALAPI BOOLEAN NTAPI HalBeginSystemInterrupt ( _In_ KIRQL  Irql,
_In_ ULONG  Vector,
_Out_ PKIRQL  OldIrql 
)

◆ HalClearSoftwareInterrupt()

VOID FASTCALL HalClearSoftwareInterrupt ( _In_ KIRQL  Request)

◆ HalDisableSystemInterrupt()

NTHALAPI VOID NTAPI HalDisableSystemInterrupt ( _In_ ULONG  Vector,
_In_ KIRQL  Irql 
)

◆ HalDisplayString()

NTHALAPI VOID NTAPI HalDisplayString ( _In_ PCHAR  String)

◆ HalEnableSystemInterrupt()

NTHALAPI BOOLEAN NTAPI HalEnableSystemInterrupt ( _In_ ULONG  Vector,
_In_ KIRQL  Irql,
_In_ KINTERRUPT_MODE  InterruptMode 
)

◆ HalEndSystemInterrupt()

NTHALAPI VOID NTAPI HalEndSystemInterrupt ( _In_ KIRQL  Irql,
_In_ UCHAR  Vector 
)

◆ HalHandleNMI()

NTHALAPI VOID NTAPI HalHandleNMI ( PVOID  NmiInfo)

◆ HalProcessorIdle()

NTHALAPI VOID NTAPI HalProcessorIdle ( VOID  )

Definition at line 83 of file processor.c.

84{
85 /* Enable interrupts and halt the processor */
86 _enable();
88 while (TRUE);
89}
#define UNIMPLEMENTED
Definition: debug.h:115
void __cdecl _enable(void)
Definition: intrin_arm.h:373

Referenced by PopIdle0().

◆ HalQueryRealTimeClock()

NTHALAPI BOOLEAN NTAPI HalQueryRealTimeClock ( _In_ PTIME_FIELDS  RtcTime)

◆ HalReportResourceUsage()

NTHALAPI VOID NTAPI HalReportResourceUsage ( VOID  )

Definition at line 67 of file usage.c.

68{
69 UNICODE_STRING HalString;
70
71 /* Build HAL usage */
72 RtlInitUnicodeString(&HalString, L"ARM Versatile HAL");
74}
VOID NTAPI HalpReportResourceUsage(IN PUNICODE_STRING HalName, IN INTERFACE_TYPE InterfaceType)
Definition: usage.c:26
@ Internal
Definition: hwresource.cpp:137
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define L(x)
Definition: ntvdm.h:50

Referenced by Phase1InitializationDiscard().

◆ HalRequestIpi()

NTHALAPI VOID NTAPI HalRequestIpi ( _In_ KAFFINITY  TargetSet)

Definition at line 19 of file up.c.

21{
22 /* This should never be called in UP mode */
24}
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698

◆ HalRequestSoftwareInterrupt()

NTHALAPI VOID FASTCALL HalRequestSoftwareInterrupt ( _In_ KIRQL  SoftwareInterruptRequested)

◆ HalReturnToFirmware()

NTHALAPI VOID NTAPI HalReturnToFirmware ( _In_ FIRMWARE_REENTRY  Action)

Definition at line 21 of file reboot.c.

23{
24 /* Check what kind of action this is */
25 switch (Action)
26 {
27 /* All recognized actions */
28 case HalHaltRoutine:
32 {
33 /* Acquire the display */
35 // TODO: Reboot
36 }
37
38 /* Anything else */
39 default:
40 {
41 /* Print message and break */
42 DbgPrint("HalReturnToFirmware called!\n");
44 }
45 }
46}
#define DbgPrint
Definition: hal.h:12
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:290
NTSYSAPI void WINAPI DbgBreakPoint(void)
@ HalRestartRoutine
Definition: haltypes.h:36
@ HalHaltRoutine
Definition: haltypes.h:34
@ HalPowerDownRoutine
Definition: haltypes.h:35
@ HalRebootRoutine
Definition: haltypes.h:37
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510

Referenced by KdbpCmdReboot(), KdpSendWaitContinue(), KeBugCheckWithTf(), and PopShutdownSystem().

◆ HalSetProfileInterval()

NTHALAPI ULONG_PTR NTAPI HalSetProfileInterval ( _In_ ULONG_PTR  Interval)

Definition at line 58 of file profil.c.

60{
61 /*
62 * FIXME:
63 * 1) What is the maximum and minimum interrupt frequency for the RTC?
64 * 2) Find the maximum possible clock divisor value.
65 */
67
68 /* Update interval */
71
72 /* For now... */
73 return Interval;
74}
VOID NTAPI HalStartProfileInterrupt(_In_ KPROFILE_SOURCE ProfileSource)
Definition: profil.c:41
BOOLEAN HalpProfilingStopped
Definition: profil.c:17
DWORD Interval
Definition: netstat.c:30

◆ HalSetRealTimeClock()

NTHALAPI BOOLEAN NTAPI HalSetRealTimeClock ( _In_ PTIME_FIELDS  RtcTime)

Definition at line 288 of file cmos.c.

290{
291 UCHAR i, j;
292 UCHAR SysTime[6];
293
295
296 HalpRtcWriteCommand(RTC_CMD_REGISTER_SHIFT);
297
298 SysTime[0] = INT_BCD(Time->Second);
299 SysTime[1] = INT_BCD(Time->Minute);
300 SysTime[2] = INT_BCD(Time->Hour);
301 SysTime[3] = INT_BCD(Time->Day);
302 SysTime[4] = (Time->Month << 4) | (Time->Weekday & 0x0F);
303 SysTime[5] = INT_BCD(Time->Year % 100);
304
305 /* Write time fields to RTC */
306 for (i = 0; i < 6; i++)
307 {
308 for (j = 0; j < 8; j++)
309 HalpRtcWriteBit(SysTime[i] >> j);
310 }
311
312 HalpRtcWriteCommand(RTC_CMD_TIME_SET_COUNTER_HOLD);
313 HalpRtcWriteCommand(RTC_CMD_REGISTER_HOLD);
314
316
317 return TRUE;
318}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
VOID NTAPI HalpReleaseCmosSpinLock(VOID)
Definition: spinlock.c:243
VOID NTAPI HalpAcquireCmosSpinLock(VOID)
Definition: spinlock.c:226
#define INT_BCD(int)
Definition: halp.h:73
static PLARGE_INTEGER Time
Definition: time.c:105
#define RTC_CMD_REGISTER_HOLD
Definition: rtc.h:16
#define RTC_CMD_TIME_SET_COUNTER_HOLD
Definition: rtc.h:18
#define RTC_CMD_REGISTER_SHIFT
Definition: rtc.h:17
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ HalSetTimeIncrement()

NTHALAPI ULONG NTAPI HalSetTimeIncrement ( _In_ ULONG  Increment)

◆ HalStartProfileInterrupt()

VOID NTAPI HalStartProfileInterrupt ( _In_ KPROFILE_SOURCE  ProfileSource)

Definition at line 41 of file profil.c.

43{
44 UNREFERENCED_PARAMETER(ProfileSource);
45
47
49
50 /* Configure the clock divisor for generating periodic interrupts */
52
54}
#define FALSE
Definition: types.h:117
UCHAR HalpProfileRate
Definition: profil.c:18
PPC_QUAL void __outbyte(unsigned long const Port, const unsigned char Data)
Definition: intrin_ppc.h:605
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define RTC_IO_o_INT_CLOCK_DIVISOR
Definition: rtc.h:37

◆ HalStopProfileInterrupt()

NTHALAPI VOID NTAPI HalStopProfileInterrupt ( _In_ KPROFILE_SOURCE  ProfileSource)

Definition at line 24 of file profil.c.

26{
27 UNREFERENCED_PARAMETER(ProfileSource);
28
30
31 /* Clear the interrupt flag */
33
35
37}
#define VOID
Definition: acefi.h:82
PPC_QUAL unsigned char __inbyte(const unsigned long Port)
Definition: intrin_ppc.h:539
#define RTC_IO_i_INTERRUPT_RESET
Definition: rtc.h:44

◆ HalSystemVectorDispatchEntry()

NTHALAPI UCHAR FASTCALL HalSystemVectorDispatchEntry ( _In_ ULONG  Vector,
_Out_ PKINTERRUPT_ROUTINE **  FlatDispatch,
_Out_ PKINTERRUPT_ROUTINE NoConnection 
)

◆ x86BiosAllocateBuffer()

NTSTATUS NTAPI x86BiosAllocateBuffer ( _In_ ULONG Size,
_In_ USHORT Segment,
_In_ USHORT Offset 
)

Definition at line 151 of file x86bios.c.

155{
156 /* Check if the system is initialized and the buffer is large enough */
158 {
159 /* Something was wrong, fail! */
161 }
162
163 /* Check if the buffer is already allocated */
165 {
166 /* Buffer was already allocated, fail */
168 }
169
170 /* The buffer is sufficient, return hardcoded address and size */
171 *Size = PAGE_SIZE;
173 *Offset = 0;
174
175 return STATUS_SUCCESS;
176}
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
LONG x86BiosBufferIsAllocated
Definition: x86bios.c:23
BOOLEAN x86BiosIsInitialized
Definition: x86bios.c:22
ULONG64 x86BiosBufferPhysical
Definition: x86bios.c:27
_Inout_ PVOID Segment
Definition: exfuncs.h:1101

Referenced by IntInt10AllocateBuffer().

◆ x86BiosCall()

BOOLEAN NTAPI x86BiosCall ( _In_ ULONG  InterruptNumber,
_Inout_ PX86_BIOS_REGISTERS  Registers 
)

Definition at line 410 of file x86bios.c.

413{
414 const ULONG StackBase = 0x2000;
415 FAST486_STATE EmulatorContext;
416 ULONG FlatIp;
417 PUCHAR InstructionPointer;
418
419 /* Initialize the emulator context */
423 x86IoRead,
425 x86BOP,
426 x86IntAck,
427 NULL, // FpuCallback,
428 NULL); // Tlb
429
430 /* Copy the registers */
431 EmulatorContext.GeneralRegs[FAST486_REG_EAX].Long = Registers->Eax;
432 EmulatorContext.GeneralRegs[FAST486_REG_EBX].Long = Registers->Ebx;
433 EmulatorContext.GeneralRegs[FAST486_REG_ECX].Long = Registers->Ecx;
434 EmulatorContext.GeneralRegs[FAST486_REG_EDX].Long = Registers->Edx;
435 EmulatorContext.GeneralRegs[FAST486_REG_ESI].Long = Registers->Esi;
436 EmulatorContext.GeneralRegs[FAST486_REG_EDI].Long = Registers->Edi;
437 EmulatorContext.SegmentRegs[FAST486_REG_DS].Selector = Registers->SegDs;
438 EmulatorContext.SegmentRegs[FAST486_REG_ES].Selector = Registers->SegEs;
439
440 /* Set Eflags */
441 EmulatorContext.Flags.Long = 0;
442 EmulatorContext.Flags.AlwaysSet = 1;
443 EmulatorContext.Flags.If = 1;
444
445 /* Set up the INT stub */
446 FlatIp = StackBase - 4;
447 InstructionPointer = x86BiosMemoryMapping + FlatIp;
448 InstructionPointer[0] = 0xCD; // INT instruction
449 InstructionPointer[1] = (UCHAR)InterruptNumber;
450 InstructionPointer[2] = 0x90; // NOP. We will stop at this address.
451
452 /* Set the stack pointer */
453 Fast486SetStack(&EmulatorContext, 0, StackBase - 8);
454
455 /* Start execution at the INT stub */
456 Fast486ExecuteAt(&EmulatorContext, 0x00, FlatIp);
457
458 while (TRUE)
459 {
460 /* Get the current flat IP */
461 FlatIp = (EmulatorContext.SegmentRegs[FAST486_REG_CS].Selector << 4) +
462 EmulatorContext.InstPtr.Long;
463
464 /* Make sure we haven't left the allowed memory range */
465 if (FlatIp >= 0x100000)
466 {
467 DPRINT1("x86BiosCall: invalid IP (0x%lx) during BIOS execution\n", FlatIp);
468 return FALSE;
469 }
470
471 /* Check if we returned from our int stub */
472 if (FlatIp == (StackBase - 2))
473 {
474 /* We are done! */
475 break;
476 }
477
478 /* Emulate one instruction */
480 }
481
482 /* Copy the registers back */
483 Registers->Eax = EmulatorContext.GeneralRegs[FAST486_REG_EAX].Long;
484 Registers->Ebx = EmulatorContext.GeneralRegs[FAST486_REG_EBX].Long;
485 Registers->Ecx = EmulatorContext.GeneralRegs[FAST486_REG_ECX].Long;
486 Registers->Edx = EmulatorContext.GeneralRegs[FAST486_REG_EDX].Long;
487 Registers->Esi = EmulatorContext.GeneralRegs[FAST486_REG_ESI].Long;
488 Registers->Edi = EmulatorContext.GeneralRegs[FAST486_REG_EDI].Long;
489 Registers->SegDs = EmulatorContext.SegmentRegs[FAST486_REG_DS].Selector;
490 Registers->SegEs = EmulatorContext.SegmentRegs[FAST486_REG_ES].Selector;
491
492 return TRUE;
493}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
VOID NTAPI Fast486SetStack(PFAST486_STATE State, USHORT Segment, ULONG Offset)
Definition: fast486.c:227
VOID NTAPI Fast486Initialize(PFAST486_STATE State, FAST486_MEM_READ_PROC MemReadCallback, FAST486_MEM_WRITE_PROC MemWriteCallback, FAST486_IO_READ_PROC IoReadCallback, FAST486_IO_WRITE_PROC IoWriteCallback, FAST486_BOP_PROC BopCallback, FAST486_INT_ACK_PROC IntAckCallback, FAST486_FPU_PROC FpuCallback, PULONG Tlb)
Definition: fast486.c:103
VOID NTAPI Fast486ExecuteAt(PFAST486_STATE State, USHORT Segment, ULONG Offset)
Definition: fast486.c:212
if(dx< 0)
Definition: linetemp.h:194
VOID NTAPI Fast486StepInto(PFAST486_STATE State)
Definition: debug.c:248
FAST486_STATE EmulatorContext
Definition: cpu.c:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
static VOID FASTCALL x86IoRead(PFAST486_STATE State, USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize)
Definition: x86bios.c:343
static VOID FASTCALL x86MemWrite(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
Definition: x86bios.c:280
static VOID FASTCALL x86MemRead(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
Definition: x86bios.c:259
PUCHAR x86BiosMemoryMapping
Definition: x86bios.c:24
static UCHAR FASTCALL x86IntAck(PFAST486_STATE State)
Definition: x86bios.c:401
static VOID FASTCALL x86IoWrite(PFAST486_STATE State, USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize)
Definition: x86bios.c:367
static VOID FASTCALL x86BOP(PFAST486_STATE State, UCHAR BopCode)
Definition: x86bios.c:391

Referenced by IntInt10CallBios().

◆ x86BiosFreeBuffer()

NTSTATUS NTAPI x86BiosFreeBuffer ( _In_ USHORT  Segment,
_In_ USHORT  Offset 
)

Definition at line 180 of file x86bios.c.

183{
184 /* Check if the system is initialized and if the address matches */
185 if (!x86BiosIsInitialized || (Segment != 0x2000) || (Offset != 0))
186 {
187 /* Something was wrong, fail */
189 }
190
191 /* Check if the buffer was allocated */
193 {
194 /* It was not, fail */
196 }
197
198 /* Buffer is freed, nothing more to do */
199 return STATUS_SUCCESS;
200}
#define InterlockedBitTestAndReset
Definition: interlocked.h:35
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by IntInt10FreeBuffer().

◆ x86BiosReadMemory()

NTSTATUS NTAPI x86BiosReadMemory ( _In_ USHORT  Segment,
_In_ USHORT  Offset,
_Out_writes_bytes_(Size) PVOID  Buffer,
_In_ ULONG  Size 
)

Definition at line 204 of file x86bios.c.

209{
211
212 /* Calculate the physical address */
213 Address = (Segment << 4) + Offset;
214
215 /* Check if it's valid */
216 if (!x86BiosIsInitialized || ((Address + Size) > 0x100000))
217 {
218 /* Invalid */
220 }
221
222 /* Copy the memory to the buffer */
224
225 /* Return success */
226 return STATUS_SUCCESS;
227}
Definition: bufpool.h:45
static WCHAR Address[46]
Definition: ping.c:68
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by IntInt10ReadMemory().

◆ x86BiosWriteMemory()

NTSTATUS NTAPI x86BiosWriteMemory ( _In_ USHORT  Segment,
_In_ USHORT  Offset,
_In_reads_bytes_(Size) PVOID  Buffer,
_In_ ULONG  Size 
)

Definition at line 231 of file x86bios.c.

236{
238
239 /* Calculate the physical address */
240 Address = (Segment << 4) + Offset;
241
242 /* Check if it's valid */
243 if (!x86BiosIsInitialized || ((Address + Size) > 0x100000))
244 {
245 /* Invalid */
247 }
248
249 /* Copy the memory from the buffer */
251
252 /* Return success */
253 return STATUS_SUCCESS;
254}

Referenced by IntInt10WriteMemory().