-/* $Id: halddk.h,v 1.4 2000/07/04 11:11:03 dwelch Exp $
+/* $Id: halddk.h,v 1.5 2000/07/24 23:48:24 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PCM_RESOURCE_LIST *AllocatedResources
);
-/*
-HalBeginSystemInterrupt
-*/
+BOOLEAN STDCALL HalBeginSystemInterrupt (ULONG Vector,
+ KIRQL Irql,
+ PKIRQL OldIrql);
/*
HalCalibratePerformanceCounter
HalClearSoftwareInterrupt
*/
-/*
-HalDisableSystemInterrupt
-*/
+BOOLEAN STDCALL HalDisableSystemInterrupt (ULONG Vector,
+ ULONG Unknown2);
VOID
STDCALL
IN PCH String
);
-/*
-HalEnableSystemInterrupt
-*/
+BOOLEAN STDCALL HalEnableSystemInterrupt (ULONG Vector,
+ ULONG Unknown2,
+ ULONG Unknown3);
+
+VOID STDCALL HalEndSystemInterrupt (KIRQL Irql,
+ ULONG Unknown2);
-/*
-HalEndSystemInterrupt
-*/
/* Is this function really exported ?? */
VOID
VOID STDCALL KeEnterCriticalRegion (VOID);
+/*
+ * FUNCTION: Enters the kernel debugger
+ * ARGUMENTS:
+ * None
+ */
+VOID STDCALL KeEnterKernelDebugger (VOID);
+
+VOID STDCALL KeFlushWriteBuffer (VOID);
+
KIRQL STDCALL KeGetCurrentIrql (VOID);
ULONG KeGetCurrentProcessorNumber(VOID);
);
-/*
- * FUNCTION: Sets the current irql without altering the current processor
- * state
- * ARGUMENTS:
- * newlvl = IRQ level to set
- * NOTE: This is for internal use only
- */
-VOID KeSetCurrentIrql(KIRQL newlvl);
-
// io permission map has a 8k size
// Each bit in the IOPM corresponds to an io port byte address. The bitmap
NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
IN ULONG NumOfSelectors);
-/*
- * FUNCTION: Enters the kernel debugger
- * ARGUMENTS:
- * None
- */
-VOID
-STDCALL
-KeEnterKernelDebugger (VOID);
-
-
-VOID
-STDCALL
-KeFlushWriteBuffer (
- VOID
- );
KIRQL
FASTCALL
-/* $Id: halinit.c,v 1.13 2000/07/10 21:49:29 ekohl Exp $
+/* $Id: halinit.c,v 1.14 2000/07/24 23:50:13 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <ddk/ntddk.h>
#include <internal/hal.h>
#include <internal/ntoskrnl.h>
+#include <internal/halio.h>
#define NDEBUG
#include <internal/debug.h>
{
HalInitializeDisplay (LoaderBlock);
HalpCalibrateStallExecution ();
+ HalpInitPICs ();
}
else
{
/* GLOBALS ******************************************************************/
+/* FIXME: this should be in a header file */
+#define NR_IRQS (16)
+#define IRQ_BASE (0x40)
+
/*
* PURPOSE: Current irq level
*/
extern ULONG DpcQueueSize;
+static VOID KeSetCurrentIrql(KIRQL newlvl);
+
/* FUNCTIONS ****************************************************************/
+VOID HalpInitPICs(VOID)
+{
+ /* Mask off all interrupts from PICs */
+ outb(0x21,0xff);
+ outb(0xa1,0xff);
+}
+
#if 0
static unsigned int HiGetCurrentPICMask(void)
{
}
-VOID KeSetCurrentIrql(KIRQL newlvl)
+KIRQL STDCALL KeGetCurrentIrql (VOID)
/*
- * PURPOSE: Sets the current irq level without taking any action
+ * PURPOSE: Returns the current irq level
+ * RETURNS: The current irq level
*/
{
-// DPRINT("KeSetCurrentIrql(newlvl %x)\n",newlvl);
- CurrentIrql = newlvl;
+ return(CurrentIrql);
}
-KIRQL STDCALL KeGetCurrentIrql (VOID)
+static VOID KeSetCurrentIrql(KIRQL newlvl)
/*
- * PURPOSE: Returns the current irq level
- * RETURNS: The current irq level
+ * PURPOSE: Sets the current irq level without taking any action
*/
{
- return(CurrentIrql);
+// DPRINT("KeSetCurrentIrql(newlvl %x)\n",newlvl);
+ CurrentIrql = newlvl;
}
*OldIrql = KfRaiseIrql (NewIrql);
}
+
+BOOLEAN STDCALL HalBeginSystemInterrupt (ULONG Vector,
+ KIRQL Irql,
+ PKIRQL OldIrql)
+{
+ if (Vector < IRQ_BASE || Vector > IRQ_BASE + NR_IRQS)
+ return FALSE;
+
+ /* Send EOI to the PICs */
+ outb(0x20,0x20);
+ if ((Vector-IRQ_BASE)>=8)
+ {
+ outb(0xa0,0x20);
+ }
+
+ *OldIrql = KeGetCurrentIrql();
+ if (Vector-IRQ_BASE != 0)
+ {
+ DPRINT("old_level %d\n",*OldIrql);
+ }
+ KeSetCurrentIrql(Irql);
+
+ return TRUE;
+}
+
+
+VOID STDCALL HalEndSystemInterrupt (KIRQL Irql,
+ ULONG Unknown2)
+{
+ KeSetCurrentIrql(Irql);
+}
+
+
+BOOLEAN STDCALL HalDisableSystemInterrupt (ULONG Vector,
+ ULONG Unknown2)
+{
+ ULONG irq;
+
+ if (Vector < IRQ_BASE || Vector > IRQ_BASE + NR_IRQS)
+ return FALSE;
+
+ irq = Vector - IRQ_BASE;
+ if (irq<8)
+ {
+ outb(0x21,inb(0x21)|(1<<irq));
+ }
+ else
+ {
+ outb(0xa1,inb(0xa1)|(1<<(irq-8)));
+ }
+
+ return TRUE;
+}
+
+
+BOOLEAN STDCALL HalEnableSystemInterrupt (ULONG Vector,
+ ULONG Unknown2,
+ ULONG Unknown3)
+{
+ ULONG irq;
+
+ if (Vector < IRQ_BASE || Vector > IRQ_BASE + NR_IRQS)
+ return FALSE;
+
+ irq = Vector - IRQ_BASE;
+ if (irq<8)
+ {
+ outb(0x21,inb(0x21)&(~(1<<irq)));
+ }
+ else
+ {
+ outb(0xa1,inb(0xa1)&(~(1<<(irq-8))));
+ }
+
+ return TRUE;
+}
+
/* EOF */
VOID HalpInitBusHandlers (VOID);
+/* irql.c */
+VOID HalpInitPICs(VOID);
+
/* udelay.c */
VOID HalpCalibrateStallExecution(VOID);
-/* $Id: irq.c,v 1.1 2000/07/10 21:54:51 ekohl Exp $
+/* $Id: irq.c,v 1.2 2000/07/24 23:51:46 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <internal/ke.h>
#include <internal/ps.h>
#include <internal/i386/segment.h>
-#include <internal/halio.h>
#define NDEBUG
#include <internal/debug.h>
DPRINT("KeInitInterrupts ()\n",0);
- /*
- * First mask off all interrupts from pic
- */
- outb(0x21,0xff);
- outb(0xa1,0xff);
-
-
/*
* Setup the IDT entries to point to the interrupt handlers
*/
/*
* Notify the rest of the kernel of the raised irq level
*/
- old_level = KeGetCurrentIrql();
- if (irq != 0)
- {
- DPRINT("old_level %d\n",old_level);
- }
- KeSetCurrentIrql(HIGH_LEVEL - irq);
+ HalBeginSystemInterrupt (irq+IRQ_BASE,
+ HIGH_LEVEL-irq,
+ &old_level);
/*
* Enable interrupts
*/
__asm__("cli\n\t");
- /*
- * Send EOI to the PIC
- */
- outb(0x20,0x20);
- if (irq>=8)
- {
- outb(0xa0,0x20);
- }
-
/*
* Unmask the related irq
*/
- if (irq<8)
- {
- outb(0x21,inb(0x21)&(~(1<<irq)));
- }
- else
- {
- outb(0xa1,inb(0xa1)&(~(1<<(irq-8))));
- }
+ HalEnableSystemInterrupt (irq + IRQ_BASE, 0, 0);
/*
* If the processor level will drop below dispatch level on return then
*/
if (old_level < DISPATCH_LEVEL)
{
- KeSetCurrentIrql(DISPATCH_LEVEL);
+ HalEndSystemInterrupt (DISPATCH_LEVEL, 0);
__asm__("sti\n\t");
if (irq == 0)
{
// DbgPrint("$");
}
- KeSetCurrentIrql(old_level);
+
+ HalEndSystemInterrupt (old_level, 0);
// DbgPrint("}");
}