Author: ion Date: Fri Aug 25 03:25:37 2006 New Revision: 23694
URL: http://svn.reactos.org/svn/reactos?rev=23694&view=rev Log: - 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
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/ke/i386/irq.c (contents, props changed) trunk/reactos/ntoskrnl/ke/i386/irqhand.s (contents, props changed) trunk/reactos/ntoskrnl/ke/i386/trap.s
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/k... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h Fri Aug 25 03:25:37 2006 @@ -29,6 +29,25 @@ MaximumCachedModuleType, } 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; @@ -47,6 +66,11 @@ 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 @@ 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 */
Modified: trunk/reactos/ntoskrnl/ke/i386/irq.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/irq.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/irq.c (original) +++ trunk/reactos/ntoskrnl/ke/i386/irq.c Fri Aug 25 03:25:37 2006 @@ -1,113 +1,33 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory * FILE: ntoskrnl/ke/i386/irq.c - * PURPOSE: IRQ handling - * - * PROGRAMMERS: David Welch (welch@mcmail.com) + * 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) */
-/* - * 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 - * - */ - /* 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 @@ 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 @@ * @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 @@ * @implemented */ BOOLEAN -STDCALL -KeDisconnectInterrupt(PKINTERRUPT Interrupt) +NTAPI +KeDisconnectInterrupt(IN PKINTERRUPT Interrupt) { KIRQL OldIrql, Irql; ULONG Vector;
Propchange: trunk/reactos/ntoskrnl/ke/i386/irq.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*
Modified: trunk/reactos/ntoskrnl/ke/i386/irqhand.s URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/irqhand.s?... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/irqhand.s (original) +++ trunk/reactos/ntoskrnl/ke/i386/irqhand.s Fri Aug 25 03:25:37 2006 @@ -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 */ + cli + call _HalEndSystemInterrupt@8
-#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 - + pop gs + pop fs + pop es + pop ds + popa + iret
Propchange: trunk/reactos/ntoskrnl/ke/i386/irqhand.s ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*
Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?rev... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/trap.s (original) +++ trunk/reactos/ntoskrnl/ke/i386/trap.s Fri Aug 25 03:25:37 2006 @@ -63,7 +63,7 @@
/* 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 @@ 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]