- New ARM HAL after 2 nights in the company of a madman.
authorevb <evb@svn.reactos.org>
Tue, 9 Feb 2010 02:26:28 +0000 (02:26 +0000)
committerevb <evb@svn.reactos.org>
Tue, 9 Feb 2010 02:26:28 +0000 (02:26 +0000)
- Many fixes, more implemented routines, support for ARMv7.
- Some Linux code, marked as GPL, from ARM Ltd in cache.s. All OS use this code.

svn path=/trunk/; revision=45518

32 files changed:
reactos/hal/hal.pspec
reactos/hal/hal.rbuild
reactos/hal/halarm/directory.rbuild
reactos/hal/halarm/generic/beep.c [new file with mode: 0644]
reactos/hal/halarm/generic/bus.c [new file with mode: 0644]
reactos/hal/halarm/generic/cache.S [new file with mode: 0644]
reactos/hal/halarm/generic/display.c [new file with mode: 0644]
reactos/hal/halarm/generic/dma.c [new file with mode: 0644]
reactos/hal/halarm/generic/drive.c [new file with mode: 0644]
reactos/hal/halarm/generic/fmutex.c [new file with mode: 0644]
reactos/hal/halarm/generic/generic.rbuild [deleted file]
reactos/hal/halarm/generic/hal.c [deleted file]
reactos/hal/halarm/generic/halinit.c [new file with mode: 0644]
reactos/hal/halarm/generic/misc.c [new file with mode: 0644]
reactos/hal/halarm/generic/pic.c [new file with mode: 0644]
reactos/hal/halarm/generic/portio.c [new file with mode: 0644]
reactos/hal/halarm/generic/processor.c [new file with mode: 0644]
reactos/hal/halarm/generic/profil.c [new file with mode: 0644]
reactos/hal/halarm/generic/reboot.c [new file with mode: 0644]
reactos/hal/halarm/generic/rtc.c [new file with mode: 0644]
reactos/hal/halarm/generic/spinlock.c [new file with mode: 0644]
reactos/hal/halarm/generic/sysinfo.c [new file with mode: 0644]
reactos/hal/halarm/generic/timer.c [new file with mode: 0644]
reactos/hal/halarm/generic/usage.c [new file with mode: 0644]
reactos/hal/halarm/hal.rbuild [new file with mode: 0644]
reactos/hal/halarm/hal_generic.rbuild [new file with mode: 0644]
reactos/hal/halarm/include/hal.h
reactos/hal/halarm/include/halp.h
reactos/hal/halarm/up/halinit_up.c [deleted file]
reactos/hal/halarm/versa/halinit_up.c [new file with mode: 0644]
reactos/hal/halarm/versa/halup.rbuild [moved from reactos/hal/halarm/up/halup.rbuild with 59% similarity]
reactos/hal/halarm/versa/halup.rc [moved from reactos/hal/halarm/up/halup.rc with 100% similarity]

index 786372d..7419304 100644 (file)
@@ -46,7 +46,7 @@
 @ stdcall HalGetEnvironmentVariable(str long str)
 @ fastcall -arch=arm HalGetInterruptSource()
 @ stdcall HalGetInterruptVector(long long long long ptr ptr)
-@ stdcall HalHandleNMI(ptr)
+@ stdcall -arch=i386 HalHandleNMI(ptr)
 @ stdcall HalInitSystem(long ptr)
 @ stdcall HalInitializeProcessor(long ptr)
 @ stdcall HalMakeBeep(long)
index a7cf4bb..b846b04 100644 (file)
@@ -1,9 +1,12 @@
 <?xml version="1.0"?>
 <!DOCTYPE group SYSTEM "../tools/rbuild/project.dtd">
 <group xmlns:xi="http://www.w3.org/2001/XInclude">
-       <directory name="halx86">
-               <xi:include href="halx86/directory.rbuild" />
-       </directory>
+
+    <if property="ARCH" value="i386">
+           <directory name="halx86">
+                   <xi:include href="halx86/directory.rbuild" />
+           </directory>
+       </if>
 
        <if property="ARCH" value="powerpc">
                <directory name="halppc">
index 1e0c730..72cfe7e 100644 (file)
@@ -1,10 +1,11 @@
 <?xml version="1.0"?>
-<!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
+<!DOCTYPE group SYSTEM "../tools/rbuild/project.dtd">
 <group xmlns:xi="http://www.w3.org/2001/XInclude">
-       <directory name="generic">
-               <xi:include href="generic/generic.rbuild" />
-       </directory>
-       <directory name="up">
-               <xi:include href="up/halup.rbuild" />
-       </directory>
+
+       <xi:include href="hal_generic.rbuild" />
+
+       <if property="SARCH" value="versatile">
+               <xi:include href="versa/halup.rbuild" />
+       </if>
+
 </group>
diff --git a/reactos/hal/halarm/generic/beep.c b/reactos/hal/halarm/generic/beep.c
new file mode 100644 (file)
index 0000000..bd27412
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/beep.c
+ * PURPOSE:         Speaker support (beeping)
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * @implemented
+ */
+BOOLEAN
+NTAPI
+HalMakeBeep(IN ULONG Frequency)
+{
+    UNIMPLEMENTED;
+    return FALSE;
+}
diff --git a/reactos/hal/halarm/generic/bus.c b/reactos/hal/halarm/generic/bus.c
new file mode 100644 (file)
index 0000000..aeae3cb
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/bus.c
+ * PURPOSE:         Bus Support Routines
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+/* PUBLIC FUNCTIONS ***********************************************************/
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+HalAdjustResourceList(IN PIO_RESOURCE_REQUIREMENTS_LIST *ResourceList)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return STATUS_SUCCESS;
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+HalAssignSlotResources(IN PUNICODE_STRING RegistryPath,
+                       IN PUNICODE_STRING DriverClassName,
+                       IN PDRIVER_OBJECT DriverObject,
+                       IN PDEVICE_OBJECT DeviceObject,
+                       IN INTERFACE_TYPE BusType,
+                       IN ULONG BusNumber,
+                       IN ULONG SlotNumber,
+                       IN OUT PCM_RESOURCE_LIST *AllocatedResources)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return STATUS_SUCCESS;
+}
+
+/*
+ * @unimplemented
+ */
+ULONG
+NTAPI
+HalGetBusData(IN BUS_DATA_TYPE BusDataType,
+              IN ULONG BusNumber,
+              IN ULONG SlotNumber,
+              IN PVOID Buffer,
+              IN ULONG Length)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+ULONG
+NTAPI
+HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType,
+                      IN ULONG BusNumber,
+                      IN ULONG SlotNumber,
+                      IN PVOID Buffer,
+                      IN ULONG Offset,
+                      IN ULONG Length)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+ULONG
+NTAPI
+HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType,
+                      IN ULONG BusNumber,
+                      IN ULONG BusInterruptLevel,
+                      IN ULONG BusInterruptVector,
+                      OUT PKIRQL Irql,
+                      OUT PKAFFINITY Affinity)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+ULONG
+NTAPI
+HalSetBusData(IN BUS_DATA_TYPE BusDataType,
+              IN ULONG BusNumber,
+              IN ULONG SlotNumber,
+              IN PVOID Buffer,
+              IN ULONG Length)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+ULONG
+NTAPI
+HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType,
+                      IN ULONG BusNumber,
+                      IN ULONG SlotNumber,
+                      IN PVOID Buffer,
+                      IN ULONG Offset,
+                      IN ULONG Length)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOLEAN
+NTAPI
+HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType,
+                       IN ULONG BusNumber,
+                       IN PHYSICAL_ADDRESS BusAddress,
+                       IN OUT PULONG AddressSpace,
+                       OUT PPHYSICAL_ADDRESS TranslatedAddress)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return 0;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/cache.S b/reactos/hal/halarm/generic/cache.S
new file mode 100644 (file)
index 0000000..c4325a5
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            hal/halarm/generic/cache.s
+ * PURPOSE:         Implements cache clean, invalidate routines for ARM machines
+ * PROGRAMMERS:     Copyright (C) 2005 ARM Ltd.
+ */
+
+    .title "ARM HAL Cache Routines"
+    .include "ntoskrnl/include/internal/arm/kxarm.h"
+    .include "ntoskrnl/include/internal/arm/ksarm.h"
+
+    NESTED_ENTRY v7_flush_dcache_all
+    PROLOG_END v7_flush_dcache_all
+    
+       mrc     p15, 1, r0, c0, c0, 1           // read clidr
+       ands    r3, r0, #0x7000000              // extract loc from clidr
+       mov     r3, r3, lsr #23             // left align loc bit field
+       beq     finished                    // if loc is 0, then no need to clean
+       mov     r10, #0                     // start clean at cache level 0
+loop1:
+       add     r2, r10, r10, lsr #1            // work out 3x current cache level
+       mov     r1, r0, lsr r2              // extract cache type bits from clidr
+       and     r1, r1, #7                  // mask of the bits for current cache only
+       cmp     r1, #2                      // see what cache we have at this level
+       blt     skip                        // skip if no cache, or just i-cache
+       mcr     p15, 2, r10, c0, c0, 0          // select current cache level in cssr
+       isb                             // isb to sych the new cssr&csidr
+       mrc     p15, 1, r1, c0, c0, 0           // read the new csidr
+       and     r2, r1, #7                  // extract the length of the cache lines
+       add     r2, r2, #4                  // add 4 (line length offset)
+       ldr     r4, =0x3ff
+       ands    r4, r4, r1, lsr #3              // find maximum number on the way size
+       clz     r5, r4                      // find bit position of way size increment
+       ldr     r7, =0x7fff
+       ands    r7, r7, r1, lsr #13             // extract max number of the index size
+loop2:
+       mov     r9, r4                      // create working copy of max way size
+loop3:
+       orr     r11, r10, r9, lsl r5            // factor way and cache number into r11
+       orr     r11, r11, r7, lsl r2            // factor index number into r11
+       mcr     p15, 0, r11, c7, c14, 2         // clean & invalidate by set/way
+       subs    r9, r9, #1              // decrement the way
+       bge     loop3
+       subs    r7, r7, #1              // decrement the index
+       bge     loop2
+skip:
+       add     r10, r10, #2                // increment cache number
+       cmp     r3, r10
+       bgt     loop1
+finished:
+       mov     r10, #0                     // swith back to cache level 0
+       mcr     p15, 2, r10, c0, c0, 0          // select current cache level in cssr
+       isb
+       mov     pc, lr
+    
+    ENTRY_END v7_flush_dcache_all
diff --git a/reactos/hal/halarm/generic/display.c b/reactos/hal/halarm/generic/display.c
new file mode 100644 (file)
index 0000000..f21ca6d
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/display.c
+ * PURPOSE:         Screen Display Routines, now useless since NT 5.1+
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+#include <ndk/inbvfuncs.h>
+
+/* PUBLIC FUNCTIONS ***********************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
+{
+    /* Stub since Windows XP implemented Inbv */
+    return;
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalDisplayString(IN PCH String)
+{
+    /* Call the Inbv driver */
+    InbvDisplayString(String);
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalQueryDisplayParameters(OUT PULONG DispSizeX,
+                          OUT PULONG DispSizeY,
+                          OUT PULONG CursorPosX,
+                          OUT PULONG CursorPosY)
+{
+    /* Stub since Windows XP implemented Inbv */
+    return;
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalSetDisplayParameters(IN ULONG CursorPosX,
+                        IN ULONG CursorPosY)
+{
+    /* Stub since Windows XP implemented Inbv */
+    return;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/dma.c b/reactos/hal/halarm/generic/dma.c
new file mode 100644 (file)
index 0000000..3070f25
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/dma.c
+ * PURPOSE:         DMA Support
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* FUNCTIONS ******************************************************************/
+
+/*
+ * @unimplemented
+ */
+PADAPTER_OBJECT
+NTAPI
+HalGetAdapter(IN PDEVICE_DESCRIPTION DeviceDescription,
+              OUT PULONG NumberOfMapRegisters)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return NULL;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+HalPutDmaAdapter(IN PADAPTER_OBJECT AdapterObject)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+/*
+ * @unimplemented
+ */
+PVOID
+NTAPI
+HalAllocateCommonBuffer(IN PADAPTER_OBJECT AdapterObject,
+                        IN ULONG Length,
+                        IN PPHYSICAL_ADDRESS LogicalAddress,
+                        IN BOOLEAN CacheEnabled)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return NULL;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+HalFreeCommonBuffer(IN PADAPTER_OBJECT AdapterObject,
+                    IN ULONG Length,
+                    IN PHYSICAL_ADDRESS LogicalAddress,
+                    IN PVOID VirtualAddress,
+                    IN BOOLEAN CacheEnabled)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+/*
+ * @unimplemented
+ */
+ULONG
+NTAPI
+HalReadDmaCounter(IN PADAPTER_OBJECT AdapterObject)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+HalAllocateAdapterChannel(IN PADAPTER_OBJECT AdapterObject,
+                          IN PWAIT_CONTEXT_BLOCK WaitContextBlock,
+                          IN ULONG NumberOfMapRegisters,
+                          IN PDRIVER_CONTROL ExecutionRoutine)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return STATUS_SUCCESS;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+IoFreeAdapterChannel(IN PADAPTER_OBJECT AdapterObject)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+IoFreeMapRegisters(IN PADAPTER_OBJECT AdapterObject,
+                   IN PVOID MapRegisterBase,
+                   IN ULONG NumberOfMapRegisters)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+/*
+ * @unimplemented
+ */
+BOOLEAN
+NTAPI
+IoFlushAdapterBuffers(IN PADAPTER_OBJECT AdapterObject,
+                      IN PMDL Mdl,
+                      IN PVOID MapRegisterBase,
+                      IN PVOID CurrentVa,
+                      IN ULONG Length,
+                      IN BOOLEAN WriteToDevice)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+PHYSICAL_ADDRESS
+NTAPI
+IoMapTransfer(IN PADAPTER_OBJECT AdapterObject,
+              IN PMDL Mdl,
+              IN PVOID MapRegisterBase,
+              IN PVOID CurrentVa,
+              IN OUT PULONG Length,
+              IN BOOLEAN WriteToDevice)
+{
+    PHYSICAL_ADDRESS Address;
+
+    UNIMPLEMENTED;
+    while (TRUE);
+    
+    Address.QuadPart = 0;
+    return Address;
+}
+
+/*
+ * @unimplemented
+ */
+BOOLEAN
+NTAPI
+HalFlushCommonBuffer(IN PADAPTER_OBJECT AdapterObject,
+                     IN ULONG Length,
+                     IN PHYSICAL_ADDRESS LogicalAddress,
+                     IN PVOID VirtualAddress)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+PVOID
+NTAPI
+HalAllocateCrashDumpRegisters(IN PADAPTER_OBJECT AdapterObject,
+                              IN OUT PULONG NumberOfMapRegisters)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return NULL;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/drive.c b/reactos/hal/halarm/generic/drive.c
new file mode 100644 (file)
index 0000000..b1140bc
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/drive.c
+ * PURPOSE:         HAL Stubs for Disk I/O Routines
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* FUNCTIONS *****************************************************************/
+
+VOID
+NTAPI
+HalpAssignDriveLetters(IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
+                       IN PSTRING NtDeviceName,
+                       OUT PUCHAR NtSystemPath,
+                       OUT PSTRING NtSystemPathString)
+{
+    /* Call the kernel */
+    IoAssignDriveLetters(LoaderBlock,
+                         NtDeviceName,
+                         NtSystemPath,
+                         NtSystemPathString);
+}
+
+NTSTATUS
+NTAPI
+HalpReadPartitionTable(IN PDEVICE_OBJECT DeviceObject,
+                       IN ULONG SectorSize,
+                       IN BOOLEAN ReturnRecognizedPartitions,
+                       IN OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer)
+{
+    /* Call the kernel */
+    return IoReadPartitionTable(DeviceObject,
+                                SectorSize,
+                                ReturnRecognizedPartitions,
+                                PartitionBuffer);
+}
+
+NTSTATUS
+NTAPI
+HalpWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
+                        IN ULONG SectorSize,
+                        IN ULONG SectorsPerTrack,
+                        IN ULONG NumberOfHeads,
+                        IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer)
+{
+    /* Call the kernel */
+    return IoWritePartitionTable(DeviceObject,
+                                 SectorSize,
+                                 SectorsPerTrack,
+                                 NumberOfHeads,
+                                 PartitionBuffer);
+}
+
+NTSTATUS
+NTAPI
+HalpSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
+                            IN ULONG SectorSize,
+                            IN ULONG PartitionNumber,
+                            IN ULONG PartitionType)
+{
+    /* Call the kernel */
+    return IoSetPartitionInformation(DeviceObject,
+                                     SectorSize,
+                                     PartitionNumber,
+                                     PartitionType);
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/fmutex.c b/reactos/hal/halarm/generic/fmutex.c
new file mode 100644 (file)
index 0000000..1187288
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/fmutex.c
+ * PURPOSE:         Fast Mutex Support
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+#undef ExAcquireFastMutex
+#undef ExReleaseFastMutex
+#undef ExTryToAcquireFastMutex
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+FASTCALL
+ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+VOID
+FASTCALL
+ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+BOOLEAN
+FASTCALL
+ExTryToAcquireFastMutex(IN PFAST_MUTEX FastMutex)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return TRUE;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/generic.rbuild b/reactos/hal/halarm/generic/generic.rbuild
deleted file mode 100644 (file)
index 5f4ec64..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="halarm_generic" type="objectlibrary">
-       <include base="halarm_generic">../include</include>
-       <include base="ntoskrnl">include</include>
-       <define name="_NTHAL_" />
-       <file>hal.c</file>
-       <pch>../include/hal.h</pch>
-</module>
diff --git a/reactos/hal/halarm/generic/hal.c b/reactos/hal/halarm/generic/hal.c
deleted file mode 100644 (file)
index cd89ac1..0000000
+++ /dev/null
@@ -1,1540 +0,0 @@
-/*
- * PROJECT:         ReactOS HAL
- * LICENSE:         BSD - See COPYING.ARM in the top level directory
- * FILE:            hal/halarm/generic/hal.c
- * PURPOSE:         Hardware Abstraction Layer
- * PROGRAMMERS:     ReactOS Portable Systems Group
- */
-
-/* INCLUDES *******************************************************************/
-
-#include <hal.h>
-#define NDEBUG
-#include <debug.h>
-#include <ndk/inbvfuncs.h>
-
-#undef ExAcquireFastMutex
-#undef ExReleaseFastMutex
-#undef ExTryToAcquireFastMutex
-#undef KeAcquireSpinLock
-#undef KeLowerIrql
-#undef KeRaiseIrql
-#undef KeReleaseSpinLock
-
-#define READ_REGISTER_ULONG(r) (*((volatile ULONG * const)(r)))
-#define WRITE_REGISTER_ULONG(r, v) (*((volatile ULONG *)(r)) = (v))
-
-VOID
-FASTCALL
-KeUpdateSystemTime(
-    IN PKTRAP_FRAME TrapFrame,
-    IN ULONG Increment,
-    IN KIRQL OldIrql
-);
-
-/* DATA **********************************************************************/
-
-ULONG HalpCurrentTimeIncrement, HalpNextTimeIncrement, HalpNextIntervalCount;
-PUCHAR KdComPortInUse;
-
-ULONG HalpIrqlTable[HIGH_LEVEL + 1] =
-{
-    0xFFFFFFFF, // IRQL 0 PASSIVE_LEVEL
-    0xFFFFFFFD, // IRQL 1 APC_LEVEL
-    0xFFFFFFF9, // IRQL 2 DISPATCH_LEVEL
-    0xFFFFFFD9, // IRQL 3
-    0xFFFFFF99, // IRQL 4
-    0xFFFFFF19, // IRQL 5
-    0xFFFFFE19, // IRQL 6
-    0xFFFFFC19, // IRQL 7
-    0xFFFFF819, // IRQL 8
-    0xFFFFF019, // IRQL 9
-    0xFFFFE019, // IRQL 10
-    0xFFFFC019, // IRQL 11
-    0xFFFF8019, // IRQL 12
-    0xFFFF0019, // IRQL 13
-    0xFFFE0019, // IRQL 14
-    0xFFFC0019, // IRQL 15
-    0xFFF80019, // IRQL 16
-    0xFFF00019, // IRQL 17
-    0xFFE00019, // IRQL 18
-    0xFFC00019, // IRQL 19
-    0xFF800019, // IRQL 20
-    0xFF000019, // IRQL 21
-    0xFE000019, // IRQL 22
-    0xFC000019, // IRQL 23
-    0xF0000019, // IRQL 24
-    0x80000019, // IRQL 25
-    0x19,       // IRQL 26
-    0x18,       // IRQL 27 PROFILE_LEVEL
-    0x10,       // IRQL 28 CLOCK2_LEVEL
-    0x00,       // IRQL 29 IPI_LEVEL
-    0x00,       // IRQL 30 POWER_LEVEL
-    0x00,       // IRQL 31 HIGH_LEVEL
-};
-
-UCHAR HalpMaskTable[HIGH_LEVEL + 1] =
-{
-    PROFILE_LEVEL, // INT 0 WATCHDOG
-    APC_LEVEL,     // INT 1 SOFTWARE INTERRUPT
-    DISPATCH_LEVEL,// INT 2 COMM RX
-    IPI_LEVEL,     // INT 3 COMM TX
-    CLOCK2_LEVEL,  // INT 4 TIMER 0
-    3,
-    4,
-    5,
-    6,
-    7,
-    8,
-    9,
-    10,
-    11,
-    12,
-    13,
-    14,
-    15,
-    16,
-    17,
-    18,
-    19,
-    20,
-    21,
-    22,
-    23,
-    24,
-    25,
-    26,
-    26,
-    26
-};
-
-/* FUNCTIONS *****************************************************************/
-
-NTSTATUS
-NTAPI
-DriverEntry(
-  PDRIVER_OBJECT DriverObject,
-  PUNICODE_STRING RegistryPath)
-{
-  UNIMPLEMENTED;
-
-  return STATUS_SUCCESS;
-}
-
-/*
-* @unimplemented
-*/
-VOID
-NTAPI
-HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource)
-{
-    UNIMPLEMENTED;
-    return;
-}
-
-/*
-* @unimplemented
-*/
-VOID
-NTAPI
-HalStartProfileInterrupt(IN KPROFILE_SOURCE ProfileSource)
-{
-    UNIMPLEMENTED;
-    return;
-}
-
-/*
-* @unimplemented
-*/
-ULONG_PTR
-NTAPI
-HalSetProfileInterval(IN ULONG_PTR Interval)
-{
-    UNIMPLEMENTED;
-    return Interval;
-}
-
-VOID
-FASTCALL
-ExAcquireFastMutex(
-  PFAST_MUTEX FastMutex)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-FASTCALL
-ExReleaseFastMutex(
-  PFAST_MUTEX FastMutex)
-{
-  UNIMPLEMENTED;
-}
-
-
-BOOLEAN FASTCALL
-ExTryToAcquireFastMutex(
-  PFAST_MUTEX FastMutex)
-{
-  UNIMPLEMENTED;
-
-  return TRUE;
-}
-
-
-NTSTATUS
-NTAPI
-HalAdjustResourceList(
-  PCM_RESOURCE_LIST Resources)
-{
-  UNIMPLEMENTED;
-
-  return STATUS_SUCCESS;
-}
-
-
-/*
- * @implemented
- */
-BOOLEAN
-NTAPI
-HalAllProcessorsStarted(VOID)
-{
-    /* Do nothing */
-    return TRUE;
-}
-
-
-NTSTATUS
-NTAPI
-HalAllocateAdapterChannel(
-  PADAPTER_OBJECT AdapterObject,
-  PWAIT_CONTEXT_BLOCK WaitContextBlock,
-  ULONG NumberOfMapRegisters,
-  PDRIVER_CONTROL ExecutionRoutine)
-{
-  UNIMPLEMENTED;
-
-  return STATUS_SUCCESS;
-}
-
-
-PVOID
-NTAPI
-HalAllocateCommonBuffer(
-  PADAPTER_OBJECT AdapterObject,
-  ULONG Length,
-  PPHYSICAL_ADDRESS LogicalAddress,
-  BOOLEAN CacheEnabled)
-{
-  UNIMPLEMENTED;
-
-  return NULL;
-}
-
-
-PVOID
-NTAPI
-HalAllocateCrashDumpRegisters(
-  PADAPTER_OBJECT AdapterObject,
-  PULONG NumberOfMapRegisters)
-{
-  UNIMPLEMENTED;
-  return NULL;
-}
-
-
-NTSTATUS
-NTAPI
-HalAssignSlotResources(
-  PUNICODE_STRING RegistryPath,
-  PUNICODE_STRING DriverClassName,
-  PDRIVER_OBJECT DriverObject,
-  PDEVICE_OBJECT DeviceObject,
-  INTERFACE_TYPE BusType,
-  ULONG BusNumber,
-  ULONG SlotNumber,
-  PCM_RESOURCE_LIST *AllocatedResources)
-{
-  UNIMPLEMENTED;
-
-  return TRUE;
-}
-
-
-BOOLEAN
-NTAPI
-HalBeginSystemInterrupt(IN KIRQL Irql,
-                        IN UCHAR Vector,
-                        OUT PKIRQL OldIrql)
-{
-  UNIMPLEMENTED;
-
-  return TRUE;
-}
-
-
-VOID
-NTAPI
-HalCalibratePerformanceCounter(
-  volatile LONG *Count,
-  ULONGLONG NewCount)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-NTAPI
-HalDisableSystemInterrupt(IN UCHAR Vector,
-                          IN KIRQL Irql)
-{
-    UNIMPLEMENTED;
-}
-
-VOID
-NTAPI
-HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
-{
-    //
-    // Stub since Windows XP implemented Inbv
-    //
-    return;
-}
-
-VOID
-NTAPI
-HalDisplayString(IN PCH String)
-{
-    //
-    // Call the Inbv driver
-    //
-    InbvDisplayString(String);
-}
-
-VOID
-NTAPI
-HalQueryDisplayParameters(OUT PULONG DispSizeX,
-                          OUT PULONG DispSizeY,
-                          OUT PULONG CursorPosX,
-                          OUT PULONG CursorPosY)
-{
-    //
-    // Stub since Windows XP implemented Inbv
-    //
-    return;
-}
-
-VOID
-NTAPI
-HalSetDisplayParameters(IN ULONG CursorPosX,
-                        IN ULONG CursorPosY)
-{
-    //
-    // Stub since Windows XP implemented Inbv
-    //
-    return;
-}
-
-BOOLEAN
-NTAPI
-HalEnableSystemInterrupt(IN UCHAR Vector,
-                         IN KIRQL Irql,
-                         IN KINTERRUPT_MODE InterruptMode)
-{
-  UNIMPLEMENTED;
-
-  return TRUE;
-}
-
-
-VOID
-NTAPI
-HalEndSystemInterrupt(IN KIRQL OldIrql,
-                      IN PKTRAP_FRAME TrapFrame)
-{
-  UNIMPLEMENTED;
-}
-
-
-BOOLEAN
-NTAPI
-HalFlushCommonBuffer(
-  ULONG Unknown1,
-  ULONG Unknown2,
-  ULONG Unknown3,
-  ULONG Unknown4,
-  ULONG Unknown5)
-{
-  UNIMPLEMENTED;
-
-   return TRUE;
-}
-
-
-VOID
-NTAPI
-HalFreeCommonBuffer(
-  PADAPTER_OBJECT AdapterObject,
-  ULONG Length,
-  PHYSICAL_ADDRESS LogicalAddress,
-  PVOID VirtualAddress,
-  BOOLEAN CacheEnabled)
-{
-  UNIMPLEMENTED;
-}
-
-
-PADAPTER_OBJECT
-NTAPI
-HalGetAdapter(
-  PDEVICE_DESCRIPTION DeviceDescription,
-  PULONG NumberOfMapRegisters)
-{
-  UNIMPLEMENTED;
-
-  return (PADAPTER_OBJECT)NULL;
-}
-
-
-ULONG
-NTAPI
-HalGetBusData(
-  BUS_DATA_TYPE BusDataType,
-  ULONG BusNumber,
-  ULONG SlotNumber,
-  PVOID Buffer,
-  ULONG Length)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-ULONG
-NTAPI
-HalGetBusDataByOffset(
-  BUS_DATA_TYPE BusDataType,
-  ULONG BusNumber,
-  ULONG SlotNumber,
-  PVOID Buffer,
-  ULONG Offset,
-  ULONG Length)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-ARC_STATUS
-NTAPI
-HalGetEnvironmentVariable(
-  PCH Name,
-  USHORT ValueLength,
-  PCH Value)
-{
-  UNIMPLEMENTED;
-
-  return ENOENT;
-}
-
-
-ULONG
-NTAPI
-HalGetInterruptVector(
-  INTERFACE_TYPE InterfaceType,
-  ULONG BusNumber,
-  ULONG BusInterruptLevel,
-  ULONG BusInterruptVector,
-  PKIRQL Irql,
-  PKAFFINITY Affinity)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-VOID
-NTAPI
-HalHandleNMI(
-  PVOID NmiData)
-{
-  UNIMPLEMENTED;
-}
-
-VOID
-NTAPI
-HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
-{
-    PCHAR CommandLine;
-    
-    /* Make sure we have a loader block and command line */
-    if ((LoaderBlock) && (LoaderBlock->LoadOptions))
-    {
-        /* Read the command line */
-        CommandLine = LoaderBlock->LoadOptions;
-        
-        /* Check for initial breakpoint */
-        if (strstr(CommandLine, "BREAK")) DbgBreakPoint();
-    }
-}
-
-ULONG
-HalGetInterruptSource(VOID)
-{
-    ULONG InterruptStatus;
-    
-    //
-    // Get the interrupt status, and return the highest bit set
-    //
-    InterruptStatus = READ_REGISTER_ULONG(VIC_INT_STATUS);
-    return 31 - _clz(InterruptStatus);
-}
-
-VOID
-HalpClockInterrupt(VOID)
-{   
-    //
-    // Clear the interrupt
-    //
-    ASSERT(KeGetCurrentIrql() == CLOCK2_LEVEL);
-    WRITE_REGISTER_ULONG(TIMER0_INT_CLEAR, 1);
-    
-    //
-    // FIXME: Update HAL Perf counters
-    //
-    
-    //
-    // FIXME: Check if someone changed the clockrate
-    //
-    
-    //
-    // Call the kernel
-    //
-    KeUpdateSystemTime(KeGetCurrentThread()->TrapFrame,
-                       CLOCK2_LEVEL,
-                       HalpCurrentTimeIncrement);
-    
-    //
-    // We're done
-    //
-}
-
-VOID
-HalpStallInterrupt(VOID)
-{   
-    //
-    // Clear the interrupt
-    //
-    WRITE_REGISTER_ULONG(TIMER0_INT_CLEAR, 1);
-}
-
-VOID
-HalpInitializeInterrupts(VOID)
-{
-    PKPCR Pcr = (PKPCR)KeGetPcr();
-    ULONG ClockInterval;
-    SP804_CONTROL_REGISTER ControlRegister;
-    
-    //
-    // Fill out the IRQL mappings
-    //
-    RtlCopyMemory(Pcr->IrqlTable, HalpIrqlTable, sizeof(Pcr->IrqlTable));
-    RtlCopyMemory(Pcr->IrqlMask, HalpMaskTable, sizeof(Pcr->IrqlMask));
-    
-    //
-    // Setup the clock and profile interrupt
-    //
-    Pcr->InterruptRoutine[CLOCK2_LEVEL] = HalpStallInterrupt;
-    
-    //
-    // Configure the interval to 10ms
-    //  (INTERVAL (10ms) * TIMCLKfreq (1MHz))
-    // --------------------------------------- == 10^4
-    //  (TIMCLKENXdiv (1) * PRESCALEdiv (1))
-    //
-    ClockInterval = 0x2710;
-    
-    //
-    // Configure the timer
-    //
-    ControlRegister.AsUlong = 0;
-    ControlRegister.Wide = TRUE;
-    ControlRegister.Periodic = TRUE;
-    ControlRegister.Interrupt = TRUE;
-    ControlRegister.Enabled = TRUE;
-    
-    //
-    // Enable the timer
-    //
-    WRITE_REGISTER_ULONG(TIMER0_LOAD, ClockInterval);
-    WRITE_REGISTER_ULONG(TIMER0_CONTROL, ControlRegister.AsUlong);
-}
-
-/*
- * @implemented
- */
-BOOLEAN
-NTAPI
-HalInitSystem(IN ULONG BootPhase,
-              IN PLOADER_PARAMETER_BLOCK LoaderBlock)
-{
-    PKPRCB Prcb = KeGetCurrentPrcb();
-    
-    //
-    // Check the boot phase
-    //
-    if (!BootPhase)
-    {
-        //
-        // Get command-line parameters
-        //
-        HalpGetParameters(LoaderBlock);
-        
-#if DBG
-        //
-        // Checked HAL requires checked kernel
-        //
-        if (!(Prcb->BuildType & PRCB_BUILD_DEBUG))
-        {
-            //
-            // No match, bugcheck
-            //
-            KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0);
-        }
-#else
-        //
-        // Release build requires release HAL
-        //
-        if (Prcb->BuildType & PRCB_BUILD_DEBUG)
-        {
-            //
-            // No match, bugcheck
-            //
-            KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
-        }
-#endif
-        
-#ifdef CONFIG_SMP
-        //
-        // SMP HAL requires SMP kernel
-        //
-        if (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR)
-        {
-            //
-            // No match, bugcheck
-            //
-            KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
-        }
-#endif
-        
-        //
-        // Validate the PRCB
-        //
-        if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
-        {
-            //
-            // Validation failed, bugcheck
-            //
-            KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0);
-        }
-        
-        //
-        // Setup time increments to 10ms and 1ms
-        //
-        HalpCurrentTimeIncrement = 100000;
-        HalpNextTimeIncrement = 100000;
-        HalpNextIntervalCount = 0;
-        KeSetTimeIncrement(100000, 10000);
-        
-        //
-        // Initialize interrupts
-        //
-        HalpInitializeInterrupts();
-    }
-    else if (BootPhase == 1)
-    {
-        //
-        // Switch to real clock interrupt
-        //
-        PCR->InterruptRoutine[CLOCK2_LEVEL] = HalpClockInterrupt;
-    }
-    
-    //
-    // All done, return
-    //
-    return TRUE;
-}
-
-
-VOID
-NTAPI
-HalInitializeProcessor(IN ULONG ProcessorNumber,
-                       IN PLOADER_PARAMETER_BLOCK LoaderBlock)
-{
-    //
-    // Nothing to do
-    //
-    return;
-}
-
-
-BOOLEAN
-NTAPI
-HalMakeBeep(
-  ULONG Frequency)
-{
-  UNIMPLEMENTED;
-
-  return TRUE;
-}
-
-
-VOID
-NTAPI
-HalProcessorIdle(VOID)
-{
-  UNIMPLEMENTED;
-}
-
-
-#define RTC_DATA   (PVOID)0xE00E8000
-
-BOOLEAN
-NTAPI
-HalQueryRealTimeClock(IN PTIME_FIELDS Time)
-{
-    LARGE_INTEGER LargeTime;
-    ULONG Seconds;
-    
-    //
-    // Query the RTC value
-    //
-    Seconds = READ_REGISTER_ULONG(RTC_DATA);
-    
-    //
-    // Convert to time
-    //
-    RtlSecondsSince1970ToTime(Seconds, &LargeTime);
-    
-    //
-    // Convert to time-fields
-    //
-    RtlTimeToTimeFields(&LargeTime, Time);
-    return TRUE;
-}
-
-ULONG
-NTAPI
-HalReadDmaCounter(
-  PADAPTER_OBJECT AdapterObject)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-VOID
-NTAPI
-HalReportResourceUsage(VOID)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-NTAPI
-HalRequestIpi(
-  ULONG Unknown)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-FASTCALL
-HalRequestSoftwareInterrupt(IN KIRQL Request)
-{
-    //
-    // Force a software interrupt
-    //
-    WRITE_REGISTER_ULONG(VIC_SOFT_INT, 1 << Request);
-}
-
-VOID
-FASTCALL
-HalClearSoftwareInterrupt(IN KIRQL Request)
-{    
-    //
-    // Clear a software interrupt
-    //
-    WRITE_REGISTER_ULONG(VIC_SOFT_INT_CLEAR, 1 << Request);
-}
-
-VOID
-NTAPI
-HalReturnToFirmware(
-  FIRMWARE_REENTRY Action)
-{
-  UNIMPLEMENTED;
-}
-
-
-ULONG
-NTAPI
-HalSetBusData(
-  BUS_DATA_TYPE BusDataType,
-  ULONG BusNumber,
-  ULONG SlotNumber,
-  PVOID Buffer,
-  ULONG Length)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-ULONG
-NTAPI
-HalSetBusDataByOffset(
-  BUS_DATA_TYPE BusDataType,
-  ULONG BusNumber,
-  ULONG SlotNumber,
-  PVOID Buffer,
-  ULONG Offset,
-  ULONG Length)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-ARC_STATUS
-NTAPI
-HalSetEnvironmentVariable(
-  PCH Name,
-  PCH Value)
-{
-  UNIMPLEMENTED;
-
-  return ESUCCESS;
-}
-
-
-BOOLEAN
-NTAPI
-HalSetRealTimeClock(
-  PTIME_FIELDS Time)
-{
-  UNIMPLEMENTED;
-
-  return TRUE;
-}
-
-
-ULONG
-NTAPI
-HalSetTimeIncrement(
-  ULONG Increment)
-{
-  UNIMPLEMENTED;
-
-  return Increment;
-}
-
-
-BOOLEAN
-NTAPI
-HalStartNextProcessor(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
-                      IN PKPROCESSOR_STATE ProcessorState)
-{
-  UNIMPLEMENTED;
-
-  return TRUE;
-}
-
-
-UCHAR
-FASTCALL
-HalSystemVectorDispatchEntry(IN ULONG Vector,
-                             OUT PKINTERRUPT_ROUTINE **FlatDispatch,
-                             OUT PKINTERRUPT_ROUTINE *NoConnection)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-BOOLEAN
-NTAPI
-HalTranslateBusAddress(
-  INTERFACE_TYPE InterfaceType,
-  ULONG BusNumber,
-  PHYSICAL_ADDRESS BusAddress,
-  PULONG AddressSpace,
-  PPHYSICAL_ADDRESS TranslatedAddress)
-{
-  UNIMPLEMENTED;
-
-  return TRUE;
-}
-
-
-VOID
-NTAPI
-HalpAssignDriveLetters(IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
-                       IN PSTRING NtDeviceName,
-                       OUT PUCHAR NtSystemPath,
-                       OUT PSTRING NtSystemPathString)
-{
-    /* Call the kernel */
-    IoAssignDriveLetters(LoaderBlock,
-                                NtDeviceName,
-                                NtSystemPath,
-                                NtSystemPathString);
-}
-
-NTSTATUS
-NTAPI
-HalpReadPartitionTable(IN PDEVICE_OBJECT DeviceObject,
-                       IN ULONG SectorSize,
-                       IN BOOLEAN ReturnRecognizedPartitions,
-                       IN OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer)
-{
-    /* Call the kernel */
-    return IoReadPartitionTable(DeviceObject,
-                                SectorSize,
-                                ReturnRecognizedPartitions,
-                                PartitionBuffer);
-}
-
-NTSTATUS
-NTAPI
-HalpWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
-                        IN ULONG SectorSize,
-                        IN ULONG SectorsPerTrack,
-                        IN ULONG NumberOfHeads,
-                        IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer)
-{
-    /* Call the kernel */
-    return IoWritePartitionTable(DeviceObject,
-                                 SectorSize,
-                                 SectorsPerTrack,
-                                 NumberOfHeads,
-                                 PartitionBuffer);
-}
-
-NTSTATUS
-NTAPI
-HalpSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
-                            IN ULONG SectorSize,
-                            IN ULONG PartitionNumber,
-                            IN ULONG PartitionType)
-{
-    /* Call the kernel */
-    return IoSetPartitionInformation(DeviceObject,
-                                     SectorSize,
-                                     PartitionNumber,
-                                     PartitionType);
-}
-
-
-BOOLEAN
-NTAPI
-IoFlushAdapterBuffers(
-  PADAPTER_OBJECT AdapterObject,
-  PMDL Mdl,
-  PVOID MapRegisterBase,
-  PVOID CurrentVa,
-  ULONG Length,
-  BOOLEAN WriteToDevice)
-{
-  UNIMPLEMENTED;
-
-  return TRUE;
-}
-
-
-VOID
-NTAPI
-IoFreeAdapterChannel(
-  PADAPTER_OBJECT AdapterObject)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-NTAPI
-IoFreeMapRegisters(
-  PADAPTER_OBJECT AdapterObject,
-  PVOID MapRegisterBase,
-  ULONG NumberOfMapRegisters)
-{
-  UNIMPLEMENTED;
-}
-
-
-PHYSICAL_ADDRESS
-NTAPI
-IoMapTransfer(
-  PADAPTER_OBJECT AdapterObject,
-  PMDL Mdl,
-  PVOID MapRegisterBase,
-  PVOID CurrentVa,
-  PULONG Length,
-  BOOLEAN WriteToDevice)
-{
-  PHYSICAL_ADDRESS Address;
-
-  UNIMPLEMENTED;
-
-  Address.QuadPart = 0;
-
-  return Address;
-}
-
-VOID
-NTAPI
-KeFlushWriteBuffer(VOID)
-{
-  UNIMPLEMENTED;
-}
-
-LARGE_INTEGER
-NTAPI
-KeQueryPerformanceCounter(
-  PLARGE_INTEGER PerformanceFreq)
-{
-  LARGE_INTEGER Value;
-
-  UNIMPLEMENTED;
-
-  Value.QuadPart = 0;
-
-  return Value;
-}
-
-VOID
-NTAPI
-KeStallExecutionProcessor(IN ULONG Microseconds)
-{
-    SP804_CONTROL_REGISTER ControlRegister;
-    
-    //
-    // Enable the timer
-    //
-    WRITE_REGISTER_ULONG(TIMER1_LOAD, Microseconds);
-    
-    //
-    // Configure the timer
-    //
-    ControlRegister.AsUlong = 0;
-    ControlRegister.OneShot = TRUE;
-    ControlRegister.Wide = TRUE;
-    ControlRegister.Periodic = TRUE;
-    ControlRegister.Enabled = TRUE;
-    WRITE_REGISTER_ULONG(TIMER1_CONTROL, ControlRegister.AsUlong);
-    
-    //
-    // Now we will loop until the timer reached 0
-    //
-    while (READ_REGISTER_ULONG(TIMER1_VALUE));
-}
-
-VOID
-FASTCALL
-KfLowerIrql(IN KIRQL NewIrql)
-{
-    ULONG InterruptMask;
-    ARM_STATUS_REGISTER Flags;
-    PKPCR Pcr = (PKPCR)KeGetPcr();
-    
-    //
-    // Validate the new IRQL
-    //
-    Flags = KeArmStatusRegisterGet();
-    _disable();
-    ASSERT(NewIrql <= Pcr->CurrentIrql);
-    
-    //
-    // IRQLs are internally 8 bits
-    //
-    NewIrql &= 0xFF;
-    
-    //
-    // Setup the interrupt mask for this IRQL
-    //
-    InterruptMask = KeGetPcr()->IrqlTable[NewIrql];
-//    DPRINT1("[LOWER] IRQL: %d InterruptMask: %lx\n", NewIrql, InterruptMask);
-    
-    //
-    // Clear interrupts associated to the old IRQL
-    //
-    WRITE_REGISTER_ULONG(VIC_INT_CLEAR, 0xFFFFFFFF);
-    
-    //
-    // Set the new interrupt mask
-    // PL190 VIC support only for now
-    //
-    WRITE_REGISTER_ULONG(VIC_INT_ENABLE, InterruptMask);
-    
-    //
-    // Save the new IRQL
-    //
-    Pcr->CurrentIrql = NewIrql;
-    if (!Flags.IrqDisable) _enable();
-}
-
-KIRQL
-FASTCALL
-KfRaiseIrql(IN KIRQL NewIrql)
-{
-    KIRQL OldIrql;
-    ULONG InterruptMask;
-    ARM_STATUS_REGISTER Flags;
-    PKPCR Pcr = (PKPCR)KeGetPcr();
-    
-    //
-    // Save the current IRQL
-    //
-    Flags = KeArmStatusRegisterGet();
-    _disable();
-    OldIrql = Pcr->CurrentIrql;
-    
-    //
-    // IRQLs are internally 8 bits
-    //
-    NewIrql &= 0xFF;
-    
-    //
-    // Setup the interrupt mask for this IRQL
-    //
-    InterruptMask = KeGetPcr()->IrqlTable[NewIrql];
-  //  DPRINT1("[RAISE] IRQL: %d InterruptMask: %lx\n", NewIrql, InterruptMask);
-    ASSERT(NewIrql >= OldIrql);
-    
-    //
-    // Clear interrupts associated to the old IRQL
-    //
-    WRITE_REGISTER_ULONG(VIC_INT_CLEAR, 0xFFFFFFFF);
-    
-    //
-    // Set the new interrupt mask
-    // PL190 VIC support only for now
-    //
-    WRITE_REGISTER_ULONG(VIC_INT_ENABLE, InterruptMask);
-    
-    //
-    // Save the new IRQL
-    //
-    Pcr->CurrentIrql = NewIrql;
-    if (!Flags.IrqDisable) _enable();
-    return OldIrql;
-}
-
-VOID
-NTAPI
-READ_PORT_BUFFER_UCHAR(
-  PUCHAR Port,
-  PUCHAR Buffer,
-  ULONG Count)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-NTAPI
-READ_PORT_BUFFER_ULONG(
-  PULONG Port,
-  PULONG Buffer,
-  ULONG Count)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-NTAPI
-READ_PORT_BUFFER_USHORT(
-  PUSHORT Port,
-  PUSHORT Buffer,
-  ULONG Count)
-{
-  UNIMPLEMENTED;
-}
-
-
-UCHAR
-NTAPI
-READ_PORT_UCHAR(
-  PUCHAR Port)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-ULONG
-NTAPI
-READ_PORT_ULONG(
-  PULONG Port)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-USHORT
-NTAPI
-READ_PORT_USHORT(
-  PUSHORT Port)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
-
-VOID
-NTAPI
-WRITE_PORT_BUFFER_UCHAR(
-  PUCHAR Port,
-  PUCHAR Buffer,
-  ULONG Count)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-NTAPI
-WRITE_PORT_BUFFER_USHORT(
-  PUSHORT Port,
-  PUSHORT Buffer,
-  ULONG Count)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-NTAPI
-WRITE_PORT_BUFFER_ULONG(
-  PULONG Port,
-  PULONG Buffer,
-  ULONG Count)
-{
-  UNIMPLEMENTED;
-}
-
-
-VOID
-NTAPI
-WRITE_PORT_UCHAR(
-  PUCHAR Port,
-  UCHAR Value)
-{
-  UNIMPLEMENTED;
-}
-
-VOID
-NTAPI
-WRITE_PORT_ULONG(
-  PULONG Port,
-  ULONG Value)
-{
-  UNIMPLEMENTED;
-}
-
-VOID
-NTAPI
-WRITE_PORT_USHORT(
-  PUSHORT Port,
-  USHORT Value)
-{
-  UNIMPLEMENTED;
-}
-
-KIRQL
-KeRaiseIrqlToDpcLevel(VOID)
-{
-    //
-    // Call the generic routine
-    //
-    return KfRaiseIrql(DISPATCH_LEVEL);
-}
-
-KIRQL
-KeRaiseIrqlToSynchLevel(VOID)
-{
-    //
-    // Call the generic routine
-    //
-    return KfRaiseIrql(DISPATCH_LEVEL);
-}
-
-BOOLEAN HalpProcessorIdentified;
-BOOLEAN HalpTestCleanSupported;
-
-VOID
-HalpIdentifyProcessor(VOID)
-{
-    ARM_ID_CODE_REGISTER IdRegister;
-
-    //
-    // Don't do it again
-    //
-    HalpProcessorIdentified = TRUE;
-    
-    //
-    // Read the ID Code
-    //
-    IdRegister = KeArmIdCodeRegisterGet();
-    
-    //
-    // Architecture "6" CPUs support test-and-clean (926EJ-S and 1026EJ-S)
-    //
-    HalpTestCleanSupported = (IdRegister.Architecture == 6);
-}
-
-VOID
-HalSweepDcache(VOID)
-{
-    //
-    // We get called very early on, before HalInitSystem or any of the Hal*
-    // processor routines, so we need to figure out what CPU we're on.
-    //
-    if (!HalpProcessorIdentified) HalpIdentifyProcessor();
-    
-    //
-    // Check if we can do it the ARMv5TE-J way
-    //
-    if (HalpTestCleanSupported)
-    {
-        //
-        // Test, clean, flush D-Cache
-        //
-        __asm__ __volatile__ ("1: mrc p15, 0, pc, c7, c14, 3; bne 1b");
-    }
-    else
-    {
-        //
-        // We need to do it it by set/way
-        //
-        UNIMPLEMENTED;
-    }
-}
-
-VOID
-HalSweepIcache(VOID)
-{
-    //
-    // All ARM cores support the same Icache flush command, no need for HAL work
-    //
-    KeArmFlushIcache();
-}
-
-/*
- * @implemented
- */
-#undef KeGetCurrentIrql
-KIRQL
-NTAPI
-KeGetCurrentIrql(VOID)
-{
-    /* Return IRQL */
-    return PCR->CurrentIrql;
-}
-
-/*
- * @implemented
- */
-VOID
-NTAPI
-KeLowerIrql(KIRQL NewIrql)
-{
-    /* Call the fastcall function */
-    KfLowerIrql(NewIrql);
-}
-
-/*
- * @implemented
- */
-VOID
-NTAPI
-KeRaiseIrql(KIRQL NewIrql,
-            PKIRQL OldIrql)
-{
-    /* Call the fastcall function */
-    *OldIrql = KfRaiseIrql(NewIrql);
-}
-
-/*
- * @implemented
- */
-VOID
-NTAPI
-KeAcquireSpinLock(PKSPIN_LOCK SpinLock,
-                  PKIRQL OldIrql)
-{
-    /* Call the fastcall function */
-    *OldIrql = KfAcquireSpinLock(SpinLock);
-}
-
-/*
- * @implemented
- */
-KIRQL
-FASTCALL
-KeAcquireSpinLockRaiseToSynch(PKSPIN_LOCK SpinLock)
-{
-    /* Simply raise to dispatch */
-    return KfRaiseIrql(DISPATCH_LEVEL);
-}
-
-/*
- * @implemented
- */
-VOID
-NTAPI
-KeReleaseSpinLock(PKSPIN_LOCK SpinLock,
-                  KIRQL NewIrql)
-{
-    /* Call the fastcall function */
-    KfReleaseSpinLock(SpinLock, NewIrql);
-}
-
-/*
- * @implemented
- */
-KIRQL
-FASTCALL
-KfAcquireSpinLock(PKSPIN_LOCK SpinLock)
-{
-    /* Simply raise to dispatch */
-    return KfRaiseIrql(DISPATCH_LEVEL);
-}
-
-/*
- * @implemented
- */
-VOID
-FASTCALL
-KfReleaseSpinLock(PKSPIN_LOCK SpinLock,
-                  KIRQL OldIrql)
-{
-    /* Simply lower IRQL back */
-    KfLowerIrql(OldIrql);
-}
-
-/*
- * @implemented
- */
-KIRQL
-FASTCALL
-KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
-{
-    /* Simply raise to dispatch */
-    return KfRaiseIrql(DISPATCH_LEVEL);
-}
-
-/*
- * @implemented
- */
-KIRQL
-FASTCALL
-KeAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
-{
-    /* Simply raise to dispatch */
-    return KfRaiseIrql(DISPATCH_LEVEL);
-}
-
-/*
- * @implemented
- */
-VOID
-FASTCALL
-KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock,
-                               IN PKLOCK_QUEUE_HANDLE LockHandle)
-{
-    /* Simply raise to dispatch */
-    LockHandle->OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
-}
-
-/*
- * @implemented
- */
-VOID
-FASTCALL
-KeAcquireInStackQueuedSpinLockRaiseToSynch(IN PKSPIN_LOCK SpinLock,
-                                           IN PKLOCK_QUEUE_HANDLE LockHandle)
-{
-    /* Simply raise to synch */
-    LockHandle->OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
-}
-
-/*
- * @implemented
- */
-VOID
-FASTCALL
-KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
-                        IN KIRQL OldIrql)
-{
-    /* Simply lower IRQL back */
-    KfLowerIrql(OldIrql);
-}
-
-/*
- * @implemented
- */
-VOID
-FASTCALL
-KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
-{
-    /* Simply lower IRQL back */
-    KfLowerIrql(LockHandle->OldIrql);
-}
-
-/*
- * @implemented
- */
-BOOLEAN
-FASTCALL
-KeTryToAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
-                                         IN PKIRQL OldIrql)
-{
-    /* Simply raise to dispatch */
-    *OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
-    
-    /* Always return true on UP Machines */
-    return TRUE;
-}
-
-/*
- * @implemented
- */
-LOGICAL
-FASTCALL
-KeTryToAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
-                             OUT PKIRQL OldIrql)
-{
-    /* Simply raise to dispatch */
-    *OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
-    
-    /* Always return true on UP Machines */
-    return TRUE;
-}
-
-/* EOF */
diff --git a/reactos/hal/halarm/generic/halinit.c b/reactos/hal/halarm/generic/halinit.c
new file mode 100644 (file)
index 0000000..6f63dc9
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/halinit.c
+ * PURPOSE:         HAL Entrypoint and Initialization
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+VOID
+NTAPI
+HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+    PCHAR CommandLine;
+
+    /* Make sure we have a loader block and command line */
+    if ((LoaderBlock) && (LoaderBlock->LoadOptions))
+    {
+        /* Read the command line */
+        CommandLine = LoaderBlock->LoadOptions;
+
+        /* Check for initial breakpoint */
+        if (strstr(CommandLine, "BREAK")) DbgBreakPoint();
+    }
+}
+
+/* FUNCTIONS ******************************************************************/
+
+/*
+ * @implemented
+ */
+BOOLEAN
+NTAPI
+HalInitSystem(IN ULONG BootPhase,
+              IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+    PKPRCB Prcb = KeGetCurrentPrcb();
+
+    /* Check the boot phase */
+    if (!BootPhase)
+    {
+        /* Get command-line parameters */
+        HalpGetParameters(LoaderBlock);
+
+        /* Checked HAL requires checked kernel */
+#if DBG
+        if (!(Prcb->BuildType & PRCB_BUILD_DEBUG))
+        {
+            /* No match, bugcheck */
+            KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0);
+        }
+#else
+        /* Release build requires release HAL */
+        if (Prcb->BuildType & PRCB_BUILD_DEBUG)
+        {
+            /* No match, bugcheck */
+            KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
+        }
+#endif
+
+#ifdef CONFIG_SMP
+        /* SMP HAL requires SMP kernel */
+        if (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR)
+        {
+            /* No match, bugcheck */
+            KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
+        }
+#endif
+
+        /* Validate the PRCB */
+        if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
+        {
+            /* Validation failed, bugcheck */
+            KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0);
+        }
+        
+        /* Initialize interrupts */
+        HalpInitializeInterrupts();
+
+        /* Force initial PIC state */
+        KfRaiseIrql(KeGetCurrentIrql());
+
+        /* Fill out the dispatch tables */
+        //HalQuerySystemInformation = NULL; // FIXME: TODO;
+        //HalSetSystemInformation = NULL; // FIXME: TODO;
+        //HalInitPnpDriver = NULL; // FIXME: TODO
+        //HalGetDmaAdapter = NULL; // FIXME: TODO;
+        //HalGetInterruptTranslator = NULL;  // FIXME: TODO
+        //HalResetDisplay = NULL; // FIXME: TODO;
+        //HalHaltSystem = NULL; // FIXME: TODO;
+
+        /* Setup I/O space */
+        //HalpDefaultIoSpace.Next = HalpAddressUsageList;
+        //HalpAddressUsageList = &HalpDefaultIoSpace;
+
+        /* Setup busy waiting */
+        //HalpCalibrateStallExecution();
+
+        /* Initialize the clock */
+        HalpInitializeClock();
+
+        /* Setup time increments to 10ms and 1ms */
+        HalpCurrentTimeIncrement = 100000;
+        HalpNextTimeIncrement = 100000;
+        HalpNextIntervalCount = 0;
+        KeSetTimeIncrement(100000, 10000);
+
+        /*
+         * We could be rebooting with a pending profile interrupt,
+         * so clear it here before interrupts are enabled
+         */
+        HalStopProfileInterrupt(ProfileTime);
+
+        /* Do some HAL-specific initialization */
+        HalpInitPhase0(LoaderBlock);
+    }
+    else if (BootPhase == 1)
+    {
+        /* Enable timer interrupt */
+        HalpEnableInterruptHandler(IDT_DEVICE,
+                                   0,
+                                   PRIMARY_VECTOR_BASE,
+                                   CLOCK2_LEVEL,
+                                   HalpClockInterrupt,
+                                   Latched);
+#if 0
+        /* Enable IRQ 8 */
+        HalpEnableInterruptHandler(IDT_DEVICE,
+                                   0,
+                                   PRIMARY_VECTOR_BASE + 8,
+                                   PROFILE_LEVEL,
+                                   HalpProfileInterrupt,
+                                   Latched);
+#endif
+        /* Initialize DMA. NT does this in Phase 0 */
+        //HalpInitDma();
+
+        /* Do some HAL-specific initialization */
+        HalpInitPhase1();
+    }
+
+    /* All done, return */
+    return TRUE;
+}
+
+#include <internal/kd.h>
+ULONG
+DbgPrintEarly(const char *fmt, ...)
+{
+    va_list args;
+    unsigned int i;
+    char Buffer[1024];
+    PCHAR String = Buffer;
+
+    va_start(args, fmt);
+    i = vsprintf(Buffer, fmt, args);
+    va_end(args);
+    
+    /* Output the message */
+    while (*String != 0)
+    {
+        if (*String == '\n')
+        {
+            KdPortPutByteEx(NULL, '\r');
+        }
+        KdPortPutByteEx(NULL, *String);
+        String++;
+    }
+    
+    return STATUS_SUCCESS;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/misc.c b/reactos/hal/halarm/generic/misc.c
new file mode 100644 (file)
index 0000000..86fbe76
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * PROJECT:         ReactOS Hardware Abstraction Layer (HAL)
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/misc.c
+ * PURPOSE:         Misc functions to move
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS  *******************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/*
+ * @implemented
+ */
+UCHAR
+FASTCALL
+HalSystemVectorDispatchEntry(IN ULONG Vector,
+                             OUT PKINTERRUPT_ROUTINE **FlatDispatch,
+                             OUT PKINTERRUPT_ROUTINE *NoConnection)
+{
+    /* Not implemented */
+    UNIMPLEMENTED;
+    while (TRUE);
+    return 0;
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeFlushWriteBuffer(VOID)
+{
+    /* Not implemented */
+    UNIMPLEMENTED;
+    while (TRUE);
+    return;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/pic.c b/reactos/hal/halarm/generic/pic.c
new file mode 100644 (file)
index 0000000..5be8c3f
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/pic.c
+ * PURPOSE:         HAL PIC Management and Control Code
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+#undef KeGetCurrentIrql
+
+/* GLOBALS ********************************************************************/
+
+ULONG HalpIrqlTable[HIGH_LEVEL + 1] =
+{
+    0xFFFFFFFF, // IRQL 0 PASSIVE_LEVEL
+    0xFFFFFFFD, // IRQL 1 APC_LEVEL
+    0xFFFFFFF9, // IRQL 2 DISPATCH_LEVEL
+    0xFFFFFFD9, // IRQL 3
+    0xFFFFFF99, // IRQL 4
+    0xFFFFFF19, // IRQL 5
+    0xFFFFFE19, // IRQL 6
+    0xFFFFFC19, // IRQL 7
+    0xFFFFF819, // IRQL 8
+    0xFFFFF019, // IRQL 9
+    0xFFFFE019, // IRQL 10
+    0xFFFFC019, // IRQL 11
+    0xFFFF8019, // IRQL 12
+    0xFFFF0019, // IRQL 13
+    0xFFFE0019, // IRQL 14
+    0xFFFC0019, // IRQL 15
+    0xFFF80019, // IRQL 16
+    0xFFF00019, // IRQL 17
+    0xFFE00019, // IRQL 18
+    0xFFC00019, // IRQL 19
+    0xFF800019, // IRQL 20
+    0xFF000019, // IRQL 21
+    0xFE000019, // IRQL 22
+    0xFC000019, // IRQL 23
+    0xF0000019, // IRQL 24
+    0x80000019, // IRQL 25
+    0x19,       // IRQL 26
+    0x18,       // IRQL 27 PROFILE_LEVEL
+    0x10,       // IRQL 28 CLOCK2_LEVEL
+    0x00,       // IRQL 29 IPI_LEVEL
+    0x00,       // IRQL 30 POWER_LEVEL
+    0x00,       // IRQL 31 HIGH_LEVEL
+};
+
+UCHAR HalpMaskTable[HIGH_LEVEL + 1] =
+{
+    PROFILE_LEVEL, // INT 0 WATCHDOG
+    APC_LEVEL,     // INT 1 SOFTWARE INTERRUPT
+    DISPATCH_LEVEL,// INT 2 COMM RX
+    IPI_LEVEL,     // INT 3 COMM TX
+    CLOCK2_LEVEL,  // INT 4 TIMER 0
+    3,
+    4,
+    5,
+    6,
+    7,
+    8,
+    9,
+    10,
+    11,
+    12,
+    13,
+    14,
+    15,
+    16,
+    17,
+    18,
+    19,
+    20,
+    21,
+    22,
+    23,
+    24,
+    25,
+    26,
+    26,
+    26
+};
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+HalpInitializeInterrupts(VOID)
+{
+    PKIPCR Pcr = (PKIPCR)KeGetPcr();
+
+    /* Fill out the IRQL mappings */
+    RtlCopyMemory(Pcr->IrqlTable, HalpIrqlTable, sizeof(Pcr->IrqlTable));
+    RtlCopyMemory(Pcr->IrqlMask, HalpMaskTable, sizeof(Pcr->IrqlMask));
+}
+    
+/* IRQL MANAGEMENT ************************************************************/
+
+/*
+ * @implemented
+ */
+ULONG
+HalGetInterruptSource(VOID)
+{
+    ULONG InterruptStatus;
+    
+    /* Get the interrupt status, and return the highest bit set */
+    InterruptStatus = READ_REGISTER_ULONG(VIC_INT_STATUS);
+    return 31 - _clz(InterruptStatus);
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+NTAPI
+KeGetCurrentIrql(VOID)
+{
+    /* Return the IRQL */
+    return KeGetPcr()->Irql;
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+NTAPI
+KeRaiseIrqlToDpcLevel(VOID)
+{
+    PKPCR Pcr = KeGetPcr();
+    KIRQL CurrentIrql;
+    
+    /* Save and update IRQL */
+    CurrentIrql = Pcr->Irql;
+    Pcr->Irql = DISPATCH_LEVEL;
+    
+#ifdef IRQL_DEBUG
+    /* Validate correct raise */
+    if (CurrentIrql > DISPATCH_LEVEL) KeBugCheck(IRQL_NOT_GREATER_OR_EQUAL);
+#endif
+
+    /* Return the previous value */
+    return CurrentIrql;
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+NTAPI
+KeRaiseIrqlToSynchLevel(VOID)
+{
+    PKPCR Pcr = KeGetPcr();
+    KIRQL CurrentIrql;
+    
+    /* Save and update IRQL */
+    CurrentIrql = Pcr->Irql;
+    Pcr->Irql = SYNCH_LEVEL;
+    
+#ifdef IRQL_DEBUG
+    /* Validate correct raise */
+    if (CurrentIrql > SYNCH_LEVEL)
+    {
+        /* Crash system */
+        KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
+                     CurrentIrql,
+                     SYNCH_LEVEL,
+                     0,
+                     1);
+    }
+#endif
+
+    /* Return the previous value */
+    return CurrentIrql;
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+FASTCALL
+KfRaiseIrql(IN KIRQL NewIrql)
+{
+    ARM_STATUS_REGISTER Flags;
+    PKIPCR Pcr = (PKIPCR)KeGetPcr();
+    KIRQL CurrentIrql;
+    ULONG InterruptMask;
+    
+    /* Disable interrupts */
+    Flags = KeArmStatusRegisterGet();
+    _disable();
+
+    /* Read current IRQL */
+    CurrentIrql = Pcr->Irql;
+    
+#ifdef IRQL_DEBUG
+    /* Validate correct raise */
+    if (CurrentIrql > NewIrql)
+    {
+        /* Crash system */
+        Pcr->Irql = PASSIVE_LEVEL;
+        KeBugCheck(IRQL_NOT_GREATER_OR_EQUAL);
+    }
+#endif
+    /* Clear interrupts associated to the old IRQL */
+    WRITE_REGISTER_ULONG(VIC_INT_CLEAR, 0xFFFFFFFF);
+    
+    /* Set the new interrupt mask */
+    InterruptMask = Pcr->IrqlTable[NewIrql];
+    WRITE_REGISTER_ULONG(VIC_INT_ENABLE, InterruptMask);
+
+    /* Set new IRQL */
+    Pcr->Irql = NewIrql;
+    
+    /* Restore interrupt state */
+    if (!Flags.IrqDisable) _enable();
+    
+    /* Return old IRQL */
+    return CurrentIrql;
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KfLowerIrql(IN KIRQL NewIrql)
+{
+    ARM_STATUS_REGISTER Flags;
+    PKIPCR Pcr = (PKIPCR)KeGetPcr();
+    ULONG InterruptMask;
+    
+    /* Disableinterrupts */
+    Flags = KeArmStatusRegisterGet();
+    _disable();    
+    
+#ifdef IRQL_DEBUG
+    /* Validate correct lower */
+    if (OldIrql > Pcr->Irql)
+    {
+        /* Crash system */
+        Pcr->Irql = HIGH_LEVEL;
+        KeBugCheck(IRQL_NOT_LESS_OR_EQUAL);
+    }
+#endif
+
+    /* Clear interrupts associated to the old IRQL */
+    WRITE_REGISTER_ULONG(VIC_INT_CLEAR, 0xFFFFFFFF);
+    
+    /* Set the new interrupt mask */
+    InterruptMask = Pcr->IrqlTable[NewIrql];
+    WRITE_REGISTER_ULONG(VIC_INT_ENABLE, InterruptMask);
+    
+    /* Save the new IRQL and restore interrupt state */
+    Pcr->Irql = NewIrql;
+    if (!Flags.IrqDisable) _enable();
+}
+
+/* SOFTWARE INTERRUPTS ********************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+HalRequestSoftwareInterrupt(IN KIRQL Irql)
+{
+    /* Force a software interrupt */
+    WRITE_REGISTER_ULONG(VIC_SOFT_INT, 1 << Irql);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+HalClearSoftwareInterrupt(IN KIRQL Irql)
+{
+    /* Clear software interrupt */
+    WRITE_REGISTER_ULONG(VIC_SOFT_INT_CLEAR, 1 << Irql);
+}
+
+/* SYSTEM INTERRUPTS **********************************************************/
+
+/*
+ * @implemented
+ */
+BOOLEAN
+NTAPI
+HalEnableSystemInterrupt(IN UCHAR Vector,
+                         IN KIRQL Irql,
+                         IN KINTERRUPT_MODE InterruptMode)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return FALSE;
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalDisableSystemInterrupt(IN UCHAR Vector,
+                          IN KIRQL Irql)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN
+NTAPI
+HalBeginSystemInterrupt(IN KIRQL Irql,
+                        IN UCHAR Vector,
+                        OUT PKIRQL OldIrql)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return FALSE;
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalEndSystemInterrupt(IN KIRQL OldIrql,
+                      IN PKTRAP_FRAME TrapFrame)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/portio.c b/reactos/hal/halarm/generic/portio.c
new file mode 100644 (file)
index 0000000..91786b4
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/portio.c
+ * PURPOSE:         I/O Functions for access to ports
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+#undef READ_PORT_UCHAR
+#undef READ_PORT_USHORT
+#undef READ_PORT_ULONG
+#undef WRITE_PORT_UCHAR
+#undef WRITE_PORT_USHORT
+#undef WRITE_PORT_ULONG
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+READ_PORT_BUFFER_UCHAR(IN PUCHAR Port,
+                       OUT PUCHAR Buffer,
+                       IN ULONG Count)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+VOID
+NTAPI
+READ_PORT_BUFFER_USHORT(IN PUSHORT Port,
+                        OUT PUSHORT Buffer,
+                        IN ULONG Count)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+VOID
+NTAPI
+READ_PORT_BUFFER_ULONG(IN PULONG Port,
+                       OUT PULONG Buffer,
+                       IN ULONG Count)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+UCHAR
+NTAPI
+READ_PORT_UCHAR(IN PUCHAR Port)
+{
+    return READ_REGISTER_UCHAR(Port);
+}
+
+USHORT
+NTAPI
+READ_PORT_USHORT(IN PUSHORT Port)
+{
+    return READ_REGISTER_USHORT(Port);
+}
+
+ULONG
+NTAPI
+READ_PORT_ULONG(IN PULONG Port)
+{
+    return READ_REGISTER_ULONG(Port);
+}
+
+VOID
+NTAPI
+WRITE_PORT_BUFFER_UCHAR(IN PUCHAR Port,
+                        IN PUCHAR Buffer,
+                        IN ULONG Count)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+VOID
+NTAPI
+WRITE_PORT_BUFFER_USHORT(IN PUSHORT Port,
+                         IN PUSHORT Buffer,
+                         IN ULONG Count)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+VOID
+NTAPI
+WRITE_PORT_BUFFER_ULONG(IN PULONG Port,
+                        IN PULONG Buffer,
+                        IN ULONG Count)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+VOID
+NTAPI
+WRITE_PORT_UCHAR(IN PUCHAR Port,
+                 IN UCHAR Value)
+{
+    WRITE_REGISTER_UCHAR(Port, Value);
+}
+
+VOID
+NTAPI
+WRITE_PORT_USHORT(IN PUSHORT Port,
+                  IN USHORT Value)
+{
+    WRITE_REGISTER_USHORT(Port, Value);
+}
+
+VOID
+NTAPI
+WRITE_PORT_ULONG(IN PULONG Port,
+                 IN ULONG Value)
+{
+    WRITE_REGISTER_ULONG(Port, Value);
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/processor.c b/reactos/hal/halarm/generic/processor.c
new file mode 100644 (file)
index 0000000..b52ef5c
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/processor.c
+ * PURPOSE:         HAL Processor Routines
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+LONG HalpActiveProcessors;
+KAFFINITY HalpDefaultInterruptAffinity;
+BOOLEAN HalpProcessorIdentified;
+BOOLEAN HalpTestCleanSupported;
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+VOID
+HalpIdentifyProcessor(VOID)
+{
+    ARM_ID_CODE_REGISTER IdRegister;
+
+    /* Don't do it again */
+    HalpProcessorIdentified = TRUE;
+    
+    // fixfix: Use Pcr->ProcessorId
+    
+    /* Read the ID Code */
+    IdRegister = KeArmIdCodeRegisterGet();
+    
+    /* Architecture "6" CPUs support test-and-clean (926EJ-S and 1026EJ-S) */
+    HalpTestCleanSupported = (IdRegister.Architecture == 6);
+}
+
+/* FUNCTIONS ******************************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalInitializeProcessor(IN ULONG ProcessorNumber,
+                       IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+    /* Do nothing */
+    return;
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN
+NTAPI
+HalAllProcessorsStarted(VOID)
+{
+    /* Do nothing */
+    return TRUE;
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN
+NTAPI
+HalStartNextProcessor(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+                      IN PKPROCESSOR_STATE ProcessorState)
+{
+    /* Ready to start */
+    return FALSE;
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalProcessorIdle(VOID)
+{
+    /* Enable interrupts and halt the processor */
+    _enable();
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalRequestIpi(KAFFINITY TargetProcessors)
+{
+    /* Not implemented on UP */
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+/*
+ * @implemented
+ */
+VOID
+HalSweepDcache(VOID)
+{
+    /*
+     * We get called very early on, before HalInitSystem or any of the Hal*
+     * processor routines, so we need to figure out what CPU we're on.
+     */
+    if (!HalpProcessorIdentified) HalpIdentifyProcessor();
+    
+    /*
+     * Check if we can do it the ARMv5TE-J way
+     */
+    if (HalpTestCleanSupported)
+    {
+        /* Test, clean, flush D-Cache */
+        __asm__ __volatile__ ("1: mrc p15, 0, pc, c7, c14, 3; bne 1b");
+    }
+    else
+    {
+        /* We need to do it it by set/way. For now always call ARMv7 function */
+        //extern VOID v7_flush_dcache_all(VOID);
+        //v7_flush_dcache_all();
+    }
+}
+
+/*
+ * @implemented
+ */
+VOID
+HalSweepIcache(VOID)
+{
+    /* All ARM cores support the same Icache flush command */
+    KeArmFlushIcache();
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/profil.c b/reactos/hal/halarm/generic/profil.c
new file mode 100644 (file)
index 0000000..44f9e6f
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/profil.c
+ * PURPOSE:         System Profiling
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* FUNCTIONS ******************************************************************/
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource)
+{
+    UNIMPLEMENTED;
+    return;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+HalStartProfileInterrupt(IN KPROFILE_SOURCE ProfileSource)
+{
+    UNIMPLEMENTED;
+    return;
+}
+
+/*
+ * @unimplemented
+ */
+ULONG_PTR
+NTAPI
+HalSetProfileInterval(IN ULONG_PTR Interval)
+{
+    UNIMPLEMENTED;
+    return Interval;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/reboot.c b/reactos/hal/halarm/generic/reboot.c
new file mode 100644 (file)
index 0000000..51de486
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/reboot.c
+ * PURPOSE:         Reboot Function
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* PUBLIC FUNCTIONS **********************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
+{
+    /* Check what kind of action this is */
+    switch (Action)
+    {
+        /* All recognized actions */
+        case HalHaltRoutine:
+        case HalRebootRoutine:
+
+            /* Acquire the display */
+            InbvAcquireDisplayOwnership();
+
+        /* Anything else */
+        default:
+
+            /* Print message and break */
+            DbgPrint("HalReturnToFirmware called!\n");
+            DbgBreakPoint();
+    }
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/rtc.c b/reactos/hal/halarm/generic/rtc.c
new file mode 100644 (file)
index 0000000..e2fe11e
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/rtc.c
+ * PURPOSE:         Real Time Clock and Environment Variable Support
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* FUNCTIONS ******************************************************************/
+
+#define RTC_DATA   (PVOID)0x101E8000
+
+/*
+ * @implemented
+ */
+BOOLEAN
+NTAPI
+HalQueryRealTimeClock(IN PTIME_FIELDS Time)
+{
+    LARGE_INTEGER LargeTime;
+    ULONG Seconds;
+    
+    /* Query the RTC value */
+    Seconds = READ_REGISTER_ULONG(RTC_DATA);
+    
+    /* Convert to time */
+    RtlSecondsSince1970ToTime(Seconds, &LargeTime);
+    
+    /* Convert to time-fields */
+    RtlTimeToTimeFields(&LargeTime, Time);
+    return TRUE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOLEAN
+NTAPI
+HalSetRealTimeClock(IN PTIME_FIELDS Time)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return TRUE;
+}
+
+/*
+ * @unimplemented
+ */
+ARC_STATUS
+NTAPI
+HalSetEnvironmentVariable(IN PCH Name,
+                          IN PCH Value)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return ESUCCESS;
+}
+
+/*
+ * @unimplemented
+ */
+ARC_STATUS
+NTAPI
+HalGetEnvironmentVariable(IN PCH Name,
+                          IN USHORT ValueLength,
+                          IN PCH Value)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return ENOENT;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/spinlock.c b/reactos/hal/halarm/generic/spinlock.c
new file mode 100644 (file)
index 0000000..ff53749
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/spinlock.c
+ * PURPOSE:         SpinLock Routines
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+/* INCLUDES ******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+#undef KeAcquireSpinLock
+#undef KeReleaseSpinLock
+#undef KeRaiseIrql
+#undef KeLowerIrql
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeRaiseIrql(KIRQL NewIrql,
+            PKIRQL OldIrql)
+{
+    /* Call the fastcall function */
+    *OldIrql = KfRaiseIrql(NewIrql);
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeLowerIrql(KIRQL NewIrql)
+{
+    /* Call the fastcall function */
+    KfLowerIrql(NewIrql);
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeAcquireSpinLock(PKSPIN_LOCK SpinLock,
+                  PKIRQL OldIrql)
+{
+    /* Call the fastcall function */
+    *OldIrql = KfAcquireSpinLock(SpinLock);
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+FASTCALL
+KeAcquireSpinLockRaiseToSynch(PKSPIN_LOCK SpinLock)
+{
+    /* Simply raise to dispatch */
+    return KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeReleaseSpinLock(PKSPIN_LOCK SpinLock,
+                  KIRQL NewIrql)
+{
+    /* Call the fastcall function */
+    KfReleaseSpinLock(SpinLock, NewIrql);
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+FASTCALL
+KfAcquireSpinLock(PKSPIN_LOCK SpinLock)
+{
+    /* Simply raise to dispatch */
+    return KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KfReleaseSpinLock(PKSPIN_LOCK SpinLock,
+                  KIRQL OldIrql)
+{
+    /* Simply lower IRQL back */
+    KeLowerIrql(OldIrql);
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+FASTCALL
+KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
+{
+    /* Simply raise to dispatch */
+    return KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+FASTCALL
+KeAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
+{
+    /* Simply raise to dispatch */
+    return KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock,
+                               IN PKLOCK_QUEUE_HANDLE LockHandle)
+{
+    /* Simply raise to dispatch */
+    LockHandle->OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLockRaiseToSynch(IN PKSPIN_LOCK SpinLock,
+                                           IN PKLOCK_QUEUE_HANDLE LockHandle)
+{
+    /* Simply raise to dispatch */
+    LockHandle->OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
+                        IN KIRQL OldIrql)
+{
+    /* Simply lower IRQL back */
+    KfLowerIrql(OldIrql);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
+{
+    /* Simply lower IRQL back */
+    KfLowerIrql(LockHandle->OldIrql);
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN
+FASTCALL
+KeTryToAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
+                                         IN PKIRQL OldIrql)
+{
+    /* Simply raise to synch */
+    KeRaiseIrql(SYNCH_LEVEL, OldIrql);
+
+    /* Always return true on UP Machines */
+    return TRUE;
+}
+
+/*
+ * @implemented
+ */
+LOGICAL
+FASTCALL
+KeTryToAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
+                             OUT PKIRQL OldIrql)
+{
+    /* Simply raise to dispatch */
+    KeRaiseIrql(DISPATCH_LEVEL, OldIrql);
+
+    /* Always return true on UP Machines */
+    return TRUE;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/sysinfo.c b/reactos/hal/halarm/generic/sysinfo.c
new file mode 100644 (file)
index 0000000..f48ae96
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/spinlock.c
+ * PURPOSE:         HAL Information Routines
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS
+NTAPI
+HaliQuerySystemInformation(IN HAL_QUERY_INFORMATION_CLASS InformationClass,
+                           IN ULONG BufferSize,
+                           IN OUT PVOID Buffer,
+                           OUT PULONG ReturnedLength)
+{
+       UNIMPLEMENTED;
+    while (TRUE);
+       return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+HaliSetSystemInformation(IN HAL_SET_INFORMATION_CLASS InformationClass,
+                         IN ULONG BufferSize,
+                         IN OUT PVOID Buffer)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/timer.c b/reactos/hal/halarm/generic/timer.c
new file mode 100644 (file)
index 0000000..9ed2a2a
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/timer.c
+ * PURPOSE:         Timer Routines
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+VOID
+FASTCALL
+KeUpdateSystemTime(
+    IN PKTRAP_FRAME TrapFrame,
+    IN ULONG Increment,
+    IN KIRQL OldIrql
+);
+
+/* GLOBALS ********************************************************************/
+
+ULONG HalpCurrentTimeIncrement, HalpNextTimeIncrement, HalpNextIntervalCount;
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+VOID
+HalpClockInterrupt(VOID)
+{   
+    /* Clear the interrupt */
+    ASSERT(KeGetCurrentIrql() == CLOCK2_LEVEL);
+    WRITE_REGISTER_ULONG(TIMER0_INT_CLEAR, 1);
+    
+    /* FIXME: Update HAL Perf counters */
+    
+    /* FIXME: Check if someone changed the clockrate */
+    
+    /* Call the kernel */
+    KeUpdateSystemTime(KeGetCurrentThread()->TrapFrame,
+                       HalpCurrentTimeIncrement,
+                       CLOCK2_LEVEL);
+}
+
+VOID
+HalpStallInterrupt(VOID)
+{   
+    /* Clear the interrupt */
+    WRITE_REGISTER_ULONG(TIMER0_INT_CLEAR, 1);
+}
+
+VOID
+HalpInitializeClock(VOID)
+{
+    PKIPCR Pcr = (PKIPCR)KeGetPcr();
+    ULONG ClockInterval;
+    SP804_CONTROL_REGISTER ControlRegister;
+    
+    /* Setup the clock and profile interrupt */
+    Pcr->InterruptRoutine[CLOCK2_LEVEL] = HalpStallInterrupt;
+    
+    /*
+     * Configure the interval to 10ms
+     * (INTERVAL (10ms) * TIMCLKfreq (1MHz))
+     * --------------------------------------- == 10^4
+     *  (TIMCLKENXdiv (1) * PRESCALEdiv (1))
+     */
+    ClockInterval = 0x2710;
+    
+    /* Configure the timer */
+    ControlRegister.AsUlong = 0;
+    ControlRegister.Wide = TRUE;
+    ControlRegister.Periodic = TRUE;
+    ControlRegister.Interrupt = TRUE;
+    ControlRegister.Enabled = TRUE;
+    
+    /* Enable the timer */
+    WRITE_REGISTER_ULONG(TIMER0_LOAD, ClockInterval);
+    WRITE_REGISTER_ULONG(TIMER0_CONTROL, ControlRegister.AsUlong);
+}
+
+/* PUBLIC FUNCTIONS ***********************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalCalibratePerformanceCounter(IN volatile PLONG Count,
+                               IN ULONGLONG NewCount)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+}
+
+/*
+ * @implemented
+ */
+ULONG
+NTAPI
+HalSetTimeIncrement(IN ULONG Increment)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return Increment;
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeStallExecutionProcessor(IN ULONG Microseconds)
+{
+    SP804_CONTROL_REGISTER ControlRegister;
+    
+    /* Enable the timer */
+    WRITE_REGISTER_ULONG(TIMER1_LOAD, Microseconds);
+    
+    /* Configure the timer */
+    ControlRegister.AsUlong = 0;
+    ControlRegister.OneShot = TRUE;
+    ControlRegister.Wide = TRUE;
+    ControlRegister.Periodic = TRUE;
+    ControlRegister.Enabled = TRUE;
+    WRITE_REGISTER_ULONG(TIMER1_CONTROL, ControlRegister.AsUlong);
+    
+    /* Now we will loop until the timer reached 0 */
+    while (READ_REGISTER_ULONG(TIMER1_VALUE));
+}
+
+/*
+ * @implemented
+ */
+LARGE_INTEGER
+NTAPI
+KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq)
+{
+    LARGE_INTEGER Value;
+
+    UNIMPLEMENTED;
+    while (TRUE);
+
+    Value.QuadPart = 0;
+    return Value;
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/generic/usage.c b/reactos/hal/halarm/generic/usage.c
new file mode 100644 (file)
index 0000000..248f383
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/generic/usage.c
+ * PURPOSE:         Resource Usage Management Routines
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+PUCHAR KdComPortInUse;
+
+IDTUsageFlags HalpIDTUsageFlags[256];
+IDTUsage HalpIDTUsage[256];
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+VOID
+NTAPI
+HalpReportResourceUsage(IN PUNICODE_STRING HalName,
+                        IN INTERFACE_TYPE InterfaceType)
+{
+    DbgPrint("%wZ has been initialized\n", HalName);
+}
+
+VOID
+NTAPI
+HalpRegisterVector(IN UCHAR Flags,
+                   IN ULONG BusVector,
+                   IN ULONG SystemVector,
+                   IN KIRQL Irql)
+{
+    /* Save the vector flags */
+    HalpIDTUsageFlags[SystemVector].Flags = Flags;
+
+    /* Save the vector data */
+    HalpIDTUsage[SystemVector].Irql  = Irql;
+    HalpIDTUsage[SystemVector].BusReleativeVector = BusVector;
+}
+
+VOID
+NTAPI
+HalpEnableInterruptHandler(IN UCHAR Flags,
+                           IN ULONG BusVector,
+                           IN ULONG SystemVector,
+                           IN KIRQL Irql,
+                           IN PVOID Handler,
+                           IN KINTERRUPT_MODE Mode)
+{
+    /* Register the routine */
+    ((PKIPCR)KeGetPcr())->InterruptRoutine[Irql] = Handler;
+}
+
+/* PUBLIC FUNCTIONS ***********************************************************/
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+HalReportResourceUsage(VOID)
+{
+    UNICODE_STRING HalString;
+
+    /* Build HAL usage */
+    RtlInitUnicodeString(&HalString, L"ARM Versatile HAL");
+    HalpReportResourceUsage(&HalString, Internal);
+}
+
+/* EOF */
diff --git a/reactos/hal/halarm/hal.rbuild b/reactos/hal/halarm/hal.rbuild
new file mode 100644 (file)
index 0000000..2a6086a
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
+<group xmlns:xi="http://www.w3.org/2001/XInclude">
+       <module name="hal" type="kernelmodedll" entrypoint="HalInitSystem@8" installbase="system32" installname="hal.dll">
+               <importlibrary base="hal" definition="../hal.pspec" />
+               <bootstrap installbase="$(CDOUTPUT)" />
+               <include>include</include>
+               <include base="ntoskrnl">include</include>
+               <define name="_NTHAL_" />
+               <library>hal_generic</library>
+               <library>ntoskrnl</library>
+
+               <directory name="versa">
+                       <file>halinit_up.c</file>
+                       <file>halup.rc</file>
+               </directory>
+       </module>
+</group>
diff --git a/reactos/hal/halarm/hal_generic.rbuild b/reactos/hal/halarm/hal_generic.rbuild
new file mode 100644 (file)
index 0000000..b46c036
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!DOCTYPE group SYSTEM "../../../tools/rbuild/project.dtd">
+<group>
+       <module name="hal_generic" type="objectlibrary">
+               <include>include</include>
+               <include base="ntoskrnl">include</include>
+               <define name="_NTHAL_" />
+               <directory name="generic">
+                       <file>beep.c</file>
+                       <file>bus.c</file>
+                       <file>cache.S</file>
+                       <file>dma.c</file>
+                       <file>drive.c</file>
+                       <file>display.c</file>
+                       <file>fmutex.c</file>
+                       <file>halinit.c</file>
+                       <file>misc.c</file>
+                       <file>pic.c</file>
+                       <file>portio.c</file>
+                       <file>processor.c</file>
+                       <file>profil.c</file>
+                       <file>reboot.c</file>
+                       <file>rtc.c</file>
+                       <file>spinlock.c</file>
+                       <file>sysinfo.c</file>
+                       <file>timer.c</file>
+                       <file>usage.c</file>
+               </directory>
+               <directory name="include">
+                       <pch>hal.h</pch>
+               </directory>
+       </module>
+</group>
index f2c8c2e..e6ae706 100644 (file)
@@ -9,6 +9,7 @@
 /* INCLUDES ******************************************************************/
 
 /* C Headers */
+#define DbgPrint DbgPrintEarly
 #include <stdio.h>
 
 /* WDK HAL Compilation hack */
@@ -22,6 +23,7 @@
 
 /* IFS/DDK/NDK Headers */
 #include <ntifs.h>
+#include <ioaccess.h>
 #include <bugcodes.h>
 #include <ntdddisk.h>
 #include <arc/arc.h>
@@ -29,6 +31,7 @@
 #include <kefuncs.h>
 #include <intrin.h>
 #include <halfuncs.h>
+#include <inbvfuncs.h>
 #include <iofuncs.h>
 #include <ldrtypes.h>
 #include <obfuncs.h>
index 98507b4..5ee60dd 100644 (file)
 #include <peripherals/pl190.h>
 #include <peripherals/sp804.h>
 
+#define PRIMARY_VECTOR_BASE     0x00
+
+/* Usage flags */
+#define IDT_REGISTERED          0x01
+#define IDT_LATCHED             0x02
+#define IDT_INTERNAL            0x11
+#define IDT_DEVICE              0x21
+
+typedef struct _IDTUsageFlags
+{
+    UCHAR Flags;
+} IDTUsageFlags;
+
+typedef struct
+{
+    KIRQL Irql;
+    UCHAR BusReleativeVector;
+} IDTUsage;
+
+VOID
+NTAPI
+HalpRegisterVector(IN UCHAR Flags,
+                   IN ULONG BusVector,
+                   IN ULONG SystemVector,
+                   IN KIRQL Irql);
+
+VOID
+NTAPI
+HalpEnableInterruptHandler(IN UCHAR Flags,
+                           IN ULONG BusVector,
+                           IN ULONG SystemVector,
+                           IN KIRQL Irql,
+                           IN PVOID Handler,
+                           IN KINTERRUPT_MODE Mode);
+
+VOID HalpInitPhase0 (PLOADER_PARAMETER_BLOCK LoaderBlock);
+VOID HalpInitPhase1(VOID);
+
+VOID HalpInitializeInterrupts(VOID);
+VOID HalpInitializeClock(VOID);
+VOID HalpClockInterrupt(VOID);
+VOID HalpProfileInterrupt(VOID);
+
+extern ULONG HalpCurrentTimeIncrement, HalpNextTimeIncrement, HalpNextIntervalCount;
+
 #endif /* __INTERNAL_HAL_HAL_H */
diff --git a/reactos/hal/halarm/up/halinit_up.c b/reactos/hal/halarm/up/halinit_up.c
deleted file mode 100644 (file)
index cbb18bc..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* $Id: halinit_up.c 24964 2006-11-29 08:28:20Z ion $
- *
- * COPYRIGHT:     See COPYING in the top level directory
- * PROJECT:       ReactOS kernel
- * FILE:          ntoskrnl/hal/x86/halinit.c
- * PURPOSE:       Initalize the x86 hal
- * PROGRAMMER:    David Welch (welch@cwcom.net)
- * UPDATE HISTORY:
- *              11/06/98: Created
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <hal.h>
-#define NDEBUG
-#include <debug.h>
-
-/* FUNCTIONS ***************************************************************/
-
-VOID
-HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
-{
-
-}
-
-VOID
-HalpInitPhase1(VOID)
-{
-
-}
-
-/* EOF */
diff --git a/reactos/hal/halarm/versa/halinit_up.c b/reactos/hal/halarm/versa/halinit_up.c
new file mode 100644 (file)
index 0000000..0b96939
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/versa/halinit_up.c
+ * PURPOSE:         Versatile Board-Specific HAL Initialization
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+VOID
+HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+
+}
+
+VOID
+HalpInitPhase1(VOID)
+{
+
+}
+
+/* EOF */
similarity index 59%
rename from reactos/hal/halarm/up/halup.rbuild
rename to reactos/hal/halarm/versa/halup.rbuild
index b443905..ac59afe 100644 (file)
@@ -1,13 +1,16 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
 <module name="hal" type="kernelmodedll" entrypoint="HalInitSystem" installbase="system32" installname="hal.dll">
-       <importlibrary base="hal" definition="../../hal.pspec" />
+       <importlibrary base="hal" definition="../hal.pspec" />
        <bootstrap installbase="$(CDOUTPUT)" nameoncd="hal.dll" />
-       <include base="halarm_generic">../include</include>
+       <include base="hal">include</include>
        <include base="ntoskrnl">include</include>
        <define name="_NTHAL_" />
-       <library>halarm_generic</library>
+       <library>hal_generic</library>
        <library>ntoskrnl</library>
-       <file>halinit_up.c</file>
-       <file>halup.rc</file>
+       <library>kdcom</library>
+       <directory name="versa">
+               <file>halinit_up.c</file>
+               <file>halup.rc</file>
+       </directory>
 </module>