mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Moved interrupt code from hal into kernel
Implemented missing interrupt functions svn path=/trunk/; revision=1261
This commit is contained in:
parent
b4f80cb2e6
commit
85c3d3799b
20 changed files with 260 additions and 421 deletions
|
@ -51,6 +51,8 @@ BOOLEAN STDCALL KeCancelTimer (PKTIMER Timer);
|
|||
|
||||
VOID STDCALL KeClearEvent (PKEVENT Event);
|
||||
|
||||
NTSTATUS STDCALL KeConnectInterrupt(PKINTERRUPT InterruptObject);
|
||||
|
||||
NTSTATUS STDCALL KeDelayExecutionThread (KPROCESSOR_MODE WaitMode,
|
||||
BOOLEAN Alertable,
|
||||
PLARGE_INTEGER Internal);
|
||||
|
@ -60,6 +62,8 @@ BOOLEAN STDCALL KeDeregisterBugCheckCallback (
|
|||
|
||||
VOID STDCALL KeDetachProcess (VOID);
|
||||
|
||||
VOID STDCALL KeDisconnectInterrupt(PKINTERRUPT InterruptObject);
|
||||
|
||||
VOID STDCALL KeEnterCriticalRegion (VOID);
|
||||
|
||||
KIRQL STDCALL KeGetCurrentIrql (VOID);
|
||||
|
@ -100,6 +104,18 @@ VOID STDCALL KeInitializeEvent (PKEVENT Event,
|
|||
EVENT_TYPE Type,
|
||||
BOOLEAN State);
|
||||
|
||||
NTSTATUS STDCALL KeInitializeInterrupt(PKINTERRUPT InterruptObject,
|
||||
PKSERVICE_ROUTINE ServiceRoutine,
|
||||
PVOID ServiceContext,
|
||||
PKSPIN_LOCK SpinLock,
|
||||
ULONG Vector,
|
||||
KIRQL Irql,
|
||||
KIRQL SynchronizeIrql,
|
||||
KINTERRUPT_MODE InterruptMode,
|
||||
BOOLEAN ShareVector,
|
||||
KAFFINITY ProcessorEnableMask,
|
||||
BOOLEAN FloatingSave);
|
||||
|
||||
VOID STDCALL KeInitializeMutex (PKMUTEX Mutex,
|
||||
ULONG Level);
|
||||
|
||||
|
@ -139,6 +155,10 @@ VOID STDCALL KeLeaveCriticalRegion (VOID);
|
|||
|
||||
VOID STDCALL KeLowerIrql (KIRQL NewIrql);
|
||||
|
||||
NTSTATUS STDCALL KePulseEvent (PKEVENT Event,
|
||||
KPRIORITY Increment,
|
||||
BOOLEAN Wait);
|
||||
|
||||
LARGE_INTEGER
|
||||
STDCALL
|
||||
KeQueryPerformanceCounter (
|
||||
|
@ -448,4 +468,11 @@ KfReleaseSpinLock (
|
|||
IN KIRQL NewIrql
|
||||
);
|
||||
|
||||
|
||||
VOID STDCALL KiDeliverApc(ULONG Unknown1,
|
||||
ULONG Unknown2,
|
||||
ULONG Unknown3);
|
||||
|
||||
VOID STDCALL KiDispatchInterrupt(VOID);
|
||||
|
||||
#endif /* __INCLUDE_DDK_KEFUNCS_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: halinit.c,v 1.12 2000/07/01 18:23:06 ekohl Exp $
|
||||
/* $Id: halinit.c,v 1.13 2000/07/10 21:49:29 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/hal.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
|
||||
#define NDEBUG
|
||||
|
@ -32,9 +31,6 @@ HalInitSystem (
|
|||
{
|
||||
HalInitializeDisplay (LoaderBlock);
|
||||
HalpCalibrateStallExecution ();
|
||||
KeInitExceptions ();
|
||||
HalpInitIRQs ();
|
||||
KeLowerIrql(DISPATCH_LEVEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -92,7 +92,7 @@ static VOID HiSwitchIrql(KIRQL oldIrql)
|
|||
{
|
||||
KeSetCurrentIrql(DISPATCH_LEVEL);
|
||||
__asm__("sti\n\t");
|
||||
KeDrainDpcQueue();
|
||||
KiDispatchInterrupt();
|
||||
__asm__("cli\n\t");
|
||||
KeSetCurrentIrql(PASSIVE_LEVEL);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ static VOID HiSwitchIrql(KIRQL oldIrql)
|
|||
{
|
||||
KeSetCurrentIrql(APC_LEVEL);
|
||||
__asm__("sti\n\t");
|
||||
KeCallApcsThread();
|
||||
KiDeliverApc(0, 0, 0);
|
||||
__asm__("cli\n\t");
|
||||
KeSetCurrentIrql(PASSIVE_LEVEL);
|
||||
__asm__("sti\n\t");
|
||||
|
|
|
@ -1,205 +0,0 @@
|
|||
.file "irql.c"
|
||||
gcc2_compiled.:
|
||||
___gnu_compiled_c:
|
||||
.globl _CurrentIrql
|
||||
.data
|
||||
_CurrentIrql:
|
||||
.byte 19
|
||||
.text
|
||||
.p2align 2
|
||||
_pic_get_current_mask:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
/APP
|
||||
inb $33,%al
|
||||
outb %al,$0x80
|
||||
inb $161,%al
|
||||
outb %al,$0x80
|
||||
/NO_APP
|
||||
leave
|
||||
ret
|
||||
.p2align 2
|
||||
_pic_set_current_mask:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
movl 8(%ebp),%eax
|
||||
/APP
|
||||
outb %al,$33
|
||||
outb %al,$0x80
|
||||
/NO_APP
|
||||
shrl $8,%eax
|
||||
/APP
|
||||
outb %al,$161
|
||||
outb %al,$0x80
|
||||
/NO_APP
|
||||
leave
|
||||
ret
|
||||
.p2align 2
|
||||
_switch_irql:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $4,%esp
|
||||
pushl %ebx
|
||||
movb _CurrentIrql,%al
|
||||
cmpb $19,%al
|
||||
jne L62
|
||||
pushl $65535
|
||||
call _pic_set_current_mask
|
||||
jmp L61
|
||||
.align 2,0x90
|
||||
L62:
|
||||
cmpb $2,%al
|
||||
jbe L71
|
||||
movl $0,-4(%ebp)
|
||||
movzbl _CurrentIrql,%eax
|
||||
leal -2(%eax),%edx
|
||||
cmpl $2,%edx
|
||||
jbe L65
|
||||
movl $16,%ebx
|
||||
leal -4(%ebp),%ecx
|
||||
.align 2,0x90
|
||||
L67:
|
||||
movl %ebx,%eax
|
||||
subl %edx,%eax
|
||||
/APP
|
||||
btsl %eax,(%ecx)
|
||||
sbbl %eax,%eax
|
||||
/NO_APP
|
||||
decl %edx
|
||||
cmpl $2,%edx
|
||||
ja L67
|
||||
L65:
|
||||
pushl -4(%ebp)
|
||||
call _pic_set_current_mask
|
||||
/APP
|
||||
sti
|
||||
|
||||
/NO_APP
|
||||
jmp L61
|
||||
.align 2,0x90
|
||||
L71:
|
||||
pushl $0
|
||||
call _pic_set_current_mask
|
||||
/APP
|
||||
sti
|
||||
|
||||
/NO_APP
|
||||
L61:
|
||||
movl -8(%ebp),%ebx
|
||||
leave
|
||||
ret
|
||||
.p2align 2
|
||||
.globl _KeSetCurrentIrql
|
||||
_KeSetCurrentIrql:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
movl 8(%ebp),%eax
|
||||
movb %al,_CurrentIrql
|
||||
leave
|
||||
ret
|
||||
.p2align 2
|
||||
.globl _KeGetCurrentIrql
|
||||
_KeGetCurrentIrql:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
movzbl _CurrentIrql,%eax
|
||||
leave
|
||||
ret
|
||||
LC0:
|
||||
.ascii "irql.c\0"
|
||||
LC1:
|
||||
.ascii "(%s:%d) \0"
|
||||
LC2:
|
||||
.ascii "NewIrql %x CurrentIrql %x\12\0"
|
||||
LC3:
|
||||
.ascii "Assertion NewIrql <= CurrentIrql failed at %s:%d\12\0"
|
||||
.p2align 2
|
||||
.globl _KeLowerIrql
|
||||
_KeLowerIrql:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
pushl %ebx
|
||||
movb 8(%ebp),%bl
|
||||
/APP
|
||||
cli
|
||||
|
||||
/NO_APP
|
||||
pushl $103
|
||||
pushl $LC0
|
||||
pushl $LC1
|
||||
call _printk
|
||||
movzbl _CurrentIrql,%eax
|
||||
pushl %eax
|
||||
movzbl %bl,%eax
|
||||
pushl %eax
|
||||
pushl $LC2
|
||||
call _printk
|
||||
addl $24,%esp
|
||||
cmpb %bl,_CurrentIrql
|
||||
jae L79
|
||||
pushl $104
|
||||
pushl $LC0
|
||||
pushl $LC3
|
||||
call _printk
|
||||
.align 2,0x90
|
||||
L82:
|
||||
jmp L82
|
||||
.align 2,0x90
|
||||
L79:
|
||||
movb %bl,_CurrentIrql
|
||||
call _switch_irql
|
||||
movl -4(%ebp),%ebx
|
||||
leave
|
||||
ret
|
||||
LC4:
|
||||
.ascii "%s:%d\12\0"
|
||||
LC5:
|
||||
.ascii "NewIrql %x OldIrql %x CurrentIrql %x\12\0"
|
||||
.p2align 2
|
||||
.globl _KeRaiseIrql
|
||||
_KeRaiseIrql:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
movl 12(%ebp),%esi
|
||||
movb 8(%ebp),%al
|
||||
cmpb %al,_CurrentIrql
|
||||
jbe L84
|
||||
pushl $122
|
||||
pushl $LC0
|
||||
pushl $LC4
|
||||
call _printk
|
||||
.align 2,0x90
|
||||
L87:
|
||||
jmp L87
|
||||
.align 2,0x90
|
||||
L84:
|
||||
/APP
|
||||
cli
|
||||
|
||||
/NO_APP
|
||||
movzbl %al,%ebx
|
||||
pushl %ebx
|
||||
pushl $_CurrentIrql
|
||||
call _InterlockedExchange
|
||||
movb %al,(%esi)
|
||||
pushl $129
|
||||
pushl $LC0
|
||||
pushl $LC1
|
||||
call _printk
|
||||
movzbl _CurrentIrql,%eax
|
||||
pushl %eax
|
||||
movzbl (%esi),%eax
|
||||
pushl %eax
|
||||
pushl %ebx
|
||||
pushl $LC5
|
||||
call _printk
|
||||
addl $28,%esp
|
||||
call _switch_irql
|
||||
leal -8(%ebp),%esp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
leave
|
||||
ret
|
||||
.comm ___ProcessHeap,4
|
|
@ -8,8 +8,6 @@ OBJECTS_HAL = \
|
|||
hal/x86/drive.o \
|
||||
hal/x86/fmutex.o \
|
||||
hal/x86/halinit.o \
|
||||
hal/x86/irq.o \
|
||||
hal/x86/irqhand.o \
|
||||
hal/x86/isa.o \
|
||||
hal/x86/irql.o \
|
||||
hal/x86/kdbg.o \
|
||||
|
@ -26,4 +24,3 @@ OBJECTS_HAL = \
|
|||
hal/x86/sysinfo.o \
|
||||
hal/x86/time.o \
|
||||
hal/x86/udelay.o
|
||||
|
||||
|
|
|
@ -27,14 +27,9 @@ BOOLEAN Hal_bios32_is_service_present(ULONG service);
|
|||
VOID HalInitializeDisplay (PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||
VOID HalResetDisplay (VOID);
|
||||
|
||||
VOID
|
||||
HalpInitBusHandlers (VOID);
|
||||
VOID HalpInitBusHandlers (VOID);
|
||||
|
||||
/* udelay.c */
|
||||
VOID HalpCalibrateStallExecution(VOID);
|
||||
|
||||
/* irq.c */
|
||||
VOID HalpDispatchInterrupt (ULONG irq);
|
||||
VOID HalpInitIRQs (VOID);
|
||||
|
||||
#endif /* __INTERNAL_HAL_HAL_H */
|
||||
|
|
|
@ -69,9 +69,6 @@ VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait);
|
|||
BOOLEAN KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
|
||||
|
||||
VOID KiInterruptDispatch(ULONG irq);
|
||||
VOID KiDispatchInterrupt(ULONG irq);
|
||||
VOID KeDrainApcQueue(VOID);
|
||||
VOID KeDrainDpcQueue(VOID);
|
||||
VOID KeExpireTimers(VOID);
|
||||
NTSTATUS KeAddThreadTimeout(struct _KTHREAD* Thread,
|
||||
PLARGE_INTEGER Interval);
|
||||
|
@ -82,16 +79,13 @@ VOID KeDumpStackFrames(PVOID Stack, ULONG NrFrames);
|
|||
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
|
||||
VOID KeFreeGdtSelector(ULONG Entry);
|
||||
BOOLEAN KiTestAlert(struct _KTHREAD* Thread, PCONTEXT UserContext);
|
||||
VOID KeCallApcsThread(VOID);
|
||||
VOID KeRemoveAllWaitsThread(struct _ETHREAD* Thread, NTSTATUS WaitStatus);
|
||||
PULONG KeGetStackTopThread(struct _ETHREAD* Thread);
|
||||
LONG STDCALL KePulseEvent (PKEVENT Event,
|
||||
KPRIORITY Increment,
|
||||
BOOLEAN Wait);
|
||||
|
||||
/* INITIALIZATION FUNCTIONS *************************************************/
|
||||
|
||||
VOID KeInitExceptions(VOID);
|
||||
VOID KeInitInterrupts(VOID);
|
||||
VOID KeInitTimer(VOID);
|
||||
VOID KeInitDpc(VOID);
|
||||
VOID KeInitDispatcher(VOID);
|
||||
|
@ -99,4 +93,7 @@ VOID KeInitializeDispatcher(VOID);
|
|||
VOID KeInitializeTimerImpl(VOID);
|
||||
VOID KeInitializeBugCheck(VOID);
|
||||
|
||||
VOID KeInit1(VOID);
|
||||
VOID KeInit2(VOID);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -47,8 +47,6 @@ VOID MmInitSystem(ULONG Phase, PLOADER_PARAMETER_BLOCK LoaderBlock, ULONG LastKe
|
|||
VOID IoInit(VOID);
|
||||
VOID ObInit(VOID);
|
||||
VOID PsInit(VOID);
|
||||
VOID TstBegin(VOID);
|
||||
VOID KeInit(VOID);
|
||||
VOID CmInitializeRegistry(VOID);
|
||||
VOID CmImportHive(PCHAR);
|
||||
VOID KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||
|
|
|
@ -115,14 +115,16 @@ BOOLEAN KiTestAlert(PKTHREAD Thread,
|
|||
return ret;
|
||||
}
|
||||
|
||||
VOID KeCallApcsThread(VOID)
|
||||
VOID STDCALL KiDeliverApc(ULONG Unknown1,
|
||||
ULONG Unknown2,
|
||||
ULONG Unknown3)
|
||||
{
|
||||
PETHREAD Thread = PsGetCurrentThread();
|
||||
PLIST_ENTRY current;
|
||||
PKAPC Apc;
|
||||
KIRQL oldlvl;
|
||||
|
||||
DPRINT("KeCallApcsThread()\n");
|
||||
DPRINT("KiDeliverApc()\n");
|
||||
KeAcquireSpinLock(&PiApcLock, &oldlvl);
|
||||
while(!IsListEmpty(&(Thread->Tcb.ApcState.ApcListHead[0])))
|
||||
{
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/dispatch.c
|
||||
* PURPOSE: Handles a dispatch interrupt
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/ps.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
VOID KiDispatchInterrupt(ULONG irq)
|
||||
/*
|
||||
* FUNCTION: Called after an irq when the interrupted processor was at a lower
|
||||
* level than DISPATCH_LEVEL
|
||||
*/
|
||||
{
|
||||
if (irq == 0)
|
||||
{
|
||||
KeExpireTimers();
|
||||
}
|
||||
KeDrainDpcQueue();
|
||||
PsDispatchThread(THREAD_STATE_RUNNABLE);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: dpc.c,v 1.17 2000/07/04 08:52:39 dwelch Exp $
|
||||
/* $Id: dpc.c,v 1.18 2000/07/10 21:54:19 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -50,7 +50,7 @@ VOID STDCALL KeInitializeDpc (PKDPC Dpc,
|
|||
Dpc->Lock=0;
|
||||
}
|
||||
|
||||
VOID KeDrainDpcQueue(VOID)
|
||||
VOID STDCALL KiDispatchInterrupt(VOID)
|
||||
/*
|
||||
* FUNCTION: Called to execute queued dpcs
|
||||
*/
|
||||
|
@ -65,7 +65,7 @@ VOID KeDrainDpcQueue(VOID)
|
|||
{
|
||||
return;
|
||||
}
|
||||
DPRINT("KeDrainDpcQueue()\n");
|
||||
DPRINT("KiDispatchInterrupt()\n");
|
||||
|
||||
KeRaiseIrql(HIGH_LEVEL, &oldlvl);
|
||||
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
|
||||
|
|
|
@ -75,9 +75,9 @@ LONG STDCALL KeSetEvent (PKEVENT Event,
|
|||
return(ret);
|
||||
}
|
||||
|
||||
LONG STDCALL KePulseEvent (PKEVENT Event,
|
||||
KPRIORITY Increment,
|
||||
BOOLEAN Wait)
|
||||
NTSTATUS STDCALL KePulseEvent (PKEVENT Event,
|
||||
KPRIORITY Increment,
|
||||
BOOLEAN Wait)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -87,7 +87,7 @@ LONG STDCALL KePulseEvent (PKEVENT Event,
|
|||
KeDispatcherObjectWake((DISPATCHER_HEADER *)Event);
|
||||
InterlockedExchange(&(Event->Header.SignalState),0);
|
||||
KeReleaseDispatcherDatabaseLock(Wait);
|
||||
return(ret);
|
||||
return((NTSTATUS)ret);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* $Id: irq.c,v 1.15 2000/07/04 08:52:37 dwelch Exp $
|
||||
/* $Id: irq.c,v 1.1 2000/07/10 21:54:51 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/hal/x86/irq.c
|
||||
* FILE: ntoskrnl/ke/i386/irq.c
|
||||
* PURPOSE: IRQ handling
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
|
@ -20,16 +20,10 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/stddef.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
#include <internal/ps.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/halio.h>
|
||||
#include <internal/hal.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -81,18 +75,44 @@ static unsigned int irq_handler[NR_IRQS]=
|
|||
* NOTE: The data in this table is only modified at passsive level but can
|
||||
* be accessed at any irq level.
|
||||
*/
|
||||
|
||||
static LIST_ENTRY isr_table[NR_IRQS]={{NULL,NULL},};
|
||||
static PKSPIN_LOCK isr_lock[NR_IRQS] = {NULL,};
|
||||
static KSPIN_LOCK isr_table_lock = {0,};
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
#define PRESENT (0x8000)
|
||||
#define I486_INTERRUPT_GATE (0xe00)
|
||||
|
||||
VOID KeInitInterrupts (VOID)
|
||||
{
|
||||
int i;
|
||||
|
||||
VOID HalpDispatchInterrupt (ULONG irq)
|
||||
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
|
||||
*/
|
||||
for (i=0;i<NR_IRQS;i++)
|
||||
{
|
||||
KiIdt[IRQ_BASE+i].a=(irq_handler[i]&0xffff)+(KERNEL_CS<<16);
|
||||
KiIdt[IRQ_BASE+i].b=(irq_handler[i]&0xffff0000)+PRESENT+
|
||||
I486_INTERRUPT_GATE;
|
||||
InitializeListHead(&isr_table[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID KiInterruptDispatch (ULONG irq)
|
||||
/*
|
||||
* FUNCTION: Calls the irq specific handler for an irq
|
||||
* ARGUMENTS:
|
||||
|
@ -127,8 +147,7 @@ VOID HalpDispatchInterrupt (ULONG irq)
|
|||
}
|
||||
else
|
||||
{
|
||||
DPRINT("HalpDispatchInterrupt(irq %d)\n",irq);
|
||||
// KiInterruptDispatch (irq);
|
||||
DPRINT("KiInterruptDispatch(irq %d)\n",irq);
|
||||
/*
|
||||
* Iterate the list until one of the isr tells us its device interrupted
|
||||
*/
|
||||
|
@ -178,7 +197,13 @@ VOID HalpDispatchInterrupt (ULONG irq)
|
|||
{
|
||||
KeSetCurrentIrql(DISPATCH_LEVEL);
|
||||
__asm__("sti\n\t");
|
||||
KiDispatchInterrupt(irq);
|
||||
|
||||
if (irq == 0)
|
||||
{
|
||||
KeExpireTimers();
|
||||
}
|
||||
KiDispatchInterrupt();
|
||||
PsDispatchThread(THREAD_STATE_RUNNABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -188,30 +213,6 @@ VOID HalpDispatchInterrupt (ULONG irq)
|
|||
// DbgPrint("}");
|
||||
}
|
||||
|
||||
VOID HalpInitIRQs (VOID)
|
||||
{
|
||||
int i;
|
||||
|
||||
DPRINT("HalpInitIRQs ()\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
|
||||
*/
|
||||
for (i=0;i<NR_IRQS;i++)
|
||||
{
|
||||
KiIdt[IRQ_BASE+i].a=(irq_handler[i]&0xffff)+(KERNEL_CS<<16);
|
||||
KiIdt[IRQ_BASE+i].b=(irq_handler[i]&0xffff0000)+PRESENT+
|
||||
I486_INTERRUPT_GATE;
|
||||
InitializeListHead(&isr_table[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID KeDumpIrqList(VOID)
|
||||
{
|
||||
|
@ -234,6 +235,108 @@ static VOID KeDumpIrqList(VOID)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
KeConnectInterrupt(PKINTERRUPT InterruptObject)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
KIRQL synch_oldlvl;
|
||||
PKINTERRUPT ListHead;
|
||||
ULONG Vector;
|
||||
|
||||
DPRINT("KeConnectInterrupt()\n");
|
||||
|
||||
Vector = InterruptObject->Vector;
|
||||
|
||||
/*
|
||||
* Acquire the table spinlock
|
||||
*/
|
||||
KeAcquireSpinLock(&isr_table_lock,&oldlvl);
|
||||
|
||||
/*
|
||||
* Check if the vector is already in use that we can share it
|
||||
*/
|
||||
ListHead = CONTAINING_RECORD(isr_table[Vector].Flink,KINTERRUPT,Entry);
|
||||
if (!IsListEmpty(&isr_table[Vector]) &&
|
||||
(InterruptObject->Shareable == FALSE || ListHead->Shareable==FALSE))
|
||||
{
|
||||
KeReleaseSpinLock(&isr_table_lock,oldlvl);
|
||||
return(STATUS_INVALID_PARAMETER);
|
||||
}
|
||||
else
|
||||
{
|
||||
isr_lock[Vector]=ExAllocatePool(NonPagedPool,sizeof(KSPIN_LOCK));
|
||||
KeInitializeSpinLock(isr_lock[Vector]);
|
||||
}
|
||||
|
||||
InterruptObject->IrqLock = isr_lock[Vector];
|
||||
|
||||
KeRaiseIrql(InterruptObject->SynchLevel,&synch_oldlvl);
|
||||
KeAcquireSpinLockAtDpcLevel(InterruptObject->IrqLock);
|
||||
DPRINT("%x %x\n",isr_table[Vector].Flink,isr_table[Vector].Blink);
|
||||
InsertTailList(&isr_table[Vector],&InterruptObject->Entry);
|
||||
DPRINT("%x %x\n",InterruptObject->Entry.Flink,
|
||||
InterruptObject->Entry.Blink);
|
||||
KeReleaseSpinLockFromDpcLevel(InterruptObject->IrqLock);
|
||||
KeLowerIrql(synch_oldlvl);
|
||||
|
||||
/*
|
||||
* Release the table spinlock
|
||||
*/
|
||||
KeReleaseSpinLock(&isr_table_lock,oldlvl);
|
||||
|
||||
KeDumpIrqList();
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
KeDisconnectInterrupt(PKINTERRUPT InterruptObject)
|
||||
/*
|
||||
* FUNCTION: Releases a drivers isr
|
||||
* ARGUMENTS:
|
||||
* InterruptObject = isr to release
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
||||
KeRaiseIrql(InterruptObject->SynchLevel,&oldlvl);
|
||||
KeAcquireSpinLockAtDpcLevel(InterruptObject->IrqLock);
|
||||
RemoveEntryList(&InterruptObject->Entry);
|
||||
KeReleaseSpinLockFromDpcLevel(InterruptObject->IrqLock);
|
||||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
KeInitializeInterrupt(PKINTERRUPT InterruptObject,
|
||||
PKSERVICE_ROUTINE ServiceRoutine,
|
||||
PVOID ServiceContext,
|
||||
PKSPIN_LOCK SpinLock,
|
||||
ULONG Vector,
|
||||
KIRQL Irql,
|
||||
KIRQL SynchronizeIrql,
|
||||
KINTERRUPT_MODE InterruptMode,
|
||||
BOOLEAN ShareVector,
|
||||
KAFFINITY ProcessorEnableMask,
|
||||
BOOLEAN FloatingSave)
|
||||
{
|
||||
InterruptObject->ServiceContext = ServiceContext;
|
||||
InterruptObject->ServiceRoutine = ServiceRoutine;
|
||||
InterruptObject->Vector = Vector;
|
||||
InterruptObject->ProcessorEnableMask = ProcessorEnableMask;
|
||||
InterruptObject->SynchLevel = SynchronizeIrql;
|
||||
InterruptObject->Shareable = ShareVector;
|
||||
InterruptObject->FloatingSave = FALSE;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
IoConnectInterrupt(PKINTERRUPT* InterruptObject,
|
||||
|
@ -275,9 +378,8 @@ IoConnectInterrupt(PKINTERRUPT* InterruptObject,
|
|||
* IRQL: PASSIVE_LEVEL
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
KIRQL synch_oldlvl;
|
||||
PKINTERRUPT ListHead;
|
||||
PKINTERRUPT Interrupt;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
ASSERT_IRQL(PASSIVE_LEVEL);
|
||||
|
||||
|
@ -295,59 +397,40 @@ IoConnectInterrupt(PKINTERRUPT* InterruptObject,
|
|||
return(STATUS_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
/*
|
||||
* Acquire the table spinlock
|
||||
*/
|
||||
KeAcquireSpinLock(&isr_table_lock,&oldlvl);
|
||||
|
||||
/*
|
||||
* Check if the vector is already in use that we can share it
|
||||
*/
|
||||
ListHead = CONTAINING_RECORD(isr_table[Vector].Flink,KINTERRUPT,Entry);
|
||||
if (!IsListEmpty(&isr_table[Vector]) &&
|
||||
(ShareVector == FALSE || ListHead->Shareable==FALSE))
|
||||
{
|
||||
KeReleaseSpinLock(&isr_table_lock,oldlvl);
|
||||
return(STATUS_INVALID_PARAMETER);
|
||||
}
|
||||
else
|
||||
{
|
||||
isr_lock[Vector]=ExAllocatePool(NonPagedPool,sizeof(KSPIN_LOCK));
|
||||
KeInitializeSpinLock(isr_lock[Vector]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize interrupt object
|
||||
*/
|
||||
(*InterruptObject)=ExAllocatePool(NonPagedPool,sizeof(KINTERRUPT));
|
||||
if ((*InterruptObject)==NULL)
|
||||
Interrupt=ExAllocatePool(NonPagedPool,sizeof(KINTERRUPT));
|
||||
if (Interrupt==NULL)
|
||||
{
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
(*InterruptObject)->ServiceContext = ServiceContext;
|
||||
(*InterruptObject)->ServiceRoutine = ServiceRoutine;
|
||||
(*InterruptObject)->Vector = Vector;
|
||||
(*InterruptObject)->ProcessorEnableMask = ProcessorEnableMask;
|
||||
(*InterruptObject)->SynchLevel = SynchronizeIrql;
|
||||
(*InterruptObject)->Shareable = ShareVector;
|
||||
(*InterruptObject)->FloatingSave = FALSE;
|
||||
(*InterruptObject)->IrqLock = isr_lock[Vector];
|
||||
|
||||
KeRaiseIrql((*InterruptObject)->SynchLevel,&synch_oldlvl);
|
||||
KeAcquireSpinLockAtDpcLevel((*InterruptObject)->IrqLock);
|
||||
DPRINT("%x %x\n",isr_table[Vector].Flink,isr_table[Vector].Blink);
|
||||
InsertTailList(&isr_table[Vector],&((*InterruptObject)->Entry));
|
||||
DPRINT("%x %x\n",(*InterruptObject)->Entry.Flink,
|
||||
(*InterruptObject)->Entry.Blink);
|
||||
KeReleaseSpinLockFromDpcLevel((*InterruptObject)->IrqLock);
|
||||
KeLowerIrql(synch_oldlvl);
|
||||
Status = KeInitializeInterrupt(Interrupt,
|
||||
ServiceRoutine,
|
||||
ServiceContext,
|
||||
SpinLock,
|
||||
Vector,
|
||||
Irql,
|
||||
SynchronizeIrql,
|
||||
InterruptMode,
|
||||
ShareVector,
|
||||
ProcessorEnableMask,
|
||||
FloatingSave);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePool(Interrupt);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the table spinlock
|
||||
*/
|
||||
KeReleaseSpinLock(&isr_table_lock,oldlvl);
|
||||
Status = KeConnectInterrupt(Interrupt);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePool(Interrupt);
|
||||
return Status;
|
||||
}
|
||||
|
||||
KeDumpIrqList();
|
||||
*InterruptObject = Interrupt;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -362,36 +445,8 @@ IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
|
|||
* InterruptObject = isr to release
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
||||
KeRaiseIrql(InterruptObject->SynchLevel,&oldlvl);
|
||||
KeAcquireSpinLockAtDpcLevel(InterruptObject->IrqLock);
|
||||
RemoveEntryList(&InterruptObject->Entry);
|
||||
KeReleaseSpinLockFromDpcLevel(InterruptObject->IrqLock);
|
||||
KeLowerIrql(oldlvl);
|
||||
KeDisconnectInterrupt(InterruptObject);
|
||||
ExFreePool(InterruptObject);
|
||||
}
|
||||
|
||||
#if 0
|
||||
BOOLEAN
|
||||
STDCALL
|
||||
HalDisableSystemInterrupt (
|
||||
ULONG Vector,
|
||||
KIRQL Irql
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
STDCALL
|
||||
HalEnableSystemInterrupt (
|
||||
ULONG Vector,
|
||||
ULONG Unknown1,
|
||||
ULONG Unknown2
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -3,10 +3,6 @@
|
|||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/mmhal.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
|
||||
#define _STR(x) #x
|
||||
|
@ -28,7 +24,7 @@
|
|||
"orb $1<<"##x",%al\n\t" \
|
||||
"outb %al,$0x21\n\t" \
|
||||
"pushl $"##x"\n\t" \
|
||||
"call _HalpDispatchInterrupt\n\t"\
|
||||
"call _KiInterruptDispatch\n\t"\
|
||||
"popl %eax\n\t" \
|
||||
"popl %eax\n\t" \
|
||||
"popl %es\n\t" \
|
||||
|
@ -51,7 +47,7 @@
|
|||
"orb $1<<("##x"-8),%al\n\t" \
|
||||
"outb %al,$0xa1\n\t" \
|
||||
"pushl $"##x"\n\t" \
|
||||
"call _HalpDispatchInterrupt\n\t"\
|
||||
"call _KiInterruptDispatch\n\t"\
|
||||
"popl %eax\n\t" \
|
||||
"popl %eax\n\t" \
|
||||
"popl %es\n\t" \
|
|
@ -18,15 +18,16 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID KeInit(VOID)
|
||||
VOID KeInit1(VOID)
|
||||
{
|
||||
KeInitExceptions ();
|
||||
KeInitInterrupts ();
|
||||
}
|
||||
|
||||
VOID KeInit2(VOID)
|
||||
{
|
||||
KeInitDpc();
|
||||
KeInitializeBugCheck();
|
||||
KeInitializeDispatcher();
|
||||
KeInitializeTimerImpl();
|
||||
|
||||
/*
|
||||
* Allow interrupts
|
||||
*/
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: main.c,v 1.54 2000/07/08 18:47:57 ekohl Exp $
|
||||
/* $Id: main.c,v 1.55 2000/07/10 21:54:19 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -22,6 +22,7 @@
|
|||
#include <internal/ex.h>
|
||||
#include <internal/ps.h>
|
||||
#include <internal/hal.h>
|
||||
#include <internal/ke.h>
|
||||
|
||||
#include <internal/mmhal.h>
|
||||
#include <internal/i386/segment.h>
|
||||
|
@ -82,6 +83,8 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
* Initialization phase 0
|
||||
*/
|
||||
HalInitSystem (0, &KeLoaderBlock);
|
||||
KeInit1();
|
||||
KeLowerIrql(DISPATCH_LEVEL);
|
||||
|
||||
/*
|
||||
* Display version number and copyright/warranty message
|
||||
|
@ -117,7 +120,13 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
*/
|
||||
HalInitSystem (1, &KeLoaderBlock);
|
||||
MmInit2();
|
||||
KeInit();
|
||||
KeInit2();
|
||||
|
||||
/*
|
||||
* Allow interrupts
|
||||
*/
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
|
||||
ExInit();
|
||||
ObInit();
|
||||
PiInitProcessManager();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile_rex,v 1.81 2000/07/07 10:30:54 dwelch Exp $
|
||||
# $Id: makefile_rex,v 1.82 2000/07/10 21:47:36 ekohl Exp $
|
||||
#
|
||||
# ReactOS Operating System
|
||||
#
|
||||
|
@ -66,7 +66,6 @@ OBJECTS_KE = \
|
|||
ke/bug.o \
|
||||
ke/catch.o \
|
||||
ke/critical.o \
|
||||
ke/dispatch.o \
|
||||
ke/dpc.o \
|
||||
ke/error.o \
|
||||
ke/event.o \
|
||||
|
@ -83,9 +82,10 @@ OBJECTS_KE = \
|
|||
ke/timer.o \
|
||||
ke/wait.o
|
||||
|
||||
|
||||
OBJECTS_KE_I386 = \
|
||||
ke/i386/exp.o \
|
||||
ke/i386/irq.o \
|
||||
ke/i386/irqhand.o \
|
||||
ke/i386/thread.o \
|
||||
ke/i386/usercall.o \
|
||||
ke/i386/trap.o
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.def,v 1.83 2000/07/07 00:39:24 phreak Exp $
|
||||
; $Id: ntoskrnl.def,v 1.84 2000/07/10 21:47:36 ekohl Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -320,12 +320,12 @@ KeBugCheck@4
|
|||
KeBugCheckEx@20
|
||||
KeCancelTimer@4
|
||||
KeClearEvent@4
|
||||
;KeConnectInterrupt
|
||||
KeConnectInterrupt@4
|
||||
;KeDcacheFlushCount DATA
|
||||
KeDelayExecutionThread@12
|
||||
KeDeregisterBugCheckCallback@4
|
||||
KeDetachProcess@0
|
||||
;KeDisconnectInterrupt
|
||||
KeDisconnectInterrupt@4
|
||||
KeEnterCriticalRegion@0
|
||||
KeEnterKernelDebugger@0
|
||||
;KeFindConfigurationEntry
|
||||
|
@ -348,7 +348,7 @@ KeInitializeApc@32
|
|||
KeInitializeDeviceQueue@4
|
||||
KeInitializeDpc@12
|
||||
KeInitializeEvent@12
|
||||
;KeInitializeInterrupt
|
||||
KeInitializeInterrupt@44
|
||||
;KeInitializeMutant
|
||||
KeInitializeMutex@8
|
||||
;KeInitializeQueue
|
||||
|
@ -425,8 +425,8 @@ KeWaitForSingleObject@20
|
|||
;KiAcquireSpinLock@4
|
||||
;KiBugCheckData DATA
|
||||
;KiCoprocessorError@0
|
||||
;KiDeliverApc@12
|
||||
;KiDispatchInterrupt@0
|
||||
KiDeliverApc@12
|
||||
KiDispatchInterrupt@0
|
||||
;KiIpiServiceRoutine@8
|
||||
;KiReleaseSpinLock@4
|
||||
;KiUnexpectedInterrupt
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.edf,v 1.70 2000/07/07 00:39:24 phreak Exp $
|
||||
; $Id: ntoskrnl.edf,v 1.71 2000/07/10 21:47:36 ekohl Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -320,12 +320,12 @@ KeBugCheck=KeBugCheck@4
|
|||
KeBugCheckEx=KeBugCheckEx@20
|
||||
KeCancelTimer=KeCancelTimer@4
|
||||
KeClearEvent=KeClearEvent@4
|
||||
;KeConnectInterrupt
|
||||
KeConnectInterrupt=KeConnectInterrupt@4
|
||||
;KeDcacheFlushCount DATA
|
||||
KeDelayExecutionThread=KeDelayExecutionThread@12
|
||||
KeDeregisterBugCheckCallback=KeDeregisterBugCheckCallback@4
|
||||
KeDetachProcess=KeDetachProcess@0
|
||||
;KeDisconnectInterrupt
|
||||
KeDisconnectInterrupt=KeDisconnectInterrupt@4
|
||||
KeEnterCriticalRegion=KeEnterCriticalRegion@0
|
||||
KeEnterKernelDebugger=KeEnterKernelDebugger@0
|
||||
;KeFindConfigurationEntry
|
||||
|
@ -348,7 +348,7 @@ KeInitializeApc=KeInitializeApc@32
|
|||
KeInitializeDeviceQueue=KeInitializeDeviceQueue@4
|
||||
KeInitializeDpc=KeInitializeDpc@12
|
||||
KeInitializeEvent=KeInitializeEvent@12
|
||||
;KeInitializeInterrupt
|
||||
KeInitializeInterrupt=KeInitializeInterrupt@44
|
||||
;KeInitializeMutant
|
||||
KeInitializeMutex=KeInitializeMutex@8
|
||||
;KeInitializeQueue
|
||||
|
@ -425,8 +425,8 @@ KeWaitForSingleObject=KeWaitForSingleObject@20
|
|||
;KiAcquireSpinLock@4
|
||||
;KiBugCheckData DATA
|
||||
;KiCoprocessorError@0
|
||||
;KiDeliverApc@12
|
||||
;KiDispatchInterrupt@0
|
||||
KiDeliverApc=KiDeliverApc@12
|
||||
KiDispatchInterrupt=KiDispatchInterrupt@0
|
||||
;KiIpiServiceRoutine@8
|
||||
;KiReleaseSpinLock@4
|
||||
;KiUnexpectedInterrupt
|
||||
|
|
|
@ -37,7 +37,7 @@ static NTSTATUS PsIdleThreadMain(PVOID Context)
|
|||
if (DpcQueueSize > 0)
|
||||
{
|
||||
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
|
||||
KeDrainDpcQueue();
|
||||
KiDispatchInterrupt();
|
||||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
NtYieldExecution();
|
||||
|
|
Loading…
Reference in a new issue