brings code in line with release 12

svn path=/trunk/; revision=55
This commit is contained in:
Rex Jolliff 1998-10-05 04:50:07 +00:00
parent ee81c811cd
commit 3f988bd286
19 changed files with 959 additions and 348 deletions

View file

@ -127,6 +127,42 @@ typedef struct _IO_STACK_LOCATION
struct _VPB* Vpb;
struct _DEVICE_OBJECT* DeviceObject;
} Mount;
struct {
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
} QueryFile;
struct {
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} QueryVolume;
struct {
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} SetVolume;
struct {
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
struct FILE_OBJECT* FileObject;
union {
struct {
BOOLEAN ReplaceIfExists;
BOOLEAN AdvanceOnly;
} d;
ULONG ClusterCount;
HANDLE DeleteHandle;
} u;
} SetFile;
/*
* This is a guess
*/
struct
{
FILE_INFORMATION_CLASS FileInformationClass;
BOOLEAN ReturnSingleEntry;
PUNICODE_STRING FileName;
BOOLEAN RestartScan;
} QueryDirectory;
} Parameters;
PIO_COMPLETION_ROUTINE CompletionRoutine;

View file

@ -299,5 +299,30 @@ RtlFreeHeap(
PVOID Address
);
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString);
NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
OUT PULONG Value);
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString);
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString);
BOOLEAN RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor);
NTSTATUS RtlWriteRegistryValue(ULONG RelativeTo,
PWSTR Path,
PWSTR ValueName,
ULONG ValueType,
PVOID ValueData,
ULONG ValueLength);
VOID RtlStoreUlong(PULONG Address,
ULONG Value);
#endif /* __DDK_RTL_H */

View file

@ -23,15 +23,17 @@
#define DPRINT1(x)
#endif
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is umimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
#ifndef NDEBUG
#define DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); ExAllocatePool(NonPagedPool, 0); } while(0);
#define OLD_DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); } while(0);
#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); ExAllocatePool(NonPagedPool,0); } while(0);
//#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
#define CHECKPOINT do {DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool, 0); } while(0);
#define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
#else
#define DPRINT(fmt,args...)
#define DPRINT(args...)
#define OLD_DPRINT(args...)
#define assert(x)
#define CHECKPOINT
#endif /* NDEBUG */

View file

@ -567,10 +567,10 @@ l8:
dw 0x00eb,0x00eb ; jmp $+2, jmp $+2
out 0A0h,al ; and to 8259A-2
dw 0x00eb,0x00eb
mov al,020h ; start of hardware int's (0x20)
mov al,040h ; start of hardware int's (0x20)
out 021h,al
dw 0x00eb,0x00eb
mov al,028h ; start of hardware int's 2 (0x28)
mov al,048h ; start of hardware int's 2 (0x28)
out 0A1h,al
dw 0x00eb,0x00eb
mov al,04h ; 8259-1 is master
@ -626,6 +626,7 @@ next:
mov ss,ax
mov es,ax
mov fs,ax
mov gs,ax
;
; Initalize eflags

View file

@ -15,7 +15,7 @@ include rules.mak
#
# Required to run the system
#
COMPONENTS = kernel lib
COMPONENTS = iface_native ntoskrnl kernel32 ntdll crtdll mingw32
#
# Select the server(s) you want to build
@ -30,55 +30,79 @@ LOADERS = dos
#
# Select the device drivers and filesystems you want
#
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test minix
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test sdisk \
minix vfat
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES)
APPS = hello shell
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
clean: dummy
make -C iface/native clean
#
# Applications
#
hello: dummy
make -C apps/hello
cmd: dummy
make -C apps/cmd
shell: dummy
make -C apps/shell
#
# Interfaces
#
iface_native: dummy
make -C iface/native
#
# Device driver rules
#
vfat: dummy
make -C services/fs/vfat
sdisk: dummy
make -C services/sdisk
make -C services/dd/sdisk
minix: dummy
make -C services/fs/minix
template: dummy
make -C services/fs/template
ide-test: dummy
make -C services/ide-test
make -C services/dd/ide-test
ide: dummy
make -C services/ide
make -C services/dd/ide
test: dummy
make -C services/test
make -C services/dd/test
test1: dummy
make -C services/test1
make -C services/dd/test1
null: dummy
make -C services/null
make -C services/dd/null
parallel: dummy
make -C services/parallel
make -C services/dd/parallel
keyboard: dummy
make -C services/keyboard
make -C services/dd/keyboard
mouse: dummy
make -C services/mouse
make -C services/dd/mouse
serial: dummy
make -C services/serial
make -C services/dd/serial
sound: dummy
make -C services/sound
ide: dummy
make -C services/ide
ide-test: dummy
make -C services/ide-test
make -C services/dd/sound
#
# Kernel loaders
@ -91,10 +115,19 @@ dos: dummy
# Required system components
#
kernel: dummy
ntoskrnl: dummy
make -C ntoskrnl
lib: dummy
make -C lib
kernel32: dummy
make -C lib/kernel32
ntdll: dummy
make -C lib/ntdll
crtdll: dummy
make -C lib/crtdll
mingw32: dummy
make -C lib/mingw32
dummy:

View file

@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: mkernel/hal/irql.c
* FILE: ntoskrnl/hal/x86/irql.c
* PURPOSE: Implements IRQLs
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
@ -118,12 +118,12 @@ VOID KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
/*
* sanity check
*/
DPRINT("CurrentIrql %x NewIrql %x OldIrql %x\n",CurrentIrql,NewIrql,
OldIrql);
DPRINT("CurrentIrql %x NewIrql %x OldIrql %x\n",CurrentIrql,NewIrql,
OldIrql);
if (NewIrql < CurrentIrql)
{
DbgPrint("%s:%d CurrentIrql %x NewIrql %x OldIrql %x\n",__FILE__,__LINE__,
CurrentIrql,NewIrql,OldIrql);
DbgPrint("%s:%d CurrentIrql %x NewIrql %x OldIrql %x\n",
__FILE__,__LINE__,CurrentIrql,NewIrql,OldIrql);
for(;;);
}

View file

@ -17,6 +17,13 @@
/* FUNCTIONS *****************************************************************/
NTSTATUS IoPrepareIrpBuffer(PIRP Irp,
PDEVICE_OBJECT DeviceObject,
PVOID Buffer,
PVOID Length)
{
}
PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
PDEVICE_OBJECT DeviceObject,
PKEVENT UserEvent,
@ -27,6 +34,10 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
* ARGUMENTS:
* MinorFunction = Type of filesystem control
* DeviceObject = Device object to send the request to
* UserEvent = Event used to notify the caller of completion
* IoStatusBlock (OUT) = Used to return the status of the operation
* DeviceToMount = Device to mount (for the IRP_MN_MOUNT_DEVICE
* request)
*/
{
PIRP Irp;
@ -48,9 +59,23 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = NULL;
StackPtr->Parameters.Mount.Vpb = DeviceObject->Vpb;
StackPtr->Parameters.Mount.DeviceObject = DeviceToMount;
switch(MinorFunction)
{
case IRP_MN_USER_FS_REQUEST:
break;
case IRP_MN_MOUNT_VOLUME:
StackPtr->Parameters.Mount.Vpb = DeviceObject->Vpb;
StackPtr->Parameters.Mount.DeviceObject = DeviceToMount;
break;
case IRP_MN_VERIFY_VOLUME:
break;
case IRP_MN_LOAD_FILE_SYSTEM:
break;
}
return(Irp);
}
@ -74,40 +99,20 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
* NULL on failure
*/
{
PIRP Irp;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
DPRINT("IoBuildAsynchronousFsdRequest(MajorFunction %x, DeviceObject %x, "
"Buffer %x, Length %x, StartingOffset %x, "
"IoStatusBlock %x\n",MajorFunction,DeviceObject,Buffer,Length,
StartingOffset,IoStatusBlock);
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
if (Irp==NULL)
{
return(NULL);
}
Irp->UserBuffer = (LPVOID)Buffer;
if (DeviceObject->Flags&DO_BUFFERED_IO)
{
DPRINT("Doing buffer i/o\n",0);
Irp->AssociatedIrp.SystemBuffer = (PVOID)
ExAllocatePool(NonPagedPool,Length);
if (Irp->AssociatedIrp.SystemBuffer==NULL)
{
return(NULL);
}
Irp->UserBuffer = NULL;
}
if (DeviceObject->Flags&DO_DIRECT_IO)
{
DPRINT("Doing direct i/o\n",0);
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
Irp->UserBuffer = NULL;
Irp->AssociatedIrp.SystemBuffer = NULL;
}
Irp->UserIosb = IoStatusBlock;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
StackPtr->MinorFunction = 0;
@ -116,19 +121,45 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = NULL;
StackPtr->Parameters.Write.Length = Length;
if (StartingOffset!=NULL)
{
StackPtr->Parameters.Write.ByteOffset.LowPart =
StartingOffset->LowPart;
StackPtr->Parameters.Write.ByteOffset.HighPart =
StartingOffset->HighPart;
}
else
{
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
}
if (MajorFunction == IRP_MJ_READ || MajorFunction == IRP_MJ_WRITE)
{
Irp->UserBuffer = (LPVOID)Buffer;
if (DeviceObject->Flags&DO_BUFFERED_IO)
{
DPRINT("Doing buffer i/o\n",0);
Irp->AssociatedIrp.SystemBuffer = (PVOID)
ExAllocatePool(NonPagedPool,Length);
if (Irp->AssociatedIrp.SystemBuffer==NULL)
{
return(NULL);
}
}
if (DeviceObject->Flags&DO_DIRECT_IO)
{
DPRINT("Doing direct i/o\n",0);
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
Irp->UserBuffer = NULL;
Irp->AssociatedIrp.SystemBuffer = NULL;
}
if (StartingOffset!=NULL)
{
StackPtr->Parameters.Write.ByteOffset.LowPart =
StartingOffset->LowPart;
StackPtr->Parameters.Write.ByteOffset.HighPart =
StartingOffset->HighPart;
}
else
{
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
}
}
Irp->UserIosb = IoStatusBlock;
return(Irp);
}
@ -215,9 +246,6 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
Irp->AssociatedIrp.SystemBuffer = NULL;
}
Irp->UserIosb = IoStatusBlock;
Irp->UserEvent = Event;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
StackPtr->MinorFunction = 0;

View file

@ -30,6 +30,7 @@
/* INCLUDES ****************************************************************/
#include <internal/string.h>
#include <internal/io.h>
#include <ddk/ntddk.h>
//#define NDEBUG
@ -79,7 +80,12 @@ VOID IoMarkIrpPending(PIRP Irp)
* Irp = Irp to mark
*/
{
DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
IoGetCurrentIrpStackLocation(Irp));
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
DPRINT("IoGetCurrentIrpStackLocation(Irp)->Control %x\n",
IoGetCurrentIrpStackLocation(Irp)->Control);
DPRINT("SL_PENDING_RETURNED %x\n",SL_PENDING_RETURNED);
}
USHORT IoSizeOfIrp(CCHAR StackSize)
@ -156,7 +162,6 @@ NTSTATUS IoCallDriver(PDEVICE_OBJECT DevObject, PIRP irp)
DPRINT("Io stack address %x\n",param);
DPRINT("Function %d Routine %x\n",param->MajorFunction,
drv->MajorFunction[param->MajorFunction]);
DPRINT("IRP_MJ_CREATE %d\n",IRP_MJ_CREATE);
return(drv->MajorFunction[param->MajorFunction](DevObject,irp));
}
@ -208,7 +213,7 @@ VOID IoSetCompletionRoutine(PIRP Irp,
param->CompletionContext=Context;
if (InvokeOnSuccess)
{
param->Control = SL_INVOKE_ON_SUCCESS;
param->Control = param->Control | SL_INVOKE_ON_SUCCESS;
}
if (InvokeOnError)
{
@ -220,6 +225,16 @@ VOID IoSetCompletionRoutine(PIRP Irp,
}
}
VOID IopCompleteRequest(struct _KAPC* Apc,
PKNORMAL_ROUTINE* NormalRoutine,
PVOID* NormalContext,
PVOID* SystemArgument1,
PVOID* SystemArgument2)
{
IoSecondStageCompletion((PIRP)(*NormalContext),
IO_NO_INCREMENT);
}
VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
/*
* FUNCTION: Indicates the caller has finished all processing for a given
@ -231,20 +246,47 @@ VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
*/
{
unsigned int i;
NTSTATUS Status;
DPRINT("IoCompleteRequest(Irp %x, PriorityBoost %d)\n",
Irp,PriorityBoost);
Irp,PriorityBoost);
for (i=0;i<Irp->StackCount;i++)
{
DPRINT("&Irp->Stack[i] %x\n",&Irp->Stack[i]);
if (Irp->Stack[i].CompletionRoutine!=NULL)
{
Irp->Stack[i].CompletionRoutine(Irp->Stack[i].DeviceObject,Irp,
Status = Irp->Stack[i].CompletionRoutine(
Irp->Stack[i].DeviceObject,
Irp,
Irp->Stack[i].CompletionContext);
if (Status == STATUS_MORE_PROCESSING_REQUIRED)
{
return;
}
}
DPRINT("Irp->Stack[i].Control %x\n",Irp->Stack[i].Control);
if (Irp->Stack[i].Control & SL_PENDING_RETURNED)
{
DPRINT("Setting PendingReturned flag\n");
Irp->PendingReturned = TRUE;
}
}
if (Irp->UserEvent!=NULL)
if (Irp->PendingReturned)
{
KeSetEvent(Irp->UserEvent,PriorityBoost,FALSE);
KeInitializeApc(&Irp->Tail.Apc,
&Irp->Tail.Overlay.Thread->Tcb,
0,
IopCompleteRequest,
NULL,
NULL,
0,
Irp);
KeInsertQueueApc(&Irp->Tail.Apc,NULL,NULL,0);
}
else
{
IoSecondStageCompletion(Irp,PriorityBoost);
}
}

View file

@ -74,7 +74,7 @@ VOID IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable)
else
{
DeviceObject->CurrentIrp = NULL;
}
}
}
VOID IoStartPacket(PDEVICE_OBJECT DeviceObject,

View file

@ -21,39 +21,25 @@
/* FUNCTIONS ***************************************************************/
static VOID IoSecondStageCompletion(PIRP Irp,
BOOLEAN FromDevice,
PDEVICE_OBJECT DeviceObject,
ULONG Length,
PVOID Buffer)
/*
* FUNCTION: Performs the second stage of irp completion for read/write irps
* ARGUMENTS:
* Irp = Irp to completion
* FromDevice = True if the operation transfered data from the device
*/
NTSTATUS NtReadFile(HANDLE FileHandle,
HANDLE EventHandle,
PIO_APC_ROUTINE ApcRoutine,
PVOID ApcContext,
PIO_STATUS_BLOCK IoStatusBlock,
PVOID Buffer,
ULONG Length,
PLARGE_INTEGER ByteOffset,
PULONG Key)
{
if (Irp->UserIosb!=NULL)
{
*Irp->UserIosb=Irp->IoStatus;
}
if (DeviceObject->Flags & DO_BUFFERED_IO && FromDevice)
{
memcpy(Buffer,Irp->AssociatedIrp.SystemBuffer,Length);
}
if (DeviceObject->Flags & DO_DIRECT_IO)
{
if (Irp->MdlAddress->MappedSystemVa!=NULL)
{
MmUnmapLockedPages(Irp->MdlAddress->MappedSystemVa,
Irp->MdlAddress);
}
MmUnlockPages(Irp->MdlAddress);
ExFreePool(Irp->MdlAddress);
}
IoFreeIrp(Irp);
return(ZwReadFile(FileHandle,
EventHandle,
ApcRoutine,
ApcContext,
IoStatusBlock,
Buffer,
Length,
ByteOffset,
Key));
}
NTSTATUS ZwReadFile(HANDLE FileHandle,
@ -77,10 +63,15 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
"IoStatusBlock %x)\n",
FileHandle,Buffer,Length,ByteOffset,IoStatusBlock);
if (hdr==NULL)
Status = ObReferenceObjectByHandle(FileHandle,
FILE_READ_DATA,
NULL,
UserMode,
&FileObject,
NULL);
if (Status != STATUS_SUCCESS)
{
DPRINT("%s() = STATUS_INVALID_HANDLE\n",__FUNCTION__);
return(STATUS_INVALID_HANDLE);
return(Status);
}
if (ByteOffset==NULL)
@ -89,6 +80,7 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
}
KeInitializeEvent(&Event,NotificationEvent,FALSE);
DPRINT("FileObject %x\n",FileObject);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
FileObject->DeviceObject,
Buffer,
@ -136,6 +128,27 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
return(Status);
}
NTSTATUS NtWriteFile(HANDLE FileHandle,
HANDLE EventHandle,
PIO_APC_ROUTINE ApcRoutine,
PVOID ApcContext,
PIO_STATUS_BLOCK IoStatusBlock,
PVOID Buffer,
ULONG Length,
PLARGE_INTEGER ByteOffset,
PULONG Key)
{
return(ZwWriteFile(FileHandle,
EventHandle,
ApcRoutine,
ApcContext,
IoStatusBlock,
Buffer,
Length,
ByteOffset,
Key));
}
NTSTATUS ZwWriteFile(HANDLE FileHandle,
HANDLE EventHandle,
PIO_APC_ROUTINE ApcRoutine,
@ -168,7 +181,7 @@ NTSTATUS ZwWriteFile(HANDLE FileHandle,
IoStatusBlock);
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
Status = IoCallDriver(FileObject->DeviceObject,Irp);
if (Status==STATUS_PENDING)
if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = Irp->IoStatus.Status;
@ -176,3 +189,71 @@ NTSTATUS ZwWriteFile(HANDLE FileHandle,
return(Status);
}
NTSTATUS STDCALL NtReadFileScatter(IN HANDLE FileHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
IN PVOID UserApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK UserIoStatusBlock,
IN FILE_SEGMENT_ELEMENT BufferDescription[],
IN ULONG BufferLength,
IN PLARGE_INTEGER ByteOffset,
IN PULONG Key OPTIONAL)
{
return(ZwReadFileScatter(FileHandle,
Event,
UserApcRoutine,
UserApcContext,
UserIoStatusBlock,
BufferDescription,
BufferLength,
ByteOffset,
Key));
}
NTSTATUS STDCALL ZwReadFileScatter(IN HANDLE FileHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
IN PVOID UserApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK UserIoStatusBlock,
IN FILE_SEGMENT_ELEMENT BufferDescription[],
IN ULONG BufferLength,
IN PLARGE_INTEGER ByteOffset,
IN PULONG Key OPTIONAL)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL NtWriteFileGather(IN HANDLE FileHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN FILE_SEGMENT_ELEMENT BufferDescription[],
IN ULONG BufferLength,
IN PLARGE_INTEGER ByteOffset,
IN PULONG Key OPTIONAL)
{
return(ZwWriteFileGather(FileHandle,
Event,
ApcRoutine,
ApcContext,
IoStatusBlock,
BufferDescription,
BufferLength,
ByteOffset,
Key));
}
NTSTATUS STDCALL ZwWriteFileGather(IN HANDLE FileHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN FILE_SEGMENT_ELEMENT BufferDescription[],
IN ULONG BufferLength,
IN PLARGE_INTEGER ByteOffset,
IN PULONG Key OPTIONAL)
{
UNIMPLEMENTED;
}

View file

@ -2,7 +2,7 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/vpb.c
* PURPOSE: Volume Parameters Block managment
* PURPOSE: Volume Parameter Block managment
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
@ -12,6 +12,7 @@
#include <ddk/ntddk.h>
#include <internal/string.h>
#include <internal/ob.h>
#include <internal/debug.h>
@ -39,3 +40,189 @@ NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject)
DeviceObject->Vpb = Vpb;
}
PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction,
PFILE_OBJECT FileObject,
PVOID FSInformation,
ULONG Length,
CINT FSInformationClass,
PIO_STATUS_BLOCK IoStatusBlock,
PKEVENT Event)
{
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
PDEVICE_OBJECT DeviceObject;
DeviceObject = FileObject->DeviceObject;
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
if (Irp==NULL)
{
return(NULL);
}
Irp->AssociatedIrp.SystemBuffer = FSInformation;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = FileObject;
Irp->UserEvent = Event;
Irp->UserIosb = IoStatusBlock;
if (MajorFunction == IRP_MJ_QUERY_VOLUME_INFORMATION)
{
StackPtr->Parameters.SetVolume.Length = Length;
StackPtr->Parameters.SetVolume.FileInformationClass =
FSInformationClass;
}
else
{
StackPtr->Parameters.QueryVolume.Length = Length;
StackPtr->Parameters.QueryVolume.FileInformationClass =
FSInformationClass;
}
return(Irp);
}
NTSTATUS STDCALL NtQueryVolumeInformationFile(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FSInformation,
IN ULONG Length,
IN CINT FSInformationClass)
/*
* FUNCTION: Queries the volume information
* ARGUMENTS:
* FileHandle = Handle to a file object on the target volume
* ReturnLength = DataWritten
* FSInformation = Caller should supply storage for the information
* structure.
* Length = Size of the information structure
* FSInformationClass = Index to a information structure
*
* FileFsVolumeInformation FILE_FS_VOLUME_INFORMATION
* FileFsLabelInformation FILE_FS_LABEL_INFORMATION
* FileFsSizeInformation FILE_FS_SIZE_INFORMATION
* FileFsDeviceInformation FILE_FS_DEVICE_INFORMATION
* FileFsAttributeInformation FILE_FS_ATTRIBUTE_INFORMATION
* FileFsControlInformation
* FileFsQuotaQueryInformation --
* FileFsQuotaSetInformation --
* FileFsMaximumInformation
*
* RETURNS: Status
*/
{
return(ZwQueryVolumeInformationFile(FileHandle,IoStatusBlock,FSInformation,
Length,FSInformationClass));
}
NTSTATUS
STDCALL
ZwQueryVolumeInformationFile(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FSInformation,
IN ULONG Length,
IN CINT FSInformationClass)
{
PFILE_OBJECT FileObject;
PDEVICE_OBJECT DeviceObject;
PIRP Irp;
KEVENT Event;
NTSTATUS Status;
Status = ObReferenceObjectByHandle(FileHandle,
FILE_READ_ATTRIBUTES,
NULL,
UserMode,
(PVOID*)&FileObject,
NULL);
if (Status != STATUS_SUCCESS)
{
return(Status);
}
DeviceObject = FileObject->DeviceObject;
KeInitializeEvent(&Event,NotificationEvent,FALSE);
Irp = IoBuildVolumeInformationIrp(IRP_MJ_QUERY_VOLUME_INFORMATION,
FileObject,
FSInformation,
Length,
FSInformationClass,
IoStatusBlock,
&Event);
Status = IoCallDriver(DeviceObject,Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,UserRequest,KernelMode,FALSE,NULL);
Status = IoStatusBlock->Status;
}
return(Status);
}
NTSTATUS
STDCALL
NtSetVolumeInformationFile(
IN HANDLE FileHandle,
IN CINT VolumeInformationClass,
PVOID VolumeInformation,
ULONG Length
)
{
return(ZwSetVolumeInformationFile(FileHandle,VolumeInformationClass,
VolumeInformation,Length));
}
NTSTATUS
STDCALL
ZwSetVolumeInformationFile(
IN HANDLE FileHandle,
IN CINT VolumeInformationClass,
PVOID VolumeInformation,
ULONG Length
)
{
PFILE_OBJECT FileObject;
PDEVICE_OBJECT DeviceObject;
PIRP Irp;
KEVENT Event;
NTSTATUS Status;
Status = ObReferenceObjectByHandle(FileHandle,
FILE_WRITE_ATTRIBUTES,
NULL,
UserMode,
(PVOID*)&FileObject,
NULL);
if (Status != STATUS_SUCCESS)
{
return(Status);
}
DeviceObject = FileObject->DeviceObject;
KeInitializeEvent(&Event,NotificationEvent,FALSE);
Irp = IoBuildVolumeInformationIrp(IRP_MJ_SET_VOLUME_INFORMATION,
FileObject,
VolumeInformation,
Length,
VolumeInformationClass,
NULL,
&Event);
Status = IoCallDriver(DeviceObject,Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,UserRequest,KernelMode,FALSE,NULL);
}
return(Status);
}

View file

@ -19,8 +19,8 @@
#include <internal/symbol.h>
#include <internal/module.h>
#include <internal/hal/page.h>
#include <internal/hal/segment.h>
#include <internal/mmhal.h>
#include <internal/i386/segment.h>
//#define NDEBUG
#include <internal/debug.h>
@ -134,7 +134,9 @@ asmlinkage void _main(boot_param* _bp)
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
if (start < ((int)&end))
{
DbgPrint("start %x end %x\n",start,(int)&end);
DbgPrint("Kernel booted incorrectly, aborting\n");
DbgPrint("Reduce the amount of uninitialized data\n");
for(;;);
}
DPRINT("MmGetPhysicalAddress(start) = %x\n",MmGetPhysicalAddress(start));
@ -187,5 +189,5 @@ asmlinkage void _main(boot_param* _bp)
* Enter idle loop
*/
printk("Finished main()\n");
for (;;);
PsTerminateSystemThread(STATUS_SUCCESS);
}

View file

@ -78,7 +78,7 @@ static unsigned int get_symbol_value_by_name(module* mod, char* sname,
for (i=0; i<mod->nsyms; i++)
{
get_symbol_name(mod,i,name);
// DPRINT("Scanning %s Value %x\n",name,mod->sym_list[i].e_value);
DPRINT("Scanning %s Value %x\n",name,mod->sym_list[i].e_value);
if (strcmp(name,sname)==0)
{
DPRINT("Returning %x\n",mod->sym_list[i].e_value);
@ -368,7 +368,7 @@ BOOLEAN process_boot_module(unsigned int start)
}
}
DPRINT("Allocate base: %x\n",mod->base);
DbgPrint("Module base: %x\n",mod->base);
/*
* Find the entry point

View file

@ -1,4 +1,3 @@
all: kimage
#
@ -6,6 +5,10 @@ all: kimage
#
include hal/x86/sources
NT_OBJECTS = nt/port.o nt/channel.o nt/ntevent.o nt/nttimer.o nt/atom.o \
nt/evtpair.o nt/ntsem.o nt/mutant.o nt/misc.o nt/plugplay.o \
nt/profile.o
RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \
rtl/time.o rtl/unalign.o rtl/mem.o rtl/largeint.o rtl/ctype.o \
rtl/list.o rtl/slist.o rtl/interlck.o rtl/return.o \
@ -14,30 +17,33 @@ RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \
KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o ke/exports.o \
ke/module.o ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \
ke/sem.o ke/critical.o ke/event.o ke/apc.o ke/bug.o \
ke/mutex.o ke/kernel.o
ke/mutex.o ke/kernel.o ke/ldt.o ke/apchelp.o
MM_OBJECTS = mm/mm.o mm/freelist.o mm/pool.o mm/virtual.o \
mm/mdl.o mm/zone.o mm/special.o mm/paging.o \
mm/section.o mm/marea.o mm/ppool.o mm/npool.o
MM_OBJECTS = mm/mm.o mm/freelist.o mm/pool.o mm/pageflt.o mm/virtual.o \
mm/mdl.o mm/zone.o mm/special.o \
mm/section.o mm/marea.o
IO_OBJECTS = io/iomgr.o io/create.o io/irp.o io/device.o io/rw.o \
io/queue.o io/drvlck.o io/timer.o io/share.o io/errlog.o \
io/shutdown.o io/fdisk.o io/cancel.o io/error.o io/arc.o \
io/dpc.o io/symlink.o io/adapter.o io/cntrller.o io/mdl.o \
io/resource.o io/event.o io/process.o io/file.o io/ioctrl.o \
io/fs.o io/vpb.o io/buildirp.o
io/fs.o io/vpb.o io/buildirp.o io/flush.o io/dir.o io/iocomp.o \
io/mailslot.o io/npipe.o io/lock.o io/page.o io/cleanup.o
OB_OBJECTS = ob/object.o ob/handle.o ob/namespc.o
PS_OBJECTS = ps/psmgr.o ps/thread.o ps/process.o ps/idle.o
PS_OBJECTS = ps/psmgr.o ps/thread.o ps/process.o ps/idle.o ps/kill.o \
ps/tinfo.o
EX_OBJECTS = ex/work.o ex/fmutex.o ex/resource.o ex/time.o ex/interlck.o \
ex/callback.o
ex/callback.o ex/napi.o ex/power.o ex/sysinfo.o ex/locale.o \
ex/stamp.o
SE_OBJECTS = se/semgr.o
CFG_OBJECTS = cfg/registry.o
CM_OBJECTS = cm/registry.o
TST_OBJECTS = tst/test.o tst/sshell.o tst/readline.o
@ -45,10 +51,56 @@ DBG_OBJECTS = dbg/brkpoint.o
LDR_OBJECTS = ldr/loader.o
OBJECTS = $(HAL_OBJECTS) $(KE_OBJECTS) $(RTL_OBJECTS) $(MM_OBJECTS) \
$(IO_OBJECTS) $(OB_OBJECTS) $(PS_OBJECTS) $(EX_OBJECTS) \
$(SE_OBJECTS) $(CFG_OBJECTS) $(TST_OBJECTS) $(DBG_OBJECTS)
CC_OBJECTS = cc/cacheman.o cc/block.o
objects/hal.o: $(HAL_OBJECTS)
$(LD) -r $(HAL_OBJECTS) -o objects/hal.o
objects/io.o: $(IO_OBJECTS)
$(LD) -r $(IO_OBJECTS) -o objects/io.o
objects/ke.o: $(KE_OBJECTS)
$(LD) -r $(KE_OBJECTS) -o objects/ke.o
objects/rtl.o: $(RTL_OBJECTS)
$(LD) -r $(RTL_OBJECTS) -o objects/rtl.o
objects/mm.o: $(MM_OBJECTS)
$(LD) -r $(MM_OBJECTS) -o objects/mm.o
objects/ob.o: $(OB_OBJECTS)
$(LD) -r $(OB_OBJECTS) -o objects/ob.o
objects/ps.o: $(PS_OBJECTS)
$(LD) -r $(PS_OBJECTS) -o objects/ps.o
objects/ex.o: $(EX_OBJECTS)
$(LD) -r $(EX_OBJECTS) -o objects/ex.o
objects/se.o: $(SE_OBJECTS)
$(LD) -r $(SE_OBJECTS) -o objects/se.o
objects/cm.o: $(CM_OBJECTS)
$(LD) -r $(CM_OBJECTS) -o objects/cm.o
objects/tst.o: $(TST_OBJECTS)
$(LD) -r $(TST_OBJECTS) -o objects/tst.o
objects/dbg.o: $(DBG_OBJECTS)
$(LD) -r $(DBG_OBJECTS) -o objects/dbg.o
objects/nt.o: $(NT_OBJECTS)
$(LD) -r $(NT_OBJECTS) -o objects/nt.o
objects/cc.o: $(CC_OBJECTS)
$(LD) -r $(CC_OBJECTS) -o objects/cc.o
OBJECTS = objects/hal.o objects/ke.o objects/rtl.o objects/mm.o \
objects/io.o objects/ob.o objects/ps.o objects/ex.o \
objects/se.o objects/cm.o objects/tst.o objects/dbg.o\
objects/nt.o objects/cc.o
utils/export/export$(EXE_POSTFIX): utils/export/export.c
$(NATIVE_CC) -g utils/export/export.c -o utils/export/export$(EXE_POSTFIX)
@ -57,10 +109,18 @@ ke/exports.o: exports.lst utils/export/export$(EXE_POSTFIX)
$(CC) $(CFLAGS) -c ke/exports.c -o ke/exports.o
kimage: $(OBJECTS)
$(LD) --defsym _end=end --defsym _etext=etext --oformat=$(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) libgcc.a -o kimage
$(LD) --defsym _end=end --defsym _etext=etext --oformat=$(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) $(LIBGCC) -o kimage
$(OBJCOPY) -S --gap-fill=0 -O binary kimage kimage.bin
old_kimage: $(OBJECTS)
$(LD) --defsym _end=end --defsym _etext=etext --oformat=$(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) $(LIBGCC) -o kimage
$(NM) --numeric-sort kimage > kernel.sym
$(OBJCOPY) -S --gap-fill=0 -O binary kimage kimage.bin
dummy:
ex/napi.o: ex/napi.c ../include/ntdll/napi.h
WITH_DEBUGGING = yes
WIN32_LEAN_AND_MEAN = yes
include ../rules.mak

View file

@ -12,7 +12,7 @@
#include <ddk/ntddk.h>
#include <internal/mm.h>
#include <internal/hal/page.h>
#include <internal/mmhal.h>
#define NDEBUG
#include <internal/debug.h>
@ -24,23 +24,25 @@ static KSPIN_LOCK SystemAreaListLock = {0,};
/* FUNCTIONS *****************************************************************/
VOID MmDumpMemoryAreas(VOID)
VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
{
PLIST_ENTRY current_entry;
MEMORY_AREA* current;
PLIST_ENTRY ListHead = &SystemAreaList;
ULONG i;
DbgPrint("MmDumpMemoryAreas()\n");
current_entry = ListHead->Flink;
while (current_entry!=ListHead)
{
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
DPRINT("Base %x Length %x End %x Attributes %x Flink %x\n",
DbgPrint("Base %x Length %x End %x Attributes %x Flink %x\n",
current->BaseAddress,current->Length,
current->BaseAddress+current->Length,current->Attributes,
current->Entry.Flink);
current_entry = current_entry->Flink;
}
DbgPrint("Finished MmDumpMemoryAreas()\n");
}
VOID MmLockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
@ -71,8 +73,36 @@ VOID MmUnlockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
}
VOID MmLockMemoryAreaListByMode(KPROCESSOR_MODE Mode, PKIRQL oldlvl)
{
if (Mode == KernelMode)
{
KeAcquireSpinLock(&SystemAreaListLock,oldlvl);
}
else
{
PKPROCESS CurrentProcess = KeGetCurrentProcess();
KeAcquireSpinLock(&(CurrentProcess->SpinLock),oldlvl);
}
}
static PLIST_ENTRY MmGetRelatedListHead(ULONG BaseAddress)
VOID MmUnlockMemoryAreaListByMode(KPROCESSOR_MODE Mode, PKIRQL oldlvl)
{
if (Mode == KernelMode)
{
KeReleaseSpinLock(&SystemAreaListLock,*oldlvl);
}
else
{
PKPROCESS CurrentProcess = KeGetCurrentProcess();
KeReleaseSpinLock(&(CurrentProcess->SpinLock),*oldlvl);
}
}
static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, ULONG BaseAddress)
{
if (BaseAddress >= KERNEL_BASE)
{
@ -80,12 +110,7 @@ static PLIST_ENTRY MmGetRelatedListHead(ULONG BaseAddress)
}
else
{
PEPROCESS CurrentProcess = PsGetCurrentProcess();
if (CurrentProcess==NULL)
{
return(NULL);
}
return(&(CurrentProcess->Pcb.MemoryAreaList));
return(&(Process->Pcb.MemoryAreaList));
}
}
@ -95,7 +120,7 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
PLIST_ENTRY current_entry;
MEMORY_AREA* current;
MmDumpMemoryAreas();
// MmDumpMemoryAreas();
DPRINT("MmInternalOpenMemoryAreaByAddress(ListHead %x, Address %x)\n",
ListHead,Address);
@ -112,14 +137,17 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
if (current->BaseAddress <= Address &&
(current->BaseAddress + current->Length) > Address)
{
DPRINT("%s() = %x\n",__FUNCTION__,current);
return(current);
}
if (current->BaseAddress > Address)
{
DPRINT("%s() = NULL\n",__FUNCTION__);
return(NULL);
}
current_entry = current_entry->Flink;
}
DPRINT("%s() = NULL\n",__FUNCTION__);
return(NULL);
}
@ -132,69 +160,80 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
MEMORY_AREA* current;
ULONG Extent;
DPRINT("MmInternalOpenMemoryAreaByRegion()\n",0);
DPRINT("MmInternalOpenMemoryAreaByRegion(ListHead %x, Address %x, "
"Length %x)\n",ListHead,Address,Length);
MmDumpMemoryAreas();
// MmDumpMemoryAreas();
current_entry = ListHead->Flink;
while (current_entry!=ListHead)
{
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
DPRINT("current->BaseAddress %x current->Length %x\n",
current->BaseAddress,current->Length);
if (current->BaseAddress >= Address &&
current->BaseAddress <= (Address+Length))
{
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
current);
return(current);
}
Extent = current->BaseAddress + current->Length;
if (Extent > Address &&
Extent < (Address+Length))
{
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
current);
return(current);
}
if (current->BaseAddress <= Address &&
Extent >= (Address+Length))
{
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
current);
return(current);
}
if (current->BaseAddress >= (Address+Length))
{
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()= NULL\n",0);
return(NULL);
}
current_entry = current_entry->Flink;
}
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = NULL\n",0);
return(NULL);
}
MEMORY_AREA* MmOpenMemoryAreaByRegion(ULONG Address, ULONG Length)
MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process, ULONG Address,
ULONG Length)
{
KIRQL oldlvl;
MEMORY_AREA* Result;
PLIST_ENTRY ListHead;
DPRINT("MmOpenMemoryByRegion(Process %x, Address %x, Length %x)\n",
Process,Address,Length);
MmLockMemoryAreaList(Address,&oldlvl);
ListHead = MmGetRelatedListHead(Address);
ListHead = MmGetRelatedListHead(Process,Address);
Result = MmInternalOpenMemoryAreaByRegion(ListHead,Address,Length);
MmUnlockMemoryAreaList(Address,&oldlvl);
return(Result);
}
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(ULONG Address, ULONG Length)
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(PEPROCESS Process,
ULONG Address, ULONG Length)
{
MEMORY_AREA* Result;
PLIST_ENTRY ListHead;
ListHead = MmGetRelatedListHead(Address);
ListHead = MmGetRelatedListHead(Process, Address);
Result = MmInternalOpenMemoryAreaByRegion(ListHead,Address,Length);
return(Result);
}
MEMORY_AREA* MmOpenMemoryAreaByAddress(ULONG Address)
MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address)
{
KIRQL oldlvl;
MEMORY_AREA* Result;
@ -203,23 +242,25 @@ MEMORY_AREA* MmOpenMemoryAreaByAddress(ULONG Address)
DPRINT("MmOpenMemoryAreaByAddress(Address %x)\n",Address);
MmLockMemoryAreaList(Address,&oldlvl);
ListHead = MmGetRelatedListHead(Address);
ListHead = MmGetRelatedListHead(Process, Address);
Result = MmInternalOpenMemoryAreaByAddress(ListHead,Address);
MmUnlockMemoryAreaList(Address,&oldlvl);
return(Result);
}
MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(ULONG Address)
MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(PEPROCESS Process,
ULONG Address)
{
MEMORY_AREA* Result;
PLIST_ENTRY ListHead;
ListHead = MmGetRelatedListHead(Address);
ListHead = MmGetRelatedListHead(Process, Address);
Result = MmInternalOpenMemoryAreaByAddress(ListHead,Address);
return(Result);
}
static VOID MmInsertMemoryAreaWithoutLock(MEMORY_AREA* marea)
static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
MEMORY_AREA* marea)
{
PLIST_ENTRY ListHead;
PLIST_ENTRY current_entry;
@ -231,7 +272,7 @@ static VOID MmInsertMemoryAreaWithoutLock(MEMORY_AREA* marea)
DPRINT("marea->BaseAddress %x\n",marea->BaseAddress);
DPRINT("marea->Length %x\n",marea->Length);
ListHead=MmGetRelatedListHead(marea->BaseAddress);
ListHead=MmGetRelatedListHead(Process,marea->BaseAddress);
current_entry = ListHead->Flink;
CHECKPOINT;
if (IsListEmpty(ListHead))
@ -257,11 +298,13 @@ static VOID MmInsertMemoryAreaWithoutLock(MEMORY_AREA* marea)
// CHECKPOINT;
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
next = CONTAINING_RECORD(current_entry->Flink,MEMORY_AREA,Entry);
assert(current->BaseAddress != marea->BaseAddress);
assert(next->BaseAddress != marea->BaseAddress);
if (current->BaseAddress < marea->BaseAddress &&
current->Entry.Flink==ListHead)
{
current_entry->Flink = inserted_entry;
inserted_entry->Flink=&ListHead;
inserted_entry->Flink=ListHead;
inserted_entry->Blink=current_entry;
return;
}
@ -280,7 +323,8 @@ static VOID MmInsertMemoryAreaWithoutLock(MEMORY_AREA* marea)
InsertTailList(ListHead,inserted_entry);
}
static ULONG MmFindGapWithoutLock(KPROCESSOR_MODE Mode, ULONG Length)
static ULONG MmFindGapWithoutLock(PEPROCESS Process,
KPROCESSOR_MODE Mode, ULONG Length)
{
PLIST_ENTRY ListHead;
PLIST_ENTRY current_entry;
@ -290,13 +334,14 @@ static ULONG MmFindGapWithoutLock(KPROCESSOR_MODE Mode, ULONG Length)
DPRINT("MmFindGapWithoutLock(Mode %x Length %x)\n",Mode,Length);
if (Mode == KernelMode)
{
ListHead = &SystemAreaList;
}
else
{
ListHead = &(KeGetCurrentProcess()->MemoryAreaList);
ListHead = &(Process->Pcb.MemoryAreaList);
}
@ -317,6 +362,13 @@ static ULONG MmFindGapWithoutLock(KPROCESSOR_MODE Mode, ULONG Length)
}
current_entry = current_entry->Flink;
}
if (current_entry == ListHead)
{
assert(Mode==UserMode);
return(MM_LOWEST_USER_ADDRESS);
}
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
//DbgPrint("current %x returning %x\n",current,current->BaseAddress+
// current->Length);
@ -334,7 +386,8 @@ NTSTATUS MmInitMemoryAreas(VOID)
return(STATUS_SUCCESS);
}
NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
PVOID BaseAddress,
ULONG Length,
BOOLEAN FreePages)
{
@ -342,10 +395,14 @@ NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
ULONG i;
KIRQL oldlvl;
DPRINT("MmFreeMemoryArea(Process %x, BaseAddress %x, Length %x,"
"FreePages %d)\n",Process,BaseAddress,Length,FreePages);
MmLockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
MemoryArea = MmOpenMemoryAreaByAddressWithoutLock((ULONG)BaseAddress);
if (MemoryArea!=NULL)
MemoryArea = MmOpenMemoryAreaByAddressWithoutLock(Process,
(ULONG)BaseAddress);
if (MemoryArea==NULL)
{
MmUnlockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
return(STATUS_UNSUCCESSFUL);
@ -365,9 +422,81 @@ NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
return(STATUS_SUCCESS);
}
NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea)
{
MemoryArea->LockCount++;
}
NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea)
{
MemoryArea->LockCount--;
}
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
PMEMORY_AREA OriginalMemoryArea,
PVOID BaseAddress,
ULONG Length,
ULONG NewType,
ULONG NewAttributes)
{
KIRQL oldlvl;
PMEMORY_AREA Result;
PMEMORY_AREA Split;
Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
RtlZeroMemory(Result,sizeof(MEMORY_AREA));
Result->Type=NewType;
Result->BaseAddress=BaseAddress;
Result->Length=Length;
Result->Attributes=NewAttributes;
Result->LockCount=0;
MmLockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
if (BaseAddress == OriginalMemoryArea->BaseAddress)
{
OriginalMemoryArea->BaseAddress = BaseAddress + Length;
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
MmInsertMemoryAreaWithoutLock(Process,Result);
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
return(Result);
}
if ((BaseAddress + Length) ==
(OriginalMemoryArea->BaseAddress + OriginalMemoryArea->Length))
{
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
MmInsertMemoryAreaWithoutLock(Process,Result);
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
return(Result);
}
Split = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
RtlCopyMemory(Split,OriginalMemoryArea,sizeof(MEMORY_AREA));
Split->BaseAddress = BaseAddress + Length;
Split->Length = OriginalMemoryArea->Length - (((ULONG)BaseAddress)
+ Length);
OriginalMemoryArea->Length = BaseAddress - OriginalMemoryArea->BaseAddress;
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
return(Split);
}
NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
PEPROCESS Process,
ULONG Type,
PULONG BaseAddress,
PVOID* BaseAddress,
ULONG Length,
ULONG Attributes,
MEMORY_AREA** Result)
@ -377,48 +506,50 @@ NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
DPRINT("MmCreateMemoryArea(Mode %x, Type %d, BaseAddress %x,"
"*BaseAddress %x, Length %x, Attributes %x, Result %x)\n",
Mode,Type,BaseAddress,*BaseAddress,Length,Attributes,Result);
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
MmLockMemoryAreaList(*BaseAddress,&oldlvl);
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
if ((*BaseAddress)==0)
{
*BaseAddress = MmFindGapWithoutLock(Mode,PAGE_ROUND_UP(Length)
MmLockMemoryAreaListByMode(Mode,&oldlvl);
}
else
{
MmLockMemoryAreaList(*BaseAddress,&oldlvl);
}
if ((*BaseAddress)==0)
{
*BaseAddress = MmFindGapWithoutLock(Process,Mode,PAGE_ROUND_UP(Length)
+(PAGESIZE*2));
if ((*BaseAddress)==0)
{
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
MmUnlockMemoryAreaListByMode(Mode,&oldlvl);
return(STATUS_UNSUCCESSFUL);
}
(*BaseAddress)=(*BaseAddress)+PAGESIZE;
}
else
{
if (MmOpenMemoryAreaByRegionWithoutLock(*BaseAddress,Length)!=NULL)
(*BaseAddress) = PAGE_ROUND_DOWN((*BaseAddress));
if (MmOpenMemoryAreaByRegionWithoutLock(Process,*BaseAddress,
Length)!=NULL)
{
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
return(STATUS_UNSUCCESSFUL);
}
}
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
*Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
RtlZeroMemory(*Result,sizeof(MEMORY_AREA));
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
(*Result)->Type=Type;
(*Result)->BaseAddress=*BaseAddress;
(*Result)->Length=Length;
(*Result)->Attributes=Attributes;
DPRINT("&SystemAreaList %x ",&SystemAreaList);
DPRINT("SystemAreaList.Flink %x ",SystemAreaList.Flink);
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
MmInsertMemoryAreaWithoutLock(*Result);
// DbgPrint("(%s:%d) Start1 %x\n",__FILE__,__LINE__,
// *((unsigned int *)0xc0017000));
(*Result)->LockCount=0;
MmInsertMemoryAreaWithoutLock(Process,*Result);
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
DPRINT("SystemAreaList.Flink %x ",SystemAreaList.Flink);
DPRINT("(*Result)->Entry.Flink %x\n",(*Result)->Entry.Flink);
MmDumpMemoryAreas();
return(STATUS_SUCCESS);
}

View file

@ -1,4 +1,4 @@
/*
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/mdl.c
@ -12,7 +12,7 @@
#include <ddk/ntddk.h>
#include <internal/mm.h>
#include <internal/hal/page.h>
#include <internal/mmhal.h>
#include <internal/string.h>
#define NDEBUG
@ -31,7 +31,7 @@ VOID MmUnlockPages(PMDL MemoryDescriptorList)
* MDL is updated
*/
{
UNIMPLEMENTED;
/* It is harmless to leave this one as a stub */
}
PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
@ -54,6 +54,7 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);
MmCreateMemoryArea(KernelMode,
PsGetCurrentProcess(),
MEMORY_AREA_MDL_MAPPING,
&base,
Mdl->ByteCount + Mdl->ByteOffset,
@ -61,19 +62,18 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
&Result);
CHECKPOINT;
mdl_pages = (ULONG *)(Mdl + 1);
for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount + Mdl->ByteOffset)/PAGESIZE); i++)
for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount+Mdl->ByteOffset)/PAGESIZE); i++)
{
DPRINT("Writing %x with physical address %x\n",
base+(i*PAGESIZE),mdl_pages[i]);
DPRINT("&((PULONG)(Mdl+1))[i] %x\n",&mdl_pages[i]);
set_page(base+(i*PAGESIZE),PA_READ + PA_SYSTEM,
mdl_pages[i]);
set_page(base+(i*PAGESIZE),PA_READ + PA_SYSTEM,mdl_pages[i]);
}
DPRINT("base %x\n",base);
Mdl->MdlFlags = Mdl->MdlFlags | MDL_MAPPED_TO_SYSTEM_VA;
return(base + Mdl->ByteOffset);
}
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList)
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
/*
* FUNCTION: Releases a mapping set up by a preceding call to MmMapLockedPages
* ARGUMENTS:
@ -81,7 +81,8 @@ VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList)
* MemoryDescriptorList = MDL describing the mapped pages
*/
{
(void)MmFreeMemoryArea(BaseAddress,MemoryDescriptorList->ByteCount,FALSE);
(void)MmFreeMemoryArea(PsGetCurrentProcess(),BaseAddress-Mdl->ByteOffset,
Mdl->ByteCount,FALSE);
}
VOID MmPrepareMdlForReuse(PMDL Mdl)
@ -113,7 +114,8 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
DPRINT("MmProbeAndLockPages(Mdl %x)\n",Mdl);
DPRINT("StartVa %x\n",Mdl->StartVa);
marea = MmOpenMemoryAreaByAddress((ULONG)Mdl->StartVa);
marea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),
(ULONG)Mdl->StartVa);
DPRINT("marea %x\n",marea);
@ -126,36 +128,7 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
printk("Area is invalid\n");
ExRaiseStatus(STATUS_INVALID_PARAMETER);
}
/*
* Check the permissions
*/
#if 0
switch(Operation)
{
case IoReadAccess:
if (marea->access&PAGE_GUARD || marea->access&PAGE_NOACCESS)
{
ExRaiseStatus(STATUS_INVALID_PARAMETER);
}
break;
case IoWriteAccess:
case IoModifyAccess:
if (marea->access&PAGE_GUARD || marea->access&PAGE_READONLY)
{
printk("Invalid area protections\n");
ExRaiseStatus(STATUS_INVALID_PARAMETER);
}
break;
default:
printk("Invalid operation type at %s:%d in %s\n",__FILE__,__LINE__,
__FUNCTION__);
KeBugCheck(UNEXPECTED_KERNEL_MODE_TRAP);
}
#endif
/*
* Lock the memory area
* (We can't allow it to be freed while an I/O operation to it is
@ -169,7 +142,7 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
for (i=0;i<(PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGESIZE);i++)
{
Address = Mdl->StartVa + (i*PAGESIZE);
Address = Mdl->StartVa + (i*PAGESIZE);
mdl_pages[i]=MmGetPhysicalAddress(Address).LowPart;
DPRINT("mdl_pages[i] %x\n",mdl_pages[i]);
}
@ -244,6 +217,7 @@ VOID MmBuildMdlForNonPagedPool(PMDL Mdl)
*/
{
int va;
Mdl->MdlFlags = Mdl->MdlFlags | MDL_SOURCE_IS_NONPAGED_POOL;
for (va=0; va<Mdl->Size; va++)
{
((PULONG)(Mdl + 1))[va] = MmGetPhysicalAddress(

View file

@ -14,6 +14,7 @@
#include <internal/linkage.h>
#include <ddk/ntddk.h>
#define NDEBUG
#include <internal/debug.h>
typedef long long int LLI, *PLLI;
@ -112,10 +113,17 @@ RtlLargeIntegerAdd(LARGE_INTEGER Addend1,
{
LLI RC, A1, A2;
DPRINT("Addend1.LowPart %d Addend1.HighPart %d\n",
Addend1.LowPart,Addend1.HighPart);
DPRINT("Addend2.LowPart %d Addend2.HighPart %d\n",
Addend2.LowPart,Addend2.HighPart);
A1 = LLIFromLI(Addend1);
A2 = LLIFromLI(Addend2);
RC = A1 + A2;
DPRINT("RC %d\n",(unsigned int)RC);
return LIFromLLI(RC);
}

View file

@ -13,6 +13,10 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/string.h>
#include <internal/mm.h>
#include <internal/mmhal.h>
#include <internal/i386/segment.h>
#include <internal/ps.h>
//#define NDEBUG
#include <internal/debug.h>
@ -49,12 +53,10 @@ NTSTATUS TstFirstThread(PVOID start)
printk("Beginning Thread A\n");
for (;;)
// for (i=0;i<10;i++)
{
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
printk("AAA ");
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
for (i=0;i<10000;i++);
}
}
@ -64,12 +66,10 @@ NTSTATUS TstSecondThread(PVOID start)
printk("Beginning Thread B\n");
for(;;)
// for (i=0;i<10;i++)
{
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
printk("BBB ");
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
for (i=0;i<100000;i++);
}
}
@ -84,83 +84,93 @@ NTSTATUS TstThreadSupport()
for(;;);
}
void TstGeneralWrite(VOID)
VOID ExExecuteShell(VOID)
{
HANDLE ShellHandle;
HANDLE ThreadHandle;
PVOID BaseAddress;
HANDLE SectionHandle;
OBJECT_ATTRIBUTES attr;
HANDLE hfile;
char buf[512];
ANSI_STRING afilename;
UNICODE_STRING ufilename;
LARGE_INTEGER SectionOffset;
ULONG Size;
CONTEXT Context;
DbgPrint("Opening test device\n");
RtlInitAnsiString(&afilename,"\\Device\\SDisk");
ZwCreateProcess(&ShellHandle,
PROCESS_ALL_ACCESS,
NULL,
SystemProcessHandle,
FALSE,
NULL,
NULL,
NULL);
RtlInitAnsiString(&afilename,"\\??\\C:\\reactos\\system\\shell.bin");
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
ZwOpenFile(&hfile,0,&attr,NULL,0,0);
ZwOpenFile(&hfile,FILE_ALL_ACCESS,&attr,NULL,0,0);
if (hfile==NULL)
{
DbgPrint("Failed to open test device\n");
DbgPrint("Failed to open file\n");
return;
}
ZwReadFile(hfile,
NULL,
NULL,
NULL,
NULL,
buf,
512,
0,
0);
DbgPrint("buf %s\n",buf);
}
void TstParallelPortWrite(VOID)
{
HANDLE hfile;
DbgPrint("Opening parallel port\n");
// hfile = CreateFile("\\Device\\Parallel",0,0,0,0,0,0);
if (hfile==NULL)
{
DbgPrint("Failed to open parallel port\n");
}
// WriteFile(hfile,"hello world",strlen("hello world"),NULL,NULL);
ZwCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
NULL,
NULL,
PAGE_READWRITE,
MEM_COMMIT,
hfile);
BaseAddress = (PVOID)0x10000;
SectionOffset.HighPart = 0;
SectionOffset.LowPart = 0;
Size = 0x6000;
ZwMapViewOfSection(SectionHandle,
ShellHandle,
&BaseAddress,
0,
0x6000,
&SectionOffset,
&Size,
0,
MEM_COMMIT,
PAGE_READWRITE);
memset(&Context,0,sizeof(CONTEXT));
Context.SegSs = USER_DS;
Context.Esp = 0x2000;
Context.EFlags = 0x202;
Context.SegCs = USER_CS;
Context.Eip = 0x10000;
Context.SegDs = USER_DS;
Context.SegEs = USER_DS;
Context.SegFs = USER_DS;
Context.SegGs = USER_DS;
BaseAddress = 0x1000;
ZwAllocateVirtualMemory(ShellHandle,
&BaseAddress,
0,
PAGESIZE,
MEM_COMMIT,
PAGE_READWRITE);
ZwCreateThread(&ThreadHandle,
THREAD_ALL_ACCESS,
NULL,
ShellHandle,
NULL,
&Context,
NULL,
FALSE);
}
void TstKeyboardRead(VOID)
{
OBJECT_ATTRIBUTES attr;
HANDLE hfile;
ANSI_STRING afilename;
UNICODE_STRING ufilename;
KEY_EVENT_RECORD key[2];
DbgPrint("Opening keyboard\n");
RtlInitAnsiString(&afilename,"\\Device\\Keyboard");
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
ZwOpenFile(&hfile,0,&attr,NULL,0,0);
if (hfile==NULL)
{
DbgPrint("Failed to open keyboard\n");
return;
}
for(;;)
{
ZwReadFile(hfile,
NULL,
NULL,
NULL,
NULL,
&key[0],
sizeof(KEY_EVENT_RECORD)*2,
0,
0);
DbgPrint("%c",key[0].AsciiChar);
// DbgPrint("%c",key[1].AsciiChar);
}
}
/* IDE TEST STUFF ***********************************************************/
typedef struct _BOOT_PARAMETERS {
@ -204,43 +214,6 @@ typedef struct _ROOT_DIR_ENTRY {
#define ENTRIES_PER_BLOCK (512 / sizeof(ROOT_DIR_ENTRY))
void TstFileRead(VOID)
{
OBJECT_ATTRIBUTES attr;
HANDLE hfile;
ANSI_STRING afilename;
UNICODE_STRING ufilename;
char ch;
IO_STATUS_BLOCK IoStatusBlock;
DbgPrint("Opening file\n");
RtlInitAnsiString(&afilename,"\\??\\C:\\my_other_directory\\..\\"
"my_valid_directory\\apc.txt");
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
ZwOpenFile(&hfile,0,&attr,NULL,0,0);
if (hfile==NULL)
{
DbgPrint("Failed to open file\n");
return;
}
while (1)
{
// CHECKPOINT;
ZwReadFile(hfile,
NULL,
NULL,
NULL,
&IoStatusBlock,
&ch,
1,
NULL,
NULL);
DbgPrint("%c",ch);
}
CHECKPOINT;
}
void TstIDERead(void)
{
BOOLEAN TestFailed;
@ -462,11 +435,12 @@ static char SectorBuffer[512 * 10];
void TstBegin()
{
ExExecuteShell();
// TstFileRead();
// TstGeneralWrite();
// TstThreadSupport();
// TstKeyboardRead();
TstIDERead();
// TstIDERead();
// TstKeyboardRead();
// TstShell();
}

View file

@ -7,20 +7,31 @@
#
# Choose various options
#
ifeq ($(HOST),elf-linux)
NASM_FORMAT = elf
PREFIX =
KERNEL_BFD_TARGET = elf32-i386
EXE_POSTFIX =
CP = cp
endif
ifeq ($(HOST),djgpp-linux)
NASM_FORMAT = coff
PREFIX = dos-
KERNEL_BFD_TARGET = coff-i386
EXE_POSTFIX =
CP = cp
LIBGCC = ./libgcc.a
endif
ifeq ($(HOST),mingw32-linux)
NASM_FORMAT = win32
PREFIX = i386-mingw32
PREFIX = /opt/gnu/bin/i386-mingw32-
KERNEL_BFD_TARGET = pe-i386
EXE_POSTFIX
EXE_POSTFIX =
CP = cp
DLLTOOL = $(PREFIX)dlltool --as=$(PREFIX)as
LIBGCC = /opt/gnu/lib/gcc-lib/i386-mingw32/2.8.0/libgcc.a
endif
ifeq ($(HOST),djgpp-msdos)
@ -29,6 +40,7 @@ PREFIX =
KERNEL_BFD_TARGET = coff-go32
EXE_POSTFIX = .exe
CP = copy
LIBGCC = libgcc.a
endif
ifeq ($(HOST),mingw32-windows)
@ -42,24 +54,39 @@ endif
#
# Create variables for all the compiler tools
#
DEFINES = -DCHECKED_BUILD -DWIN32_LEAN_AND_MEAN -DDBG
ifeq ($(WITH_DEBUGGING),yes)
DEBUGGING_CFLAGS = -g
else
DEBUGGING_CFLAGS =
endif
DEFINES = -DDBG
ifeq ($(WIN32_LEAN_AND_MEAN),yes)
LEAN_AND_MEAN_DEFINE = -DWIN32_LEAN_AND_MEAN
else
LEAN_AND_MEAN_DEFINE =
endif
CC = $(PREFIX)gcc
NATIVE_CC = gcc
CFLAGS = -O2 -I../../../include -I../../include -I../include -fno-builtin $(DEFINES) -Wall -Wstrict-prototypes
CFLAGS = -O2 -I../../../include -I../../include -I../include -fno-builtin \
$(LEAN_AND_MEAN_DEFINE) $(DEFINES) -Wall -Wstrict-prototypes $(DEBUGGING_CFLAGS)
CXXFLAGS = $(CFLAGS)
ASM = nasm
NFLAGS = -i../include/ -f$(NASM_FORMAT)
NASM_CMD = nasm
NFLAGS = -i../../include/ -i../include/ -pinternal/asm.inc -f$(NASM_FORMAT) -d$(NASM_FORMAT)
LD = $(PREFIX)ld
NM = $(PREFIX)nm
OBJCOPY = $(PREFIX)objcopy
STRIP = $(PREFIX)strip
AS = $(PREFIX)gcc -c -x assembler-with-cpp
CPP = $(PREFIX)cpp
AR = $(PREFIX)ar
%.o: %.cc
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.asm
$(ASM) $(NFLAGS) $< -o $@
$(NASM_CMD) $(NFLAGS) $< -o $@
RULES_MAK_INCLUDED = 1