- Got rid of the deprecated stuff left in irq.c and directly implemented it as part of irqhand.S (which is also deprecated).

- Cleaned up irq.c. Fixed file header, function prototypes, includes, etc, and moved general definitions and externs to ke.h

svn path=/trunk/; revision=23694
This commit is contained in:
Alex Ionescu 2006-08-24 23:25:37 +00:00
parent 52f5a2cccc
commit 5d9935a1fa
4 changed files with 125 additions and 191 deletions

View file

@ -30,6 +30,25 @@ typedef enum _CACHED_MODULE_TYPE
} CACHED_MODULE_TYPE, *PCACHED_MODULE_TYPE;
extern PLOADER_MODULE CachedModules[MaximumCachedModuleType];
typedef enum _CONNECT_TYPE
{
NoConnect,
NormalConnect,
ChainConnect,
UnknownConnect
} CONNECT_TYPE, *PCONNECT_TYPE;
typedef struct _DISPATCH_INFO
{
CONNECT_TYPE Type;
PKINTERRUPT Interrupt;
PKINTERRUPT_ROUTINE NoDispatch;
PKINTERRUPT_ROUTINE InterruptDispatch;
PKINTERRUPT_ROUTINE FloatingDispatch;
PKINTERRUPT_ROUTINE ChainedDispatch;
PKINTERRUPT_ROUTINE *FlatDispatch;
} DISPATCH_INFO, *PDISPATCH_INFO;
struct _KIRQ_TRAPFRAME;
struct _KPCR;
struct _KPRCB;
@ -47,6 +66,11 @@ extern ULONG KeI386FxsrPresent;
extern PKNODE KeNodeBlock[1];
extern UCHAR KeNumberNodes;
extern UCHAR KeProcessNodeSeed;
extern ULONG KiInterruptTemplate[KINTERRUPT_DISPATCH_CODES];
extern PULONG KiInterruptTemplateObject;
extern PULONG KiInterruptTemplateDispatch;
extern PULONG KiInterruptTemplate2ndDispatch;
extern ULONG KiUnexpectedEntrySize;
/* MACROS *************************************************************************/
@ -685,6 +709,30 @@ KeV86Exception(
ULONG address
);
VOID
NTAPI
KiStartUnexpectedRange(
VOID
);
VOID
NTAPI
KiEndUnexpectedRange(
VOID
);
VOID
NTAPI
KiInterruptDispatch(
VOID
);
VOID
NTAPI
KiChainedDispatch(
VOID
);
#include "ke_x.h"
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_KE_H */

View file

@ -1,113 +1,33 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/i386/irq.c
* PURPOSE: IRQ handling
*
* PROGRAMMERS: David Welch (welch@mcmail.com)
*/
/*
* NOTE: In general the PIC interrupt priority facilities are used to
* preserve the NT IRQL semantics, global interrupt disables are only used
* to keep the PIC in a consistent state
*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ke/i386/irq.c
* PURPOSE: Manages the Kernel's IRQ support for external drivers,
* for the purpopses of connecting, disconnecting and setting
* up ISRs for drivers. The backend behind the Io* Interrupt
* routines.
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ****************************************************************/
#include <ntoskrnl.h>
#include <../hal/halx86/include/halirq.h>
#include <../hal/halx86/include/mps.h>
#define NDEBUG
#include <internal/debug.h>
typedef enum _CONNECT_TYPE
{
NoConnect,
NormalConnect,
ChainConnect,
UnknownConnect
} CONNECT_TYPE, *PCONNECT_TYPE;
typedef struct _DISPATCH_INFO
{
CONNECT_TYPE Type;
PKINTERRUPT Interrupt;
PKINTERRUPT_ROUTINE NoDispatch;
PKINTERRUPT_ROUTINE InterruptDispatch;
PKINTERRUPT_ROUTINE FloatingDispatch;
PKINTERRUPT_ROUTINE ChainedDispatch;
PKINTERRUPT_ROUTINE *FlatDispatch;
} DISPATCH_INFO, *PDISPATCH_INFO;
extern ULONG KiInterruptTemplate[KINTERRUPT_DISPATCH_CODES];
extern PULONG KiInterruptTemplateObject;
extern PULONG KiInterruptTemplateDispatch;
extern PULONG KiInterruptTemplate2ndDispatch;
extern ULONG KiUnexpectedEntrySize;
VOID
NTAPI
KiStartUnexpectedRange(VOID);
VOID
NTAPI
KiEndUnexpectedRange(VOID);
VOID
NTAPI
KiInterruptDispatch3(VOID);
VOID
NTAPI
KiChainedDispatch(VOID);
#include <debug.h>
/* DEPRECATED FUNCTIONS ******************************************************/
void irq_handler_0(void);
extern IDT_DESCRIPTOR KiIdt[256];
#define PRESENT (0x8000)
#define I486_INTERRUPT_GATE (0xe00)
VOID
INIT_FUNCTION
NTAPI
KeInitInterrupts (VOID)
{
KiIdt[IRQ_BASE].a=((ULONG)irq_handler_0&0xffff)+(KGDT_R0_CODE<<16);
KiIdt[IRQ_BASE].b=((ULONG)irq_handler_0&0xffff0000)+PRESENT+
I486_INTERRUPT_GATE;
}
VOID
KiInterruptDispatch (ULONG vector, PKIRQ_TRAPFRAME Trapframe)
/*
* FUNCTION: Calls the irq specific handler for an irq
* ARGUMENTS:
* irq = IRQ that has interrupted
*/
{
KIRQL old_level;
KeGetCurrentPrcb()->InterruptCount++;
/*
* Notify the rest of the kernel of the raised irq level. For the
* default HAL this will send an EOI to the PIC and alter the IRQL.
*/
if (!HalBeginSystemInterrupt (VECTOR2IRQL(vector),
vector,
&old_level))
{
return;
}
Ke386EnableInterrupts();
Ke386DisableInterrupts();
HalEndSystemInterrupt (old_level, 0);
KiIdt[0x30].a=((ULONG)irq_handler_0&0xffff)+(KGDT_R0_CODE<<16);
KiIdt[0x30].b=((ULONG)irq_handler_0&0xffff0000)+0x8000+
0xe00;
}
/* PRIVATE FUNCTIONS *********************************************************/
@ -126,7 +46,7 @@ KiGetVectorDispatch(IN ULONG Vector,
KiUnexpectedEntrySize);
/* Setup the handlers */
Dispatch->InterruptDispatch = KiInterruptDispatch3;
Dispatch->InterruptDispatch = KiInterruptDispatch;
Dispatch->FloatingDispatch = NULL; // Floating Interrupts are not supported
Dispatch->ChainedDispatch = KiChainedDispatch;
Dispatch->FlatDispatch = NULL;
@ -225,18 +145,18 @@ KiConnectVectorToInterrupt(IN PKINTERRUPT Interrupt,
* @implemented
*/
VOID
STDCALL
KeInitializeInterrupt(PKINTERRUPT Interrupt,
PKSERVICE_ROUTINE ServiceRoutine,
PVOID ServiceContext,
PKSPIN_LOCK SpinLock,
ULONG Vector,
KIRQL Irql,
KIRQL SynchronizeIrql,
KINTERRUPT_MODE InterruptMode,
BOOLEAN ShareVector,
CHAR ProcessorNumber,
BOOLEAN FloatingSave)
NTAPI
KeInitializeInterrupt(IN PKINTERRUPT Interrupt,
IN PKSERVICE_ROUTINE ServiceRoutine,
IN PVOID ServiceContext,
IN PKSPIN_LOCK SpinLock,
IN ULONG Vector,
IN KIRQL Irql,
IN KIRQL SynchronizeIrql,
IN KINTERRUPT_MODE InterruptMode,
IN BOOLEAN ShareVector,
IN CHAR ProcessorNumber,
IN BOOLEAN FloatingSave)
{
ULONG i;
PULONG DispatchCode = &Interrupt->DispatchCode[0], Patch = DispatchCode;
@ -378,8 +298,8 @@ KeConnectInterrupt(IN PKINTERRUPT Interrupt)
* @implemented
*/
BOOLEAN
STDCALL
KeDisconnectInterrupt(PKINTERRUPT Interrupt)
NTAPI
KeDisconnectInterrupt(IN PKINTERRUPT Interrupt)
{
KIRQL OldIrql, Irql;
ULONG Vector;

View file

@ -1,89 +1,55 @@
/*
* FILE: ntoskrnl/ke/i386/clock.S
* COPYRIGHT: See COPYING in the top level directory
* PURPOSE: System Clock Management
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES ******************************************************************/
#include <asm.h>
#include <internal/i386/asmmacro.S>
.intel_syntax noprefix
/* GLOBALS *******************************************************************/
#include <ndk/asm.h>
#include <../hal/halx86/include/halirq.h>
_KiCommonInterrupt:
cld
pushl %ds
pushl %es
pushl %fs
pushl %gs
pushl $0xceafbeef
movl $KGDT_R0_DATA,%eax
movl %eax,%ds
movl %eax,%es
movl %eax,%gs
movl $KGDT_R0_PCR,%eax
movl %eax,%fs
pushl %esp
pushl %ebx
call _KiInterruptDispatch
addl $0xC, %esp
popl %gs
popl %fs
popl %es
popl %ds
popa
iret
.global _irq_handler_0
_irq_handler_0:
pusha
cld
push ds
push es
push fs
push gs
push 0xCEAFBEEF
mov eax, KGDT_R0_DATA
mov ds, eax
mov es, eax
mov gs, eax
mov eax, KGDT_R0_PCR
mov fs, eax
/* Increase interrupt count */
inc dword ptr [fs:KPCR_PRCB_INTERRUPT_COUNT]
#ifdef CONFIG_SMP
/* Put vector in EBX and make space for KIRQL */
sub esp, 4
#define BUILD_INTERRUPT_HANDLER(intnum) \
.global _KiUnexpectedInterrupt##intnum; \
_KiUnexpectedInterrupt##intnum:; \
pusha; \
movl $0x##intnum, %ebx; \
jmp _KiCommonInterrupt;
/* Begin interrupt */
push esp
push 0x30
push HIGH_LEVEL
call _HalBeginSystemInterrupt@12
/* Interrupt handlers and declarations */
#define B(x,y) \
BUILD_INTERRUPT_HANDLER(x##y)
#define B16(x) \
B(x,0) B(x,1) B(x,2) B(x,3) \
B(x,4) B(x,5) B(x,6) B(x,7) \
B(x,8) B(x,9) B(x,A) B(x,B) \
B(x,C) B(x,D) B(x,E) B(x,F)
B16(3) B16(4) B16(5) B16(6)
B16(7) B16(8) B16(9) B16(A)
B16(B) B16(C) B16(D) B16(E)
B16(F)
#undef B
#undef B16
#undef BUILD_INTERRUPT_HANDLER
#else /* CONFIG_SMP */
#define BUILD_INTERRUPT_HANDLER(intnum) \
.global _irq_handler_##intnum; \
_irq_handler_##intnum:; \
pusha; \
movl $(##intnum + IRQ_BASE), %ebx; \
jmp _KiCommonInterrupt;
/* Interrupt handlers and declarations */
#define B(x) \
BUILD_INTERRUPT_HANDLER(x)
B(0) B(1) B(2) B(3)
B(4) B(5) B(6) B(7)
B(8) B(9) B(10) B(11)
B(12) B(13) B(14) B(15)
#undef B
#undef BUILD_INTERRUPT_HANDLER
#endif /* CONFIG_SMP */
.intel_syntax noprefix
.globl _KiUnexpectedInterrupt@0
_KiUnexpectedInterrupt@0:
/* Bugcheck with invalid interrupt code */
push 0x12
call _KeBugCheck@4
cli
call _HalEndSystemInterrupt@8
pop gs
pop fs
pop es
pop ds
popa
iret

View file

@ -63,7 +63,7 @@ GENERATE_IDT_STUBS /* INT 30-FF: UNEXPECTED INTERRUPTS */
/* Chained and Normal generic interrupt handlers for 1st and 2nd level entry*/
.globl _KiChainedDispatch2ndLvl@0
.globl _KiInterruptDispatch3@0
.globl _KiInterruptDispatch@0
.globl _KiChainedDispatch@0
/* We implement the following trap exit points: */
@ -1437,8 +1437,8 @@ _KiChainedDispatch@0:
jmp _Kei386EoiHelper@0
.endfunc
.func KiInterruptDispatch3@0
_KiInterruptDispatch3@0:
.func KiInterruptDispatch@0
_KiInterruptDispatch@0:
/* Increase interrupt count */
inc dword ptr [fs:KPCR_PRCB_INTERRUPT_COUNT]