diff --git a/reactos/ntoskrnl/Makefile b/reactos/ntoskrnl/Makefile index d63a4bb8783..4d45ec5af93 100644 --- a/reactos/ntoskrnl/Makefile +++ b/reactos/ntoskrnl/Makefile @@ -1,9 +1,14 @@ -# $Id: Makefile,v 1.17 2001/03/12 19:23:48 dwelch Exp $ +# $Id: Makefile,v 1.18 2001/03/14 00:21:21 dwelch Exp $ # # ReactOS Operating System # PATH_TO_TOP = .. +# +# Architecture to build for +# +ARCH := i386 + TARGETNAME = ntoskrnl OBJECTS_PATH = objects @@ -19,11 +24,18 @@ all: \ $(TARGETNAME).nostrip.exe \ $(TARGETNAME).exe +# # Hardware Abstraction Layer (Hal) # Defines $(OBJECTS_HAL) # include hal/x86/sources +# +# Architecture specific Makefile +# Defines $(OBJECTS_ARCH) +# +include Makefile.$(ARCH) + # System API (Nt/Zw) OBJECTS_NT = \ nt/atom.o \ @@ -68,7 +80,6 @@ OBJECTS_RTL = \ # Kernel (Ke) # Note: head.o MUST be the first file!!! OBJECTS_KE = \ - ke/multiboot.o \ ke/apc.o \ ke/bug.o \ ke/catch.o \ @@ -76,11 +87,8 @@ OBJECTS_KE = \ ke/dpc.o \ ke/error.o \ ke/event.o \ - ke/gdt.o \ - ke/idt.o \ ke/kernel.o \ ke/kqueue.o \ - ke/ldt.o \ ke/main.o \ ke/mutex.o \ ke/process.o \ @@ -90,21 +98,6 @@ OBJECTS_KE = \ ke/wait.o \ ke/kthread.o -OBJECTS_KE_I386 = \ - ke/i386/exp.o \ - ke/i386/irq.o \ - ke/i386/irqhand.o \ - ke/i386/thread.o \ - ke/i386/usercall.o \ - ke/i386/trap.o \ - ke/i386/bthread.o \ - ke/i386/syscall.o \ - ke/i386/tskswitch.o \ - ke/i386/v86m.o \ - ke/i386/v86m_sup.o \ - ke/i386/bios.o \ - ke/i386/i386-mcount.o - # Memory Manager (Mm) OBJECTS_MM = \ mm/aspace.o \ @@ -286,8 +279,8 @@ OBJECTS_KD = \ kd/service.o \ kd/dlog.o -C_OBJECTS := $(OBJECTS_NT) $(OBJECTS_HAL) $(OBJECTS_MM) $(OBJECTS_MM_I386) \ - $(OBJECTS_IO) $(OBJECTS_KE) $(OBJECTS_KE_I386) $(OBJECTS_OB) \ +C_OBJECTS := $(OBJECTS_NT) $(OBJECTS_HAL) $(OBJECTS_MM) $(OBJECTS_ARCH) \ + $(OBJECTS_IO) $(OBJECTS_KE) $(OBJECTS_OB) \ $(OBJECTS_PS) $(OBJECTS_EX) $(OBJECTS_CC) $(OBJECTS_FS) $(OBJECTS_SE) \ $(OBJECTS_DBG) $(OBJECTS_CM) $(OBJECTS_LDR) $(OBJECTS_LPC) \ $(OBJECTS_PO) $(OBJECTS_KD) $(OBJECTS_RTL) @@ -316,18 +309,20 @@ $(OBJECTS_PATH)/hal.o: $(OBJECTS_HAL) -o $(OBJECTS_PATH)/hal.o \ $(OBJECTS_HAL) +$(OBJECTS_PATH)/arch.o: $(OBJECTS_ARCH) + $(LD) -r -o $(OBJECTS_PATH)/arch.o $(OBJECTS_ARCH) + $(OBJECTS_PATH)/io.o: $(OBJECTS_IO) $(LD) \ -r \ -o $(OBJECTS_PATH)/io.o \ $(OBJECTS_IO) -$(OBJECTS_PATH)/ke.o: $(OBJECTS_KE) $(OBJECTS_KE_I386) +$(OBJECTS_PATH)/ke.o: $(OBJECTS_KE) $(LD) \ -r \ -o $(OBJECTS_PATH)/ke.o \ - $(OBJECTS_KE) \ - $(OBJECTS_KE_I386) + $(OBJECTS_KE) $(OBJECTS_PATH)/rtl.o: $(OBJECTS_RTL) $(LD) \ @@ -335,12 +330,11 @@ $(OBJECTS_PATH)/rtl.o: $(OBJECTS_RTL) -o $(OBJECTS_PATH)/rtl.o \ $(OBJECTS_RTL) -$(OBJECTS_PATH)/mm.o: $(OBJECTS_MM) $(OBJECTS_MM_I386) +$(OBJECTS_PATH)/mm.o: $(OBJECTS_MM) $(LD) \ -r \ -o $(OBJECTS_PATH)/mm.o \ - $(OBJECTS_MM) \ - $(OBJECTS_MM_I386) + $(OBJECTS_MM) $(OBJECTS_PATH)/ob.o: $(OBJECTS_OB) $(LD) \ @@ -430,7 +424,8 @@ $(TARGETNAME).coff: $(TARGETNAME).rc ../include/reactos/resource.h # Note: ke.o MUST be the first file!!! -OBJECTS = \ +OBJECTS := \ + $(OBJECTS_PATH)/arch.o \ $(OBJECTS_PATH)/ke.o \ $(OBJECTS_PATH)/hal.o \ $(OBJECTS_PATH)/cc.o \ diff --git a/reactos/ntoskrnl/Makefile.i386 b/reactos/ntoskrnl/Makefile.i386 new file mode 100644 index 00000000000..83fffc3dd82 --- /dev/null +++ b/reactos/ntoskrnl/Makefile.i386 @@ -0,0 +1,26 @@ +OBJECTS_BOOT := ke/i386/multiboot.o + +OBJECTS_KE_I386 := \ + ke/i386/exp.o \ + ke/i386/irq.o \ + ke/i386/irqhand.o \ + ke/i386/thread.o \ + ke/i386/usercall.o \ + ke/i386/trap.o \ + ke/i386/bthread.o \ + ke/i386/syscall.o \ + ke/i386/tskswitch.o \ + ke/i386/v86m.o \ + ke/i386/v86m_sup.o \ + ke/i386/bios.o \ + ke/i386/i386-mcount.o \ + ke/i386/gdt.o \ + ke/i386/idt.o \ + ke/i386/ldt.o + +OBJECTS_MM_I386 := \ + mm/i386/memsafe.o \ + mm/i386/page.o \ + mm/i386/pfault.o + +OBJECTS_ARCH = $(OBJECTS_BOOT) $(OBJECTS_KE_I386) $(OBJECTS_MM_I386) \ No newline at end of file diff --git a/reactos/ntoskrnl/cc/cacheman.c b/reactos/ntoskrnl/cc/cacheman.c index 33f303f2bc3..395fe890b24 100644 --- a/reactos/ntoskrnl/cc/cacheman.c +++ b/reactos/ntoskrnl/cc/cacheman.c @@ -33,7 +33,8 @@ /* FUNCTIONS *****************************************************************/ -NTSTATUS CcInit(VOID) +NTSTATUS +CcInit(VOID) { /* Nothing in here at the moment */ diff --git a/reactos/ntoskrnl/ke/apc.c b/reactos/ntoskrnl/ke/apc.c index 99c130b4e6f..db762a1e099 100644 --- a/reactos/ntoskrnl/ke/apc.c +++ b/reactos/ntoskrnl/ke/apc.c @@ -1,9 +1,27 @@ /* - * COPYRIGHT: See COPYING in the top level directory + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/apc.c * PURPOSE: Possible implementation of APCs * PROGRAMMER: David Welch (welch@cwcom.net) + * PORTABILITY: Unchecked * UPDATE HISTORY: * Created 22/05/98 * 12/11/99: Phillip Susi: Reworked the APC code @@ -21,10 +39,6 @@ #define NDEBUG #include -/* NOTES *********************************************************************/ - - - /* GLOBALS *******************************************************************/ KSPIN_LOCK PiApcLock; diff --git a/reactos/ntoskrnl/ke/bug.c b/reactos/ntoskrnl/ke/bug.c index 34463b21d29..804fd6428ce 100644 --- a/reactos/ntoskrnl/ke/bug.c +++ b/reactos/ntoskrnl/ke/bug.c @@ -1,10 +1,28 @@ -/* $Id: bug.c,v 1.15 2001/03/07 08:57:08 dwelch Exp $ +/* + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: bug.c,v 1.16 2001/03/14 00:21:22 dwelch Exp $ * - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/bug.c * PURPOSE: Graceful system shutdown if a bug is detected * PROGRAMMER: David Welch (welch@cwcom.net) + * PORTABILITY: Unchecked * UPDATE HISTORY: * Created 22/05/98 * Phillip Susi: 12/8/99: Minor fix @@ -27,45 +45,40 @@ VOID PsDumpThreads(VOID); /* FUNCTIONS *****************************************************************/ -VOID KeInitializeBugCheck(VOID) +VOID +KeInitializeBugCheck(VOID) { InitializeListHead(&BugcheckCallbackListHead); InBugCheck = 0; } BOOLEAN STDCALL -KeDeregisterBugCheckCallback ( - PKBUGCHECK_CALLBACK_RECORD CallbackRecord - ) +KeDeregisterBugCheckCallback (PKBUGCHECK_CALLBACK_RECORD CallbackRecord) { - UNIMPLEMENTED; + UNIMPLEMENTED; } BOOLEAN STDCALL -KeRegisterBugCheckCallback ( - PKBUGCHECK_CALLBACK_RECORD CallbackRecord, - PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, - PVOID Buffer, - ULONG Length, - PUCHAR Component - ) +KeRegisterBugCheckCallback (PKBUGCHECK_CALLBACK_RECORD CallbackRecord, + PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, + PVOID Buffer, + ULONG Length, + PUCHAR Component) { - InsertTailList(&BugcheckCallbackListHead,&CallbackRecord->Entry); - CallbackRecord->Length=Length; - CallbackRecord->Buffer=Buffer; - CallbackRecord->Component=Component; - CallbackRecord->CallbackRoutine=CallbackRoutine; - return(TRUE); + InsertTailList(&BugcheckCallbackListHead,&CallbackRecord->Entry); + CallbackRecord->Length=Length; + CallbackRecord->Buffer=Buffer; + CallbackRecord->Component=Component; + CallbackRecord->CallbackRoutine=CallbackRoutine; + return(TRUE); } VOID STDCALL -KeBugCheckEx ( - ULONG BugCheckCode, - ULONG BugCheckParameter1, - ULONG BugCheckParameter2, - ULONG BugCheckParameter3, - ULONG BugCheckParameter4 - ) +KeBugCheckEx (ULONG BugCheckCode, + ULONG BugCheckParameter1, + ULONG BugCheckParameter2, + ULONG BugCheckParameter3, + ULONG BugCheckParameter4) /* * FUNCTION: Brings the system down in a controlled manner when an * inconsistency that might otherwise cause corruption has been detected @@ -75,7 +88,8 @@ KeBugCheckEx ( * RETURNS: Doesn't */ { - __asm__("cli\n\t"); //PJS: disable interrupts first, then do the rest + /* PJS: disable interrupts first, then do the rest */ + __asm__("cli\n\t"); DbgPrint("Bug detected (code %x param %x %x %x %x)\n",BugCheckCode, BugCheckParameter1,BugCheckParameter2,BugCheckParameter3, BugCheckParameter4); diff --git a/reactos/ntoskrnl/ke/cont.c b/reactos/ntoskrnl/ke/cont.c deleted file mode 100644 index 1f549ba48cf..00000000000 --- a/reactos/ntoskrnl/ke/cont.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/ke/cont.c - * PURPOSE: Continues from the specified context - * PROGRAMMER: David Welch (welch@mcmail.com) - * UPDATE HISTORY: - * Created 02/10/98 - */ - -/* INCLUDES *****************************************************************/ - -#include - -#include - -/* FUNCTIONS *****************************************************************/ - -VOID KeContinue(PCONTEXT Context) -/* - * FUNCTION: Continues from the specified processor context - * NOTE: This function doesn't return - */ -{ - _ - __asm__("movl %0,%%eax\n\t" - "movw $"STR(USER_DS)",%%bx\n\t" - "movw %%bx,%%ds\n\t" - "movw %%bx,%%es\n\t" - "movw %%bx,%%fs\n\t" - "movw %%bx,%%gs\n\t" - "pushl $"STR(USER_DS)"\n\t" - "pushl $0x2000\n\t" // ESP - "pushl $0x202\n\t" // EFLAGS - "pushl $"STR(USER_CS)"\n\t" // CS - "pushl %%eax\n\t" // EIP - "iret\n\t" - : /* no output */ - : "d" (Eip)); -} diff --git a/reactos/ntoskrnl/ke/head.s b/reactos/ntoskrnl/ke/head.s deleted file mode 100644 index d9d36e5044d..00000000000 --- a/reactos/ntoskrnl/ke/head.s +++ /dev/null @@ -1,42 +0,0 @@ -#include - -#define NR_TASKS 128 - -.globl _start -.globl _NtProcessStartup -.globl _init_stack -.globl _init_stack_top - -_NtProcessStartup: -_start: - lidt _idt_descr - lgdt _gdt_descr - - movw $0x10,%ax - movw %ax,%ds - - popl %eax - popl %eax - movl $_init_stack_top,%esp - pushl %eax - pushl $0 - - jmp __main - -.data - -_idt_descr: - .word (256*8)-1 - .long _KiIdt - -_gdt_descr: - .word ((8+NR_TASKS)*8)-1 - .long _KiGdt - -.align 8 -_init_stack: - .fill MM_STACK_SIZE,1,0 -_init_stack_top: - - - diff --git a/reactos/ntoskrnl/ke/gdt.c b/reactos/ntoskrnl/ke/i386/gdt.c similarity index 100% rename from reactos/ntoskrnl/ke/gdt.c rename to reactos/ntoskrnl/ke/i386/gdt.c diff --git a/reactos/ntoskrnl/ke/idt.c b/reactos/ntoskrnl/ke/i386/idt.c similarity index 100% rename from reactos/ntoskrnl/ke/idt.c rename to reactos/ntoskrnl/ke/i386/idt.c diff --git a/reactos/ntoskrnl/ke/ldt.c b/reactos/ntoskrnl/ke/i386/ldt.c similarity index 100% rename from reactos/ntoskrnl/ke/ldt.c rename to reactos/ntoskrnl/ke/i386/ldt.c diff --git a/reactos/ntoskrnl/ke/multiboot.S b/reactos/ntoskrnl/ke/i386/multiboot.S similarity index 100% rename from reactos/ntoskrnl/ke/multiboot.S rename to reactos/ntoskrnl/ke/i386/multiboot.S diff --git a/reactos/ntoskrnl/ke/timer.c b/reactos/ntoskrnl/ke/timer.c index 333f169d024..1a05d010b55 100644 --- a/reactos/ntoskrnl/ke/timer.c +++ b/reactos/ntoskrnl/ke/timer.c @@ -1,4 +1,4 @@ -/* $Id: timer.c,v 1.39 2001/02/18 19:43:15 phreak Exp $ +/* $Id: timer.c,v 1.40 2001/03/14 00:21:22 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -379,10 +379,10 @@ static void HandleExpiredTimer(PKTIMER current) NULL); DPRINT("Finished dpc routine\n"); } - KeAcquireDispatcherDatabaseLock( FALSE ); + KeAcquireDispatcherDatabaseLock(FALSE); current->Header.SignalState = TRUE; - KeDispatcherObjectWake( ¤t->Header ); - KeReleaseDispatcherDatabaseLock( FALSE ); + KeDispatcherObjectWake(¤t->Header); + KeReleaseDispatcherDatabaseLock(FALSE); if (current->Period != 0) { current->DueTime.QuadPart += @@ -395,10 +395,11 @@ static void HandleExpiredTimer(PKTIMER current) } } -VOID KeExpireTimers( PKDPC Dpc, - PVOID Context1, - PVOID Arg1, - PVOID Arg2 ) +VOID +KeExpireTimers(PKDPC Dpc, + PVOID Context1, + PVOID Arg1, + PVOID Arg2) { PLIST_ENTRY current_entry = NULL; PKTIMER current = NULL; @@ -409,36 +410,29 @@ VOID KeExpireTimers( PKDPC Dpc, KeAcquireSpinLockAtDpcLevel(&TimerListLock); - while (current_entry!=(&TimerListHead)) + while (current_entry != &TimerListHead) { - current = CONTAINING_RECORD(current_entry, KTIMER, TimerListEntry); + current = CONTAINING_RECORD(current_entry, KTIMER, TimerListEntry); - current_entry = current_entry->Flink; - - if (system_time >= current->DueTime.QuadPart) - { - HandleExpiredTimer(current); - } + current_entry = current_entry->Flink; + + if (system_time >= current->DueTime.QuadPart) + { + HandleExpiredTimer(current); + } } - KeReleaseSpinLockFromDpcLevel( &TimerListLock ); + KeReleaseSpinLockFromDpcLevel(&TimerListLock); } -VOID KiUpdateSystemTime (VOID) +VOID +KiUpdateSystemTime (VOID) /* * FUNCTION: Handles a timer interrupt */ { - char str[36]; - char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36); - int i; - int x,y; -// extern ULONG EiNrUsedBlocks; - extern unsigned int EiFreeNonPagedPool; - extern unsigned int EiUsedNonPagedPool; - // extern ULONG PiNrThreads; -// extern ULONG MiNrFreePages; + char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 2); KiRawTicks++; @@ -456,40 +450,35 @@ VOID KiUpdateSystemTime (VOID) * Display the tick count in the top left of the screen as a debugging * aid */ -// sprintf(str,"%.8u %.8u",nr_used_blocks,ticks); - if ((EiFreeNonPagedPool + EiUsedNonPagedPool) == 0) + switch (KiTimerTicks % 4) { - x = y = 0; - } - else - { - x = (EiFreeNonPagedPool * 100) / - (EiFreeNonPagedPool + EiUsedNonPagedPool); - y = (EiUsedNonPagedPool * 100) / - (EiFreeNonPagedPool + EiUsedNonPagedPool); - } - memset(str, 0, sizeof(str)); -// sprintf(str,"%.8u %.8u",(unsigned int)EiNrUsedBlocks, -// (unsigned int)EiFreeNonPagedPool); -// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,EiUsedNonPagedPool); -// sprintf(str,"%.8u %.8u",(unsigned int)PiNrRunnableThreads, -// (unsigned int)PiNrThreads); -// sprintf(str,"%.8u %.8u", (unsigned int)PiNrRunnableThreads, -// (unsigned int)MiNrFreePages); - sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,(unsigned int)KiTimerTicks); + case 0: + vidmem[0] = '|'; + break; + + case 1: + vidmem[0] = '/'; + break; - for (i=0;i<17;i++) - { - *vidmem=str[i]; - vidmem++; - *vidmem=0x7; - vidmem++; + case 2: + vidmem[0] = '-'; + break; + + case 3: + vidmem[0] = '\\'; + break; } - KeInsertQueueDpc( &ExpireTimerDpc, 0, 0 ); + vidmem[1] = 0x7; + + /* + * Queue a DPC that will expire timers + */ + KeInsertQueueDpc(&ExpireTimerDpc, 0, 0); } -VOID KeInitializeTimerImpl(VOID) +VOID +KeInitializeTimerImpl(VOID) /* * FUNCTION: Initializes timer irq handling * NOTE: This is only called once from main() @@ -505,7 +494,7 @@ VOID KeInitializeTimerImpl(VOID) InitializeListHead(&TimerListHead); KeInitializeSpinLock(&TimerListLock); - KeInitializeDpc( &ExpireTimerDpc, KeExpireTimers, 0 ); + KeInitializeDpc(&ExpireTimerDpc, KeExpireTimers, 0); TimerInitDone = TRUE; /* diff --git a/reactos/ntoskrnl/mm/npool.c b/reactos/ntoskrnl/mm/npool.c index b97b46a33b1..c622d00cea2 100644 --- a/reactos/ntoskrnl/mm/npool.c +++ b/reactos/ntoskrnl/mm/npool.c @@ -1,4 +1,4 @@ -/* $Id: npool.c,v 1.40 2001/03/13 21:46:43 dwelch Exp $ +/* $Id: npool.c,v 1.41 2001/03/14 00:21:22 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -163,7 +163,8 @@ MiAddToTagHashTable(BLOCK_HDR* block) } } -VOID ExInitNonPagedPool(ULONG BaseAddress) +VOID +ExInitNonPagedPool(ULONG BaseAddress) { kernel_pool_base = BaseAddress; KeInitializeSpinLock(&MmNpoolLock); @@ -546,7 +547,7 @@ add_to_free_list(BLOCK_HDR* blk) * FUNCTION: add the block to the free list (internal) */ { -#if 0 +#if 1 PLIST_ENTRY current_entry; PLIST_ENTRY next_entry; BLOCK_HDR* current;