Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300/* * PROJECT: ReactOS Hardware Abstraction Layer (HAL) * LICENSE: BSD - See COPYING.ARM in the top level directory * PURPOSE: I/O Mapping and x86 Subs * PROGRAMMERS: ReactOS Portable Systems Group */
/* INCLUDES *******************************************************************/
#include <hal.h>
#define NDEBUG#include <debug.h>
/* GLOBALS *******************************************************************/
UCHAR HalpSerialLen;CHAR HalpSerialNumber[31];
/* PRIVATE FUNCTIONS **********************************************************/
#ifndef _MINIHAL_CODE_SEG("INIT")VOIDNTAPIHalpReportSerialNumber(VOID){ NTSTATUS Status; UNICODE_STRING KeyString; HANDLE Handle;
/* Make sure there is a serial number */ if (!HalpSerialLen) return;
/* Open the system key */ RtlInitUnicodeString(&KeyString, L"\\Registry\\Machine\\Hardware\\Description\\System"); Status = HalpOpenRegistryKey(&Handle, 0, &KeyString, KEY_ALL_ACCESS, FALSE); if (NT_SUCCESS(Status)) { /* Add the serial number */ RtlInitUnicodeString(&KeyString, L"Serial Number"); ZwSetValueKey(Handle, &KeyString, 0, REG_BINARY, HalpSerialNumber, HalpSerialLen);
/* Close the handle */ ZwClose(Handle); }}
CODE_SEG("INIT")NTSTATUSNTAPIHalpMarkAcpiHal(VOID){ NTSTATUS Status; UNICODE_STRING KeyString; HANDLE KeyHandle; HANDLE Handle; ULONG Value = HalDisableFirmwareMapper ? 1 : 0;
/* Open the control set key */ RtlInitUnicodeString(&KeyString, L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET"); Status = HalpOpenRegistryKey(&Handle, 0, &KeyString, KEY_ALL_ACCESS, FALSE); if (NT_SUCCESS(Status)) { /* Open the PNP key */ RtlInitUnicodeString(&KeyString, L"Control\\Pnp"); Status = HalpOpenRegistryKey(&KeyHandle, Handle, &KeyString, KEY_ALL_ACCESS, TRUE); /* Close root key */ ZwClose(Handle);
/* Check if PNP BIOS key exists */ if (NT_SUCCESS(Status)) { /* Set the disable value to false -- we need the mapper */ RtlInitUnicodeString(&KeyString, L"DisableFirmwareMapper"); Status = ZwSetValueKey(KeyHandle, &KeyString, 0, REG_DWORD, &Value, sizeof(Value));
/* Close subkey */ ZwClose(KeyHandle); } }
/* Return status */ return Status;}
NTSTATUSNTAPIHalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create){ NTSTATUS Status; ULONG Disposition; OBJECT_ATTRIBUTES ObjectAttributes;
/* Setup the attributes we received */ InitializeObjectAttributes(&ObjectAttributes, KeyName, OBJ_CASE_INSENSITIVE, RootKey, NULL);
/* What to do? */ if ( Create ) { /* Create the key */ Status = ZwCreateKey(KeyHandle, DesiredAccess, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, &Disposition); } else { /* Open the key */ Status = ZwOpenKey(KeyHandle, DesiredAccess, &ObjectAttributes); }
/* We're done */ return Status;}#endif /* !_MINIHAL_ */
VOIDNTAPIHalpCheckPowerButton(VOID){ // // Nothing to do on non-ACPI // return;}
VOIDNTAPIHalpFlushTLB(VOID){ ULONG_PTR Flags, Cr4; INT CpuInfo[4]; ULONG_PTR PageDirectory;
// // Disable interrupts // Flags = __readeflags(); _disable();
// // Get page table directory base // PageDirectory = __readcr3();
// // Check for CPUID support // if (KeGetCurrentPrcb()->CpuID) { // // Check for global bit in CPU features // __cpuid(CpuInfo, 1); if (CpuInfo[3] & 0x2000) { // // Get current CR4 value // Cr4 = __readcr4();
// // Disable global bit // __writecr4(Cr4 & ~CR4_PGE);
// // Flush TLB and re-enable global bit // __writecr3(PageDirectory); __writecr4(Cr4);
// // Restore interrupts // __writeeflags(Flags); return; } }
// // Legacy: just flush TLB // __writecr3(PageDirectory); __writeeflags(Flags);}
/* FUNCTIONS *****************************************************************/
/* * @implemented */UCHARFASTCALLHalSystemVectorDispatchEntry(IN ULONG Vector, OUT PKINTERRUPT_ROUTINE **FlatDispatch, OUT PKINTERRUPT_ROUTINE *NoConnection){ // // Not implemented on x86 // return 0;}
/* * @implemented */VOIDNTAPIKeFlushWriteBuffer(VOID){ // // Not implemented on x86 // return;}
#ifdef _M_IX86/* x86 fastcall wrappers */
#undef KeRaiseIrql/* * @implemented */VOIDNTAPIKeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql){ /* Call the fastcall function */ *OldIrql = KfRaiseIrql(NewIrql);}
#undef KeLowerIrql/* * @implemented */VOIDNTAPIKeLowerIrql(KIRQL NewIrql){ /* Call the fastcall function */ KfLowerIrql(NewIrql);}
#undef KeAcquireSpinLock/* * @implemented */VOIDNTAPIKeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql){ /* Call the fastcall function */ *OldIrql = KfAcquireSpinLock(SpinLock);}
#undef KeReleaseSpinLock/* * @implemented */VOIDNTAPIKeReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL NewIrql){ /* Call the fastcall function */ KfReleaseSpinLock(SpinLock, NewIrql);}
#endif /* _M_IX86 */