Implemented hal system interrupt functions

svn path=/trunk/; revision=1275
This commit is contained in:
Eric Kohl 2000-07-24 23:51:46 +00:00
parent 07b9585e22
commit afde198a7d
6 changed files with 135 additions and 82 deletions

View file

@ -1,4 +1,4 @@
/* $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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -344,9 +344,9 @@ HalAssignSlotResources (
PCM_RESOURCE_LIST *AllocatedResources PCM_RESOURCE_LIST *AllocatedResources
); );
/* BOOLEAN STDCALL HalBeginSystemInterrupt (ULONG Vector,
HalBeginSystemInterrupt KIRQL Irql,
*/ PKIRQL OldIrql);
/* /*
HalCalibratePerformanceCounter HalCalibratePerformanceCounter
@ -357,9 +357,8 @@ FASTCALL
HalClearSoftwareInterrupt HalClearSoftwareInterrupt
*/ */
/* BOOLEAN STDCALL HalDisableSystemInterrupt (ULONG Vector,
HalDisableSystemInterrupt ULONG Unknown2);
*/
VOID VOID
STDCALL STDCALL
@ -367,13 +366,13 @@ HalDisplayString (
IN PCH String IN PCH String
); );
/* BOOLEAN STDCALL HalEnableSystemInterrupt (ULONG Vector,
HalEnableSystemInterrupt ULONG Unknown2,
*/ ULONG Unknown3);
VOID STDCALL HalEndSystemInterrupt (KIRQL Irql,
ULONG Unknown2);
/*
HalEndSystemInterrupt
*/
/* Is this function really exported ?? */ /* Is this function really exported ?? */
VOID VOID

View file

@ -66,6 +66,15 @@ VOID STDCALL KeDisconnectInterrupt(PKINTERRUPT InterruptObject);
VOID STDCALL KeEnterCriticalRegion (VOID); VOID STDCALL KeEnterCriticalRegion (VOID);
/*
* FUNCTION: Enters the kernel debugger
* ARGUMENTS:
* None
*/
VOID STDCALL KeEnterKernelDebugger (VOID);
VOID STDCALL KeFlushWriteBuffer (VOID);
KIRQL STDCALL KeGetCurrentIrql (VOID); KIRQL STDCALL KeGetCurrentIrql (VOID);
ULONG KeGetCurrentProcessorNumber(VOID); ULONG KeGetCurrentProcessorNumber(VOID);
@ -355,15 +364,6 @@ KeWaitForSingleObject (
); );
/*
* 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 // io permission map has a 8k size
// Each bit in the IOPM corresponds to an io port byte address. The bitmap // Each bit in the IOPM corresponds to an io port byte address. The bitmap
@ -426,21 +426,6 @@ NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray, NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
IN ULONG NumOfSelectors); IN ULONG NumOfSelectors);
/*
* FUNCTION: Enters the kernel debugger
* ARGUMENTS:
* None
*/
VOID
STDCALL
KeEnterKernelDebugger (VOID);
VOID
STDCALL
KeFlushWriteBuffer (
VOID
);
KIRQL KIRQL
FASTCALL FASTCALL

View file

@ -1,4 +1,4 @@
/* $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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -14,6 +14,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/hal.h> #include <internal/hal.h>
#include <internal/ntoskrnl.h> #include <internal/ntoskrnl.h>
#include <internal/halio.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -31,6 +32,7 @@ HalInitSystem (
{ {
HalInitializeDisplay (LoaderBlock); HalInitializeDisplay (LoaderBlock);
HalpCalibrateStallExecution (); HalpCalibrateStallExecution ();
HalpInitPICs ();
} }
else else
{ {

View file

@ -19,6 +19,10 @@
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
/* FIXME: this should be in a header file */
#define NR_IRQS (16)
#define IRQ_BASE (0x40)
/* /*
* PURPOSE: Current irq level * PURPOSE: Current irq level
*/ */
@ -26,8 +30,17 @@ static KIRQL CurrentIrql = HIGH_LEVEL;
extern ULONG DpcQueueSize; extern ULONG DpcQueueSize;
static VOID KeSetCurrentIrql(KIRQL newlvl);
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
VOID HalpInitPICs(VOID)
{
/* Mask off all interrupts from PICs */
outb(0x21,0xff);
outb(0xa1,0xff);
}
#if 0 #if 0
static unsigned int HiGetCurrentPICMask(void) static unsigned int HiGetCurrentPICMask(void)
{ {
@ -118,16 +131,6 @@ static VOID HiSwitchIrql(KIRQL oldIrql)
} }
VOID KeSetCurrentIrql(KIRQL newlvl)
/*
* PURPOSE: Sets the current irq level without taking any action
*/
{
// DPRINT("KeSetCurrentIrql(newlvl %x)\n",newlvl);
CurrentIrql = newlvl;
}
KIRQL STDCALL KeGetCurrentIrql (VOID) KIRQL STDCALL KeGetCurrentIrql (VOID)
/* /*
* PURPOSE: Returns the current irq level * PURPOSE: Returns the current irq level
@ -138,6 +141,16 @@ KIRQL STDCALL KeGetCurrentIrql (VOID)
} }
static VOID KeSetCurrentIrql(KIRQL newlvl)
/*
* PURPOSE: Sets the current irq level without taking any action
*/
{
// DPRINT("KeSetCurrentIrql(newlvl %x)\n",newlvl);
CurrentIrql = newlvl;
}
/********************************************************************** /**********************************************************************
* NAME EXPORTED * NAME EXPORTED
* KfLowerIrql * KfLowerIrql
@ -282,4 +295,81 @@ KeRaiseIrql (
*OldIrql = KfRaiseIrql (NewIrql); *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 */ /* EOF */

View file

@ -29,6 +29,9 @@ VOID HalResetDisplay (VOID);
VOID HalpInitBusHandlers (VOID); VOID HalpInitBusHandlers (VOID);
/* irql.c */
VOID HalpInitPICs(VOID);
/* udelay.c */ /* udelay.c */
VOID HalpCalibrateStallExecution(VOID); VOID HalpCalibrateStallExecution(VOID);

View file

@ -1,4 +1,4 @@
/* $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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -23,7 +23,6 @@
#include <internal/ke.h> #include <internal/ke.h>
#include <internal/ps.h> #include <internal/ps.h>
#include <internal/i386/segment.h> #include <internal/i386/segment.h>
#include <internal/halio.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -92,13 +91,6 @@ VOID KeInitInterrupts (VOID)
DPRINT("KeInitInterrupts ()\n",0); 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 * Setup the IDT entries to point to the interrupt handlers
*/ */
@ -128,12 +120,9 @@ VOID KiInterruptDispatch (ULONG irq)
/* /*
* Notify the rest of the kernel of the raised irq level * Notify the rest of the kernel of the raised irq level
*/ */
old_level = KeGetCurrentIrql(); HalBeginSystemInterrupt (irq+IRQ_BASE,
if (irq != 0) HIGH_LEVEL-irq,
{ &old_level);
DPRINT("old_level %d\n",old_level);
}
KeSetCurrentIrql(HIGH_LEVEL - irq);
/* /*
* Enable interrupts * Enable interrupts
@ -168,26 +157,10 @@ VOID KiInterruptDispatch (ULONG irq)
*/ */
__asm__("cli\n\t"); __asm__("cli\n\t");
/*
* Send EOI to the PIC
*/
outb(0x20,0x20);
if (irq>=8)
{
outb(0xa0,0x20);
}
/* /*
* Unmask the related irq * Unmask the related irq
*/ */
if (irq<8) HalEnableSystemInterrupt (irq + IRQ_BASE, 0, 0);
{
outb(0x21,inb(0x21)&(~(1<<irq)));
}
else
{
outb(0xa1,inb(0xa1)&(~(1<<(irq-8))));
}
/* /*
* If the processor level will drop below dispatch level on return then * If the processor level will drop below dispatch level on return then
@ -195,7 +168,7 @@ VOID KiInterruptDispatch (ULONG irq)
*/ */
if (old_level < DISPATCH_LEVEL) if (old_level < DISPATCH_LEVEL)
{ {
KeSetCurrentIrql(DISPATCH_LEVEL); HalEndSystemInterrupt (DISPATCH_LEVEL, 0);
__asm__("sti\n\t"); __asm__("sti\n\t");
if (irq == 0) if (irq == 0)
@ -209,7 +182,8 @@ VOID KiInterruptDispatch (ULONG irq)
{ {
// DbgPrint("$"); // DbgPrint("$");
} }
KeSetCurrentIrql(old_level);
HalEndSystemInterrupt (old_level, 0);
// DbgPrint("}"); // DbgPrint("}");
} }