From fbb680dffd983747a2dc90ac16ab009cc3316dc1 Mon Sep 17 00:00:00 2001 From: David Welch Date: Thu, 29 Mar 2001 17:24:43 +0000 Subject: [PATCH] Strip everything from ntoskrnl svn path=/trunk/; revision=1746 --- reactos/loaders/dos/loadros.asm | 12 +-- reactos/ntoskrnl/Makefile | 13 ++- reactos/ntoskrnl/ke/i386/i386-mcount.S | 2 +- reactos/ntoskrnl/ke/i386/multiboot.S | 9 +- reactos/ntoskrnl/mm/section.c | 109 +++++++++++++++++++++---- 5 files changed, 114 insertions(+), 31 deletions(-) diff --git a/reactos/loaders/dos/loadros.asm b/reactos/loaders/dos/loadros.asm index 2d23eff5b8c..a7a6e3c1794 100644 --- a/reactos/loaders/dos/loadros.asm +++ b/reactos/loaders/dos/loadros.asm @@ -323,12 +323,12 @@ entry: and eax, 0xffff ; clear carry shl eax,8 mov [_multiboot_mem_upper],eax -;; xor eax,eax -;; mov al, 0x30 -;; out 0x70, al -;; in al, 0x71 -;; and eax, 0xffff ; clear carry -;; add [_multiboot_mem_lower],eax + xor eax,eax + mov al, 0x30 + out 0x70, al + in al, 0x71 + and eax, 0xffff ; clear carry + add [_multiboot_mem_lower],eax .done_mem: pop ebx diff --git a/reactos/ntoskrnl/Makefile b/reactos/ntoskrnl/Makefile index 5d1d0f849d0..17d71d0e1be 100644 --- a/reactos/ntoskrnl/Makefile +++ b/reactos/ntoskrnl/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.26 2001/03/25 18:56:12 dwelch Exp $ +# $Id: Makefile,v 1.27 2001/03/29 17:24:43 dwelch Exp $ # # ReactOS Operating System # @@ -27,7 +27,8 @@ include $(PATH_TO_TOP)/rules.mak all: $(EXE_PREFIX)depends$(EXE_POSTFIX) \ $(OBJECTS_PATH) \ $(TARGETNAME).nostrip.exe \ - $(TARGETNAME).exe + $(TARGETNAME).exe \ + $(TARGETNAME).sym $(EXE_PREFIX)depends$(EXE_POSTFIX): depends.c $(HOST_CC) -o depends$(EXE_POSTFIX) depends.c @@ -500,9 +501,6 @@ $(TARGETNAME).nostrip.exe: $(TARGETNAME).o $(TARGETNAME).a $(IE_DATA) - $(RM) temp.exp $(TARGETNAME).exe: $(TARGETNAME).o $(TARGETNAME).a - $(STRIP) \ - --strip-debug \ - $(TARGETNAME).o $(CC) \ -Wl,-T,ntoskrnl.lnk \ -nostartfiles -nostdlib \ @@ -523,7 +521,7 @@ $(TARGETNAME).exe: $(TARGETNAME).o $(TARGETNAME).a --kill-at - $(RM) base.tmp $(CC) \ - -Wl,-T,ntoskrnl.lnk \ + -Wl,-T,ntoskrnl.lnk -Wl,-s\ -nostartfiles -nostdlib \ -mdll \ -o $(TARGETNAME).exe \ @@ -534,8 +532,9 @@ $(TARGETNAME).exe: $(TARGETNAME).o $(TARGETNAME).a -Wl,temp.exp \ $(TARGETNAME).o -lgcc - $(RM) temp.exp - $(NM) --numeric-sort $(TARGETNAME).exe > $(TARGETNAME).sym +$(TARGETNAME).sym: $(TARGETNAME).nostrip.exe + $(NM) --numeric-sort $(TARGETNAME).nostrip.exe > $(TARGETNAME).sym $(TARGETNAME).o: $(OBJECTS) $(LD) \ diff --git a/reactos/ntoskrnl/ke/i386/i386-mcount.S b/reactos/ntoskrnl/ke/i386/i386-mcount.S index 97d764410dc..8f873989947 100644 --- a/reactos/ntoskrnl/ke/i386/i386-mcount.S +++ b/reactos/ntoskrnl/ke/i386/i386-mcount.S @@ -24,7 +24,7 @@ use of profiling together with nested functions - the ELF `fixup' function uses GCC's regparm feature - some (future) systems might want to pass parameters in registers. */ -/* dwelch: Alerted for ReactOS to output the files to port 0xe9 for processing +/* dwelch: Altered for ReactOS to output the files to port 0xe9 for processing by bochs. */ diff --git a/reactos/ntoskrnl/ke/i386/multiboot.S b/reactos/ntoskrnl/ke/i386/multiboot.S index 85ee05a7b51..136976b8483 100644 --- a/reactos/ntoskrnl/ke/i386/multiboot.S +++ b/reactos/ntoskrnl/ke/i386/multiboot.S @@ -65,9 +65,14 @@ _multiboot_entry: movl %cr0, %edx orl $0x80000000, %edx movl %edx, %cr0 - movl $l2, %edx + + /* + * Do an absolute jump because we now want to execute at 0xc0000000 + */ + movl $.l2, %edx jmp *%edx -l2: +.l2: + /* * Load the GDTR and IDTR with new tables located above * 0xc0000000 diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 58bf0f75b83..592fe7b681b 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -1,6 +1,23 @@ -/* $Id: section.c,v 1.52 2001/03/25 02:34:28 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: section.c,v 1.53 2001/03/29 17:24:43 dwelch Exp $ * - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/section.c * PURPOSE: Implements section objects @@ -36,6 +53,9 @@ static GENERIC_MAPPING MmpSectionMapping = { #define TAG_MM_SECTION_SEGMENT TAG('M', 'M', 'S', 'S') #define TAG_SECTION_PAGE_TABLE TAG('M', 'S', 'P', 'T') +#define SHARE_COUNT(E) ((E) & 0xFFF) +#define MAX_SHARE_COUNT 0xFFF + /* FUNCTIONS *****************************************************************/ VOID @@ -58,6 +78,7 @@ MmFreeSectionSegments(PFILE_OBJECT FileObject) if (FileObject->SectionObjectPointers->ImageSectionObject != NULL) { PMM_IMAGE_SECTION_OBJECT ImageSectionObject; + ULONG i; ImageSectionObject = @@ -161,6 +182,7 @@ MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, Table->Pages[TableOffset] = Entry; } + ULONG MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, ULONG Offset) @@ -184,6 +206,49 @@ MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, return(Entry); } +VOID +MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, + ULONG Offset) +{ + ULONG Entry; + + Entry = MmGetPageEntrySectionSegment(Segment, Offset); + if (Entry == 0) + { + DPRINT1("Entry == 0 for MmSharePageEntrySectionSegment\n"); + KeBugCheck(0); + } + if (SHARE_COUNT(Entry) == MAX_SHARE_COUNT) + { + DPRINT1("Maximum share count reached\n"); + KeBugCheck(0); + } + Entry++; + MmSetPageEntrySectionSegment(Segment, Offset, Entry); +} + +VOID +MmUnsharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, + ULONG Offset) +{ + ULONG Entry; + + Entry = MmGetPageEntrySectionSegment(Segment, Offset); + if (Entry == 0) + { + DPRINT1("Entry == 0 for MmSharePageEntrySectionSegment\n"); + KeBugCheck(0); + } + if (SHARE_COUNT(Entry) == 0) + { + DPRINT1("Zero share count for unshare\n"); + KeBugCheck(0); + } + Entry--; + MmSetPageEntrySectionSegment(Segment, Offset, Entry); +} + + NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, MEMORY_AREA* MemoryArea, @@ -271,7 +336,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, */ if (!NT_SUCCESS(PageOp->Status)) { - return(Status); + return(PageOp->Status); } MmLockAddressSpace(AddressSpace); MmLockSection(Section); @@ -286,6 +351,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, Page = (PVOID)(Entry & 0xFFFFF000); MmReferencePage(Page); + // MmSharePageEntrySectionSegment(Segment, Offset.u.LowPart); Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, @@ -435,7 +501,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, /* * FIXME: What do we know in this case? */ - DPRINT("IoPageRead failed (Status %x)\n", Status); + DPRINT1("IoPageRead failed (Status %x)\n", Status); /* * Cleanup and release locks @@ -471,6 +537,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, */ Entry = (ULONG)Page; MmSetPageEntrySectionSegment(Segment, Offset.QuadPart, Entry); + // MmSharePageEntrySectionSegment(Segment, Offset.QuadPart); Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, @@ -502,6 +569,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, Page = (PVOID)Entry; MmReferencePage(Page); + // MmSharePageEntrySectionSegment(Segment, Offset.QuadPart); Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, @@ -1694,24 +1762,35 @@ VOID STATIC MmFreeSectionPage(PVOID Context, PVOID Address, ULONG PhysAddr) { PMEMORY_AREA MArea; + ULONG Entry; MArea = (PMEMORY_AREA)Context; if (PhysAddr != 0) { - if (MmGetReferenceCountPage((PVOID)PhysAddr) == 1) + ULONG Offset; + + Offset = + ((ULONG)PAGE_ROUND_DOWN(Address) - (ULONG)MArea->BaseAddress) + + MArea->Data.SectionData.ViewOffset; + + Entry = MmGetPageEntrySectionSegment(MArea->Data.SectionData.Segment, + Offset); + /* + * Just dereference private pages + */ + if (PhysAddr != (Entry & 0xFFFFF000)) { - ULONG Offset; - - Offset = - ((ULONG)PAGE_ROUND_DOWN(Address) - (ULONG)MArea->BaseAddress) + - MArea->Data.SectionData.ViewOffset; - - MmSetPageEntrySectionSegment(MArea->Data.SectionData.Segment, - Offset, - 0); + MmDereferencePage((PVOID)PhysAddr); + } + else + { +#if 0 + MmUnsharePageEntrySectionSegment(MArea->Data.SectionData.Segment, + Offset); + MmDereferencePage((PVOID)PhysAddr); +#endif } - MmDereferencePage((PVOID)PhysAddr); } }