My first CVS commit. Hope I get this right. I did put a few files in the CVS dir manually... Innocent mistake... I'll clean it up after I'm done with this. Sorry!

Some of NTOSKRNL now compiles with __USE_W32API enabled. Note that this commit is purely so I know what to do, and also to allow other people to continue working on this if they wish to do so. I will continue hacking away at it.

It's not complete yet, but I've ensured that the changes I have made aren't incompatible with ReactOS as it stands at the moment. It compiles without __USE_W32API fine.

* Modified the tools/depend.mk file to force the use of forward slash (SEH variable?) otherwise it tries to run "toolsdepend.exe" without a slash.

* Moved a couple of routines from include/ddk/halfuncs.h to hal/halx86/include/hal.h

* Fixed conflicting types in ntoskrnl/ex/interlck.c

* Replaced .a with .u, #undef'd "lite" functions and defined NONAMELESSUNION in ntoskrnl/ex/resource.c so that it compiles with Win 32 API

* Added some more conditional defines to include/shared_data.h, ntoskrnl/include/internal/mm.h (and i386/mm.h), ntoskrnl/include/internal/ps.h

* Replaced .a with .u for OWNER_ENTRY and ERESOURCE in include/ddk/extypes.h (so they are compatible with Win 32 API headers)

* Various other small adjustments

Hope this works!

svn path=/trunk/; revision=5130
This commit is contained in:
Andrew Greenwood 2003-07-15 16:26:18 +00:00
parent 5522330a11
commit acd21b1447
14 changed files with 145 additions and 56 deletions

View file

@ -50,4 +50,12 @@ HalpQuerySystemInformation(IN HAL_QUERY_INFORMATION_CLASS InformationClass,
OUT PULONG ReturnedLength);
/* Non-standard functions */
VOID STDCALL
HalReleaseDisplayOwnership();
BOOLEAN STDCALL
HalQueryDisplayOwnership();
#endif /* __INTERNAL_HAL_HAL_H */

View file

@ -441,7 +441,8 @@ ExIsResourceAcquiredExclusiveLite (
PERESOURCE Resource
);
ULONG
// was ULONG
USHORT
STDCALL
ExIsResourceAcquiredSharedLite (
PERESOURCE Resource

View file

@ -1,4 +1,4 @@
/* $Id: extypes.h,v 1.16 2003/07/12 10:24:45 chorns Exp $ */
/* $Id: extypes.h,v 1.17 2003/07/15 16:26:18 silverblade Exp $ */
#ifndef __INCLUDE_DDK_EXTYPES_H
#define __INCLUDE_DDK_EXTYPES_H
@ -27,7 +27,7 @@ typedef struct _OWNER_ENTRY
{
LONG OwnerCount;
ULONG TableSize;
} a;
} u;
} OWNER_ENTRY, *POWNER_ENTRY;
typedef struct _ERESOURCE
@ -46,7 +46,7 @@ typedef struct _ERESOURCE
{
PVOID Address;
ULONG CreatorBackTraceIndex;
} a;
} u;
KSPIN_LOCK SpinLock;
} ERESOURCE, *PERESOURCE;

View file

@ -1,6 +1,6 @@
#ifndef __INCLUDE_DDK_HALFUNCS_H
#define __INCLUDE_DDK_HALFUNCS_H
/* $Id: halfuncs.h,v 1.8 2003/07/12 10:24:45 chorns Exp $ */
/* $Id: halfuncs.h,v 1.9 2003/07/15 16:26:18 silverblade Exp $ */
#include <ntos/haltypes.h>
@ -98,8 +98,13 @@ HalGetBusDataByOffset(BUS_DATA_TYPE BusDataType,
ULONG Length);
/* Is this function really exported ?? */
ULONG
HalGetDmaAlignmentRequirement(VOID);
//ULONG
//HalGetDmaAlignmentRequirement(VOID);
// NTOSAPI
// DDKAPI
ULONG STDCALL
HalGetDmaAlignmentRequirement(
VOID);
BOOLEAN STDCALL
HalGetEnvironmentVariable(IN PCH Name,

View file

@ -4,7 +4,9 @@
/* KERNEL FUNCTIONS ********************************************************/
#ifndef KeFlushIoBuffers
#define KeFlushIoBuffers(Mdl, ReadOperation, DmaOperation)
#endif
VOID STDCALL KeAttachProcess (struct _EPROCESS* Process);
@ -21,8 +23,24 @@ struct _KPROCESS* KeGetCurrentProcess(VOID);
VOID STDCALL KeAcquireSpinLock (PKSPIN_LOCK SpinLock,
PKIRQL OldIrql);
VOID STDCALL KeAcquireSpinLockAtDpcLevel (PKSPIN_LOCK SpinLock);
//VOID STDCALL KeAcquireSpinLockAtDpcLevel (PKSPIN_LOCK SpinLock);
//NTOSAPI
//DDKFASTAPI
STDCALL
VOID
KeAcquireSpinLockAtDpcLevel(
IN PKSPIN_LOCK SpinLock);
#define KefAcquireSpinLockAtDpcLevel KeAcquireSpinLockAtDpcLevel
//NTOSAPI
//DDKFASTAPI
STDCALL
VOID
KeReleaseSpinLockFromDpcLevel(
IN PKSPIN_LOCK SpinLock);
/*
* FUNCTION: Brings the system down in a controlled manner when an
* inconsistency that might otherwise cause corruption has been detected
@ -77,14 +95,14 @@ VOID STDCALL KeFlushWriteBuffer (VOID);
KIRQL STDCALL KeGetCurrentIrql (VOID);
#ifndef __USE_W32API
ULONG KeGetCurrentProcessorNumber(VOID);
ULONG KeGetDcacheFillSize(VOID);
ULONG STDCALL KeGetPreviousMode (VOID);
#endif
struct _KTHREAD* STDCALL KeGetCurrentThread (VOID);
ULONG KeGetDcacheFillSize(VOID);
ULONG STDCALL KeGetPreviousMode (VOID);
VOID STDCALL KeInitializeApc (IN PKAPC Apc,
IN PKTHREAD Thread,
IN UCHAR StateIndex,
@ -101,8 +119,10 @@ VOID STDCALL KeInitializeApc (IN PKAPC Apc,
* PKBUGCHECK_CALLBACK_RECORD CallbackRecord
* );
*/
#ifndef KeInitializeCallbackRecord
#define KeInitializeCallbackRecord(CallbackRecord) \
(CallbackRecord)->State = BufferEmpty
#endif
VOID STDCALL KeInitializeDeviceQueue (PKDEVICE_QUEUE DeviceQueue);
@ -298,11 +318,13 @@ KeReleaseSpinLock (
KIRQL NewIrql
);
#ifndef __USE_W32API
VOID
STDCALL
KeReleaseSpinLockFromDpcLevel (
PKSPIN_LOCK Spinlock
);
#endif
PKDEVICE_QUEUE_ENTRY
STDCALL

View file

@ -58,7 +58,9 @@ typedef struct _KUSER_SHARED_DATA
#define USER_SHARED_DATA (0x7FFE0000)
#if defined(__NTOSKRNL__) || defined(__NTDRIVER__) || defined(__NTHAL__)
#define KI_USER_SHARED_DATA (0xFFDF0000)
#ifndef __USE_W32API
#define KI_USER_SHARED_DATA (0xFFDF0000)
#endif
#ifdef SharedUserData
#undef SharedUserData
#endif

View file

@ -113,7 +113,7 @@ typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
#ifdef __NTOSKRNL__
#define EXCEPTION_EXECUTE_HANDLER 1
#define EXCEPTION_CONTINUE_SEARCH 0
#define EXCEPTION_CONTINUE_EXECUTION -1
// #define EXCEPTION_CONTINUE_EXECUTION -1
#endif /* __NTOSKRNL__ */
#endif /* _GNU_H_WINDOWS32_DEFINES */

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.100 2003/07/11 20:55:43 gvg Exp $
# $Id: Makefile,v 1.101 2003/07/15 16:26:18 silverblade Exp $
#
# ReactOS Operating System
#
@ -40,6 +40,9 @@ ASFLAGS += -I./include -I$(SDK_PATH_INC)
CFLAGS += -I./include -I$(SDK_PATH_INC) -D__NTOSKRNL__ $(CFLAGS_DBG) -Wall -Werror
endif
# ASFLAGS += -D__USE_W32API -D_NTOSKRNL_
# CFLAGS += -D__USE_W32API -D_NTOSKRNL_
#
# Build configuration
#

View file

@ -1,4 +1,4 @@
/* $Id: resource.c,v 1.23 2003/07/11 01:23:14 royce Exp $
/* $Id: resource.c,v 1.24 2003/07/15 16:26:18 silverblade Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -36,6 +36,11 @@
#define ResourceOwnedExclusive 0x80
#define ResourceDisableBoost 0x08
#ifdef __USE_W32API
#define NONAMELESSUNION
#endif
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
@ -70,6 +75,10 @@ ExTryToAcquireResourceExclusiveLite (
return(ExAcquireResourceExclusiveLite(Resource,FALSE));
}
#ifdef ExAcquireResourceExclusive
#undef ExAcquireResourceExclusive
#endif
/*
* @implemented
*/
@ -83,6 +92,7 @@ ExAcquireResourceExclusive (
return(ExAcquireResourceExclusiveLite(Resource,Wait));
}
/*
* @implemented
*/
@ -115,7 +125,7 @@ ExAcquireResourceExclusiveLite (
&& Resource->OwnerThreads[0].OwnerThread == ExGetCurrentResourceThread())
{
/* it's ok : same lock for same thread */
Resource->OwnerThreads[0].a.OwnerCount++;
Resource->OwnerThreads[0].u.OwnerCount++;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireResourceExclusiveLite() = TRUE\n");
return(TRUE);
@ -152,7 +162,7 @@ ExAcquireResourceExclusiveLite (
Resource->Flag |= ResourceOwnedExclusive;
Resource->ActiveCount = 1;
Resource->OwnerThreads[0].OwnerThread = ExGetCurrentResourceThread();
Resource->OwnerThreads[0].a.OwnerCount = 1;
Resource->OwnerThreads[0].u.OwnerCount = 1;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireResourceExclusiveLite() = TRUE\n");
return(TRUE);
@ -172,8 +182,8 @@ static BOOLEAN EiRemoveSharedOwner(PERESOURCE Resource,
if (Resource->OwnerThreads[1].OwnerThread == ResourceThreadId)
{
Resource->OwnerThreads[1].a.OwnerCount--;
if (Resource->OwnerThreads[1].a.OwnerCount == 0)
Resource->OwnerThreads[1].u.OwnerCount--;
if (Resource->OwnerThreads[1].u.OwnerCount == 0)
{
Resource->ActiveCount--;
Resource->OwnerThreads[1].OwnerThread = 0;
@ -187,12 +197,12 @@ static BOOLEAN EiRemoveSharedOwner(PERESOURCE Resource,
return(FALSE);;
}
for (i=0; i<Resource->OwnerThreads[1].a.TableSize; i++)
for (i=0; i<Resource->OwnerThreads[1].u.TableSize; i++)
{
if (Resource->OwnerTable[i].OwnerThread == ResourceThreadId)
{
Resource->OwnerTable[i].a.OwnerCount--;
if (Resource->OwnerTable[i].a.OwnerCount == 0)
Resource->OwnerTable[i].u.OwnerCount--;
if (Resource->OwnerTable[i].u.OwnerCount == 0)
{
Resource->ActiveCount--;
Resource->OwnerTable[i].OwnerThread = 0;
@ -222,7 +232,7 @@ static BOOLEAN EiAddSharedOwner(PERESOURCE Resource)
{
/* no owner, it's easy */
Resource->OwnerThreads[1].OwnerThread = ExGetCurrentResourceThread();
Resource->OwnerThreads[1].a.OwnerCount = 1;
Resource->OwnerThreads[1].u.OwnerCount = 1;
if (Resource->OwnerTable != NULL)
{
ExFreePool(Resource->OwnerTable);
@ -256,10 +266,10 @@ static BOOLEAN EiAddSharedOwner(PERESOURCE Resource)
sizeof(OWNER_ENTRY));
Resource->OwnerThreads[1].OwnerThread = 0;
Resource->OwnerThreads[1].a.TableSize = 3;
Resource->OwnerThreads[1].u.TableSize = 3;
Resource->OwnerTable[1].OwnerThread = CurrentThread;
Resource->OwnerTable[1].a.OwnerCount = 1;
Resource->OwnerTable[1].u.OwnerCount = 1;
Resource->ActiveCount++;
return(TRUE);
@ -268,15 +278,15 @@ static BOOLEAN EiAddSharedOwner(PERESOURCE Resource)
DPRINT("Search free entries\n");
DPRINT("Number of entries %d\n",
Resource->OwnerThreads[1].a.TableSize);
Resource->OwnerThreads[1].u.TableSize);
freeEntry = NULL;
for (i=0; i<Resource->OwnerThreads[1].a.TableSize; i++)
for (i=0; i<Resource->OwnerThreads[1].u.TableSize; i++)
{
if (Resource->OwnerTable[i].OwnerThread == CurrentThread)
{
DPRINT("Thread already owns resource\n");
Resource->OwnerTable[i].a.OwnerCount++;
Resource->OwnerTable[i].u.OwnerCount++;
return(TRUE);
}
if (Resource->OwnerTable[i].OwnerThread == 0)
@ -296,7 +306,7 @@ static BOOLEAN EiAddSharedOwner(PERESOURCE Resource)
freeEntry =
ExAllocatePoolWithTag(NonPagedPool,
sizeof(OWNER_ENTRY)*
(Resource->OwnerThreads[1].a.TableSize+1),
(Resource->OwnerThreads[1].u.TableSize+1),
TAG_OWNER_TABLE);
if (freeEntry == NULL)
{
@ -304,15 +314,15 @@ static BOOLEAN EiAddSharedOwner(PERESOURCE Resource)
return(FALSE);
}
memcpy(freeEntry,Resource->OwnerTable,
sizeof(OWNER_ENTRY)*(Resource->OwnerThreads[1].a.TableSize));
sizeof(OWNER_ENTRY)*(Resource->OwnerThreads[1].u.TableSize));
ExFreePool(Resource->OwnerTable);
Resource->OwnerTable=freeEntry;
freeEntry=&Resource->OwnerTable[Resource->OwnerThreads[1].a.TableSize];
Resource->OwnerThreads[1].a.TableSize++;
freeEntry=&Resource->OwnerTable[Resource->OwnerThreads[1].u.TableSize];
Resource->OwnerThreads[1].u.TableSize++;
}
DPRINT("Creating entry\n");
freeEntry->OwnerThread=ExGetCurrentResourceThread();
freeEntry->a.OwnerCount=1;
freeEntry->u.OwnerCount=1;
Resource->ActiveCount++;
return(TRUE);
}
@ -361,7 +371,7 @@ ExAcquireResourceSharedLite (
/*
* NOTE: Is this correct? Seems the same as ExConvertExclusiveToShared
*/
Resource->OwnerThreads[0].a.OwnerCount++;
Resource->OwnerThreads[0].u.OwnerCount++;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireResourceSharedLite() = TRUE\n");
return(TRUE);
@ -436,9 +446,9 @@ ExConvertExclusiveToSharedLite (
//transfer infos from entry 0 to entry 1 and erase entry 0
Resource->OwnerThreads[1].OwnerThread=Resource->OwnerThreads[0].OwnerThread;
Resource->OwnerThreads[1].a.OwnerCount=Resource->OwnerThreads[0].a.OwnerCount;
Resource->OwnerThreads[1].u.OwnerCount=Resource->OwnerThreads[0].u.OwnerCount;
Resource->OwnerThreads[0].OwnerThread=0;
Resource->OwnerThreads[0].a.OwnerCount=0;
Resource->OwnerThreads[0].u.OwnerCount=0;
/* erase exclusive flag */
Resource->Flag &= (~ResourceOwnedExclusive);
/* if no shared waiters, that's all */
@ -510,7 +520,7 @@ ExAcquireSharedStarveExclusive (
if (Resource->ActiveCount == 0)
{
Resource->OwnerThreads[1].OwnerThread=ExGetCurrentResourceThread();
Resource->OwnerThreads[1].a.OwnerCount=1;
Resource->OwnerThreads[1].u.OwnerCount=1;
Resource->ActiveCount=1;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireSharedStarveExclusive() = TRUE\n");
@ -521,7 +531,7 @@ ExAcquireSharedStarveExclusive (
&& Resource->OwnerThreads[0].OwnerThread==ExGetCurrentResourceThread())
{
/* exclusive, but by same thread : it's ok */
Resource->OwnerThreads[0].a.OwnerCount++;
Resource->OwnerThreads[0].u.OwnerCount++;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireSharedStarveExclusive() = TRUE\n");
return(TRUE);
@ -565,6 +575,12 @@ ExAcquireSharedWaitForExclusive (
return(ExAcquireResourceSharedLite(Resource,Wait));
}
#ifdef ExDeleteResource
#undef ExDeleteResource
#endif
/*
* @implemented
*/
@ -605,6 +621,11 @@ ExGetSharedWaiterCount (
return(Resource->NumberOfSharedWaiters);
}
#ifdef ExInitializeResource
#undef ExInitializeResource
#endif
/*
* @implemented
*/
@ -662,14 +683,23 @@ ExIsResourceAcquiredExclusiveLite (
&& Resource->OwnerThreads[0].OwnerThread==ExGetCurrentResourceThread());
}
#ifdef ExIsResourceAcquiredSharedLite
#undef ExIsResourceAcquiredSharedLite
#endif
/*
* @implemented
*/
ULONG
STDCALL
ExIsResourceAcquiredSharedLite (
PERESOURCE Resource
)
//NTOSAPI
//DDKAPI
USHORT STDCALL
ExIsResourceAcquiredSharedLite(
IN PERESOURCE Resource)
/*
* FUNCTION: Returns whether the current thread has shared access to a given
* resource
@ -682,21 +712,21 @@ ExIsResourceAcquiredSharedLite (
ULONG i;
if (Resource->OwnerThreads[0].OwnerThread == ExGetCurrentResourceThread())
{
return(Resource->OwnerThreads[0].a.OwnerCount);
return(Resource->OwnerThreads[0].u.OwnerCount);
}
if (Resource->OwnerThreads[1].OwnerThread == ExGetCurrentResourceThread())
{
return(Resource->OwnerThreads[1].a.OwnerCount);
return(Resource->OwnerThreads[1].u.OwnerCount);
}
if (!Resource->OwnerThreads[1].a.TableSize)
if (!Resource->OwnerThreads[1].u.TableSize)
{
return(0);
}
for (i=0; i<Resource->OwnerThreads[1].a.TableSize; i++)
for (i=0; i<Resource->OwnerThreads[1].u.TableSize; i++)
{
if (Resource->OwnerTable[i].OwnerThread==ExGetCurrentResourceThread())
{
return Resource->OwnerTable[i].a.OwnerCount;
return Resource->OwnerTable[i].u.OwnerCount;
}
}
return(0);
@ -724,9 +754,9 @@ ExReinitializeResourceLite (
ExFreePool(Resource->OwnerTable);
}
Resource->OwnerThreads[0].OwnerThread=0;
Resource->OwnerThreads[0].a.OwnerCount=0;
Resource->OwnerThreads[0].u.OwnerCount=0;
Resource->OwnerThreads[1].OwnerThread=0;
Resource->OwnerThreads[1].a.OwnerCount=0;
Resource->OwnerThreads[1].u.OwnerCount=0;
}
/*
@ -742,6 +772,13 @@ ExReleaseResourceLite (
ExGetCurrentResourceThread()));
}
#ifdef ExReleaseResourceForThread
#undef ExReleaseResourceForThread
#endif
/*
* @implemented
*/
@ -755,6 +792,7 @@ ExReleaseResourceForThread (
return(ExReleaseResourceForThreadLite(Resource,ResourceThreadId));
}
/*
* @unimplemented
*/
@ -785,8 +823,8 @@ ExReleaseResourceForThreadLite (
{
DPRINT("Releasing from exclusive access\n");
Resource->OwnerThreads[0].a.OwnerCount--;
if (Resource->OwnerThreads[0].a.OwnerCount > 0)
Resource->OwnerThreads[0].u.OwnerCount--;
if (Resource->OwnerThreads[0].u.OwnerCount > 0)
{
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExReleaseResourceForThreadLite() finished\n");

View file

@ -24,7 +24,7 @@ struct _EPROCESS;
#define PA_SYSTEM (0)
#endif
#define PAGE_SIZE (4096)
// #define PAGE_SIZE (4096)
PULONG MmGetPageEntry(PVOID Address);

View file

@ -211,7 +211,9 @@ NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea);
NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea);
NTSTATUS MmInitSectionImplementation(VOID);
#ifndef __USE_W32API
#define MM_LOWEST_USER_ADDRESS (4096)
#endif
PMEMORY_AREA MmSplitMemoryArea(struct _EPROCESS* Process,
PMADDRESS_SPACE AddressSpace,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: ps.h,v 1.48 2003/06/20 16:20:34 ekohl Exp $
/* $Id: ps.h,v 1.49 2003/07/15 16:26:18 silverblade Exp $
*
* FILE: ntoskrnl/ke/kthread.c
* PURPOSE: Process manager definitions
@ -43,7 +43,9 @@ struct _KTRAPFRAME;
#include <internal/mm.h>
#include <napi/teb.h>
#ifndef __USE_W32API
#define KeGetCurrentProcessorNumber() (KeGetCurrentKPCR()->ProcessorNumber)
#endif
extern HANDLE SystemProcessHandle;

View file

@ -16,7 +16,7 @@
* 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.33 2003/07/12 10:24:45 chorns Exp $
/* $Id: bug.c,v 1.34 2003/07/15 16:26:18 silverblade Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/bug.c
@ -37,6 +37,8 @@
#include <internal/debug.h>
#include "../../hal/halx86/include/hal.h"
/* GLOBALS ******************************************************************/
static LIST_ENTRY BugcheckCallbackListHead = {NULL,NULL};

View file

@ -6,6 +6,10 @@ DEP_FILTERED := $(filter-out $(DEP_EXCLUDE_FILTER), $(DEP_OBJECTS:.o=.d))
DEP_FILES := $(join $(dir $(DEP_FILTERED)), $(addprefix ., $(notdir $(DEP_FILTERED))))
# Added by Silver Blade:
SEP = /
ifneq ($(MAKECMDGOALS),clean)
include $(DEP_FILES)
endif