* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: syscall.S,v 1.15 2004/07/01 01:52:37 royce Exp $
+/* $Id: syscall.S,v 1.16 2004/07/02 00:47:57 royce Exp $
*
* FILE: ntoskrnl/hal/x86/syscall.s
* PURPOSE: 2E trap handler
pushl $0 /* XXX: TempCS */
pushl $0 /* XXX: DebugPointer */
pushl $0 /* XXX: DebugArgMark */
+
#ifdef DBG
/* Trick gdb 6 into backtracing over the system call */
movl 4(%ebp), %ebx
movl %ebx, KTHREAD_TRAP_FRAME(%esi)
KiRosTrapReturn:
+
+#if 0
+ mov KTRAP_FRAME_RESERVED1(%ebp), %ax
+ cmp %ax, SSIDX_NTCONTINUE
+ jnz KeNoEpilogPrint
+ movl KTRAP_FRAME_ESP(%ebp), %ecx
+ movl KTRAP_FRAME_EBP(%ebp), %edx
+ call @KeRosPrintEspEbp@8
+KeNoEpilogPrint:
+#endif
+
/* Skip debug information and unsaved registers */
addl $0x30, %esp
popl %gs
*/
.globl @KeRosTrapReturn@8
@KeRosTrapReturn@8:
+
+ /* point %esp to the trap frame to restore */
+ movl %ecx, %esp
+ movl %esp, %ebp
+
/* Call the post system call hook and deliver any pending APCs */
pushl %esp
call _KiAfterSystemCallHook
/* Restore the old trap frame pointer */
movl %edx, KTHREAD_TRAP_FRAME(%esi)
- /* point %esp to the trap frame to restore */
- movl %ecx, %esp
jmp KiRosTrapReturn;
--- /dev/null
+/* $Id: continue.c,v 1.1 2004/07/02 00:47:57 royce Exp $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/ps/i386/continue.c
+ * PURPOSE: i386 implementation of NtContinue()
+ * PROGRAMMER: Royce Mitchell III, kjk_hyperion
+ * REVISION HISTORY:
+ * 29/06/04: Created
+ */
+
+/* INCLUDES ****************************************************************/
+
+#include <ddk/ntddk.h>
+#include <internal/ke.h>
+#include <internal/ob.h>
+#include <internal/ps.h>
+#include <internal/ob.h>
+#include <internal/pool.h>
+#include <ntos/minmax.h>
+#include <internal/ldr.h>
+#include <rosrtl/string.h>
+
+#define NDEBUG
+#include <internal/debug.h>
+
+#if 1
+VOID
+FASTCALL
+KeRosTrapReturn ( PKTRAP_FRAME TrapFrame, PKTRAP_FRAME PrevTrapFrame );
+
+VOID STDCALL
+KeRosDumpStackFrames ( PULONG Frame, ULONG FrameCount );
+
+/*
+ * @implemented
+ */
+NTSTATUS STDCALL
+NtContinue (
+ IN PCONTEXT Context,
+ IN BOOLEAN TestAlert)
+{
+ PKTRAP_FRAME TrapFrame = KeGetCurrentThread()->TrapFrame;
+ PKTRAP_FRAME PrevTrapFrame = (PKTRAP_FRAME)TrapFrame->Edx;
+
+ DPRINT1("NtContinue: Context: Eip=0x%x, Esp=0x%x\n", Context->Eip, Context->Esp );
+ PULONG Frame = 0;
+ __asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
+ DbgPrint ( "NtContinue(): Ebp=%x, prev/TF=%x/%x\n", Frame, Frame[0], TrapFrame );
+ KeRosDumpStackFrames(NULL,5);
+
+ if ( Context == NULL )
+ {
+ DPRINT1("NtContinue called with NULL Context\n");
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ if ( TrapFrame == NULL )
+ {
+ CPRINT("NtContinue called but TrapFrame was NULL\n");
+ KEBUGCHECK(0);
+ }
+
+ /*
+ * Copy the supplied context over the register information that was saved
+ * on entry to kernel mode, it will then be restored on exit
+ * FIXME: Validate the context
+ */
+ KeContextToTrapFrame ( Context, TrapFrame );
+
+ KeRosTrapReturn ( TrapFrame, PrevTrapFrame );
+
+ return STATUS_SUCCESS; /* this doesn't actually happen b/c KeRosTrapReturn() won't return */
+}
+#else
+NTSTATUS STDCALL
+NtContinue (
+ IN PCONTEXT Context,
+ IN BOOLEAN TestAlert)
+{
+ PKTRAP_FRAME TrapFrame = KeGetCurrentThread()->TrapFrame;
+ PULONG Frame = 0;
+ __asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
+ DbgPrint ( "NtContinue(): Ebp=%x, prev/TF=%x/%x\n", Frame, Frame[0], TrapFrame );
+
+ /*
+ * Copy the supplied context over the register information that was saved
+ * on entry to kernel mode, it will then be restored on exit
+ * FIXME: Validate the context
+ */
+ if ( TrapFrame == NULL )
+ {
+ CPRINT("NtContinue called but TrapFrame was NULL\n");
+ KEBUGCHECK(0);
+ }
+ KeContextToTrapFrame ( Context, TrapFrame );
+ return(STATUS_SUCCESS);
+}
+#endif
-/* $Id: thread.c,v 1.125 2004/07/01 02:40:23 hyperion Exp $
+/* $Id: thread.c,v 1.126 2004/07/02 00:47:57 royce Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/thread.c
* PURPOSE: Thread managment
* PROGRAMMER: David Welch (welch@mcmail.com)
- * REVISION HISTORY:
+ * REVISION HISTORY:
* 23/06/98: Created
* 12/10/99: Phillip Susi: Thread priorities, and APC work
*/
/*
* NOTE:
- *
+ *
* All of the routines that manipulate the thread queue synchronize on
* a single spinlock
- *
+ *
*/
/* INCLUDES ****************************************************************/
return(PsGetCurrentThread()->Cid.UniqueThread);
}
-static VOID
+static VOID
PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
{
assert(THREAD_STATE_READY == Thread->Tcb.State);
PETHREAD current;
ULONG t;
ULONG i;
-
+
current_entry = PiThreadListHead.Flink;
t = 0;
-
+
while (current_entry != &PiThreadListHead)
{
PULONG Ebp;
PULONG Esp;
- current = CONTAINING_RECORD(current_entry, ETHREAD,
+ current = CONTAINING_RECORD(current_entry, ETHREAD,
Tcb.ThreadListEntry);
t++;
if (t > PiNrThreads)
if (IncludeSystem || current->ThreadsProcess->UniqueProcessId >= 6)
{
DbgPrint("current->Tcb.State %d PID.TID %d.%d Name %.8s Stack: \n",
- current->Tcb.State,
+ current->Tcb.State,
current->ThreadsProcess->UniqueProcessId,
- current->Cid.UniqueThread,
+ current->Cid.UniqueThread,
current->ThreadsProcess->ImageFileName);
if (current->Tcb.State == THREAD_STATE_READY ||
current->Tcb.State == THREAD_STATE_SUSPENDED ||
DPRINT("PsDispatchThread() %d/%d/%d/%d\n", KeGetCurrentProcessorNumber(),
CurrentThread->Cid.UniqueThread, NewThreadStatus, CurrentThread->Tcb.State);
-
+
CurrentThread->Tcb.State = (UCHAR)NewThreadStatus;
if (CurrentThread->Tcb.State == THREAD_STATE_READY)
{
{
PiNrThreadsAwaitingReaping++;
}
-
+
Affinity = 1 << KeGetCurrentProcessorNumber();
for (CurrentPriority = HIGH_PRIORITY;
CurrentPriority >= LOW_PRIORITY;
PETHREAD OldThread;
DPRINT("Scheduling %x(%d)\n",Candidate, CurrentPriority);
-
+
Candidate->Tcb.State = THREAD_STATE_RUNNING;
-
+
OldThread = CurrentThread;
CurrentThread = Candidate;
-#if 0
+#if 0
/*
* This code is moved to the end of KiArchContextSwitch.
* It should be execute after the context switch.
{
PiWakeupReaperThread();
}
-#endif
+#endif
KiArchContextSwitch(&CurrentThread->Tcb, &OldThread->Tcb);
return;
}
PsDispatchThread(ULONG NewThreadStatus)
{
KIRQL oldIrql;
-
+
if (!DoneInitYet)
{
return;
}
-
+
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
/*
* Save wait IRQL
VOID
PsFreezeAllThreads(PEPROCESS Process)
/*
- * Used by the debugging code to freeze all the process's threads
- * while the debugger is examining their state.
+ * Used by the debugging code to freeze all the process's threads
+ * while the debugger is examining their state.
*/
{
KIRQL oldIrql;
current_entry = Process->ThreadListHead.Flink;
while (current_entry != &Process->ThreadListHead)
{
- current = CONTAINING_RECORD(current_entry, ETHREAD,
+ current = CONTAINING_RECORD(current_entry, ETHREAD,
Tcb.ProcessThreadListEntry);
/*
current_entry = current_entry->Flink;
}
-
+
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
}
VOID
PsApplicationProcessorInit(VOID)
{
- ((PIKPCR) KeGetCurrentKPCR())->CurrentThread =
+ ((PIKPCR) KeGetCurrentKPCR())->CurrentThread =
(PVOID)IdleThreads[KeGetCurrentProcessorNumber()];
}
&IdleThread,
&IdleThreadHandle,
THREAD_ALL_ACCESS,
- NULL,
+ NULL,
TRUE);
IdleThread->Tcb.State = THREAD_STATE_RUNNING;
IdleThread->Tcb.FreezeCount = 0;
ULONG i;
HANDLE FirstThreadHandle;
NTSTATUS Status;
-
+
KeInitializeSpinLock(&PiThreadListLock);
for (i=0; i < MAXIMUM_PRIORITY; i++)
{
}
InitializeListHead(&PiThreadListHead);
-
+
PsThreadType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
-
+
PsThreadType->Tag = TAG('T', 'H', 'R', 'T');
PsThreadType->TotalObjects = 0;
PsThreadType->TotalHandles = 0;
PsThreadType->OkayToClose = NULL;
PsThreadType->Create = NULL;
PsThreadType->DuplicationNotify = NULL;
-
+
RtlRosInitUnicodeStringFromLiteral(&PsThreadType->TypeName, L"Thread");
-
+
ObpCreateTypeObject(PsThreadType);
PsInitializeThread(NULL,&FirstThread,&FirstThreadHandle,
FirstThread->Tcb.FreezeCount = 0;
((PIKPCR) KeGetCurrentKPCR())->CurrentThread = (PVOID)FirstThread;
NtClose(FirstThreadHandle);
-
+
DPRINT("FirstThread %x\n",FirstThread);
-
+
DoneInitYet = TRUE;
/*
KIRQL oldIrql;
PKTHREAD CurrentThread;
ULONG Mask;
-
+
if (Priority < LOW_PRIORITY || Priority >= MAXIMUM_PRIORITY)
{
KEBUGCHECK(0);
}
-
+
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
OldPriority = Thread->Priority;
PETHREAD Thread;
NTSTATUS Status;
NTSTATUS ThreadStatus;
-
+
Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_SUSPEND_RESUME,
PsThreadType,
{
return(Status);
}
-
+
ThreadStatus = STATUS_ALERTED;
(VOID)PsUnblockThread(Thread, &ThreadStatus);
-
+
ObDereferenceObject(Thread);
return(STATUS_SUCCESS);
}
return(Status);
}
-NTSTATUS STDCALL
-NtContinue(IN PCONTEXT Context,
- IN BOOLEAN TestAlert)
-{
- PKTRAP_FRAME TrapFrame;
-
- /*
- * Copy the supplied context over the register information that was saved
- * on entry to kernel mode, it will then be restored on exit
- * FIXME: Validate the context
- */
- TrapFrame = KeGetCurrentThread()->TrapFrame;
- if (TrapFrame == NULL)
- {
- CPRINT("NtContinue called but TrapFrame was NULL\n");
- KEBUGCHECK(0);
- }
- KeContextToTrapFrame(Context, TrapFrame);
-
- if(TestAlert)
- KiTestAlert();
-
- return(STATUS_SUCCESS);
-}
-
-
NTSTATUS STDCALL
NtYieldExecution(VOID)
{