I double checked, but in case someone's recent commit is somehow overwritten -- please, don't be very frustrated :) -- I will fix it, just drop me a note.
svn path=/trunk/; revision=7338
-/* $Id: copy.c,v 1.19 2003/07/21 21:53:51 royce Exp $
+/* $Id: copy.c,v 1.20 2003/12/30 18:52:03 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
+#if defined(__GNUC__)
static PHYSICAL_ADDRESS CcZeroPage = (PHYSICAL_ADDRESS)0LL;
+#else
+static PHYSICAL_ADDRESS CcZeroPage = { 0 };
+#endif
/* FUNCTIONS *****************************************************************/
{
TempLength = min(Bcb->CacheSegmentSize, Length);
memcpy(Buffer, current->BaseAddress, TempLength);
+#if defined(__GNUC__)
Buffer += TempLength;
+#else
+ {
+ char* pTemp = Buffer;
+ pTemp += TempLength;
+ Buffer = pTemp;
+ }
+#endif
Length = Length - TempLength;
previous = current;
current = current->NextInChain;
{
PVOID address;
PHYSICAL_ADDRESS page;
- address = current2->BaseAddress + (i * PAGE_SIZE);
+ address = (char*)current2->BaseAddress + (i * PAGE_SIZE);
page = MmGetPhysicalAddressForProcess(NULL, address);
((PULONG)(Mdl + 1))[offset] = page.u.LowPart;
offset++;
current = current->NextInChain;
TempLength = min(Bcb->CacheSegmentSize, Length);
memcpy(Buffer, previous->BaseAddress, TempLength);
+#if defined(__GNUC__)
Buffer += TempLength;
+#else
+ {
+ char* pTemp = Buffer;
+ pTemp += TempLength;
+ Buffer = pTemp;
+ }
+#endif
Length = Length - TempLength;
CcRosReleaseCacheSegment(Bcb, previous, TRUE, FALSE, FALSE);
}
KEVENT Event;
SegOffset.QuadPart = CacheSeg->FileOffset;
- Size = CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset;
+ Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset);
if (Size > CacheSeg->Bcb->CacheSegmentSize)
{
Size = CacheSeg->Bcb->CacheSegmentSize;
}
if (CacheSeg->Bcb->CacheSegmentSize > Size)
{
- memset (CacheSeg->BaseAddress + Size, 0,
+ memset ((char*)CacheSeg->BaseAddress + Size, 0,
CacheSeg->Bcb->CacheSegmentSize - Size);
}
return STATUS_SUCCESS;
CacheSeg->Dirty = FALSE;
SegOffset.QuadPart = CacheSeg->FileOffset;
- Size = CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset;
+ Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset);
if (Size > CacheSeg->Bcb->CacheSegmentSize)
{
Size = CacheSeg->Bcb->CacheSegmentSize;
Buffer, IoStatus);
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
- ReadOffset = FileOffset->QuadPart;
+ ReadOffset = (ULONG)FileOffset->QuadPart;
DPRINT("AllocationSize %d, FileSize %d\n",
(ULONG)Bcb->AllocationSize.QuadPart,
return FALSE;
}
}
- memcpy (Buffer, BaseAddress + ReadOffset % Bcb->CacheSegmentSize,
+ memcpy (Buffer, (char*)BaseAddress + ReadOffset % Bcb->CacheSegmentSize,
TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
ReadLength += TempLength;
Length -= TempLength;
ReadOffset += TempLength;
+#if defined(__GNUC__)
Buffer += TempLength;
+#else
+ {
+ char* pTemp = Buffer;
+ pTemp += TempLength;
+ Buffer = pTemp;
+ }
+#endif
}
while (Length > 0)
{
ReadLength += TempLength;
Length -= TempLength;
ReadOffset += TempLength;
+#if defined(__GNUC__)
Buffer += TempLength;
+#else
+ {
+ char* pTemp = Buffer;
+ pTemp += TempLength;
+ Buffer = pTemp;
+ }
+#endif
}
IoStatus->Status = STATUS_SUCCESS;
IoStatus->Information = ReadLength;
return(FALSE);
}
}
- memcpy (BaseAddress + WriteOffset % Bcb->CacheSegmentSize,
+ memcpy ((char*)BaseAddress + WriteOffset % Bcb->CacheSegmentSize,
Buffer, TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, TRUE, FALSE);
Length -= TempLength;
WriteOffset += TempLength;
+#if defined(__GNUC__)
Buffer += TempLength;
+#else
+ {
+ char* pTemp = Buffer;
+ pTemp += TempLength;
+ Buffer = pTemp;
+ }
+#endif
}
while (Length > 0)
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, TRUE, FALSE);
Length -= TempLength;
WriteOffset += TempLength;
+#if defined(__GNUC__)
Buffer += TempLength;
+#else
+ {
+ char* pTemp = Buffer;
+ pTemp += TempLength;
+ Buffer = pTemp;
+ }
+#endif
}
return(TRUE);
}
}
TempLength = min (Length, Bcb->CacheSegmentSize -
Start % Bcb->CacheSegmentSize);
- memset (current->BaseAddress + Start % Bcb->CacheSegmentSize,
+ memset ((char*)current->BaseAddress + Start % Bcb->CacheSegmentSize,
0, TempLength);
}
else
count < size; i++)
{
PVOID Address;
- Address = current->BaseAddress + (i * PAGE_SIZE);
+ Address = (char*)current->BaseAddress + (i * PAGE_SIZE);
page =
MmGetPhysicalAddressForProcess(NULL, Address);
((PULONG)(Mdl + 1))[count++] = page.u.LowPart;
-/* $Id: pin.c,v 1.13 2003/07/10 06:27:13 royce Exp $
+/* $Id: pin.c,v 1.14 2003/12/30 18:52:03 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
" pBcb %x, pBuffer %x)\n", FileObject, (ULONG)FileOffset->QuadPart,
Length, Wait, pBcb, pBuffer);
- ReadOffset = FileOffset->QuadPart;
+ ReadOffset = (ULONG)FileOffset->QuadPart;
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
assert(Bcb);
return(FALSE);
}
}
+#if defined(__GNUC__)
*pBuffer += ReadOffset % Bcb->CacheSegmentSize;
+#else
+ {
+ char* pTemp = *pBuffer;
+ pTemp += ReadOffset % Bcb->CacheSegmentSize;
+ *pBuffer = pTemp;
+ }
+#endif
iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList);
if (iBcb == NULL)
{
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: view.c,v 1.69 2003/10/12 17:05:44 hbirr Exp $
+/* $Id: view.c,v 1.70 2003/12/30 18:52:03 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/view.c
static CLIENT_ID LazyCloseThreadId;
static volatile BOOLEAN LazyCloseThreadShouldTerminate;
+#if defined(__GNUC__)
void * alloca(size_t size);
+#elif defined(_MSC_VER)
+void* _alloca(size_t size);
+#else
+#error Unknown compiler for alloca intrinsic stack allocation "function"
+#endif
+
NTSTATUS
CcRosInternalFreeCacheSegment(PCACHE_SEGMENT CacheSeg);
for (i = 0; i < current->Bcb->CacheSegmentSize / PAGE_SIZE; i++)
{
PHYSICAL_ADDRESS Page;
- Page = MmGetPhysicalAddress(current->BaseAddress + i * PAGE_SIZE);
+ Page = MmGetPhysicalAddress((char*)current->BaseAddress + i * PAGE_SIZE);
Status = MmPageOutPhysicalAddress(Page);
if (!NT_SUCCESS(Status))
{
}
Status = MmCreateVirtualMapping(NULL,
- current->BaseAddress + (i * PAGE_SIZE),
+ (char*)current->BaseAddress + (i * PAGE_SIZE),
PAGE_READWRITE,
Page,
TRUE);
Length = ROUND_UP(Length, Bcb->CacheSegmentSize);
+#if defined(__GNUC__)
CacheSegList = alloca(sizeof(PCACHE_SEGMENT) *
(Length / Bcb->CacheSegmentSize));
+#elif defined(_MSC_VER)
+ CacheSegList = _alloca(sizeof(PCACHE_SEGMENT) *
+ (Length / Bcb->CacheSegmentSize));
+#else
+#error Unknown compiler for alloca intrinsic stack allocation "function"
+#endif
/*
* Look for a cache segment already mapping the same data.
}
else
{
+#if defined(__GNUC__)
Offset.QuadPart = 0LL;
+#else
+ Offset.QuadPart = 0;
+#endif
Length = Bcb->FileSize.u.LowPart;
}
while (1)
{
+#if defined(__GNUC__)
Timeout.QuadPart += 100000000LL; // 10sec
+#else
+ Timeout.QuadPart += 100000000; // 10sec
+#endif
Status = KeWaitForSingleObject(&LazyCloseThreadEvent,
0,
KernelMode,
BitmapSize);
/* Write hive block and block bitmap */
+#if defined(__GNUC__)
FileOffset.QuadPart = 0ULL;
+#else
+ FileOffset.QuadPart = 0;
+#endif
Status = NtWriteFile(FileHandle,
NULL,
NULL,
}
BlockIndex++;
+#if defined(__GNUC__)
FileOffset.QuadPart += 4096ULL;
+#else
+ FileOffset.QuadPart += 4096;
+#endif
}
/* Truncate log file */
BitmapSize);
/* Write hive block and block bitmap */
+#if defined(__GNUC__)
FileOffset.QuadPart = 0ULL;
+#else
+ FileOffset.QuadPart = 0;
+#endif
Status = NtWriteFile(FileHandle,
NULL,
NULL,
RegistryHive->HiveHeader->Checksum = CmiCalcChecksum((PULONG)RegistryHive->HiveHeader);
/* Write hive block */
+#if defined(__GNUC__)
FileOffset.QuadPart = 0ULL;
+#else
+ FileOffset.QuadPart = 0;
+#endif
Status = NtWriteFile(FileHandle,
NULL,
NULL,
BlockPtr = RegistryHive->BlockList[BlockIndex];
DPRINT("BlockPtr %p\n", BlockPtr);
+#if defined(__GNUC__)
FileOffset.QuadPart = (ULONGLONG)(BlockIndex + 1) * 4096ULL;
+#else
+ FileOffset.QuadPart = (ULONGLONG)(BlockIndex + 1) * 4096;
+#endif
DPRINT("File offset %I64x\n", FileOffset.QuadPart);
/* Write hive block */
RegistryHive->HiveHeader->Checksum = CmiCalcChecksum((PULONG)RegistryHive->HiveHeader);
/* Write hive block */
+#if defined(__GNUC__)
FileOffset.QuadPart = 0ULL;
+#else
+ FileOffset.QuadPart = 0;
+#endif
Status = NtWriteFile(FileHandle,
NULL,
NULL,
/* Remove the key from the parent key's hash block */
if (ParentKey->KeyCell->HashTableOffset != (BLOCK_OFFSET) -1)
{
- DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset)
+ DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset);
HashBlock = CmiGetCell (ParentKey->RegistryHive,
ParentKey->KeyCell->HashTableOffset,
NULL);
DPRINT("CmiGetCell() failed\n");
return STATUS_UNSUCCESSFUL;
}
- DPRINT("ParentKey HashBlock %p\n", HashBlock)
+ DPRINT("ParentKey HashBlock %p\n", HashBlock);
if (HashBlock != NULL)
{
CmiRemoveKeyFromHashTable(ParentKey->RegistryHive,
/* Remove the key's hash block */
if (SubKey->KeyCell->HashTableOffset != (BLOCK_OFFSET) -1)
{
- DPRINT("SubKey HashTableOffset %lx\n", SubKey->KeyCell->HashTableOffset)
+ DPRINT("SubKey HashTableOffset %lx\n", SubKey->KeyCell->HashTableOffset);
HashBlock = CmiGetCell (RegistryHive,
SubKey->KeyCell->HashTableOffset,
NULL);
DPRINT("CmiGetCell() failed\n");
return STATUS_UNSUCCESSFUL;
}
- DPRINT("SubKey HashBlock %p\n", HashBlock)
+ DPRINT("SubKey HashBlock %p\n", HashBlock);
if (HashBlock != NULL)
{
CmiDestroyCell (RegistryHive,
/* Decrement the number of the parent key's sub keys */
if (ParentKey != NULL)
{
- DPRINT("ParentKey %p\n", ParentKey)
+ DPRINT("ParentKey %p\n", ParentKey);
ParentKey->KeyCell->NumberOfSubKeys--;
/* Remove the parent key's hash table */
if (ParentKey->KeyCell->NumberOfSubKeys == 0)
{
- DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset)
+ DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset);
HashBlock = CmiGetCell (ParentKey->RegistryHive,
ParentKey->KeyCell->HashTableOffset,
NULL);
DPRINT("CmiGetCell() failed\n");
return STATUS_UNSUCCESSFUL;
}
- DPRINT("ParentKey HashBlock %p\n", HashBlock)
+ DPRINT("ParentKey HashBlock %p\n", HashBlock);
if (HashBlock != NULL)
{
CmiDestroyCell (ParentKey->RegistryHive,
pFree->CellSize = -pFree->CellSize;
/* Clear block (except the block size) */
- RtlZeroMemory(((PVOID)pFree) + sizeof(ULONG),
+ RtlZeroMemory(((char*)pFree) + sizeof(ULONG),
pFree->CellSize - sizeof(ULONG));
/* Add block to the list of free blocks */
Hive->HiveHeader->Checksum = CmiCalcChecksum ((PULONG)Hive->HiveHeader);
/* Write hive block */
+#if defined(__GNUC__)
FileOffset.QuadPart = 0ULL;
+#else
+ FileOffset.QuadPart = 0;
+#endif
Status = NtWriteFile (FileHandle,
NULL,
NULL,
BlockPtr = Hive->BlockList[BlockIndex];
DPRINT ("BlockPtr %p\n", BlockPtr);
+#if defined(__GNUC__)
FileOffset.QuadPart = (ULONGLONG)(BlockIndex + 1) * 4096ULL;
+#else
+ FileOffset.QuadPart = (ULONGLONG)(BlockIndex + 1) * 4096;
+#endif
DPRINT ("File offset %I64x\n", FileOffset.QuadPart);
/* Write hive block */
-/* $Id: registry.c,v 1.115 2003/11/27 00:48:11 gdalsnes Exp $
+/* $Id: registry.c,v 1.116 2003/12/30 18:52:03 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
CmiHiveSyncPending = TRUE;
+#if defined(__GNUC__)
Timeout.QuadPart = -50000000LL;
+#else
+ Timeout.QuadPart = -50000000;
+#endif
KeSetTimer(&CmiHiveSyncTimer,
Timeout,
&CmiHiveSyncDpc);
{
DPRINT("Expand REG_MULTI_SZ type\n");
- StringPtr = (PWSTR)((PVOID)FullValueInfo + FullValueInfo->DataOffset);
+ StringPtr = (PWSTR)((char*)FullValueInfo + FullValueInfo->DataOffset);
while (*StringPtr != 0)
{
StringLen = (wcslen(StringPtr) + 1) * sizeof(WCHAR);
{
Status = QueryEntry->QueryRoutine(ValueName,
FullValueInfo->Type,
- (PVOID)FullValueInfo + FullValueInfo->DataOffset,
+ (char*)FullValueInfo + FullValueInfo->DataOffset,
FullValueInfo->DataLength,
Context,
QueryEntry->EntryContext);
CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
if (address >= (PVOID)current->BaseAddress &&
- address < (PVOID)(current->BaseAddress + current->SizeOfImage))
+ address < (PVOID)((char*)current->BaseAddress + current->SizeOfImage))
{
RelativeAddress = (ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
Status = LdrGetAddressInformation(¤t->SymbolInfo,
-/* $Id: interlck.c,v 1.5 2002/12/16 22:56:30 hbirr Exp $
+/* $Id: interlck.c,v 1.6 2003/12/30 18:52:03 fireball Exp $
*
* reactos/ntoskrnl/ex/i386/interlck.c
*
#include <ddk/ntddk.h>
+#if defined(__GNUC__)
+
INTERLOCKED_RESULT FASTCALL
Exfi386InterlockedIncrementLong(IN PLONG Addend);
"andl $0xC000, %eax\n\t"
"ret\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+INTERLOCKED_RESULT FASTCALL
+Exfi386InterlockedIncrementLong(IN PLONG Addend)
+{
+ __asm add ecx, 1
+ __asm lahf
+ __asm and eax, 0xC000
+ __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
+#if defined(__GNUC__)
INTERLOCKED_RESULT FASTCALL
Exfi386InterlockedDecrementLong(IN PLONG Addend);
"andl $0xC000, %eax\n\t"
"ret\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+INTERLOCKED_RESULT FASTCALL
+Exfi386InterlockedDecrementLong(IN PLONG Addend)
+{
+ __asm sub ecx, 1
+ __asm lahf
+ __asm and eax, 0xC000
+ __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
+#if defined(__GNUC__)
ULONG FASTCALL
Exfi386InterlockedExchangeUlong(IN PULONG Target,
"movl %edx,%eax\n\t"
"ret\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+ULONG FASTCALL
+Exfi386InterlockedExchangeUlong(IN PULONG Target,
+ IN ULONG Value)
+{
+ __asm xchg [ecx], edx
+ __asm mov eax, edx
+ __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+#if defined(__GNUC__)
INTERLOCKED_RESULT STDCALL
Exi386InterlockedIncrementLong(IN PLONG Addend);
"andl $0xC000, %eax\n\t"
"ret $4\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+INTERLOCKED_RESULT STDCALL
+Exi386InterlockedIncrementLong(IN PLONG Addend)
+{
+ __asm mov eax, Addend
+ __asm add [eax], 1
+ __asm lahf
+ __asm and eax, 0xC000
+ __asm ret 4
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
+#if defined(__GNUC__)
INTERLOCKED_RESULT STDCALL
Exi386InterlockedDecrementLong(IN PLONG Addend);
"andl $0xC000, %eax\n\t"
"ret $4\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+INTERLOCKED_RESULT STDCALL
+Exi386InterlockedDecrementLong(IN PLONG Addend)
+{
+ __asm mov eax, Addend
+ __asm sub [eax], 1
+ __asm lahf
+ __asm and eax, 0xC000
+ __asm ret 4
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
+#if defined(__GNUC__)
ULONG STDCALL
Exi386InterlockedExchangeUlong(IN PULONG Target,
"xchgl %eax,(%edx)\n\t"
"ret $8\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+ULONG STDCALL
+Exi386InterlockedExchangeUlong(IN PULONG Target,
+ IN ULONG Value)
+{
+ __asm mov edx, Value
+ __asm mov eax, Target
+ __asm xchg [edx], eax
+ __asm ret 8
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
/**********************************************************************
* FASTCALL: @InterlockedIncrement@4
* STDCALL : _InterlockedIncrement@4
*/
+#if defined(__GNUC__)
LONG FASTCALL
InterlockedIncrement(PLONG Addend);
/*
"incl %eax\n\t"
"ret\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedIncrement(PLONG Addend)
+{
+ __asm mov eax, 1
+ __asm xadd [ecx], eax
+ __asm inc eax
+ __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
/**********************************************************************
* FASTCALL: @InterlockedDecrement@4
* STDCALL : _InterlockedDecrement@4
*/
+#if defined(__GNUC__)
LONG FASTCALL
InterlockedDecrement(PLONG Addend);
"decl %eax\n\t"
"ret\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedDecrement(PLONG Addend)
+{
+ __asm mov eax, -1
+ __asm xadd [ecx], eax
+ __asm dec eax
+ __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
/**********************************************************************
* FASTCALL: @InterlockedExchange@8
* STDCALL : _InterlockedExchange@8
*/
+#if defined(__GNUC__)
LONG FASTCALL
InterlockedExchange(PLONG Target,
LONG Value);
"movl %edx,%eax\n\t"
"ret\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedExchange(PLONG Target,
+ LONG Value)
+{
+ __asm xchg [ecx], edx
+ __asm mov eax, edx
+ __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
/**********************************************************************
* FASTCALL: @InterlockedExchangeAdd@8
* STDCALL: _InterlockedExchangeAdd@8
*/
+#if defined(__GNUC__)
+
LONG FASTCALL
InterlockedExchangeAdd(PLONG Addend,
LONG Value);
"movl %edx,%eax\n\t"
"ret\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedExchangeAdd(PLONG Addend,
+ LONG Value)
+{
+ __asm xadd [ecx], edx
+ __asm mov eax, edx
+ __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
/**********************************************************************
* FASTCALL: @InterlockedCompareExchange@12
* STDCALL: _InterlockedCompareExchange@12
*/
+#if defined(__GNUC__)
+
LONG FASTCALL
InterlockedCompareExchange(PLONG Destination,
LONG Exchange,
"cmpxchg %edx,(%ecx)\n\t"
"ret $4\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedCompareExchange(PLONG Destination,
+ LONG Exchange,
+ LONG Comperand)
+{
+ __asm mov eax, Comperand
+ __asm cmpxchg [ecx], edx
+ __asm ret 4
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
/* EOF */
-/* $Id: lookas.c,v 1.12 2003/10/12 17:05:44 hbirr Exp $
+/* $Id: lookas.c,v 1.13 2003/12/30 18:52:03 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* Buffer = Pointer to memory to free
*/
{
- return ExFreePool(Buffer);
+ ExFreePool(Buffer);
}
-/* $Id: resource.c,v 1.26 2003/08/14 18:30:28 silverblade Exp $
+/* $Id: resource.c,v 1.27 2003/12/30 18:52:03 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
ULONG i;
if (Resource->OwnerThreads[0].OwnerThread == ExGetCurrentResourceThread())
{
- return(Resource->OwnerThreads[0].OwnerCount);
+ return (USHORT)(Resource->OwnerThreads[0].OwnerCount);
}
if (Resource->OwnerThreads[1].OwnerThread == ExGetCurrentResourceThread())
{
- return(Resource->OwnerThreads[1].OwnerCount);
+ return (USHORT)(Resource->OwnerThreads[1].OwnerCount);
}
if (!Resource->OwnerThreads[1].TableSize)
{
{
if (Resource->OwnerTable[i].OwnerThread==ExGetCurrentResourceThread())
{
- return Resource->OwnerTable[i].OwnerCount;
+ return (USHORT)Resource->OwnerTable[i].OwnerCount;
}
}
return(0);
PERESOURCE Resource
)
{
- return(ExReleaseResourceForThreadLite(Resource,
- ExGetCurrentResourceThread()));
+ ExReleaseResourceForThreadLite(Resource,
+ ExGetCurrentResourceThread());
}
ERESOURCE_THREAD ResourceThreadId
)
{
- return(ExReleaseResourceForThreadLite(Resource,ResourceThreadId));
+ ExReleaseResourceForThreadLite(Resource,ResourceThreadId);
}
-/* $Id: zone.c,v 1.6 2003/07/17 16:57:38 silverblade Exp $
+/* $Id: zone.c,v 1.7 2003/12/30 18:52:03 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PushEntryList(&Zone->SegmentList,&seg->SegmentList);
- entry = (PZONE_SEGMENT_HEADER)( ((PVOID)seg) + sizeof(ZONE_SEGMENT_HEADER) );
+ entry = (PZONE_SEGMENT_HEADER)( ((char*)seg) + sizeof(ZONE_SEGMENT_HEADER) );
for (i=0;i<(SegmentSize / Zone->BlockSize);i++)
{
PushEntryList(&Zone->FreeList,&entry->SegmentList);
- entry = (PZONE_SEGMENT_HEADER)(((PVOID)entry) + sizeof(PZONE_SEGMENT_HEADER) +
+ entry = (PZONE_SEGMENT_HEADER)(((char*)entry) + sizeof(PZONE_SEGMENT_HEADER) +
Zone->BlockSize);
}
return(STATUS_SUCCESS);
PushEntryList(&Zone->SegmentList,&seg->SegmentList);
- entry = (PZONE_SEGMENT_HEADER)( ((PVOID)seg) + sizeof(ZONE_SEGMENT_HEADER) );
+ entry = (PZONE_SEGMENT_HEADER)( ((char*)seg) + sizeof(ZONE_SEGMENT_HEADER) );
for (i=0;i<(InitialSegmentSize / BlockSize);i++)
{
PushEntryList(&Zone->FreeList,&entry->SegmentList);
- entry = (PZONE_SEGMENT_HEADER)(((PVOID)entry) + sizeof(PZONE_SEGMENT_HEADER) + BlockSize);
+ entry = (PZONE_SEGMENT_HEADER)(((char*)entry) + sizeof(PZONE_SEGMENT_HEADER) + BlockSize);
}
return(STATUS_SUCCESS);
-/* $Id: mcb.c,v 1.10 2003/07/10 06:27:13 royce Exp $
+/* $Id: mcb.c,v 1.11 2003/12/30 18:52:03 fireball Exp $
*
* reactos/ntoskrnl/fs/mcb.c
*
IN LONGLONG Lbn,
IN LONGLONG SectorCount)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return(FALSE);
}
OUT PLONGLONG Lbn,
OUT PLONGLONG SectorCount)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return(FALSE);
}
FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb,
IN POOL_TYPE PoolType)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
Mcb->PoolType = PoolType;
}
OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL,
OUT PULONG Index OPTIONAL)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return(FALSE);
}
OUT PLONGLONG Vbn,
OUT PLONGLONG Lbn)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return(FALSE);
}
OUT PVBN Vbn,
OUT PLBN Lbn)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return(FALSE);
}
OUT PULONG SectorCount OPTIONAL,
OUT PULONG Index)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return(FALSE);
}
IN LONGLONG Vbn,
IN LONGLONG SectorCount)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
}
IN VBN Vbn,
IN ULONG SectorCount)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
}
IN LONGLONG Vbn,
IN LONGLONG Amount)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return(FALSE);
}
FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb,
IN LONGLONG Vbn)
{
- UNIMPLEMENTED
+ UNIMPLEMENTED;
}
-/* $Id: notify.c,v 1.8 2003/10/11 20:40:21 navaraf Exp $
+/* $Id: notify.c,v 1.9 2003/12/30 18:52:03 fireball Exp $
*
* reactos/ntoskrnl/fs/notify.c
*
IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL
)
{
+#if defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1300)
DbgPrint("%s()\n", __FUNCTION__);
+#else
+ DbgPrint("FsRtlNotifyFullChangeDirectory()\n");
+#endif
}
-/* $Id: inbv.c,v 1.4 2003/11/17 02:12:50 hyperion Exp $
+/* $Id: inbv.c,v 1.5 2003/12/30 18:52:03 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
}
BOOLEAN
-STDCALL_FUNC
+STDCALL
InbvResetDisplayParameters(ULONG SizeX, ULONG SizeY)
{
return(InbvResetDisplay());
* The following flags are used to tell iswctype and _isctype what character
* types you are looking for.
*/
+
#define _UPPER 0x0001
#define _LOWER 0x0002
#define _DIGIT 0x0004
typedef wchar_t wctype_t;
+#if defined(_MSC_VER)
+#define inline __inline
+typedef wchar_t wint_t;
+#endif
extern inline int isspace(int c);
extern inline int toupper(int c);
#include <internal/dbg.h>
#include <roscfg.h>
-#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
+#if defined(_MSC_VER) && (_MSC_VER < 1300)
+/* TODO: Verify which version the MS compiler learned the __FUNCTION__ macro */
+#define __FUNCTION__ "<unknown>"
+#endif
+#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0)
#ifdef DBG
#endif
/* Print if using a "checked" version */
-#define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
+#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
+#define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
+#else
+#define CPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
+#endif
#else /* DBG */
#endif /* DBG */
-#define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
-#define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
+#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
+#define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
+#else
+#define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
+#endif
+
+#define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
#if defined(KDBG) && defined(NDEBUG) && defined(__NTOSKRNL__)
DbgPrint("(%s:%d) ",__FILE__,__LINE__); \
DbgPrint(args); \
} \
-} while(0);
+} while(0)
#define CHECKPOINT
#else /* KDBG && NDEBUG && __NTOSKRNL__ */
#ifndef NDEBUG
-#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
-#define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
+#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
+#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
+#else
+#define DPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
+#endif
+#define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0)
#else /* NDEBUG */
+#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
#define DPRINT(args...)
+#else
+#define DPRINT
+#endif
#define CHECKPOINT
#endif /* NDEBUG */
#define KERNEL_BASE (0xc0000000)
+#if defined(__GNUC__)
+
#define FLUSH_TLB { \
unsigned int tmp; \
__asm__ __volatile__( \
:: "memory"); \
}
+#elif defined(_MSC_VER)
+/* TODO: Verify that this really WORKS. Perhaps it, as the GCC thing */
+/* above, needs to actually touch some memory too ? */
+#define FLUSH_TLB __asm mov eax, cr3 __asm mov cr3, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
PULONG MmGetPageDirectory(VOID);
#if 0
{
ULONG value;
+#if defined(__GNUC__)
__asm__ __volatile__ ("movl %%fs:0x18, %0\n\t"
: "=r" (value)
: /* no inputs */
);
+#elif defined(_MSC_VER)
+ __asm mov eax, fs:0x18;
+ __asm mov value, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
return((PKPCR)value);
}
-/* $Id: buildirp.c,v 1.37 2003/11/19 21:11:47 gdalsnes Exp $
+/* $Id: buildirp.c,v 1.38 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
StackPtr = IoGetNextIrpStackLocation(Irp);
- StackPtr->MajorFunction = MajorFunction;
+ StackPtr->MajorFunction = (UCHAR)MajorFunction;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
}
StackPtr = IoGetNextIrpStackLocation(Irp);
- StackPtr->MajorFunction = MajorFunction;
+ StackPtr->MajorFunction = (UCHAR)MajorFunction;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
-/* $Id: create.c,v 1.71 2003/12/14 17:44:02 hbirr Exp $
+/* $Id: create.c,v 1.72 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
break;
}
StackLoc->MinorFunction = 0;
- StackLoc->Flags = Options;
+ StackLoc->Flags = (UCHAR)Options;
StackLoc->Control = 0;
StackLoc->DeviceObject = FileObject->DeviceObject;
StackLoc->FileObject = FileObject;
StackLoc->Parameters.Create.SecurityContext = &SecurityContext;
StackLoc->Parameters.Create.Options = (CreateOptions & FILE_VALID_OPTION_FLAGS);
StackLoc->Parameters.Create.Options |= (CreateDisposition << 24);
- StackLoc->Parameters.Create.FileAttributes = FileAttributes;
- StackLoc->Parameters.Create.ShareAccess = ShareAccess;
+ StackLoc->Parameters.Create.FileAttributes = (USHORT)FileAttributes;
+ StackLoc->Parameters.Create.ShareAccess = (USHORT)ShareAccess;
StackLoc->Parameters.Create.EaLength = EaLength;
/*
-/* $Id: driver.c,v 1.32 2003/12/15 17:50:23 ekohl Exp $
+/* $Id: driver.c,v 1.33 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
for (i = 0; i < PAGE_ROUND_UP(Length)/PAGE_SIZE; i++)
{
- MmDeleteVirtualMapping(NULL, StartAddress + i * PAGE_SIZE, TRUE, NULL, NULL);
+ MmDeleteVirtualMapping(NULL, (char*)StartAddress + i * PAGE_SIZE, TRUE, NULL, NULL);
}
}
-/* $Id: errlog.c,v 1.15 2003/11/21 22:28:50 ekohl Exp $
+/* $Id: errlog.c,v 1.16 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
KeInitializeTimer (&WorkerDpc->Timer);
/* Restart after 30 seconds */
+#if defined(__GNUC__)
Timeout.QuadPart = -300000000LL;
+#else
+ Timeout.QuadPart = -300000000;
+#endif
KeSetTimer (&WorkerDpc->Timer,
Timeout,
&WorkerDpc->Dpc);
Message->Size =
sizeof(IO_ERROR_LOG_MESSAGE) - sizeof(IO_ERROR_LOG_PACKET) +
LogEntry->PacketSize + DriverNameLength;
- Message->DriverNameLength = DriverNameLength;
+ Message->DriverNameLength = (USHORT)DriverNameLength;
Message->TimeStamp.QuadPart = LogEntry->TimeStamp.QuadPart;
Message->DriverNameOffset = (DriverName != NULL) ? LogEntry->PacketSize : 0;
-/* $Id: iowork.c,v 1.5 2003/07/11 01:23:14 royce Exp $
+/* $Id: iowork.c,v 1.6 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* FUNCTIONS ****************************************************************/
-VOID STDCALL STATIC
+VOID STATIC STDCALL
IoWorkItemCallback(PVOID Parameter)
{
PIO_WORKITEM IoWorkItem = (PIO_WORKITEM)Parameter;
-/* $Id: irp.c,v 1.55 2003/11/30 20:01:05 gdalsnes Exp $
+/* $Id: irp.c,v 1.56 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
VOID STDCALL
IoEnqueueIrp(IN PIRP Irp)
{
- return IoQueueThreadIrp(Irp);
+ IoQueueThreadIrp(Irp);
}
-/* $Id: mdl.c,v 1.12 2003/07/10 15:47:00 royce Exp $
+/* $Id: mdl.c,v 1.13 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
MmSizeOfMdl(VirtualAddress,Length),
TAG_MDL);
}
- MmInitializeMdl(Mdl,VirtualAddress,Length);
+ MmInitializeMdl(Mdl, (char*)VirtualAddress, Length);
if (Irp!=NULL && !SecondaryBuffer)
{
Irp->MdlAddress = Mdl;
-/* $Id: pnproot.c,v 1.18 2003/11/17 02:12:51 hyperion Exp $
+/* $Id: pnproot.c,v 1.19 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
} PNPROOT_DEVICE_STATE;
+#if defined(__GNUC__)
+
typedef struct _PNPROOT_COMMON_DEVICE_EXTENSION
{
// Pointer to device object, this device extension is associated with
DEVICE_POWER_STATE DevicePowerState;
} __attribute((packed)) PNPROOT_COMMON_DEVICE_EXTENSION, *PPNPROOT_COMMON_DEVICE_EXTENSION;
+#elif defined(_MSC_VER)
+
+#include <pshpack1.h>
+typedef struct _PNPROOT_COMMON_DEVICE_EXTENSION
+{
+ // Pointer to device object, this device extension is associated with
+ PDEVICE_OBJECT DeviceObject;
+ // Wether this device extension is for an FDO or PDO
+ BOOLEAN IsFDO;
+ // Wether the device is removed
+ BOOLEAN Removed;
+ // Current device power state for the device
+ DEVICE_POWER_STATE DevicePowerState;
+} PNPROOT_COMMON_DEVICE_EXTENSION, *PPNPROOT_COMMON_DEVICE_EXTENSION;
+#include <poppack.h>
+
+#else
+#error Unknown compiler for structure packing
+#endif
+
+
+#if defined(__GNUC__)
+
/* Physical Device Object device extension for a child device */
typedef struct _PNPROOT_PDO_DEVICE_EXTENSION
{
UNICODE_STRING InstanceID;
} __attribute((packed)) PNPROOT_PDO_DEVICE_EXTENSION, *PPNPROOT_PDO_DEVICE_EXTENSION;
+#elif defined(_MSC_VER)
+
+#include <pshpack1.h>
+typedef struct _PNPROOT_PDO_DEVICE_EXTENSION
+{
+ // Common device data
+ PNPROOT_COMMON_DEVICE_EXTENSION Common;
+ // Device ID
+ UNICODE_STRING DeviceID;
+ // Instance ID
+ UNICODE_STRING InstanceID;
+} PNPROOT_PDO_DEVICE_EXTENSION, *PPNPROOT_PDO_DEVICE_EXTENSION;
+#include <poppack.h>
+
+#else
+#error Unknown compiler for structure packing
+#endif
+
+
+#if defined(__GNUC__)
+
/* Functional Device Object device extension for the PCI driver device object */
typedef struct _PNPROOT_FDO_DEVICE_EXTENSION
{
KSPIN_LOCK DeviceListLock;
} __attribute((packed)) PNPROOT_FDO_DEVICE_EXTENSION, *PPNPROOT_FDO_DEVICE_EXTENSION;
+#elif defined(_MSC_VER)
+
+#include <pshpack1.h>
+typedef struct _PNPROOT_FDO_DEVICE_EXTENSION
+{
+ // Common device data
+ PNPROOT_COMMON_DEVICE_EXTENSION Common;
+ // Physical Device Object
+ PDEVICE_OBJECT Pdo;
+ // Lower device object
+ PDEVICE_OBJECT Ldo;
+ // Current state of the driver
+ PNPROOT_DEVICE_STATE State;
+ // Namespace device list
+ LIST_ENTRY DeviceListHead;
+ // Number of (not removed) devices in device list
+ ULONG DeviceListCount;
+ // Lock for namespace device list
+ // FIXME: Use fast mutex instead?
+ KSPIN_LOCK DeviceListLock;
+} PNPROOT_FDO_DEVICE_EXTENSION, *PPNPROOT_FDO_DEVICE_EXTENSION;
+#include <poppack.h>
+
+#else
+#error Unknown compiler for structure packing
+#endif
+
+
PDEVICE_OBJECT PnpRootDeviceObject;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: process.c,v 1.15 2003/07/10 15:47:00 royce Exp $
+/* $Id: process.c,v 1.16 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
*
* @implemented
*/
-BOOLEAN STDCALL EXPORTED
+BOOLEAN STDCALL
IoSetThreadHardErrorMode(IN BOOLEAN HardErrorEnabled)
{
- BOOLEAN PreviousHEM = NtCurrentTeb()->HardErrorDisabled;
+ BOOLEAN PreviousHEM = (BOOLEAN)(NtCurrentTeb()->HardErrorDisabled);
NtCurrentTeb()->HardErrorDisabled = ((TRUE == HardErrorEnabled) ? FALSE : TRUE);
-/* $Id: rawfs.c,v 1.8 2003/12/14 17:56:22 hbirr Exp $
+/* $Id: rawfs.c,v 1.9 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
RawFsClose(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsClose(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
IrpContext->Irp->IoStatus.Status = Status;
IoCompleteRequest(IrpContext->Irp,
- NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);
+ (CCHAR)(NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT));
RawFsFreeIrpContext(IrpContext);
return Status;
RawFsRead(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsRead(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
RawFsWrite(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsWrite(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
RawFsQueryInformation(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsQueryInformation(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
RawFsSetInformation(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsSetInformation(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
RawFsDirectoryControl(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsDirectoryControl(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
RawFsQueryVolumeInformation(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsQueryVolumeInformation(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
RawFsSetVolumeInformation(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsSetVolumeInformation(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
RawFsLockControl(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsLockControl(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
RawFsCleanup(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsCleanup(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
RawFsFlush(IN PRAWFS_IRP_CONTEXT IrpContext)
{
DPRINT("RawFsFlush(IrpContext %x)\n", IrpContext);
- UNIMPLEMENTED
+ UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
-/* $Id: timer.c,v 1.10 2003/11/05 22:49:06 gvg Exp $
+/* $Id: timer.c,v 1.11 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* DeviceObject = Device whose timer is to be started
*/
{
- long long int lli;
+ LONGLONG lli;
LARGE_INTEGER li;
lli = -1000000;
-/* $Id: xhaldrv.c,v 1.41 2003/12/14 17:56:22 hbirr Exp $
+/* $Id: xhaldrv.c,v 1.42 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
return;
}
+#if defined(__GNUC__)
SectorOffset.QuadPart = 0LL;
+#else
+ SectorOffset.QuadPart = 0;
+#endif
Status = xHalpReadSector (DeviceObject,
SectorSize,
&SectorOffset,
{
LARGE_INTEGER RealPartitionOffset;
ULONGLONG PartitionOffset;
+#if defined(__GNUC__)
ULONGLONG nextPartitionOffset = 0LL;
+#else
+ ULONGLONG nextPartitionOffset = 0;
+#endif
ULONGLONG containerOffset;
NTSTATUS Status;
PPARTITION_SECTOR PartitionSector;
RtlZeroMemory(LayoutBuffer,
0x1000);
+#if defined(__GNUC__)
PartitionOffset = 0ULL;
containerOffset = 0ULL;
+#else
+ PartitionOffset = 0;
+ containerOffset = 0;
+#endif
do
{
/* Shift offset by 63 sectors */
RealPartitionOffset.QuadPart = PartitionOffset + (ULONGLONG)(63 * SectorSize);
}
+#if defined(__GNUC__)
else if (DiskManager == EZ_Drive && PartitionOffset == 0ULL)
+#else
+ else if (DiskManager == EZ_Drive && PartitionOffset == 0)
+#endif
{
/* Use sector 1 instead of sector 0 */
RealPartitionOffset.QuadPart = (ULONGLONG)SectorSize;
}
#endif
+#if defined(__GNUC__)
if (PartitionOffset == 0ULL)
+#else
+ if (PartitionOffset == 0)
+#endif
{
LayoutBuffer->Signature = PartitionSector->Signature;
DPRINT("Disk signature: %lx\n", LayoutBuffer->Signature);
PPARTITION_SECTOR PartitionSector;
LARGE_INTEGER RealPartitionOffset;
ULONGLONG PartitionOffset;
+#if defined(__GNUC__)
ULONGLONG nextPartitionOffset = 0LL;
+#else
+ ULONGLONG nextPartitionOffset = 0;
+#endif
ULONGLONG containerOffset;
NTSTATUS Status;
ULONG i;
return STATUS_INSUFFICIENT_RESOURCES;
}
+#if defined(__GNUC__)
PartitionOffset = 0ULL;
containerOffset = 0ULL;
+#else
+ PartitionOffset = 0;
+ containerOffset = 0;
+#endif
do
{
/* Shift offset by 63 sectors */
RealPartitionOffset.QuadPart = PartitionOffset + (ULONGLONG)(63 * SectorSize);
}
+#if defined(__GNUC__)
else if (DiskManager == EZ_Drive && PartitionOffset == 0ULL)
+#else
+ else if (DiskManager == EZ_Drive && PartitionOffset == 0)
+#endif
{
/* Use sector 1 instead of sector 0 */
RealPartitionOffset.QuadPart = (ULONGLONG)SectorSize;
if (IsContainerPartition (PartitionSector->Partition[i].PartitionType))
{
ExtendedFound = TRUE;
+#if defined(__GNUC__)
if (containerOffset == 0ULL)
+#else
+ if (containerOffset == 0)
+#endif
{
containerOffset = PartitionOffset;
}
PPARTITION_SECTOR PartitionSector;
LARGE_INTEGER RealPartitionOffset;
ULONGLONG PartitionOffset;
+#if defined(__GNUC__)
ULONGLONG NextPartitionOffset = 0LL;
+#else
+ ULONGLONG NextPartitionOffset = 0;
+#endif
ULONGLONG ContainerOffset;
BOOLEAN ContainerEntry;
DISK_MANAGER DiskManager;
}
Status = STATUS_SUCCESS;
+#if defined(__GNUC__)
PartitionOffset = 0ULL;
ContainerOffset = 0ULL;
+#else
+ PartitionOffset = 0;
+ ContainerOffset = 0;
+#endif
for (i = 0; i < PartitionBuffer->PartitionCount; i += 4)
{
DPRINT ("PartitionOffset: %I64u\n", PartitionOffset);
/* Shift offset by 63 sectors */
RealPartitionOffset.QuadPart = PartitionOffset + (ULONGLONG)(63 * SectorSize);
}
+#if defined(__GNUC__)
else if (DiskManager == EZ_Drive && PartitionOffset == 0ULL)
+#else
+ else if (DiskManager == EZ_Drive && PartitionOffset == 0)
+#endif
{
/* Use sector 1 instead of sector 0 */
RealPartitionOffset.QuadPart = (ULONGLONG)SectorSize;
PartitionBuffer->PartitionEntry[i + j].PartitionType;
/* Set partition data */
+#if defined(__GNUC__)
if (PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart == 0ULL &&
PartitionBuffer->PartitionEntry[i + j].PartitionLength.QuadPart == 0ULL)
+#else
+ if (PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart == 0 &&
+ PartitionBuffer->PartitionEntry[i + j].PartitionLength.QuadPart == 0)
+#endif
{
PartitionSector->Partition[j].StartingBlock = 0;
PartitionSector->Partition[j].SectorCount = 0;
*/
/* Compute starting CHS values */
- lba = (PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart) / SectorSize;
+ lba = (ULONG)((PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart) / SectorSize);
x = lba / SectorsPerTrack;
StartCylinder = (x / NumberOfHeads) %1024;
StartHead = x % NumberOfHeads;
lba, StartCylinder, StartHead, StartSector);
/* Compute ending CHS values */
- lba = (PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart +
- (PartitionBuffer->PartitionEntry[i + j].PartitionLength.QuadPart - 1)) / SectorSize;
+ lba = (ULONG)((PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart +
+ (PartitionBuffer->PartitionEntry[i + j].PartitionLength.QuadPart - 1)) / SectorSize);
x = lba / SectorsPerTrack;
EndCylinder = (x / NumberOfHeads) % 1024;
EndHead = x % NumberOfHeads;
NextPartitionOffset =
PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart;
+#if defined(__GNUC__)
if (ContainerOffset == 0ULL)
+#else
+ if (ContainerOffset == 0)
+#endif
{
ContainerOffset = NextPartitionOffset;
}
if (ch == '#')
{
ch = KdGetChar ();
- XmitChecksum = HexValue (ch) << 4;
+ XmitChecksum = (CHAR)(HexValue (ch) << 4);
ch = KdGetChar ();
- XmitChecksum += HexValue (ch);
+ XmitChecksum += (CHAR)(HexValue (ch));
if (Checksum != XmitChecksum)
{
for (i = 0; i < countinpage && ! GspMemoryError; i++)
{
- ch = HexValue (*Buffer++) << 4;
- ch = ch + HexValue (*Buffer++);
+ ch = (CHAR)(HexValue (*Buffer++) << 4);
+ ch = (CHAR)(ch + HexValue (*Buffer++));
GspAccessLocation = Address;
*current = ch;
ULONG Address;
} GsHwBreakPoint;
+#if defined(__GNUC__)
GsHwBreakPoint GspBreakpoints[4] =
{
{ Enabled : FALSE },
{ Enabled : FALSE },
{ Enabled : FALSE }
};
+#else
+GsHwBreakPoint GspBreakpoints[4] =
+{
+ { FALSE },
+ { FALSE },
+ { FALSE },
+ { FALSE }
+};
+#endif
VOID
GspCorrectHwBreakpoint()
ULONG BreakpointNumber;
BOOLEAN CorrectIt;
BOOLEAN Bit;
- ULONG dr7;
+ ULONG dr7_;
+#if defined(__GNUC__)
asm volatile (
- "movl %%db7, %0\n" : "=r" (dr7) : );
+ "movl %%db7, %0\n" : "=r" (dr7_) : );
do
{
ULONG addr0, addr1, addr2, addr3;
: "=r" (addr0), "=r" (addr1),
"=r" (addr2), "=r" (addr3) : );
} while (FALSE);
+#elif defined(_MSC_VER)
+ __asm
+ {
+ mov eax, dr7; mov dr7_, eax;
+ mov eax, dr0; mov addr0, eax;
+ mov eax, dr1; mov addr1, eax;
+ mov eax, dr2; mov addr2, eax;
+ mov eax, dr3; mov addr3, eax;
+ }
+#else
+#error Unknown compiler for inline assembler
+#endif
CorrectIt = FALSE;
for (BreakpointNumber = 0; BreakpointNumber < 3; BreakpointNumber++)
{
Bit = 2 << (BreakpointNumber << 1);
- if (!(dr7 & Bit) && GspBreakpoints[BreakpointNumber].Enabled) {
+ if (!(dr7_ & Bit) && GspBreakpoints[BreakpointNumber].Enabled) {
CorrectIt = TRUE;
- dr7 |= Bit;
- dr7 &= ~(0xf0000 << (BreakpointNumber << 2));
- dr7 |= (((GspBreakpoints[BreakpointNumber].Length << 2) |
+ dr7_ |= Bit;
+ dr7_ &= ~(0xf0000 << (BreakpointNumber << 2));
+ dr7_ |= (((GspBreakpoints[BreakpointNumber].Length << 2) |
GspBreakpoints[BreakpointNumber].Type) << 16) << (BreakpointNumber << 2);
switch (BreakpointNumber) {
+#if defined(__GNUC__)
case 0:
asm volatile ("movl %0, %%dr0\n"
: : "r" (GspBreakpoints[BreakpointNumber].Address) );
asm volatile ("movl %0, %%dr3\n"
: : "r" (GspBreakpoints[BreakpointNumber].Address) );
break;
+#elif defined(_MSC_VER)
+ case 0:
+ {
+ ULONG addr = GspBreakpoints[BreakpointNumber].Address;
+ __asm mov eax, addr;
+ __asm mov dr0, eax;
+ }
+ break;
+ case 1:
+ {
+ ULONG addr = GspBreakpoints[BreakpointNumber].Address;
+ __asm mov eax, addr;
+ __asm mov dr1, eax;
+ }
+ break;
+ case 2:
+ {
+ ULONG addr = GspBreakpoints[BreakpointNumber].Address;
+ __asm mov eax, addr;
+ __asm mov dr2, eax;
+ }
+ break;
+ case 3:
+ {
+ ULONG addr = GspBreakpoints[BreakpointNumber].Address;
+ __asm mov eax, addr;
+ __asm mov dr3, eax;
+ }
+ break;
+#else
+#error Unknown compiler for inline assembler
+#endif
}
}
- else if ((dr7 & Bit) && !GspBreakpoints[BreakpointNumber].Enabled)
+ else if ((dr7_ & Bit) && !GspBreakpoints[BreakpointNumber].Enabled)
{
CorrectIt = TRUE;
- dr7 &= ~Bit;
- dr7 &= ~(0xf0000 << (BreakpointNumber << 2));
+ dr7_ &= ~Bit;
+ dr7_ &= ~(0xf0000 << (BreakpointNumber << 2));
}
}
if (CorrectIt)
{
- asm volatile ( "movl %0, %%db7\n" : : "r" (dr7));
+#if defined(__GNUC__)
+ asm volatile ( "movl %0, %%db7\n" : : "r" (dr7_));
+#elif defined(_MSC_VER)
+ __asm mov eax, dr7_;
+ __asm mov dr7, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
}
}
/* FIXME: Stop on other CPUs too */
/* Disable hardware debugging while we are inside the stub */
+#if defined(__GNUC__)
__asm__("movl %0,%%db7" : /* no output */ : "r" (0));
+#elif defined(_MSC_VER)
+ __asm mov eax, 0 __asm mov dr7, eax
+#else
+#error Unknown compiler for inline assembler
+#endif
if (STATUS_ACCESS_VIOLATION == (NTSTATUS) ExceptionRecord->ExceptionCode &&
NULL != GspAccessLocation &&
case 'c':
{
ULONG BreakpointNumber;
- ULONG dr6;
+ ULONG dr6_;
/* try to read optional parameter, pc unchanged if no parm */
if (GspHex2Long (&ptr, &Address))
if (Stepping)
Context->EFlags |= 0x100;
- asm volatile ("movl %%db6, %0\n" : "=r" (dr6) : );
- if (!(dr6 & 0x4000))
+#if defined(__GNUC__)
+ asm volatile ("movl %%db6, %0\n" : "=r" (dr6_) : );
+#elif defined(_MSC_VER)
+ __asm mov eax, dr6 __asm mov dr6_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+ if (!(dr6_ & 0x4000))
{
for (BreakpointNumber = 0; BreakpointNumber < 4; ++BreakpointNumber)
{
- if (dr6 & (1 << BreakpointNumber))
+ if (dr6_ & (1 << BreakpointNumber))
{
if (GspBreakpoints[BreakpointNumber].Type == 0)
{
}
}
GspCorrectHwBreakpoint();
+#if defined(__GNUC__)
asm volatile ("movl %0, %%db6\n" : : "r" (0));
+#elif defined(_MSC_VER)
+ __asm mov eax, 0 __asm mov dr6, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
return kdHandleException;
break;
-/* $Id: service.c,v 1.5 2002/09/08 10:23:27 chorns Exp $
+/* $Id: service.c,v 1.6 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#define _STR(x) #x
#define STR(x) _STR(x)
+#if defined(__GNUC__)
+
void interrupt_handler2d(void);
__asm__("\n\t.global _interrupt_handler2d\n\t"
"_interrupt_handler2d:\n\t"
"iret\n\t");
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+void interrupt_handler2d()
+{
+ __asm
+ {
+ /* Save the user context */
+ push ebp
+ push eax
+ push ecx
+ push edx
+ push ebx
+ push esi
+ push edi
+
+ push ds
+ push es
+ push fs
+ push gs
+
+ sub esp, 112 /* FloatSave */
+
+ mov eax, dr7; push eax;
+ mov eax, dr6; push eax;
+ mov eax, dr3; push eax;
+ mov eax, dr2; push eax;
+ mov eax, dr1; push eax;
+ mov eax, dr0; push eax;
+
+ push 0 /* ContextFlags */
+
+ /* Set ES to kernel segment */
+ mov bx, KERNEL_DS
+ mov es, bx
+
+ /* FIXME: check to see if SS is valid/inrange */
+
+ mov ds, bx /* DS is now also kernel segment */
+
+ /* Call debug service dispatcher */
+ push edx
+ push ecx
+ push eax
+ call KdpServiceDispatcher
+ add esp, 12 /* restore stack pointer */
+
+ /* Restore the user context */
+ add esp, 4 /* UserContext */
+ pop eax; mov dr0, eax;
+ pop eax; mov dr1, eax;
+ pop eax; mov dr2, eax;
+ pop eax; mov dr3, eax;
+ pop eax; mov dr6, eax;
+ pop eax; mov dr7, eax;
+ add esp, 112 /* FloatingSave */
+ pop gs
+ pop fs
+ pop es
+ pop ds
+
+ pop edi
+ pop esi
+ pop ebx
+ pop edx
+ pop ecx
+ add esp, 4 /* Eax Not restored */
+
+ pop ebp
+
+ iret
+ }
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
/* EOF */
KeInsertQueueApc (PKAPC Apc,
PVOID SystemArgument1,
PVOID SystemArgument2,
- KPRIORITY PriorityBoost)
+ KPRIORITY PriorityBoost)
/*
* FUNCTION: Queues an APC for execution
* ARGUMENTS:
DPRINT("KeInsertQueueApc(Apc %x, SystemArgument1 %x, "
"SystemArgument2 %x)\n",Apc,SystemArgument1,
SystemArgument2);
-
- KeAcquireSpinLock(&PiApcLock, &oldlvl);
-
+
Apc->SystemArgument1 = SystemArgument1;
Apc->SystemArgument2 = SystemArgument2;
-
+
if (Apc->Inserted)
{
+#if 0
+ /* TMN: This code is in error */
DbgPrint("KeInsertQueueApc(): multiple APC insertations\n");
KEBUGCHECK(0);
+#else
+ return FALSE;
+#endif
}
-
+
+ KeAcquireSpinLock(&PiApcLock, &oldlvl);
+
TargetThread = Apc->Thread;
if (TargetThread->State == THREAD_STATE_TERMINATED_1 ||
* 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.40 2003/10/12 17:05:45 hbirr Exp $
+/* $Id: bug.c,v 1.41 2003/12/30 18:52:04 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/bug.c
KdDebugState |= KD_DEBUG_SCREEN;
}
+#if defined(__GNUC__)
__asm__("cli\n\t");
+#elif defined(_MSC_VER)
+ __asm cli
+#else
+#error Unknown compiler for inline assembler
+#endif
+
if (KeGetCurrentIrql() < DISPATCH_LEVEL)
{
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
DbgPrint("Recursive bug check halting now\n");
for (;;)
{
- __asm__ ("hlt\n\t");
+#if defined(__GNUC__)
+ __asm__("hlt\n\t");
+#elif defined(_MSC_VER)
+ __asm hlt
+#else
+#error Unknown compiler for inline assembler
+#endif
}
}
InBugCheck = 1;
if (KdDebuggerEnabled)
{
+#if defined(__GNUC__)
__asm__("sti\n\t");
DbgBreakPoint();
__asm__("cli\n\t");
+#elif defined(_MSC_VER)
+ __asm sti
+ DbgBreakPoint();
+ __asm cli
+#else
+#error Unknown compiler for inline assembler
+#endif
}
for (;;)
{
+#if defined(__GNUC__)
__asm__("hlt\n\t");
+#elif defined(_MSC_VER)
+ __asm hlt
+#else
+#error Unknown compiler for inline assembler
+#endif
}
}
KdDebugState |= KD_DEBUG_SCREEN;
}
+#if defined(__GNUC__)
__asm__("cli\n\t");
+#elif defined(_MSC_VER)
+ __asm cli
+#else
+#error Unknown compiler for inline assembler
+#endif
if (KeGetCurrentIrql() < DISPATCH_LEVEL)
{
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
DbgPrint("Recursive bug check halting now\n");
for (;;)
{
+#if defined(__GNUC__)
__asm__("hlt\n\t");
+#elif defined(_MSC_VER)
+ __asm hlt
+#else
+#error Unknown compiler for inline assembler
+#endif
}
}
InBugCheck = 1;
PsGetCurrentThread(),
PsGetCurrentThread()->Cid.UniqueThread);
}
+#if defined(__GNUC__)
KeDumpStackFrames((PULONG)__builtin_frame_address(0));
+#elif defined(_MSC_VER)
+ __asm push ebp
+ __asm call KeDumpStackFrames
+ __asm add esp, 4
+#else
+#error Unknown compiler for inline assembler
+#endif
MmDumpToPagingFile(BugCheckCode, BugCheckParameter1,
BugCheckParameter2, BugCheckParameter3,
BugCheckParameter4, NULL);
if (KdDebuggerEnabled)
{
+#if defined(__GNUC__)
__asm__("sti\n\t");
DbgBreakPoint();
__asm__("cli\n\t");
+#elif defined(_MSC_VER)
+ __asm sti
+ DbgBreakPoint();
+ __asm cli
+#else
+#error Unknown compiler for inline assembler
+#endif
}
for (;;)
{
+#if defined(__GNUC__)
__asm__("hlt\n\t");
+#elif defined(_MSC_VER)
+ __asm hlt
+#else
+#error Unknown compiler for inline assembler
+#endif
}
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: catch.c,v 1.38 2003/12/14 19:43:09 navaraf Exp $
+/* $Id: catch.c,v 1.39 2003/12/30 18:52:04 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/catch.c
KiDispatchException(ExceptionRecord,
Context,
PsGetCurrentThread()->Tcb.TrapFrame,
- ExGetPreviousMode(),
+ (KPROCESSOR_MODE)ExGetPreviousMode(),
SearchFrames);
return(STATUS_SUCCESS);
}
/*
* ReactOS kernel
- * Copyright (C) 2000, 1999, 1998 David Welch <welch@cwcom.net>,
+ * Copyright (C) 2000, 1999, 1998 David Welch <welch@cwcom.net>,
* Philip Susi <phreak@iag.net>,
* Eric Kohl <ekohl@abo.rhein-zeitung.de>
*
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: dpc.c,v 1.28 2003/10/12 17:05:45 hbirr Exp $
+/* $Id: dpc.c,v 1.29 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
static LIST_ENTRY DpcQueueHead; /* Head of the list of pending DPCs */
static KSPIN_LOCK DpcQueueLock; /* Lock for the above list */
-/*
+/*
* Number of pending DPCs. This is inspected by
* the idle thread to determine if the queue needs to
* be run down
*/
-ULONG DpcQueueSize = 0;
+ULONG DpcQueueSize = 0;
/* FUNCTIONS ****************************************************************/
/*
* @implemented
*/
-VOID STDCALL
+VOID STDCALL
KeInitializeDpc (PKDPC Dpc,
PKDEFERRED_ROUTINE DeferredRoutine,
PVOID DeferredContext)
/*
* @implemented
*/
-VOID STDCALL
+VOID STDCALL
KiDispatchInterrupt(VOID)
/*
* FUNCTION: Called to execute queued dpcs
PLIST_ENTRY current_entry;
PKDPC current;
KIRQL oldlvl;
-
+
assert_irql(DISPATCH_LEVEL);
-
+
if (DpcQueueSize == 0)
{
return;
}
-
+
KeRaiseIrql(HIGH_LEVEL, &oldlvl);
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
{
current_entry = RemoveHeadList(&DpcQueueHead);
DpcQueueSize--;
+
+ assert(DpcQueueSize || IsListEmpty(&DpcQueueHead));
+
current = CONTAINING_RECORD(current_entry,KDPC,DpcListEntry);
current->Lock=FALSE;
- KeReleaseSpinLock(&DpcQueueLock, oldlvl);
+ KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
+ KeLowerIrql(oldlvl);
current->DeferredRoutine(current,current->DeferredContext,
current->SystemArgument1,
current->SystemArgument2);
KeRaiseIrql(HIGH_LEVEL, &oldlvl);
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
}
- KeReleaseSpinLock(&DpcQueueLock, oldlvl);
+ KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
+ KeLowerIrql(oldlvl);
}
/*
* @implemented
*/
-BOOLEAN STDCALL
+BOOLEAN STDCALL
KeRemoveQueueDpc (PKDPC Dpc)
/*
* FUNCTION: Removes DPC object from the system dpc queue
*/
{
KIRQL oldIrql;
-
+ BOOLEAN WasInQueue;
+
KeRaiseIrql(HIGH_LEVEL, &oldIrql);
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
- if (!Dpc->Lock)
+ WasInQueue = Dpc->Lock ? TRUE : FALSE;
+ if (WasInQueue)
{
- KeReleaseSpinLock(&DpcQueueLock, oldIrql);
- return(FALSE);
+ RemoveEntryList(&Dpc->DpcListEntry);
+ DpcQueueSize--;
+ Dpc->Lock=0;
}
- RemoveEntryList(&Dpc->DpcListEntry);
- DpcQueueSize--;
- Dpc->Lock=0;
- KeReleaseSpinLock(&DpcQueueLock, oldIrql);
- return(TRUE);
+
+ assert(DpcQueueSize || IsListEmpty(&DpcQueueHead));
+
+ KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
+ KeLowerIrql(oldIrql);
+
+ return WasInQueue;
}
/*
* @implemented
*/
-BOOLEAN STDCALL
+BOOLEAN STDCALL
KeInsertQueueDpc (PKDPC Dpc,
PVOID SystemArgument1,
PVOID SystemArgument2)
}
KeRaiseIrql(HIGH_LEVEL, &oldlvl);
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
+ assert(DpcQueueSize || IsListEmpty(&DpcQueueHead));
InsertHeadList(&DpcQueueHead,&Dpc->DpcListEntry);
DPRINT("Dpc->DpcListEntry.Flink %x\n", Dpc->DpcListEntry.Flink);
DpcQueueSize++;
Dpc->Lock=(PULONG)1;
- KeReleaseSpinLock( &DpcQueueLock, oldlvl );
+ KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
+ KeLowerIrql(oldlvl);
DPRINT("DpcQueueHead.Flink %x\n",DpcQueueHead.Flink);
DPRINT("Leaving KeInsertQueueDpc()\n",0);
return(TRUE);
VOID STDCALL
DbgBreakPoint(VOID)
{
+#if defined(__GNUC__)
__asm__("int $3\n\t");
+#elif defined(_MSC_VER)
+ __asm int 3;
+#else
+#error Unknown compiler for inline assembler
+#endif
}
/*
VOID STDCALL
DbgBreakPointWithStatus(ULONG Status)
{
+#if defined(__GNUC__)
__asm__("mov %0, %%eax\n\t"
"int $3\n\t"
::"m"(Status));
+#elif defined(_MSC_VER)
+ __asm mov eax, Status
+ __asm int 3;
+#else
+#error Unknown compiler for inline assembler
+#endif
}
ULONG
KiDoubleFaultHandler(VOID)
{
- unsigned int cr2;
+ unsigned int cr2_;
ULONG StackLimit;
ULONG StackBase;
ULONG Esp0;
Esp0 = OldTss->Esp;
/* Get CR2 */
- __asm__("movl %%cr2,%0\n\t" : "=d" (cr2));
+#if defined(__GNUC__)
+ __asm__("movl %%cr2,%0\n\t" : "=d" (cr2_));
+#elif defined(_MSC_VER)
+ __asm mov eax, cr2;
+ __asm mov cr2_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
if (PsGetCurrentThread() != NULL &&
PsGetCurrentThread()->ThreadsProcess != NULL)
{
- OldCr3 =
+ OldCr3 = (ULONG)
PsGetCurrentThread()->ThreadsProcess->Pcb.DirectoryTableBase.QuadPart;
}
else
DbgPrint("CS:EIP %x:%x ", OldTss->Cs, OldTss->Eip);
print_address((PVOID)OldTss->Eip);
DbgPrint("\n");
- DbgPrint("cr2 %x cr3 %x ", cr2, OldCr3);
+ DbgPrint("cr2 %x cr3 %x ", cr2_, OldCr3);
DbgPrint("Proc: %x ",PsGetCurrentProcess());
if (PsGetCurrentProcess() != NULL)
{
VOID
KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2)
{
- ULONG cr3;
+ ULONG cr3_;
ULONG i;
ULONG StackLimit;
PULONG Frame;
Tf->Cs&0xffff, Tf->Eip);
print_address((PVOID)Tf->Eip);
DbgPrint("\n");
- __asm__("movl %%cr3,%0\n\t" : "=d" (cr3));
- DbgPrint("cr2 %x cr3 %x ", cr2, cr3);
+#if defined(__GNUC__)
+ __asm__("movl %%cr3,%0\n\t" : "=d" (cr3_));
+#elif defined(_MSC_VER)
+ __asm mov eax, cr3;
+ __asm mov cr3_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+ DbgPrint("cr2 %x cr3 %x ", cr2, cr3_);
DbgPrint("Proc: %x ",PsGetCurrentProcess());
if (PsGetCurrentProcess() != NULL)
{
* Complete CPU context
*/
{
- unsigned int cr2;
+ unsigned int cr2_;
NTSTATUS Status;
ULONG Esp0;
Esp0 = (ULONG)&Tf->Eip;
/* Get CR2 */
- __asm__("movl %%cr2,%0\n\t" : "=d" (cr2));
- Tf->DebugPointer = (PVOID)cr2;
+#if defined(__GNUC__)
+ __asm__("movl %%cr2,%0\n\t" : "=d" (cr2_));
+#elif defined(_MSC_VER)
+ __asm mov eax, cr2;
+ __asm mov cr2_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+ Tf->DebugPointer = (PVOID)cr2_;
/*
* If this was a V86 mode exception then handle it specially
*/
if (Tf->Eflags & (1 << 17))
{
- return(KeV86Exception(ExceptionNr, Tf, cr2));
+ return(KeV86Exception(ExceptionNr, Tf, cr2_));
}
/*
Status = MmPageFault(Tf->Cs&0xffff,
&Tf->Eip,
&Tf->Eax,
- cr2,
+ cr2_,
Tf->ErrorCode);
if (NT_SUCCESS(Status))
{
*/
if ((Tf->Cs & 0xFFFF) == USER_CS)
{
- return(KiUserTrapHandler(Tf, ExceptionNr, (PVOID)cr2));
+ return(KiUserTrapHandler(Tf, ExceptionNr, (PVOID)cr2_));
}
else
{
- return(KiKernelTrapHandler(Tf, ExceptionNr, (PVOID)cr2));
+ return(KiKernelTrapHandler(Tf, ExceptionNr, (PVOID)cr2_));
}
}
-/* $Id: fpu.c,v 1.11 2003/11/06 20:40:25 gvg Exp $
+/* $Id: fpu.c,v 1.12 2003/12/30 18:52:04 fireball Exp $
*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
KiCheckFPU(VOID)
{
unsigned short int status;
- int cr0;
+ int cr0_;
HardwareMathSupport = 0;
- __asm__("movl %%cr0, %0\n\t" : "=a" (cr0));
+#if defined(__GNUC__)
+ __asm__("movl %%cr0, %0\n\t" : "=a" (cr0_));
/* Set NE and MP. */
- cr0 = cr0 | 0x22;
+ cr0_ = cr0_ | 0x22;
/* Clear EM */
- cr0 = cr0 & (~0x4);
- __asm__("movl %0, %%cr0\n\t" : : "a" (cr0));
+ cr0_ = cr0_ & (~0x4);
+ __asm__("movl %0, %%cr0\n\t" : : "a" (cr0_));
__asm__("clts\n\t");
__asm__("fninit\n\t");
__asm__("fstsw %0\n\t" : "=a" (status));
if (status != 0)
{
- __asm__("movl %%cr0, %0\n\t" : "=a" (cr0));
+ __asm__("movl %%cr0, %0\n\t" : "=a" (cr0_));
/* Set the EM flag in CR0 so any FPU instructions cause a trap. */
- cr0 = cr0 | 0x4;
+ cr0_ = cr0_ | 0x4;
__asm__("movl %0, %%cr0\n\t" :
- : "a" (cr0));
+ : "a" (cr0_));
return;
}
/* fsetpm for i287, ignored by i387 */
__asm__(".byte 0xDB, 0xE4\n\t");
+#elif defined(_MSC_VER)
+ __asm mov eax, cr0;
+ __asm mov cr0_, eax;
+ cr0_ |= 0x22; /* Set NE and MP. */
+ cr0_ &= ~0x4; /* Clear EM */
+ __asm
+ {
+ mov eax, cr0_;
+ mov cr0, eax;
+ clts;
+ fninit;
+ fstsw status
+ }
+ if (status != 0)
+ {
+ __asm mov eax, cr0_;
+ __asm or eax, 4; /* Set the EM flag in CR0 so any FPU instructions cause a trap. */
+ __asm mov cr0, eax;
+ return;
+ }
+ /* fsetpm for i287, ignored by i387 */
+ __asm _emit 0xDB __asm _emit 0xe4
+// __asm fsetpm;
+// __asm__(".byte 0xDB, 0xE4\n\t");
+#else
+#error Unknown compiler for inline assembler
+#endif
+
HardwareMathSupport = 1;
}
}
*((PVOID *) Save) = FpState;
+#if defined(__GNUC__)
__asm__("fsave %0\n\t" : "=m" (*FpState));
+#elif defined(_MSC_VER)
+ __asm mov eax, FpState;
+ __asm fsave [eax];
+#else
+#error Unknown compiler for inline assembler
+#endif
return STATUS_SUCCESS;
}
{
char *FpState = *((PVOID *) Save);
+#if defined(__GNUC__)
__asm__("frstor %0\n\t" : "=m" (*FpState));
+#elif defined(_MSC_VER)
+ __asm mov eax, FpState;
+ __asm frstor [eax];
+#else
+#error Unknown compiler for inline assembler
+#endif
+
ExFreePool(FpState);
return STATUS_SUCCESS;
*/
Base = (ULONG)Pcr;
Entry = PCR_SELECTOR / 2;
- Gdt[Entry + 1] = ((ULONG)Base) & 0xffff;
+ Gdt[Entry + 1] = (USHORT)(((ULONG)Base) & 0xffff);
Gdt[Entry + 2] = Gdt[Entry + 2] & ~(0xff);
- Gdt[Entry + 2] = Gdt[Entry + 2] | ((((ULONG)Base) & 0xff0000) >> 16);
+ Gdt[Entry + 2] = (USHORT)(Gdt[Entry + 2] | ((((ULONG)Base) & 0xff0000) >> 16));
Gdt[Entry + 3] = Gdt[Entry + 3] & ~(0xff00);
- Gdt[Entry + 3] = Gdt[Entry + 3] | ((((ULONG)Base) & 0xff000000) >> 16);
+ Gdt[Entry + 3] = (USHORT)(Gdt[Entry + 3] | ((((ULONG)Base) & 0xff000000) >> 16));
/*
* Load the GDT
*/
Descriptor.Length = 8 * 11;
Descriptor.Base = (ULONG)Gdt;
+#if defined(__GNUC__)
__asm__ ("lgdt %0\n\t" : /* no output */ : "m" (Descriptor));
/*
".l4:\n\t"
: /* no output */
: "a" (KERNEL_CS));
+#elif defined(_MSC_VER)
+ __asm
+ {
+ lgdt Descriptor;
+ mov ax, KERNEL_DS;
+ mov bx, PCR_SELECTOR;
+ mov ds, ax;
+ mov es, ax;
+ mov fs, bx;
+ mov gs, ax;
+ push KERNEL_CS;
+ push offset l4 ; // what the heck...
+ ret
+ l4:
+ }
+#else
+#error Unknown compiler for inline assembler
+#endif
}
VOID
Entry = (Entry & (~0x3)) / 2;
- Gdt[Entry + 1] = ((ULONG)Base) & 0xffff;
+ Gdt[Entry + 1] = (USHORT)(((ULONG)Base) & 0xffff);
Gdt[Entry + 2] = Gdt[Entry + 2] & ~(0xff);
- Gdt[Entry + 2] = Gdt[Entry + 2] |
- ((((ULONG)Base) & 0xff0000) >> 16);
+ Gdt[Entry + 2] = (USHORT)(Gdt[Entry + 2] |
+ ((((ULONG)Base) & 0xff0000) >> 16));
Gdt[Entry + 3] = Gdt[Entry + 3] & ~(0xff00);
- Gdt[Entry + 3] = Gdt[Entry + 3] |
- ((((ULONG)Base) & 0xff000000) >> 16);
+ Gdt[Entry + 3] = (USHORT)(Gdt[Entry + 3] |
+ ((((ULONG)Base) & 0xff000000) >> 16));
DPRINT("%x %x %x %x\n",
Gdt[Entry + 0],
IDT_DESCRIPTOR KiIdt[256];
+#if defined(__GNUC__)
struct
{
USHORT Length;
ULONG Base;
} __attribute__((packed)) KiIdtDescriptor = {256 * 8, (ULONG)KiIdt};
+#else
+#include <pshpack1.h>
+struct dummyname_for_this_one
+{
+ USHORT Length;
+ ULONG Base;
+};
+#include <poppack.h>
+struct dummyname_for_this_one KiIdtDescriptor = {256 * 8, (ULONG)KiIdt};
+#endif
/* FUNCTIONS *****************************************************************/
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: irq.c,v 1.36 2003/10/12 17:05:45 hbirr Exp $
+/* $Id: irq.c,v 1.37 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/i386/irq.c
KeIRQTrapFrameToTrapFrame(PKIRQ_TRAPFRAME IrqTrapFrame,
PKTRAP_FRAME TrapFrame)
{
- TrapFrame->Fs = IrqTrapFrame->Fs;
- TrapFrame->Es = IrqTrapFrame->Es;
- TrapFrame->Ds = IrqTrapFrame->Ds;
+ TrapFrame->Fs = (USHORT)IrqTrapFrame->Fs;
+ TrapFrame->Es = (USHORT)IrqTrapFrame->Es;
+ TrapFrame->Ds = (USHORT)IrqTrapFrame->Ds;
TrapFrame->Eax = IrqTrapFrame->Eax;
TrapFrame->Ecx = IrqTrapFrame->Ecx;
TrapFrame->Edx = IrqTrapFrame->Edx;
* default HAL this will send an EOI to the PIC and alter the IRQL.
*/
if (!HalBeginSystemInterrupt (irq + IRQ_BASE,
- PROFILE_LEVEL - irq,
+ (KIRQL)(PROFILE_LEVEL - irq),
&old_level))
{
return;
PAGE_READWRITE,
PcrPages[Offset]);
memset(KPCR, 0, PAGE_SIZE);
- KPCR->ProcessorNumber = Offset;
+ KPCR->ProcessorNumber = (UCHAR)Offset;
KPCR->Self = KPCR;
KPCR->Irql = HIGH_LEVEL;
memcpy((PVOID) NewLdtBase, (PVOID) LdtBase, LdtLimit+1);
}
- LdtDescriptor[0] = (--NewLdtSize) & 0xffff;
- LdtDescriptor[1] = NewLdtBase & 0xffff;
- LdtDescriptor[2] = ((NewLdtBase & 0xff0000) >> 16) | 0x8200;
- LdtDescriptor[3] = ((NewLdtSize & 0xf0000) >> 16) |
- ((NewLdtBase & 0xff000000) >> 16);
+ LdtDescriptor[0] = (USHORT)((--NewLdtSize) & 0xffff);
+ LdtDescriptor[1] = (USHORT)(NewLdtBase & 0xffff);
+ LdtDescriptor[2] = (USHORT)(((NewLdtBase & 0xff0000) >> 16) | 0x8200);
+ LdtDescriptor[3] = (USHORT)(((NewLdtSize & 0xf0000) >> 16) |
+ ((NewLdtBase & 0xff000000) >> 16));
KeSetGdtSelector(LDT_SELECTOR,
((PULONG) LdtDescriptor)[0],
((PULONG) LdtDescriptor)[1]);
+#if defined(__GNUC__)
__asm__("lldtw %%ax"
: /* no output */
: "a" (LDT_SELECTOR));
+#elif defined(_MSC_VER)
+ __asm mov ax, LDT_SELECTOR
+ __asm lldt ax
+#else
+#error Unknown compiler for inline assembler
+#endif
if(LdtBase)
{
if(Selector1)
{
- memcpy((PVOID) LdtBase + Selector1,
+ memcpy((char*)LdtBase + Selector1,
&LdtEntry1,
sizeof(LDT_ENTRY));
}
if(Selector2)
{
- memcpy((PVOID) LdtBase + Selector2,
+ memcpy((char*)LdtBase + Selector2,
&LdtEntry2,
sizeof(LDT_ENTRY));
}
InitSize = 5 * sizeof(DWORD) + sizeof(DWORD) + 6 * sizeof(DWORD) +
sizeof(FLOATING_SAVE_AREA) + sizeof(KTRAP_FRAME);
- KernelStack = (PULONG)(Thread->KernelStack - InitSize);
+ KernelStack = (PULONG)((char*)Thread->KernelStack - InitSize);
/* Set up the initial frame for the return from the dispatcher. */
KernelStack[0] = 0; /* EDI */
/* Set up a trap frame from the context. */
TrapFrame = (PKTRAP_FRAME)
- ((PVOID)KernelStack + 12 * sizeof(DWORD) + sizeof(FLOATING_SAVE_AREA));
+ ((char*)KernelStack + 12 * sizeof(DWORD) + sizeof(FLOATING_SAVE_AREA));
TrapFrame->DebugEbp = (PVOID)Context->Ebp;
TrapFrame->DebugEip = (PVOID)Context->Eip;
TrapFrame->DebugArgMark = 0;
TrapFrame->DebugPointer = 0;
TrapFrame->TempCs = 0;
TrapFrame->TempEip = 0;
- TrapFrame->Gs = Context->SegGs;
- TrapFrame->Es = Context->SegEs;
- TrapFrame->Ds = Context->SegDs;
+ TrapFrame->Gs = (USHORT)Context->SegGs;
+ TrapFrame->Es = (USHORT)Context->SegEs;
+ TrapFrame->Ds = (USHORT)Context->SegDs;
TrapFrame->Edx = Context->Edx;
TrapFrame->Ecx = Context->Ecx;
TrapFrame->Eax = Context->Eax;
TrapFrame->Eflags = Context->EFlags | FLAG_IF;
TrapFrame->Eflags &= ~(FLAG_VM | FLAG_NT | FLAG_IOPL);
TrapFrame->Esp = Context->Esp;
- TrapFrame->Ss = Context->SegSs;
+ TrapFrame->Ss = (USHORT)Context->SegSs;
/* FIXME: Should check for a v86 mode context here. */
/* Save back the new value of the kernel stack. */
* Setup a stack frame for exit from the task switching routine
*/
- KernelStack = (PULONG)(Thread->KernelStack - (8*4));
+ KernelStack = (PULONG)((char*)Thread->KernelStack - (8*4));
KernelStack[0] = 0; /* EDI */
KernelStack[1] = 0; /* ESI */
KernelStack[2] = 0; /* EBX */
VOID
Ki386ApplicationProcessorInitializeTSS(VOID)
{
- ULONG cr3;
+ ULONG cr3_;
KTSS* Tss;
KTSSNOIOPM* TrapTss;
PVOID TrapStack;
Id = KeGetCurrentProcessorNumber();
Gdt = KeGetCurrentKPCR()->GDT;
- __asm__("movl %%cr3,%0\n\t" : "=d" (cr3));
+#if defined(__GNUC__)
+ __asm__("movl %%cr3,%0\n\t" : "=d" (cr3_));
+#elif defined(_MSC_VER)
+ __asm mov eax, cr3;
+ __asm mov cr3_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
Tss = ExAllocatePool(NonPagedPool, sizeof(KTSS));
TrapTss = ExAllocatePool(NonPagedPool, sizeof(KTSSNOIOPM));
base = (ULONG)Tss;
length = sizeof(KTSS) - 1;
- Gdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
- Gdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
- Gdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
- Gdt[(TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
- ((base & 0xFF000000) >> 16);
+ Gdt[(TSS_SELECTOR / 2) + 0] = (USHORT)(length & 0xFFFF);
+ Gdt[(TSS_SELECTOR / 2) + 1] = (USHORT)(base & 0xFFFF);
+ Gdt[(TSS_SELECTOR / 2) + 2] = (USHORT)(((base & 0xFF0000) >> 16) | 0x8900);
+ Gdt[(TSS_SELECTOR / 2) + 3] = (USHORT)(((length & 0xF0000) >> 16) |
+ ((base & 0xFF000000) >> 16));
/* Initialize the TSS used for handling double faults. */
TrapTss->Eflags = 0;
TrapTss->IoMapBase = 0xFFFF; /* No i/o bitmap */
TrapTss->IoBitmap[0] = 0xFF;
TrapTss->Ldt = 0;
- TrapTss->Cr3 = cr3;
+ TrapTss->Cr3 = cr3_;
/*
* Initialize a descriptor for the trap TSS.
base = (ULONG)TrapTss;
length = sizeof(KTSSNOIOPM) - 1;
- Gdt[(TRAP_TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
- Gdt[(TRAP_TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
- Gdt[(TRAP_TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
- Gdt[(TRAP_TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
- ((base & 0xFF000000) >> 16);
+ Gdt[(TRAP_TSS_SELECTOR / 2) + 0] = (USHORT)(length & 0xFFFF);
+ Gdt[(TRAP_TSS_SELECTOR / 2) + 1] = (USHORT)(base & 0xFFFF);
+ Gdt[(TRAP_TSS_SELECTOR / 2) + 2] = (USHORT)(((base & 0xFF0000) >> 16) | 0x8900);
+ Gdt[(TRAP_TSS_SELECTOR / 2) + 3] = (USHORT)(((length & 0xF0000) >> 16) |
+ ((base & 0xFF000000) >> 16));
/*
* Load the task register
*/
+#if defined(__GNUC__)
__asm__("ltr %%ax"
: /* no output */
: "a" (TSS_SELECTOR));
+#elif defined(_MSC_VER)
+ __asm mov ax, TSS_SELECTOR
+ __asm ltr ax
+#else
+#error Unknown compiler for inline assembler
+#endif
}
VOID INIT_FUNCTION
Ki386BootInitializeTSS(VOID)
{
- ULONG cr3;
+ ULONG cr3_;
extern unsigned int init_stack, init_stack_top;
extern unsigned int trap_stack, trap_stack_top;
unsigned int base, length;
- __asm__("movl %%cr3,%0\n\t" : "=d" (cr3));
+#if defined(__GNUC__)
+ __asm__("movl %%cr3,%0\n\t" : "=d" (cr3_));
+#elif defined(_MSC_VER)
+ __asm mov eax, cr3;
+ __asm mov cr3_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
Ki386TssArray[0] = &KiBootTss;
Ki386TrapTssArray[0] = &KiBootTrapTss;
KiBootTrapTss.IoMapBase = 0xFFFF; /* No i/o bitmap */
KiBootTrapTss.IoBitmap[0] = 0xFF;
KiBootTrapTss.Ldt = 0x0;
- KiBootTrapTss.Cr3 = cr3;
+ KiBootTrapTss.Cr3 = cr3_;
/*
* Initialize a descriptor for the trap TSS.
/*
* Load the task register
*/
+#if defined(__GNUC__)
__asm__("ltr %%ax"
: /* no output */
: "a" (TSS_SELECTOR));
+#elif defined(_MSC_VER)
+ __asm mov ax, TSS_SELECTOR
+ __asm ltr ax
+#else
+#error Unknown compiler for inline assembler
+#endif
}
CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
if (address >= (PVOID)current->BaseAddress &&
- address < (PVOID)(current->BaseAddress + current->SizeOfImage))
+ address < (PVOID)((char*)current->BaseAddress + current->SizeOfImage))
{
RelativeAddress =
(ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
{
Tf->Esp = Tf->Esp - 2;
sp = sp - 1;
- sp[0] = Tf->Eflags & 0xFFFF;
+ sp[0] = (USHORT)(Tf->Eflags & 0xFFFF);
if (VTf->regs->Vif == 1)
{
- sp[0] = sp[0] | INTERRUPT_FLAG;
+ sp[0] = (USHORT)(sp[0] | INTERRUPT_FLAG);
}
else
{
- sp[0] = sp[0] & (~INTERRUPT_FLAG);
+ sp[0] = (USHORT)(sp[0] & (~INTERRUPT_FLAG));
}
}
else
{
DPRINT("outb %d, %x\n", (ULONG)ip[i + 1], Tf->Eax & 0xFF);
WRITE_PORT_UCHAR((PUCHAR)(ULONG)ip[i + 1],
- Tf->Eax & 0xFF);
+ (UCHAR)(Tf->Eax & 0xFF));
Tf->Eip = Tf->Eip + 2;
return(0);
}
if (!BigDataPrefix)
{
DPRINT("outw %d, %x\n", (ULONG)ip[i + 1], Tf->Eax & 0xFFFF);
- WRITE_PORT_USHORT((PUSHORT)(ULONG)ip[1], Tf->Eax & 0xFFFF);
+ WRITE_PORT_USHORT((PUSHORT)(ULONG)ip[1], (USHORT)(Tf->Eax & 0xFFFF));
}
else
{
if (VTf->regs->Flags & KV86M_ALLOW_IO_PORT_ACCESS)
{
DPRINT("outb %d, %x\n", Tf->Edx & 0xFFFF, Tf->Eax & 0xFF);
- WRITE_PORT_UCHAR((PUCHAR)(Tf->Edx & 0xFFFF), Tf->Eax & 0xFF);
+ WRITE_PORT_UCHAR((PUCHAR)(Tf->Edx & 0xFFFF), (UCHAR)(Tf->Eax & 0xFF));
Tf->Eip = Tf->Eip + 1;
return(0);
}
{
DPRINT("outw %d, %x\n", Tf->Edx & 0xFFFF, Tf->Eax & 0xFFFF);
WRITE_PORT_USHORT((PUSHORT)(Tf->Edx & 0xFFFF),
- Tf->Eax & 0xFFFF);
+ (USHORT)(Tf->Eax & 0xFFFF));
}
else
{
Tf->Esp = Tf->Esp - 6;
sp = sp - 3;
- sp[0] = (Tf->Eip & 0xFFFF) + 2;
- sp[1] = Tf->Cs & 0xFFFF;
- sp[2] = Tf->Eflags & 0xFFFF;
+ sp[0] = (USHORT)((Tf->Eip & 0xFFFF) + 2);
+ sp[1] = (USHORT)(Tf->Cs & 0xFFFF);
+ sp[2] = (USHORT)(Tf->Eflags & 0xFFFF);
if (VTf->regs->Vif == 1)
{
- sp[2] = sp[2] | INTERRUPT_FLAG;
+ sp[2] = (USHORT)(sp[2] | INTERRUPT_FLAG);
}
DPRINT("sp[0] %x sp[1] %x sp[2] %x\n", sp[0], sp[1], sp[2]);
Tf->Eip = entry & 0xFFFF;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: kthread.c,v 1.44 2003/11/30 19:00:02 gdalsnes Exp $
+/* $Id: kthread.c,v 1.45 2003/12/30 18:52:04 fireball Exp $
*
* FILE: ntoskrnl/ke/kthread.c
* PURPOSE: Microkernel thread support
KEBUGCHECK(0);
}
Status = MmCreateVirtualMapping(NULL,
- KernelStack + (i * PAGE_SIZE),
+ (char*)KernelStack + (i * PAGE_SIZE),
PAGE_EXECUTE_READWRITE,
Page,
TRUE);
}
- Thread->InitialStack = KernelStack + MM_STACK_SIZE;
- Thread->StackBase = KernelStack + MM_STACK_SIZE;
- Thread->StackLimit = (ULONG)KernelStack;
- Thread->KernelStack = KernelStack + MM_STACK_SIZE;
+ Thread->InitialStack = (char*)KernelStack + MM_STACK_SIZE;
+ Thread->StackBase = (char*)KernelStack + MM_STACK_SIZE;
+ Thread->StackLimit = (ULONG)KernelStack;
+ Thread->KernelStack = (char*)KernelStack + MM_STACK_SIZE;
}
else
{
Thread->Queue = NULL;
KeInitializeSpinLock(&Thread->ApcQueueLock);
memset(&Thread->Timer, 0, sizeof(KTIMER));
+ KeInitializeTimer(&Thread->Timer);
Thread->QueueListEntry.Flink = NULL;
Thread->QueueListEntry.Blink = NULL;
Thread->Affinity = Process->Affinity;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: main.c,v 1.179 2003/12/14 18:16:18 hbirr Exp $
+/* $Id: main.c,v 1.180 2003/12/30 18:52:04 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c
#ifdef HALDBG
#include <internal/ntosdbg.h>
#else
+#if defined(_MSC_VER) && (_MSC_VER <= 1200)
+#define ps
+#else
#define ps(args...)
+#endif /* HALDBG */
+
#endif
#define NDEBUG
/* GLOBALS *******************************************************************/
+#ifdef __GNUC__
ULONG EXPORTED NtBuildNumber = KERNEL_VERSION_BUILD;
ULONG EXPORTED NtGlobalFlag = 0;
CHAR EXPORTED KeNumberProcessors;
LOADER_PARAMETER_BLOCK EXPORTED KeLoaderBlock;
ULONG EXPORTED KeDcacheFlushCount = 0;
ULONG EXPORTED KeIcacheFlushCount = 0;
+#else
+/* Microsoft-style declarations */
+EXPORTED ULONG NtBuildNumber = KERNEL_VERSION_BUILD;
+EXPORTED ULONG NtGlobalFlag = 0;
+EXPORTED CHAR KeNumberProcessors;
+EXPORTED LOADER_PARAMETER_BLOCK KeLoaderBlock;
+EXPORTED ULONG KeDcacheFlushCount = 0;
+EXPORTED ULONG KeIcacheFlushCount = 0;
+#endif /* __GNUC__ */
+
static LOADER_MODULE KeLoaderModules[64];
static UCHAR KeLoaderModuleStrings[64][256];
static UCHAR KeLoaderCommandLine[256];
/* Allocate a stack for use when booting the processor */
/* FIXME: The nonpaged memory for the stack is not released after use */
ProcessorStack =
- ExAllocatePool(NonPagedPool, MM_STACK_SIZE) + MM_STACK_SIZE;
+ (char*)ExAllocatePool(NonPagedPool, MM_STACK_SIZE) + MM_STACK_SIZE;
Ki386InitialStackArray[((int)KeNumberProcessors)] =
- (PVOID)(ProcessorStack - MM_STACK_SIZE);
+ (PVOID)((char*)ProcessorStack - MM_STACK_SIZE);
HalInitializeProcessor(KeNumberProcessors, ProcessorStack);
KeNumberProcessors++;
}
Handles[1] = ProcessHandle;
/* Wait for the system to be initialized */
+#ifdef __GNUC__
Timeout.QuadPart = -1200000000LL; /* 120 second timeout */
+#else
+ Timeout.QuadPart = -1200000000; /* 120 second timeout */
+#endif
Status = NtWaitForMultipleObjects(((LONG) sizeof(Handles) / sizeof(HANDLE)),
Handles,
WaitAny,
/*
* Crash the system if the initial process terminates within 5 seconds.
*/
+#ifdef __GNUC__
Timeout.QuadPart = -50000000LL;
+#else
+ Timeout.QuadPart = -50000000;
+#endif
Status = NtWaitForSingleObject(ProcessHandle,
FALSE,
&Timeout);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: process.c,v 1.17 2003/11/27 01:09:10 gdalsnes Exp $
+/* $Id: process.c,v 1.18 2003/12/30 18:52:04 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/process.c
CurrentThread->OldProcess = PsGetCurrentProcess();
CurrentThread->ThreadsProcess = Process;
PageDir = Process->Pcb.DirectoryTableBase.u.LowPart;
- DPRINT("Switching process context to %x\n",PageDir)
+ DPRINT("Switching process context to %x\n",PageDir);
+#if defined(__GNUC__)
__asm__("movl %0,%%cr3\n\t"
: /* no outputs */
: "r" (PageDir));
-
+#elif defined(_MSC_VER)
+ __asm mov eax, PageDir;
+ __asm mov cr3, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
KeLowerIrql(oldlvl);
}
CurrentThread->ThreadsProcess = CurrentThread->OldProcess;
CurrentThread->OldProcess = NULL;
PageDir = CurrentThread->ThreadsProcess->Pcb.DirectoryTableBase.u.LowPart;
+#if defined(__GNUC__)
__asm__("movl %0,%%cr3\n\t"
: /* no inputs */
: "r" (PageDir));
-
+#elif defined(_MSC_VER)
+ __asm mov eax, PageDir;
+ __asm mov cr3, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+
KeLowerIrql(oldlvl);
}
-/* $Id: timer.c,v 1.63 2003/11/02 01:15:15 ekohl Exp $
+/* $Id: timer.c,v 1.64 2003/12/30 18:52:04 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <internal/ke.h>
#include <internal/id.h>
#include <internal/ps.h>
+#include <internal/safe.h>
#define NDEBUG
#include <internal/debug.h>
/*
* Current time
*/
-static LARGE_INTEGER boot_time = (LARGE_INTEGER)0LL;
-static LARGE_INTEGER system_time = (LARGE_INTEGER)0LL;
+static LONGLONG boot_time = 0;
+static LONGLONG system_time = 0;
/*
* Number of timer interrupts since initialisation
{
LARGE_INTEGER PerfCounter;
LARGE_INTEGER PerfFrequency;
+ NTSTATUS Status;
PerfCounter = KeQueryPerformanceCounter(&PerfFrequency);
if (Counter != NULL)
- Counter->QuadPart = PerfCounter.QuadPart;
+ {
+ Status = MmCopyToCaller(&Counter->QuadPart, &PerfCounter.QuadPart, sizeof(PerfCounter.QuadPart));
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ }
if (Frequency != NULL)
- Frequency->QuadPart = PerfFrequency.QuadPart;
+ {
+ Status = MmCopyToCaller(&Frequency->QuadPart, &PerfFrequency.QuadPart, sizeof(PerfFrequency.QuadPart));
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ }
return(STATUS_SUCCESS);
}
{
NTSTATUS Status;
LARGE_INTEGER Timeout;
-
+
+ Status = MmCopyFromCaller(&Timeout, Interval, sizeof(Timeout));
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
Timeout = *((PLARGE_INTEGER)Interval);
DPRINT("NtDelayExecution(Alertable %d, Internal %x) IntervalP %x\n",
Alertable, Internal, Timeout);
DPRINT("Execution delay is %d/%d\n",
Timeout.u.HighPart, Timeout.u.LowPart);
- Status = KeDelayExecutionThread(UserMode, Alertable, &Timeout);
+ Status = KeDelayExecutionThread(UserMode, (BOOLEAN)Alertable, &Timeout);
return(Status);
}
{
PKTHREAD Thread = KeGetCurrentThread();
- KeInitializeTimer(&Thread->Timer);
KeSetTimer(&Thread->Timer, *Interval, NULL);
return (KeWaitForSingleObject(&Thread->Timer,
- Executive,
- UserMode,
+ (WaitMode == KernelMode) ? Executive : UserRequest, /* TMN: Was unconditionally Executive */
+ WaitMode, /* TMN: Was UserMode */
Alertable,
NULL));
}
KeRaiseIrql(PROFILE_LEVEL, &oldIrql);
KeAcquireSpinLockAtDpcLevel(&TimerValueLock);
- *CurrentTime = system_time;
- KeReleaseSpinLock(&TimerValueLock, oldIrql);
+ CurrentTime->QuadPart = system_time;
+ KeReleaseSpinLockFromDpcLevel(&TimerValueLock);
+ KeLowerIrql(oldIrql);
}
{
LARGE_INTEGER TickCount;
if (UpTime == NULL)
+ {
return(STATUS_INVALID_PARAMETER);
+ }
+
KeQueryTickCount(&TickCount);
- *UpTime = TickCount.u.LowPart;
- return (STATUS_SUCCESS);
+ return(MmCopyToCaller(UpTime, &TickCount.u.LowPart, sizeof(*UpTime)));
}
{
KIRQL oldlvl;
LARGE_INTEGER SystemTime;
-
- DPRINT("KeSetTimerEx(Timer %x), DueTime: \n",Timer);
+ BOOLEAN AlreadyInList;
- KeRaiseIrql(PROFILE_LEVEL, &oldlvl);
- KeAcquireSpinLockAtDpcLevel(&TimerValueLock);
+ DPRINT("KeSetTimerEx(Timer %x), DueTime: \n",Timer);
- SystemTime = system_time;
+ assert(KeGetCurrentIrql() <= DISPATCH_LEVEL);
- KeReleaseSpinLock(&TimerValueLock, DISPATCH_LEVEL);
+ KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
+ KeQuerySystemTime(&SystemTime);
KeAcquireSpinLockAtDpcLevel(&TimerListLock);
Timer->Dpc = Dpc;
if (DueTime.QuadPart < 0)
{
-
Timer->DueTime.QuadPart = SystemTime.QuadPart - DueTime.QuadPart;
}
else
}
Timer->Period = Period;
Timer->Header.SignalState = FALSE;
- if (Timer->TimerListEntry.Flink != NULL)
+ AlreadyInList = (Timer->TimerListEntry.Flink == NULL) ? FALSE : TRUE;
+ assert((Timer->TimerListEntry.Flink == NULL && Timer->TimerListEntry.Blink == NULL) ||
+ (Timer->TimerListEntry.Flink != NULL && Timer->TimerListEntry.Blink != NULL));
+ if (!AlreadyInList)
{
- KeReleaseSpinLock(&TimerListLock, oldlvl);
- return(TRUE);
+ assert(&TimerListHead != &Timer->TimerListEntry);
+ InsertTailList(&TimerListHead, &Timer->TimerListEntry);
+ assert(TimerListHead.Flink != &TimerListHead);
+ assert(Timer->TimerListEntry.Flink != &Timer->TimerListEntry);
}
- InsertTailList(&TimerListHead,&Timer->TimerListEntry);
- KeReleaseSpinLock(&TimerListLock, oldlvl);
-
- return(FALSE);
+ /*
+ * TODO: Perhaps verify that the timer really is in
+ * the TimerListHead list if AlreadyInList is TRUE?
+ */
+ KeReleaseSpinLockFromDpcLevel(&TimerListLock);
+ KeLowerIrql(oldlvl);
+
+ return AlreadyInList;
}
/*
KIRQL oldlvl;
DPRINT("KeCancelTimer(Timer %x)\n",Timer);
-
+
KeAcquireSpinLock(&TimerListLock, &oldlvl);
-
+
if (Timer->TimerListEntry.Flink == NULL)
{
KeReleaseSpinLock(&TimerListLock, oldlvl);
return(FALSE);
}
+ assert(&Timer->TimerListEntry != &TimerListHead);
+ assert(Timer->TimerListEntry.Flink != &Timer->TimerListEntry);
RemoveEntryList(&Timer->TimerListEntry);
Timer->TimerListEntry.Flink = Timer->TimerListEntry.Blink = NULL;
KeReleaseSpinLock(&TimerListLock, oldlvl);
BOOLEAN STDCALL
KeReadStateTimer (PKTIMER Timer)
{
- return(Timer->Header.SignalState);
+ return (BOOLEAN)(Timer->Header.SignalState);
}
/*
*/
{
ULONG IType;
-
+
if (Type == NotificationTimer)
{
IType = InternalNotificationTimer;
assert(FALSE);
return;
}
-
+
KeInitializeDispatcherHeader(&Timer->Header,
IType,
sizeof(KTIMER) / sizeof(ULONG),
TickCount->QuadPart = KeTickCount;
}
+/*
+ * We enter this function at IRQL DISPATCH_LEVEL, and with the
+ * TimerListLock held.
+ */
STATIC VOID
-HandleExpiredTimer(PKTIMER current)
+HandleExpiredTimer(PKTIMER Timer)
{
- KIRQL OldIrql;
-
- DPRINT("HandleExpiredTime(current %x)\n",current);
- if (current->Dpc != NULL)
+ DPRINT("HandleExpiredTime(Timer %x) at IRQL: %d\n", Timer, KeGetCurrentIrql());
+ if (Timer->Dpc != NULL)
{
- DPRINT("current->Dpc %x current->Dpc->DeferredRoutine %x\n",
- current->Dpc, current->Dpc->DeferredRoutine);
- KeInsertQueueDpc(current->Dpc,
+ DPRINT("Timer->Dpc %x Timer->Dpc->DeferredRoutine %x\n",
+ Timer->Dpc, Timer->Dpc->DeferredRoutine);
+ KeInsertQueueDpc(Timer->Dpc,
NULL,
NULL);
DPRINT("Finished dpc routine\n");
}
- OldIrql = KeAcquireDispatcherDatabaseLock ();
- current->Header.SignalState = TRUE;
- KeDispatcherObjectWake(¤t->Header);
- KeReleaseDispatcherDatabaseLock (OldIrql);
- if (current->Period != 0)
+
+ assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
+
+ KeAcquireDispatcherDatabaseLockAtDpcLevel();
+ Timer->Header.SignalState = TRUE;
+ KeDispatcherObjectWake(&Timer->Header);
+ KeReleaseDispatcherDatabaseLockFromDpcLevel();
+ if (Timer->Period != 0)
{
- current->DueTime.QuadPart +=
- current->Period * SYSTEM_TIME_UNITS_PER_MSEC;
+ Timer->DueTime.QuadPart +=
+ Timer->Period * SYSTEM_TIME_UNITS_PER_MSEC;
}
else
{
- RemoveEntryList(¤t->TimerListEntry);
- current->TimerListEntry.Flink = current->TimerListEntry.Blink = NULL;
+ assert(&Timer->TimerListEntry != &TimerListHead);
+ RemoveEntryList(&Timer->TimerListEntry);
+ Timer->TimerListEntry.Flink = Timer->TimerListEntry.Blink = NULL;
}
}
PLIST_ENTRY current_entry = NULL;
PKTIMER current = NULL;
ULONG Eip = (ULONG)Arg1;
- KIRQL oldIrql;
LARGE_INTEGER SystemTime;
DPRINT("KeExpireTimers()\n");
- KeRaiseIrql(PROFILE_LEVEL, &oldIrql);
- KeAcquireSpinLockAtDpcLevel(&TimerValueLock);
+ assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
- SystemTime = system_time;
-
- KeReleaseSpinLock(&TimerValueLock, oldIrql);
- KeAcquireSpinLockAtDpcLevel(&TimerListLock);
+ KeQuerySystemTime(&SystemTime);
if (KeGetCurrentIrql() > DISPATCH_LEVEL)
{
KEBUGCHECK(0);
}
+ KeAcquireSpinLockAtDpcLevel(&TimerListLock);
current_entry = TimerListHead.Flink;
+ assert(current_entry);
+
while (current_entry != &TimerListHead)
{
current = CONTAINING_RECORD(current_entry, KTIMER, TimerListEntry);
-
+ assert(current);
+ assert(current_entry != &TimerListHead);
+ assert(current_entry->Flink != current_entry);
+
current_entry = current_entry->Flink;
if ((ULONGLONG) SystemTime.QuadPart >= current->DueTime.QuadPart)
{
}
KiAddProfileEvent(ProfileTime, Eip);
-
+
KeReleaseSpinLockFromDpcLevel(&TimerListLock);
}
SharedUserData->TickCountLow++;
KeAcquireSpinLockAtDpcLevel(&TimerValueLock);
- system_time.QuadPart += CLOCK_INCREMENT;
+ system_time += CLOCK_INCREMENT;
KeReleaseSpinLockFromDpcLevel(&TimerValueLock);
-
+
/*
* Queue a DPC that will expire timers
*/
*/
HalQueryRealTimeClock(&TimeFields);
RtlTimeFieldsToTime(&TimeFields, &SystemBootTime);
- boot_time=SystemBootTime;
+ boot_time=SystemBootTime.QuadPart;
system_time=boot_time;
SharedUserData->TickCountLow = 0;
ULONG Size,
ULONG SignalState)
{
- Header->Type = Type;
+ Header->Type = (UCHAR)Type;
Header->Absolute = 0;
Header->Inserted = 0;
- Header->Size = Size;
+ Header->Size = (UCHAR)Size;
Header->SignalState = SignalState;
InitializeListHead(&(Header->WaitListHead));
}
*/
if (Timeout != NULL && Timeout->QuadPart != 0)
{
- KeInitializeTimer(&CurrentThread->Timer);
KeSetTimer(&CurrentThread->Timer, *Timeout, NULL);
}
blk->Object = KiGetWaitableObjectFromObject(Object[i]);
blk->Thread = CurrentThread;
- blk->WaitKey = STATUS_WAIT_0 + i;
- blk->WaitType = WaitType;
+ blk->WaitKey = (USHORT)(STATUS_WAIT_0 + i);
+ blk->WaitType = (USHORT)WaitType;
if (i == (Count - 1))
{
}
}
- PsBlockThread(&Status, Alertable, WaitMode, TRUE, WaitIrql, WaitReason);
+ PsBlockThread(&Status, Alertable, WaitMode, TRUE, WaitIrql, (UCHAR)WaitReason);
//io completion
if (CurrentThread->Queue)
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: init.c,v 1.44 2003/11/17 02:12:51 hyperion Exp $
+/* $Id: init.c,v 1.45 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ldr/init.c
Context.FloatSave.StatusWord = 0xffff0000;
Context.FloatSave.TagWord = 0xffffffff;
Context.FloatSave.DataSelector = 0xffff0000;
- Context.Eip = (ULONG_PTR)(ImageBaseAddress + (ULONG_PTR)Sii.EntryPoint);
+ Context.Eip = (ULONG_PTR)((char*)ImageBaseAddress + (ULONG_PTR)Sii.EntryPoint);
Context.SegCs = USER_CS;
Context.SegDs = USER_DS;
Context.SegEs = USER_DS;
-/* $Id: loader.c,v 1.137 2003/10/15 17:04:39 navaraf Exp $
+/* $Id: loader.c,v 1.138 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#ifdef HALDBG
#include <internal/ntosdbg.h>
#else
+#ifdef __GNUC__
#define ps(args...)
+#else
+#define ps
+#endif /* __GNUC__ */
#endif
#define NDEBUG
Smi->Module[ModuleCount].Base = current->Base;
Smi->Module[ModuleCount].Size = current->Length;
Smi->Module[ModuleCount].Flags = 0; /* Flags ??? (GN) */
- Smi->Module[ModuleCount].Index = ModuleCount;
+ Smi->Module[ModuleCount].Index = (USHORT)ModuleCount;
Smi->Module[ModuleCount].NameLength = 0;
Smi->Module[ModuleCount].LoadCount = 0; /* FIXME */
Length =
max(PESectionHeaders[Idx].Misc.VirtualSize,
PESectionHeaders[Idx].SizeOfRawData);
- BaseAddress = PESectionHeaders[Idx].VirtualAddress + DriverBase;
- NeedsWriteAccess = BaseAddress < PageStart + PAGE_SIZE &&
+ BaseAddress = PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase;
+ NeedsWriteAccess = (char*)BaseAddress < (char*)PageStart + PAGE_SIZE &&
PageStart < (PVOID)((PCHAR) BaseAddress + Length);
}
}
(IMAGE_SECTION_CHAR_CODE | IMAGE_SECTION_CHAR_DATA))
{
DPRINT("PESectionHeaders[Idx].VirtualAddress + DriverBase %x\n",
- PESectionHeaders[Idx].VirtualAddress + DriverBase);
- memcpy(PESectionHeaders[Idx].VirtualAddress + DriverBase,
- (PVOID)(ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData),
+ PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase);
+ memcpy(PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase,
+ (PVOID)((char*)ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData),
PESectionHeaders[Idx].Misc.VirtualSize > PESectionHeaders[Idx].SizeOfRawData
? PESectionHeaders[Idx].SizeOfRawData : PESectionHeaders[Idx].Misc.VirtualSize );
}
else
{
DPRINT("PESectionHeaders[Idx].VirtualAddress + DriverBase %x\n",
- PESectionHeaders[Idx].VirtualAddress + DriverBase);
- memset(PESectionHeaders[Idx].VirtualAddress + DriverBase,
+ PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase);
+ memset(PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase,
'\0', PESectionHeaders[Idx].Misc.VirtualSize);
}
DPRINT("Name %.8s PESectionHeader[Idx].PointerToRawData %x\n",
PESectionHeaders[Idx].Name,
PESectionHeaders[Idx].PointerToRawData);
- RelocDir = PESectionHeaders[Idx].PointerToRawData +
- ModuleLoadBase;
+ RelocDir = (PRELOCATION_DIRECTORY)(PESectionHeaders[Idx].PointerToRawData +
+ (char*)ModuleLoadBase);
CurrentSize = PESectionHeaders[Idx].Misc.VirtualSize;
break;
}
Offset = RelocEntry[Idx].TypeOffset & 0xfff;
Type = (RelocEntry[Idx].TypeOffset >> 12) & 0xf;
- RelocItem = (PDWORD)(DriverBase + RelocDir->VirtualAddress +
+ RelocItem = (PDWORD)((char*)DriverBase + RelocDir->VirtualAddress +
Offset);
/* DPRINT(" reloc at %08lx %x %s old:%08lx new:%08lx\n",
RelocItem,
pName = NULL;
- Hint = (*FunctionNameList) & 0xffff;
+ Hint = (WORD)((*FunctionNameList) & 0xffff);
}
else // hint-name
{
Length =
max(PESectionHeaders[Idx].Misc.VirtualSize,
PESectionHeaders[Idx].SizeOfRawData);
- BaseAddress = PESectionHeaders[Idx].VirtualAddress + DriverBase;
+ BaseAddress = PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase;
PageAddress = (PVOID)PAGE_ROUND_DOWN(BaseAddress);
if (! PageNeedsWriteAccess(PageAddress, DriverBase, PEFileHeader, PESectionHeaders))
{
{
//ps("PESectionHeaders[Idx].VirtualAddress (%X) + DriverBase %x\n",
//PESectionHeaders[Idx].VirtualAddress, PESectionHeaders[Idx].VirtualAddress + DriverBase);
- memcpy(PESectionHeaders[Idx].VirtualAddress + DriverBase,
- (PVOID)(ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData),
+ memcpy(PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase,
+ (PVOID)((char*)ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData),
PESectionHeaders[Idx].Misc.VirtualSize > PESectionHeaders[Idx].SizeOfRawData ?
PESectionHeaders[Idx].SizeOfRawData : PESectionHeaders[Idx].Misc.VirtualSize );
}
else
{
ps("PESectionHeaders[Idx].VirtualAddress (%X) + DriverBase %x\n",
- PESectionHeaders[Idx].VirtualAddress, PESectionHeaders[Idx].VirtualAddress + DriverBase);
- memset(PESectionHeaders[Idx].VirtualAddress + DriverBase,
+ PESectionHeaders[Idx].VirtualAddress, PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase);
+ memset(PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase,
'\0',
PESectionHeaders[Idx].Misc.VirtualSize);
}
DPRINT("Name %.8s PESectionHeader[Idx].PointerToRawData %x\n",
PESectionHeaders[Idx].Name,
PESectionHeaders[Idx].PointerToRawData);
- RelocDir = PESectionHeaders[Idx].PointerToRawData + ModuleLoadBase;
+ RelocDir = (PRELOCATION_DIRECTORY)(PESectionHeaders[Idx].PointerToRawData + (char*)ModuleLoadBase);
CurrentSize = PESectionHeaders[Idx].Misc.VirtualSize;
break;
}
Offset = RelocEntry[Idx].TypeOffset & 0xfff;
Type = (RelocEntry[Idx].TypeOffset >> 12) & 0xf;
- RelocItem = (PULONG)(DriverBase + RelocDir->VirtualAddress + Offset);
+ RelocItem = (PULONG)((char*)DriverBase + RelocDir->VirtualAddress + Offset);
if (Type == 3)
{
(*RelocItem) += RelocDelta;
{
/* Hint */
pName = NULL;
- Hint = (*FunctionNameList) & 0xffff;
+ Hint = (USHORT)((*FunctionNameList) & 0xffff);
}
else
{
return NULL;
}
- FunctionList = (PDWORD)((DWORD)ExportDir->AddressOfFunctions + ModuleObject->Base);
- NameList = (PDWORD)((DWORD)ExportDir->AddressOfNames + ModuleObject->Base);
- OrdinalList = (PWORD)((DWORD)ExportDir->AddressOfNameOrdinals + ModuleObject->Base);
+ FunctionList = (PDWORD)((DWORD)ExportDir->AddressOfFunctions + (char*)ModuleObject->Base);
+ NameList = (PDWORD)((DWORD)ExportDir->AddressOfNames + (char*)ModuleObject->Base);
+ OrdinalList = (PWORD)((DWORD)ExportDir->AddressOfNameOrdinals + (char*)ModuleObject->Base);
ExportAddress = 0;
ps("ExportDir %x\n", ExportDir);
}
- FunctionList = (PDWORD)((DWORD)ExportDir->AddressOfFunctions + ImportModuleBase);
- NameList = (PDWORD)((DWORD)ExportDir->AddressOfNames + ImportModuleBase);
- OrdinalList = (PWORD)((DWORD)ExportDir->AddressOfNameOrdinals + ImportModuleBase);
+ FunctionList = (PDWORD)((DWORD)ExportDir->AddressOfFunctions + (char*)ImportModuleBase);
+ NameList = (PDWORD)((DWORD)ExportDir->AddressOfNames + (char*)ImportModuleBase);
+ OrdinalList = (PWORD)((DWORD)ExportDir->AddressOfNameOrdinals + (char*)ImportModuleBase);
ExportAddress = 0;
-/* $Id: rtl.c,v 1.17 2003/07/11 01:23:15 royce Exp $
+/* $Id: rtl.c,v 1.18 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PIMAGE_NT_HEADERS NTHeaders;
DosHeader = (PIMAGE_DOS_HEADER)BaseAddress;
- NTHeaders = (PIMAGE_NT_HEADERS)(BaseAddress + DosHeader->e_lfanew);
+ NTHeaders = (PIMAGE_NT_HEADERS)((char*)BaseAddress + DosHeader->e_lfanew);
if ((DosHeader->e_magic != IMAGE_DOS_MAGIC)
|| (DosHeader->e_lfanew == 0L)
|| (*(PULONG) NTHeaders != IMAGE_PE_MAGIC))
*Size = NtHeader->OptionalHeader.DataDirectory[Directory].Size;
if (ImageLoaded)
- return (PVOID)(BaseAddress + Va);
+ return (PVOID)((char*)BaseAddress + Va);
/* image mapped as ordinary file, we must find raw pointer */
SectionHeader = (PIMAGE_SECTION_HEADER)(NtHeader + 1);
while (Count--)
{
if (SectionHeader->VirtualAddress == Va)
- return (PVOID)(BaseAddress + SectionHeader->PointerToRawData);
+ return (PVOID)((char*)BaseAddress + SectionHeader->PointerToRawData);
SectionHeader++;
}
*SectionHeader = Section;
}
- return (ULONG)(BaseAddress +
+ return (ULONG)((char*)BaseAddress +
Rva +
Section->PointerToRawData -
Section->VirtualAddress);
return(STATUS_INVALID_PARAMETER);
}
- AddressPtr = (PULONG)RVA(BaseAddress, ExportDir->AddressOfFunctions);
+ AddressPtr = (PULONG)RVA((char*)BaseAddress, ExportDir->AddressOfFunctions);
if (Name && Name->Length)
{
ULONG minn, maxn;
/* by name */
OrdinalPtr =
- (PUSHORT)RVA(BaseAddress, ExportDir->AddressOfNameOrdinals);
- NamePtr = (PULONG)RVA(BaseAddress, ExportDir->AddressOfNames);
+ (PUSHORT)RVA((char*)BaseAddress, ExportDir->AddressOfNameOrdinals);
+ NamePtr = (PULONG)RVA((char*)BaseAddress, ExportDir->AddressOfNames);
minn = 0; maxn = ExportDir->NumberOfNames;
while (minn <= maxn)
LONG res;
mid = (minn + maxn) / 2;
- res = _strnicmp(Name->Buffer, (PCH)RVA(BaseAddress, NamePtr[mid]),
+ res = _strnicmp(Name->Buffer, (PCH)RVA((char*)BaseAddress, NamePtr[mid]),
Name->Length);
if (res == 0)
{
*ProcedureAddress =
- (PVOID)RVA(BaseAddress, AddressPtr[OrdinalPtr[mid]]);
+ (PVOID)RVA((char*)BaseAddress, AddressPtr[OrdinalPtr[mid]]);
return(STATUS_SUCCESS);
}
else if (res > 0)
for (i = 0; i < ExportDir->NumberOfNames; i++, NamePtr++, OrdinalPtr++)
{
if (!_strnicmp(Name->Buffer,
- (char*)(BaseAddress + *NamePtr), Name->Length))
+ (char*)((char*)BaseAddress + *NamePtr), Name->Length))
{
*ProcedureAddress =
(PVOID)((ULONG)BaseAddress +
-/* $Id: complete.c,v 1.9 2003/07/11 01:23:15 royce Exp $
+/* $Id: complete.c,v 1.10 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* NtCompleteConnectPort@4
*
*/
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
NtCompleteConnectPort (HANDLE PortHandle)
{
NTSTATUS Status;
-/* $Id: connect.c,v 1.21 2003/11/20 11:06:35 ekohl Exp $
+/* $Id: connect.c,v 1.22 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
*
* RETURN VALUE
*/
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
NtAcceptConnectPort (PHANDLE ServerPortHandle,
HANDLE NamedPortHandle,
PLPC_MESSAGE LpcMessage,
-/* $Id: create.c,v 1.13 2003/09/25 20:04:59 ekohl Exp $
+/* $Id: create.c,v 1.14 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
*
* RETURN VALUE
*/
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
NtCreatePort (PHANDLE PortHandle,
POBJECT_ATTRIBUTES ObjectAttributes,
ULONG MaxConnectInfoLength,
*
* RETURN VALUE
*/
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
NtCreateWaitablePort (OUT PHANDLE PortHandle,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN ULONG MaxConnectInfoLength,
-/* $Id: listen.c,v 1.7 2003/07/11 01:23:15 royce Exp $
+/* $Id: listen.c,v 1.8 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
*
* NOTE
*/
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
NtListenPort (IN HANDLE PortHandle,
IN PLPC_MESSAGE ConnectMsg)
{
-/* $Id: query.c,v 1.7 2003/07/11 01:23:15 royce Exp $
+/* $Id: query.c,v 1.8 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* P. Dabak reports that this system service seems to return
* no information.
*/
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
NtQueryInformationPort (IN HANDLE PortHandle,
IN CINT PortInformationClass,
OUT PVOID PortInformation,
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: anonmem.c,v 1.22 2003/11/30 17:24:22 hbirr Exp $
+/* $Id: anonmem.c,v 1.23 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/anonmem.c
LARGE_INTEGER PhysicalAddr;
if (MmIsPageSwapEntry(AddressSpace->Process,
- BaseAddress + (i * PAGE_SIZE)))
+ (char*)BaseAddress + (i * PAGE_SIZE)))
{
SWAPENTRY SwapEntry;
MmDeletePageFileMapping(AddressSpace->Process,
- BaseAddress + (i * PAGE_SIZE),
+ (char*)BaseAddress + (i * PAGE_SIZE),
&SwapEntry);
MmFreeSwapPage(SwapEntry);
}
else
{
MmDeleteVirtualMapping(AddressSpace->Process,
- BaseAddress + (i*PAGE_SIZE),
+ (char*)BaseAddress + (i*PAGE_SIZE),
FALSE, NULL, &PhysicalAddr);
if (PhysicalAddr.QuadPart != 0)
{
MmSetSavedSwapEntryPage(PhysicalAddr, 0);
}
MmDeleteRmap(PhysicalAddr, AddressSpace->Process,
- BaseAddress + (i * PAGE_SIZE));
+ (char*)BaseAddress + (i * PAGE_SIZE));
MmReleasePageMemoryConsumer(MC_USER, PhysicalAddr);
}
}
for (i=0; i < PAGE_ROUND_UP(RegionSize)/PAGE_SIZE; i++)
{
if (MmIsPagePresent(AddressSpace->Process,
- BaseAddress + (i*PAGE_SIZE)))
+ (char*)BaseAddress + (i*PAGE_SIZE)))
{
MmSetPageProtect(AddressSpace->Process,
- BaseAddress + (i*PAGE_SIZE),
+ (char*)BaseAddress + (i*PAGE_SIZE),
NewProtect);
}
}
}
PageOp = MmCheckForPageOp(MemoryArea, Process->UniqueProcessId,
- MemoryArea->BaseAddress + (i * PAGE_SIZE),
+ (char*)MemoryArea->BaseAddress + (i * PAGE_SIZE),
NULL, 0);
if (PageOp != NULL)
{
Address, &RegionBase);
Info->AllocationBase = RegionBase;
Info->AllocationProtect = Region->Protect; /* FIXME */
- Info->RegionSize = RegionBase + Region->Length - Info->BaseAddress;
+ Info->RegionSize = (char*)RegionBase + Region->Length - (char*)Info->BaseAddress;
Info->State = Region->Type;
Info->Protect = Region->Protect;
Info->Type = MEM_PRIVATE;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: balance.c,v 1.24 2003/11/24 16:15:00 gvg Exp $
+/* $Id: balance.c,v 1.25 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/balance.c
PLIST_ENTRY Entry;
KIRQL oldIrql;
+#if defined(__GNUC__)
if (Page.QuadPart == 0LL)
+#else
+ if (Page.QuadPart == 0)
+#endif
{
DPRINT1("Tried to release page zero.\n");
KEBUGCHECK(0);
if (Consumer == MC_NPPOOL || MiIsBalancerThread())
{
Page = MmAllocPage(Consumer, 0);
+#if defined(__GNUC__)
if (Page.QuadPart == 0LL)
+#else
+ if (Page.QuadPart == 0)
+#endif
{
KEBUGCHECK(0);
}
}
/* Insert an allocation request. */
+#if defined(__GNUC__)
Request.Page.QuadPart = 0LL;
+#else
+ Request.Page.QuadPart = 0;
+#endif
KeInitializeEvent(&Request.Event, NotificationEvent, FALSE);
InterlockedIncrement((LONG *)&MiPagesRequired);
NULL);
Page = Request.Page;
+#if defined(__GNUC__)
if (Page.QuadPart == 0LL)
+#else
+ if (Page.QuadPart == 0)
+#endif
{
KEBUGCHECK(0);
}
* Actually allocate the page.
*/
Page = MmAllocPage(Consumer, 0);
+#if defined(__GNUC__)
if (Page.QuadPart == 0LL)
+#else
+ if (Page.QuadPart == 0)
+#endif
{
KEBUGCHECK(0);
}
{
KPRIORITY Priority;
NTSTATUS Status;
+#if !defined(__GNUC__)
+ LARGE_INTEGER dummyJunkNeeded;
+ dummyJunkNeeded.QuadPart = -20000000; /* 2 sec */;
+#endif
CHECKPOINT;
KeInitializeEvent(&MiBalancerEvent, SynchronizationEvent, FALSE);
KeInitializeTimerEx(&MiBalancerTimer, SynchronizationTimer);
KeSetTimerEx(&MiBalancerTimer,
+#if defined(__GNUC__)
(LARGE_INTEGER)(LONGLONG)-20000000LL, /* 2 sec */
+#else
+ dummyJunkNeeded,
+#endif
2000, /* 2 sec */
NULL);
-/* $Id: cont.c,v 1.28 2003/07/11 01:23:15 royce Exp $
+/* $Id: cont.c,v 1.29 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PBase = MmGetContinuousPages(NumberOfBytes,
HighestAcceptableAddress,
Alignment);
+#if defined(__GNUC__)
if (PBase.QuadPart == 0LL)
+#else
+ if (PBase.QuadPart == 0)
+#endif
{
MmLockAddressSpace(MmGetKernelAddressSpace());
MmFreeMemoryArea(MmGetKernelAddressSpace(),
}
for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++)
{
+#if !defined(__GNUC__)
+ LARGE_INTEGER dummyJunkNeeded;
+ dummyJunkNeeded.QuadPart = PBase.QuadPart + (i * 4096);
+#endif
MmCreateVirtualMapping(NULL,
- BaseAddress + (i * 4096),
+ (char*)BaseAddress + (i * 4096),
PAGE_EXECUTE_READWRITE | PAGE_SYSTEM,
+#if defined(__GNUC__)
(LARGE_INTEGER)(PBase.QuadPart + (i * 4096)),
+#else
+ dummyJunkNeeded,
+#endif
TRUE);
}
return(BaseAddress);
if (NextListEntry == &UsedPageListHeads[MC_USER])
{
KeReleaseSpinLock(&PageListLock, oldIrql);
- return((LARGE_INTEGER)0LL);
+#if defined(__GNUC__)
+ return((PHYSICAL_ADDRESS)0LL);
+#else
+ {
+ const PHYSICAL_ADDRESS dummyJunkNeeded = { 0 };
+ return dummyJunkNeeded;
+ }
+#endif
}
PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
Next.QuadPart = (ULONG)((ULONG)PageDescriptor - (ULONG)MmPageArray);
if (NextListEntry == &UsedPageListHeads[MC_USER])
{
KeReleaseSpinLock(&PageListLock, oldIrql);
- return((LARGE_INTEGER)0LL);
+#if defined(__GNUC__)
+ return((PHYSICAL_ADDRESS)0LL);
+#else
+ {
+ const PHYSICAL_ADDRESS dummyJunkNeeded = { 0 };
+ return dummyJunkNeeded;
+ }
+#endif
}
PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
Next.QuadPart = (ULONG)((ULONG)PageDescriptor - (ULONG)MmPageArray);
if (start == -1 || length != NrPages)
{
KeReleaseSpinLock(&PageListLock, oldIrql);
- return((LARGE_INTEGER)(LONGLONG)0);
+#if defined(__GNUC__)
+ return((PHYSICAL_ADDRESS)(LONGLONG)0);
+#else
+ {
+ const PHYSICAL_ADDRESS dummyJunkNeeded = { 0 };
+ return dummyJunkNeeded;
+ }
+#endif
}
for (i = start; i < (start + length); i++)
{
&MmPageArray[i].ListEntry);
}
KeReleaseSpinLock(&PageListLock, oldIrql);
- return((LARGE_INTEGER)((LONGLONG)start * PAGE_SIZE));
+#if defined(__GNUC__)
+ return((PHYSICAL_ADDRESS)((LONGLONG)start * PAGE_SIZE));
+#else
+ {
+ const PHYSICAL_ADDRESS dummyJunkNeeded = { start * PAGE_SIZE };
+ return dummyJunkNeeded;
+ }
+#endif
}
VOID INIT_FUNCTION
LastKernelAddress = PAGE_ROUND_UP(LastKernelAddress);
LastKernelAddress = ((ULONG)LastKernelAddress + (Reserved * PAGE_SIZE));
LastPhysKernelAddress = (PVOID)PAGE_ROUND_UP(LastPhysKernelAddress);
- LastPhysKernelAddress = LastPhysKernelAddress + (Reserved * PAGE_SIZE);
+ LastPhysKernelAddress = (char*)LastPhysKernelAddress + (Reserved * PAGE_SIZE);
MmStats.NrTotalPages = 0;
MmStats.NrSystemPages = 0;
for (i = 0; i < Reserved; i++)
{
- PVOID Address = (PVOID)(ULONG)MmPageArray + (i * PAGE_SIZE);
+ PVOID Address = (char*)(ULONG)MmPageArray + (i * PAGE_SIZE);
if (!MmIsPagePresent(NULL, Address))
{
- ULONG PhysicalAddress;
- PhysicalAddress = (ULONG)LastPhysKernelAddress -
+#if !defined(__GNUC__)
+ const PHYSICAL_ADDRESS dummyJunkNeeded = {
+ (ULONG)LastPhysKernelAddress -
+ (Reserved * PAGE_SIZE) + (i * PAGE_SIZE)
+ };
+#endif
+ ULONG PhysicalAddress = (ULONG)LastPhysKernelAddress -
(Reserved * PAGE_SIZE) + (i * PAGE_SIZE);
Status =
MmCreateVirtualMappingUnsafe(NULL,
Address,
PAGE_READWRITE,
+#if defined(__GNUC__)
(PHYSICAL_ADDRESS)(LONGLONG)PhysicalAddress,
+#else
+ dummyJunkNeeded,
+#endif
FALSE);
if (!NT_SUCCESS(Status))
{
KEBUGCHECK(0);
}
}
- memset((PVOID)MmPageArray + (i * PAGE_SIZE), 0, PAGE_SIZE);
+ memset((char*)MmPageArray + (i * PAGE_SIZE), 0, PAGE_SIZE);
}
{
DPRINT1("MmAllocPage(): Out of memory\n");
KeReleaseSpinLock(&PageListLock, oldIrql);
+#if defined(__GNUC__)
return((PHYSICAL_ADDRESS)0LL);
+#else
+ {
+ const PHYSICAL_ADDRESS dummyJunkNeeded = { 0 };
+ return dummyJunkNeeded;
+ }
+#endif
}
ListEntry = RemoveTailList(&FreeUnzeroedPageListHead);
UnzeroedPageCount--;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: page.c,v 1.60 2003/10/12 17:05:48 hbirr Exp $
+/* $Id: page.c,v 1.61 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/i386/page.c
ULONG MmGlobalKernelPageDirectory[1024] = {0, };
+#if defined(__GNUC__)
#define PTE_TO_PAGE(X) ((LARGE_INTEGER)(LONGLONG)(PAGE_MASK(X)))
+#else
+__inline LARGE_INTEGER PTE_TO_PAGE(ULONG npage)
+{
+ LARGE_INTEGER dummy;
+ dummy.QuadPart = (LONGLONG)(PAGE_MASK(npage));
+ return dummy;
+}
+#endif
/* FUNCTIONS ***************************************************************/
MmGetPageDirectory(VOID)
{
unsigned int page_dir=0;
+#if defined(__GNUC__)
__asm__("movl %%cr3,%0\n\t"
: "=r" (page_dir));
+#elif defined(_MSC_VER)
+ __asm mov eax, cr3;
+ __asm mov page_dir, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
return((PULONG)page_dir);
}
}
MmReleasePageMemoryConsumer(MC_NPPOOL, Process->Pcb.DirectoryTableBase);
+#if defined(__GNUC__)
Process->Pcb.DirectoryTableBase.QuadPart = 0LL;
+#else
+ Process->Pcb.DirectoryTableBase.QuadPart = 0;
+#endif
DPRINT("Finished Mmi386ReleaseMmInfo()\n");
return(STATUS_SUCCESS);
if (!(PageEntry & PA_PRESENT))
{
+#if defined(__GNUC__)
return((LARGE_INTEGER)0LL);
+#else
+ {
+ PHYSICAL_ADDRESS dummy = { 0 };
+ return dummy;
+ }
+#endif
}
return(PTE_TO_PAGE(PageEntry));
}
}
if (PhysicalAddr != NULL)
{
+#if defined(__GNUC__)
*PhysicalAddr = (LARGE_INTEGER)0LL;
+#else
+ PhysicalAddr->QuadPart = 0;
+#endif
}
return;
}
BOOLEAN MmIsDirtyPage(PEPROCESS Process, PVOID Address)
{
- return((MmGetPageEntryForProcess(Process, Address)) & PA_DIRTY);
+ return (BOOLEAN)((MmGetPageEntryForProcess(Process, Address)) & PA_DIRTY);
}
BOOLEAN
}
PageEntry = MmGetPageEntry(Address);
- Accessed = (*PageEntry) & PA_ACCESSED;
+ Accessed = (BOOLEAN)((*PageEntry) & PA_ACCESSED);
if (Accessed)
{
(*PageEntry) = (*PageEntry) & (~PA_ACCESSED);
BOOLEAN MmIsPagePresent(PEPROCESS Process, PVOID Address)
{
- return((MmGetPageEntryForProcess1(Process, Address)) & PA_PRESENT);
+ return (BOOLEAN)((MmGetPageEntryForProcess1(Process, Address)) & PA_PRESENT);
}
BOOLEAN MmIsPageSwapEntry(PEPROCESS Process, PVOID Address)
{
KEBUGCHECK(0);
}
- *Pte = PhysicalAddress.QuadPart | Attributes;
+ *Pte = (ULONG)(PhysicalAddress.QuadPart | Attributes);
FLUSH_TLB;
return(STATUS_SUCCESS);
}
{
MmMarkPageUnmapped(PTE_TO_PAGE((*Pte)));
}
- *Pte = PhysicalAddress.QuadPart | Attributes;
+ *Pte = (ULONG)(PhysicalAddress.QuadPart | Attributes);
if (Process != NULL &&
Process->AddressSpace.PageTableRefCountTable != NULL &&
Address < (PVOID)KERNEL_BASE &&
{
MmMarkPageUnmapped(PTE_TO_PAGE((*Pte)));
}
- *Pte = PhysicalAddress.QuadPart | Attributes;
+ *Pte = (ULONG)(PhysicalAddress.QuadPart | Attributes);
if (Process != NULL &&
Process->AddressSpace.PageTableRefCountTable != NULL &&
Address < (PVOID)KERNEL_BASE &&
MmUpdateStackPageDir(PULONG LocalPageDir, PKTHREAD PThread)
{
unsigned EntryBase = ADDR_TO_PDE_OFFSET(PThread->StackLimit);
- unsigned EntryTop = ADDR_TO_PDE_OFFSET(PThread->InitialStack - PAGE_SIZE);
+ unsigned EntryTop = ADDR_TO_PDE_OFFSET((char*)PThread->InitialStack - PAGE_SIZE);
if (0 == LocalPageDir[EntryBase])
{
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: iospace.c,v 1.22 2003/12/20 21:43:21 navaraf Exp $
+/* $Id: iospace.c,v 1.23 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/iospace.c
}
for (i = 0; (i < (PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE)); i++)
{
+#if !defined(__GNUC__)
+ PHYSICAL_ADDRESS dummyJunkNeeded;
+ dummyJunkNeeded.QuadPart = PhysicalAddress.QuadPart + (i * PAGE_SIZE);
+#endif
Status =
- MmCreateVirtualMappingForKernel(Result + (i * PAGE_SIZE),
+ MmCreateVirtualMappingForKernel((char*)Result + (i * PAGE_SIZE),
Attributes,
+#if defined(__GNUC__)
(PHYSICAL_ADDRESS)
(PhysicalAddress.QuadPart +
- (i * PAGE_SIZE)));
+ (i * PAGE_SIZE))
+#else
+ dummyJunkNeeded
+#endif
+ );
if (!NT_SUCCESS(Status))
{
DbgPrint("Unable to create virtual mapping\n");
KEBUGCHECK(0);
}
+#if defined(__GNUC__)
MmMarkPageMapped((PHYSICAL_ADDRESS) (PhysicalAddress.QuadPart +
(i * PAGE_SIZE)));
+#else
+ MmMarkPageMapped(dummyJunkNeeded);
+#endif
}
- return ((PVOID)(Result + PhysicalAddress.QuadPart % PAGE_SIZE));
+ return ((PVOID)((char*)Result + PhysicalAddress.QuadPart % PAGE_SIZE));
}
IN ULONG NumberOfBytes,
IN MEMORY_CACHING_TYPE CacheType)
{
- return MmMapIoSpace (PhysicalAddress, NumberOfBytes, CacheType);
+ return MmMapIoSpace (PhysicalAddress, NumberOfBytes, (BOOLEAN)CacheType);
}
-/* $Id: kmap.c,v 1.29 2003/10/12 17:05:48 hbirr Exp $
+/* $Id: kmap.c,v 1.30 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
ExUnmapPage(PVOID Addr)
{
KIRQL oldIrql;
- ULONG Base = (Addr - MiKernelMapStart) / PAGE_SIZE;
+ ULONG Base = ((char*)Addr - (char*)MiKernelMapStart) / PAGE_SIZE;
DPRINT("ExUnmapPage(Addr %x)\n",Addr);
{
AllocMapHint = Base + 1;
KeReleaseSpinLock(&AllocMapLock, oldlvl);
- Addr = MiKernelMapStart + Base * PAGE_SIZE;
+ Addr = (char*)MiKernelMapStart + Base * PAGE_SIZE;
Status = MmCreateVirtualMapping(NULL,
Addr,
PAGE_READWRITE | PAGE_SYSTEM,
MiFreeNonPagedPoolRegion(PVOID Addr, ULONG Count, BOOLEAN Free)
{
ULONG i;
- ULONG Base = (Addr - MiKernelMapStart) / PAGE_SIZE;
+ ULONG Base = ((char*)Addr - (char*)MiKernelMapStart) / PAGE_SIZE;
KIRQL oldlvl;
for (i = 0; i < Count; i++)
{
MmDeleteVirtualMapping(NULL,
- Addr + (i * PAGE_SIZE),
+ (char*)Addr + (i * PAGE_SIZE),
Free,
NULL,
NULL);
}
KeReleaseSpinLock(&AllocMapLock, oldlvl);
//DPRINT("returning %x\n",NonPagedPoolBase + Base * PAGE_SIZE);
- return MiKernelMapStart + Base * PAGE_SIZE;
+ return (char*)MiKernelMapStart + Base * PAGE_SIZE;
}
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
DbgPrint("Base %x Length %x End %x Attributes %x Flink %x\n",
current->BaseAddress,current->Length,
- current->BaseAddress+current->Length,current->Attributes,
+ (char*)current->BaseAddress+current->Length,current->Attributes,
current->Entry.Flink);
current_entry = current_entry->Flink;
}
assert(current_entry->Flink->Blink == current_entry);
assert(previous_entry->Flink == current_entry);
if (current->BaseAddress <= Address &&
- (current->BaseAddress + current->Length) > Address)
+ (PVOID)((char*)current->BaseAddress + current->Length) > Address)
{
DPRINT("%s() = %x\n",__FUNCTION__,current);
return(current);
DPRINT("current->BaseAddress %x current->Length %x\n",
current->BaseAddress,current->Length);
if (current->BaseAddress >= Address &&
- current->BaseAddress < (Address+Length))
+ current->BaseAddress < (PVOID)((char*)Address+Length))
{
DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
current);
}
Extent = (ULONG)current->BaseAddress + current->Length;
if (Extent > (ULONG)Address &&
- Extent < (ULONG)(Address+Length))
+ Extent < (ULONG)((char*)Address+Length))
{
DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
current);
return(current);
}
if (current->BaseAddress <= Address &&
- Extent >= (ULONG)(Address+Length))
+ Extent >= (ULONG)((char*)Address+Length))
{
DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
current);
return(current);
}
- if (current->BaseAddress >= (Address+Length))
+ if (current->BaseAddress >= (PVOID)((char*)Address+Length))
{
DPRINT("Finished MmOpenMemoryAreaByRegion()= NULL\n",0);
return(NULL);
{
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
next = CONTAINING_RECORD(current_entry->Flink,MEMORY_AREA,Entry);
- Gap = next->BaseAddress - (current->BaseAddress + PAGE_ROUND_UP(current->Length));
+ Gap = (char*)next->BaseAddress - ((char*)current->BaseAddress + PAGE_ROUND_UP(current->Length));
if (Gap >= Length)
{
- return(current->BaseAddress + PAGE_ROUND_UP(current->Length));
+ return((char*)current->BaseAddress + PAGE_ROUND_UP(current->Length));
}
current_entry = current_entry->Flink;
}
else
{
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
- Address = current->BaseAddress + PAGE_ROUND_UP(current->Length);
+ Address = (char*)current->BaseAddress + PAGE_ROUND_UP(current->Length);
}
/* Check if enough space for the block */
if (AddressSpace->LowestAddress < KERNEL_BASE)
while (current_entry->Blink != ListHead)
{
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
- BottomAddress = current->BaseAddress + PAGE_ROUND_UP(current->Length);
+ BottomAddress = (char*)current->BaseAddress + PAGE_ROUND_UP(current->Length);
DPRINT("Base %p Length %lx\n", current->BaseAddress, PAGE_ROUND_UP(current->Length));
if (BottomAddress < HighestAddress)
{
- Gap = TopAddress - BottomAddress + 1;
+ Gap = (char*)TopAddress - (char*)BottomAddress + 1;
DPRINT("Bottom %p Top %p Gap %lx\n", BottomAddress, TopAddress, Gap);
if (Gap >= Length)
{
- DPRINT("Found gap at %p\n", TopAddress - Length);
- return(TopAddress - Length + 1);
+ DPRINT("Found gap at %p\n", (char*)TopAddress - Length);
+ return((char*)TopAddress - Length + 1);
}
- TopAddress = current->BaseAddress - 1;
+ TopAddress = (char*)current->BaseAddress - 1;
}
current_entry = current_entry->Blink;
}
if (current_entry == ListHead)
{
- Address = (PVOID)HighestAddress - Length + 1;
+ Address = (char*)HighestAddress - Length + 1;
}
else
{
- Address = TopAddress - Length + 1;
+ Address = (char*)TopAddress - Length + 1;
}
/* Check if enough space for the block */
}
for (i=0; i<(PAGE_ROUND_UP(MemoryArea->Length)/PAGE_SIZE); i++)
{
+#if defined(__GNUC__)
PHYSICAL_ADDRESS PhysAddr = (PHYSICAL_ADDRESS)0LL;
+#else
+ PHYSICAL_ADDRESS PhysAddr = { 0 };
+#endif
BOOL Dirty = FALSE;
SWAPENTRY SwapEntry = 0;
if (MmIsPageSwapEntry(AddressSpace->Process,
- MemoryArea->BaseAddress + (i * PAGE_SIZE)))
+ (char*)MemoryArea->BaseAddress + (i * PAGE_SIZE)))
{
MmDeletePageFileMapping(AddressSpace->Process,
- MemoryArea->BaseAddress + (i * PAGE_SIZE),
+ (char*)MemoryArea->BaseAddress + (i * PAGE_SIZE),
&SwapEntry);
}
else
{
MmDeleteVirtualMapping(AddressSpace->Process,
- MemoryArea->BaseAddress + (i*PAGE_SIZE),
+ (char*)MemoryArea->BaseAddress + (i*PAGE_SIZE),
FALSE, &Dirty, &PhysAddr);
}
if (FreePage != NULL)
{
FreePage(FreePageContext, MemoryArea,
- MemoryArea->BaseAddress + (i * PAGE_SIZE), PhysAddr,
- SwapEntry, Dirty);
+ (char*)MemoryArea->BaseAddress + (i * PAGE_SIZE), PhysAddr,
+ SwapEntry, (BOOLEAN)Dirty);
}
}
if (AddressSpace->Process != NULL &&
if (BaseAddress == OriginalMemoryArea->BaseAddress)
{
- OriginalMemoryArea->BaseAddress = BaseAddress + Length;
+ OriginalMemoryArea->BaseAddress = (char*)BaseAddress + Length;
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
MmInsertMemoryArea(AddressSpace, Result);
return(Result);
}
- if ((BaseAddress + Length) ==
- (OriginalMemoryArea->BaseAddress + OriginalMemoryArea->Length))
+ if (((char*)BaseAddress + Length) ==
+ ((char*)OriginalMemoryArea->BaseAddress + OriginalMemoryArea->Length))
{
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
MmInsertMemoryArea(AddressSpace, Result);
Split = ExAllocatePoolWithTag(NonPagedPool, sizeof(MEMORY_AREA),
TAG_MAREA);
RtlCopyMemory(Split,OriginalMemoryArea,sizeof(MEMORY_AREA));
- Split->BaseAddress = BaseAddress + Length;
+ Split->BaseAddress = (char*)BaseAddress + Length;
Split->Length = OriginalMemoryArea->Length - (((ULONG)BaseAddress)
+ Length);
- OriginalMemoryArea->Length = BaseAddress - OriginalMemoryArea->BaseAddress;
+ OriginalMemoryArea->Length = (char*)BaseAddress - (char*)OriginalMemoryArea->BaseAddress;
return(Split);
}
DPRINT("No suitable gap\n");
return(STATUS_NO_MEMORY);
}
+#if defined(__GNUC__)
(*BaseAddress)=(*BaseAddress)+PAGE_SIZE;
+#else
+ {
+ char* pTemp = *BaseAddress;
+ pTemp += PAGE_SIZE;
+ *BaseAddress = pTemp;
+ }
+#endif
}
else
{
}
if (AddressSpace->LowestAddress < KERNEL_BASE &&
- (*BaseAddress) + tmpLength > (PVOID)KERNEL_BASE)
+ (PVOID)((char*)(*BaseAddress) + tmpLength) > (PVOID)KERNEL_BASE)
{
return STATUS_ACCESS_VIOLATION;
}
-/* $Id: mdl.c,v 1.54 2003/10/12 17:05:48 hbirr Exp $
+/* $Id: mdl.c,v 1.55 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
MdlPages = (PULONG)(Mdl + 1);
for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount+Mdl->ByteOffset)/PAGE_SIZE); i++)
{
+#if defined(__GNUC__)
MmUnlockPage((LARGE_INTEGER)(LONGLONG)MdlPages[i]);
MmDereferencePage((LARGE_INTEGER)(LONGLONG)MdlPages[i]);
+#else
+ PHYSICAL_ADDRESS dummyJunkNeeded;
+ dummyJunkNeeded.QuadPart = MdlPages[i];
+ MmUnlockPage(dummyJunkNeeded);
+ MmDereferencePage(dummyJunkNeeded);
+#endif
}
Mdl->MdlFlags = Mdl->MdlFlags & (~MDL_PAGES_LOCKED);
}
KEBUGCHECK(0);
}
- Base = MiMdlMappingRegionBase + StartingOffset * PAGE_SIZE;
+ Base = (char*)MiMdlMappingRegionBase + StartingOffset * PAGE_SIZE;
if (MiMdlMappingRegionHint == StartingOffset)
{
for (i = 0; i < RegionSize; i++)
{
NTSTATUS Status;
+#if !defined(__GNUC__)
+ PHYSICAL_ADDRESS dummyJunkNeeded;
+ dummyJunkNeeded.QuadPart = MdlPages[i];
+#endif
Status = MmCreateVirtualMapping(NULL,
(PVOID)((ULONG)Base+(i*PAGE_SIZE)),
PAGE_READWRITE,
+#if defined(__GNUC__)
(LARGE_INTEGER)(LONGLONG)MdlPages[i],
+#else
+ dummyJunkNeeded,
+#endif
FALSE);
if (!NT_SUCCESS(Status))
{
/* Mark the MDL has having being mapped. */
Mdl->MdlFlags = Mdl->MdlFlags | MDL_MAPPED_TO_SYSTEM_VA;
- Mdl->MappedSystemVa = Base + Mdl->ByteOffset;
- return(Base + Mdl->ByteOffset);
+ Mdl->MappedSystemVa = (char*)Base + Mdl->ByteOffset;
+ return((char*)Base + Mdl->ByteOffset);
}
/*
/* Calculate the number of pages we mapped. */
RegionSize = PAGE_ROUND_UP(Mdl->ByteCount + Mdl->ByteOffset) / PAGE_SIZE;
+#if defined(__GNUC__)
BaseAddress -= Mdl->ByteOffset;
+#else
+ {
+ char* pTemp = BaseAddress;
+ pTemp -= Mdl->ByteOffset;
+ BaseAddress = pTemp;
+ }
+#endif
/* Unmap all the pages. */
for (i = 0; i < RegionSize; i++)
{
MmDeleteVirtualMapping(NULL,
- BaseAddress + (i * PAGE_SIZE),
+ (char*)BaseAddress + (i * PAGE_SIZE),
FALSE,
NULL,
NULL);
KeAcquireSpinLock(&MiMdlMappingRegionLock, &oldIrql);
/* Deallocate all the pages used. */
- Base = (ULONG)(BaseAddress - MiMdlMappingRegionBase) / PAGE_SIZE;
+ Base = (ULONG)((char*)BaseAddress - (char*)MiMdlMappingRegionBase) / PAGE_SIZE;
RtlClearBits(&MiMdlMappingRegionAllocMap, Base, RegionSize);
{
PVOID Address;
- Address = Mdl->StartVa + (i*PAGE_SIZE);
+ Address = (char*)Mdl->StartVa + (i*PAGE_SIZE);
if (!MmIsPagePresent(NULL, Address))
{
{
for (j = 0; j < i; j++)
{
+#if defined(__GNUC__)
MmUnlockPage((LARGE_INTEGER)(LONGLONG)MdlPages[j]);
MmDereferencePage((LARGE_INTEGER)(LONGLONG)MdlPages[j]);
+#else
+ PHYSICAL_ADDRESS dummyJunkNeeded;
+ dummyJunkNeeded.QuadPart = MdlPages[j];
+ MmUnlockPage(dummyJunkNeeded);
+ MmDereferencePage(dummyJunkNeeded);
+#endif
}
ExRaiseStatus(Status);
}
{
for (j = 0; j < i; j++)
{
+#if defined(__GNUC__)
MmUnlockPage((LARGE_INTEGER)(LONGLONG)MdlPages[j]);
MmDereferencePage(
(LARGE_INTEGER)(LONGLONG)MdlPages[j]);
+#else
+ PHYSICAL_ADDRESS dummyJunkNeeded;
+ dummyJunkNeeded.QuadPart = MdlPages[j];
+ MmUnlockPage(dummyJunkNeeded);
+ MmDereferencePage(dummyJunkNeeded);
+#endif
}
ExRaiseStatus(Status);
}
}
MdlPages[i] = MmGetPhysicalAddressForProcess(NULL, Address).u.LowPart;
+#if defined(__GNUC__)
MmReferencePage((LARGE_INTEGER)(LONGLONG)MdlPages[i]);
+#else
+ {
+ PHYSICAL_ADDRESS dummyJunkNeeded;
+ dummyJunkNeeded.QuadPart = MdlPages[i];
+ MmReferencePage(dummyJunkNeeded);
+ }
+#endif
}
MmUnlockAddressSpace(&Mdl->Process->AddressSpace);
if (Mode == UserMode && Mdl->Process != CurrentProcess)
for (va=0; va < ((Mdl->Size - sizeof(MDL)) / sizeof(ULONG)); va++)
{
((PULONG)(Mdl + 1))[va] =
- (MmGetPhysicalAddress(Mdl->StartVa + (va * PAGE_SIZE))).u.LowPart;
+ (MmGetPhysicalAddress((char*)Mdl->StartVa + (va * PAGE_SIZE))).u.LowPart;
}
- Mdl->MappedSystemVa = Mdl->StartVa + Mdl->ByteOffset;
+ Mdl->MappedSystemVa = (char*)Mdl->StartVa + Mdl->ByteOffset;
}
return(NULL);
}
}
-
- MmInitializeMdl(MemoryDescriptorList,Base,Length);
-
+
+ MmInitializeMdl(MemoryDescriptorList, (char*)Base, Length);
+
return(MemoryDescriptorList);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: mm.c,v 1.66 2003/07/26 12:45:37 hbirr Exp $
+/* $Id: mm.c,v 1.67 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
DPRINT("MmReleaseMemoryArea(Process %x, Marea %x)\n",Process,Marea);
DPRINT("Releasing %x between %x %x (type %d)\n",
- Marea, Marea->BaseAddress, Marea->BaseAddress + Marea->Length,
+ Marea, Marea->BaseAddress, (char*)Marea->BaseAddress + Marea->Length,
Marea->Type);
switch (Marea->Type)
-/* $Id: mminit.c,v 1.57 2003/11/30 17:17:02 hbirr Exp $
+/* $Id: mminit.c,v 1.58 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
extern unsigned int _init_start__;
extern unsigned int _init_end__;
+extern unsigned int _bss_end__;
+
+#if defined(_MSC_VER)
+
+#pragma message("This will never work until we somehow fix these!")
+
+#endif
+
static BOOLEAN IsThisAnNtAsSystem = FALSE;
static MM_SYSTEM_SIZE MmSystemSize = MmSmallSystem;
-extern unsigned int _bss_end__;
-
static MEMORY_AREA* kernel_text_desc = NULL;
static MEMORY_AREA* kernel_init_desc = NULL;
static MEMORY_AREA* kernel_map_desc = NULL;
MmInitMemoryAreas();
/* Don't change the start of kernel map. Pte's must always exist for this region. */
- MiKernelMapStart = (PVOID)LastKernelAddress + PAGE_SIZE;
+ MiKernelMapStart = (char*)LastKernelAddress + PAGE_SIZE;
MiKernelMapLength = MM_KERNEL_MAP_SIZE;
- MiNonPagedPoolStart = MiKernelMapStart + MiKernelMapLength + PAGE_SIZE;
+ MiNonPagedPoolStart = (char*)MiKernelMapStart + MiKernelMapLength + PAGE_SIZE;
MiNonPagedPoolLength = MM_NONPAGED_POOL_SIZE;
- MmPagedPoolBase = MiNonPagedPoolStart + MiNonPagedPoolLength + PAGE_SIZE;
+ MmPagedPoolBase = (char*)MiNonPagedPoolStart + MiNonPagedPoolLength + PAGE_SIZE;
MmPagedPoolSize = MM_PAGED_POOL_SIZE;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: mpw.c,v 1.16 2003/07/21 21:53:53 royce Exp $
+/* $Id: mpw.c,v 1.17 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/mpw.c
NTSTATUS Status;
Page = MmGetLRUFirstUserPage();
+#if defined(__GNUC__)
while (Page.QuadPart != 0LL && Target > 0)
+#else
+ while (Page.QuadPart && Target > 0)
+#endif
{
/*
* FIXME: While the current page is write back it is possible
-/* $Id: ncache.c,v 1.25 2003/07/10 21:05:03 royce Exp $
+/* $Id: ncache.c,v 1.26 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &NPage);
MmCreateVirtualMapping (NULL,
- Result + (i * PAGE_SIZE),
+ (char*)Result + (i * PAGE_SIZE),
Attributes,
NPage,
TRUE);
-/* $Id: npool.c,v 1.79 2003/12/14 17:56:23 hbirr Exp $
+/* $Id: npool.c,v 1.80 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#if 0
#define POOL_TRACE(args...) do { DbgPrint(args); } while(0);
#else
+#if defined(__GNUC__)
#define POOL_TRACE(args...)
+#else
+#define POOL_TRACE
+#endif /* __GNUC__ */
#endif
/* avl types ****************************************************************/
{
CHAR c1, c2, c3, c4;
- c1 = (CurrentTag >> 24) & 0xFF;
- c2 = (CurrentTag >> 16) & 0xFF;
- c3 = (CurrentTag >> 8) & 0xFF;
- c4 = CurrentTag & 0xFF;
+ c1 = (CHAR)((CurrentTag >> 24) & 0xFF);
+ c2 = (CHAR)((CurrentTag >> 16) & 0xFF);
+ c3 = (CHAR)((CurrentTag >> 8) & 0xFF);
+ c4 = (CHAR)(CurrentTag & 0xFF);
if (isprint(c1) && isprint(c2) && isprint(c3) && isprint(c4))
{
if (!NewOnly || !current->Used.Dumped)
{
CHAR c1, c2, c3, c4;
-
- c1 = (current->Used.Tag >> 24) & 0xFF;
- c2 = (current->Used.Tag >> 16) & 0xFF;
- c3 = (current->Used.Tag >> 8) & 0xFF;
- c4 = current->Used.Tag & 0xFF;
-
+
+ c1 = (CHAR)((current->Used.Tag >> 24) & 0xFF);
+ c2 = (CHAR)((current->Used.Tag >> 16) & 0xFF);
+ c3 = (CHAR)((current->Used.Tag >> 8) & 0xFF);
+ c4 = (CHAR)(current->Used.Tag & 0xFF);
+
if (isprint(c1) && isprint(c2) && isprint(c3) && isprint(c4))
{
DbgPrint("Size 0x%x Tag 0x%x (%c%c%c%c) Allocator 0x%x\n",
}
current = (BLOCK_HDR*)((char*)blk + BLOCK_HDR_SIZE + blk->Size);
- if ((PVOID)current < MiNonPagedPoolStart + MiNonPagedPoolLength &&
+ if ((char*)current < (char*)MiNonPagedPoolStart + MiNonPagedPoolLength &&
current->Magic == BLOCK_HDR_FREE_MAGIC)
{
remove_from_free_list(current);
blk->Size += BLOCK_HDR_SIZE + current->Size;
memset(current, 0xcc, BLOCK_HDR_SIZE);
current = (BLOCK_HDR*)((char*)blk + BLOCK_HDR_SIZE + blk->Size);
- if ((PVOID)current < MiNonPagedPoolStart + MiNonPagedPoolLength)
+ if ((char*)current < (char*)MiNonPagedPoolStart + MiNonPagedPoolLength)
{
current->previous = blk;
}
PVOID start = (PVOID)PAGE_ROUND_UP((ULONG)((char*)blk + BLOCK_HDR_SIZE));
end = (PVOID)PAGE_ROUND_UP(end);
- index = (ULONG)(start - MiNonPagedPoolStart) / PAGE_SIZE;
+ index = (ULONG)((char*)start - (char*)MiNonPagedPoolStart) / PAGE_SIZE;
while (start < end)
{
if (!(MiNonPagedPoolAllocMap[index / 32] & (1 << (index % 32))))
MiNonPagedPoolNrOfPages++;
}
index++;
+#if defined(__GNUC__)
start += PAGE_SIZE;
+#else
+ {
+ char* pTemp = start;
+ pTemp += PAGE_SIZE;
+ start = pTemp;
+ }
+#endif
}
return result;
}
}
}
- end = (PVOID)current + BLOCK_HDR_SIZE + size;
-
+ end = (char*)current + BLOCK_HDR_SIZE + size;
+
if (current_size >= size + BLOCK_HDR_SIZE + MM_POOL_ALIGNMENT)
{
/* create a new free block after our block, if the memory size is >= 4 byte for this block */
next = (BLOCK_HDR*)((ULONG)current + size + BLOCK_HDR_SIZE);
next_size = current_size - size - BLOCK_HDR_SIZE;
current_size = size;
- end = (PVOID)next + BLOCK_HDR_SIZE;
+ end = (char*)next + BLOCK_HDR_SIZE;
}
if (previous)
if (next == NULL)
{
blk = (BLOCK_HDR*)((char*)current + BLOCK_HDR_SIZE + current->Size);
- if ((PVOID)blk < MiNonPagedPoolStart + MiNonPagedPoolLength)
+ if ((char*)blk < (char*)MiNonPagedPoolStart + MiNonPagedPoolLength)
{
blk->previous = current;
}
next->Magic = BLOCK_HDR_FREE_MAGIC;
next->previous = current;
blk = (BLOCK_HDR*)((char*)next + BLOCK_HDR_SIZE + next->Size);
- if ((PVOID)blk < MiNonPagedPoolStart + MiNonPagedPoolLength)
+ if ((char*)blk < (char*)MiNonPagedPoolStart + MiNonPagedPoolLength)
{
blk->previous = next;
}
DPRINT("freeing block %x\n",blk);
- POOL_TRACE("ExFreePool(block %x), size %d, caller %x\n",block,blk->size,
+ POOL_TRACE("ExFreePool(block %x), size %d, caller %x\n",block,blk->Size,
((PULONG)&block)[-1]);
KeAcquireSpinLock(&MmNpoolLock, &oldIrql);
KEBUGCHECK(0);
}
MiNonPagedPoolAllocMap[i / 32] |= (1 << (i % 32));
+#if defined(__GNUC__)
Address += PAGE_SIZE;
+#else
+ {
+ char* pTemp = Address;
+ pTemp += PAGE_SIZE;
+ Address = pTemp;
+ }
+#endif
}
/* the first block contains the non paged pool bitmap */
blk = (BLOCK_HDR*)MiNonPagedPoolStart;
/* the second block is the first free block */
blk = (BLOCK_HDR*)((char*)blk + BLOCK_HDR_SIZE + blk->Size);
memset(blk, 0, BLOCK_HDR_SIZE);
- memset((PVOID)blk + BLOCK_HDR_SIZE, 0x0cc, MiNonPagedPoolNrOfPages * PAGE_SIZE - ((ULONG)blk + BLOCK_HDR_SIZE - (ULONG)MiNonPagedPoolStart));
+ memset((char*)blk + BLOCK_HDR_SIZE, 0x0cc, MiNonPagedPoolNrOfPages * PAGE_SIZE - ((ULONG)blk + BLOCK_HDR_SIZE - (ULONG)MiNonPagedPoolStart));
blk->Magic = BLOCK_HDR_FREE_MAGIC;
blk->Size = MiNonPagedPoolLength - ((ULONG)blk + BLOCK_HDR_SIZE - (ULONG)MiNonPagedPoolStart);
blk->previous = (BLOCK_HDR*)MiNonPagedPoolStart;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: pagefile.c,v 1.40 2003/12/14 17:54:22 hbirr Exp $
+/* $Id: pagefile.c,v 1.41 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/pagefile.c
}
}
KEBUGCHECK(0);
+#if defined(__GNUC__)
return (LARGE_INTEGER)0LL;
+#else
+ {
+ const LARGE_INTEGER dummy = { 0 };
+ return dummy;
+ }
+#endif
}
NTSTATUS MmWriteToSwapPage(SWAPENTRY SwapEntry, PMDL Mdl)
Headers->BugCheckParameters[3] = BugCodeParameter4;
Headers->FaultingStackBase = (PVOID)Thread->Tcb.StackLimit;
Headers->FaultingStackSize = StackSize =
- (ULONG)(Thread->Tcb.StackBase - Thread->Tcb.StackLimit);
+ (ULONG)((char*)Thread->Tcb.StackBase - Thread->Tcb.StackLimit);
Headers->PhysicalMemorySize = MmStats.NrTotalPages * PAGE_SIZE;
/* Initialize the dump device. */
/* Dump the header. */
MdlMap[0] = MmGetPhysicalAddress(MmCoreDumpPageFrame).u.LowPart;
+#if defined(__GNUC__)
DiskOffset = MmGetOffsetPageFile(RetrievalPointers, (LARGE_INTEGER)0LL);
+#else
+ {
+ const LARGE_INTEGER dummy = { 0 };
+ DiskOffset = MmGetOffsetPageFile(RetrievalPointers, dummy);
+ }
+#endif
DiskOffset.QuadPart += MmCoreDumpLcnMapping.LcnDiskOffset.QuadPart;
Status = MmCoreDumpFunctions->DumpWrite(DiskOffset, Mdl);
if (!NT_SUCCESS(Status))
MmCreateVirtualMappingDump(MmCoreDumpPageFrame,
PAGE_READWRITE,
PhysicalAddress);
+#if defined(__GNUC__)
DiskOffset = MmGetOffsetPageFile(RetrievalPointers,
(LARGE_INTEGER)NextOffset);
+#else
+ {
+ LARGE_INTEGER dummy;
+ dummy.QuadPart = NextOffset;
+ DiskOffset = MmGetOffsetPageFile(RetrievalPointers, dummy);
+ }
+#endif
DiskOffset.QuadPart += MmCoreDumpLcnMapping.LcnDiskOffset.QuadPart;
Status = MmCoreDumpFunctions->DumpWrite(DiskOffset, Mdl);
if (!NT_SUCCESS(Status))
return(STATUS_NO_MEMORY);
}
+#if defined(__GNUC__)
Vcn.QuadPart = 0LL;
+#else
+ Vcn.QuadPart = 0;
+#endif
ExtentCount = 0;
- MaxVcn = (InitialSize->QuadPart + BytesPerAllocationUnit - 1) / BytesPerAllocationUnit;
+ MaxVcn = (ULONG)((InitialSize->QuadPart + BytesPerAllocationUnit - 1) / BytesPerAllocationUnit);
while(1)
{
Status = NtFsControlFile(FileHandle,
PagingFile->FileObject = FileObject;
PagingFile->MaximumSize.QuadPart = MaximumSize->QuadPart;
PagingFile->CurrentSize.QuadPart = InitialSize->QuadPart;
- PagingFile->FreePages = InitialSize->QuadPart / PAGE_SIZE;
+ PagingFile->FreePages = (ULONG)(InitialSize->QuadPart / PAGE_SIZE);
PagingFile->UsedPages = 0;
KeInitializeSpinLock(&PagingFile->AllocMapLock);
-/* $Id: pool.c,v 1.25 2003/12/14 17:44:02 hbirr Exp $
+/* $Id: pool.c,v 1.26 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* FUNCTIONS ***************************************************************/
+#if defined(__GNUC__)
PVOID STDCALL STATIC
+#else
+STATIC PVOID STDCALL
+#endif
EiAllocatePool(POOL_TYPE PoolType,
ULONG NumberOfBytes,
ULONG Tag,
*/
{
PVOID Block;
+#if defined(__GNUC__)
Block = EiAllocatePool(PoolType,
NumberOfBytes,
TAG_NONE,
(PVOID)__builtin_return_address(0));
+#elif defined(_MSC_VER)
+ Block = EiAllocatePool(PoolType,
+ NumberOfBytes,
+ TAG_NONE,
+ &ExAllocatePool);
+#else
+#error Unknown compiler
+#endif
return(Block);
}
ExAllocatePoolWithTag (ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
{
PVOID Block;
+#if defined(__GNUC__)
Block = EiAllocatePool(PoolType,
NumberOfBytes,
Tag,
(PVOID)__builtin_return_address(0));
+#elif defined(_MSC_VER)
+ Block = EiAllocatePool(PoolType,
+ NumberOfBytes,
+ Tag,
+ &ExAllocatePoolWithTag);
+#else
+#error Unknown compiler
+#endif
return(Block);
}
VOID STDCALL
ExFreePool(IN PVOID Block)
{
- if (Block >= MmPagedPoolBase && Block < (MmPagedPoolBase + MmPagedPoolSize))
+ if (Block >= MmPagedPoolBase && (char*)Block < ((char*)MmPagedPoolBase + MmPagedPoolSize))
{
ExFreePagedPool(Block);
}
-/* $Id: ppool.c,v 1.23 2003/12/14 18:36:15 navaraf Exp $
+/* $Id: ppool.c,v 1.24 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#undef assert
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); }
#define ASSERT_SIZE(n) assert ( (n) <= MmPagedPoolSize && (n) >= 0 )
-#define ASSERT_PTR(p) assert ( ((size_t)(p)) >= ((size_t)MmPagedPoolBase) && ((size_t)(p)) < ((size_t)(MmPagedPoolBase+MmPagedPoolSize)) )
+#define ASSERT_PTR(p) assert ( ((size_t)(p)) >= ((size_t)MmPagedPoolBase) && ((size_t)(p)) < ((size_t)((size_t)MmPagedPoolBase+MmPagedPoolSize)) )
// to disable buffer over/under-run detection, set the following macro to 0
#define MM_PPOOL_REDZONE_BYTES 4
while ( CurrentBlock != NULL )
{
PVOID Addr = block_to_address(CurrentBlock);
- PVOID CurrentBlockEnd = (PVOID)CurrentBlock + CurrentBlock->Size;
+ PVOID CurrentBlockEnd = (char*)CurrentBlock + CurrentBlock->Size;
/* calculate last size-aligned address available within this block */
- PVOID AlignedAddr = MM_ROUND_DOWN(CurrentBlockEnd-NumberOfBytes-MM_PPOOL_REDZONE_BYTES, Alignment);
- assert ( AlignedAddr+NumberOfBytes+MM_PPOOL_REDZONE_BYTES <= CurrentBlockEnd );
+ PVOID AlignedAddr = MM_ROUND_DOWN((char*)CurrentBlockEnd-NumberOfBytes-MM_PPOOL_REDZONE_BYTES, Alignment);
+ assert ( (char*)AlignedAddr+NumberOfBytes+MM_PPOOL_REDZONE_BYTES <= (char*)CurrentBlockEnd );
/* special case, this address is already size-aligned, and the right size */
if ( Addr == AlignedAddr )
PMM_PPOOL_FREE_BLOCK_HEADER NewFreeBlock =
(PMM_PPOOL_FREE_BLOCK_HEADER)address_to_block(BestAlignedAddr);
assert ( BestAlignedAddr > Addr );
- NewFreeBlock->Size = Addr + BestBlock->Size - BestAlignedAddr;
+ NewFreeBlock->Size = (char*)Addr + BestBlock->Size - (char*)BestAlignedAddr;
ASSERT_SIZE(NewFreeBlock->Size);
BestBlock->Size = (size_t)NewFreeBlock - (size_t)Addr;
ASSERT_SIZE(BestBlock->Size);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: region.c,v 1.5 2003/01/02 16:41:56 hbirr Exp $
+/* $Id: region.c,v 1.6 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/region.c
}
NewRegion1->Type = NewType;
NewRegion1->Protect = NewProtect;
- InternalLength = (InitialBaseAddress + InitialRegion->Length) - StartAddress;
+ InternalLength = ((char*)InitialBaseAddress + InitialRegion->Length) - (char*)StartAddress;
InternalLength = min(InternalLength, Length);
NewRegion1->Length = InternalLength;
InsertAfterEntry(&InitialRegion->RegionListEntry,
* If necessary create a new region for the portion of the initial region
* beyond the range of addresses to alter.
*/
- if ((InitialBaseAddress + InitialRegion->Length) > (StartAddress + Length))
+ if (((char*)InitialBaseAddress + InitialRegion->Length) > ((char*)StartAddress + Length))
{
NewRegion2->Type = InitialRegion->Type;
NewRegion2->Protect = InitialRegion->Protect;
- NewRegion2->Length = (InitialBaseAddress + InitialRegion->Length) -
- (StartAddress + Length);
+ NewRegion2->Length = ((char*)InitialBaseAddress + InitialRegion->Length) -
+ ((char*)StartAddress + Length);
InsertAfterEntry(&NewRegion1->RegionListEntry,
&NewRegion2->RegionListEntry);
}
}
else
{
- InitialRegion->Length = StartAddress - InitialBaseAddress;
+ InitialRegion->Length = (char*)StartAddress - (char*)InitialBaseAddress;
}
return(NewRegion1);
*/
InitialRegion = MmFindRegion(BaseAddress, RegionListHead, StartAddress,
&InitialBaseAddress);
- if ((StartAddress + Length) >
- (InitialBaseAddress + InitialRegion->Length))
+ if (((char*)StartAddress + Length) >
+ ((char*)InitialBaseAddress + InitialRegion->Length))
{
- RemainingLength = (StartAddress + Length) -
- (InitialBaseAddress + InitialRegion->Length);
+ RemainingLength = ((char*)StartAddress + Length) -
+ ((char*)InitialBaseAddress + InitialRegion->Length);
}
else
{
CurrentEntry = NewRegion->RegionListEntry.Flink;
CurrentRegion = CONTAINING_RECORD(CurrentEntry, MM_REGION,
RegionListEntry);
- CurrentBaseAddress = StartAddress + NewRegion->Length;
+ CurrentBaseAddress = (char*)StartAddress + NewRegion->Length;
while (RemainingLength > 0 && CurrentRegion->Length <= RemainingLength)
{
if (CurrentRegion->Type != NewType &&
CurrentRegion->Type, CurrentRegion->Protect,
NewType, NewProtect);
}
+#if defined(__GNUC__)
CurrentBaseAddress += CurrentRegion->Length;
+#else
+ {
+ char* pTemp = CurrentBaseAddress;
+ pTemp += CurrentRegion->Length;
+ CurrentBaseAddress = pTemp;
+ }
+#endif
NewRegion->Length += CurrentRegion->Length;
RemainingLength -= CurrentRegion->Length;
CurrentEntry = CurrentEntry->Flink;
current = CONTAINING_RECORD(current_entry, MM_REGION, RegionListEntry);
if (StartAddress <= Address &&
- (StartAddress + current->Length) > Address)
+ ((char*)StartAddress + current->Length) > (char*)Address)
{
if (RegionBaseAddress != NULL)
{
}
current_entry = current_entry->Flink;
+#if defined(__GNUC__)
StartAddress += current->Length;
+#else
+ {
+ char* pTemp = StartAddress;
+ pTemp += current->Length;
+ StartAddress = pTemp;
+ }
+#endif
}
return(NULL);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: rmap.c,v 1.25 2003/10/22 18:26:34 hbirr Exp $
+/* $Id: rmap.c,v 1.26 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
Type = MemoryArea->Type;
if (Type == MEMORY_AREA_SECTION_VIEW)
{
- Offset = (ULONG)(Address - (ULONG)MemoryArea->BaseAddress);
+ Offset = (ULONG)((char*)Address - (ULONG)MemoryArea->BaseAddress);
/*
* Get or create a pageop
Type = MemoryArea->Type;
if (Type == MEMORY_AREA_SECTION_VIEW)
{
- Offset = (ULONG)(Address - (ULONG)MemoryArea->BaseAddress);
+ Offset = (ULONG)((char*)Address - (ULONG)MemoryArea->BaseAddress);
/*
* Get or create a pageop
DPRINT1("Insert rmap (%d, 0x%.8X) 0x%.8X which doesn't match physical "
"address 0x%.8X\n", Process->UniqueProcessId, Address,
MmGetPhysicalAddressForProcess(Process, Address).u.LowPart,
- PhysicalAddress.u.LowPart)
+ PhysicalAddress.u.LowPart);
KEBUGCHECK(0);
}
* 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.137 2003/12/21 19:12:19 navaraf Exp $
+/* $Id: section.c,v 1.138 2003/12/30 18:52:05 fireball Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c
#include <ddk/ntifs.h>
#include <ntos/minmax.h>
#include <rosrtl/string.h>
+#include <reactos/bugcodes.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
+/* Note: Mmsp prefix denotes "Memory Manager Section Private". */
+
+/*
+ * FUNCTION: Waits in kernel mode up to ten seconds for an MM_PAGEOP event.
+ * ARGUMENTS: PMM_PAGEOP which event we should wait for.
+ * RETURNS: Status of the wait.
+ */
+static NTSTATUS
+MmspWaitForPageOpCompletionEvent(PMM_PAGEOP PageOp)
+{
+ LARGE_INTEGER Timeout;
+#ifdef __GNUC__ /* TODO: Use other macro to check for suffix to use? */
+ Timeout.QuadPart = -100000000LL; // 10 sec
+#else
+ Timeout.QuadPart = -100000000; // 10 sec
+#endif
+ return KeWaitForSingleObject(&PageOp->CompletionEvent, 0, KernelMode, FALSE, &Timeout);
+}
+
+
+/*
+ * FUNCTION: Sets the page op completion event and releases the page op.
+ * ARGUMENTS: PMM_PAGEOP.
+ * RETURNS: In shorter time than it takes you to even read this
+ * description, so don't even think about geting a mug of coffee.
+ */
+static void
+MmspCompleteAndReleasePageOp(PMM_PAGEOP PageOp)
+{
+ KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
+ MmReleasePageOp(PageOp);
+}
+
+
+/*
+ * FUNCTION: Waits in kernel mode indefinitely for a file object lock.
+ * ARGUMENTS: PFILE_OBJECT to wait for.
+ * RETURNS: Status of the wait.
+ */
+static NTSTATUS
+MmspWaitForFileLock(PFILE_OBJECT File)
+{
+ return KeWaitForSingleObject(&File->Lock, 0, KernelMode, FALSE, NULL);
+}
+
+
VOID
MmFreePageTablesSectionSegment(PMM_SECTION_SEGMENT Segment)
{
}
}
-VOID
+VOID
MmLockSectionSegment(PMM_SECTION_SEGMENT Segment)
{
ExAcquireFastMutex(&Segment->Lock);
ExReleaseFastMutex(&Segment->Lock);
}
-VOID
+VOID
MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
ULONG Offset,
ULONG Entry)
Table = Segment->PageDirectory.PageTables[DirectoryOffset];
if (Table == NULL)
{
- Table =
+ Table =
Segment->PageDirectory.PageTables[DirectoryOffset] =
ExAllocatePoolWithTag(NonPagedPool, sizeof(SECTION_PAGE_TABLE),
TAG_SECTION_PAGE_TABLE);
}
-ULONG
+ULONG
MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
ULONG Offset)
{
ULONG Entry;
ULONG DirectoryOffset;
ULONG TableOffset;
-
+
DPRINT("MmGetPageEntrySection(Offset %x)\n", Offset);
-
+
if (Segment->Length <= NR_SECTION_PAGE_TABLES * PAGE_SIZE)
{
Table = (PSECTION_PAGE_TABLE)&Segment->PageDirectory;
}
Entry = MAKE_SSE(PAGE_FROM_SSE(Entry), SHARE_COUNT_FROM_SSE(Entry) - 1);
/*
- * If we reducing the share count of this entry to zero then set the entry
+ * If we reducing the share count of this entry to zero then set the entry
* to zero and tell the cache the page is no longer mapped.
*/
if (SHARE_COUNT_FROM_SSE(Entry) == 0)
ULONG FileOffset;
FileOffset = Offset + Segment->FileOffset;
-
+
IsImageSection = Section->AllocationAttributes & SEC_IMAGE ? TRUE : FALSE;
-
- Page = (PHYSICAL_ADDRESS)(LONGLONG)PAGE_FROM_SSE(Entry);
+
+ Page.QuadPart = (LONGLONG)PAGE_FROM_SSE(Entry);
FileObject = Section->FileObject;
if (FileObject != NULL)
{
{
if (Segment->Flags & MM_PAGEFILE_SEGMENT)
{
- /*
+ /*
* FIXME:
- * Try to page out this page and set the swap entry
+ * Try to page out this page and set the swap entry
* within the section segment. There exist no rmap entry
- * for this page. The pager thread can't page out a
+ * for this page. The pager thread can't page out a
* page without a rmap entry.
*/
MmSetPageEntrySectionSegment(Segment, Offset, Entry);
PBCB Bcb;
BOOLEAN IsImageSection;
ULONG Length;
-
+
FileObject = MemoryArea->Data.SectionData.Section->FileObject;
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
RawLength = MemoryArea->Data.SectionData.Segment->RawLength;
FileOffset = SegOffset + MemoryArea->Data.SectionData.Segment->FileOffset;
IsImageSection = MemoryArea->Data.SectionData.Section->AllocationAttributes & SEC_IMAGE ? TRUE : FALSE;
-
+
assert(Bcb);
DPRINT("%S %x\n", FileObject->FileName.Buffer, FileOffset);
/*
* Retrieve the page from the cache segment that we actually want.
*/
- Addr = MmGetPhysicalAddress(BaseAddress +
+ Addr = MmGetPhysicalAddress((char*)BaseAddress +
FileOffset - BaseOffset);
(*Page) = Addr;
MmReferencePage((*Page));
Length = RawLength - SegOffset;
if (Length <= CacheSegOffset && Length <= PAGE_SIZE)
{
- memcpy(PageAddr, BaseAddress + FileOffset - BaseOffset, Length);
+ memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, Length);
}
else if (CacheSegOffset >= PAGE_SIZE)
{
- memcpy(PageAddr, BaseAddress + FileOffset - BaseOffset, PAGE_SIZE);
+ memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, PAGE_SIZE);
}
else
{
- memcpy(PageAddr, BaseAddress + FileOffset - BaseOffset, CacheSegOffset);
+ memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, CacheSegOffset);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
Status = CcRosGetCacheSegment(Bcb,
FileOffset + CacheSegOffset,
}
if (Length < PAGE_SIZE)
{
- memcpy(PageAddr + CacheSegOffset, BaseAddress, Length - CacheSegOffset);
+ memcpy((char*)PageAddr + CacheSegOffset, BaseAddress, Length - CacheSegOffset);
}
else
{
- memcpy(PageAddr + CacheSegOffset, BaseAddress, PAGE_SIZE - CacheSegOffset);
+ memcpy((char*)PageAddr + CacheSegOffset, BaseAddress, PAGE_SIZE - CacheSegOffset);
}
}
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
ULONG Attributes;
PMM_PAGEOP PageOp;
PMM_REGION Region;
- LARGE_INTEGER Timeout;
/*
* There is a window between taking the page fault and locking the
if (Locked)
{
MmLockPage(MmGetPhysicalAddressForProcess(AddressSpace->Process, Address));
- }
+ }
return(STATUS_SUCCESS);
}
-
+
PAddress = (ULONG)PAGE_ROUND_DOWN(((ULONG)Address));
Offset = PAddress - (ULONG)MemoryArea->BaseAddress;
-
+
Segment = MemoryArea->Data.SectionData.Segment;
Section = MemoryArea->Data.SectionData.Section;
Region = MmFindRegion(MemoryArea->BaseAddress,
- &MemoryArea->Data.SectionData.RegionListHead,
+ &MemoryArea->Data.SectionData.RegionListHead,
Address, NULL);
/*
* Lock the segment
{
Attributes = Region->Protect;
}
-
+
/*
* Get or create a page operation descriptor
*/
{
MmUnlockSectionSegment(Segment);
MmUnlockAddressSpace(AddressSpace);
- Timeout.QuadPart = -100000000LL; // 10 sec
- Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
- 0,
- KernelMode,
- FALSE,
- &Timeout);
-
+ Status = MmspWaitForPageOpCompletionEvent(PageOp);
/*
* Check for various strange conditions
*/
*/
if (PageOp->OpType != MM_PAGEOP_PAGEIN)
{
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_MM_RESTART_OPERATION);
}
-
+
/*
* If the thread handling this fault has failed then we don't retry
*/
if (!NT_SUCCESS(PageOp->Status))
{
Status = PageOp->Status;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(Status);
}
MmLockSectionSegment(Segment);
/*
- * If the completed fault was for another address space then set the
+ * If the completed fault was for another address space then set the
* page in this one.
*/
if (!MmIsPagePresent(AddressSpace->Process, Address))
if (Entry == 0)
{
MmUnlockSectionSegment(Segment);
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_MM_RESTART_OPERATION);
- }
+ }
- Page = (LARGE_INTEGER)(LONGLONG)(PAGE_FROM_SSE(Entry));
- MmReferencePage(Page);
+ Page.QuadPart = (LONGLONG)(PAGE_FROM_SSE(Entry));
+ MmReferencePage(Page);
MmSharePageEntrySectionSegment(Segment, Offset);
Status = MmCreateVirtualMapping(MemoryArea->Process,
}
MmUnlockSectionSegment(Segment);
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
}
KEBUGCHECK(0);
}
MmLockAddressSpace(AddressSpace);
- Status = MmCreateVirtualMapping(AddressSpace->Process,
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
Page,
FALSE);
if (Status == STATUS_NO_MEMORY)
{
- MmUnlockAddressSpace(AddressSpace);
+ MmUnlockAddressSpace(AddressSpace);
Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
Page,
TRUE);
MmLockAddressSpace(AddressSpace);
- }
+ }
if (!NT_SUCCESS(Status))
{
DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
* Store the swap entry for later use.
*/
MmSetSavedSwapEntryPage(Page, SwapEntry);
-
+
/*
* Add the page to the process's working set
*/
MmInsertRmap(Page, AddressSpace->Process, (PVOID)PAddress);
-
+
/*
* Finish the operation
*/
if (Locked)
{
MmLockPage(MmGetPhysicalAddressForProcess(NULL, Address));
- }
+ }
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
}
{
MmUnlockSectionSegment(Segment);
/*
- * Just map the desired physical page
+ * Just map the desired physical page
*/
Page.QuadPart = Offset + MemoryArea->Data.SectionData.ViewOffset;
Status = MmCreateVirtualMapping(AddressSpace->Process,
FALSE);
if (Status == STATUS_NO_MEMORY)
{
- MmUnlockAddressSpace(AddressSpace);
+ MmUnlockAddressSpace(AddressSpace);
Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
Page,
TRUE);
MmLockAddressSpace(AddressSpace);
- }
+ }
if (!NT_SUCCESS(Status))
{
DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
KEBUGCHECK(0);
return(Status);
}
- /*
- * Don't add an rmap entry since the page mapped could be for
- * anything.
+ /*
+ * Don't add an rmap entry since the page mapped could be for
+ * anything.
*/
if (Locked)
{
MmLockPage(Page);
- }
+ }
/*
* Cleanup and release locks
*/
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
}
-
+
/*
* Map anonymous memory for BSS sections
*/
Status = MmRequestPageMemoryConsumer(MC_USER, FALSE, &Page);
if (!NT_SUCCESS(Status))
{
- MmUnlockAddressSpace(AddressSpace);
+ MmUnlockAddressSpace(AddressSpace);
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
MmLockAddressSpace(AddressSpace);
}
FALSE);
if (Status == STATUS_NO_MEMORY)
{
- MmUnlockAddressSpace(AddressSpace);
+ MmUnlockAddressSpace(AddressSpace);
Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
Page,
TRUE);
MmLockAddressSpace(AddressSpace);
- }
+ }
if (!NT_SUCCESS(Status))
{
if (Locked)
{
MmLockPage(Page);
- }
+ }
/*
* Cleanup and release locks
*/
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
}
* Get the entry corresponding to the offset within the section
*/
Entry = MmGetPageEntrySectionSegment(Segment, Offset);
-
+
if (Entry == 0)
- {
+ {
/*
* If the entry is zero (and it can't change because we have
* locked the segment) then we need to load the page.
MmUnlockSectionSegment(Segment);
MmUnlockAddressSpace(AddressSpace);
- if ((Segment->Flags & MM_PAGEFILE_SEGMENT) ||
+ if ((Segment->Flags & MM_PAGEFILE_SEGMENT) ||
(Offset >= PAGE_ROUND_UP(Segment->RawLength) && Section->AllocationAttributes & SEC_IMAGE))
{
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
*/
MmLockAddressSpace(AddressSpace);
PageOp->Status = Status;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(Status);
}
*/
MmLockAddressSpace(AddressSpace);
MmLockSectionSegment(Segment);
-
+
/*
* Check the entry. No one should change the status of a page
* that has a pending page-in.
DbgPrint("Someone changed ppte entry while we slept\n");
KEBUGCHECK(0);
}
-
+
/*
* Mark the offset within the section as having valid, in-memory
* data
if (Locked)
{
MmLockPage(Page);
- }
+ }
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
}
MmUnlockSectionSegment(Segment);
MmUnlockAddressSpace(AddressSpace);
-
+
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
if (!NT_SUCCESS(Status))
{
*/
MmLockAddressSpace(AddressSpace);
MmLockSectionSegment(Segment);
-
+
/*
* Check the entry. No one should change the status of a page
* that has a pending page-in.
DbgPrint("Someone changed ppte entry while we slept\n");
KEBUGCHECK(0);
}
-
+
/*
* Mark the offset within the section as having valid, in-memory
* data
if (Locked)
{
MmLockPage(Page);
- }
+ }
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
}
{
/*
* If the section offset is already in-memory and valid then just
- * take another reference to the page
+ * take another reference to the page
*/
-
- Page = (LARGE_INTEGER)(LONGLONG)PAGE_FROM_SSE(Entry);
- MmReferencePage(Page);
+
+ Page.QuadPart = (LONGLONG)PAGE_FROM_SSE(Entry);
+ MmReferencePage(Page);
MmSharePageEntrySectionSegment(Segment, Offset);
MmUnlockSectionSegment(Segment);
if (Locked)
{
MmLockPage(Page);
- }
+ }
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
}
}
-NTSTATUS
+NTSTATUS
MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
- MEMORY_AREA* MemoryArea,
+ MEMORY_AREA* MemoryArea,
PVOID Address,
BOOLEAN Locked)
{
ULONG Offset;
PMM_PAGEOP PageOp;
PMM_REGION Region;
- LARGE_INTEGER Timeout;
/*
* Check if the page has been paged out or has already been set readwrite
{
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
- }
+ }
/*
* Find the offset of the page
if (PageOp->Thread != PsGetCurrentThread())
{
MmUnlockAddressSpace(AddressSpace);
- Timeout.QuadPart = -100000000LL; // 10 sec
- Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
- 0,
- KernelMode,
- FALSE,
- &Timeout);
+ Status = MmspWaitForPageOpCompletionEvent(PageOp);
/*
* Check for various strange conditions
*/
* Restart the operation
*/
MmLockAddressSpace(AddressSpace);
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_MM_RESTART_OPERATION);
}
* Copy the old page
*/
OldPage = MmGetPhysicalAddressForProcess(NULL, Address);
-
+
NewAddress = ExAllocatePageWithPhysPage(NewPage);
memcpy(NewAddress, (PVOID)PAddress, PAGE_SIZE);
ExUnmapPage(NewAddress);
Address,
Region->Protect,
NewPage,
- FALSE);
+ FALSE);
if (Status == STATUS_NO_MEMORY)
{
- MmUnlockAddressSpace(AddressSpace);
+ MmUnlockAddressSpace(AddressSpace);
Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
NewPage,
TRUE);
MmLockAddressSpace(AddressSpace);
- }
+ }
if (!NT_SUCCESS(Status))
{
DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
}
if (Locked)
{
+/* MmUnlockPage(OldPage); */
MmLockPage(NewPage);
- }
+ }
/*
* Unshare the old page.
MmReleasePageMemoryConsumer(MC_USER, OldPage);
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
}
NTSTATUS
MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
- MEMORY_AREA* MemoryArea,
+ MEMORY_AREA* MemoryArea,
PVOID Address,
PMM_PAGEOP PageOp)
{
Context.Segment = MemoryArea->Data.SectionData.Segment;
Context.Section = MemoryArea->Data.SectionData.Section;
- Context.Offset = (ULONG)(Address - (ULONG)MemoryArea->BaseAddress);
+ Context.Offset = (ULONG)((char*)Address - (ULONG)MemoryArea->BaseAddress);
FileOffset = Context.Offset + Context.Segment->FileOffset;
IsImageSection = Context.Section->AllocationAttributes & SEC_IMAGE ? TRUE : FALSE;
if (FileObject != NULL)
{
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
-
+
/*
* If the file system is letting us go directly to the cache and the
* memory area was mapped at an offset in the file which is page aligned
DirectMapped = TRUE;
}
}
-
+
/*
* This should never happen since mappings of physical memory are never
if (Context.Section->AllocationAttributes & SEC_PHYSICALMEMORY)
{
DPRINT1("Trying to page out from physical memory section address 0x%X "
- "process %d\n", Address,
+ "process %d\n", Address,
AddressSpace->Process ? AddressSpace->Process->UniqueProcessId : 0);
KEBUGCHECK(0);
}
AddressSpace->Process ? AddressSpace->Process->UniqueProcessId : 0, Address);
KEBUGCHECK(0);
}
- PhysicalAddress =
+ PhysicalAddress =
MmGetPhysicalAddressForProcess(AddressSpace->Process, Address);
SwapEntry = MmGetSavedSwapEntryPage(PhysicalAddress);
*/
Context.WasDirty = FALSE;
if (Context.Segment->Characteristics & IMAGE_SECTION_CHAR_BSS ||
- IS_SWAP_FROM_SSE(Entry) ||
+ IS_SWAP_FROM_SSE(Entry) ||
(LONGLONG)PAGE_FROM_SSE(Entry) != PhysicalAddress.QuadPart)
{
Context.Private = TRUE;
if (SwapEntry != 0)
{
DPRINT1("SwapEntry != 0 was 0x%.8X at address 0x%.8X, "
- "paddress 0x%.8X\n", SwapEntry, Address,
+ "paddress 0x%.8X\n", SwapEntry, Address,
PhysicalAddress);
KEBUGCHECK(0);
}
DPRINT1("Had private copy of read-only page.\n");
KEBUGCHECK(0);
}
-
+
/*
* Delete all mappings of this page.
*/
- MmDeleteAllRmaps(PhysicalAddress, (PVOID)&Context,
+ MmDeleteAllRmaps(PhysicalAddress, (PVOID)&Context,
MmPageOutDeleteMapping);
if (Context.WasDirty)
{
}
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_SUCCESS);
}
{
if(!MiIsPageFromCache(MemoryArea, Context.Offset))
{
- DPRINT1("Direct mapped non private page is not associated with the cache.\n")
+ DPRINT1("Direct mapped non private page is not associated with the cache.\n");;
KEBUGCHECK(0);
}
}
}
MmDeleteAllRmaps(PhysicalAddress, (PVOID)&Context, MmPageOutDeleteMapping);
-
+
/*
* If this wasn't a private page then we should have reduced the entry to
* zero by deleting all the rmaps.
/*
* If the page wasn't dirty then we can just free it as for a readonly page.
* Since we unmapped all the mappings above we know it will not suddenly
- * become dirty.
- * If the page is from a pagefile section and has no swap entry,
+ * become dirty.
+ * If the page is from a pagefile section and has no swap entry,
* we can't free the page at this point.
*/
SwapEntry = MmGetSavedSwapEntryPage(PhysicalAddress);
- if (!Context.WasDirty &&
+ if (!Context.WasDirty &&
!(SwapEntry == 0 && Context.Segment->Flags & MM_PAGEFILE_SEGMENT))
-
+
{
if (Context.Private)
{
DPRINT1("Private page, non-dirty but not swapped out "
"process %d address 0x%.8X\n",
AddressSpace->Process ? AddressSpace->Process->UniqueProcessId : 0,
- Address);
+ Address);
KEBUGCHECK(0);
}
else
{
MmReleasePageMemoryConsumer(MC_USER, PhysicalAddress);
}
-
+
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_SUCCESS);
}
KEBUGCHECK(0);
}
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_SUCCESS);
}
*/
if (Context.Private)
{
- Status = MmCreateVirtualMapping(MemoryArea->Process,
+ Status = MmCreateVirtualMapping(MemoryArea->Process,
Address,
MemoryArea->Attributes,
PhysicalAddress,
FALSE);
MmSetDirtyPage(MemoryArea->Process, Address);
- MmInsertRmap(PhysicalAddress,
+ MmInsertRmap(PhysicalAddress,
MemoryArea->Process,
Address);
}
{
/*
* For non-private pages if the page wasn't direct mapped then
- * set it back into the section segment entry so we don't loose
+ * set it back into the section segment entry so we don't loose
* our copy. Otherwise it will be handled by the cache manager.
*/
- Status = MmCreateVirtualMapping(MemoryArea->Process,
+ Status = MmCreateVirtualMapping(MemoryArea->Process,
Address,
MemoryArea->Attributes,
PhysicalAddress,
FALSE);
MmSetDirtyPage(MemoryArea->Process, Address);
- MmInsertRmap(PhysicalAddress,
+ MmInsertRmap(PhysicalAddress,
MemoryArea->Process,
Address);
Entry = MAKE_SSE(PhysicalAddress.u.LowPart, 1);
MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
}
PageOp->Status = STATUS_UNSUCCESSFUL;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_PAGEFILE_QUOTA);
}
}
Status = MmWriteToSwapPage(SwapEntry, Mdl);
if (!NT_SUCCESS(Status))
{
- DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
+ DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
Status);
/*
* As above: undo our actions.
*/
if (Context.Private)
{
- Status = MmCreateVirtualMapping(MemoryArea->Process,
+ Status = MmCreateVirtualMapping(MemoryArea->Process,
Address,
MemoryArea->Attributes,
PhysicalAddress,
FALSE);
MmSetDirtyPage(MemoryArea->Process, Address);
- MmInsertRmap(PhysicalAddress,
+ MmInsertRmap(PhysicalAddress,
MemoryArea->Process,
Address);
}
else
{
- Status = MmCreateVirtualMapping(MemoryArea->Process,
+ Status = MmCreateVirtualMapping(MemoryArea->Process,
Address,
MemoryArea->Attributes,
PhysicalAddress,
FALSE);
MmSetDirtyPage(MemoryArea->Process, Address);
- MmInsertRmap(PhysicalAddress,
+ MmInsertRmap(PhysicalAddress,
MemoryArea->Process,
Address);
Entry = MAKE_SSE(PhysicalAddress.u.LowPart, 1);
MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
}
PageOp->Status = STATUS_UNSUCCESSFUL;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_UNSUCCESSFUL);
}
if (Context.Private)
{
- Status = MmCreatePageFileMapping(MemoryArea->Process,
+ Status = MmCreatePageFileMapping(MemoryArea->Process,
Address,
SwapEntry);
if (!NT_SUCCESS(Status))
}
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_SUCCESS);
}
-NTSTATUS
+NTSTATUS
MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
PMEMORY_AREA MemoryArea,
PVOID Address,
Address = (PVOID)PAGE_ROUND_DOWN(Address);
- Offset = (ULONG)(Address - (ULONG)MemoryArea->BaseAddress);
+ Offset = (ULONG)((char*)Address - (ULONG)MemoryArea->BaseAddress);
/*
* Get the segment and section.
if (FileObject != NULL)
{
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
-
+
/*
* If the file system is letting us go directly to the cache and the
* memory area was mapped at an offset in the file which is page aligned
DirectMapped = TRUE;
}
}
-
+
/*
* This should never happen since mappings of physical memory are never
* placed in the rmap lists.
if (Section->AllocationAttributes & SEC_PHYSICALMEMORY)
{
DPRINT1("Trying to write back page from physical memory mapped at %X "
- "process %d\n", Address,
+ "process %d\n", Address,
AddressSpace->Process ? AddressSpace->Process->UniqueProcessId : 0);
KEBUGCHECK(0);
}
AddressSpace->Process ? AddressSpace->Process->UniqueProcessId : 0, Address);
KEBUGCHECK(0);
}
- PhysicalAddress =
+ PhysicalAddress =
MmGetPhysicalAddressForProcess(AddressSpace->Process, Address);
SwapEntry = MmGetSavedSwapEntryPage(PhysicalAddress);
* Check for a private (COWed) page.
*/
if (Segment->Characteristics & IMAGE_SECTION_CHAR_BSS ||
- IS_SWAP_FROM_SSE(Entry) ||
+ IS_SWAP_FROM_SSE(Entry) ||
(LONGLONG)PAGE_FROM_SSE(Entry) != PhysicalAddress.QuadPart)
{
Private = TRUE;
* Speculatively set all mappings of the page to clean.
*/
MmSetCleanAllRmaps(PhysicalAddress);
-
+
/*
* If this page was direct mapped from the cache then the cache manager
* will take care of writing it back to disk.
assert(SwapEntry == 0);
CcRosMarkDirtyCacheSegment(Bcb, Offset + MemoryArea->Data.SectionData.ViewOffset);
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_SUCCESS);
}
{
MmSetDirtyAllRmaps(PhysicalAddress);
PageOp->Status = STATUS_UNSUCCESSFUL;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_PAGEFILE_QUOTA);
}
MmSetSavedSwapEntryPage(PhysicalAddress, SwapEntry);
Status = MmWriteToSwapPage(SwapEntry, Mdl);
if (!NT_SUCCESS(Status))
{
- DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
+ DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
Status);
MmSetDirtyAllRmaps(PhysicalAddress);
PageOp->Status = STATUS_UNSUCCESSFUL;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_UNSUCCESSFUL);
}
*/
DPRINT("MM: Wrote section page 0x%.8X to swap!\n", PhysicalAddress);
PageOp->Status = STATUS_SUCCESS;
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
return(STATUS_SUCCESS);
}
{
for (i = 0; i < PAGE_ROUND_UP(RegionSize) / PAGE_SIZE; i++)
{
- PVOID Address = BaseAddress + (i * PAGE_SIZE);
+ PVOID Address = (char*)BaseAddress + (i * PAGE_SIZE);
ULONG Protect = NewProtect;
- /*
+ /*
* If we doing COW for this segment then check if the page is
* already private.
*/
Offset = (ULONG)Address - (ULONG)MemoryArea->BaseAddress;
Entry = MmGetPageEntrySectionSegment(Segment, Offset);
- PhysicalAddress =
+ PhysicalAddress =
MmGetPhysicalAddressForProcess(AddressSpace->Process, Address);
Protect = PAGE_READONLY;
if ((Segment->Characteristics & IMAGE_SECTION_CHAR_BSS ||
- IS_SWAP_FROM_SSE(Entry) ||
+ IS_SWAP_FROM_SSE(Entry) ||
(LONGLONG)PAGE_FROM_SSE(Entry) != PhysicalAddress.QuadPart))
{
Protect = NewProtect;
if (MmIsPagePresent(AddressSpace->Process, Address))
{
- MmSetPageProtect(AddressSpace->Process, BaseAddress,
+ MmSetPageProtect(AddressSpace->Process, BaseAddress,
Protect);
}
}
PMM_REGION Region;
NTSTATUS Status;
- Length =
- min(Length, (ULONG) (MemoryArea->BaseAddress + MemoryArea->Length - BaseAddress));
+ Length =
+ min(Length, (ULONG) ((char*)MemoryArea->BaseAddress + MemoryArea->Length - (char*)BaseAddress));
Region = MmFindRegion(MemoryArea->BaseAddress,
&MemoryArea->Data.SectionData.RegionListHead,
BaseAddress, NULL);
{
PMM_REGION Region;
PVOID RegionBaseAddress;
-
+
Region = MmFindRegion(MemoryArea->BaseAddress,
&MemoryArea->Data.SectionData.RegionListHead,
Address, &RegionBaseAddress);
ULONG Length;
ULONG Entry;
PMM_SECTION_SEGMENT Segment;
-
+
Segment = Section->Segment;
Length = PAGE_ROUND_UP(Segment->Length);
-
+
for (Offset = 0; Offset < Length; Offset += PAGE_SIZE)
{
Entry = MmGetPageEntrySectionSegment(Segment, Offset);
}
else
{
- PHYSICAL_ADDRESS Page = (PHYSICAL_ADDRESS)(LONGLONG)PAGE_FROM_SSE(Entry);
+ PHYSICAL_ADDRESS Page;
+ Page.QuadPart = (LONGLONG)PAGE_FROM_SSE(Entry);
MmReleasePageMemoryConsumer(MC_USER, Page);
}
}
CcRosDereferenceCache(Section->FileObject);
ObDereferenceObject(Section->FileObject);
Section->FileObject = NULL;
- }
+ }
}
VOID STDCALL
{
DPRINT("MmpCreateSection(ObjectBody %x, Parent %x, RemainingPath %S)\n",
ObjectBody, Parent, RemainingPath);
-
+
if (RemainingPath == NULL)
{
return(STATUS_SUCCESS);
}
-
+
if (wcschr(RemainingPath+1, L'\\') != NULL)
{
return(STATUS_UNSUCCESSFUL);
OBJECT_ATTRIBUTES Obj;
UNICODE_STRING Name = ROS_STRING_INITIALIZER(L"\\Device\\PhysicalMemory");
LARGE_INTEGER SectionSize;
-
+
/*
- * Create the section mapping physical memory
+ * Create the section mapping physical memory
*/
SectionSize.QuadPart = 0xFFFFFFFF;
InitializeObjectAttributes(&Obj,
}
PhysSection->AllocationAttributes |= SEC_PHYSICALMEMORY;
ObDereferenceObject((PVOID)PhysSection);
-
+
return(STATUS_SUCCESS);
}
MmInitSectionImplementation(VOID)
{
MmSectionObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
-
+
RtlRosInitUnicodeStringFromLiteral(&MmSectionObjectType->TypeName, L"Section");
-
+
MmSectionObjectType->Tag = TAG('S', 'E', 'C', 'T');
MmSectionObjectType->TotalObjects = 0;
MmSectionObjectType->TotalHandles = 0;
MmSectionObjectType->OkayToClose = NULL;
MmSectionObjectType->Create = MmpCreateSection;
MmSectionObjectType->DuplicationNotify = NULL;
-
+
/*
* NOTE: Do not register the section object type here because
* the object manager it not initialized yet!
return(STATUS_UNSUCCESSFUL);
}
MaximumSize = *UMaximumSize;
-
+
/*
* Check the protection
*/
- if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
+ if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
SectionPageProtection)
{
return(STATUS_INVALID_PAGE_PROTECTION);
}
-
+
/*
* Create the section
*/
IO_STATUS_BLOCK Iosb;
LARGE_INTEGER Offset;
CHAR Buffer;
-
+
/*
* Check the protection
*/
- if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
+ if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
SectionPageProtection)
{
return(STATUS_INVALID_PAGE_PROTECTION);
{
FileAccess = FILE_READ_DATA;
}
-
+
/*
* Reference the file handle
*/
ObDereferenceObject(FileObject);
return(STATUS_INVALID_FILE_FOR_SECTION);
}
-
+
/*
* FIXME: Revise this once a locking order for file size changes is
* decided
}
else
{
- MaximumSize =
+ MaximumSize =
((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize;
}
- if (MaximumSize.QuadPart >
+ if (MaximumSize.QuadPart >
((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize.QuadPart)
{
Status = NtSetInformationFile(FileHandle,
ZwClose(*SectionHandle);
ObDereferenceObject(Section);
ObDereferenceObject(FileObject);
- return STATUS_INVALID_PARAMETER;
+ return STATUS_INVALID_PARAMETER;
}
}
/*
* Lock the file
*/
- Status = KeWaitForSingleObject((PVOID)&FileObject->Lock,
- 0,
- KernelMode,
- FALSE,
- NULL);
+ Status = MmspWaitForFileLock(FileObject);
if (Status != STATUS_SUCCESS)
{
ZwClose(*SectionHandle);
/*
* If the file is already mapped as a data file then we may need
* to extend it
- */
- Segment =
+ */
+ Segment =
(PMM_SECTION_SEGMENT)FileObject->SectionObjectPointer->
DataSectionObject;
Section->Segment = Segment;
InterlockedIncrement((PLONG)&Segment->ReferenceCount);
MmLockSectionSegment(Segment);
- if (MaximumSize.u.LowPart > Segment->RawLength &&
+ if (MaximumSize.u.LowPart > Segment->RawLength &&
!(AllocationAttributes & SEC_RESERVE))
{
Segment->RawLength = MaximumSize.u.LowPart;
}
}
MmUnlockSectionSegment(Segment);
- Section->FileObject = FileObject;
+ Section->FileObject = FileObject;
Section->MaximumSize = MaximumSize;
CcRosReferenceCache(FileObject);
KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
return(STATUS_SUCCESS);
}
-static ULONG SectionCharacteristicsToProtect[16] =
+static ULONG SectionCharacteristicsToProtect[16] =
{
PAGE_NOACCESS, // 0 = NONE
PAGE_NOACCESS, // 1 = SHARED
IO_STATUS_BLOCK Iosb;
LARGE_INTEGER Offset;
IMAGE_NT_HEADERS PEHeader;
- PIMAGE_SECTION_HEADER ImageSections;
PMM_SECTION_SEGMENT SectionSegments;
ULONG NrSegments;
PMM_IMAGE_SECTION_OBJECT ImageSectionObject;
/*
* Check the protection
*/
- if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
+ if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
SectionPageProtection)
{
return(STATUS_INVALID_PAGE_PROTECTION);
}
-
+
/*
* Specifying a maximum size is meaningless for an image section
*/
if (UMaximumSize != NULL)
{
return(STATUS_INVALID_PARAMETER_4);
- }
+ }
/*
* Reference the file handle
}
/*
- * Initialized caching for this file object if previously caching
+ * Initialized caching for this file object if previously caching
* was initialized for the same on disk file
*/
Status = CcTryToInitializeFileCache(FileObject);
-
+
if (!NT_SUCCESS(Status) || FileObject->SectionObjectPointer->ImageSectionObject == NULL)
{
+ PIMAGE_SECTION_HEADER ImageSections;
/*
* Read the dos header and check the DOS signature
*/
ObDereferenceObject(FileObject);
return(Status);
}
-
+
/*
* Check the DOS signature
*/
/*
* Check the signature
*/
- if (Iosb.Information != sizeof(PEHeader) ||
+ if (Iosb.Information != sizeof(PEHeader) ||
PEHeader.Signature != IMAGE_NT_SIGNATURE)
{
ObDereferenceObject(FileObject);
/*
* Read in the section headers
*/
- Offset.QuadPart = DosHeader.e_lfanew + sizeof(PEHeader);
+ Offset.QuadPart = DosHeader.e_lfanew + sizeof(PEHeader);
ImageSections = ExAllocatePool(NonPagedPool,
- PEHeader.FileHeader.NumberOfSections *
+ PEHeader.FileHeader.NumberOfSections *
sizeof(IMAGE_SECTION_HEADER));
if (ImageSections == NULL)
{
NULL,
&Iosb,
ImageSections,
- PEHeader.FileHeader.NumberOfSections *
+ PEHeader.FileHeader.NumberOfSections *
sizeof(IMAGE_SECTION_HEADER),
&Offset,
0);
{
FileAccess = FILE_READ_DATA;
}
-
+
/*
* We can't do memory mappings if the file system doesn't support the
* standard FCB
ExFreePool(ImageSections);
return(STATUS_INVALID_FILE_FOR_SECTION);
}
-
+
/*
* Lock the file
*/
- Status = KeWaitForSingleObject((PVOID)&FileObject->Lock,
- 0,
- KernelMode,
- FALSE,
- NULL);
+ Status = MmspWaitForFileLock(FileObject);
if (Status != STATUS_SUCCESS)
{
ZwClose(*SectionHandle);
SectionSegments[i].Protection = PAGE_NOACCESS;
SectionSegments[i].WriteCopy = TRUE;
}
-
+
/*
* Set up the attributes.
*/
SectionSegments[i].VirtualAddress = (PVOID)ImageSections[i-1].VirtualAddress;
ExInitializeFastMutex(&SectionSegments[i].Lock);
}
- if (0 != InterlockedCompareExchange((PLONG)&FileObject->SectionObjectPointer->ImageSectionObject,
+ if (0 != InterlockedCompareExchange((PLONG)&FileObject->SectionObjectPointer->ImageSectionObject,
(LONG)ImageSectionObject, 0))
{
/*
{
FileAccess = FILE_READ_DATA;
}
-
+
/*
* Lock the file
*/
- Status = KeWaitForSingleObject((PVOID)&FileObject->Lock,
- 0,
- KernelMode,
- FALSE,
- NULL);
+ Status = MmspWaitForFileLock(FileObject);
if (Status != STATUS_SUCCESS)
{
ZwClose(*SectionHandle);
AllocationAttributes,
FileHandle));
}
- else if (FileHandle != NULL)
+
+ if (FileHandle != NULL)
{
return(MmCreateDataFileSection(SectionHandle,
DesiredAccess,
AllocationAttributes,
FileHandle));
}
- else
- {
- return(MmCreatePageFileSection(SectionHandle,
- DesiredAccess,
- ObjectAttributes,
- MaximumSize,
- SectionPageProtection,
- AllocationAttributes));
- }
+
+ return(MmCreatePageFileSection(SectionHandle,
+ DesiredAccess,
+ ObjectAttributes,
+ MaximumSize,
+ SectionPageProtection,
+ AllocationAttributes));
}
if (!NT_SUCCESS(Status))
{
DPRINT1("Mapping between 0x%.8X and 0x%.8X failed.\n",
- (*BaseAddress), (*BaseAddress) + ViewSize);
+ (*BaseAddress), (char*)(*BaseAddress) + ViewSize);
return(Status);
}
* NtMapViewOfSection
*
* DESCRIPTION
- * Maps a view of a section into the virtual address space of a
+ * Maps a view of a section into the virtual address space of a
* process.
- *
+ *
* ARGUMENTS
* SectionHandle
* Handle of the section.
- *
+ *
* ProcessHandle
* Handle of the process.
- *
+ *
* BaseAddress
* Desired base address (or NULL) on entry;
* Actual base address of the view on exit.
- *
+ *
* ZeroBits
* Number of high order address bits that must be zero.
- *
+ *
* CommitSize
- * Size in bytes of the initially committed section of
+ * Size in bytes of the initially committed section of
* the view.
- *
+ *
* SectionOffset
* Offset in bytes from the beginning of the section
* to the beginning of the view.
- *
+ *
* ViewSize
* Desired length of map (or zero to map all) on entry
* Actual length mapped on exit.
- *
+ *
* InheritDisposition
* Specified how the view is to be shared with
* child processes.
- *
+ *
* AllocateType
* Type of allocation for the pages.
- *
+ *
* Protect
* Protection for the committed region of the view.
*
{
return(Status);
}
-
+
AddressSpace = &Process->AddressSpace;
-
+
Status = ObReferenceObjectByHandle(SectionHandle,
SECTION_MAP_READ,
MmSectionObjectType,
ObDereferenceObject(Process);
return(Status);
}
-
+
Status = MmMapViewOfSection(Section,
Process,
BaseAddress,
InheritDisposition,
AllocationType,
Protect);
-
+
ObDereferenceObject(Section);
ObDereferenceObject(Process);
-
+
return(Status);
}
VOID STATIC
MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
- PHYSICAL_ADDRESS PhysAddr, SWAPENTRY SwapEntry,
+ PHYSICAL_ADDRESS PhysAddr, SWAPENTRY SwapEntry,
BOOLEAN Dirty)
{
PMEMORY_AREA MArea;
ULONG Offset;
SWAPENTRY SavedSwapEntry;
PMM_PAGEOP PageOp;
- LARGE_INTEGER Timeout;
NTSTATUS Status;
PSECTION_OBJECT Section;
PMM_SECTION_SEGMENT Segment;
PageOp = MmCheckForPageOp(MArea, 0, NULL, Segment, Offset);
-
+
while (PageOp)
{
MmUnlockSectionSegment(Segment);
MmUnlockAddressSpace(&MArea->Process->AddressSpace);
- Timeout.QuadPart = -100000000LL; // 10 sec
- Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
- 0,
- KernelMode,
- FALSE,
- &Timeout);
+ Status = MmspWaitForPageOpCompletionEvent(PageOp);
if (Status != STATUS_SUCCESS)
{
DPRINT1("Failed to wait for page op, status = %x\n", Status);
MmLockAddressSpace(&MArea->Process->AddressSpace);
MmLockSectionSegment(Segment);
- KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
- MmReleasePageOp(PageOp);
+ MmspCompleteAndReleasePageOp(PageOp);
PageOp = MmCheckForPageOp(MArea, 0, NULL, Segment, Offset);
}
Entry = MmGetPageEntrySectionSegment(Segment, Offset);
-
+
/*
* For a dirty, datafile, non-private page mark it as dirty in the
* cache manager.
MmFreeSwapPage(SwapEntry);
}
else if (PhysAddr.QuadPart != 0)
- {
- if (IS_SWAP_FROM_SSE(Entry) ||
+ {
+ if (IS_SWAP_FROM_SSE(Entry) ||
PhysAddr.QuadPart != (PAGE_FROM_SSE(Entry)))
{
/*
MemoryArea->DeleteInProgress = TRUE;
Section = MemoryArea->Data.SectionData.Section;
Segment = MemoryArea->Data.SectionData.Segment;
-
+
MmLockSectionSegment(Segment);
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
RemoveEntryList(&MemoryArea->Data.SectionData.ViewListEntry);
PMEMORY_AREA MemoryArea;
PMADDRESS_SPACE AddressSpace;
PSECTION_OBJECT Section;
-
+
DPRINT("Opening memory area Process %x BaseAddress %x\n",
Process, BaseAddress);
assert(Process);
-
+
AddressSpace = &Process->AddressSpace;
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
BaseAddress);
PMM_SECTION_SEGMENT SectionSegments;
PVOID ImageBaseAddress = 0;
PMM_SECTION_SEGMENT Segment;
-
+
Segment = MemoryArea->Data.SectionData.Segment;
ImageSectionObject = Section->ImageSection;
SectionSegments = ImageSectionObject->Segments;
NrSegments = ImageSectionObject->NrSegments;
- /* Search for the current segment within the section segments
+ /* Search for the current segment within the section segments
* and calculate the image base address */
for (i = 0; i < NrSegments; i++)
{
{
if (Segment == &SectionSegments[i])
{
- ImageBaseAddress = BaseAddress - (ULONG_PTR)SectionSegments[i].VirtualAddress;
+ ImageBaseAddress = (char*)BaseAddress - (ULONG_PTR)SectionSegments[i].VirtualAddress;
break;
}
}
if (!(SectionSegments[i].Characteristics & IMAGE_SECTION_NOLOAD))
{
PVOID SBaseAddress = (PVOID)
- (ImageBaseAddress + (ULONG_PTR)SectionSegments[i].VirtualAddress);
+ ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].VirtualAddress);
Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress);
}
{
PEPROCESS Process;
NTSTATUS Status;
-
+
DPRINT("NtUnmapViewOfSection(ProcessHandle %x, BaseAddress %x)\n",
ProcessHandle, BaseAddress);
-
+
DPRINT("Referencing process\n");
Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_VM_OPERATION,
NtQuerySection (IN HANDLE SectionHandle,
IN CINT SectionInformationClass,
OUT PVOID SectionInformation,
- IN ULONG Length,
+ IN ULONG Length,
OUT PULONG ResultLength)
/*
* FUNCTION: Queries the information of a section object.
- * ARGUMENTS:
+ * ARGUMENTS:
* SectionHandle = Handle to the section link object
* SectionInformationClass = Index to a certain information structure
- * SectionInformation (OUT)= Caller supplies storage for resulting
+ * SectionInformation (OUT)= Caller supplies storage for resulting
* information
- * Length = Size of the supplied storage
+ * Length = Size of the supplied storage
* ResultLength = Data written
* RETURNS: Status
*
}
Sbi = (PSECTION_BASIC_INFORMATION)SectionInformation;
-
+
Sbi->BaseAddress = 0;
Sbi->Attributes = 0;
Sbi->Size.QuadPart = 0;
ObDereferenceObject(Section);
return(STATUS_INFO_LENGTH_MISMATCH);
}
-
- Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation;
+
+ Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation;
memset(Sii, 0, sizeof(SECTION_IMAGE_INFORMATION));
if (Section->AllocationAttributes & SEC_IMAGE)
{
PMM_IMAGE_SECTION_OBJECT ImageSectionObject;
ImageSectionObject = Section->ImageSection;
-
+
Sii->EntryPoint = ImageSectionObject->EntryPoint;
Sii->StackReserve = ImageSectionObject->StackReserve;
Sii->StackCommit = ImageSectionObject->StackCommit;
Sii->Subsystem = ImageSectionObject->Subsystem;
- Sii->MinorSubsystemVersion = ImageSectionObject->MinorSubsystemVersion;
- Sii->MajorSubsystemVersion = ImageSectionObject->MajorSubsystemVersion;
+ Sii->MinorSubsystemVersion = (USHORT)ImageSectionObject->MinorSubsystemVersion;
+ Sii->MajorSubsystemVersion = (USHORT)ImageSectionObject->MajorSubsystemVersion;
Sii->Characteristics = ImageSectionObject->ImageCharacteristics;
Sii->ImageNumber = ImageSectionObject->Machine;
Sii->Executable = ImageSectionObject->Executable;
}
-NTSTATUS STDCALL
+NTSTATUS STDCALL
NtExtendSection(IN HANDLE SectionHandle,
IN ULONG NewMaximumSize)
{
*
* REVISIONS
*/
-PVOID STDCALL
+PVOID STDCALL
MmAllocateSection (IN ULONG Length)
{
PVOID Result;
NTSTATUS Status;
ULONG i;
PMADDRESS_SPACE AddressSpace;
-
+
DPRINT("MmAllocateSection(Length %x)\n",Length);
-
+
AddressSpace = MmGetKernelAddressSpace();
Result = NULL;
MmLockAddressSpace(AddressSpace);
&marea,
FALSE,
FALSE);
+ MmUnlockAddressSpace(AddressSpace);
if (!NT_SUCCESS(Status))
{
- MmUnlockAddressSpace(AddressSpace);
return (NULL);
}
- MmUnlockAddressSpace(AddressSpace);
DPRINT("Result %p\n",Result);
for (i = 0; i < PAGE_ROUND_UP(Length) / PAGE_SIZE; i++)
{
KEBUGCHECK(0);
}
Status = MmCreateVirtualMapping (NULL,
- (Result + (i * PAGE_SIZE)),
+ ((char*)Result + (i * PAGE_SIZE)),
PAGE_READWRITE,
Page,
TRUE);
* MmMapViewOfSection
*
* DESCRIPTION
- * Maps a view of a section into the virtual address space of a
+ * Maps a view of a section into the virtual address space of a
* process.
- *
+ *
* ARGUMENTS
* Section
* Pointer to the section object.
- *
+ *
* ProcessHandle
* Pointer to the process.
- *
+ *
* BaseAddress
* Desired base address (or NULL) on entry;
* Actual base address of the view on exit.
- *
+ *
* ZeroBits
* Number of high order address bits that must be zero.
- *
+ *
* CommitSize
- * Size in bytes of the initially committed section of
+ * Size in bytes of the initially committed section of
* the view.
- *
+ *
* SectionOffset
* Offset in bytes from the beginning of the section
* to the beginning of the view.
- *
+ *
* ViewSize
* Desired length of map (or zero to map all) on entry
* Actual length mapped on exit.
- *
+ *
* InheritDisposition
* Specified how the view is to be shared with
* child processes.
- *
+ *
* AllocationType
* Type of allocation for the pages.
- *
+ *
* Protect
* Protection for the committed region of the view.
*
if (!(SectionSegments[i].Characteristics & IMAGE_SECTION_NOLOAD))
{
ULONG MaxExtent;
- MaxExtent = (ULONG)(SectionSegments[i].VirtualAddress +
+ MaxExtent = (ULONG)((char*)SectionSegments[i].VirtualAddress +
SectionSegments[i].Length);
ImageSize = max(ImageSize, MaxExtent);
}
}
/* Check there is enough space to map the section at that point. */
- if (MmOpenMemoryAreaByRegion(AddressSpace, ImageBase,
+ if (MmOpenMemoryAreaByRegion(AddressSpace, ImageBase,
PAGE_ROUND_UP(ImageSize)) != NULL)
{
/* Fail if the user requested a fixed base address. */
for (i = 0; i < NrSegments; i++)
{
- PVOID SBaseAddress;
-
if (!(SectionSegments[i].Characteristics & IMAGE_SECTION_NOLOAD))
{
- SBaseAddress = (PVOID)
- (ImageBase + (ULONG_PTR)SectionSegments[i].VirtualAddress);
+ PVOID SBaseAddress = (PVOID)
+ ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].VirtualAddress);
MmLockSectionSegment(&SectionSegments[i]);
Status = MmMapViewOfSegment(Process,
AddressSpace,
}
else
{
+ if (ViewSize == NULL)
+ {
+ /* Following this pointer would lead to us to the dark side */
+ /* What to do? Bugcheck? Return status? Do the mambo? */
+ KEBUGCHECK(MEMORY_MANAGEMENT);
+ }
+
if (SectionOffset == NULL)
{
ViewOffset = 0;
{
switch(FlushType)
{
- case MmFlushForDelete:
- if (SectionObjectPointer->ImageSectionObject ||
+ case MmFlushForDelete:
+ if (SectionObjectPointer->ImageSectionObject ||
SectionObjectPointer->DataSectionObject)
{
return FALSE;
MmLockAddressSpace(AddressSpace);
-
+
if ((*ViewSize) == 0)
{
(*ViewSize) = Section->MaximumSize.u.LowPart;
/**********************************************************************
* NAME EXPORTED
* MmCreateSection@
- *
+ *
* DESCRIPTION
* Creates a section object.
- *
+ *
* ARGUMENTS
* SectionObjiect (OUT)
* Caller supplied storage for the resulting pointer
* to a SECTION_OBJECT instance;
- *
+ *
* DesiredAccess
* Specifies the desired access to the section can be a
* combination of:
* SECTION_MAP_WRITE |
* SECTION_MAP_READ |
* SECTION_MAP_EXECUTE
- *
+ *
* ObjectAttributes [OPTIONAL]
- * Initialized attributes for the object can be used
+ * Initialized attributes for the object can be used
* to create a named section;
*
* MaximumSize
- * Maximizes the size of the memory section. Must be
- * non-NULL for a page-file backed section.
- * If value specified for a mapped file and the file is
+ * Maximizes the size of the memory section. Must be
+ * non-NULL for a page-file backed section.
+ * If value specified for a mapped file and the file is
* not large enough, file will be extended.
- *
+ *
* SectionPageProtection
* Can be a combination of:
- * PAGE_READONLY |
+ * PAGE_READONLY |
* PAGE_READWRITE |
- * PAGE_WRITEONLY |
+ * PAGE_WRITEONLY |
* PAGE_WRITECOPY
- *
+ *
* AllocationAttributes
* Can be a combination of:
- * SEC_IMAGE |
+ * SEC_IMAGE |
* SEC_RESERVE
- *
+ *
* FileHandle
* Handle to a file to create a section mapped to a file
* instead of a memory backed section;
*
* File
* Unknown.
- *
+ *
* RETURN VALUE
* Status.
*
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: slab.c,v 1.9 2003/07/21 21:53:53 royce Exp $
+/* $Id: slab.c,v 1.10 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
return(NULL);
}
- SlabPage = (PSLAB_CACHE_PAGE)(Page + PAGE_SIZE - sizeof(SLAB_CACHE_PAGE));
+ SlabPage = (PSLAB_CACHE_PAGE)((char*)Page + PAGE_SIZE - sizeof(SLAB_CACHE_PAGE));
SlabPage->ReferenceCount = 0;
SlabPage->FirstFreeBuffer = (PSLAB_CACHE_BUFCTL)Page;
for (i = 0; i < Slab->ObjectsPerPage; i++)
{
- BufCtl = (PSLAB_CACHE_BUFCTL)(Page + (i * Slab->ObjectSize));
+ BufCtl = (PSLAB_CACHE_BUFCTL)((char*)Page + (i * Slab->ObjectSize));
Object = (PVOID)(BufCtl + 1);
if (Slab->Constructor != NULL)
{
if (i == (Slab->ObjectsPerPage - 1))
{
BufCtl->NextFree =
- (PSLAB_CACHE_BUFCTL)(Page + ((i + 1) * Slab->ObjectSize));
+ (PSLAB_CACHE_BUFCTL)((char*)Page + ((i + 1) * Slab->ObjectSize));
}
else
{
/*
* Allocate the first free object from the page.
*/
- Object = (PVOID)Page->FirstFreeBuffer + sizeof(SLAB_CACHE_BUFCTL);
+ Object = (PVOID)((char*)Page->FirstFreeBuffer + sizeof(SLAB_CACHE_BUFCTL));
Page->FirstFreeBuffer = Page->FirstFreeBuffer->NextFree;
Page->ReferenceCount++;
{
PSLAB_CACHE_BUFCTL BufCtl;
- BufCtl = (PSLAB_CACHE_BUFCTL)(Object - sizeof(SLAB_CACHE_BUFCTL));
+ BufCtl = (PSLAB_CACHE_BUFCTL)((char*)Object - sizeof(SLAB_CACHE_BUFCTL));
BufCtl->NextFree = Page->FirstFreeBuffer;
Page->FirstFreeBuffer = BufCtl;
Page->ReferenceCount--;
current = CONTAINING_RECORD(current_entry,
SLAB_CACHE_PAGE,
PageListEntry);
- Base = (PVOID)current + sizeof(SLAB_CACHE_PAGE) - PAGE_SIZE;
+ Base = (PVOID)((char*)current + sizeof(SLAB_CACHE_PAGE) - PAGE_SIZE);
if (Base >= Object &&
- (Base + PAGE_SIZE - sizeof(SLAB_CACHE_PAGE)) >=
- (Object + Slab->ObjectSize))
+ ((char*)Base + PAGE_SIZE - sizeof(SLAB_CACHE_PAGE)) >=
+ ((char*)Object + Slab->ObjectSize))
{
ExFreeFromPageSlabCache(Slab, current, Object);
/*
current = CONTAINING_RECORD(current_entry,
SLAB_CACHE_PAGE,
PageListEntry);
- Base = (PVOID)current + sizeof(SLAB_CACHE_PAGE) - PAGE_SIZE;
+ Base = (PVOID)((char*)current + sizeof(SLAB_CACHE_PAGE) - PAGE_SIZE);
if (Slab->Destructor != NULL)
{
for (i = 0; i < Slab->ObjectsPerPage; i++)
{
- Object = Base + (i * Slab->ObjectSize) +
+ Object = (char*)Base + (i * Slab->ObjectSize) +
sizeof(SLAB_CACHE_BUFCTL);
Slab->Destructor(Object, Slab->BaseSize);
}
-/* $Id: evtpair.c,v 1.19 2003/10/12 17:05:48 hbirr Exp $
+/* $Id: evtpair.c,v 1.20 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* eventpair via NtSetInformationThread.
* @implemented
*/
-NTSYSAPI
NTSTATUS
+NTSYSAPI
NTAPI
NtSetLowWaitHighThread(
VOID
* eventpair via NtSetInformationThread.
* @implemented
*/
-NTSYSAPI
NTSTATUS
+NTSYSAPI
NTAPI
NtSetHighWaitLowThread(
VOID
-/* $Id: nttimer.c,v 1.22 2003/10/12 17:05:48 hbirr Exp $
+/* $Id: nttimer.c,v 1.23 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
}
-VOID
+VOID STDCALL
NtpTimerDpcRoutine(PKDPC Dpc,
PVOID DeferredContext,
PVOID SystemArgument1,
if ( Timer->Running )
{
- KeInsertQueueApc(&Timer->Apc,
- SystemArgument1,
- SystemArgument2,
- IO_NO_INCREMENT);
+ KeInsertQueueApc(&Timer->Apc,
+ SystemArgument1,
+ SystemArgument2,
+ IO_NO_INCREMENT);
}
}
-VOID
+VOID STDCALL
NtpTimerApcKernelRoutine(PKAPC Apc,
PKNORMAL_ROUTINE* NormalRoutine,
PVOID* NormalContext,
VOID INIT_FUNCTION
NtInitializeTimerImplementation(VOID)
{
+ assert(!ExTimerType)
ExTimerType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE));
RtlCreateUnicodeString(&ExTimerType->TypeName, L"Timer");
KeInitializeTimerEx(&Timer->Timer,
TimerType);
- KeInitializeDpc (&Timer->Dpc,
- (PKDEFERRED_ROUTINE)NtpTimerDpcRoutine,
- (PVOID)Timer);
+ KeInitializeDpc(&Timer->Dpc,
+ &NtpTimerDpcRoutine,
+ Timer);
Timer->Running = FALSE;
Status = ObReferenceObjectByHandle(TimerHandle,
TIMER_QUERY_STATE,
ExTimerType,
- KeGetPreviousMode(),
+ (KPROCESSOR_MODE)KeGetPreviousMode(),
(PVOID*)&Timer,
NULL);
if (!NT_SUCCESS(Status))
memcpy(&TimerInformation.TimeRemaining, &Timer->Timer.DueTime,
sizeof(LARGE_INTEGER));
- TimerInformation.SignalState = Timer->Timer.Header.SignalState;
+ TimerInformation.SignalState = (BOOLEAN)Timer->Timer.Header.SignalState;
ResultLength = sizeof(TIMER_BASIC_INFORMATION);
Status = MmCopyToCaller(UnsafeTimerInformation, &TimerInformation,
PNTTIMER Timer;
NTSTATUS Status;
BOOLEAN Result;
- KIRQL OldIrql;
BOOLEAN State;
DPRINT("NtSetTimer()\n");
Status = ObReferenceObjectByHandle(TimerHandle,
TIMER_ALL_ACCESS,
ExTimerType,
- KeGetPreviousMode(),
+ (KPROCESSOR_MODE)KeGetPreviousMode(),
(PVOID*)&Timer,
NULL);
if (!NT_SUCCESS(Status))
- return Status;
+ {
+ return Status;
+ }
State = KeReadStateTimer(&Timer->Timer);
if (Timer->Running == TRUE)
{
/* cancel running timer */
- OldIrql = KeRaiseIrqlToDpcLevel();
+ const KIRQL OldIrql = KeRaiseIrqlToDpcLevel();
KeCancelTimer(&Timer->Timer);
KeRemoveQueueDpc(&Timer->Dpc);
KeRemoveQueueApc(&Timer->Apc);
Timer->Running = FALSE;
KeLowerIrql(OldIrql);
}
- if( TimerApcRoutine )
- KeInitializeApc(&Timer->Apc,
- KeGetCurrentThread(),
- OriginalApcEnvironment,
- (PKKERNEL_ROUTINE)NtpTimerApcKernelRoutine,
- (PKRUNDOWN_ROUTINE)NULL,
- (PKNORMAL_ROUTINE)TimerApcRoutine,
- KeGetPreviousMode(),
- TimerContext);
-
- Result = KeSetTimerEx (&Timer->Timer,
- *DueTime,
- Period,
- TimerApcRoutine ? &Timer->Dpc : 0 );
+
+ if (TimerApcRoutine)
+ {
+ KeInitializeApc(&Timer->Apc,
+ KeGetCurrentThread(),
+ OriginalApcEnvironment,
+ &NtpTimerApcKernelRoutine,
+ (PKRUNDOWN_ROUTINE)NULL,
+ (PKNORMAL_ROUTINE)TimerApcRoutine,
+ (KPROCESSOR_MODE)KeGetPreviousMode(),
+ TimerContext);
+ }
+
+ Result = KeSetTimerEx(&Timer->Timer,
+ *DueTime,
+ Period,
+ TimerApcRoutine ? &Timer->Dpc : 0 );
if (Result == TRUE)
{
ObDereferenceObject(Timer);
return;
}
- if (current->Base <= Eip && (current->Base + current->Size) > Eip &&
+ if (current->Base <= Eip && ((char*)current->Base + current->Size) > (char*)Eip &&
current->Started)
{
ULONG Bucket;
- Bucket = ((ULONG)(Eip - current->Base)) >> current->BucketShift;
+ Bucket = ((ULONG)((char*)Eip - (char*)current->Base)) >> current->BucketShift;
if ((Bucket*4) < current->BufferSize)
{
-/* $Id: ntobj.c,v 1.18 2003/11/16 13:47:20 ekohl Exp $
+/* $Id: ntobj.c,v 1.19 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
Status = ObReferenceObjectByHandle (ObjectHandle,
0,
NULL,
- KeGetPreviousMode (),
+ (KPROCESSOR_MODE)KeGetPreviousMode (),
&Object,
NULL);
if (!NT_SUCCESS (Status))
Status = ObReferenceObjectByHandle (ObjectHandle,
0,
NULL,
- KeGetPreviousMode(),
+ (KPROCESSOR_MODE)KeGetPreviousMode(),
&Object,
&HandleInfo);
if (!NT_SUCCESS (Status))
}
else
{
+#if defined(__GNUC__)
BasicInfo->CreateTime.QuadPart = 0ULL;
+#else
+ BasicInfo->CreateTime.QuadPart = 0;
+#endif
}
Status = STATUS_SUCCESS;
}
Status = ObReferenceObjectByHandle(Handle,
0,
NULL,
- KeGetPreviousMode(),
+ (KPROCESSOR_MODE)KeGetPreviousMode(),
& Object,
NULL);
if (Status != STATUS_SUCCESS)
-/* $Id: object.c,v 1.72 2003/11/09 23:20:27 gvg Exp $
+/* $Id: object.c,v 1.73 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PVOID HEADER_TO_BODY(POBJECT_HEADER obj)
{
- return(((void *)obj)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER));
+ return(((char*)obj)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER));
}
if (Length < sizeof(OBJECT_NAME_INFORMATION) + sizeof(WCHAR))
return STATUS_INVALID_BUFFER_SIZE;
- ObjectNameInfo->Name.MaximumLength = Length - sizeof(OBJECT_NAME_INFORMATION);
+ ObjectNameInfo->Name.MaximumLength = (USHORT)(Length - sizeof(OBJECT_NAME_INFORMATION));
ObjectNameInfo->Name.Length = 0;
ObjectNameInfo->Name.Buffer =
(PWCHAR)((ULONG_PTR)ObjectNameInfo + sizeof(OBJECT_NAME_INFORMATION));
Status = ObCreateHandle(PsGetCurrentProcess(),
Object,
DesiredAccess,
- HandleAttributes & OBJ_INHERIT,
+ (BOOLEAN)(HandleAttributes & OBJ_INHERIT),
Handle);
ObDereferenceObject(Object);
-/* $Id: symlink.c,v 1.7 2003/11/17 02:12:51 hyperion Exp $
+/* $Id: symlink.c,v 1.8 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
return(ObOpenObjectByName(ObjectAttributes,
ObSymbolicLinkType,
NULL,
- KeGetPreviousMode(),
+ (KPROCESSOR_MODE)KeGetPreviousMode(),
DesiredAccess,
NULL,
LinkHandle));
Status = ObReferenceObjectByHandle(LinkHandle,
SYMBOLIC_LINK_QUERY,
ObSymbolicLinkType,
- KeGetPreviousMode(),
+ (KPROCESSOR_MODE)KeGetPreviousMode(),
(PVOID *)&SymlinkObject,
NULL);
if (!NT_SUCCESS(Status))
-/* $Id: tinfo.c,v 1.23 2003/09/14 10:53:32 hbirr Exp $
+/* $Id: tinfo.c,v 1.24 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
VOID KeSetPreviousMode(ULONG Mode)
{
- PsGetCurrentThread()->Tcb.PreviousMode = Mode;
+ PsGetCurrentThread()->Tcb.PreviousMode = (UCHAR)Mode;
}
/*
/*
* @implemented
*/
-ULONG STDCALL
+KPROCESSOR_MODE STDCALL
ExGetPreviousMode (VOID)
{
- return (ULONG)PsGetCurrentThread()->Tcb.PreviousMode;
+ return (KPROCESSOR_MODE)PsGetCurrentThread()->Tcb.PreviousMode;
}
/* EOF */
-/* $Id: w32call.c,v 1.9 2003/10/12 17:05:50 hbirr Exp $
+/* $Id: w32call.c,v 1.10 2003/12/30 18:52:05 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
return(NULL);
}
Status = MmCreateVirtualMapping(NULL,
- KernelStack + (i * PAGE_SIZE),
+ (char*)KernelStack + (i * PAGE_SIZE),
PAGE_EXECUTE_READWRITE,
Page,
TRUE);
Thread = PsGetCurrentThread();
/* Set up the new kernel and user environment. */
- StackSize = (ULONG)(Thread->Tcb.StackBase - Thread->Tcb.StackLimit);
+ StackSize = (ULONG)((char*)Thread->Tcb.StackBase - Thread->Tcb.StackLimit);
if (IsListEmpty(&CallbackStackListHead))
{
NewStack = PsAllocateCallbackStack(StackSize);
}
else
{
- PLIST_ENTRY StackEntry;
+ PLIST_ENTRY StackEntry;
StackEntry = RemoveHeadList(&CallbackStackListHead);
AssignedStack = CONTAINING_RECORD(StackEntry, NTW32CALL_CALLBACK_STACK,
NewStack = AssignedStack->BaseAddress;
}
/* FIXME: Need to check whether we were interrupted from v86 mode. */
- memcpy(NewStack + StackSize - sizeof(KTRAP_FRAME), Thread->Tcb.TrapFrame,
+ memcpy((char*)NewStack + StackSize - sizeof(KTRAP_FRAME), Thread->Tcb.TrapFrame,
sizeof(KTRAP_FRAME) - (4 * sizeof(DWORD)));
- NewFrame = (PKTRAP_FRAME)(NewStack + StackSize - sizeof(KTRAP_FRAME));
+ NewFrame = (PKTRAP_FRAME)((char*)NewStack + StackSize - sizeof(KTRAP_FRAME));
NewFrame->Esp -= (ArgumentLength + (4 * sizeof(ULONG)));
NewFrame->Eip = (ULONG)LdrpGetSystemDllCallbackDispatcher();
UserEsp = (PULONG)NewFrame->Esp;
SavedState.CallbackStatus = &CallbackStatus;
SavedState.SavedTrapFrame = Thread->Tcb.TrapFrame;
SavedState.SavedCallbackStack = Thread->Tcb.CallbackStack;
- Thread->Tcb.InitialStack = Thread->Tcb.StackBase = NewStack + StackSize;
+ Thread->Tcb.InitialStack = Thread->Tcb.StackBase = (char*)NewStack + StackSize;
Thread->Tcb.StackLimit = (ULONG)NewStack;
- Thread->Tcb.KernelStack = NewStack + StackSize - sizeof(KTRAP_FRAME);
+ Thread->Tcb.KernelStack = (char*)NewStack + StackSize - sizeof(KTRAP_FRAME);
KeGetCurrentKPCR()->TSS->Esp0 = (ULONG)Thread->Tcb.InitialStack;
KePushAndStackSwitchAndSysRet((ULONG)&SavedState, Thread->Tcb.KernelStack);
-/* $Id: handle.c,v 1.4 2003/06/14 09:52:57 gvg Exp $
+/* $Id: handle.c,v 1.5 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* update handle array pointers */
HandleTable->Handles = (PRTL_HANDLE)ArrayPointer;
- HandleTable->Limit = (PRTL_HANDLE)(ArrayPointer + ArraySize);
+ HandleTable->Limit = (PRTL_HANDLE)((char*)ArrayPointer + ArraySize);
HandleTable->LastUsed = (PRTL_HANDLE)ArrayPointer;
}
-/* $Id: exception.c,v 1.8 2003/07/27 11:49:32 dwelch Exp $
+/* $Id: exception.c,v 1.9 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
}
#endif
+#if !defined(_MSC_VER)
+/*
+ * When compiling this file with MSVC itself, don't compile these functions.
+ * They are replacements for MS compiler and/or C runtime library functions,
+ * which are already provided by the MSVC compiler and C runtime library.
+ */
+
/*
* @implemented
*/
return;
}
+#endif /* _MSC_VER */
+
/* Implemented in except.s */
-/* $Id: sprintf.c,v 1.14 2003/12/14 18:06:44 hbirr Exp $
+/* $Id: sprintf.c,v 1.15 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
+#if defined(__GNUC__)
+
#define do_div(n,base) ({ \
int __res; \
__res = ((unsigned long long) n) % (unsigned) base; \
n = ((unsigned long long) n) / (unsigned) base; \
__res; })
+#else /* __GNUC__ */
+/* n /= base, "returns" remainder */
+__inline int int_do_div(__int64* n, int base)
+{
+ int __res = (int)(((unsigned __int64)*n) % (unsigned) base);
+ *n = (int)(((unsigned __int64)*n) / (unsigned) base);
+ return __res;
+}
+#define do_div(n,base) int_do_div(&n, base)
+
+#endif /* __GNUC__ */
+
static int skip_atoi(const char **s)
{
static char *
+#if defined(__GNUC__)
number(char *buf, char *end, long long num, int base, int size, int precision, int type)
+#else
+number(char *buf, char *end, __int64 num, int base, int size, int precision, int type)
+#endif
{
char c,sign,tmp[66];
const char *digits;
int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args)
{
int len;
+#if defined(__GNUC__)
unsigned long long num;
+#else
+ unsigned __int64 num;
+#endif
int base;
char *str, *end;
const char *s;
}
if (qualifier == 'I')
+#if defined(__GNUC__)
num = va_arg(args, unsigned long long);
+#else
+ num = va_arg(args, unsigned __int64);
+#endif
else if (qualifier == 'l')
num = va_arg(args, unsigned long);
else if (qualifier == 'h') {
-/* $Id: stdlib.c,v 1.9 2003/12/14 18:06:44 hbirr Exp $
+/* $Id: stdlib.c,v 1.10 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* GLOBALS ****************************************************************/
+#if defined(__GNUC__)
static unsigned long long next = 0;
+#else
+static unsigned __int64 next = 0;
+#endif
/* FUNCTIONS ****************************************************************/
*/
int rand(void)
{
+#if defined(__GNUC__)
next = next * 0x5deece66dLL + 11;
+#else
+ next = next * 0x5deece66di64 + 11;
+#endif
return (int)((next >> 16) & RAND_MAX);
}
-/* $Id: swprintf.c,v 1.12 2003/12/14 18:06:44 hbirr Exp $
+/* $Id: swprintf.c,v 1.13 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <internal/debug.h>
+#if defined(__GNUC__)
+typedef long long SWPRINT_INT64;
+typedef unsigned long long SWPRINT_UINT64;
+#else
+typedef __int64 SWPRINT_INT64;
+typedef unsigned __int64 SWPRINT_UINT64;
+#endif
+
+
#define ZEROPAD 1 /* pad with zero */
#define SIGN 2 /* unsigned/signed long */
#define PLUS 4 /* show plus */
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
+#if defined(__GNUC__)
+
#define do_div(n,base) ({ \
int __res; \
-__res = ((unsigned long long) n) % (unsigned) base; \
-n = ((unsigned long long) n) / (unsigned) base; \
+__res = ((SWPRINT_UINT64) n) % (unsigned) base; \
+n = ((SWPRINT_UINT64) n) / (unsigned) base; \
__res; })
+#elif defined(_MSC_VER)
+
+static __inline int do_foo_div(SWPRINT_INT64* n, int base)
+{
+ int __res = (int)(((SWPRINT_UINT64) *n) % (unsigned) base);
+ *n = (int)(((SWPRINT_UINT64) *n) / (unsigned) base);
+ return __res;
+}
+#define do_div(n,base) do_foo_div(&n,base)
+
+#else
+#error Unknown compiler for this special compiler trickery
+#endif
+
+
static int skip_atoi(const wchar_t **s)
{
static wchar_t *
-number(wchar_t * buf, wchar_t * end, long long num, int base, int size, int precision, int type)
+number(wchar_t * buf, wchar_t * end, SWPRINT_INT64 num, int base, int size, int precision, int type)
{
wchar_t c,sign, tmp[66];
const wchar_t *digits;
int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args)
{
int len;
- unsigned long long num;
+ SWPRINT_UINT64 num;
int base;
wchar_t * str, * end;
const char *s;
}
if (qualifier == 'I')
- num = va_arg(args, unsigned long long);
+ num = va_arg(args, SWPRINT_UINT64);
else if (qualifier == 'l')
num = va_arg(args, unsigned long);
else if (qualifier == 'h') {
-/* $Id: time.c,v 1.17 2003/07/11 01:23:16 royce Exp $
+/* $Id: time.c,v 1.18 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#define DAYSPERLEAPYEAR 366
#define MONSPERYEAR 12
+#if defined(__GNUC__)
#define TICKSTO1970 0x019db1ded53e8000LL
#define TICKSTO1980 0x01a8e79fe1d58000LL
+#else
+#define TICKSTO1970 0x019db1ded53e8000i64
+#define TICKSTO1980 0x01a8e79fe1d58000i64
+#endif
static const int YearLengths[2] = {DAYSPERNORMALYEAR, DAYSPERLEAPYEAR};
int LeapSecondCorrections, SecondsInDay, CurYear;
int LeapYear, CurMonth, GMTOffset;
long int Days;
+#if defined(__GNUC__)
long long int Time = (long long int)liTime->QuadPart;
+#else
+ __int64 Time = (__int64)liTime->QuadPart;
+#endif
/* Extract millisecond from time and convert time into seconds */
TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC);
PLARGE_INTEGER Time)
{
int CurMonth;
+#if defined(__GNUC__)
long long int rcTime;
+#else
+ __int64 rcTime;
+#endif
TIME_FIELDS TimeFields = *tfTimeFields;
const int *Months;
-/* $Id: unicode.c,v 1.33 2003/12/14 18:06:44 hbirr Exp $
+/* $Id: unicode.c,v 1.34 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
if ((Source->Length + Destination->Length) >= Destination->MaximumLength)
return STATUS_BUFFER_TOO_SMALL;
- memcpy((PVOID)Destination->Buffer + Destination->Length, Source->Buffer, Source->Length);
+ memcpy((char*)Destination->Buffer + Destination->Length, Source->Buffer, Source->Length);
Destination->Length += Source->Length;
Destination->Buffer[Destination->Length / sizeof(WCHAR)] = 0;
if (Destination->Length + slen >= Destination->MaximumLength)
return(STATUS_BUFFER_TOO_SMALL);
- memcpy((PVOID)Destination->Buffer + Destination->Length, Source, slen + sizeof(WCHAR));
+ memcpy((char*)Destination->Buffer + Destination->Length, Source, slen + sizeof(WCHAR));
Destination->Length += slen;
return(STATUS_SUCCESS);
-/* $Id: acl.c,v 1.13 2003/10/12 17:05:50 hbirr Exp $
+/* $Id: acl.c,v 1.14 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
return(TRUE);
}
- AclEnd = Acl->AclSize + (PVOID)Acl;
+ AclEnd = Acl->AclSize + (char*)Acl;
do
{
if ((PVOID)Current >= AclEnd)
return(FALSE);
}
}
- Current = (PACE)((PVOID)Current + (ULONG)Current->Header.AceSize);
+ Current = (PACE)((char*)Current + (ULONG)Current->Header.AceSize);
i++;
}
while (i < Acl->AceCount);
{
return(STATUS_UNSUCCESSFUL);
}
- if (((PVOID)Ace + RtlLengthSid(Sid) + sizeof(ACE)) >=
- ((PVOID)Acl + Acl->AclSize))
+ if (((char*)Ace + RtlLengthSid(Sid) + sizeof(ACE)) >=
+ ((char*)Acl + Acl->AclSize))
{
return(STATUS_BUFFER_TOO_SMALL);
}
{
AclRevision = Acl->AclRevision;
}
- if (((PVOID)AceList + AceListLength) <= (PVOID)AceList)
+ if ((PVOID)((char*)AceList + AceListLength) <= (PVOID)AceList)
{
return(STATUS_UNSUCCESSFUL);
}
i = 0;
Current = (PACE)(Acl + 1);
- while ((PVOID)Current < ((PVOID)AceList + AceListLength))
+ while ((char*)Current < ((char*)AceList + AceListLength))
{
if (AceList->Header.AceType == 4 &&
AclRevision < 3)
{
return(STATUS_UNSUCCESSFUL);
}
- Current = (PACE)((PVOID)Current + Current->Header.AceSize);
+ Current = (PACE)((char*)Current + Current->Header.AceSize);
}
if (Ace == NULL)
{
return(STATUS_UNSUCCESSFUL);
}
- if (((PVOID)Ace + AceListLength) >= ((PVOID)Acl + Acl->AclSize))
+ if (((char*)Ace + AceListLength) >= ((char*)Acl + Acl->AclSize))
{
return(STATUS_UNSUCCESSFUL);
}
Current = (PACE)(Acl + 1);
for (j = 0; j < StartingIndex; j++)
{
- Current = (PACE)((PVOID)Current + Current->Header.AceSize);
+ Current = (PACE)((char*)Current + Current->Header.AceSize);
}
}
}
-/* $Id: sd.c,v 1.12 2003/10/15 11:02:04 ekohl Exp $
+/* $Id: sd.c,v 1.13 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
Dacl = SecurityDescriptor->Dacl;
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
{
- Dacl = (PACL)((ULONG)Dacl + (PVOID)SecurityDescriptor);
+ Dacl = (PACL)((ULONG)Dacl + (char*)SecurityDescriptor);
}
Length = Length + ((Dacl->AclSize + 3) & 0xfc);
}
Sacl = SecurityDescriptor->Sacl;
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
{
- Sacl = (PACL)((ULONG)Sacl + (PVOID)SecurityDescriptor);
+ Sacl = (PACL)((ULONG)Sacl + (char*)SecurityDescriptor);
}
Length = Length + ((Sacl->AclSize + 3) & 0xfc);
}
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
{
*Dacl = (PACL)((ULONG)SecurityDescriptor->Dacl +
- (PVOID)SecurityDescriptor);
+ (char*)SecurityDescriptor);
}
else
{
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
{
*Owner = (PSID)((ULONG)SecurityDescriptor->Owner +
- (PVOID)SecurityDescriptor);
+ (char*)SecurityDescriptor);
}
else
{
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
{
*Group = (PSID)((ULONG)SecurityDescriptor->Group +
- (PVOID)SecurityDescriptor);
+ (char*)SecurityDescriptor);
}
else
{
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
{
*Sacl = (PACL)((ULONG)SecurityDescriptor->Sacl +
- (PVOID)SecurityDescriptor);
+ (char*)SecurityDescriptor);
}
else
{
-/* $Id: sid.c,v 1.15 2003/10/12 17:05:50 hbirr Exp $
+/* $Id: sid.c,v 1.16 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
Dest[i].Sid = SidArea;
Dest[i].Attributes = Src[i].Attributes;
RtlCopySid(RtlLengthSid(Src[i].Sid), SidArea, Src[i].Sid);
- SidArea = SidArea + RtlLengthSid(Src[i].Sid);
+ SidArea = (char*)SidArea + RtlLengthSid(Src[i].Sid);
}
*RemainingSidArea = SidArea;
*RemainingSidAreaSize = Length;
-/* $Id: token.c,v 1.31 2003/12/23 05:06:47 arty Exp $
+/* $Id: token.c,v 1.32 2003/12/30 18:52:06 fireball Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
Token->UserAndGroups,
TokenInformationLength,
TokenInformation,
- TokenInformation + 8,
+ (char*)TokenInformation + 8,
&UnusedInfo,
&uLength);
if (NT_SUCCESS(Status))
}
else
{
- EndMem = TokenInformation + Token->UserAndGroupCount * sizeof(SID_AND_ATTRIBUTES);
+ EndMem = (char*)TokenInformation + Token->UserAndGroupCount * sizeof(SID_AND_ATTRIBUTES);
PtrTokenGroups = (PTOKEN_GROUPS)TokenInformation;
PtrTokenGroups->GroupCount = Token->UserAndGroupCount - 1;
Status = RtlCopySidAndAttributesArray(Token->UserAndGroupCount - 1,
AccessToken->UserAndGroups[i].Sid = (PSID) SidArea;
AccessToken->UserAndGroups[i++].Attributes = 0;
RtlCopySid(uLocalSystemLength, SidArea, SeLocalSystemSid);
- SidArea += uLocalSystemLength;
+ SidArea = (char*)SidArea + uLocalSystemLength;
AccessToken->DefaultOwnerIndex = i;
AccessToken->UserAndGroups[i].Sid = (PSID) SidArea;
AccessToken->PrimaryGroup = (PSID) SidArea;
AccessToken->UserAndGroups[i++].Attributes = SE_GROUP_ENABLED|SE_GROUP_ENABLED_BY_DEFAULT;
Status = RtlCopySid(uAdminsLength, SidArea, SeAliasAdminsSid);
- SidArea += uAdminsLength;
+ SidArea = (char*)SidArea + uAdminsLength;
AccessToken->UserAndGroups[i].Sid = (PSID) SidArea;
AccessToken->UserAndGroups[i++].Attributes = SE_GROUP_ENABLED|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_MANDATORY;
RtlCopySid(uWorldLength, SidArea, SeWorldSid);
- SidArea += uWorldLength;
+ SidArea = (char*)SidArea + uWorldLength;
AccessToken->UserAndGroups[i].Sid = (PSID) SidArea;
AccessToken->UserAndGroups[i++].Attributes = SE_GROUP_ENABLED|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_MANDATORY;
RtlCopySid(uAuthUserLength, SidArea, SeAuthenticatedUserSid);
- SidArea += uAuthUserLength;
+ SidArea = (char*)SidArea + uAuthUserLength;
AccessToken->PrivilegeCount = 20;