SMP detection work

Changed initialization back
Changed to NT IRQLs
Check for return from main

svn path=/trunk/; revision=1797
This commit is contained in:
David Welch 2001-04-16 02:02:07 +00:00
parent bdfcd5630a
commit 65b55ec6c6
30 changed files with 1311 additions and 812 deletions

View file

@ -211,29 +211,19 @@ enum
#include <ddk/i386/irql.h> #include <ddk/i386/irql.h>
/* #define PASSIVE_LEVEL 0 // Passive release level
* IRQ levels #define LOW_LEVEL 0 // Lowest interrupt level
*/ #define APC_LEVEL 1 // APC interrupt level
#if 0 #define DISPATCH_LEVEL 2 // Dispatcher level
#define PASSIVE_LEVEL (1) /* timer used for profiling */
#define APC_LEVEL (2) #define PROFILE_LEVEL 27
#define DISPATCH_LEVEL (3) /* Interval clock 1 level - Not used on x86 */
#define FIRST_DEVICE_SPECIFIC_LEVEL (4) #define CLOCK1_LEVEL 28
#define HIGH_LEVEL (FIRST_DEVICE_SPECIFIC_LEVEL + NR_DEVICE_SPECIFIC_LEVELS) #define CLOCK2_LEVEL 28 // Interval clock 2 level
#else #define IPI_LEVEL 29 // Interprocessor interrupt level
/* NT's IRQL */ #define POWER_LEVEL 30 // Power failure level
#define PASSIVE_LEVEL 0 // Passive release level #define HIGH_LEVEL 31 // Highest interrupt level
#define LOW_LEVEL 0 // Lowest interrupt level #define SYNCH_LEVEL (IPI_LEVEL-1) // synchronization level
#define APC_LEVEL 1 // APC interrupt level
#define DISPATCH_LEVEL 2 // Dispatcher level
#define PROFILE_LEVEL 27 // Timer used for profiling
#define CLOCK1_LEVEL 28 // Interval clock 1 level - Not used on x86
#define CLOCK2_LEVEL 28 // Interval clock 2 level
#define IPI_LEVEL 29 // Interprocessor interrupt level
#define POWER_LEVEL 30 // Power failure level
#define HIGH_LEVEL 31 // Highest interrupt level
#define SYNCH_LEVEL (IPI_LEVEL-1) // Synchronization level
#endif
#endif /* __ASM__ */ #endif /* __ASM__ */

View file

@ -9,6 +9,6 @@ mount -t vfat /bochs/10M.vga.dos /mnt/floppy -o loop,offset=8704,rw
./install.sh /mnt/floppy ./install.sh /mnt/floppy
umount /mnt/floppy umount /mnt/floppy
echo "Installing to minix disk." echo "Installing to minix disk."
mount -t minix /bochs/10M.vga.minix /mnt/floppy -o loop,offset=8704,rw #mount -t minix /bochs/10M.vga.minix /mnt/floppy -o loop,offset=8704,rw
./install.sh /mnt/floppy #./install.sh /mnt/floppy
umount /mnt/floppy #umount /mnt/floppy

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.35 2001/04/16 00:48:04 chorns Exp $ # $Id: Makefile,v 1.36 2001/04/16 02:02:03 dwelch Exp $
# #
# ReactOS Operating System # ReactOS Operating System
# #
@ -22,8 +22,12 @@ CONFIG :=
ifeq ($(DBG), 1) ifeq ($(DBG), 1)
CFLAGS_DBG := -g CFLAGS_DBG := -g
CONFIG += DBG CONFIG += DBG
LINKER_SCRIPT := ntoskrnl.lnk
STRIP_FLAGS := -Wl,-s
else else
CFLAGS_DBG := CFLAGS_DBG :=
LINKER_SCRIPT := ntoskrnl.lnk
STRIP_FLAGS := -Wl,-s
endif endif
ifeq ($(KDBG), 1) ifeq ($(KDBG), 1)
@ -52,7 +56,8 @@ all: $(EXE_PREFIX)depends$(EXE_POSTFIX) \
$(OBJECTS_PATH) \ $(OBJECTS_PATH) \
$(TARGETNAME).nostrip.exe \ $(TARGETNAME).nostrip.exe \
$(TARGETNAME).exe \ $(TARGETNAME).exe \
$(TARGETNAME).sym $(TARGETNAME).sym \
$(TARGETNAME).dbg
$(EXE_PREFIX)depends$(EXE_POSTFIX): depends.c $(EXE_PREFIX)depends$(EXE_POSTFIX): depends.c
$(HOST_CC) -o depends$(EXE_POSTFIX) depends.c $(HOST_CC) -o depends$(EXE_POSTFIX) depends.c
@ -519,9 +524,9 @@ $(TARGETNAME).nostrip.exe: $(TARGETNAME).o $(TARGETNAME).a $(IE_DATA)
$(TARGETNAME).o -lgcc $(TARGETNAME).o -lgcc
- $(RM) temp.exp - $(RM) temp.exp
$(TARGETNAME).exe: $(TARGETNAME).o $(TARGETNAME).a $(TARGETNAME).lnk $(TARGETNAME).exe: $(TARGETNAME).o $(TARGETNAME).a $(LINKER_SCRIPT)
$(CC) \ $(CC) \
-Wl,-T,ntoskrnl.lnk \ -Wl,-T,$(LINKER_SCRIPT) \
-nostartfiles -nostdlib \ -nostartfiles -nostdlib \
-mdll \ -mdll \
-o junk.tmp \ -o junk.tmp \
@ -540,7 +545,7 @@ $(TARGETNAME).exe: $(TARGETNAME).o $(TARGETNAME).a $(TARGETNAME).lnk
--kill-at --kill-at
- $(RM) base.tmp - $(RM) base.tmp
$(CC) \ $(CC) \
-Wl,-T,ntoskrnl.lnk -Wl,-s\ -Wl,-T,$(LINKER_SCRIPT) $(STRIP_FLAGS)\
-nostartfiles -nostdlib \ -nostartfiles -nostdlib \
-mdll \ -mdll \
-o $(TARGETNAME).exe \ -o $(TARGETNAME).exe \
@ -552,6 +557,42 @@ $(TARGETNAME).exe: $(TARGETNAME).o $(TARGETNAME).a $(TARGETNAME).lnk
$(TARGETNAME).o -lgcc $(TARGETNAME).o -lgcc
- $(RM) temp.exp - $(RM) temp.exp
$(TARGETNAME).dbg.o: $(TARGETNAME).o
$(STRIP) --strip-debug -o $(TARGETNAME).dbg.o $(TARGETNAME).o
$(TARGETNAME).dbg: $(TARGETNAME).dbg.o $(TARGETNAME).a $(TARGETNAME).dbg.lnk
$(CC) \
-Wl,-T,$(TARGETNAME).dbg.lnk \
-nostartfiles -nostdlib \
-mdll \
-o junk.tmp \
-Wl,--subsystem,native \
-Wl,--image-base,0xc0000000 \
-Wl,--file-alignment,0x1000 \
-Wl,--section-alignment,0x1000 \
-Wl,--base-file,base.tmp \
$(TARGETNAME).dbg.o -lgcc
- $(RM) junk.tmp
$(DLLTOOL) \
--dllname $(TARGETNAME).dbg \
--base-file base.tmp \
--output-exp temp.exp \
--def $(TARGETNAME).edf \
--kill-at
- $(RM) base.tmp
$(CC) \
-Wl,-T,$(TARGETNAME).dbg.lnk \
-nostartfiles -nostdlib \
-mdll \
-o $(TARGETNAME).dbg \
-Wl,--subsystem,native \
-Wl,--image-base,0xc0000000 \
-Wl,--file-alignment,0x1000 \
-Wl,--section-alignment,0x1000 \
-Wl,temp.exp \
$(TARGETNAME).dbg.o -lgcc
- $(RM) temp.exp
$(TARGETNAME).sym: $(TARGETNAME).nostrip.exe $(TARGETNAME).sym: $(TARGETNAME).nostrip.exe
$(NM) --numeric-sort $(TARGETNAME).nostrip.exe > $(TARGETNAME).sym $(NM) --numeric-sort $(TARGETNAME).nostrip.exe > $(TARGETNAME).sym

View file

@ -16,4 +16,4 @@ DBG := 1
# #
# Whether to compile a multiprocessor or single processor version # Whether to compile a multiprocessor or single processor version
# #
MP := 0 MP := 1

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: kdb.c,v 1.2 2001/04/12 00:56:04 dwelch Exp $ /* $Id: kdb.c,v 1.3 2001/04/16 02:02:03 dwelch Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/dbg/kdb.c * FILE: ntoskrnl/dbg/kdb.c
@ -30,6 +30,9 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ke.h> #include <internal/ke.h>
#include <internal/ps.h>
#include <limits.h>
#include <ctype.h>
#include "kdb.h" #include "kdb.h"
#define NDEBUG #define NDEBUG
@ -39,19 +42,124 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
ULONG
DbgContCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
DbgRegsCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
DbgDRegsCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
DbgCRegsCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
DbgBugCheckCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
DbgBackTraceCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
DbgProcessListCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
struct struct
{ {
PCH Name; PCH Name;
ULONG (*Fn)(PKTRAP_FRAME Tf, PCH Args); ULONG (*Fn)(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
} DebuggerCommands[] = { } DebuggerCommands[] = {
{"cont", DbgContCommand}, {"cont", DbgContCommand},
{"regs", DbgRegsCommand}, {"regs", DbgRegsCommand},
{"dregs", DbgDRegsCommand},
{"cregs", DbgCRegsCommand},
{"bugcheck", DbgBugCheckCommand}, {"bugcheck", DbgBugCheckCommand},
{"bt", DbgBackTraceCommand},
{"plist", DbgProcessListCommand},
{NULL, NULL} {NULL, NULL}
}; };
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
/*
* Convert a string to an unsigned long integer.
*
* Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous.
*/
static unsigned long
strtoul(const char *nptr, char **endptr, int base)
{
const char *s = nptr;
unsigned long acc;
int c;
unsigned long cutoff;
int neg = 0, any, cutlim;
/*
* See strtol for comments as to the logic used.
*/
do {
c = *s++;
} while (isspace(c));
if (c == '-')
{
neg = 1;
c = *s++;
}
else if (c == '+')
c = *s++;
if ((base == 0 || base == 16) &&
c == '0' && (*s == 'x' || *s == 'X'))
{
c = s[1];
s += 2;
base = 16;
}
if (base == 0)
base = c == '0' ? 8 : 10;
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
for (acc = 0, any = 0;; c = *s++)
{
if (isdigit(c))
c -= '0';
else if (isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else {
any = 1;
acc *= base;
acc += c;
}
}
if (any < 0)
{
acc = ULONG_MAX;
}
else if (neg)
acc = -acc;
if (endptr != 0)
*endptr = any ? (char *)s - 1 : (char *)nptr;
return acc;
}
char*
strpbrk(const char* s, const char* accept)
{
int i;
for (; (*s) != 0; s++)
{
for (i = 0; accept[i] != 0; i++)
{
if (accept[i] == (*s))
{
return((char *)s);
}
}
}
return(NULL);
}
VOID VOID
KdbGetCommand(PCH Buffer) KdbGetCommand(PCH Buffer)
{ {
@ -76,55 +184,397 @@ KdbGetCommand(PCH Buffer)
} }
ULONG ULONG
DbgContCommnad(PCH Args, PKTRAP_FRAME Tf) DbgProcessListCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
{
extern LIST_ENTRY PsProcessListHead;
PLIST_ENTRY current_entry;
PEPROCESS current;
ULONG i = 1;
if (PsProcessListHead.Flink == NULL)
{
DbgPrint("No processes.\n");
return(1);
}
DbgPrint("Process list: ");
current_entry = PsProcessListHead.Flink;
while (current_entry != &PsProcessListHead)
{
current = CONTAINING_RECORD(current_entry, EPROCESS, ProcessListEntry);
DbgPrint("%d %.8s", current->UniqueProcessId,
current->ImageFileName);
i++;
if ((i % 4) == 0)
{
DbgPrint("\n");
}
current_entry = current_entry->Flink;
}
return(1);
}
VOID
DbgPrintBackTrace(PULONG Frame, ULONG StackBase, ULONG StackLimit)
{
ULONG i = 1;
DbgPrint("Frames: ");
while (Frame != NULL && (ULONG)Frame >= StackLimit &&
(ULONG)Frame < StackBase)
{
DbgPrint("%.8x ", Frame[1]);
Frame = (PULONG)Frame[0];
i++;
}
if ((i % 10) != 0)
{
DbgPrint("\n");
}
}
ULONG
DbgBackTraceCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
{
ULONG StackBase, StackLimit;
extern unsigned int init_stack, init_stack_top;
/* Without an argument we print the current stack. */
if (Argc == 1)
{
if (PsGetCurrentThread() != NULL)
{
StackBase = (ULONG)PsGetCurrentThread()->Tcb.StackBase;
StackLimit = PsGetCurrentThread()->Tcb.StackLimit;
}
else
{
StackBase = (ULONG)&init_stack_top;
StackLimit = (ULONG)&init_stack;
}
DbgPrintBackTrace((PULONG)Tf->Ebp, StackBase, StackLimit);
}
/*
* If there are two arguments and the second begins with a asterik treat it
* as the address of a frame to start printing the back trace from.
*/
else if (Argc == 2 && Argv[1][0] == '*')
{
PULONG Frame;
Frame = (PULONG)strtoul(&Argv[1][1], NULL, 0);
DbgPrintBackTrace(Frame, ULONG_MAX, 0);
}
/*
* Otherwise treat the argument as the id of a thread whose back trace is to
* be printed.
*/
else
{
}
return(1);
}
VOID
DbgPrintCr0(ULONG Cr0)
{
ULONG i;
DbgPrint("CR0:");
if (Cr0 & (1 << 0))
{
DbgPrint(" PE");
}
if (Cr0 & (1 << 1))
{
DbgPrint(" MP");
}
if (Cr0 & (1 << 2))
{
DbgPrint(" EM");
}
if (Cr0 & (1 << 3))
{
DbgPrint(" TS");
}
if (!(Cr0 & (1 << 4)))
{
DbgPrint(" !BIT5");
}
if (Cr0 & (1 << 5))
{
DbgPrint(" NE");
}
for (i = 6; i < 16; i++)
{
if (Cr0 & (1 << i))
{
DbgPrint(" BIT%d", i);
}
}
if (Cr0 & (1 << 16))
{
DbgPrint(" WP");
}
if (Cr0 & (1 << 17))
{
DbgPrint(" BIT17");
}
if (Cr0 & (1 << 18))
{
DbgPrint(" AM");
}
for (i = 19; i < 29; i++)
{
if (Cr0 & (1 << i))
{
DbgPrint(" BIT%d", i);
}
}
if (Cr0 & (1 << 29))
{
DbgPrint(" NW");
}
if (Cr0 & (1 << 30))
{
DbgPrint(" CD");
}
if (Cr0 & (1 << 31))
{
DbgPrint(" PG");
}
DbgPrint("\n");
}
ULONG
DbgCRegsCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
{
ULONG Cr0, Cr1, Cr2, Cr3, Cr4;
ULONG Ldtr;
USHORT Tr;
__asm__ __volatile__ ("movl %%cr0, %0\n\t" : "=d" (Cr0));
/* __asm__ __volatile__ ("movl %%cr1, %0\n\t" : "=d" (Cr1)); */
Cr1 = 0;
__asm__ __volatile__ ("movl %%cr2, %0\n\t" : "=d" (Cr2));
__asm__ __volatile__ ("movl %%cr3, %0\n\t" : "=d" (Cr3));
__asm__ __volatile__ ("movl %%cr4, %0\n\t" : "=d" (Cr4));
__asm__ __volatile__ ("str %0\n\t" : "=d" (Tr));
__asm__ __volatile__ ("sldt %0\n\t" : "=d" (Ldtr));
DbgPrintCr0(Cr0);
DbgPrint("CR1 %.8x CR2 %.8x CR3 %.8x CR4 %.8x TR %.8x LDTR %.8x\n",
Cr1, Cr2, Cr3, Cr4, (ULONG)Tf, Ldtr);
return(1);
}
ULONG
DbgDRegsCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
{
DbgPrint("DR0 %.8x DR1 %.8x DR2 %.8x DR3 %.8x DR6 %.8x DR7 %.8x\n",
Tf->Dr0, Tf->Dr1, Tf->Dr2, Tf->Dr3, Tf->Dr6, Tf->Dr7);
return(1);
}
ULONG
DbgContCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
{ {
/* Not too difficult. */ /* Not too difficult. */
return(0); return(0);
} }
VOID
DbgPrintEflags(ULONG Eflags)
{
DbgPrint("EFLAGS:");
if (Eflags & (1 << 0))
{
DbgPrint(" CF");
}
if (!(Eflags & (1 << 1)))
{
DbgPrint(" !BIT1");
}
if (Eflags & (1 << 2))
{
DbgPrint(" PF");
}
if (Eflags & (1 << 3))
{
DbgPrint(" BIT3");
}
if (Eflags & (1 << 4))
{
DbgPrint(" AF");
}
if (Eflags & (1 << 5))
{
DbgPrint(" BIT5");
}
if (Eflags & (1 << 6))
{
DbgPrint(" ZF");
}
if (Eflags & (1 << 7))
{
DbgPrint(" SF");
}
if (Eflags & (1 << 8))
{
DbgPrint(" TF");
}
if (Eflags & (1 << 9))
{
DbgPrint(" IF");
}
if (Eflags & (1 << 10))
{
DbgPrint(" DF");
}
if (Eflags & (1 << 11))
{
DbgPrint(" OF");
}
if ((Eflags & ((1 << 12) | (1 << 13))) == 0)
{
DbgPrint(" IOPL0");
}
else if ((Eflags & ((1 << 12) | (1 << 13))) == 1)
{
DbgPrint(" IOPL1");
}
else if ((Eflags & ((1 << 12) | (1 << 13))) == 2)
{
DbgPrint(" IOPL2");
}
else if ((Eflags & ((1 << 12) | (1 << 13))) == 3)
{
DbgPrint(" IOPL3");
}
if (Eflags & (1 << 14))
{
DbgPrint(" NT");
}
if (Eflags & (1 << 15))
{
DbgPrint(" BIT15");
}
if (Eflags & (1 << 16))
{
DbgPrint(" RF");
}
if (Eflags & (1 << 17))
{
DbgPrint(" VF");
}
if (Eflags & (1 << 18))
{
DbgPrint(" AC");
}
if (Eflags & (1 << 19))
{
DbgPrint(" VIF");
}
if (Eflags & (1 << 20))
{
DbgPrint(" VIP");
}
if (Eflags & (1 << 21))
{
DbgPrint(" ID");
}
if (Eflags & (1 << 22))
{
DbgPrint(" BIT22");
}
if (Eflags & (1 << 23))
{
DbgPrint(" BIT23");
}
if (Eflags & (1 << 24))
{
DbgPrint(" BIT24");
}
if (Eflags & (1 << 25))
{
DbgPrint(" BIT25");
}
if (Eflags & (1 << 26))
{
DbgPrint(" BIT26");
}
if (Eflags & (1 << 27))
{
DbgPrint(" BIT27");
}
if (Eflags & (1 << 28))
{
DbgPrint(" BIT28");
}
if (Eflags & (1 << 29))
{
DbgPrint(" BIT29");
}
if (Eflags & (1 << 30))
{
DbgPrint(" BIT30");
}
if (Eflags & (1 << 31))
{
DbgPrint(" BIT31");
}
DbgPrint("\n");
}
ULONG ULONG
DbgRegsCommand(PCH Args, PKTRAP_FRAME Tf) DbgRegsCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
{ {
DbgPrint("CS:EIP %.4x:%.8x, EAX %.8x EBX %.8x ECX %.8x EDX %.8x\n", DbgPrint("CS:EIP %.4x:%.8x, EAX %.8x EBX %.8x ECX %.8x EDX %.8x\n",
Tf->Cs, Tf->Eip, Tf->Eax, Tf->Ebx, Tf->Ecx, Tf->Edx); Tf->Cs & 0xFFFF, Tf->Eip, Tf->Eax, Tf->Ebx, Tf->Ecx, Tf->Edx);
DbgPrint("ESI %.8x EDI %.8x EBP %.8x SS:ESP %.4x:%.8x\n", DbgPrint("ESI %.8x EDI %.8x EBP %.8x SS:ESP %.4x:%.8x\n",
Tf->Esi, Tf->Edi, Tf->Ebp, Tf->Ss, Tf->Esp); Tf->Esi, Tf->Edi, Tf->Ebp, Tf->Ss & 0xFFFF, Tf->Esp);
DbgPrintEflags(Tf->Eflags);
return(1); return(1);
} }
ULONG ULONG
DbgBugCheckCommand(PCH Args, PKTRAP_FRAME Tf) DbgBugCheckCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
{ {
KeBugCheck(1); KeBugCheck(1);
return(1); return(1);
} }
VOID ULONG
KdbDoCommand(PCH CommandLine, PKTRAP_FRAME Tf) KdbDoCommand(PCH CommandLine, PKTRAP_FRAME Tf)
{ {
ULONG i; ULONG i;
PCH Next; PCH s1;
PCH s; PCH s;
static PCH Argv[256];
ULONG Argc;
static CHAR OrigCommand[256];
s = strpbrk(CommandLine, "\t "); strcpy(OrigCommand, CommandLine);
if (s != NULL)
Argc = 0;
s = CommandLine;
while ((s1 = strpbrk(s, "\t ")) != NULL)
{ {
*s = 0; Argv[Argc] = s;
Next = s + 1; *s1 = 0;
} s = s1 + 1;
else Argc++;
{
Next = NULL;
} }
Argv[Argc] = s;
Argc++;
for (i = 0; DebuggerCommands[i].Name != NULL; i++) for (i = 0; DebuggerCommands[i].Name != NULL; i++)
{ {
if (strcmp(DebuggerCommands[i], CommandLine) == 0) if (strcmp(DebuggerCommands[i].Name, Argv[0]) == 0)
{ {
return(DebuggerCommands[i](Tf, Next)); return(DebuggerCommands[i].Fn(Argc, Argv, Tf));
} }
} }
DbgPrint("Command '%s %s' is unknown\n", CommandLine, Next); DbgPrint("Command '%s' is unknown.", OrigCommand);
return(1); return(1);
} }
@ -134,6 +584,7 @@ KdbMainLoop(PKTRAP_FRAME Tf)
CHAR Command[256]; CHAR Command[256];
ULONG s; ULONG s;
DbgPrint("\n");
do do
{ {
DbgPrint("kdb:> "); DbgPrint("kdb:> ");

View file

@ -1,4 +1,4 @@
/* $Id: halinit.c,v 1.18 2001/04/13 16:12:25 chorns Exp $ /* $Id: halinit.c,v 1.19 2001/04/16 02:02:04 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -30,8 +30,8 @@ BOOLEAN STDCALL
HalInitSystem (ULONG BootPhase, HalInitSystem (ULONG BootPhase,
PLOADER_PARAMETER_BLOCK LoaderBlock) PLOADER_PARAMETER_BLOCK LoaderBlock)
{ {
if (BootPhase == 0) if (BootPhase == 0)
{ {
HalInitializeDisplay (LoaderBlock); HalInitializeDisplay (LoaderBlock);
#ifdef MP #ifdef MP
@ -47,13 +47,13 @@ HalInitSystem (ULONG BootPhase,
#endif /* MP */ #endif /* MP */
} }
else else
{ {
HalpInitBusHandlers (); HalpInitBusHandlers ();
} }
return TRUE; return TRUE;
} }
/* EOF */ /* EOF */

View file

@ -31,6 +31,9 @@ extern ULONG DpcQueueSize;
static VOID KeSetCurrentIrql(KIRQL newlvl); static VOID KeSetCurrentIrql(KIRQL newlvl);
#define DIRQL_TO_IRQ(x) (PROFILE_LEVEL - x)
#define IRQ_TO_DIRQL(x) (PROFILE_LEVEL - x)
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
VOID HalpInitPICs(VOID) VOID HalpInitPICs(VOID)
@ -53,24 +56,13 @@ VOID HalpInitPICs(VOID)
WRITE_PORT_UCHAR((PUCHAR)0xa1, 0xff); WRITE_PORT_UCHAR((PUCHAR)0xa1, 0xff);
} }
#if 0 static ULONG
static unsigned int HiGetCurrentPICMask(void) HiSetCurrentPICMask(unsigned int mask)
{ {
unsigned int mask; WRITE_PORT_UCHAR((PUCHAR)0x21,mask & 0xff);
WRITE_PORT_UCHAR((PUCHAR)0xa1,(mask >> 8) & 0xff);
mask = READ_PORT_UCHAR((PUCHAR)0x21); return mask;
mask = mask | (READ_PORT_UCHAR((PUCHAR)0xa1)<<8);
return mask;
}
#endif
static unsigned int HiSetCurrentPICMask(unsigned int mask)
{
WRITE_PORT_UCHAR((PUCHAR)0x21,mask & 0xff);
WRITE_PORT_UCHAR((PUCHAR)0xa1,(mask >> 8) & 0xff);
return mask;
} }
static VOID HiSwitchIrql(KIRQL oldIrql) static VOID HiSwitchIrql(KIRQL oldIrql)
@ -84,25 +76,48 @@ static VOID HiSwitchIrql(KIRQL oldIrql)
CurrentThread = KeGetCurrentThread(); CurrentThread = KeGetCurrentThread();
if (CurrentIrql == HIGH_LEVEL) /*
* Disable all interrupts
*/
if (CurrentIrql >= IPI_LEVEL)
{ {
HiSetCurrentPICMask(0xffff); HiSetCurrentPICMask(0xFFFF);
return; __asm__("sti\n\t");
return;
} }
if (CurrentIrql > DISPATCH_LEVEL)
/*
* Disable all interrupts but the timer
*/
if (CurrentIrql == PROFILE_LEVEL ||
CurrentIrql == CLOCK1_LEVEL ||
CurrentIrql == CLOCK2_LEVEL)
{ {
unsigned int current_mask = 0; HiSetCurrentPICMask(0xFFFE);
for (i=CurrentIrql; i>DISPATCH_LEVEL; i--)
{
current_mask = current_mask | (1 << (HIGH_LEVEL - i));
}
HiSetCurrentPICMask(current_mask);
__asm__("sti\n\t"); __asm__("sti\n\t");
return; return;
} }
/*
* Disable all interrupts of lesser priority
*/
if (CurrentIrql > DISPATCH_LEVEL)
{
unsigned int current_mask = 0;
for (i = CurrentIrql; i > (PROFILE_LEVEL - 15); i--)
{
current_mask = current_mask | (1 << (PROFILE_LEVEL - i));
}
HiSetCurrentPICMask(current_mask);
__asm__("sti\n\t");
return;
}
/*
* Enable all interrupts
*/
if (CurrentIrql == DISPATCH_LEVEL) if (CurrentIrql == DISPATCH_LEVEL)
{ {
HiSetCurrentPICMask(0); HiSetCurrentPICMask(0);
@ -110,40 +125,46 @@ static VOID HiSwitchIrql(KIRQL oldIrql)
return; return;
} }
HiSetCurrentPICMask(0); /*
* APCs are disabled but execute any pending DPCs
*/
if (CurrentIrql == APC_LEVEL) if (CurrentIrql == APC_LEVEL)
{ {
if (DpcQueueSize > 0 ) HiSetCurrentPICMask(0);
__asm__("sti\n\t");
if (DpcQueueSize > 0)
{ {
KeSetCurrentIrql(DISPATCH_LEVEL); CurrentIrql = DISPATCH_LEVEL;
__asm__("sti\n\t"); KiDispatchInterrupt();
KiDispatchInterrupt(); CurrentIrql = APC_LEVEL;
__asm__("cli\n\t");
KeSetCurrentIrql(PASSIVE_LEVEL);
} }
__asm__("sti\n\t");
return; return;
} }
if (CurrentIrql == PASSIVE_LEVEL && /*
CurrentThread != NULL && * Execute any pending DPCs or APCs
CurrentThread->ApcState.KernelApcPending) */
if (CurrentIrql == PASSIVE_LEVEL)
{ {
KeSetCurrentIrql(APC_LEVEL); if (DpcQueueSize > 0)
__asm__("sti\n\t"); {
KiDeliverApc(0, 0, 0); CurrentIrql = DISPATCH_LEVEL;
__asm__("cli\n\t"); KiDispatchInterrupt();
KeSetCurrentIrql(PASSIVE_LEVEL); CurrentIrql = PASSIVE_LEVEL;
__asm__("sti\n\t"); }
} if (CurrentThread != NULL &&
else CurrentThread->ApcState.KernelApcPending)
{ {
__asm__("sti\n\t"); CurrentIrql = APC_LEVEL;
KiDeliverApc(0, 0, 0);
CurrentIrql = PASSIVE_LEVEL;
}
} }
} }
KIRQL STDCALL KeGetCurrentIrql (VOID) KIRQL STDCALL
KeGetCurrentIrql (VOID)
/* /*
* PURPOSE: Returns the current irq level * PURPOSE: Returns the current irq level
* RETURNS: The current irq level * RETURNS: The current irq level
@ -153,13 +174,13 @@ KIRQL STDCALL KeGetCurrentIrql (VOID)
} }
static VOID KeSetCurrentIrql(KIRQL newlvl) STATIC VOID
KeSetCurrentIrql(KIRQL newlvl)
/* /*
* PURPOSE: Sets the current irq level without taking any action * PURPOSE: Sets the current irq level without taking any action
*/ */
{ {
// DPRINT("KeSetCurrentIrql(newlvl %x)\n",newlvl); CurrentIrql = newlvl;
CurrentIrql = newlvl;
} }
@ -181,27 +202,25 @@ static VOID KeSetCurrentIrql(KIRQL newlvl)
*/ */
VOID FASTCALL VOID FASTCALL
KfLowerIrql ( KfLowerIrql (KIRQL NewIrql)
KIRQL NewIrql
)
{ {
KIRQL OldIrql; KIRQL OldIrql;
__asm__("cli\n\t"); __asm__("cli\n\t");
DPRINT("KfLowerIrql(NewIrql %d)\n", NewIrql); DPRINT("KfLowerIrql(NewIrql %d)\n", NewIrql);
if (NewIrql > CurrentIrql) if (NewIrql > CurrentIrql)
{ {
DbgPrint ("(%s:%d) NewIrql %x CurrentIrql %x\n", DbgPrint ("(%s:%d) NewIrql %x CurrentIrql %x\n",
__FILE__, __LINE__, NewIrql, CurrentIrql); __FILE__, __LINE__, NewIrql, CurrentIrql);
KeDumpStackFrames (0, 32); KeDumpStackFrames (0, 32);
for(;;); for(;;);
} }
OldIrql = CurrentIrql; OldIrql = CurrentIrql;
CurrentIrql = NewIrql; CurrentIrql = NewIrql;
HiSwitchIrql(OldIrql); HiSwitchIrql(OldIrql);
} }
@ -221,13 +240,10 @@ KfLowerIrql (
* NOTES * NOTES
*/ */
VOID VOID STDCALL
STDCALL KeLowerIrql (KIRQL NewIrql)
KeLowerIrql (
KIRQL NewIrql
)
{ {
KfLowerIrql (NewIrql); KfLowerIrql (NewIrql);
} }
@ -248,33 +264,30 @@ KeLowerIrql (
* Uses fastcall convention * Uses fastcall convention
*/ */
KIRQL KIRQL FASTCALL
FASTCALL KfRaiseIrql (KIRQL NewIrql)
KfRaiseIrql (
KIRQL NewIrql
)
{ {
KIRQL OldIrql; KIRQL OldIrql;
DPRINT("KfRaiseIrql(NewIrql %d)\n", NewIrql); DPRINT("KfRaiseIrql(NewIrql %d)\n", NewIrql);
if (NewIrql < CurrentIrql) if (NewIrql < CurrentIrql)
{ {
DbgPrint ("%s:%d CurrentIrql %x NewIrql %x\n", DbgPrint ("%s:%d CurrentIrql %x NewIrql %x\n",
__FILE__,__LINE__,CurrentIrql,NewIrql); __FILE__,__LINE__,CurrentIrql,NewIrql);
KeBugCheck (0); KeBugCheck (0);
for(;;); for(;;);
} }
__asm__("cli\n\t"); __asm__("cli\n\t");
OldIrql = CurrentIrql; OldIrql = CurrentIrql;
CurrentIrql = NewIrql; CurrentIrql = NewIrql;
DPRINT ("NewIrql %x OldIrql %x CurrentIrql %x\n", DPRINT ("NewIrql %x OldIrql %x CurrentIrql %x\n",
NewIrql, OldIrql, CurrentIrql); NewIrql, OldIrql, CurrentIrql);
HiSwitchIrql(OldIrql); HiSwitchIrql(OldIrql);
return OldIrql; return OldIrql;
} }
@ -295,15 +308,11 @@ KfRaiseIrql (
* NOTES * NOTES
* Calls KfRaiseIrql * Calls KfRaiseIrql
*/ */
VOID STDCALL
VOID KeRaiseIrql (KIRQL NewIrql,
STDCALL PKIRQL OldIrql)
KeRaiseIrql (
KIRQL NewIrql,
PKIRQL OldIrql
)
{ {
*OldIrql = KfRaiseIrql (NewIrql); *OldIrql = KfRaiseIrql (NewIrql);
} }
@ -324,11 +333,10 @@ KeRaiseIrql (
* Calls KfRaiseIrql * Calls KfRaiseIrql
*/ */
KIRQL KIRQL STDCALL
STDCALL
KeRaiseIrqlToDpcLevel (VOID) KeRaiseIrqlToDpcLevel (VOID)
{ {
return KfRaiseIrql (DISPATCH_LEVEL); return KfRaiseIrql (DISPATCH_LEVEL);
} }
@ -349,66 +357,68 @@ KeRaiseIrqlToDpcLevel (VOID)
* Calls KfRaiseIrql * Calls KfRaiseIrql
*/ */
KIRQL KIRQL STDCALL
STDCALL
KeRaiseIrqlToSynchLevel (VOID) KeRaiseIrqlToSynchLevel (VOID)
{ {
// return KfRaiseIrql (CLOCK2_LEVEL); // return KfRaiseIrql (CLOCK2_LEVEL);
UNIMPLEMENTED; UNIMPLEMENTED;
} }
BOOLEAN STDCALL HalBeginSystemInterrupt (ULONG Vector, BOOLEAN STDCALL
KIRQL Irql, HalBeginSystemInterrupt (ULONG Vector,
PKIRQL OldIrql) KIRQL Irql,
PKIRQL OldIrql)
{ {
if (Vector < IRQ_BASE || Vector > IRQ_BASE + NR_IRQS) if (Vector < IRQ_BASE || Vector > IRQ_BASE + NR_IRQS)
return FALSE; return FALSE;
/* Send EOI to the PICs */ /* Send EOI to the PICs */
WRITE_PORT_UCHAR((PUCHAR)0x20,0x20); WRITE_PORT_UCHAR((PUCHAR)0x20,0x20);
if ((Vector-IRQ_BASE)>=8) if ((Vector-IRQ_BASE)>=8)
{ {
WRITE_PORT_UCHAR((PUCHAR)0xa0,0x20); WRITE_PORT_UCHAR((PUCHAR)0xa0,0x20);
} }
*OldIrql = KeGetCurrentIrql(); *OldIrql = KeGetCurrentIrql();
if (Vector-IRQ_BASE != 0) if (Vector-IRQ_BASE != 0)
{ {
DPRINT("old_level %d\n",*OldIrql); DPRINT("old_level %d\n",*OldIrql);
} }
KeSetCurrentIrql(Irql); KeSetCurrentIrql(Irql);
return TRUE; return TRUE;
} }
VOID STDCALL HalEndSystemInterrupt (KIRQL Irql, VOID STDCALL HalEndSystemInterrupt (KIRQL Irql,
ULONG Unknown2) ULONG Unknown2)
{ {
KeSetCurrentIrql(Irql); KeSetCurrentIrql(Irql);
} }
BOOLEAN STDCALL HalDisableSystemInterrupt (ULONG Vector, BOOLEAN STDCALL HalDisableSystemInterrupt (ULONG Vector,
ULONG Unknown2) ULONG Unknown2)
{ {
ULONG irq; ULONG irq;
if (Vector < IRQ_BASE || Vector > IRQ_BASE + NR_IRQS) if (Vector < IRQ_BASE || Vector > IRQ_BASE + NR_IRQS)
return FALSE; return FALSE;
irq = Vector - IRQ_BASE; irq = Vector - IRQ_BASE;
if (irq<8) if (irq < 8)
{ {
WRITE_PORT_UCHAR((PUCHAR)0x21, READ_PORT_UCHAR((PUCHAR)0x21)|(1<<irq)); WRITE_PORT_UCHAR((PUCHAR)0x21,
} READ_PORT_UCHAR((PUCHAR)0x21)|(1<<irq));
else
{
WRITE_PORT_UCHAR((PUCHAR)0xa1, READ_PORT_UCHAR((PUCHAR)0xa1)|(1<<(irq-8)));
} }
else
{
WRITE_PORT_UCHAR((PUCHAR)0xa1,
READ_PORT_UCHAR((PUCHAR)0xa1)|(1<<(irq-8)));
}
return TRUE; return TRUE;
} }
@ -416,22 +426,24 @@ BOOLEAN STDCALL HalEnableSystemInterrupt (ULONG Vector,
ULONG Unknown2, ULONG Unknown2,
ULONG Unknown3) ULONG Unknown3)
{ {
ULONG irq; ULONG irq;
if (Vector < IRQ_BASE || Vector > IRQ_BASE + NR_IRQS) if (Vector < IRQ_BASE || Vector > IRQ_BASE + NR_IRQS)
return FALSE; return FALSE;
irq = Vector - IRQ_BASE; irq = Vector - IRQ_BASE;
if (irq<8) if (irq < 8)
{
WRITE_PORT_UCHAR((PUCHAR)0x21,
READ_PORT_UCHAR((PUCHAR)0x21)&(~(1<<irq)));
}
else
{ {
WRITE_PORT_UCHAR((PUCHAR)0x21, READ_PORT_UCHAR((PUCHAR)0x21)&(~(1<<irq))); WRITE_PORT_UCHAR((PUCHAR)0xa1,
} READ_PORT_UCHAR((PUCHAR)0xa1)&(~(1<<(irq-8))));
else
{
WRITE_PORT_UCHAR((PUCHAR)0xa1, READ_PORT_UCHAR((PUCHAR)0xa1)&(~(1<<(irq-8))));
} }
return TRUE; return TRUE;
} }
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: mp.c,v 1.7 2001/04/16 00:48:04 chorns Exp $ /* $Id: mp.c,v 1.8 2001/04/16 02:02:04 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -1802,7 +1802,7 @@ ULONG MPChecksum(
while (Size--) while (Size--)
Sum += *Base++; Sum += *Base++;
return (Sum & 0xFF); return((UCHAR)Sum);
} }
@ -2016,11 +2016,12 @@ HaliReadMPConfigTable(
PUCHAR Entry; PUCHAR Entry;
ULONG Count; ULONG Count;
if ((ULONG)Table->Signature != MPC_SIGNATURE) if (Table->Signature != MPC_SIGNATURE)
{ {
PCHAR pc = (PCHAR)&Table->Signature; PUCHAR pc = (PUCHAR)&Table->Signature;
DbgPrint("Bad MP configuration block signature: %c%c%c%c\n", pc[0], pc[1], pc[2], pc[3]); DbgPrint("Bad MP configuration block signature: %c%c%c%c/%x/%x\n", pc[0],
pc[1], pc[2], pc[3], MPC_SIGNATURE, (ULONG)Table->Signature);
KeBugCheck(0); KeBugCheck(0);
return; return;
} }
@ -2225,17 +2226,19 @@ HaliScanForMPConfigTable(
*/ */
{ {
PULONG bp = (PULONG)Base; PULONG bp = (PULONG)Base;
PMP_FLOATING_POINTER mpf; MP_FLOATING_POINTER* mpf;
while (Size > 0) while (Size > 0)
{ {
if (*bp == MPF_SIGNATURE) if (*bp == MPF_SIGNATURE)
{ {
if (!MPChecksum((PUCHAR)bp, 16)) DbgPrint("Found MPF signature at %x, checksum %x\n", bp,
MPChecksum((PUCHAR)bp, 16));
if (MPChecksum((PUCHAR)bp, 16) == 0)
{ {
mpf = (PMP_FLOATING_POINTER)bp; mpf = (MP_FLOATING_POINTER*)bp;
DPRINT("Intel MultiProcessor Specification v1.%d compliant system.\n", DbgPrint("Intel MultiProcessor Specification v1.%d compliant system.\n",
mpf->Specification); mpf->Specification);
if (mpf->Feature2 & FEATURE2_IMCRP) { if (mpf->Feature2 & FEATURE2_IMCRP) {
@ -2273,7 +2276,7 @@ HaliScanForMPConfigTable(
DPRINT("MCA and PCI\n"); DPRINT("MCA and PCI\n");
break; break;
default: default:
DPRINT("Unknown standard configuration %d\n", mpf->Feature1); DbgPrint("Unknown standard configuration %d\n", mpf->Feature1);
return FALSE; return FALSE;
} }
@ -2337,7 +2340,7 @@ HalpInitMPS(
if (!HaliScanForMPConfigTable(0xF0000, 0x10000)) { if (!HaliScanForMPConfigTable(0xF0000, 0x10000)) {
EBDA = *((PUSHORT)0x040E); EBDA = *((PUSHORT)0x040E);
EBDA <<= 4; EBDA <<= 4;
if (!HaliScanForMPConfigTable((ULONG)EBDA, 0x400)) { if (!HaliScanForMPConfigTable((ULONG)EBDA, 0x1000)) {
DbgPrint("No multiprocessor compliant system found.\n"); DbgPrint("No multiprocessor compliant system found.\n");
KeBugCheck(0); KeBugCheck(0);
} }

View file

@ -2,6 +2,6 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H #ifndef __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H
#define __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H #define __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H
#define DBG #define DBG
#define UP #define MP
#define CONFIG "DBG UP" #define CONFIG "DBG MP"
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H */ #endif /* __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H */

View file

@ -220,7 +220,7 @@ typedef struct _IOAPIC_INFO
typedef struct __attribute__((packed)) _MP_FLOATING_POINTER typedef struct __attribute__((packed)) _MP_FLOATING_POINTER
{ {
ULONG Signature[4]; /* _MP_ */ ULONG Signature; /* _MP_ */
ULONG Address; /* Physical Address Pointer (0 means no configuration table exist) */ ULONG Address; /* Physical Address Pointer (0 means no configuration table exist) */
UCHAR Length; /* Structure length in 16-byte paragraphs */ UCHAR Length; /* Structure length in 16-byte paragraphs */
UCHAR Specification; /* Specification revision */ UCHAR Specification; /* Specification revision */
@ -230,7 +230,7 @@ typedef struct __attribute__((packed)) _MP_FLOATING_POINTER
UCHAR Feature3; /* Unused (0) */ UCHAR Feature3; /* Unused (0) */
UCHAR Feature4; /* Unused (0) */ UCHAR Feature4; /* Unused (0) */
UCHAR Feature5; /* Unused (0) */ UCHAR Feature5; /* Unused (0) */
} MP_FLOATING_POINTER, *PMP_FLOATING_POINTER; } __attribute__((packed)) MP_FLOATING_POINTER, *PMP_FLOATING_POINTER;
#define FEATURE2_IMCRP 0x80 #define FEATURE2_IMCRP 0x80
@ -239,7 +239,7 @@ typedef struct __attribute__((packed)) _MP_FLOATING_POINTER
typedef struct __attribute__((packed)) _MP_CONFIGURATION_TABLE typedef struct __attribute__((packed)) _MP_CONFIGURATION_TABLE
{ {
ULONG Signature[4]; /* PCMP */ ULONG Signature; /* PCMP */
USHORT Length; /* Size of configuration table */ USHORT Length; /* Size of configuration table */
CHAR Specification; /* Specification Revision */ CHAR Specification; /* Specification Revision */
CHAR Checksum; /* Checksum */ CHAR Checksum; /* Checksum */
@ -430,3 +430,5 @@ VOID IOAPICDump(VOID);
VOID APICDump(VOID); VOID APICDump(VOID);
#endif /* __INCLUDE_HAL_MPS */ #endif /* __INCLUDE_HAL_MPS */
/* EOF */

View file

@ -193,4 +193,6 @@ VOID KeTrapFrameToContext(PKTRAP_FRAME TrapFrame,
#endif /* not __ASM__ */ #endif /* not __ASM__ */
#define MAXIMUM_PROCESSORS 32
#endif #endif

View file

@ -75,6 +75,7 @@ RtlImageDirectoryEntryToData (
OUT PULONG Size); OUT PULONG Size);
VOID VOID
LdrInit1(VOID); LdrInit1(VOID);
VOID
LdrInitDebug(PLOADER_MODULE Module, PWCH Name);
#endif /* __INCLUDE_INTERNAL_LDR_H */ #endif /* __INCLUDE_INTERNAL_LDR_H */

View file

@ -31,8 +31,10 @@ typedef struct _MODULE_TEXT_SECTION
LIST_ENTRY ListEntry; LIST_ENTRY ListEntry;
PWCH Name; PWCH Name;
#ifdef KDBG #ifdef KDBG
SYMBOL_TABLE Symbols; SYMBOL_TABLE Symbols;
#endif /* KDBG */ #endif /* KDBG */
PVOID SymbolsBase;
ULONG SymbolsLength;
} MODULE_TEXT_SECTION; } MODULE_TEXT_SECTION;
typedef struct _MODULE_OBJECT typedef struct _MODULE_OBJECT

View file

@ -38,7 +38,7 @@
#define ETHREAD_THREADS_PROCESS 0x258 #define ETHREAD_THREADS_PROCESS 0x258
#define KPROCESS_PAGE_TABLE_DIRECTORY 0x10 #define KPROCESS_DIRECTORY_TABLE_BASE 0x18
#define KPCR_BASE 0xFF000000 #define KPCR_BASE 0xFF000000
@ -278,92 +278,179 @@ typedef struct _ETHREAD
* Added by David Welch (welch@cwcom.net) * Added by David Welch (welch@cwcom.net)
*/ */
struct _EPROCESS* OldProcess; /* 240/26C */ struct _EPROCESS* OldProcess; /* 240/26C */
struct _WIN32THREADDATA *Win32ThreadData; // Pointer to win32 private thread data
/* Pointer to win32 private thread data */
struct _WIN32THREADDATA *Win32ThreadData;
} __attribute__((packed)) ETHREAD, *PETHREAD; } __attribute__((packed)) ETHREAD, *PETHREAD;
typedef struct _KPROCESS typedef struct _KPROCESS
{ {
/* So it's possible to wait for the process to terminate */
DISPATCHER_HEADER DispatcherHeader; /* 000 */ DISPATCHER_HEADER DispatcherHeader; /* 000 */
PVOID PageTableDirectory; /* 010 */ /*
TIME ElapsedTime; * Presumably a list of profile objects associated with this process,
TIME KernelTime; * currently unused.
TIME UserTime; */
LIST_ENTRY InMemoryList; LIST_ENTRY ProfileListHead; /* 010 */
LIST_ENTRY SwappedOutList; /*
KSPIN_LOCK SpinLock; * We use the first member of this array to hold the physical address of
KAFFINITY Affinity; * the page directory for this process.
ULONG StackCount; */
KPRIORITY BasePriority; PVOID DirectoryTableBase[2]; /* 018 */
ULONG DefaultThreadQuantum; /*
UCHAR ProcessState; * Presumably a descriptor for the process's LDT, currently unused.
ULONG ThreadSeed; */
UCHAR DisableBoost; ULONG LdtDescriptor[2]; /* 020 */
/*
* Presumably for processing int 0x21 from V86 mode DOS, currently
* unused.
*/
ULONG Int21Descriptor[2]; /* 028 */
/* Don't know. */
USHORT IopmOffset; /* 030 */
/*
* Presumably I/O privilege level to be used for this process, currently
* unused.
*/
UCHAR Iopl; /* 032 */
/* Set if this process is a virtual dos machine? */
UCHAR VdmFlag; /* 033 */
/* Bitmask of the processors being used by this process's threads? */
ULONG ActiveProcessors; /* 034 */
/* Aggregate of the time this process's threads have spent in kernel mode? */
ULONG KernelTime; /* 038 */
/* Aggregate of the time this process's threads have spent in user mode? */
ULONG UserTime; /* 03C */
/* List of this process's threads that are ready for execution? */
LIST_ENTRY ReadyListHead; /* 040 */
/* List of this process's threads that have their stacks swapped out? */
LIST_ENTRY SwapListEntry; /* 048 */
/* List of this process's threads? */
LIST_ENTRY ThreadListHead; /* 050 */
/* Maybe a lock for this data structure, the type is assumed. */
KSPIN_LOCK ProcessLock; /* 058 */
/* Default affinity mask for this process's threads? */
ULONG Affinity; /* 05C */
/* Count of the stacks allocated for this process's threads? */
USHORT StackCount; /* 060 */
/* Base priority for this process's threads? */
KPRIORITY BasePriority; /* 062 */
/* Default quantum for this process's threads */
UCHAR ThreadQuantum; /* 063 */
/* Unknown. */
UCHAR AutoAlignment; /* 064 */
/* Process execution state, currently either active or terminated. */
UCHAR State; /* 065 */
/* Seed for generating thread ids for this process's threads? */
UCHAR ThreadSeed; /* 066 */
/* Disable priority boosts? */
UCHAR DisableBoost; /* 067 */
} KPROCESS, *PKPROCESS; } KPROCESS, *PKPROCESS;
struct _WIN32PROCESSDATA; struct _WIN32PROCESSDATA;
typedef struct _EPROCESS typedef struct _EPROCESS
{ {
KPROCESS Pcb; /* Microkernel specific process state. */
NTSTATUS ExitStatus; KPROCESS Pcb; /* 000 */
KEVENT LockEvent; /* Exit status of the process. */
ULONG LockCount; NTSTATUS ExitStatus; /* 068 */
TIME CreateTime; /* Unknown. */
TIME ExitTime; KEVENT LockEvent; /* 06C */
PVOID LockOwner; /* Unknown. */
ULONG UniqueProcessId; ULONG LockCount; /* 07C */
LIST_ENTRY ActiveProcessLinks; /* Time of process creation. */
ULONG QuotaPeakPoolUsage[2]; TIME CreateTime; /* 080 */
ULONG QuotaPoolUsage[2]; /* Time of process exit. */
ULONG PagefileUsage; TIME ExitTime; /* 088 */
ULONG CommitCharge; /* Unknown. */
ULONG PeakPagefileUsage; PVOID LockOwner; /* 090 */
ULONG PeakVirtualUsage; /* Process id. */
LARGE_INTEGER VirtualSize; ULONG UniqueProcessId; /* 094 */
PVOID Vm; // Actually 48 bytes /* Unknown. */
PVOID LastProtoPteFault; LIST_ENTRY ActiveProcessLinks; /* 098 */
struct _EPORT* DebugPort; /* Unknown. */
struct _EPORT* ExceptionPort; ULONG QuotaPeakPoolUsage[2]; /* 0A0 */
PVOID ObjectTable; /* Unknown. */
PVOID Token; ULONG QuotaPoolUsage[2]; /* 0A8 */
KMUTEX WorkingSetLock; /* Unknown. */
PVOID WorkingSetPage; ULONG PagefileUsage; /* 0B0 */
UCHAR ProcessOutswapEnabled; /* Unknown. */
UCHAR ProcessOutswapped; ULONG CommitCharge; /* 0B4 */
UCHAR AddressSpaceInitialized; /* Unknown. */
UCHAR AddressSpaceDeleted; ULONG PeakPagefileUsage; /* 0B8 */
KMUTEX AddressCreationLock; /* Unknown. */
PVOID ForkInProgress; ULONG PeakVirtualSize; /* 0BC */
PVOID VmOperation; /* Unknown. */
PKEVENT VmOperationEvent; LARGE_INTEGER VirtualSize; /* 0C0 */
PVOID PageDirectoryPte; struct
LARGE_INTEGER LastFaultCount; {
PVOID VadRoot; ULONG LastTrimTime;
PVOID VadHint; ULONG LastTrimFaultCount;
PVOID CloneRoot; ULONG PageFaultCount;
ULONG NumberOfPrivatePages; ULONG PeakWorkingSetSize;
ULONG NumberOfLockedPages; ULONG WorkingSetSize;
UCHAR ForkWasSuccessFul; ULONG MinimumWorkingSetSize;
UCHAR ExitProcessCalled; ULONG MaximumWorkingSetSize;
UCHAR CreateProcessReported; ULONG VmWorkingSetList;
HANDLE SectionHandle; LIST_ENTRY WorkingSetExpansionList;
PPEB Peb; UCHAR AllowWorkingSetAdjustment;
PVOID SectionBaseAddress; UCHAR AddressSpaceBeingDeleted;
PVOID QuotaBlock; UCHAR ForegroundPrioritySwitch;
NTSTATUS LastThreadExitStatus; UCHAR MemoryPriority;
LARGE_INTEGER WorkingSetWatch; // } Vm;
ULONG InheritedFromUniqueProcessId; PVOID LastProtoPteFault;
ACCESS_MASK GrantedAccess; struct _EPORT* DebugPort;
ULONG DefaultHardErrorProcessing; struct _EPORT* ExceptionPort;
PVOID LdtInformation; PVOID ObjectTable;
ULONG VadFreeHint; PVOID Token;
PVOID VdmObjects; // FAST_MUTEX WorkingSetLock;
KMUTANT ProcessMutant; KMUTEX WorkingSetLock;
CHAR ImageFileName[16]; PVOID WorkingSetPage;
LARGE_INTEGER VmTrimFaultValue; UCHAR ProcessOutswapEnabled;
struct _WIN32PROCESSDATA *Win32Process; UCHAR ProcessOutswapped;
UCHAR AddressSpaceInitialized;
UCHAR AddressSpaceDeleted;
FAST_MUTEX AddressCreationLock;
KSPIN_LOCK HyperSpaceLock;
PETHREAD ForkInProgress;
USHORT VmOperation;
UCHAR ForkWasSuccessful;
UCHAR MmAgressiveWsTrimMask;
PKEVENT VmOperationEvent;
PVOID PageDirectoryPte;
ULONG LastFaultCount;
PVOID VadRoot;
PVOID VadHint;
PVOID CloneRoot;
ULONG NumberOfPrivatePages;
ULONG NumberOfLockedPages;
USHORT NextProcessColour;
UCHAR ExitProcessCalled;
UCHAR CreateProcessReported;
HANDLE SectionHandle;
PPEB Peb;
PVOID SectionBaseAddress;
PVOID QuotaBlock;
NTSTATUS LastThreadExitStatus;
PVOID WorkingSetWatch;
HANDLE InheritedFromUniqueProcessId;
ACCESS_MASK GrantedAccess;
ULONG DefaultHardErrorProcessing;
PVOID LdtInformation;
ULONG VadFreeHint;
PVOID VdmObjects;
KMUTANT ProcessMutant;
CHAR ImageFileName[16];
ULONG VmTrimFaultValue;
UCHAR SetTimerResolution;
UCHAR PriorityClass;
UCHAR SubSystemMinorVersion;
UCHAR SubSystemMajorVersion;
USHORT SubSystemVersion;
struct _WIN32PROCESSDATA *Win32Process;
/* /*
* Added by David Welch (welch@mcmail.com) * Added by David Welch (welch@mcmail.com)

View file

@ -664,7 +664,7 @@ void KeInitExceptions(void)
{ {
int i; int i;
ULONG base, length; ULONG base, length;
extern USHORT KiGdt[]; extern USHORT KiBootGdt[];
extern unsigned int trap_stack_top; extern unsigned int trap_stack_top;
extern KTSS KiTss; extern KTSS KiTss;
extern KTSS KiTrapTss; extern KTSS KiTrapTss;
@ -681,10 +681,10 @@ void KeInitExceptions(void)
base = (unsigned int)&KiNullLdt; base = (unsigned int)&KiNullLdt;
length = sizeof(KiNullLdt) - 1; length = sizeof(KiNullLdt) - 1;
KiGdt[(LDT_SELECTOR / 2) + 0] = (length & 0xFFFF); KiBootGdt[(LDT_SELECTOR / 2) + 0] = (length & 0xFFFF);
KiGdt[(LDT_SELECTOR / 2) + 1] = (base & 0xFFFF); KiBootGdt[(LDT_SELECTOR / 2) + 1] = (base & 0xFFFF);
KiGdt[(LDT_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200; KiBootGdt[(LDT_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200;
KiGdt[(LDT_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) | KiBootGdt[(LDT_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
((base & 0xFF000000) >> 16); ((base & 0xFF000000) >> 16);
/* /*
@ -694,10 +694,10 @@ void KeInitExceptions(void)
base = (unsigned int)&KiTss; base = (unsigned int)&KiTss;
length = sizeof(KiTss) - 1; length = sizeof(KiTss) - 1;
KiGdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF); KiBootGdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
KiGdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF); KiBootGdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
KiGdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900; KiBootGdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
KiGdt[(TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) | KiBootGdt[(TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
((base & 0xFF000000) >> 16); ((base & 0xFF000000) >> 16);
/* /*
@ -724,10 +724,10 @@ void KeInitExceptions(void)
base = (unsigned int)&KiTrapTss; base = (unsigned int)&KiTrapTss;
length = sizeof(KiTrapTss) - 1; length = sizeof(KiTrapTss) - 1;
KiGdt[(TRAP_TSS_SELECTOR / 2) + 0] = (length & 0xFFFF); KiBootGdt[(TRAP_TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
KiGdt[(TRAP_TSS_SELECTOR / 2) + 1] = (base & 0xFFFF); KiBootGdt[(TRAP_TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
KiGdt[(TRAP_TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900; KiBootGdt[(TRAP_TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
KiGdt[(TRAP_TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) | KiBootGdt[(TRAP_TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
((base & 0xFF000000) >> 16); ((base & 0xFF000000) >> 16);
KiTrapTss.Eflags = 0; KiTrapTss.Eflags = 0;

View file

@ -28,13 +28,17 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ke.h>
#include <internal/ps.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
USHORT KiGdt[11 * 4] = PUSHORT KiGdtArray[MAXIMUM_PROCESSORS];
USHORT KiBootGdt[11 * 4] =
{ {
0x0, 0x0, 0x0, 0x0, /* Null */ 0x0, 0x0, 0x0, 0x0, /* Null */
0xffff, 0x0, 0x9a00, 0xcf, /* Kernel CS */ 0xffff, 0x0, 0x9a00, 0xcf, /* Kernel CS */
@ -53,12 +57,42 @@ struct
{ {
USHORT Length; USHORT Length;
ULONG Base; ULONG Base;
} __attribute__((packed)) KiGdtDescriptor = { 11 * 8, (ULONG)KiGdt }; } __attribute__((packed)) KiGdtDescriptor = { 11 * 8, (ULONG)KiBootGdt };
static KSPIN_LOCK GdtLock; static KSPIN_LOCK GdtLock;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID
KiInitializeGdt(ULONG Id, PKPCR Pcr)
{
PUSHORT Gdt;
if (Id == 0)
{
KiGdtArray[0] = KiBootGdt;
return;
}
/*
* Allocate a GDT
*/
Gdt = ExAllocatePool(NonPagedPool, sizeof(USHORT) * 4 * 11);
if (Gdt == NULL)
{
KeBugCheck(0);
}
/*
* Copy the boot processor's GDT onto this processor's GDT. Note that
* the only entries that can change are the PCR, TEB and LDT descriptors.
* We will be initializing these later so their current values are
* irrelevant.
*/
memcpy(Gdt, KiGdtArray, sizeof(USHORT) * 4 * 11);
KiGdtArray[Id] = Gdt;
}
VOID VOID
KeSetBaseGdtSelector(ULONG Entry, KeSetBaseGdtSelector(ULONG Entry,
PVOID Base) PVOID Base)
@ -72,14 +106,14 @@ KeSetBaseGdtSelector(ULONG Entry,
Entry = (Entry & (~0x3)) / 2; Entry = (Entry & (~0x3)) / 2;
KiGdt[Entry + 1] = ((ULONG)Base) & 0xffff; KiBootGdt[Entry + 1] = ((ULONG)Base) & 0xffff;
KiGdt[Entry + 2] = KiGdt[Entry + 2] & ~(0xff); KiBootGdt[Entry + 2] = KiBootGdt[Entry + 2] & ~(0xff);
KiGdt[Entry + 2] = KiGdt[Entry + 2] | KiBootGdt[Entry + 2] = KiBootGdt[Entry + 2] |
((((ULONG)Base) & 0xff0000) >> 16); ((((ULONG)Base) & 0xff0000) >> 16);
KiGdt[Entry + 3] = KiGdt[Entry + 3] & ~(0xff00); KiBootGdt[Entry + 3] = KiBootGdt[Entry + 3] & ~(0xff00);
KiGdt[Entry + 3] = KiGdt[Entry + 3] | KiBootGdt[Entry + 3] = KiBootGdt[Entry + 3] |
((((ULONG)Base) & 0xff000000) >> 16); ((((ULONG)Base) & 0xff000000) >> 16);
DPRINT("%x %x %x %x\n", DPRINT("%x %x %x %x\n",
@ -97,10 +131,10 @@ KeDumpGdtSelector(ULONG Entry)
USHORT a, b, c, d; USHORT a, b, c, d;
ULONG RawLimit; ULONG RawLimit;
a = KiGdt[Entry*4]; a = KiBootGdt[Entry*4];
b = KiGdt[Entry*4 + 1]; b = KiBootGdt[Entry*4 + 1];
c = KiGdt[Entry*4 + 2]; c = KiBootGdt[Entry*4 + 2];
d = KiGdt[Entry*4 + 3]; d = KiBootGdt[Entry*4 + 3];
DbgPrint("Base: %x\n", b + ((c & 0xff) * (1 << 16)) + DbgPrint("Base: %x\n", b + ((c & 0xff) * (1 << 16)) +
((d & 0xff00) * (1 << 16))); ((d & 0xff00) * (1 << 16)));
@ -123,65 +157,4 @@ KeDumpGdtSelector(ULONG Entry)
DbgPrint("G: %d\n", (d & 0x80) >> 7); DbgPrint("G: %d\n", (d & 0x80) >> 7);
} }
#if 0 /* EOF */
VOID KeFreeGdtSelector(ULONG Entry)
/*
* FUNCTION: Free a gdt selector
* ARGUMENTS:
* Entry = Entry to free
*/
{
KIRQL oldIrql;
DPRINT("KeFreeGdtSelector(Entry %d)\n",Entry);
if (Entry > (8 + NR_TASKS))
{
DPRINT1("Entry too large\n");
KeBugCheck(0);
}
KeAcquireSpinLock(&GdtLock, &oldIrql);
KiGdt[Entry*4] = 0;
KiGdt[Entry*4 + 1] = 0;
KiGdt[Entry*4 + 2] = 0;
KiGdt[Entry*4 + 3] = 0;
KeReleaseSpinLock(&GdtLock, oldIrql);
}
#endif
#if 0
ULONG
KeAllocateGdtSelector(ULONG Desc[2])
/*
* FUNCTION: Allocate a gdt selector
* ARGUMENTS:
* Desc = Contents for descriptor
* RETURNS: The index of the entry allocated
*/
{
ULONG i;
KIRQL oldIrql;
DPRINT("KeAllocateGdtSelector(Desc[0] %x, Desc[1] %x)\n",
Desc[0], Desc[1]);
KeAcquireSpinLock(&GdtLock, &oldIrql);
for (i=8; i<(8 + NR_TASKS); i++)
{
if (KiGdt[i*4] == 0 &&
KiGdt[i*4 + 1] == 0 &&
KiGdt[i*4 + 2] == 0 &&
KiGdt[i*4 + 3] == 0)
{
((PULONG)KiGdt)[i*2] = Desc[0];
((PULONG)KiGdt)[i*2 + 1] = Desc[1];
KeReleaseSpinLock(&GdtLock, oldIrql);
DPRINT("KeAllocateGdtSelector() = %x\n",i);
return(i);
}
}
KeReleaseSpinLock(&GdtLock, oldIrql);
return(0);
}
#endif

View file

@ -1,4 +1,4 @@
/* $Id: irq.c,v 1.9 2001/04/13 16:12:26 chorns Exp $ /* $Id: irq.c,v 1.10 2001/04/16 02:02:05 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -344,8 +344,8 @@ KiInterruptDispatch (ULONG irq, PKIRQ_TRAPFRAME Trapframe)
/* /*
* Notify the rest of the kernel of the raised irq level * Notify the rest of the kernel of the raised irq level
*/ */
HalBeginSystemInterrupt (irq+IRQ_BASE, HalBeginSystemInterrupt (irq + IRQ_BASE,
HIGH_LEVEL-irq, PROFILE_LEVEL - irq,
&old_level); &old_level);
/* /*
@ -354,7 +354,7 @@ KiInterruptDispatch (ULONG irq, PKIRQ_TRAPFRAME Trapframe)
*/ */
__asm__("sti\n\t"); __asm__("sti\n\t");
if (irq==0) if (irq == 0)
{ {
KiUpdateSystemTime(old_level, Trapframe->Eip); KiUpdateSystemTime(old_level, Trapframe->Eip);
} }

View file

@ -46,21 +46,23 @@ VOID
KeInit1(VOID) KeInit1(VOID)
{ {
PKPCR KPCR; PKPCR KPCR;
extern USHORT KiGdt[]; extern USHORT KiBootGdt[];
KiCheckFPU(); KiCheckFPU();
KeInitExceptions (); KeInitExceptions ();
KeInitInterrupts (); KeInitInterrupts ();
/* Initialize the initial PCR region. We can't allocate a page /*
with MmAllocPage() here because MmInit1() has not yet been * Initialize the initial PCR region. We can't allocate a page
called, so we use a predefined page in low memory */ * with MmAllocPage() here because MmInit1() has not yet been
* called, so we use a predefined page in low memory
*/
KPCR = (PKPCR)KPCR_BASE; KPCR = (PKPCR)KPCR_BASE;
memset(KPCR, 0, PAGESIZE); memset(KPCR, 0, PAGESIZE);
KPCR->Self = (PKPCR)KPCR_BASE; KPCR->Self = (PKPCR)KPCR_BASE;
KPCR->Irql = HIGH_LEVEL; KPCR->Irql = HIGH_LEVEL;
KPCR->GDT = (PUSHORT)&KiGdt; KPCR->GDT = (PUSHORT)&KiBootGdt;
KPCR->IDT = (PUSHORT)&KiIdt; KPCR->IDT = (PUSHORT)&KiIdt;
KiPcrInitDone = 1; KiPcrInitDone = 1;
} }

View file

@ -76,13 +76,13 @@ _multiboot_entry:
#ifdef MP #ifdef MP
/* /*
* Save the multiboot or application processor magic * Save the multiboot or application processor magic
*/ */
movl %eax, %edx movl %eax, %edx
cmpl $AP_MAGIC, %edx cmpl $AP_MAGIC, %edx
je .m1 je .m1
#endif /* MP */ #endif /* MP */
@ -109,9 +109,9 @@ _multiboot_entry:
movl $(V2P(lowmem_pagetable) + 0x7), 0xD00(%esi) movl $(V2P(lowmem_pagetable) + 0x7), 0xD00(%esi)
movl $(V2P(startup_pagedirectory) + 0x7), 0xF00(%esi) movl $(V2P(startup_pagedirectory) + 0x7), 0xF00(%esi)
#ifdef MP #ifdef MP
movl $(V2P(apic_pagetable) + 0x7), 0xFEC(%esi) movl $(V2P(apic_pagetable) + 0x7), 0xFEC(%esi)
#endif /* MP */ #endif /* MP */
movl $(V2P(kpcr_pagetable) + 0x7), 0xFF0(%esi) movl $(V2P(kpcr_pagetable) + 0x7), 0xFF0(%esi)
/* /*
* Initialize the page table that maps low memory * Initialize the page table that maps low memory
@ -145,8 +145,10 @@ _multiboot_entry:
* Initialize the page table that maps the APIC register address space * Initialize the page table that maps the APIC register address space
*/ */
/* FIXME: APIC register address space can be non-standard so do the mapping later */ /*
* FIXME: APIC register address space can be non-standard so do the
* mapping later
*/
movl $V2P(apic_pagetable), %esi movl $V2P(apic_pagetable), %esi
movl $0, %edi movl $0, %edi
movl $0xFEC0001B, %eax movl $0xFEC0001B, %eax
@ -171,7 +173,6 @@ _multiboot_entry:
#endif /* MP */ #endif /* MP */
/* /*
* Set up the PDBR * Set up the PDBR
*/ */
@ -186,7 +187,7 @@ _multiboot_entry:
movl %eax, %cr0 movl %eax, %cr0
/* /*
* Do an absolute jump because we now want to execute at 0xc0000000 * Do an absolute jump because we now want to execute above 0xc0000000
*/ */
movl $.l2, %eax movl $.l2, %eax
jmp *%eax jmp *%eax
@ -197,8 +198,7 @@ _multiboot_entry:
* 0xc0000000 * 0xc0000000
*/ */
/* FIXME: Application processors should have their own GDT/IDT */ /* FIXME: Application processors should have their own GDT/IDT */
lgdt _KiGdtDescriptor lgdt _KiGdtDescriptor
lidt _KiIdtDescriptor lidt _KiIdtDescriptor
@ -215,12 +215,12 @@ _multiboot_entry:
#ifdef MP #ifdef MP
cmpl $AP_MAGIC, %edx cmpl $AP_MAGIC, %edx
jne .m2 jne .m2
/* /*
* This is an application processor executing * This is an application processor executing
*/ */
/* /*
* Initialize EFLAGS * Initialize EFLAGS
@ -232,16 +232,29 @@ _multiboot_entry:
* Call the application processor initialization code * Call the application processor initialization code
*/ */
pushl $0 pushl $0
pushl $.l7
pushl $KERNEL_CS pushl $KERNEL_CS
pushl $_KiSystemStartup pushl $_KiSystemStartup
lret lret
popl %eax
/*
* Catch illegal returns from KiSystemStartup
*/
.l7:
pushl $0
call _KeBugCheck@4
popl %eax
.l8:
jmp .l8
.m2: .m2:
#endif /* MP */ #endif /* MP */
/* /*
* Load the initial ring0 stack * Load the initial kernel stack
*/ */
movl $_init_stack_top, %esp movl $_init_stack_top, %esp
@ -252,14 +265,29 @@ _multiboot_entry:
popfl popfl
/* /*
* Call the main ring0 initialization * Call the main kernel initialization
*/ */
movl $0, %ebp
pushl %ebx pushl %ebx
pushl %edx pushl %edx
pushl $0 pushl $.l5
pushl $KERNEL_CS pushl $KERNEL_CS
pushl $__main pushl $__main
lret lret
popl %eax
popl %eax
/*
* Catch illegal returns from main, try bug checking the system,
* if that fails then loop forever.
*/
.l5:
pushl $0
call _KeBugCheck@4
popl %eax
.l6:
jmp .l6
/* /*
* This needs to be page aligned so put it at the beginning of the bss * This needs to be page aligned so put it at the beginning of the bss

View file

@ -108,7 +108,7 @@ _Ki386ContextSwitch:
* Change the address space * Change the address space
*/ */
movl ETHREAD_THREADS_PROCESS(%ebx), %ebx movl ETHREAD_THREADS_PROCESS(%ebx), %ebx
movl KPROCESS_PAGE_TABLE_DIRECTORY(%ebx), %eax movl KPROCESS_DIRECTORY_TABLE_BASE(%ebx), %eax
movl %eax, %cr3 movl %eax, %cr3
/* /*

View file

@ -211,7 +211,6 @@ KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First)
Thread->ApcStateIndex = 0; Thread->ApcStateIndex = 0;
Thread->ApcQueueable = 0; Thread->ApcQueueable = 0;
Thread->AutoAlignment = 0; Thread->AutoAlignment = 0;
Thread->StackBase = KernelStack;
KeInitializeApc(&Thread->SuspendApc, KeInitializeApc(&Thread->SuspendApc,
Thread, Thread,
0, 0,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: main.c,v 1.88 2001/04/16 00:48:04 chorns Exp $ /* $Id: main.c,v 1.89 2001/04/16 02:02:04 dwelch Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c * FILE: ntoskrnl/ke/main.c
@ -383,307 +383,207 @@ InitSystemSharedUserPage (PCSZ ParameterLine)
KeBugCheck (0x0); KeBugCheck (0x0);
} }
} }
#if 0
VOID
TestV86Mode(VOID)
{
ULONG i;
extern UCHAR OrigIVT[1024];
KV86M_REGISTERS regs;
NTSTATUS Status;
struct vesa_info* vi;
for (i = 0; i < (640 / 4); i++)
{
MmCreateVirtualMapping(NULL,
(PVOID)(i * 4096),
PAGE_EXECUTE_READWRITE,
(ULONG)MmAllocPage(0));
}
for (; i < (1024 / 4); i++)
{
MmCreateVirtualMapping(NULL,
(PVOID)(i * 4096),
PAGE_EXECUTE_READ,
i * 4096);
}
vi = (struct vesa_info*)0x20000;
vi->Signature[0] = 'V';
vi->Signature[1] = 'B';
vi->Signature[2] = 'E';
vi->Signature[3] = '2';
memset(&regs, 0, sizeof(regs));
regs.Eax = 0x4F00;
regs.Es = 0x2000;
regs.Edi = 0x0;
memcpy((PVOID)0x0, OrigIVT, 1024);
Status = Ke386CallBios(0x10, &regs);
DbgPrint("Finished (Status %x, CS:EIP %x:%x)\n", Status, regs.Cs,
regs.Eip);
DbgPrint("Eax %x\n", regs.Eax);
DbgPrint("Signature %.4s\n", vi->Signature);
DbgPrint("TotalVideoMemory %dKB\n", vi->TotalVideoMemory * 64);
}
#endif
VOID VOID
ExpInitializeExecutive(VOID) ExpInitializeExecutive(VOID)
{ {
/* ULONG i;
* Initialization phase 0 ULONG start;
*/ PCHAR name;
HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); CHAR str[50];
/* Execute executive initialization code on bootstrap processor only */ /*
if (!Initialized) * Fail at runtime if someone has changed various structures without
{ * updating the offsets used for the assembler code.
Initialized = TRUE; */
DPRINT("Phase 0 initialization started...\n"); assert(FIELD_OFFSET(KTHREAD, InitialStack) == KTHREAD_INITIAL_STACK);
assert(FIELD_OFFSET(KTHREAD, Teb) == KTHREAD_TEB);
assert(FIELD_OFFSET(KTHREAD, KernelStack) == KTHREAD_KERNEL_STACK);
assert(FIELD_OFFSET(KTHREAD, PreviousMode) == KTHREAD_PREVIOUS_MODE);
assert(FIELD_OFFSET(KTHREAD, TrapFrame) == KTHREAD_TRAP_FRAME);
assert(FIELD_OFFSET(ETHREAD, ThreadsProcess) == ETHREAD_THREADS_PROCESS);
assert(FIELD_OFFSET(KPROCESS, DirectoryTableBase) ==
KPROCESS_DIRECTORY_TABLE_BASE);
assert(FIELD_OFFSET(KTRAP_FRAME, Reserved9) == KTRAP_FRAME_RESERVED9);
assert(FIELD_OFFSET(KV86M_TRAP_FRAME, regs) == TF_REGS);
assert(FIELD_OFFSET(KV86M_TRAP_FRAME, orig_ebp) == TF_ORIG_EBP);
/* assert(FIELD_OFFSET(KPCR, ExceptionList) == KPCR_EXCEPTION_LIST);
* Fail at runtime if someone has changed various structures without assert(FIELD_OFFSET(KPCR, Self) == KPCR_SELF);
* updating the offsets used for the assembler code. assert(FIELD_OFFSET(KPCR, CurrentThread) == KPCR_CURRENT_THREAD);
*/
assert(FIELD_OFFSET(KTHREAD, InitialStack) == KTHREAD_INITIAL_STACK);
assert(FIELD_OFFSET(KTHREAD, Teb) == KTHREAD_TEB);
assert(FIELD_OFFSET(KTHREAD, KernelStack) == KTHREAD_KERNEL_STACK);
assert(FIELD_OFFSET(KTHREAD, PreviousMode) == KTHREAD_PREVIOUS_MODE);
assert(FIELD_OFFSET(KTHREAD, TrapFrame) == KTHREAD_TRAP_FRAME);
assert(FIELD_OFFSET(ETHREAD, ThreadsProcess) == ETHREAD_THREADS_PROCESS);
assert(FIELD_OFFSET(KPROCESS, PageTableDirectory) ==
KPROCESS_PAGE_TABLE_DIRECTORY);
assert(FIELD_OFFSET(KTRAP_FRAME, Reserved9) == KTRAP_FRAME_RESERVED9);
assert(FIELD_OFFSET(KV86M_TRAP_FRAME, regs) == TF_REGS);
assert(FIELD_OFFSET(KV86M_TRAP_FRAME, orig_ebp) == TF_ORIG_EBP);
assert(FIELD_OFFSET(KPCR, ExceptionList) == KPCR_EXCEPTION_LIST); LdrInit1();
assert(FIELD_OFFSET(KPCR, Self) == KPCR_SELF);
assert(FIELD_OFFSET(KPCR, CurrentThread) == KPCR_CURRENT_THREAD);
LdrInit1(); KeLowerIrql(DISPATCH_LEVEL);
KeLowerIrql(DISPATCH_LEVEL); NtEarlyInitVdm();
NtEarlyInitVdm(); MmInit1(FirstKrnlPhysAddr, LastKrnlPhysAddr, LastKernelAddress);
MmInit1(FirstKrnlPhysAddr, LastKrnlPhysAddr, LastKernelAddress); /*
* Initialize the kernel debugger
*/
KdInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
if (KdPollBreakIn ())
{
DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C);
}
/* MmInit2();
* Initialize the kernel debugger KeInit2();
*/
KdInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
if (KdPollBreakIn ())
{
DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C);
}
MmInit2(); KeLowerIrql(PASSIVE_LEVEL);
KeInit2();
{ ObInit();
char tmpbuf[80]; PiInitProcessManager();
sprintf(tmpbuf,"System with %d/%d MB memory\n",
(unsigned int)(KeLoaderBlock.MemLower)/1024,
(unsigned int)(KeLoaderBlock.MemHigher)/1024);
HalDisplayString(tmpbuf);
}
KeLowerIrql(PASSIVE_LEVEL); /*
* Display version number and copyright/warranty message
*/
HalDisplayString("Starting ReactOS "KERNEL_VERSION_STR" (Build "
KERNEL_VERSION_BUILD_STR")\n");
HalDisplayString(RES_STR_LEGAL_COPYRIGHT);
HalDisplayString("\n\nReactOS is free software, covered by the GNU General "
"Public License, and you\n");
HalDisplayString("are welcome to change it and/or distribute copies of it "
"under certain\n");
HalDisplayString("conditions. There is absolutely no warranty for "
"ReactOS.\n");
ObInit(); /* Initialize all processors */
PiInitProcessManager(); KeNumberProcessors = 0;
/* while (!HalAllProcessorsStarted())
* Allow interrupts {
*/ HalInitializeProcessor(KeNumberProcessors);
__asm__ ("sti\n\t"); KeNumberProcessors++;
}
#ifdef MP if (KeNumberProcessors > 1)
//Phase1Initialization(NULL); {
#endif
}
}
VOID
KiSystemStartup(VOID)
{
ExpInitializeExecutive();
for (;;)
{
NtYieldExecution();
}
}
/* Initialization phase 1 */
VOID Phase1Initialization(PVOID Context)
{
ULONG i;
ULONG start;
PCHAR name;
CHAR str[50];
DPRINT("Initialization phase 1 started...\n");
/*
* Display version number and copyright/warranty message
*/
HalDisplayString("Starting ReactOS "KERNEL_VERSION_STR" (Build "
KERNEL_VERSION_BUILD_STR")\n");
HalDisplayString(RES_STR_LEGAL_COPYRIGHT);
HalDisplayString("\n\nReactOS is free software, covered by the GNU General "
"Public License, and you\n");
HalDisplayString("are welcome to change it and/or distribute copies of it "
"under certain\n");
HalDisplayString("conditions. There is absolutely no warranty for ReactOS.\n");
/* Initialize all processors */
KeNumberProcessors = 0;
while (!HalAllProcessorsStarted())
{
HalInitializeProcessor(
KeNumberProcessors);
KeNumberProcessors++;
}
if (KeNumberProcessors > 1)
{
sprintf(str, "Found %d system processors.\n", sprintf(str, "Found %d system processors.\n",
KeNumberProcessors); KeNumberProcessors);
} }
else else
{ {
strcpy(str, "Found 1 system processor.\n"); strcpy(str, "Found 1 system processor.\n");
} }
HalDisplayString(str); HalDisplayString(str);
#ifdef MP #ifdef MP
DbgPrint("BSP halted\n"); DbgPrint("BSP halted\n");
for (;;); for (;;);
#endif /* MP */ #endif /* MP */
/* /*
* Initialize various critical subsystems * Initialize various critical subsystems
*/ */
HalInitSystem (1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); HalInitSystem (1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
ExInit(); ExInit();
IoInit(); IoInit();
LdrInitModuleManagement(); LdrInitModuleManagement();
CmInitializeRegistry(); CmInitializeRegistry();
NtInit(); NtInit();
MmInit3(); MmInit3();
/* Report all resources used by hal */ /* Report all resources used by hal */
HalReportResourceUsage (); HalReportResourceUsage ();
/* /*
* Enter the kernel debugger before starting up the boot drivers * Enter the kernel debugger before starting up the boot drivers
*/ */
#ifdef KDBG #ifdef KDBG
KdbEnter(); KdbEnter();
#endif /* KDBG */ #endif /* KDBG */
/* /*
* Initalize services loaded at boot time * Initalize services loaded at boot time
*/ */
DPRINT1("%d files loaded\n",KeLoaderBlock.ModsCount); DPRINT1("%d files loaded\n",KeLoaderBlock.ModsCount);
for (i=0; i < KeLoaderBlock.ModsCount; i++) for (i=0; i < KeLoaderBlock.ModsCount; i++)
{ {
DPRINT1("module: %s\n", KeLoaderModules[i].String); DPRINT1("module: %s\n", KeLoaderModules[i].String);
} }
/* Pass 1: load registry chunks passed in */ /* Pass 1: load registry chunks passed in */
for (i = 1; i < KeLoaderBlock.ModsCount; i++) for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{ {
start = KeLoaderModules[i].ModStart; start = KeLoaderModules[i].ModStart;
if (strcmp ((PCHAR) start, "REGEDIT4") == 0) if (strcmp ((PCHAR) start, "REGEDIT4") == 0)
{ {
DPRINT1("process registry chunk at %08lx\n", start); DPRINT1("process registry chunk at %08lx\n", start);
CmImportHive((PCHAR) start); CmImportHive((PCHAR) start);
}
}
/* Pass 2: process boot loaded drivers */
for (i=1; i < KeLoaderBlock.ModsCount; i++)
{
start = KeLoaderModules[i].ModStart;
name = (PCHAR)KeLoaderModules[i].String;
if (strcmp ((PCHAR) start, "REGEDIT4") != 0)
{
DPRINT1("process module '%s' at %08lx\n", name, start);
LdrProcessDriver((PVOID)start, name);
}
} }
}
DPRINT("About to try MmAllocateContiguousAlignedMemory\n"); /* Pass 2: process boot loaded drivers */
do for (i=1; i < KeLoaderBlock.ModsCount; i++)
{ {
extern PVOID STDCALL start = KeLoaderModules[i].ModStart;
MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes, name = (PCHAR)KeLoaderModules[i].String;
IN PHYSICAL_ADDRESS HighestAcceptableAddress, if (strcmp ((PCHAR) start, "REGEDIT4") != 0)
IN ULONG Alignment); {
PVOID v; DPRINT1("process module '%s' at %08lx\n", name, start);
PHYSICAL_ADDRESS p; LdrProcessDriver((PVOID)start, name);
p.QuadPart = 16*1024*1024; }
v = MmAllocateContiguousAlignedMemory(12*1024, p, }
64*1024);
if (v != NULL)
{
DPRINT("Worked\n");
}
else
{
DPRINT("Failed\n");
}
}
while (0);
/* Create the SystemRoot symbolic link */ /* Create the SystemRoot symbolic link */
DbgPrint("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine); DbgPrint("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine);
CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine); CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine);
#ifdef DBGPRINT_FILE_LOG #ifdef DBGPRINT_FILE_LOG
/* On the assumption that we can now access disks start up the debug /* On the assumption that we can now access disks start up the debug
logger thread */ logger thread */
DebugLogInit2(); DebugLogInit2();
#endif /* DBGPRINT_FILE_LOG */ #endif /* DBGPRINT_FILE_LOG */
CmInitializeRegistry2(); CmInitializeRegistry2();
/* /*
* Load Auto configured drivers * Load Auto configured drivers
*/ */
LdrLoadAutoConfigDrivers(); LdrLoadAutoConfigDrivers();
/* /*
* Assign drive letters * Assign drive letters
*/ */
IoAssignDriveLetters ((PLOADER_PARAMETER_BLOCK)&KeLoaderBlock, IoAssignDriveLetters ((PLOADER_PARAMETER_BLOCK)&KeLoaderBlock,
NULL, NULL,
NULL, NULL,
NULL); NULL);
/* /*
* Initialize shared user page: * Initialize shared user page:
* - set dos system path, dos device map, etc. * - set dos system path, dos device map, etc.
*/ */
InitSystemSharedUserPage ((PUCHAR)KeLoaderBlock.CommandLine); InitSystemSharedUserPage ((PUCHAR)KeLoaderBlock.CommandLine);
/* /*
* Launch initial process * Launch initial process
*/ */
LdrLoadInitialProcess(); LdrLoadInitialProcess();
DbgPrint("Finished kernel initialization.\n"); PsTerminateSystemThread(STATUS_SUCCESS);
}
/* FIXME: Call zero page thread function */ VOID
PsTerminateSystemThread(STATUS_SUCCESS); KiSystemStartup(BOOLEAN BootProcessor)
{
HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
if (BootProcessor)
{
/* Never returns */
ExpInitializeExecutive();
KeBugCheck(0);
}
/* Do application processor initialization */
for(;;);
} }
VOID VOID
@ -697,58 +597,51 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
* invalid after the memory managment is initialized so we make a local copy. * invalid after the memory managment is initialized so we make a local copy.
*/ */
{ {
ULONG i; ULONG i;
ULONG last_kernel_address; ULONG last_kernel_address;
extern ULONG _bss_end__; extern ULONG _bss_end__;
/* /*
* Copy the parameters to a local buffer because lowmem will go away * Copy the parameters to a local buffer because lowmem will go away
*/ */
memcpy (&KeLoaderBlock, _LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK)); memcpy (&KeLoaderBlock, _LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK));
memcpy (&KeLoaderModules[1], (PVOID)KeLoaderBlock.ModsAddr, memcpy (&KeLoaderModules[1], (PVOID)KeLoaderBlock.ModsAddr,
sizeof(LOADER_MODULE) * KeLoaderBlock.ModsCount); sizeof(LOADER_MODULE) * KeLoaderBlock.ModsCount);
KeLoaderBlock.ModsCount++; KeLoaderBlock.ModsCount++;
KeLoaderBlock.ModsAddr = (ULONG)&KeLoaderModules; KeLoaderBlock.ModsAddr = (ULONG)&KeLoaderModules;
/* /*
* FIXME: Preliminary hack!!!! Add boot device to beginning of command line. * FIXME: Preliminary hack!!!! Add boot device to beginning of command line.
* This should be done by the boot loader. * This should be done by the boot loader.
*/ */
strcpy (KeLoaderCommandLine, strcpy (KeLoaderCommandLine,
"multi(0)disk(0)rdisk(0)partition(1)\\reactos /DEBUGPORT=SCREEN"); "multi(0)disk(0)rdisk(0)partition(1)\\reactos /DEBUGPORT=SCREEN");
strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine); strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine);
KeLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine; KeLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine;
strcpy(KeLoaderModuleStrings[0], "ntoskrnl.exe"); strcpy(KeLoaderModuleStrings[0], "ntoskrnl.exe");
KeLoaderModules[0].String = (ULONG)KeLoaderModuleStrings[0]; KeLoaderModules[0].String = (ULONG)KeLoaderModuleStrings[0];
KeLoaderModules[0].ModStart = 0xC0000000; KeLoaderModules[0].ModStart = 0xC0000000;
KeLoaderModules[0].ModEnd = PAGE_ROUND_UP((ULONG)&_bss_end__); KeLoaderModules[0].ModEnd = PAGE_ROUND_UP((ULONG)&_bss_end__);
for (i = 1; i < KeLoaderBlock.ModsCount; i++) for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{ {
strcpy(KeLoaderModuleStrings[i], (PUCHAR)KeLoaderModules[i].String); strcpy(KeLoaderModuleStrings[i], (PUCHAR)KeLoaderModules[i].String);
KeLoaderModules[i].ModStart -= 0x200000; KeLoaderModules[i].ModStart -= 0x200000;
KeLoaderModules[i].ModStart += 0xc0000000; KeLoaderModules[i].ModStart += 0xc0000000;
KeLoaderModules[i].ModEnd -= 0x200000; KeLoaderModules[i].ModEnd -= 0x200000;
KeLoaderModules[i].ModEnd += 0xc0000000; KeLoaderModules[i].ModEnd += 0xc0000000;
KeLoaderModules[i].String = (ULONG)KeLoaderModuleStrings[i]; KeLoaderModules[i].String = (ULONG)KeLoaderModuleStrings[i];
} }
last_kernel_address = KeLoaderModules[KeLoaderBlock.ModsCount - 1].ModEnd; last_kernel_address = KeLoaderModules[KeLoaderBlock.ModsCount - 1].ModEnd;
FirstKrnlPhysAddr = KeLoaderModules[0].ModStart - 0xc0000000 + 0x200000; FirstKrnlPhysAddr = KeLoaderModules[0].ModStart - 0xc0000000 + 0x200000;
LastKrnlPhysAddr = last_kernel_address - 0xc0000000 + 0x200000; LastKrnlPhysAddr = last_kernel_address - 0xc0000000 + 0x200000;
LastKernelAddress = last_kernel_address; LastKernelAddress = last_kernel_address;
KeInit1(); KeInit1();
#if 0 KiSystemStartup(1);
/*
* Allow interrupts
*/
__asm__ ("sti\n\t");
#endif
KiSystemStartup();
} }
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: process.c,v 1.7 2001/03/16 23:04:59 dwelch Exp $ /* $Id: process.c,v 1.8 2001/04/16 02:02:04 dwelch Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/process.c * FILE: ntoskrnl/ke/process.c
@ -60,7 +60,7 @@ KeAttachProcess (PEPROCESS Process)
CurrentThread->OldProcess = PsGetCurrentProcess(); CurrentThread->OldProcess = PsGetCurrentProcess();
CurrentThread->ThreadsProcess = Process; CurrentThread->ThreadsProcess = Process;
PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.PageTableDirectory; PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.DirectoryTableBase[0];
DPRINT("Switching process context to %x\n",PageDir) DPRINT("Switching process context to %x\n",PageDir)
__asm__("movl %0,%%cr3\n\t" __asm__("movl %0,%%cr3\n\t"
: /* no inputs */ : /* no inputs */
@ -91,7 +91,7 @@ KeDetachProcess (VOID)
CurrentThread->ThreadsProcess = CurrentThread->OldProcess; CurrentThread->ThreadsProcess = CurrentThread->OldProcess;
CurrentThread->OldProcess = NULL; CurrentThread->OldProcess = NULL;
PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.PageTableDirectory; PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.DirectoryTableBase[0];
__asm__("movl %0,%%cr3\n\t" __asm__("movl %0,%%cr3\n\t"
: /* no inputs */ : /* no inputs */
: "r" (PageDir)); : "r" (PageDir));

View file

@ -1,4 +1,4 @@
/* $Id: loader.c,v 1.72 2001/04/11 12:46:05 chorns Exp $ /* $Id: loader.c,v 1.73 2001/04/16 02:02:05 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -20,6 +20,7 @@
* CSH 11/04/2001 Added automatic loading of module symbols if they exist * CSH 11/04/2001 Added automatic loading of module symbols if they exist
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <limits.h> #include <limits.h>
@ -79,6 +80,33 @@ static PVOID LdrPEFixupForward(PCHAR ForwardName);
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID
LdrInitDebug(PLOADER_MODULE Module, PWCH Name)
{
PLIST_ENTRY current_entry;
MODULE_TEXT_SECTION* current;
current_entry = ModuleTextListHead.Flink;
while (current_entry != &ModuleTextListHead)
{
current =
CONTAINING_RECORD(current_entry, MODULE_TEXT_SECTION, ListEntry);
if (wcscmp(current->Name, Name) == 0)
{
break;
}
current_entry = current_entry->Flink;
}
if (current_entry == &ModuleTextListHead)
{
return;
}
current->SymbolsBase = (PVOID)Module->ModStart;
current->SymbolsLength = Module->ModEnd - Module->ModStart;
}
VOID VOID
LdrInit1(VOID) LdrInit1(VOID)
{ {
@ -101,6 +129,8 @@ LdrInit1(VOID)
NtoskrnlTextSection.Length = SectionList[0].Misc.VirtualSize + NtoskrnlTextSection.Length = SectionList[0].Misc.VirtualSize +
SectionList[0].VirtualAddress; SectionList[0].VirtualAddress;
NtoskrnlTextSection.Name = L"ntoskrnl.exe"; NtoskrnlTextSection.Name = L"ntoskrnl.exe";
NtoskrnlTextSection.SymbolsBase = NULL;
NtoskrnlTextSection.SymbolsLength = 0;
InsertTailList(&ModuleTextListHead, &NtoskrnlTextSection.ListEntry); InsertTailList(&ModuleTextListHead, &NtoskrnlTextSection.ListEntry);
} }
@ -359,7 +389,7 @@ PSYMBOL LdrParseLine(PCHAR Line,
} }
VOID LdrLoadModuleSymbols(PMODULE_OBJECT ModuleObject, VOID LdrLoadModuleSymbols(PMODULE_OBJECT ModuleObject,
MODULE_TEXT_SECTION* ModuleTextSection) MODULE_TEXT_SECTION* ModuleTextSection)
/* /*
Symbols must be sorted by address, e.g. Symbols must be sorted by address, e.g.
"nm --numeric-sort module.sys > module.sym" "nm --numeric-sort module.sys > module.sym"
@ -1303,6 +1333,8 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING FileName)
sizeof(MODULE_TEXT_SECTION)); sizeof(MODULE_TEXT_SECTION));
ModuleTextSection->Base = (ULONG)DriverBase; ModuleTextSection->Base = (ULONG)DriverBase;
ModuleTextSection->Length = DriverSize; ModuleTextSection->Length = DriverSize;
ModuleTextSection->SymbolsBase = NULL;
ModuleTextSection->SymbolsLength = 0;
ModuleTextSection->Name = ModuleTextSection->Name =
ExAllocatePool(NonPagedPool, ExAllocatePool(NonPagedPool,
(wcslen(NameBuffer) + 1) * sizeof(WCHAR)); (wcslen(NameBuffer) + 1) * sizeof(WCHAR));

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: page.c,v 1.26 2001/04/13 16:12:26 chorns Exp $ /* $Id: page.c,v 1.27 2001/04/16 02:02:05 dwelch Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/i386/page.c * FILE: ntoskrnl/mm/i386/page.c
@ -117,8 +117,8 @@ NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process)
{ {
DPRINT("Mmi386ReleaseMmInfo(Process %x)\n",Process); DPRINT("Mmi386ReleaseMmInfo(Process %x)\n",Process);
MmDereferencePage(Process->Pcb.PageTableDirectory); MmDereferencePage(Process->Pcb.DirectoryTableBase[0]);
Process->Pcb.PageTableDirectory = NULL; Process->Pcb.DirectoryTableBase[0] = NULL;
DPRINT("Finished Mmi386ReleaseMmInfo()\n"); DPRINT("Finished Mmi386ReleaseMmInfo()\n");
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
@ -140,7 +140,7 @@ NTSTATUS MmCopyMmInfo(PEPROCESS Src, PEPROCESS Dest)
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
PhysPageDirectory = (PULONG)(MmGetPhysicalAddress(PageDirectory)).u.LowPart; PhysPageDirectory = (PULONG)(MmGetPhysicalAddress(PageDirectory)).u.LowPart;
KProcess->PageTableDirectory = PhysPageDirectory; KProcess->DirectoryTableBase[0] = PhysPageDirectory;
CurrentPageDirectory = (PULONG)PAGEDIRECTORY_MAP; CurrentPageDirectory = (PULONG)PAGEDIRECTORY_MAP;
memset(PageDirectory,0,PAGESIZE); memset(PageDirectory,0,PAGESIZE);

View file

@ -203,18 +203,18 @@ PiTerminateProcess(PEPROCESS Process, NTSTATUS ExitStatus)
Process, ExitStatus, ObGetReferenceCount(Process), Process, ExitStatus, ObGetReferenceCount(Process),
ObGetHandleCount(Process)); ObGetHandleCount(Process));
if (Process->Pcb.ProcessState == PROCESS_STATE_TERMINATED) if (InterlockedExchange((PLONG)&Process->Pcb.State,
PROCESS_STATE_TERMINATED) ==
PROCESS_STATE_TERMINATED)
{ {
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
ObCloseAllHandles(Process); ObCloseAllHandles(Process);
KeAcquireDispatcherDatabaseLock(FALSE); KeAcquireDispatcherDatabaseLock(FALSE);
Process->Pcb.ProcessState = PROCESS_STATE_TERMINATED;
Process->Pcb.DispatcherHeader.SignalState = TRUE; Process->Pcb.DispatcherHeader.SignalState = TRUE;
KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader); KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader);
KeReleaseDispatcherDatabaseLock(FALSE); KeReleaseDispatcherDatabaseLock(FALSE);
DPRINT("RC %d\n", ObGetReferenceCount(Process));
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -234,9 +234,9 @@ NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle,
(PVOID*)&Process, (PVOID*)&Process,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return(Status); return(Status);
} }
PiTerminateProcessThreads(Process, ExitStatus); PiTerminateProcessThreads(Process, ExitStatus);
if (PsGetCurrentThread()->ThreadsProcess == Process) if (PsGetCurrentThread()->ThreadsProcess == Process)

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.60 2001/03/25 02:34:29 dwelch Exp $ /* $Id: process.c,v 1.61 2001/04/16 02:02:06 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -36,7 +36,7 @@ HANDLE SystemProcessHandle = NULL;
POBJECT_TYPE EXPORTED PsProcessType = NULL; POBJECT_TYPE EXPORTED PsProcessType = NULL;
static LIST_ENTRY PsProcessListHead; LIST_ENTRY PsProcessListHead;
static KSPIN_LOCK PsProcessListLock; static KSPIN_LOCK PsProcessListLock;
static ULONG PiNextProcessUniqueId = 0; static ULONG PiNextProcessUniqueId = 0;
@ -216,7 +216,7 @@ VOID PsInitProcessManagment(VOID)
MmInitializeAddressSpace(PsInitialSystemProcess, MmInitializeAddressSpace(PsInitialSystemProcess,
&PsInitialSystemProcess->AddressSpace); &PsInitialSystemProcess->AddressSpace);
ObCreateHandleTable(NULL,FALSE,PsInitialSystemProcess); ObCreateHandleTable(NULL,FALSE,PsInitialSystemProcess);
KProcess->PageTableDirectory = MmGetPageDirectory(); KProcess->DirectoryTableBase[0] = MmGetPageDirectory();
PsInitialSystemProcess->UniqueProcessId = PsInitialSystemProcess->UniqueProcessId =
InterlockedIncrement(&PiNextProcessUniqueId); InterlockedIncrement(&PiNextProcessUniqueId);
@ -396,7 +396,8 @@ NtCreateProcess (OUT PHANDLE ProcessHandle,
MmInitializeAddressSpace(Process, MmInitializeAddressSpace(Process,
&Process->AddressSpace); &Process->AddressSpace);
Process->UniqueProcessId = InterlockedIncrement(&PiNextProcessUniqueId); Process->UniqueProcessId = InterlockedIncrement(&PiNextProcessUniqueId);
Process->InheritedFromUniqueProcessId = ParentProcess->UniqueProcessId; Process->InheritedFromUniqueProcessId =
(HANDLE)ParentProcess->UniqueProcessId;
ObCreateHandleTable(ParentProcess, ObCreateHandleTable(ParentProcess,
InheritObjectTable, InheritObjectTable,
Process); Process);
@ -407,7 +408,7 @@ NtCreateProcess (OUT PHANDLE ProcessHandle,
InitializeListHead(&Process->ThreadListHead); InitializeListHead(&Process->ThreadListHead);
KeReleaseSpinLock(&PsProcessListLock, oldIrql); KeReleaseSpinLock(&PsProcessListLock, oldIrql);
Process->Pcb.ProcessState = PROCESS_STATE_ACTIVE; Process->Pcb.State = PROCESS_STATE_ACTIVE;
/* /*
* Add the debug port * Add the debug port
@ -678,7 +679,7 @@ NTSTATUS STDCALL NtQueryInformationProcess (IN HANDLE ProcessHandle,
ProcessBasicInformationP->UniqueProcessId = ProcessBasicInformationP->UniqueProcessId =
Process->UniqueProcessId; Process->UniqueProcessId;
ProcessBasicInformationP->InheritedFromUniqueProcessId = ProcessBasicInformationP->InheritedFromUniqueProcessId =
Process->InheritedFromUniqueProcessId; (ULONG)Process->InheritedFromUniqueProcessId;
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;

View file

@ -1,4 +1,4 @@
/* $Id: psmgr.c,v 1.8 2001/04/13 16:12:26 chorns Exp $ /* $Id: psmgr.c,v 1.9 2001/04/16 02:02:07 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -27,32 +27,10 @@ VOID PiShutdownProcessManager(VOID)
VOID PiInitProcessManager(VOID) VOID PiInitProcessManager(VOID)
{ {
#ifndef MP
HANDLE Phase1InitializationHandle;
NTSTATUS Status;
#endif
PsInitProcessManagment(); PsInitProcessManagment();
PsInitThreadManagment(); PsInitThreadManagment();
PsInitIdleThread(); PsInitIdleThread();
PiInitApcManagement(); PiInitApcManagement();
#ifndef MP
/* Create thread for Phase1Initialization */
Status = PsCreateSystemThread(
&Phase1InitializationHandle, /* Thread handle */
0, /* Desired access */
NULL, /* Object attributes */
NULL, /* Process handle */
NULL, /* Client id */
(PKSTART_ROUTINE)Phase1Initialization, /* Start routine */
NULL); /* Start context */
if (!NT_SUCCESS(Status)) {
DPRINT1("Could not create system thread (Status 0x%X)\n", Status);
KeBugCheck(0);
}
ZwClose(Phase1InitializationHandle);
#endif
} }

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.73 2001/03/25 02:34:29 dwelch Exp $ /* $Id: thread.c,v 1.74 2001/04/16 02:02:07 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -454,7 +454,8 @@ NtContinue(IN PCONTEXT Context,
NTSTATUS STDCALL NTSTATUS STDCALL
NtYieldExecution(VOID) NtYieldExecution(VOID)
{ {
return(STATUS_SUCCESS); PsDispatchThread(THREAD_STATE_RUNNABLE);
return(STATUS_SUCCESS);
} }

View file

@ -1,4 +1,4 @@
/* $Id: ctype.c,v 1.4 2000/01/11 01:16:50 ekohl Exp $ /* $Id: ctype.c,v 1.5 2001/04/16 02:02:07 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -290,12 +290,13 @@ int iswctype(wint_t wc, wctype_t wctypeFlags)
return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags); return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
} }
/*
int isalpha(int c) int isalpha(int c)
{ {
return(_isctype(c, _ALPHA)); return(_isctype(c, _ALPHA));
} }
/*
int isalnum(int c) int isalnum(int c)
{ {
return(_isctype(c, _ALPHA | _DIGIT)); return(_isctype(c, _ALPHA | _DIGIT));