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>
/*
* IRQ levels
*/
#if 0
#define PASSIVE_LEVEL (1)
#define APC_LEVEL (2)
#define DISPATCH_LEVEL (3)
#define FIRST_DEVICE_SPECIFIC_LEVEL (4)
#define HIGH_LEVEL (FIRST_DEVICE_SPECIFIC_LEVEL + NR_DEVICE_SPECIFIC_LEVELS)
#else
/* NT's IRQL */
#define PASSIVE_LEVEL 0 // Passive release level #define PASSIVE_LEVEL 0 // Passive release level
#define LOW_LEVEL 0 // Lowest interrupt level #define LOW_LEVEL 0 // Lowest interrupt level
#define APC_LEVEL 1 // APC interrupt level #define APC_LEVEL 1 // APC interrupt level
#define DISPATCH_LEVEL 2 // Dispatcher level #define DISPATCH_LEVEL 2 // Dispatcher level
#define PROFILE_LEVEL 27 // Timer used for profiling /* timer used for profiling */
#define CLOCK1_LEVEL 28 // Interval clock 1 level - Not used on x86 #define PROFILE_LEVEL 27
/* Interval clock 1 level - Not used on x86 */
#define CLOCK1_LEVEL 28
#define CLOCK2_LEVEL 28 // Interval clock 2 level #define CLOCK2_LEVEL 28 // Interval clock 2 level
#define IPI_LEVEL 29 // Interprocessor interrupt level #define IPI_LEVEL 29 // Interprocessor interrupt level
#define POWER_LEVEL 30 // Power failure level #define POWER_LEVEL 30 // Power failure level
#define HIGH_LEVEL 31 // Highest interrupt level #define HIGH_LEVEL 31 // Highest interrupt level
#define SYNCH_LEVEL (IPI_LEVEL-1) // Synchronization 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

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,19 +56,8 @@ 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;
mask = READ_PORT_UCHAR((PUCHAR)0x21);
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)0x21,mask & 0xff);
WRITE_PORT_UCHAR((PUCHAR)0xa1,(mask >> 8) & 0xff); WRITE_PORT_UCHAR((PUCHAR)0xa1,(mask >> 8) & 0xff);
@ -84,18 +76,38 @@ static VOID HiSwitchIrql(KIRQL oldIrql)
CurrentThread = KeGetCurrentThread(); CurrentThread = KeGetCurrentThread();
if (CurrentIrql == HIGH_LEVEL) /*
* Disable all interrupts
*/
if (CurrentIrql >= IPI_LEVEL)
{ {
HiSetCurrentPICMask(0xffff); HiSetCurrentPICMask(0xFFFF);
__asm__("sti\n\t");
return; return;
} }
/*
* Disable all interrupts but the timer
*/
if (CurrentIrql == PROFILE_LEVEL ||
CurrentIrql == CLOCK1_LEVEL ||
CurrentIrql == CLOCK2_LEVEL)
{
HiSetCurrentPICMask(0xFFFE);
__asm__("sti\n\t");
return;
}
/*
* Disable all interrupts of lesser priority
*/
if (CurrentIrql > DISPATCH_LEVEL) if (CurrentIrql > DISPATCH_LEVEL)
{ {
unsigned int current_mask = 0; unsigned int current_mask = 0;
for (i=CurrentIrql; i>DISPATCH_LEVEL; i--) for (i = CurrentIrql; i > (PROFILE_LEVEL - 15); i--)
{ {
current_mask = current_mask | (1 << (HIGH_LEVEL - i)); current_mask = current_mask | (1 << (PROFILE_LEVEL - i));
} }
HiSetCurrentPICMask(current_mask); HiSetCurrentPICMask(current_mask);
@ -103,6 +115,9 @@ static VOID HiSwitchIrql(KIRQL oldIrql)
return; 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();
__asm__("cli\n\t"); CurrentIrql = APC_LEVEL;
KeSetCurrentIrql(PASSIVE_LEVEL);
} }
__asm__("sti\n\t");
return; return;
} }
if (CurrentIrql == PASSIVE_LEVEL && /*
CurrentThread != NULL && * Execute any pending DPCs or APCs
*/
if (CurrentIrql == PASSIVE_LEVEL)
{
if (DpcQueueSize > 0)
{
CurrentIrql = DISPATCH_LEVEL;
KiDispatchInterrupt();
CurrentIrql = PASSIVE_LEVEL;
}
if (CurrentThread != NULL &&
CurrentThread->ApcState.KernelApcPending) CurrentThread->ApcState.KernelApcPending)
{ {
KeSetCurrentIrql(APC_LEVEL); CurrentIrql = APC_LEVEL;
__asm__("sti\n\t");
KiDeliverApc(0, 0, 0); KiDeliverApc(0, 0, 0);
__asm__("cli\n\t"); CurrentIrql = PASSIVE_LEVEL;
KeSetCurrentIrql(PASSIVE_LEVEL);
__asm__("sti\n\t");
} }
else
{
__asm__("sti\n\t");
} }
} }
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,12 +174,12 @@ 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,9 +202,7 @@ static VOID KeSetCurrentIrql(KIRQL newlvl)
*/ */
VOID FASTCALL VOID FASTCALL
KfLowerIrql ( KfLowerIrql (KIRQL NewIrql)
KIRQL NewIrql
)
{ {
KIRQL OldIrql; KIRQL OldIrql;
@ -221,11 +240,8 @@ KfLowerIrql (
* NOTES * NOTES
*/ */
VOID VOID STDCALL
STDCALL KeLowerIrql (KIRQL NewIrql)
KeLowerIrql (
KIRQL NewIrql
)
{ {
KfLowerIrql (NewIrql); KfLowerIrql (NewIrql);
} }
@ -248,11 +264,8 @@ KeLowerIrql (
* Uses fastcall convention * Uses fastcall convention
*/ */
KIRQL KIRQL FASTCALL
FASTCALL KfRaiseIrql (KIRQL NewIrql)
KfRaiseIrql (
KIRQL NewIrql
)
{ {
KIRQL OldIrql; KIRQL OldIrql;
@ -295,13 +308,9 @@ 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,8 +333,7 @@ KeRaiseIrql (
* Calls KfRaiseIrql * Calls KfRaiseIrql
*/ */
KIRQL KIRQL STDCALL
STDCALL
KeRaiseIrqlToDpcLevel (VOID) KeRaiseIrqlToDpcLevel (VOID)
{ {
return KfRaiseIrql (DISPATCH_LEVEL); return KfRaiseIrql (DISPATCH_LEVEL);
@ -349,16 +357,16 @@ 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
HalBeginSystemInterrupt (ULONG Vector,
KIRQL Irql, KIRQL Irql,
PKIRQL OldIrql) PKIRQL OldIrql)
{ {
@ -399,13 +407,15 @@ BOOLEAN STDCALL HalDisableSystemInterrupt (ULONG Vector,
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 else
{ {
WRITE_PORT_UCHAR((PUCHAR)0xa1, READ_PORT_UCHAR((PUCHAR)0xa1)|(1<<(irq-8))); WRITE_PORT_UCHAR((PUCHAR)0xa1,
READ_PORT_UCHAR((PUCHAR)0xa1)|(1<<(irq-8)));
} }
return TRUE; return TRUE;
@ -422,13 +432,15 @@ BOOLEAN STDCALL HalEnableSystemInterrupt (ULONG Vector,
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 else
{ {
WRITE_PORT_UCHAR((PUCHAR)0xa1, READ_PORT_UCHAR((PUCHAR)0xa1)&(~(1<<(irq-8)))); WRITE_PORT_UCHAR((PUCHAR)0xa1,
READ_PORT_UCHAR((PUCHAR)0xa1)&(~(1<<(irq-8))));
} }
return TRUE; return TRUE;

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

@ -33,6 +33,8 @@ typedef struct _MODULE_TEXT_SECTION
#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,74 +278,156 @@ 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. */
LIST_ENTRY ActiveProcessLinks; /* 098 */
/* Unknown. */
ULONG QuotaPeakPoolUsage[2]; /* 0A0 */
/* Unknown. */
ULONG QuotaPoolUsage[2]; /* 0A8 */
/* Unknown. */
ULONG PagefileUsage; /* 0B0 */
/* Unknown. */
ULONG CommitCharge; /* 0B4 */
/* Unknown. */
ULONG PeakPagefileUsage; /* 0B8 */
/* Unknown. */
ULONG PeakVirtualSize; /* 0BC */
/* Unknown. */
LARGE_INTEGER VirtualSize; /* 0C0 */
struct
{
ULONG LastTrimTime;
ULONG LastTrimFaultCount;
ULONG PageFaultCount;
ULONG PeakWorkingSetSize;
ULONG WorkingSetSize;
ULONG MinimumWorkingSetSize;
ULONG MaximumWorkingSetSize;
ULONG VmWorkingSetList;
LIST_ENTRY WorkingSetExpansionList;
UCHAR AllowWorkingSetAdjustment;
UCHAR AddressSpaceBeingDeleted;
UCHAR ForegroundPrioritySwitch;
UCHAR MemoryPriority;
} Vm;
PVOID LastProtoPteFault; PVOID LastProtoPteFault;
struct _EPORT* DebugPort; struct _EPORT* DebugPort;
struct _EPORT* ExceptionPort; struct _EPORT* ExceptionPort;
PVOID ObjectTable; PVOID ObjectTable;
PVOID Token; PVOID Token;
// FAST_MUTEX WorkingSetLock;
KMUTEX WorkingSetLock; KMUTEX WorkingSetLock;
PVOID WorkingSetPage; PVOID WorkingSetPage;
UCHAR ProcessOutswapEnabled; UCHAR ProcessOutswapEnabled;
UCHAR ProcessOutswapped; UCHAR ProcessOutswapped;
UCHAR AddressSpaceInitialized; UCHAR AddressSpaceInitialized;
UCHAR AddressSpaceDeleted; UCHAR AddressSpaceDeleted;
KMUTEX AddressCreationLock; FAST_MUTEX AddressCreationLock;
PVOID ForkInProgress; KSPIN_LOCK HyperSpaceLock;
PVOID VmOperation; PETHREAD ForkInProgress;
USHORT VmOperation;
UCHAR ForkWasSuccessful;
UCHAR MmAgressiveWsTrimMask;
PKEVENT VmOperationEvent; PKEVENT VmOperationEvent;
PVOID PageDirectoryPte; PVOID PageDirectoryPte;
LARGE_INTEGER LastFaultCount; ULONG LastFaultCount;
PVOID VadRoot; PVOID VadRoot;
PVOID VadHint; PVOID VadHint;
PVOID CloneRoot; PVOID CloneRoot;
ULONG NumberOfPrivatePages; ULONG NumberOfPrivatePages;
ULONG NumberOfLockedPages; ULONG NumberOfLockedPages;
UCHAR ForkWasSuccessFul; USHORT NextProcessColour;
UCHAR ExitProcessCalled; UCHAR ExitProcessCalled;
UCHAR CreateProcessReported; UCHAR CreateProcessReported;
HANDLE SectionHandle; HANDLE SectionHandle;
@ -353,8 +435,8 @@ typedef struct _EPROCESS
PVOID SectionBaseAddress; PVOID SectionBaseAddress;
PVOID QuotaBlock; PVOID QuotaBlock;
NTSTATUS LastThreadExitStatus; NTSTATUS LastThreadExitStatus;
LARGE_INTEGER WorkingSetWatch; // PVOID WorkingSetWatch;
ULONG InheritedFromUniqueProcessId; HANDLE InheritedFromUniqueProcessId;
ACCESS_MASK GrantedAccess; ACCESS_MASK GrantedAccess;
ULONG DefaultHardErrorProcessing; ULONG DefaultHardErrorProcessing;
PVOID LdtInformation; PVOID LdtInformation;
@ -362,7 +444,12 @@ typedef struct _EPROCESS
PVOID VdmObjects; PVOID VdmObjects;
KMUTANT ProcessMutant; KMUTANT ProcessMutant;
CHAR ImageFileName[16]; CHAR ImageFileName[16];
LARGE_INTEGER VmTrimFaultValue; ULONG VmTrimFaultValue;
UCHAR SetTimerResolution;
UCHAR PriorityClass;
UCHAR SubSystemMinorVersion;
UCHAR SubSystemMajorVersion;
USHORT SubSystemVersion;
struct _WIN32PROCESSDATA *Win32Process; struct _WIN32PROCESSDATA *Win32Process;
/* /*

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

@ -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
@ -198,7 +199,6 @@ _multiboot_entry:
*/ */
/* 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
@ -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,62 +383,14 @@ 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)
{
Initialized = TRUE;
DPRINT("Phase 0 initialization started...\n");
/* /*
* Fail at runtime if someone has changed various structures without * Fail at runtime if someone has changed various structures without
@ -450,8 +402,8 @@ ExpInitializeExecutive(VOID)
assert(FIELD_OFFSET(KTHREAD, PreviousMode) == KTHREAD_PREVIOUS_MODE); assert(FIELD_OFFSET(KTHREAD, PreviousMode) == KTHREAD_PREVIOUS_MODE);
assert(FIELD_OFFSET(KTHREAD, TrapFrame) == KTHREAD_TRAP_FRAME); assert(FIELD_OFFSET(KTHREAD, TrapFrame) == KTHREAD_TRAP_FRAME);
assert(FIELD_OFFSET(ETHREAD, ThreadsProcess) == ETHREAD_THREADS_PROCESS); assert(FIELD_OFFSET(ETHREAD, ThreadsProcess) == ETHREAD_THREADS_PROCESS);
assert(FIELD_OFFSET(KPROCESS, PageTableDirectory) == assert(FIELD_OFFSET(KPROCESS, DirectoryTableBase) ==
KPROCESS_PAGE_TABLE_DIRECTORY); KPROCESS_DIRECTORY_TABLE_BASE);
assert(FIELD_OFFSET(KTRAP_FRAME, Reserved9) == KTRAP_FRAME_RESERVED9); assert(FIELD_OFFSET(KTRAP_FRAME, Reserved9) == KTRAP_FRAME_RESERVED9);
assert(FIELD_OFFSET(KV86M_TRAP_FRAME, regs) == TF_REGS); assert(FIELD_OFFSET(KV86M_TRAP_FRAME, regs) == TF_REGS);
assert(FIELD_OFFSET(KV86M_TRAP_FRAME, orig_ebp) == TF_ORIG_EBP); assert(FIELD_OFFSET(KV86M_TRAP_FRAME, orig_ebp) == TF_ORIG_EBP);
@ -480,51 +432,11 @@ ExpInitializeExecutive(VOID)
MmInit2(); MmInit2();
KeInit2(); KeInit2();
{
char tmpbuf[80];
sprintf(tmpbuf,"System with %d/%d MB memory\n",
(unsigned int)(KeLoaderBlock.MemLower)/1024,
(unsigned int)(KeLoaderBlock.MemHigher)/1024);
HalDisplayString(tmpbuf);
}
KeLowerIrql(PASSIVE_LEVEL); KeLowerIrql(PASSIVE_LEVEL);
ObInit(); ObInit();
PiInitProcessManager(); PiInitProcessManager();
/*
* Allow interrupts
*/
__asm__ ("sti\n\t");
#ifdef MP
//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 * Display version number and copyright/warranty message
*/ */
@ -535,15 +447,15 @@ VOID Phase1Initialization(PVOID Context)
"Public License, and you\n"); "Public License, and you\n");
HalDisplayString("are welcome to change it and/or distribute copies of it " HalDisplayString("are welcome to change it and/or distribute copies of it "
"under certain\n"); "under certain\n");
HalDisplayString("conditions. There is absolutely no warranty for ReactOS.\n"); HalDisplayString("conditions. There is absolutely no warranty for "
"ReactOS.\n");
/* Initialize all processors */ /* Initialize all processors */
KeNumberProcessors = 0; KeNumberProcessors = 0;
while (!HalAllProcessorsStarted()) while (!HalAllProcessorsStarted())
{ {
HalInitializeProcessor( HalInitializeProcessor(KeNumberProcessors);
KeNumberProcessors);
KeNumberProcessors++; KeNumberProcessors++;
} }
@ -619,29 +531,6 @@ VOID Phase1Initialization(PVOID Context)
} }
} }
DPRINT("About to try MmAllocateContiguousAlignedMemory\n");
do
{
extern PVOID STDCALL
MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
IN PHYSICAL_ADDRESS HighestAcceptableAddress,
IN ULONG Alignment);
PVOID v;
PHYSICAL_ADDRESS p;
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);
@ -680,12 +569,23 @@ MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
*/ */
LdrLoadInitialProcess(); LdrLoadInitialProcess();
DbgPrint("Finished kernel initialization.\n");
/* FIXME: Call zero page thread function */
PsTerminateSystemThread(STATUS_SUCCESS); PsTerminateSystemThread(STATUS_SUCCESS);
} }
VOID
KiSystemStartup(BOOLEAN BootProcessor)
{
HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
if (BootProcessor)
{
/* Never returns */
ExpInitializeExecutive();
KeBugCheck(0);
}
/* Do application processor initialization */
for(;;);
}
VOID VOID
_main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock) _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
/* /*
@ -741,14 +641,7 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
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);
} }
@ -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);
} }

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,6 +454,7 @@ NtContinue(IN PCONTEXT Context,
NTSTATUS STDCALL NTSTATUS STDCALL
NtYieldExecution(VOID) NtYieldExecution(VOID)
{ {
PsDispatchThread(THREAD_STATE_RUNNABLE);
return(STATUS_SUCCESS); 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));