Added calibration of KeStallExecutionProcessor delay

Corrected compilation bugs in user32
Corrected compilation bugs related to anonymous structs in ndis code
Pass commandline from loadros
Corrected PIC mask calculation

svn path=/trunk/; revision=1326
This commit is contained in:
David Welch 2000-08-30 19:33:29 +00:00
parent 3b94410c8a
commit 8e0014c64b
28 changed files with 481 additions and 568 deletions

View file

@ -1,16 +1,45 @@
27/5/00: Fixed issue with closing non-existent or already closed handle 2000-08-30 David Welch <welch@cwcom.net>
26/1/99: ZwCreateProcess now maps ntdll rather than the user-mode code * Added calibration of KeStallExecutionProcessor timing
(code from linux 2.2.16).
9/6/99: Implemented ZwOpenProcess * Corrected compilation bugs in user32 library.
Partially implemented killing other threads (possible memory
leaks)
Made a start on a proper implemention of APCs (based on
article in NT insider)
8/12/98: Corrected bug in shell (Read two keypresses and assumed they * Corrected compilation bugs related to anonymous structs
where the key going up and down respectively) in ndis code.
Corrected race in dpc handling
Took out cleanup sections in ZwReadFile (now handled by the APC)
Disabled broken code in kernel32
* Pass command line to kernel from loadros.
* Corrected PIC mask calculation.
2000-05-27 David Welch <welch@cwcom.net>
* Fixed issue with closing non-existent or already closed
handle.
2000-01-26 David Welch <welch@cwcom.net>
* ZwCreateProcess now maps ntdll rather than the user-mode
code.
1999-09-06 David Welch <welch@cwcom.net>
* Implemented ZwOpenProcess.
* Partially implemented killing other threads (possible memory
leaks).
* Made a start on a proper implemention of APCs (based on
article in NT insider).
1998-12-08 David Welch <welch@cwcom.net>
* Corrected bug in shell (Read two keypresses and assumed they
where the key going up and down respectively).
* Corrected race in dpc handling.
* Took out cleanup sections in ZwReadFile (now handled by the
APC).
* Disabled broken code in kernel32.

View file

@ -47,7 +47,8 @@ NET_DEVICE_DRIVERS = ne2000
KERNEL_SERVICES = $(DEVICE_DRIVERS) $(FS_DRIVERS) $(NET_DRIVERS) $(NET_DEVICE_DRIVERS) KERNEL_SERVICES = $(DEVICE_DRIVERS) $(FS_DRIVERS) $(NET_DRIVERS) $(NET_DEVICE_DRIVERS)
APPS = args hello shell test cat bench apc shm lpc thread event file gditest \ APPS = args hello shell test cat bench apc shm lpc thread event file gditest \
pteb consume dump_shared_data vmtest wstest pteb consume dump_shared_data vmtest
# wstest
# objdir # objdir
all: buildno $(COMPONENTS) $(DLLS) $(SUBSYS) $(LOADERS) $(KERNEL_SERVICES) $(APPS) all: buildno $(COMPONENTS) $(DLLS) $(SUBSYS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)

View file

@ -32,7 +32,7 @@ typedef struct _MINIPORT_DRIVER {
/* Information about a logical adapter */ /* Information about a logical adapter */
typedef struct _LOGICAL_ADAPTER { typedef struct _LOGICAL_ADAPTER {
NDIS_MINIPORT_BLOCK; /* NDIS defined fields */ NDIS_MINIPORT_BLOCK NdisMiniportBlock; /* NDIS defined fields */
KDPC MiniportDpc; /* DPC routine for adapter */ KDPC MiniportDpc; /* DPC routine for adapter */
BOOLEAN MiniportBusy; /* A MiniportXxx routine is executing */ BOOLEAN MiniportBusy; /* A MiniportXxx routine is executing */

View file

@ -25,7 +25,7 @@ typedef struct _PROTOCOL_BINDING {
typedef struct _ADAPTER_BINDING { typedef struct _ADAPTER_BINDING {
NDIS_OPEN_BLOCK; /* NDIS defined fields */ NDIS_OPEN_BLOCK NdisOpenBlock; /* NDIS defined fields */
LIST_ENTRY ListEntry; /* Entry on global list */ LIST_ENTRY ListEntry; /* Entry on global list */
LIST_ENTRY ProtocolListEntry; /* Entry on protocol binding adapter list */ LIST_ENTRY ProtocolListEntry; /* Entry on protocol binding adapter list */

View file

@ -30,26 +30,26 @@ VOID HandleDeferredProcessing(
NDIS_DbgPrint(MAX_TRACE, ("Called.\n")); NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
KeAcquireSpinLockAtDpcLevel(&Adapter->Lock); KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
WasBusy = Adapter->MiniportBusy; WasBusy = Adapter->MiniportBusy;
Adapter->MiniportBusy = TRUE; Adapter->MiniportBusy = TRUE;
KeReleaseSpinLockFromDpcLevel(&Adapter->Lock); KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
NDIS_DbgPrint(MAX_TRACE, ("Before HandleInterruptHandler.\n")); NDIS_DbgPrint(MAX_TRACE, ("Before HandleInterruptHandler.\n"));
/* Call the deferred interrupt service handler for this adapter */ /* Call the deferred interrupt service handler for this adapter */
(*Adapter->Miniport->Chars.HandleInterruptHandler)( (*Adapter->Miniport->Chars.HandleInterruptHandler)(
Adapter->MiniportAdapterContext); Adapter->NdisMiniportBlock.MiniportAdapterContext);
NDIS_DbgPrint(MAX_TRACE, ("After HandleInterruptHandler.\n")); NDIS_DbgPrint(MAX_TRACE, ("After HandleInterruptHandler.\n"));
KeAcquireSpinLockAtDpcLevel(&Adapter->Lock); KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
if ((!WasBusy) && (Adapter->WorkQueueHead)) { if ((!WasBusy) && (Adapter->WorkQueueHead)) {
KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL); KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
} else { } else {
Adapter->MiniportBusy = WasBusy; Adapter->MiniportBusy = WasBusy;
} }
KeReleaseSpinLockFromDpcLevel(&Adapter->Lock); KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n")); NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
} }
@ -75,11 +75,11 @@ BOOLEAN ServiceRoutine(
(*Adapter->Miniport->Chars.ISRHandler)(&InterruptRecognized, (*Adapter->Miniport->Chars.ISRHandler)(&InterruptRecognized,
&QueueMiniportHandleInterrupt, &QueueMiniportHandleInterrupt,
Adapter->MiniportAdapterContext); Adapter->NdisMiniportBlock.MiniportAdapterContext);
if (QueueMiniportHandleInterrupt) { if (QueueMiniportHandleInterrupt) {
NDIS_DbgPrint(MAX_TRACE, ("Queueing DPC.\n")); NDIS_DbgPrint(MAX_TRACE, ("Queueing DPC.\n"));
KeInsertQueueDpc(&Adapter->Interrupt->InterruptDpc, NULL, NULL); KeInsertQueueDpc(&Adapter->NdisMiniportBlock.Interrupt->InterruptDpc, NULL, NULL);
} }
NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n")); NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
@ -361,7 +361,7 @@ NdisMRegisterInterrupt(
Interrupt->SharedInterrupt = SharedInterrupt; Interrupt->SharedInterrupt = SharedInterrupt;
Adapter->Interrupt = Interrupt; Adapter->NdisMiniportBlock.Interrupt = Interrupt;
MappedIRQ = HalGetInterruptVector(Internal, /* Adapter->AdapterType, */ MappedIRQ = HalGetInterruptVector(Internal, /* Adapter->AdapterType, */
0, 0,

View file

@ -128,17 +128,17 @@ MiniIndicateData(
} }
#endif /* DBG */ #endif /* DBG */
KeAcquireSpinLock(&Adapter->Lock, &OldIrql); KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
CurrentEntry = Adapter->ProtocolListHead.Flink; CurrentEntry = Adapter->ProtocolListHead.Flink;
while (CurrentEntry != &Adapter->ProtocolListHead) { while (CurrentEntry != &Adapter->ProtocolListHead) {
AdapterBinding = CONTAINING_RECORD(CurrentEntry, AdapterBinding = CONTAINING_RECORD(CurrentEntry,
ADAPTER_BINDING, ADAPTER_BINDING,
AdapterListEntry); AdapterListEntry);
KeReleaseSpinLock(&Adapter->Lock, OldIrql); KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
(*AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler)( (*AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler)(
AdapterBinding->ProtocolBindingContext, AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
MacReceiveContext, MacReceiveContext,
HeaderBuffer, HeaderBuffer,
HeaderBufferSize, HeaderBufferSize,
@ -146,11 +146,11 @@ MiniIndicateData(
LookaheadBufferSize, LookaheadBufferSize,
PacketSize); PacketSize);
KeAcquireSpinLock(&Adapter->Lock, &OldIrql); KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
CurrentEntry = CurrentEntry->Flink; CurrentEntry = CurrentEntry->Flink;
} }
KeReleaseSpinLock(&Adapter->Lock, OldIrql); KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
} }
@ -172,23 +172,23 @@ MiniEthReceiveComplete(
Adapter = (PLOGICAL_ADAPTER)Filter->Miniport; Adapter = (PLOGICAL_ADAPTER)Filter->Miniport;
KeAcquireSpinLock(&Adapter->Lock, &OldIrql); KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
CurrentEntry = Adapter->ProtocolListHead.Flink; CurrentEntry = Adapter->ProtocolListHead.Flink;
while (CurrentEntry != &Adapter->ProtocolListHead) { while (CurrentEntry != &Adapter->ProtocolListHead) {
AdapterBinding = CONTAINING_RECORD(CurrentEntry, AdapterBinding = CONTAINING_RECORD(CurrentEntry,
ADAPTER_BINDING, ADAPTER_BINDING,
AdapterListEntry); AdapterListEntry);
KeReleaseSpinLock(&Adapter->Lock, OldIrql); KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
(*AdapterBinding->ProtocolBinding->Chars.ReceiveCompleteHandler)( (*AdapterBinding->ProtocolBinding->Chars.ReceiveCompleteHandler)(
AdapterBinding->ProtocolBindingContext); AdapterBinding->NdisOpenBlock.ProtocolBindingContext);
KeAcquireSpinLock(&Adapter->Lock, &OldIrql); KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
CurrentEntry = CurrentEntry->Flink; CurrentEntry = CurrentEntry->Flink;
} }
KeReleaseSpinLock(&Adapter->Lock, OldIrql); KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
} }
@ -256,7 +256,7 @@ MiniSendComplete(
AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[0]; AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[0];
(*AdapterBinding->ProtocolBinding->Chars.u2.SendCompleteHandler)( (*AdapterBinding->ProtocolBinding->Chars.u2.SendCompleteHandler)(
AdapterBinding->ProtocolBindingContext, AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet, Packet,
Status); Status);
} }
@ -283,7 +283,7 @@ MiniTransferDataComplete(
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n")); NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
(*AdapterBinding->ProtocolBinding->Chars.u3.TransferDataCompleteHandler)( (*AdapterBinding->ProtocolBinding->Chars.u3.TransferDataCompleteHandler)(
AdapterBinding->ProtocolBindingContext, AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet, Packet,
Status, Status,
BytesTransferred); BytesTransferred);
@ -320,14 +320,14 @@ MiniAdapterHasAddress(
/* FIXME: Should handle fragmented packets */ /* FIXME: Should handle fragmented packets */
switch (Adapter->MediaType) { switch (Adapter->NdisMiniportBlock.MediaType) {
case NdisMedium802_3: case NdisMedium802_3:
Length = ETH_LENGTH_OF_ADDRESS; Length = ETH_LENGTH_OF_ADDRESS;
/* Destination address is the first field */ /* Destination address is the first field */
break; break;
default: default:
NDIS_DbgPrint(MIN_TRACE, ("Adapter has unsupported media type (0x%X).\n", Adapter->MediaType)); NDIS_DbgPrint(MIN_TRACE, ("Adapter has unsupported media type (0x%X).\n", Adapter->NdisMiniportBlock.MediaType));
return FALSE; return FALSE;
} }
@ -420,7 +420,7 @@ MiniQueryInformation(
BytesNeeded = (Size == 0)? Adapter->QueryBufferLength : Size; BytesNeeded = (Size == 0)? Adapter->QueryBufferLength : Size;
NdisStatus = (*Adapter->Miniport->Chars.QueryInformationHandler)( NdisStatus = (*Adapter->Miniport->Chars.QueryInformationHandler)(
Adapter->MiniportAdapterContext, Adapter->NdisMiniportBlock.MiniportAdapterContext,
Oid, Oid,
Adapter->QueryBuffer, Adapter->QueryBuffer,
BytesNeeded, BytesNeeded,
@ -445,7 +445,7 @@ MiniQueryInformation(
} }
NdisStatus = (*Adapter->Miniport->Chars.QueryInformationHandler)( NdisStatus = (*Adapter->Miniport->Chars.QueryInformationHandler)(
Adapter->MiniportAdapterContext, Adapter->NdisMiniportBlock.MiniportAdapterContext,
Oid, Oid,
Adapter->QueryBuffer, Adapter->QueryBuffer,
Size, Size,
@ -578,12 +578,12 @@ MiniDoRequest(
* Status of operation * Status of operation
*/ */
{ {
Adapter->MediaRequest = NdisRequest; Adapter->NdisMiniportBlock.MediaRequest = NdisRequest;
switch (NdisRequest->RequestType) { switch (NdisRequest->RequestType) {
case NdisRequestQueryInformation: case NdisRequestQueryInformation:
return (*Adapter->Miniport->Chars.QueryInformationHandler)( return (*Adapter->Miniport->Chars.QueryInformationHandler)(
Adapter->MiniportAdapterContext, Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.QUERY_INFORMATION.Oid, NdisRequest->DATA.QUERY_INFORMATION.Oid,
NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer, NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength, NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
@ -593,7 +593,7 @@ MiniDoRequest(
case NdisRequestSetInformation: case NdisRequestSetInformation:
return (*Adapter->Miniport->Chars.SetInformationHandler)( return (*Adapter->Miniport->Chars.SetInformationHandler)(
Adapter->MiniportAdapterContext, Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.SET_INFORMATION.Oid, NdisRequest->DATA.SET_INFORMATION.Oid,
NdisRequest->DATA.SET_INFORMATION.InformationBuffer, NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
NdisRequest->DATA.SET_INFORMATION.InformationBufferLength, NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
@ -641,7 +641,7 @@ VOID MiniportDpc(
MiniDisplayPacket((PNDIS_PACKET)WorkItemContext); MiniDisplayPacket((PNDIS_PACKET)WorkItemContext);
#endif #endif
NdisStatus = (*Adapter->Miniport->Chars.u1.SendHandler)( NdisStatus = (*Adapter->Miniport->Chars.u1.SendHandler)(
Adapter->MiniportAdapterContext, Adapter->NdisMiniportBlock.MiniportAdapterContext,
(PNDIS_PACKET)WorkItemContext, (PNDIS_PACKET)WorkItemContext,
0); 0);
if (NdisStatus != NDIS_STATUS_PENDING) { if (NdisStatus != NDIS_STATUS_PENDING) {
@ -822,8 +822,8 @@ NdisMQueryInformationComplete(
NDIS_DbgPrint(MAX_TRACE, ("Called.\n")); NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
(*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)( (*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)(
AdapterBinding->ProtocolBindingContext, AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Adapter->MediaRequest, Adapter->NdisMiniportBlock.MediaRequest,
Status); Status);
} }
@ -867,9 +867,9 @@ DoQueries(
return NdisStatus; return NdisStatus;
} }
RtlCopyMemory(&Adapter->MacOptions, Adapter->QueryBuffer, sizeof(UINT)); RtlCopyMemory(&Adapter->NdisMiniportBlock.MacOptions, Adapter->QueryBuffer, sizeof(UINT));
NDIS_DbgPrint(DEBUG_MINIPORT, ("MacOptions (0x%X).\n", Adapter->MacOptions)); NDIS_DbgPrint(DEBUG_MINIPORT, ("MacOptions (0x%X).\n", Adapter->NdisMiniportBlock.MacOptions));
/* Get current hardware address of adapter */ /* Get current hardware address of adapter */
NdisStatus = MiniQueryInformation(Adapter, NdisStatus = MiniQueryInformation(Adapter,
@ -1031,7 +1031,7 @@ NdisMRegisterMiniport(
FILE_DEVICE_PHYSICAL_NETCARD, FILE_DEVICE_PHYSICAL_NETCARD,
0, 0,
FALSE, FALSE,
&Adapter->DeviceObject); &Adapter->NdisMiniportBlock.DeviceObject);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status)) {
NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n")); NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n"));
ExFreePool(Adapter); ExFreePool(Adapter);
@ -1040,7 +1040,7 @@ NdisMRegisterMiniport(
/* Initialize adapter object */ /* Initialize adapter object */
KeInitializeSpinLock(&Adapter->Lock); KeInitializeSpinLock(&Adapter->NdisMiniportBlock.Lock);
InitializeListHead(&Adapter->ProtocolListHead); InitializeListHead(&Adapter->ProtocolListHead);
@ -1050,13 +1050,13 @@ NdisMRegisterMiniport(
/* Set handlers (some NDIS macros require these) */ /* Set handlers (some NDIS macros require these) */
Adapter->EthRxCompleteHandler = MiniEthReceiveComplete; Adapter->NdisMiniportBlock.EthRxCompleteHandler = MiniEthReceiveComplete;
Adapter->EthRxIndicateHandler = MiniEthReceiveIndication; Adapter->NdisMiniportBlock.EthRxIndicateHandler = MiniEthReceiveIndication;
Adapter->SendCompleteHandler = MiniSendComplete; Adapter->NdisMiniportBlock.SendCompleteHandler = MiniSendComplete;
Adapter->SendResourcesHandler = MiniSendResourcesAvailable; Adapter->NdisMiniportBlock.SendResourcesHandler = MiniSendResourcesAvailable;
Adapter->ResetCompleteHandler = MiniResetComplete; Adapter->NdisMiniportBlock.ResetCompleteHandler = MiniResetComplete;
Adapter->TDCompleteHandler = MiniTransferDataComplete; Adapter->NdisMiniportBlock.TDCompleteHandler = MiniTransferDataComplete;
KeInitializeDpc(&Adapter->MiniportDpc, MiniportDpc, (PVOID)Adapter); KeInitializeDpc(&Adapter->MiniportDpc, MiniportDpc, (PVOID)Adapter);
@ -1083,19 +1083,19 @@ NdisMRegisterMiniport(
if ((NdisStatus == NDIS_STATUS_SUCCESS) && if ((NdisStatus == NDIS_STATUS_SUCCESS) &&
(SelectedMediumIndex < MEDIA_ARRAY_SIZE)) { (SelectedMediumIndex < MEDIA_ARRAY_SIZE)) {
Adapter->MediaType = MediaArray[SelectedMediumIndex]; Adapter->NdisMiniportBlock.MediaType = MediaArray[SelectedMediumIndex];
switch (Adapter->MediaType) { switch (Adapter->NdisMiniportBlock.MediaType) {
case NdisMedium802_3: case NdisMedium802_3:
Adapter->MediumHeaderSize = 14; Adapter->MediumHeaderSize = 14;
AddressOID = OID_802_3_CURRENT_ADDRESS; AddressOID = OID_802_3_CURRENT_ADDRESS;
Adapter->AddressLength = ETH_LENGTH_OF_ADDRESS; Adapter->AddressLength = ETH_LENGTH_OF_ADDRESS;
Adapter->FilterDbs.u.EthDB = ExAllocatePool(NonPagedPool, Adapter->NdisMiniportBlock.FilterDbs.u.EthDB = ExAllocatePool(NonPagedPool,
sizeof(ETH_FILTER)); sizeof(ETH_FILTER));
if (Adapter->FilterDbs.u.EthDB) { if (Adapter->NdisMiniportBlock.FilterDbs.u.EthDB) {
RtlZeroMemory(Adapter->FilterDbs.u.EthDB, sizeof(ETH_FILTER)); RtlZeroMemory(Adapter->NdisMiniportBlock.FilterDbs.u.EthDB, sizeof(ETH_FILTER));
Adapter->FilterDbs.u.EthDB->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter; Adapter->NdisMiniportBlock.FilterDbs.u.EthDB->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter;
} else } else
MemError = TRUE; MemError = TRUE;
break; break;
@ -1126,7 +1126,7 @@ NdisMRegisterMiniport(
if (Adapter->LookaheadBuffer) if (Adapter->LookaheadBuffer)
ExFreePool(Adapter->LookaheadBuffer); ExFreePool(Adapter->LookaheadBuffer);
IoDeleteDevice(Adapter->DeviceObject); IoDeleteDevice(Adapter->NdisMiniportBlock.DeviceObject);
ExFreePool(Adapter); ExFreePool(Adapter);
return NDIS_STATUS_FAILURE; return NDIS_STATUS_FAILURE;
} }
@ -1205,8 +1205,8 @@ NdisMSetInformationComplete(
NDIS_DbgPrint(MAX_TRACE, ("Called.\n")); NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
(*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)( (*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)(
AdapterBinding->ProtocolBindingContext, AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Adapter->MediaRequest, Adapter->NdisMiniportBlock.MediaRequest,
Status); Status);
} }
@ -1231,9 +1231,9 @@ NdisMSetAttributes(
NDIS_DbgPrint(MAX_TRACE, ("Called.\n")); NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
Adapter->MiniportAdapterContext = MiniportAdapterContext; Adapter->NdisMiniportBlock.MiniportAdapterContext = MiniportAdapterContext;
Adapter->Attributes = BusMaster? NDIS_ATTRIBUTE_BUS_MASTER : 0; Adapter->Attributes = BusMaster? NDIS_ATTRIBUTE_BUS_MASTER : 0;
Adapter->AdapterType = AdapterType; Adapter->NdisMiniportBlock.AdapterType = AdapterType;
Adapter->AttributesSet = TRUE; Adapter->AttributesSet = TRUE;
} }

View file

@ -42,7 +42,7 @@ ProIndicatePacket(
NdisQueryPacket(Packet, NULL, NULL, NULL, &Total); NdisQueryPacket(Packet, NULL, NULL, NULL, &Total);
KeAcquireSpinLock(&Adapter->Lock, &OldIrql); KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Adapter->LoopPacket = Packet; Adapter->LoopPacket = Packet;
@ -52,7 +52,7 @@ ProIndicatePacket(
0, 0,
Adapter->CurLookaheadLength); Adapter->CurLookaheadLength);
KeReleaseSpinLock(&Adapter->Lock, OldIrql); KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (Length > Adapter->MediumHeaderSize) { if (Length > Adapter->MediumHeaderSize) {
MiniIndicateData(Adapter, MiniIndicateData(Adapter,
@ -72,11 +72,11 @@ ProIndicatePacket(
0); 0);
} }
KeAcquireSpinLock(&Adapter->Lock, &OldIrql); KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Adapter->LoopPacket = NULL; Adapter->LoopPacket = NULL;
KeReleaseSpinLock(&Adapter->Lock, OldIrql); KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -103,7 +103,7 @@ ProRequest(
NDIS_DbgPrint(MAX_TRACE, ("Called.\n")); NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
KeAcquireSpinLock(&Adapter->Lock, &OldIrql); KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Queue = Adapter->MiniportBusy; Queue = Adapter->MiniportBusy;
if (Queue) { if (Queue) {
MiniQueueWorkItem(Adapter, MiniQueueWorkItem(Adapter,
@ -113,16 +113,16 @@ ProRequest(
} else { } else {
Adapter->MiniportBusy = TRUE; Adapter->MiniportBusy = TRUE;
} }
KeReleaseSpinLock(&Adapter->Lock, OldIrql); KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (!Queue) { if (!Queue) {
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
NdisStatus = MiniDoRequest(Adapter, NdisRequest); NdisStatus = MiniDoRequest(Adapter, NdisRequest);
KeAcquireSpinLockAtDpcLevel(&Adapter->Lock); KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->MiniportBusy = FALSE; Adapter->MiniportBusy = FALSE;
if (Adapter->WorkQueueHead) if (Adapter->WorkQueueHead)
KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL); KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
KeReleaseSpinLockFromDpcLevel(&Adapter->Lock); KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
} else { } else {
NdisStatus = NDIS_STATUS_PENDING; NdisStatus = NDIS_STATUS_PENDING;
@ -164,11 +164,11 @@ ProSend(
Packet->Reserved[0] = (ULONG_PTR)MacBindingHandle; Packet->Reserved[0] = (ULONG_PTR)MacBindingHandle;
KeAcquireSpinLock(&Adapter->Lock, &OldIrql); KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Queue = Adapter->MiniportBusy; Queue = Adapter->MiniportBusy;
/* We may have to loop this packet if miniport cannot */ /* We may have to loop this packet if miniport cannot */
if (Adapter->MacOptions & NDIS_MAC_OPTION_NO_LOOPBACK) { if (Adapter->NdisMiniportBlock.MacOptions & NDIS_MAC_OPTION_NO_LOOPBACK) {
if (MiniAdapterHasAddress(Adapter, Packet)) { if (MiniAdapterHasAddress(Adapter, Packet)) {
/* Do software loopback because miniport does not support it */ /* Do software loopback because miniport does not support it */
@ -185,16 +185,16 @@ ProSend(
} else { } else {
Adapter->MiniportBusy = TRUE; Adapter->MiniportBusy = TRUE;
} }
KeReleaseSpinLock(&Adapter->Lock, OldIrql); KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (!Queue) { if (!Queue) {
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
NdisStatus = ProIndicatePacket(Adapter, Packet); NdisStatus = ProIndicatePacket(Adapter, Packet);
KeAcquireSpinLockAtDpcLevel(&Adapter->Lock); KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->MiniportBusy = FALSE; Adapter->MiniportBusy = FALSE;
if (Adapter->WorkQueueHead) if (Adapter->WorkQueueHead)
KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL); KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
KeReleaseSpinLockFromDpcLevel(&Adapter->Lock); KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
return NdisStatus; return NdisStatus;
} else { } else {
@ -214,19 +214,19 @@ ProSend(
} else { } else {
Adapter->MiniportBusy = TRUE; Adapter->MiniportBusy = TRUE;
} }
KeReleaseSpinLock(&Adapter->Lock, OldIrql); KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (!Queue) { if (!Queue) {
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
NdisStatus = (*Adapter->Miniport->Chars.u1.SendHandler)( NdisStatus = (*Adapter->Miniport->Chars.u1.SendHandler)(
Adapter->MiniportAdapterContext, Adapter->NdisMiniportBlock.MiniportAdapterContext,
Packet, Packet,
0); 0);
KeAcquireSpinLockAtDpcLevel(&Adapter->Lock); KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->MiniportBusy = FALSE; Adapter->MiniportBusy = FALSE;
if (Adapter->WorkQueueHead) if (Adapter->WorkQueueHead)
KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL); KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
KeReleaseSpinLockFromDpcLevel(&Adapter->Lock); KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
} else { } else {
NdisStatus = NDIS_STATUS_PENDING; NdisStatus = NDIS_STATUS_PENDING;
@ -285,7 +285,7 @@ ProTransferData(
return (*Adapter->Miniport->Chars.u2.TransferDataHandler)( return (*Adapter->Miniport->Chars.u2.TransferDataHandler)(
Packet, Packet,
BytesTransferred, BytesTransferred,
Adapter->MiniportAdapterContext, Adapter->NdisMiniportBlock.MiniportAdapterContext,
MacReceiveContext, MacReceiveContext,
ByteOffset, ByteOffset,
BytesToTransfer); BytesToTransfer);
@ -316,9 +316,9 @@ NdisCloseAdapter(
KeReleaseSpinLock(&AdapterBinding->ProtocolBinding->Lock, OldIrql); KeReleaseSpinLock(&AdapterBinding->ProtocolBinding->Lock, OldIrql);
/* Remove protocol from adapter's bound protocols list */ /* Remove protocol from adapter's bound protocols list */
KeAcquireSpinLock(&AdapterBinding->Adapter->Lock, &OldIrql); KeAcquireSpinLock(&AdapterBinding->Adapter->NdisMiniportBlock.Lock, &OldIrql);
RemoveEntryList(&AdapterBinding->AdapterListEntry); RemoveEntryList(&AdapterBinding->AdapterListEntry);
KeReleaseSpinLock(&AdapterBinding->Adapter->Lock, OldIrql); KeReleaseSpinLock(&AdapterBinding->Adapter->NdisMiniportBlock.Lock, OldIrql);
ExFreePool(AdapterBinding); ExFreePool(AdapterBinding);
@ -404,7 +404,7 @@ NdisOpenAdapter(
/* Find the media type in the list provided by the protocol driver */ /* Find the media type in the list provided by the protocol driver */
Found = FALSE; Found = FALSE;
for (i = 0; i < MediumArraySize; i++) { for (i = 0; i < MediumArraySize; i++) {
if (Adapter->MediaType == MediumArray[i]) { if (Adapter->NdisMiniportBlock.MediaType == MediumArray[i]) {
*SelectedMediumIndex = i; *SelectedMediumIndex = i;
Found = TRUE; Found = TRUE;
break; break;
@ -428,18 +428,18 @@ NdisOpenAdapter(
AdapterBinding->ProtocolBinding = Protocol; AdapterBinding->ProtocolBinding = Protocol;
AdapterBinding->Adapter = Adapter; AdapterBinding->Adapter = Adapter;
AdapterBinding->ProtocolBindingContext = ProtocolBindingContext; AdapterBinding->NdisOpenBlock.ProtocolBindingContext = ProtocolBindingContext;
/* Set fields required by some NDIS macros */ /* Set fields required by some NDIS macros */
AdapterBinding->MacBindingHandle = (NDIS_HANDLE)AdapterBinding; AdapterBinding->NdisOpenBlock.MacBindingHandle = (NDIS_HANDLE)AdapterBinding;
/* Set handlers (some NDIS macros require these) */ /* Set handlers (some NDIS macros require these) */
AdapterBinding->RequestHandler = ProRequest; AdapterBinding->NdisOpenBlock.RequestHandler = ProRequest;
AdapterBinding->ResetHandler = ProReset; AdapterBinding->NdisOpenBlock.ResetHandler = ProReset;
AdapterBinding->u1.SendHandler = ProSend; AdapterBinding->NdisOpenBlock.u1.SendHandler = ProSend;
AdapterBinding->SendPacketsHandler = ProSendPackets; AdapterBinding->NdisOpenBlock.SendPacketsHandler = ProSendPackets;
AdapterBinding->TransferDataHandler = ProTransferData; AdapterBinding->NdisOpenBlock.TransferDataHandler = ProTransferData;
/* Put on protocol's bound adapters list */ /* Put on protocol's bound adapters list */
ExInterlockedInsertTailList(&Protocol->AdapterListHead, ExInterlockedInsertTailList(&Protocol->AdapterListHead,
@ -449,7 +449,7 @@ NdisOpenAdapter(
/* Put protocol on adapter's bound protocols list */ /* Put protocol on adapter's bound protocols list */
ExInterlockedInsertTailList(&Adapter->ProtocolListHead, ExInterlockedInsertTailList(&Adapter->ProtocolListHead,
&AdapterBinding->AdapterListEntry, &AdapterBinding->AdapterListEntry,
&Adapter->Lock); &Adapter->NdisMiniportBlock.Lock);
*NdisBindingHandle = (NDIS_HANDLE)AdapterBinding; *NdisBindingHandle = (NDIS_HANDLE)AdapterBinding;

View file

@ -9,6 +9,6 @@ cp ntoskrnl/ntoskrnl.exe $1
cp services/fs/vfat/vfatfs.sys $1 cp services/fs/vfat/vfatfs.sys $1
cp services/dd/ide/ide.sys $1 cp services/dd/ide/ide.sys $1
#cp services/dd/floppy/floppy.sys $1 #cp services/dd/floppy/floppy.sys $1
cp ntoskrnl/ntoskrnl.exe $1/reactos/system32/ #cp ntoskrnl/ntoskrnl.exe $1/reactos/system32/
cp services/fs/vfat/vfatfs.sys $1/reactos/system32/drivers/ #cp services/fs/vfat/vfatfs.sys $1/reactos/system32/drivers/
cp services/dd/ide/ide.sys $1/reactos/system32/drivers/ #cp services/dd/ide/ide.sys $1/reactos/system32/drivers/

View file

@ -11,6 +11,8 @@
* please read EDIT.TODO (and update it when you change things) * please read EDIT.TODO (and update it when you change things)
*/ */
#include <ntos/minmax.h>
#include <windows.h> #include <windows.h>
#include <user32/win.h> #include <user32/win.h>
#include <user32/class.h> #include <user32/class.h>
@ -820,7 +822,7 @@ static void EDIT_BuildLineDefs_ML(WND *wnd, EDITSTATE *es)
current_def->length = current_def->net_length; current_def->length = current_def->net_length;
break; break;
} }
es->text_width = MAX(es->text_width, current_def->width); es->text_width = max(es->text_width, current_def->width);
start += current_def->length; start += current_def->length;
*previous_next = current_def; *previous_next = current_def;
previous_next = &current_def->next; previous_next = &current_def->next;
@ -973,8 +975,8 @@ static INT EDIT_CharFromPos(WND *wnd, EDITSTATE *es, INT x, INT y, LPBOOL after_
*/ */
static void EDIT_ConfinePoint(WND *wnd, EDITSTATE *es, LPINT x, LPINT y) static void EDIT_ConfinePoint(WND *wnd, EDITSTATE *es, LPINT x, LPINT y)
{ {
*x = MIN(MAX(*x, es->format_rect.left), es->format_rect.right - 1); *x = min(max(*x, es->format_rect.left), es->format_rect.right - 1);
*y = MIN(MAX(*y, es->format_rect.top), es->format_rect.bottom - 1); *y = min(max(*y, es->format_rect.top), es->format_rect.bottom - 1);
} }
@ -1183,14 +1185,14 @@ static BOOL EDIT_MakeFit(WND *wnd, EDITSTATE *es, INT size)
EDIT_UnlockBuffer(wnd, es, TRUE); EDIT_UnlockBuffer(wnd, es, TRUE);
if (es->text) { if (es->text) {
if ((es->text = HeapReAlloc(es->heap, 0, es->text, size + 1))) if ((es->text = HeapReAlloc(es->heap, 0, es->text, size + 1)))
es->buffer_size = MIN(HeapSize(es->heap, 0, es->text) - 1, es->buffer_limit); es->buffer_size = min(HeapSize(es->heap, 0, es->text) - 1, es->buffer_limit);
else else
es->buffer_size = 0; es->buffer_size = 0;
} else if (es->hloc) { } else if (es->hloc) {
if ((hNew = LocalReAlloc(es->hloc, size + 1, 0))) { if ((hNew = LocalReAlloc(es->hloc, size + 1, 0))) {
DPRINT( "Old bit handle %08x, new handle %08x\n", es->hloc, hNew); DPRINT( "Old bit handle %08x, new handle %08x\n", es->hloc, hNew);
es->hloc = hNew; es->hloc = hNew;
es->buffer_size = MIN(LocalSize(es->hloc) - 1, es->buffer_limit); es->buffer_size = min(LocalSize(es->hloc) - 1, es->buffer_limit);
} }
} }
if (es->buffer_size < size) { if (es->buffer_size < size) {
@ -1522,8 +1524,8 @@ static void EDIT_PaintLine(WND *wnd, EDITSTATE *es, HDC dc, INT line, BOOL rev)
s = es->selection_start; s = es->selection_start;
e = es->selection_end; e = es->selection_end;
ORDER_INT(s, e); ORDER_INT(s, e);
s = MIN(li + ll, MAX(li, s)); s = min(li + ll, max(li, s));
e = MIN(li + ll, MAX(li, e)); e = min(li + ll, max(li, e));
if (rev && (s != e) && if (rev && (s != e) &&
((es->flags & EF_FOCUSED) || (es->style & ES_NOHIDESEL))) { ((es->flags & EF_FOCUSED) || (es->style & ES_NOHIDESEL))) {
x += EDIT_PaintText(wnd, es, dc, x, y, line, 0, s - li, FALSE); x += EDIT_PaintText(wnd, es, dc, x, y, line, 0, s - li, FALSE);
@ -1622,10 +1624,10 @@ static void EDIT_SetRectNP(WND *wnd, EDITSTATE *es, LPRECT rc)
} }
es->format_rect.left += es->left_margin; es->format_rect.left += es->left_margin;
es->format_rect.right -= es->right_margin; es->format_rect.right -= es->right_margin;
es->format_rect.right = MAX(es->format_rect.right, es->format_rect.left + es->char_width); es->format_rect.right = max(es->format_rect.right, es->format_rect.left + es->char_width);
if (es->style & ES_MULTILINE) if (es->style & ES_MULTILINE)
es->format_rect.bottom = es->format_rect.top + es->format_rect.bottom = es->format_rect.top +
MAX(1, (es->format_rect.bottom - es->format_rect.top) / es->line_height) * es->line_height; max(1, (es->format_rect.bottom - es->format_rect.top) / es->line_height) * es->line_height;
else else
es->format_rect.bottom = es->format_rect.top + es->line_height; es->format_rect.bottom = es->format_rect.top + es->line_height;
if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
@ -1808,7 +1810,7 @@ static HLOCAL EDIT_EM_GetHandle(WND *wnd, EDITSTATE *es)
DPRINT( "could not allocate new bit buffer\n"); DPRINT( "could not allocate new bit buffer\n");
return 0; return 0;
} }
newSize = MIN(LocalSize(newBuf) - 1, es->buffer_limit); newSize = min(LocalSize(newBuf) - 1, es->buffer_limit);
if (!(newText = LocalLock(newBuf))) { if (!(newText = LocalLock(newBuf))) {
DPRINT( "could not lock new bit buffer\n"); DPRINT( "could not lock new bit buffer\n");
LocalFree(newBuf); LocalFree(newBuf);
@ -1848,7 +1850,7 @@ static INT EDIT_EM_GetLine(WND *wnd, EDITSTATE *es, INT line, LPSTR lpch)
line = 0; line = 0;
i = EDIT_EM_LineIndex(wnd, es, line); i = EDIT_EM_LineIndex(wnd, es, line);
src = es->text + i; src = es->text + i;
len = MIN(*(WORD *)lpch, EDIT_EM_LineLength(wnd, es, i)); len = min(*(WORD *)lpch, EDIT_EM_LineLength(wnd, es, i));
for (i = 0 ; i < len ; i++) { for (i = 0 ; i < len ; i++) {
*lpch = *src; *lpch = *src;
src++; src++;
@ -1912,7 +1914,7 @@ static INT EDIT_EM_LineFromChar(WND *wnd, EDITSTATE *es, INT index)
if (index > lstrlenA(es->text)) if (index > lstrlenA(es->text))
return es->line_count - 1; return es->line_count - 1;
if (index == -1) if (index == -1)
index = MIN(es->selection_start, es->selection_end); index = min(es->selection_start, es->selection_end);
line = 0; line = 0;
line_def = es->first_line_def; line_def = es->first_line_def;
@ -2013,7 +2015,7 @@ static BOOL EDIT_EM_LineScroll(WND *wnd, EDITSTATE *es, INT dx, INT dy)
dx = -es->x_offset; dx = -es->x_offset;
if (dx > es->text_width - es->x_offset) if (dx > es->text_width - es->x_offset)
dx = es->text_width - es->x_offset; dx = es->text_width - es->x_offset;
nyoff = MAX(0, es->y_offset + dy); nyoff = max(0, es->y_offset + dy);
if (nyoff >= es->line_count) if (nyoff >= es->line_count)
nyoff = es->line_count - 1; nyoff = es->line_count - 1;
dy = (es->y_offset - nyoff) * es->line_height; dy = (es->y_offset - nyoff) * es->line_height;
@ -2051,7 +2053,7 @@ static LRESULT EDIT_EM_PosFromChar(WND *wnd, EDITSTATE *es, INT index, BOOL afte
HFONT old_font = 0; HFONT old_font = 0;
SIZE size; SIZE size;
index = MIN(index, len); index = min(index, len);
dc = GetDC(wnd->hwndSelf); dc = GetDC(wnd->hwndSelf);
if (es->font) if (es->font)
old_font = SelectObject(dc, es->font); old_font = SelectObject(dc, es->font);
@ -2368,12 +2370,12 @@ static void EDIT_EM_SetLimitText(WND *wnd, EDITSTATE *es, INT limit)
{ {
if (es->style & ES_MULTILINE) { if (es->style & ES_MULTILINE) {
if (limit) if (limit)
es->buffer_limit = MIN(limit, BUFLIMIT_MULTI); es->buffer_limit = min(limit, BUFLIMIT_MULTI);
else else
es->buffer_limit = BUFLIMIT_MULTI; es->buffer_limit = BUFLIMIT_MULTI;
} else { } else {
if (limit) if (limit)
es->buffer_limit = MIN(limit, BUFLIMIT_SINGLE); es->buffer_limit = min(limit, BUFLIMIT_SINGLE);
else else
es->buffer_limit = BUFLIMIT_SINGLE; es->buffer_limit = BUFLIMIT_SINGLE;
} }
@ -2459,8 +2461,8 @@ static void EDIT_EM_SetSel(WND *wnd, EDITSTATE *es, UINT start, UINT end, BOOL a
start = es->selection_end; start = es->selection_end;
end = es->selection_end; end = es->selection_end;
} else { } else {
start = MIN(start, len); start = min(start, len);
end = MIN(end, len); end = min(end, len);
} }
es->selection_start = start; es->selection_start = start;
es->selection_end = end; es->selection_end = end;
@ -3347,7 +3349,7 @@ static void EDIT_WM_Paint(WND *wnd, EDITSTATE *es)
GetClipBox(dc, &rcRgn); GetClipBox(dc, &rcRgn);
if (es->style & ES_MULTILINE) { if (es->style & ES_MULTILINE) {
INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
for (i = es->y_offset ; i <= MIN(es->y_offset + vlc, es->y_offset + es->line_count - 1) ; i++) { for (i = es->y_offset ; i <= min(es->y_offset + vlc, es->y_offset + es->line_count - 1) ; i++) {
EDIT_GetLineRect(wnd, es, i, 0, -1, &rcLine); EDIT_GetLineRect(wnd, es, i, 0, -1, &rcLine);
if (IntersectRect(&rc, &rcRgn, &rcLine)) if (IntersectRect(&rc, &rcRgn, &rcLine))
EDIT_PaintLine(wnd, es, dc, i, rev); EDIT_PaintLine(wnd, es, dc, i, rev);

View file

@ -4,6 +4,10 @@
* Copyright 1996 Alexandre Julliard * Copyright 1996 Alexandre Julliard
*/ */
#include <ntos/minmax.h>
#define MIN min
#define MAX max
#include <string.h> #include <string.h>
#include <windows.h> #include <windows.h>
#include <user32/win.h> #include <user32/win.h>

View file

@ -12,6 +12,7 @@
* This is probably not the meaning this style has in MS-Windows. * This is probably not the meaning this style has in MS-Windows.
*/ */
#include <ntos/minmax.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -5,6 +5,10 @@
* Copyright 1994, 1996 Alexandre Julliard * Copyright 1994, 1996 Alexandre Julliard
*/ */
#include <ntos/minmax.h>
#define MAX max
#define MIN min
#include <windows.h> #include <windows.h>
#include <user32/sysmetr.h> #include <user32/sysmetr.h>
#include <user32/scroll.h> #include <user32/scroll.h>

View file

@ -5,6 +5,10 @@
* *
*/ */
#include <ntos/minmax.h>
#define MIN min
#define MAX max
#include <windows.h> #include <windows.h>
#include <user32/win.h> #include <user32/win.h>

View file

@ -1,3 +1,7 @@
#include <ntos/minmax.h>
#define MIN min
#define MAX max
#include <windows.h> #include <windows.h>
#include <user32/dce.h> #include <user32/dce.h>
#include <user32/win.h> #include <user32/win.h>

View file

@ -1,3 +1,7 @@
#include <ntos/minmax.h>
#define MAX max
#define MIN min
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
#include <user32/nc.h> #include <user32/nc.h>

View file

@ -4,6 +4,11 @@
* Copyright 1993, 1994, 1995 Alexandre Julliard * Copyright 1993, 1994, 1995 Alexandre Julliard
* 1995, 1996 Alex Korobka * 1995, 1996 Alex Korobka
*/ */
#include <ntos/minmax.h>
#define MIN min
#define MAX max
#include <windows.h> #include <windows.h>
#include <string.h> #include <string.h>
#include <user32/sysmetr.h> #include <user32/sysmetr.h>

View file

@ -1,3 +1,7 @@
#include <ntos/minmax.h>
#define MIN min
#define MAX max
#define UNICODE #define UNICODE
#include <windows.h> #include <windows.h>
#include <user32/win.h> #include <user32/win.h>

View file

@ -1,3 +1,7 @@
#include <ntos/minmax.h>
#define MIN min
#define MAX max
#include <windows.h> #include <windows.h>
#include <user32/nc.h> #include <user32/nc.h>

View file

@ -34,7 +34,7 @@ org 100h
; ;
BITS 16 BITS 16
;%define NDEBUG 1 %define NDEBUG 1
%macro DPRINT 1+ %macro DPRINT 1+
%ifndef NDEBUG %ifndef NDEBUG
@ -124,13 +124,39 @@ entry:
; ;
mov [_start_kernel],ebx mov [_start_kernel],ebx
;
; Setup various variables
;
mov bx,ds
movzx eax,bx
shl eax,4
add [gdt_base],eax
;
; Make the argument list into a c string
;
mov di,081h
mov si,_kernel_parameters
l21:
mov al,[di]
mov [si],al
cmp byte [di],0dh
je l22
inc di
inc si
jmp l21
l22:
mov byte [di], 0
mov byte [si], 0
mov [end_cmd_line], di
; ;
; Make the argument list into a c string ; Make the argument list into a c string
; ;
mov di,081h mov di,081h
l1: l1:
cmp byte [di],0dh cmp byte [di], 0
je l2 je l2
cmp byte [di],' ' cmp byte [di],' '
jne l12 jne l12
mov byte [di],0 mov byte [di],0
@ -138,10 +164,20 @@ l12:
inc di inc di
jmp l1 jmp l1
l2: l2:
mov byte [di],0
mov [end_cmd_line],di
;
; Check if we want to skip the first character
;
cmp byte [081h],0
jne l32
mov dx,082h mov dx,082h
jmp l14
l32:
mov dx,081h
;
; Check if we have reached the end of the string
;
l14: l14:
mov bx,dx mov bx,dx
cmp byte [bx],0 cmp byte [bx],0
@ -150,6 +186,9 @@ l14:
; ;
; Process the arguments ; Process the arguments
; ;
cmp byte [di], '/'
je l15
mov di,loading_msg mov di,loading_msg
call print_string call print_string
mov di,dx mov di,dx
@ -770,6 +809,58 @@ DPRINT 'next load base %A', 13, 10, 0
call print_string call print_string
jmp exit jmp exit
;
; copy 'ecx' bytes from 'es:esi' to logical address 'edi'
; 'eax' is destroyed
;
himem_copy:
push ds
;
; load gdt
;
lgdt [gdt_descr]
;
; Enter pmode and clear prefetch queue
;
mov eax,cr0
or eax,0x1
mov cr0,eax
jmp himem_copy_next
himem_copy_next:
;
; Load the ds register with a segment suitable for accessing
; logical addresses
;
mov ax, KERNEL_DS
mov ds, ax
;
; Copy the data
;
himem_copy_l1:
mov al, [es:si]
mov [ds:edi], al
dec ecx
jnz himem_copy_l1
;
; Exit protected mode
;
mov eax,cr0
and eax,0xfffffffe
mov cr0,eax
jmp himem_copy_next1
himem_copy_next1:
;
; Restore ds
;
pop ds
ret
; ;
; Handle of the currently open file ; Handle of the currently open file
; ;
@ -1005,14 +1096,6 @@ l8:
mov eax,[kernel_page_directory_base] mov eax,[kernel_page_directory_base]
mov cr3,eax mov cr3,eax
;
; Setup various variables
;
mov bx,ds
movzx eax,bx
shl eax,4
add [gdt_base],eax
; ;
; Enable the A20 address line (to allow access to over 1mb) ; Enable the A20 address line (to allow access to over 1mb)
; ;
@ -1127,21 +1210,6 @@ gdt:
dw 0 dw 0
dw 0 dw 0
;dw 00000h ; User code descriptor
;dw 00000h ; base: 0h limit: 3gb
;dw 0fa00h
;dw 000cch
;dw 00000h ; User data descriptor
;dw 00000h ; base: 0h limit: 3gb
;dw 0f200h
;dw 000cch
;dw 00000h
;dw 00000h
;dw 00000h
;dw 00000h
dw 0ffffh ; Kernel code descriptor dw 0ffffh ; Kernel code descriptor
dw 00000h ; dw 00000h ;
dw 09a00h ; base 0h limit 4gb dw 09a00h ; base 0h limit 4gb
@ -1152,9 +1220,6 @@ gdt:
dw 09200h ; base 0h limit 4gb dw 09200h ; base 0h limit 4gb
dw 000cfh dw 000cfh
;times NR_TASKS*8 db 0
_end: _end:

View file

@ -1,4 +1,4 @@
/* $Id: fmutex.c,v 1.1 2000/06/09 20:05:00 ekohl Exp $ /* $Id: fmutex.c,v 1.2 2000/08/30 19:33:28 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -18,12 +18,8 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID VOID FASTCALL EXPORTED
FASTCALL ExAcquireFastMutex (PFAST_MUTEX FastMutex)
EXPORTED
ExAcquireFastMutex (
PFAST_MUTEX FastMutex
)
{ {
KeEnterCriticalRegion(); KeEnterCriticalRegion();
if (InterlockedDecrement(&(FastMutex->Count))==0) if (InterlockedDecrement(&(FastMutex->Count))==0)
@ -40,12 +36,8 @@ ExAcquireFastMutex (
} }
VOID VOID FASTCALL EXPORTED
FASTCALL ExReleaseFastMutex (PFAST_MUTEX FastMutex)
EXPORTED
ExReleaseFastMutex (
PFAST_MUTEX FastMutex
)
{ {
assert(FastMutex->Owner == KeGetCurrentThread()); assert(FastMutex->Owner == KeGetCurrentThread());
FastMutex->Owner=NULL; FastMutex->Owner=NULL;
@ -59,12 +51,8 @@ ExReleaseFastMutex (
} }
BOOLEAN BOOLEAN FASTCALL EXPORTED
FASTCALL ExTryToAcquireFastMutex (PFAST_MUTEX FastMutex)
EXPORTED
ExTryToAcquireFastMutex (
PFAST_MUTEX FastMutex
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }

View file

@ -1,4 +1,4 @@
/* $Id: halinit.c,v 1.14 2000/07/24 23:50:13 ekohl Exp $ /* $Id: halinit.c,v 1.15 2000/08/30 19:33:28 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -21,17 +21,13 @@
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
BOOLEAN BOOLEAN STDCALL
STDCALL HalInitSystem (ULONG BootPhase,
HalInitSystem ( PLOADER_PARAMETER_BLOCK LoaderBlock)
ULONG BootPhase,
PLOADER_PARAMETER_BLOCK LoaderBlock
)
{ {
if (BootPhase == 0) if (BootPhase == 0)
{ {
HalInitializeDisplay (LoaderBlock); HalInitializeDisplay (LoaderBlock);
HalpCalibrateStallExecution ();
HalpInitPICs (); HalpInitPICs ();
} }
else else

View file

@ -81,9 +81,9 @@ static VOID HiSwitchIrql(KIRQL oldIrql)
{ {
unsigned int current_mask = 0; unsigned int current_mask = 0;
for (i=(CurrentIrql-DISPATCH_LEVEL);i>DISPATCH_LEVEL;i--) for (i=CurrentIrql; i>DISPATCH_LEVEL; i--)
{ {
set_bit(NR_DEVICE_SPECIFIC_LEVELS - i,&current_mask); current_mask = current_mask | (1 << (HIGH_LEVEL - i));
} }
HiSetCurrentPICMask(current_mask); HiSetCurrentPICMask(current_mask);

View file

@ -1,4 +1,4 @@
/* $Id: udelay.c,v 1.1 2000/04/08 19:08:50 ekohl Exp $ /* $Id: udelay.c,v 1.2 2000/08/30 19:33:28 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -20,64 +20,149 @@
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
#define MICROSECONDS_PER_TICK (54945) static unsigned int delay_count = 1;
#define TICKS_TO_CALIBRATE (1)
#define CALIBRATE_PERIOD (MICROSECONDS_PER_TICK * TICKS_TO_CALIBRATE)
#define SYSTEM_TIME_UNITS_PER_MSEC (10000)
static unsigned int loops_per_microsecond = 100; #define MILLISEC (10)
#define FREQ (1000/MILLISEC)
//extern ULONGLONG KiTimerTicks; #define PRECISION (8)
#define TMR_CTRL 0x43 /* I/O for control */
#define TMR_CNT0 0x40 /* I/O for counter 0 */
#define TMR_CNT1 0x41 /* I/O for counter 1 */
#define TMR_CNT2 0x42 /* I/O for counter 2 */
#define TMR_SC0 0 /* Select channel 0 */
#define TMR_SC1 0x40 /* Select channel 1 */
#define TMR_SC2 0x80 /* Select channel 2 */
#define TMR_LOW 0x10 /* RW low byte only */
#define TMR_HIGH 0x20 /* RW high byte only */
#define TMR_BOTH 0x30 /* RW both bytes */
#define TMR_MD0 0 /* Mode 0 */
#define TMR_MD1 0x2 /* Mode 1 */
#define TMR_MD2 0x4 /* Mode 2 */
#define TMR_MD3 0x6 /* Mode 3 */
#define TMR_MD4 0x8 /* Mode 4 */
#define TMR_MD5 0xA /* Mode 5 */
#define TMR_BCD 1 /* BCD mode */
#define TMR_LATCH 0 /* Latch command */
#define TMR_READ 0xF0 /* Read command */
#define TMR_CNT 0x20 /* CNT bit (Active low, subtract it) */
#define TMR_STAT 0x10 /* Status bit (Active low, subtract it) */
#define TMR_CH2 0x8 /* Channel 2 bit */
#define TMR_CH1 0x4 /* Channel 1 bit */
#define TMR_CH0 0x2 /* Channel 0 bit */
/* FUNCTIONS **************************************************************/ /* FUNCTIONS **************************************************************/
void init_pit(float h, unsigned char channel)
{
unsigned int temp=0;
temp = 1193180/h;
// WRITE_PORT_UCHAR((PUCHAR)TMR_CTRL,
// (channel*0x40) + TMR_BOTH + TMR_MD3);
WRITE_PORT_UCHAR((PUCHAR)TMR_CTRL,
(channel*0x40) + TMR_BOTH + TMR_MD2);
WRITE_PORT_UCHAR((PUCHAR)(0x40+channel),
(unsigned char) temp);
WRITE_PORT_UCHAR((PUCHAR)(0x40+channel),
(unsigned char) (temp>>8));
}
VOID STDCALL
__KeStallExecutionProcessor(ULONG Loops)
{
unsigned int i;
for (i=0; i<Loops;i++);
}
VOID STDCALL KeStallExecutionProcessor(ULONG Microseconds)
{
return(__KeStallExecutionProcessor((delay_count*(Microseconds/1000))));
}
#define HZ (100)
#define CLOCK_TICK_RATE (1193180)
#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ)
VOID HalpCalibrateStallExecution(VOID) VOID HalpCalibrateStallExecution(VOID)
{ {
// unsigned int start_tick; unsigned int prevtick;
// unsigned int end_tick; unsigned int i;
// unsigned int nr_ticks; unsigned int calib_bit;
// unsigned int i; extern volatile ULONG KiRawTicks;
// unsigned int microseconds;
DbgPrint("Calibrating delay loop... [");
/* Initialise timer interrupt with MILLISECOND ms interval */
//init_pit(FREQ, 0);
WRITE_PORT_UCHAR((PUCHAR)0x43, 0x34); /* binary, mode 2, LSB/MSB, ch 0 */
WRITE_PORT_UCHAR((PUCHAR)0x40, LATCH & 0xff); /* LSB */
WRITE_PORT_UCHAR((PUCHAR)0x40, LATCH >> 8); /* MSB */
/* Stage 1: Coarse calibration */
do {
delay_count <<= 1; /* Next delay count to try */
prevtick=KiRawTicks; /* Wait for the start of the next */
while(prevtick==KiRawTicks); /* timer tick */
prevtick=KiRawTicks; /* Start measurement now */
__KeStallExecutionProcessor(delay_count); /* Do the delay */
} while(prevtick == KiRawTicks); /* Until delay is just too big */
delay_count >>= 1; /* Get bottom value for delay */
/* Stage 2: Fine calibration */
calib_bit = delay_count; /* Which bit are we going to test */
for(i=0;i<PRECISION;i++) {
calib_bit >>= 1; /* Next bit to calibrate */
if(!calib_bit) break; /* If we have done all bits, stop */
delay_count |= calib_bit; /* Set the bit in delay_count */
prevtick=KiRawTicks; /* Wait for the start of the next */
while(prevtick==KiRawTicks); /* timer tick */
prevtick=KiRawTicks; /* Start measurement now */
__KeStallExecutionProcessor(delay_count); /* Do the delay */
if(prevtick != KiRawTicks) /* If a tick has passed, turn the */
delay_count &= ~calib_bit; /* calibrated bit back off */
}
/* We're finished: Do the finishing touches */
delay_count /= MILLISEC; /* Calculate delay_count for 1ms */
DbgPrint("]\n");
DbgPrint("delay_count: %d\n", delay_count);
DbgPrint("CPU speed: %d\n", delay_count/500);
#if 0 #if 0
for (i=0;i<20;i++) DbgPrint("About to start delay loop test\n");
for (i = 0; i < (10*1000*20); i++)
{ {
start_tick = KiTimerTicks; KeStallExecutionProcessor(50);
microseconds = 0;
while (start_tick == KiTimerTicks);
while (KiTimerTicks == (start_tick+TICKS_TO_CALIBRATE))
{
KeStallExecutionProcessor(1);
microseconds++;
};
// DbgPrint("microseconds %d\n",microseconds);
if (microseconds > (CALIBRATE_PERIOD+1000))
{
loops_per_microsecond = loops_per_microsecond + 1;
}
if (microseconds < (CALIBRATE_PERIOD-1000))
{
loops_per_microsecond = loops_per_microsecond - 1;
}
// DbgPrint("loops_per_microsecond %d\n",loops_per_microsecond);
} }
// for(;;); DbgPrint("Waiting for five minutes...");
KeStallExecutionProcessor(5*60*1000*1000);
for (i = 0; i < (5*60*1000*20); i++)
{
KeStallExecutionProcessor(50);
}
DbgPrint("finished\n");
for(;;);
#endif #endif
} }
VOID
STDCALL
KeStallExecutionProcessor(ULONG MicroSeconds)
{
unsigned int i;
for (i=0; i<(loops_per_microsecond*MicroSeconds) ;i++)
{
__asm__("nop\n\t");
}
}
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: kdebug.c,v 1.13 2000/08/12 19:33:21 dwelch Exp $ /* $Id: kdebug.c,v 1.14 2000/08/30 19:33:28 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -43,7 +43,7 @@ KdDebuggerNotPresent = TRUE; /* EXPORTED */
static BOOLEAN KdpBreakPending = FALSE; static BOOLEAN KdpBreakPending = FALSE;
static BOOLEAN KdpBreakRecieved = FALSE; static BOOLEAN KdpBreakRecieved = FALSE;
static ULONG KdpDebugType = BochsDebug; static ULONG KdpDebugType = ScreenDebug | BochsDebug;
/* PRIVATE FUNCTIONS ********************************************************/ /* PRIVATE FUNCTIONS ********************************************************/

View file

@ -19,7 +19,6 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
static ULONG HardwareMathSupport; static ULONG HardwareMathSupport;
static ULONG x;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -43,11 +42,8 @@ VOID KiCheckFPU(VOID)
return; return;
} }
/* FIXME: Do fsetpm */ /* FIXME: Do fsetpm */
DbgPrint("Detected FPU\n");
HardwareMathSupport = 1; HardwareMathSupport = 1;
DbgPrint("Testing FPU\n");
x = x * 6.789456;
} }
VOID KeInit1(VOID) VOID KeInit1(VOID)

View file

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.59 2000/08/25 15:54:11 ekohl Exp $ /* $Id: main.c,v 1.60 2000/08/30 19:33:28 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -23,13 +23,12 @@
#include <internal/ps.h> #include <internal/ps.h>
#include <internal/hal.h> #include <internal/hal.h>
#include <internal/ke.h> #include <internal/ke.h>
#include <internal/io.h>
#include <internal/mmhal.h> #include <internal/mmhal.h>
#include <internal/i386/segment.h> #include <internal/i386/segment.h>
#include <napi/shared_data.h> #include <napi/shared_data.h>
#define NDEBUG //#define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
/* DATA *********************************************************************/ /* DATA *********************************************************************/
@ -41,311 +40,21 @@ LOADER_PARAMETER_BLOCK EXPORTED KeLoaderBlock;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
static VOID static VOID CreateSystemRootLink (LPWSTR Device)
CreateSystemRootLink (PCSZ ParameterLine)
{ {
UNICODE_STRING LinkName; UNICODE_STRING LinkName;
UNICODE_STRING DeviceName; UNICODE_STRING DeviceName;
UNICODE_STRING ArcName;
UNICODE_STRING BootPath;
PCHAR ParamBuffer;
PWCHAR ArcNameBuffer;
PCHAR p;
NTSTATUS Status;
ULONG Length;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE Handle;
/* create local parameter line copy */
ParamBuffer = ExAllocatePool (PagedPool, 256);
strcpy (ParamBuffer, (char *)ParameterLine);
DPRINT("%s\n", ParamBuffer);
/* Format: <arc_name>\<path> [options...] */
/* cut options off */
p = strchr (ParamBuffer, ' ');
if (p)
*p = 0;
DPRINT("%s\n", ParamBuffer);
/* extract path */
p = strchr (ParamBuffer, '\\');
if (p)
{
DPRINT("Boot path: %s\n", p);
RtlCreateUnicodeStringFromAsciiz (&BootPath, p);
*p = 0;
}
else
{
DPRINT("Boot path: %s\n", "\\");
RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
}
DPRINT("Arc name: %s\n", ParamBuffer);
/* Only arc name left - build full arc name */
ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
swprintf (ArcNameBuffer,
L"\\ArcName\\%S", ParamBuffer);
RtlInitUnicodeString (&ArcName, ArcNameBuffer);
DPRINT("Arc name: %wZ\n", &ArcName);
/* free ParamBuffer */
ExFreePool (ParamBuffer);
/* allocate device name string */
DeviceName.Length = 0;
DeviceName.MaximumLength = 256 * sizeof(WCHAR);
DeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
InitializeObjectAttributes (&ObjectAttributes,
&ArcName,
0,
NULL,
NULL);
Status = NtOpenSymbolicLinkObject (&Handle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes);
RtlFreeUnicodeString (&ArcName);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString (&BootPath);
RtlFreeUnicodeString (&DeviceName);
DbgPrint("NtOpenSymbolicLinkObject() failed (Status %x)\n",
Status);
KeBugCheck (0x0);
}
Status = NtQuerySymbolicLinkObject (Handle,
&DeviceName,
&Length);
NtClose (Handle);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString (&BootPath);
RtlFreeUnicodeString (&DeviceName);
DbgPrint("NtQuerySymbolicObject() failed (Status %x)\n",
Status);
KeBugCheck (0x0);
}
DPRINT("Length: %lu DeviceName: %wZ\n", Length, &DeviceName);
RtlAppendUnicodeStringToString (&DeviceName,
&BootPath);
RtlFreeUnicodeString (&BootPath);
DPRINT("DeviceName: %wZ\n", &DeviceName);
/* create the '\SystemRoot' link */
RtlInitUnicodeString (&LinkName, RtlInitUnicodeString (&LinkName,
L"\\SystemRoot"); L"\\SystemRoot");
Status = IoCreateSymbolicLink (&LinkName, RtlInitUnicodeString (&DeviceName,
&DeviceName); Device);
RtlFreeUnicodeString (&DeviceName);
if (!NT_SUCCESS(Status))
{
DbgPrint("IoCreateSymbolicLink() failed (Status %x)\n",
Status);
KeBugCheck (0x0); IoCreateSymbolicLink (&LinkName,
} &DeviceName);
/*
* FIXME: test if '\SystemRoot' (LinkName)can be opened,
* otherwise crash it!
*/
} }
static VOID
InitSystemSharedUserPage (PCSZ ParameterLine)
{
PKUSER_SHARED_DATA SharedPage;
UNICODE_STRING ArcDeviceName;
UNICODE_STRING ArcName;
UNICODE_STRING BootPath;
UNICODE_STRING DriveDeviceName;
UNICODE_STRING DriveName;
WCHAR DriveNameBuffer[20];
PCHAR ParamBuffer;
PWCHAR ArcNameBuffer;
PCHAR p;
NTSTATUS Status;
ULONG Length;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE Handle;
ULONG i;
BOOLEAN BootDriveFound;
SharedPage = (PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE;
SharedPage->DosDeviceMap = 0;
SharedPage->NtProductType = NtProductWinNt;
for (i = 0; i < 32; i++)
{
SharedPage->DosDeviceDriveType[i] = 0;
}
BootDriveFound = FALSE;
/*
* Retrieve the current dos system path
* (e.g.: C:\reactos) from the given arc path
* (e.g.: multi(0)disk(0)rdisk(0)partititon(1)\reactos)
* Format: "<arc_name>\<path> [options...]"
*/
/* create local parameter line copy */
ParamBuffer = ExAllocatePool (PagedPool, 256);
strcpy (ParamBuffer, (char *)ParameterLine);
DPRINT("%s\n", ParamBuffer);
/* cut options off */
p = strchr (ParamBuffer, ' ');
if (p)
{
*p = 0;
}
DPRINT("%s\n", ParamBuffer);
/* extract path */
p = strchr (ParamBuffer, '\\');
if (p)
{
DPRINT("Boot path: %s\n", p);
RtlCreateUnicodeStringFromAsciiz (&BootPath, p);
*p = 0;
}
else
{
DPRINT("Boot path: %s\n", "\\");
RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
}
DPRINT("Arc name: %s\n", ParamBuffer);
/* Only arc name left - build full arc name */
ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
swprintf (ArcNameBuffer, L"\\ArcName\\%S", ParamBuffer);
RtlInitUnicodeString (&ArcName, ArcNameBuffer);
DPRINT("Arc name: %wZ\n", &ArcName);
/* free ParamBuffer */
ExFreePool (ParamBuffer);
/* allocate arc device name string */
ArcDeviceName.Length = 0;
ArcDeviceName.MaximumLength = 256 * sizeof(WCHAR);
ArcDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
InitializeObjectAttributes (&ObjectAttributes,
&ArcName,
0,
NULL,
NULL);
Status = NtOpenSymbolicLinkObject (&Handle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes);
RtlFreeUnicodeString (&ArcName);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString (&BootPath);
RtlFreeUnicodeString (&ArcDeviceName);
DbgPrint("NtOpenSymbolicLinkObject() failed (Status %x)\n",
Status);
KeBugCheck (0x0);
}
Status = NtQuerySymbolicLinkObject (Handle,
&ArcDeviceName,
&Length);
NtClose (Handle);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString (&BootPath);
RtlFreeUnicodeString (&ArcDeviceName);
DbgPrint("NtQuerySymbolicObject() failed (Status %x)\n",
Status);
KeBugCheck (0x0);
}
DPRINT("Length: %lu ArcDeviceName: %wZ\n", Length, &ArcDeviceName);
/* allocate device name string */
DriveDeviceName.Length = 0;
DriveDeviceName.MaximumLength = 256 * sizeof(WCHAR);
DriveDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
for (i = 0; i < 26; i++)
{
swprintf (DriveNameBuffer, L"\\??\\%C:", 'A' + i);
RtlInitUnicodeString (&DriveName,
DriveNameBuffer);
InitializeObjectAttributes (&ObjectAttributes,
&DriveName,
0,
NULL,
NULL);
Status = NtOpenSymbolicLinkObject (&Handle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
DPRINT("Failed to open link %wZ\n",
&DriveName);
continue;
}
Status = NtQuerySymbolicLinkObject (Handle,
&DriveDeviceName,
&Length);
if (!NT_SUCCESS(Status))
{
DPRINT("Failed query open link %wZ\n",
&DriveName);
continue;
}
DPRINT("Opened link: %wZ ==> %wZ\n",
&DriveName, &DriveDeviceName);
if (!RtlCompareUnicodeString (&ArcDeviceName, &DriveDeviceName, FALSE))
{
DPRINT("DOS Boot path: %c:%wZ\n", 'A' + i, &BootPath);
swprintf (SharedPage->NtSystemRoot,
L"%C:%wZ", 'A' + i, &BootPath);
BootDriveFound = TRUE;
}
NtClose (Handle);
/* set bit in dos drives bitmap (drive available) */
SharedPage->DosDeviceMap |= (1<<i);
}
RtlFreeUnicodeString (&BootPath);
RtlFreeUnicodeString (&DriveDeviceName);
RtlFreeUnicodeString (&ArcDeviceName);
DPRINT("DosDeviceMap: 0x%x\n", SharedPage->DosDeviceMap);
if (BootDriveFound == FALSE)
{
DbgPrint("No system drive found!\n");
KeBugCheck (0x0);
}
}
void _main (PLOADER_PARAMETER_BLOCK LoaderBlock) void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
/* /*
* FUNCTION: Called by the boot loader to start the kernel * FUNCTION: Called by the boot loader to start the kernel
@ -369,8 +78,7 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
* Initializes the kernel parameter line. * Initializes the kernel parameter line.
* This should be done by the boot loader. * This should be done by the boot loader.
*/ */
strcpy (KeLoaderBlock.kernel_parameters, // strcpy (KeLoaderBlock.kernel_parameters, "/DEBUGPORT=SCREEN");
"multi(0)disk(0)rdisk(0)partition(1)\\reactos /DEBUGPORT=SCREEN");
/* /*
* Initialization phase 0 * Initialization phase 0
@ -379,6 +87,9 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
KeInit1(); KeInit1();
KeLowerIrql(DISPATCH_LEVEL); KeLowerIrql(DISPATCH_LEVEL);
DbgPrint("kernel_parameters %s\n",
KeLoaderBlock.kernel_parameters);
/* /*
* Display version number and copyright/warranty message * Display version number and copyright/warranty message
*/ */
@ -437,33 +148,34 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
*/ */
DPRINT1("%d files loaded\n",KeLoaderBlock.nr_files); DPRINT1("%d files loaded\n",KeLoaderBlock.nr_files);
/* Pass 1: load registry chunks passed in */ /* Pass 1: load registry chunks passed in */
start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]); start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
for (i = 1; i < KeLoaderBlock.nr_files; i++) for (i = 1; i < KeLoaderBlock.nr_files; i++)
{ {
if (!strcmp ((PCHAR) start, "REGEDIT4")) if (!strcmp ((PCHAR) start, "REGEDIT4"))
{ {
DPRINT1("process registry chunk at %08lx\n", start); DPRINT1("process registry chunk at %08lx\n", start);
CmImportHive((PCHAR) start); CmImportHive((PCHAR) start);
} }
start = start + KeLoaderBlock.module_length[i]; start = start + KeLoaderBlock.module_length[i];
} }
/* Pass 2: process boot loaded drivers */ /* Pass 2: process boot loaded drivers */
start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]); start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
start1 = start + KeLoaderBlock.module_length[1]; start1 = start + KeLoaderBlock.module_length[1];
for (i=1;i<KeLoaderBlock.nr_files;i++) for (i=1;i<KeLoaderBlock.nr_files;i++)
{ {
if (strcmp ((PCHAR) start, "REGEDIT4")) if (strcmp ((PCHAR) start, "REGEDIT4"))
{ {
DPRINT1("process module at %08lx\n", start); DPRINT1("process module at %08lx\n", start);
LdrProcessDriver((PVOID)start); LdrProcessDriver((PVOID)start);
} }
start = start + KeLoaderBlock.module_length[i]; start = start + KeLoaderBlock.module_length[i];
} }
/* Create the SystemRoot symbolic link */ /* Create the SystemRoot symbolic link */
CreateSystemRootLink (KeLoaderBlock.kernel_parameters); /* Hardcoded to 'C:\reactos' but this will change. */
CreateSystemRootLink (L"\\Device\\Harddisk0\\Partition1\\reactos");
/* /*
* Load Auto configured drivers * Load Auto configured drivers
@ -478,11 +190,12 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
NULL, NULL,
NULL); NULL);
/* /* set system root in shared user page */
* Initialize shared user page: wcscpy (((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->NtSystemRoot,
* - set dos system path, dos device map, etc. L"C:\\reactos");
*/
InitSystemSharedUserPage (KeLoaderBlock.kernel_parameters); ((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->NtProductType = NtProductWinNt;
/* /*
* Launch initial process * Launch initial process

View file

@ -1,4 +1,4 @@
/* $Id: timer.c,v 1.33 2000/07/19 14:23:37 dwelch Exp $ /* $Id: timer.c,v 1.34 2000/08/30 19:33:28 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -61,6 +61,7 @@ static unsigned long long system_time = 0;
* Number of timer interrupts since initialisation * Number of timer interrupts since initialisation
*/ */
volatile ULONGLONG KiTimerTicks; volatile ULONGLONG KiTimerTicks;
volatile ULONG KiRawTicks = 0;
/* /*
* The increment in the system clock every timer tick (in system time units) * The increment in the system clock every timer tick (in system time units)
@ -443,6 +444,8 @@ VOID KiUpdateSystemTime (VOID)
// extern ULONG PiNrThreads; // extern ULONG PiNrThreads;
// extern ULONG MiNrFreePages; // extern ULONG MiNrFreePages;
KiRawTicks++;
if (TimerInitDone == FALSE) if (TimerInitDone == FALSE)
{ {
return; return;
@ -498,9 +501,12 @@ VOID KeInitializeTimerImpl(VOID)
{ {
TIME_FIELDS TimeFields; TIME_FIELDS TimeFields;
LARGE_INTEGER SystemBootTime; LARGE_INTEGER SystemBootTime;
extern VOID HalpCalibrateStallExecution (VOID);
DPRINT("KeInitializeTimerImpl()\n"); DPRINT("KeInitializeTimerImpl()\n");
HalpCalibrateStallExecution ();
InitializeListHead(&TimerListHead); InitializeListHead(&TimerListHead);
KeInitializeSpinLock(&TimerListLock); KeInitializeSpinLock(&TimerListLock);

View file

@ -1,4 +1,4 @@
/* $Id: mminit.c,v 1.6 2000/08/20 17:02:08 dwelch Exp $ /* $Id: mminit.c,v 1.7 2000/08/30 19:33:28 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top directory * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -145,7 +145,6 @@ VOID MmInitVirtualMemory(PLOADER_PARAMETER_BLOCK bp, ULONG LastKernelAddress)
0, 0,
&kernel_pool_desc); &kernel_pool_desc);
DPRINT1("Creating shared data page\n");
BaseAddress = (PVOID)KERNEL_SHARED_DATA_BASE; BaseAddress = (PVOID)KERNEL_SHARED_DATA_BASE;
Length = PAGESIZE; Length = PAGESIZE;
MmCreateMemoryArea(NULL, MmCreateMemoryArea(NULL,
@ -166,7 +165,6 @@ VOID MmInitVirtualMemory(PLOADER_PARAMETER_BLOCK bp, ULONG LastKernelAddress)
KeBugCheck(0); KeBugCheck(0);
} }
((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->TickCountLow = 0xdeadbeef; ((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->TickCountLow = 0xdeadbeef;
DPRINT1("Finished creating shared data page\n");
// MmDumpMemoryAreas(); // MmDumpMemoryAreas();
DPRINT("MmInitVirtualMemory() done\n"); DPRINT("MmInitVirtualMemory() done\n");