Author: ion
Date: Tue Nov 14 21:17:33 2006
New Revision: 24757
URL:
http://svn.reactos.org/svn/reactos?rev=24757&view=rev
Log:
- Implement HalSystemVectorDispatchEntry, KeFlushWriteBuffer, HalFlushCommonBuffer,
HalAllocateCrashDumpRegisters.
- Add lots of missing PCI definitions to the DDK, and to the internal file pci.h
- Make HAL compilable with the WDK thanks to a nice hack/trick I found.
Added:
trunk/reactos/ntoskrnl/include/internal/pci.h
Modified:
trunk/reactos/hal/halx86/generic/beep.c
trunk/reactos/hal/halx86/generic/dma.c
trunk/reactos/hal/halx86/generic/misc.c
trunk/reactos/hal/halx86/include/hal.h
trunk/reactos/include/ddk/winddk.h
trunk/reactos/include/ndk/halfuncs.h
Modified: trunk/reactos/hal/halx86/generic/beep.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/beep.c?…
==============================================================================
--- trunk/reactos/hal/halx86/generic/beep.c (original)
+++ trunk/reactos/hal/halx86/generic/beep.c Tue Nov 14 21:17:33 2006
@@ -1,11 +1,11 @@
/*
-* PROJECT: ReactOS HAL
-* LICENSE: GPL - See COPYING in the top level directory
-* FILE: ntoskrnl/hal/x86/beep.c
-* PURPOSE: Speak support (beeping)
-* PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
-* Eric Kohl (ekohl(a)abo.rhein-zeitung.de)
-*/
+ * PROJECT: ReactOS HAL
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/hal/x86/beep.c
+ * PURPOSE: Speak support (beeping)
+ * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
+ * Eric Kohl (ekohl(a)abo.rhein-zeitung.de)
+ */
/* INCLUDES ******************************************************************/
Modified: trunk/reactos/hal/halx86/generic/dma.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/dma.c?r…
==============================================================================
--- trunk/reactos/hal/halx86/generic/dma.c (original)
+++ trunk/reactos/hal/halx86/generic/dma.c Tue Nov 14 21:17:33 2006
@@ -1948,16 +1948,77 @@
*
* @implemented
*/
-
-BOOLEAN STDCALL
-HalFlushCommonBuffer(
- ULONG Unknown1,
- ULONG Unknown2,
- ULONG Unknown3,
- ULONG Unknown4,
- ULONG Unknown5)
-{
- return TRUE;
+BOOLEAN
+NTAPI
+HalFlushCommonBuffer(IN PADAPTER_OBJECT AdapterObject,
+ IN ULONG Length,
+ IN PHYSICAL_ADDRESS LogicalAddress,
+ IN PVOID VirtualAddress)
+{
+ /* Function always returns true */
+ return TRUE;
+}
+
+/*
+ * @implemented
+ */
+PVOID
+NTAPI
+HalAllocateCrashDumpRegisters(IN PADAPTER_OBJECT AdapterObject,
+ IN OUT PULONG NumberOfMapRegisters)
+{
+ PADAPTER_OBJECT MasterAdapter = AdapterObject->MasterAdapter;
+ ULONG MapRegisterNumber;
+
+ /* Check if it needs map registers */
+ if (AdapterObject->NeedsMapRegisters)
+ {
+ /* Check if we have enough */
+ if (*NumberOfMapRegisters > AdapterObject->MapRegistersPerChannel)
+ {
+ /* We don't, fail */
+ AdapterObject->NumberOfMapRegisters = 0;
+ return NULL;
+ }
+
+ /* Try to find free map registers */
+ MapRegisterNumber = -1;
+ MapRegisterNumber = RtlFindClearBitsAndSet(MasterAdapter->MapRegisters,
+ *NumberOfMapRegisters,
+ 0);
+
+ /* Check if nothing was found */
+ if (MapRegisterNumber == -1)
+ {
+ /* No free registers found, so use the base registers */
+ RtlSetBits(MasterAdapter->MapRegisters,
+ 0,
+ *NumberOfMapRegisters);
+ MapRegisterNumber = 0;
+ }
+
+ /* Calculate the new base */
+ AdapterObject->MapRegisterBase =
+ (PROS_MAP_REGISTER_ENTRY)(MasterAdapter->MapRegisterBase +
+ MapRegisterNumber);
+
+ /* Check if scatter gather isn't supported */
+ if (!AdapterObject->ScatterGather)
+ {
+ /* Set the flag */
+ AdapterObject->MapRegisterBase =
+ (PROS_MAP_REGISTER_ENTRY)
+ ((ULONG_PTR)AdapterObject->MapRegisterBase | MAP_BASE_SW_SG);
+ }
+ }
+ else
+ {
+ AdapterObject->MapRegisterBase = NULL;
+ AdapterObject->NumberOfMapRegisters = 0;
+ }
+
+ /* Return the base */
+ return AdapterObject->MapRegisterBase;
}
/* EOF */
Modified: trunk/reactos/hal/halx86/generic/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/misc.c?…
==============================================================================
--- trunk/reactos/hal/halx86/generic/misc.c (original)
+++ trunk/reactos/hal/halx86/generic/misc.c Tue Nov 14 21:17:33 2006
@@ -1,10 +1,10 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/hal/x86/misc.c
- * PURPOSE: Miscellaneous hardware functions
- * PROGRAMMER: Eric Kohl (ekohl(a)rz-online.de)
+/*
+ * PROJECT: ReactOS HAL
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/hal/halx86/misc.c
+ * PURPOSE: Miscellanous Routines
+ * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
+ * Eric Kohl (ekohl(a)abo.rhein-zeitung.de)
*/
/* INCLUDES *****************************************************************/
@@ -13,53 +13,63 @@
#define NDEBUG
#include <debug.h>
-
/* FUNCTIONS ****************************************************************/
-PVOID STDCALL
-HalAllocateCrashDumpRegisters(IN PADAPTER_OBJECT AdapterObject,
- IN OUT PULONG NumberOfMapRegisters)
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalHandleNMI(IN PVOID NmiInfo)
{
- UNIMPLEMENTED;
- return NULL;
+ UCHAR ucStatus;
+
+ /* Get the NMI Flag */
+ ucStatus = READ_PORT_UCHAR((PUCHAR)0x61);
+
+ /* Display NMI failure string */
+ HalDisplayString ("\n*** Hardware Malfunction\n\n");
+ HalDisplayString ("Call your hardware vendor for support\n\n");
+
+ /* Check for parity error */
+ if (ucStatus & 0x80)
+ {
+ /* Display message */
+ HalDisplayString ("NMI: Parity Check / Memory Parity Error\n");
+ }
+
+ /* Check for I/O failure */
+ if (ucStatus & 0x40)
+ {
+ /* Display message */
+ HalDisplayString ("NMI: Channel Check / IOCHK\n");
+ }
+
+ /* Halt the system */
+ HalDisplayString("\n*** The system has halted ***\n");
+ KeEnterKernelDebugger();
}
-
-VOID STDCALL
-HalHandleNMI(PVOID NmiInfo)
+/*
+ * @implemented
+ */
+BOOLEAN
+FASTCALL
+HalSystemVectorDispatchEntry(IN ULONG Vector,
+ OUT PKINTERRUPT_ROUTINE **FlatDispatch,
+ OUT PKINTERRUPT_ROUTINE *NoConnection)
{
- UCHAR ucStatus;
-
- ucStatus = READ_PORT_UCHAR((PUCHAR) 0x61);
-
- HalDisplayString ("\n*** Hardware Malfunction\n\n");
- HalDisplayString ("Call your hardware vendor for support\n\n");
-
- if (ucStatus & 0x80)
- HalDisplayString ("NMI: Parity Check / Memory Parity Error\n");
-
- if (ucStatus & 0x40)
- HalDisplayString ("NMI: Channel Check / IOCHK\n");
-
- HalDisplayString ("\n*** The system has halted ***\n");
- KeEnterKernelDebugger ();
+ /* Not implemented on x86 */
+ return FALSE;
}
-ULONG FASTCALL
-HalSystemVectorDispatchEntry (
- ULONG Unknown1,
- ULONG Unknown2,
- ULONG Unknown3
- )
-{
- return 0;
-}
-
-
-VOID STDCALL
+/*
+ * @implemented
+ */
+VOID
+NTAPI
KeFlushWriteBuffer(VOID)
{
- return;
+ /* Not implemented on x86 */
+ return;
}
-
-/* EOF */
Modified: trunk/reactos/hal/halx86/include/hal.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/hal.h?r…
==============================================================================
--- trunk/reactos/hal/halx86/include/hal.h (original)
+++ trunk/reactos/hal/halx86/include/hal.h Tue Nov 14 21:17:33 2006
@@ -11,9 +11,17 @@
/* C Headers */
#include <stdio.h>
+/* WDK HAL Complation hack */
+#ifdef _MSC_VER
+#include <excpt.h>
+#include <ntdef.h>
+#undef _NTHAL_
+#undef DECLSPEC_IMPORT
+#define DECLSPEC_IMPORT
+#endif
+
/* IFS/DDK/NDK Headers */
#include <ntifs.h>
-#include <ntddk.h>
#include <ntdddisk.h>
#include <arc/arc.h>
#include <iotypes.h>
@@ -25,6 +33,7 @@
#define KPCR_BASE 0xFF000000 // HACK!
/* Internal HAL Headers */
+#include "internal/pci.h"
#include "apic.h"
#include "bus.h"
#include "halirq.h"
Modified: trunk/reactos/include/ddk/winddk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/winddk.h?rev=2…
==============================================================================
--- trunk/reactos/include/ddk/winddk.h (original)
+++ trunk/reactos/include/ddk/winddk.h Tue Nov 14 21:17:33 2006
@@ -5240,6 +5240,47 @@
ResultPositive = RESULT_POSITIVE
} INTERLOCKED_RESULT;
+typedef VOID
+(NTAPI *PciPin2Line)(
+ IN struct _BUS_HANDLER *BusHandler,
+ IN struct _BUS_HANDLER *RootHandler,
+ IN PCI_SLOT_NUMBER SlotNumber,
+ IN PPCI_COMMON_CONFIG PciData
+);
+
+typedef VOID
+(NTAPI *PciLine2Pin)(
+ IN struct _BUS_HANDLER *BusHandler,
+ IN struct _BUS_HANDLER *RootHandler,
+ IN PCI_SLOT_NUMBER SlotNumber,
+ IN PPCI_COMMON_CONFIG PciNewData,
+ IN PPCI_COMMON_CONFIG PciOldData
+);
+
+typedef VOID
+(NTAPI *PciReadWriteConfig)(
+ IN struct _BUS_HANDLER *BusHandler,
+ IN PCI_SLOT_NUMBER Slot,
+ IN PVOID Buffer,
+ IN ULONG Offset,
+ IN ULONG Length
+);
+
+#define PCI_DATA_TAG TAG('P', 'C', 'I', ' ')
+#define PCI_DATA_VERSION 1
+
+typedef struct _PCIBUSDATA
+{
+ ULONG Tag;
+ ULONG Version;
+ PciReadWriteConfig ReadConfig;
+ PciReadWriteConfig WriteConfig;
+ PciPin2Line Pin2Line;
+ PciLine2Pin Line2Pin;
+ PCI_SLOT_NUMBER ParentSlot;
+ PVOID Reserved[4];
+} PCIBUSDATA, *PPCIBUSDATA;
+
NTHALAPI
KIRQL
DDKAPI
Modified: trunk/reactos/include/ndk/halfuncs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/halfuncs.h?rev…
==============================================================================
--- trunk/reactos/include/ndk/halfuncs.h (original)
+++ trunk/reactos/include/ndk/halfuncs.h Tue Nov 14 21:17:33 2006
@@ -26,6 +26,29 @@
#include <haltypes.h>
#ifndef NTOS_MODE_USER
+
+//
+// Private HAL Callbacks
+//
+#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
//
// The DDK steals these away from you.
Added: trunk/reactos/ntoskrnl/include/internal/pci.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/pci.h (added)
+++ trunk/reactos/ntoskrnl/include/internal/pci.h Tue Nov 14 21:17:33 2006
@@ -1,0 +1,94 @@
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/include/hal.h
+ * PURPOSE: Internal header for PCI Support
+ * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
+ */
+#ifndef _PCI_
+#define _PCI_
+
+//
+// PCI Type 1 Configuration Register
+//
+typedef struct _PCI_TYPE1_CFG_BITS
+{
+ union
+ {
+ struct
+ {
+ ULONG Reserved1:2;
+ ULONG RegisterNumber:6;
+ ULONG FunctionNumber:3;
+ ULONG DeviceNumber:5;
+ ULONG BusNumber:8;
+ ULONG Reserved2:7;
+ ULONG Enable:1;
+ } bits;
+
+ ULONG AsULONG;
+ } u;
+} PCI_TYPE1_CFG_BITS, *PPCI_TYPE1_CFG_BITS;
+
+//
+// PCI Type 2 CSE Register
+//
+typedef struct _PCI_TYPE2_CSE_BITS
+{
+ union
+ {
+ struct
+ {
+ UCHAR Enable:1;
+ UCHAR FunctionNumber:3;
+ UCHAR Key:4;
+ } bits;
+
+ UCHAR AsUCHAR;
+ } u;
+} PCI_TYPE2_CSE_BITS, PPCI_TYPE2_CSE_BITS;
+
+//
+// PCI Type 2 Address Register
+//
+typedef struct _PCI_TYPE2_ADDRESS_BITS
+{
+ union
+ {
+ struct
+ {
+ USHORT RegisterNumber:8;
+ USHORT Agent:4;
+ USHORT AddressBase:4;
+ } bits;
+
+ USHORT AsUSHORT;
+ } u;
+} PCI_TYPE2_ADDRESS_BITS, *PPCI_TYPE2_ADDRESS_BITS;
+
+//
+// PCI Registry Information
+//
+typedef struct _PCI_REGISTRY_INFO
+{
+ UCHAR MajorRevision;
+ UCHAR MinorRevision;
+ UCHAR NoBuses;
+ UCHAR HardwareMechanism;
+} PCI_REGISTRY_INFO, *PPCI_REGISTRY_INFO;
+
+//
+// PCI Card Descriptor in Registry
+//
+typedef struct _PCI_CARD_DESCRIPTOR
+{
+ ULONG Flags;
+ USHORT VendorID;
+ USHORT DeviceID;
+ USHORT RevisionID;
+ USHORT SubsystemVendorID;
+ USHORT SubsystemID;
+ USHORT Reserved;
+} PCI_CARD_DESCRIPTOR, *PPCI_CARD_DESCRIPTOR;
+
+#endif