mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Implemented hal system interrupt functions
svn path=/trunk/; revision=1275
This commit is contained in:
parent
07b9585e22
commit
afde198a7d
6 changed files with 135 additions and 82 deletions
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -344,9 +344,9 @@ HalAssignSlotResources (
|
|||
PCM_RESOURCE_LIST *AllocatedResources
|
||||
);
|
||||
|
||||
/*
|
||||
HalBeginSystemInterrupt
|
||||
*/
|
||||
BOOLEAN STDCALL HalBeginSystemInterrupt (ULONG Vector,
|
||||
KIRQL Irql,
|
||||
PKIRQL OldIrql);
|
||||
|
||||
/*
|
||||
HalCalibratePerformanceCounter
|
||||
|
@ -357,9 +357,8 @@ FASTCALL
|
|||
HalClearSoftwareInterrupt
|
||||
*/
|
||||
|
||||
/*
|
||||
HalDisableSystemInterrupt
|
||||
*/
|
||||
BOOLEAN STDCALL HalDisableSystemInterrupt (ULONG Vector,
|
||||
ULONG Unknown2);
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
|
@ -367,13 +366,13 @@ HalDisplayString (
|
|||
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
|
||||
|
|
|
@ -66,6 +66,15 @@ VOID STDCALL KeDisconnectInterrupt(PKINTERRUPT InterruptObject);
|
|||
|
||||
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);
|
||||
|
@ -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
|
||||
// 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,
|
||||
IN ULONG NumOfSelectors);
|
||||
|
||||
/*
|
||||
* FUNCTION: Enters the kernel debugger
|
||||
* ARGUMENTS:
|
||||
* None
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
KeEnterKernelDebugger (VOID);
|
||||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
KeFlushWriteBuffer (
|
||||
VOID
|
||||
);
|
||||
|
||||
KIRQL
|
||||
FASTCALL
|
||||
|
|
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -14,6 +14,7 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <internal/hal.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/halio.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -31,6 +32,7 @@ HalInitSystem (
|
|||
{
|
||||
HalInitializeDisplay (LoaderBlock);
|
||||
HalpCalibrateStallExecution ();
|
||||
HalpInitPICs ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
/* FIXME: this should be in a header file */
|
||||
#define NR_IRQS (16)
|
||||
#define IRQ_BASE (0x40)
|
||||
|
||||
/*
|
||||
* PURPOSE: Current irq level
|
||||
*/
|
||||
|
@ -26,8 +30,17 @@ static KIRQL CurrentIrql = HIGH_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)
|
||||
{
|
||||
|
@ -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)
|
||||
/*
|
||||
* 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
|
||||
* KfLowerIrql
|
||||
|
@ -282,4 +295,81 @@ KeRaiseIrql (
|
|||
*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 */
|
||||
|
|
|
@ -29,6 +29,9 @@ VOID HalResetDisplay (VOID);
|
|||
|
||||
VOID HalpInitBusHandlers (VOID);
|
||||
|
||||
/* irql.c */
|
||||
VOID HalpInitPICs(VOID);
|
||||
|
||||
/* udelay.c */
|
||||
VOID HalpCalibrateStallExecution(VOID);
|
||||
|
||||
|
|
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -23,7 +23,6 @@
|
|||
#include <internal/ke.h>
|
||||
#include <internal/ps.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/halio.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -92,13 +91,6 @@ VOID KeInitInterrupts (VOID)
|
|||
|
||||
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
|
||||
*/
|
||||
|
@ -128,12 +120,9 @@ VOID KiInterruptDispatch (ULONG irq)
|
|||
/*
|
||||
* 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
|
||||
|
@ -168,26 +157,10 @@ VOID KiInterruptDispatch (ULONG irq)
|
|||
*/
|
||||
__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
|
||||
|
@ -195,7 +168,7 @@ VOID KiInterruptDispatch (ULONG irq)
|
|||
*/
|
||||
if (old_level < DISPATCH_LEVEL)
|
||||
{
|
||||
KeSetCurrentIrql(DISPATCH_LEVEL);
|
||||
HalEndSystemInterrupt (DISPATCH_LEVEL, 0);
|
||||
__asm__("sti\n\t");
|
||||
|
||||
if (irq == 0)
|
||||
|
@ -209,7 +182,8 @@ VOID KiInterruptDispatch (ULONG irq)
|
|||
{
|
||||
// DbgPrint("$");
|
||||
}
|
||||
KeSetCurrentIrql(old_level);
|
||||
|
||||
HalEndSystemInterrupt (old_level, 0);
|
||||
// DbgPrint("}");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue