-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).
+
+ * Corrected compilation bugs in user32 library.
-9/6/99: 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)
+ * Corrected compilation bugs related to anonymous structs
+ in ndis code.
+
+ * Pass command line to kernel from loadros.
+
+ * Corrected PIC mask calculation.
+
+2000-05-27 David Welch <welch@cwcom.net>
-8/12/98: 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
+ * 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.
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 \
- pteb consume dump_shared_data vmtest wstest
+ pteb consume dump_shared_data vmtest
+# wstest
# objdir
all: buildno $(COMPONENTS) $(DLLS) $(SUBSYS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
/* Information about a 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 */
BOOLEAN MiniportBusy; /* A MiniportXxx routine is executing */
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 ProtocolListEntry; /* Entry on protocol binding adapter list */
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
- KeAcquireSpinLockAtDpcLevel(&Adapter->Lock);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
WasBusy = Adapter->MiniportBusy;
Adapter->MiniportBusy = TRUE;
- KeReleaseSpinLockFromDpcLevel(&Adapter->Lock);
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
NDIS_DbgPrint(MAX_TRACE, ("Before HandleInterruptHandler.\n"));
/* Call the deferred interrupt service handler for this adapter */
(*Adapter->Miniport->Chars.HandleInterruptHandler)(
- Adapter->MiniportAdapterContext);
+ Adapter->NdisMiniportBlock.MiniportAdapterContext);
NDIS_DbgPrint(MAX_TRACE, ("After HandleInterruptHandler.\n"));
- KeAcquireSpinLockAtDpcLevel(&Adapter->Lock);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
if ((!WasBusy) && (Adapter->WorkQueueHead)) {
KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
} else {
Adapter->MiniportBusy = WasBusy;
}
- KeReleaseSpinLockFromDpcLevel(&Adapter->Lock);
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
}
(*Adapter->Miniport->Chars.ISRHandler)(&InterruptRecognized,
&QueueMiniportHandleInterrupt,
- Adapter->MiniportAdapterContext);
+ Adapter->NdisMiniportBlock.MiniportAdapterContext);
if (QueueMiniportHandleInterrupt) {
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"));
Interrupt->SharedInterrupt = SharedInterrupt;
- Adapter->Interrupt = Interrupt;
+ Adapter->NdisMiniportBlock.Interrupt = Interrupt;
MappedIRQ = HalGetInterruptVector(Internal, /* Adapter->AdapterType, */
0,
}
#endif /* DBG */
- KeAcquireSpinLock(&Adapter->Lock, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
CurrentEntry = Adapter->ProtocolListHead.Flink;
while (CurrentEntry != &Adapter->ProtocolListHead) {
AdapterBinding = CONTAINING_RECORD(CurrentEntry,
ADAPTER_BINDING,
AdapterListEntry);
- KeReleaseSpinLock(&Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
(*AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler)(
- AdapterBinding->ProtocolBindingContext,
+ AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
MacReceiveContext,
HeaderBuffer,
HeaderBufferSize,
LookaheadBufferSize,
PacketSize);
- KeAcquireSpinLock(&Adapter->Lock, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
CurrentEntry = CurrentEntry->Flink;
}
- KeReleaseSpinLock(&Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
Adapter = (PLOGICAL_ADAPTER)Filter->Miniport;
- KeAcquireSpinLock(&Adapter->Lock, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
CurrentEntry = Adapter->ProtocolListHead.Flink;
while (CurrentEntry != &Adapter->ProtocolListHead) {
AdapterBinding = CONTAINING_RECORD(CurrentEntry,
ADAPTER_BINDING,
AdapterListEntry);
- KeReleaseSpinLock(&Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
(*AdapterBinding->ProtocolBinding->Chars.ReceiveCompleteHandler)(
- AdapterBinding->ProtocolBindingContext);
+ AdapterBinding->NdisOpenBlock.ProtocolBindingContext);
- KeAcquireSpinLock(&Adapter->Lock, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
CurrentEntry = CurrentEntry->Flink;
}
- KeReleaseSpinLock(&Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[0];
(*AdapterBinding->ProtocolBinding->Chars.u2.SendCompleteHandler)(
- AdapterBinding->ProtocolBindingContext,
+ AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status);
}
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
(*AdapterBinding->ProtocolBinding->Chars.u3.TransferDataCompleteHandler)(
- AdapterBinding->ProtocolBindingContext,
+ AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status,
BytesTransferred);
/* FIXME: Should handle fragmented packets */
- switch (Adapter->MediaType) {
+ switch (Adapter->NdisMiniportBlock.MediaType) {
case NdisMedium802_3:
Length = ETH_LENGTH_OF_ADDRESS;
/* Destination address is the first field */
break;
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;
}
BytesNeeded = (Size == 0)? Adapter->QueryBufferLength : Size;
NdisStatus = (*Adapter->Miniport->Chars.QueryInformationHandler)(
- Adapter->MiniportAdapterContext,
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
Oid,
Adapter->QueryBuffer,
BytesNeeded,
}
NdisStatus = (*Adapter->Miniport->Chars.QueryInformationHandler)(
- Adapter->MiniportAdapterContext,
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
Oid,
Adapter->QueryBuffer,
Size,
* Status of operation
*/
{
- Adapter->MediaRequest = NdisRequest;
+ Adapter->NdisMiniportBlock.MediaRequest = NdisRequest;
switch (NdisRequest->RequestType) {
case NdisRequestQueryInformation:
return (*Adapter->Miniport->Chars.QueryInformationHandler)(
- Adapter->MiniportAdapterContext,
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.QUERY_INFORMATION.Oid,
NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
case NdisRequestSetInformation:
return (*Adapter->Miniport->Chars.SetInformationHandler)(
- Adapter->MiniportAdapterContext,
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.SET_INFORMATION.Oid,
NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
MiniDisplayPacket((PNDIS_PACKET)WorkItemContext);
#endif
NdisStatus = (*Adapter->Miniport->Chars.u1.SendHandler)(
- Adapter->MiniportAdapterContext,
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
(PNDIS_PACKET)WorkItemContext,
0);
if (NdisStatus != NDIS_STATUS_PENDING) {
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
(*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)(
- AdapterBinding->ProtocolBindingContext,
- Adapter->MediaRequest,
+ AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
+ Adapter->NdisMiniportBlock.MediaRequest,
Status);
}
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 */
NdisStatus = MiniQueryInformation(Adapter,
FILE_DEVICE_PHYSICAL_NETCARD,
0,
FALSE,
- &Adapter->DeviceObject);
+ &Adapter->NdisMiniportBlock.DeviceObject);
if (!NT_SUCCESS(Status)) {
NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n"));
ExFreePool(Adapter);
/* Initialize adapter object */
- KeInitializeSpinLock(&Adapter->Lock);
+ KeInitializeSpinLock(&Adapter->NdisMiniportBlock.Lock);
InitializeListHead(&Adapter->ProtocolListHead);
/* Set handlers (some NDIS macros require these) */
- Adapter->EthRxCompleteHandler = MiniEthReceiveComplete;
- Adapter->EthRxIndicateHandler = MiniEthReceiveIndication;
+ Adapter->NdisMiniportBlock.EthRxCompleteHandler = MiniEthReceiveComplete;
+ Adapter->NdisMiniportBlock.EthRxIndicateHandler = MiniEthReceiveIndication;
- Adapter->SendCompleteHandler = MiniSendComplete;
- Adapter->SendResourcesHandler = MiniSendResourcesAvailable;
- Adapter->ResetCompleteHandler = MiniResetComplete;
- Adapter->TDCompleteHandler = MiniTransferDataComplete;
+ Adapter->NdisMiniportBlock.SendCompleteHandler = MiniSendComplete;
+ Adapter->NdisMiniportBlock.SendResourcesHandler = MiniSendResourcesAvailable;
+ Adapter->NdisMiniportBlock.ResetCompleteHandler = MiniResetComplete;
+ Adapter->NdisMiniportBlock.TDCompleteHandler = MiniTransferDataComplete;
KeInitializeDpc(&Adapter->MiniportDpc, MiniportDpc, (PVOID)Adapter);
if ((NdisStatus == NDIS_STATUS_SUCCESS) &&
(SelectedMediumIndex < MEDIA_ARRAY_SIZE)) {
- Adapter->MediaType = MediaArray[SelectedMediumIndex];
+ Adapter->NdisMiniportBlock.MediaType = MediaArray[SelectedMediumIndex];
- switch (Adapter->MediaType) {
+ switch (Adapter->NdisMiniportBlock.MediaType) {
case NdisMedium802_3:
Adapter->MediumHeaderSize = 14;
AddressOID = OID_802_3_CURRENT_ADDRESS;
Adapter->AddressLength = ETH_LENGTH_OF_ADDRESS;
- Adapter->FilterDbs.u.EthDB = ExAllocatePool(NonPagedPool,
+ Adapter->NdisMiniportBlock.FilterDbs.u.EthDB = ExAllocatePool(NonPagedPool,
sizeof(ETH_FILTER));
- if (Adapter->FilterDbs.u.EthDB) {
- RtlZeroMemory(Adapter->FilterDbs.u.EthDB, sizeof(ETH_FILTER));
- Adapter->FilterDbs.u.EthDB->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter;
+ if (Adapter->NdisMiniportBlock.FilterDbs.u.EthDB) {
+ RtlZeroMemory(Adapter->NdisMiniportBlock.FilterDbs.u.EthDB, sizeof(ETH_FILTER));
+ Adapter->NdisMiniportBlock.FilterDbs.u.EthDB->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter;
} else
MemError = TRUE;
break;
if (Adapter->LookaheadBuffer)
ExFreePool(Adapter->LookaheadBuffer);
- IoDeleteDevice(Adapter->DeviceObject);
+ IoDeleteDevice(Adapter->NdisMiniportBlock.DeviceObject);
ExFreePool(Adapter);
return NDIS_STATUS_FAILURE;
}
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
(*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)(
- AdapterBinding->ProtocolBindingContext,
- Adapter->MediaRequest,
+ AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
+ Adapter->NdisMiniportBlock.MediaRequest,
Status);
}
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
- Adapter->MiniportAdapterContext = MiniportAdapterContext;
+ Adapter->NdisMiniportBlock.MiniportAdapterContext = MiniportAdapterContext;
Adapter->Attributes = BusMaster? NDIS_ATTRIBUTE_BUS_MASTER : 0;
- Adapter->AdapterType = AdapterType;
+ Adapter->NdisMiniportBlock.AdapterType = AdapterType;
Adapter->AttributesSet = TRUE;
}
NdisQueryPacket(Packet, NULL, NULL, NULL, &Total);
- KeAcquireSpinLock(&Adapter->Lock, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Adapter->LoopPacket = Packet;
0,
Adapter->CurLookaheadLength);
- KeReleaseSpinLock(&Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (Length > Adapter->MediumHeaderSize) {
MiniIndicateData(Adapter,
0);
}
- KeAcquireSpinLock(&Adapter->Lock, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Adapter->LoopPacket = NULL;
- KeReleaseSpinLock(&Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
return STATUS_SUCCESS;
}
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
- KeAcquireSpinLock(&Adapter->Lock, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Queue = Adapter->MiniportBusy;
if (Queue) {
MiniQueueWorkItem(Adapter,
} else {
Adapter->MiniportBusy = TRUE;
}
- KeReleaseSpinLock(&Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (!Queue) {
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
NdisStatus = MiniDoRequest(Adapter, NdisRequest);
- KeAcquireSpinLockAtDpcLevel(&Adapter->Lock);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->MiniportBusy = FALSE;
if (Adapter->WorkQueueHead)
KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
- KeReleaseSpinLockFromDpcLevel(&Adapter->Lock);
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
} else {
NdisStatus = NDIS_STATUS_PENDING;
Packet->Reserved[0] = (ULONG_PTR)MacBindingHandle;
- KeAcquireSpinLock(&Adapter->Lock, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Queue = Adapter->MiniportBusy;
/* 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)) {
/* Do software loopback because miniport does not support it */
} else {
Adapter->MiniportBusy = TRUE;
}
- KeReleaseSpinLock(&Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (!Queue) {
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
NdisStatus = ProIndicatePacket(Adapter, Packet);
- KeAcquireSpinLockAtDpcLevel(&Adapter->Lock);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->MiniportBusy = FALSE;
if (Adapter->WorkQueueHead)
KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
- KeReleaseSpinLockFromDpcLevel(&Adapter->Lock);
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
return NdisStatus;
} else {
} else {
Adapter->MiniportBusy = TRUE;
}
- KeReleaseSpinLock(&Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (!Queue) {
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
NdisStatus = (*Adapter->Miniport->Chars.u1.SendHandler)(
- Adapter->MiniportAdapterContext,
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
Packet,
0);
- KeAcquireSpinLockAtDpcLevel(&Adapter->Lock);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->MiniportBusy = FALSE;
if (Adapter->WorkQueueHead)
KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
- KeReleaseSpinLockFromDpcLevel(&Adapter->Lock);
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
} else {
NdisStatus = NDIS_STATUS_PENDING;
return (*Adapter->Miniport->Chars.u2.TransferDataHandler)(
Packet,
BytesTransferred,
- Adapter->MiniportAdapterContext,
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
MacReceiveContext,
ByteOffset,
BytesToTransfer);
KeReleaseSpinLock(&AdapterBinding->ProtocolBinding->Lock, OldIrql);
/* Remove protocol from adapter's bound protocols list */
- KeAcquireSpinLock(&AdapterBinding->Adapter->Lock, &OldIrql);
+ KeAcquireSpinLock(&AdapterBinding->Adapter->NdisMiniportBlock.Lock, &OldIrql);
RemoveEntryList(&AdapterBinding->AdapterListEntry);
- KeReleaseSpinLock(&AdapterBinding->Adapter->Lock, OldIrql);
+ KeReleaseSpinLock(&AdapterBinding->Adapter->NdisMiniportBlock.Lock, OldIrql);
ExFreePool(AdapterBinding);
/* Find the media type in the list provided by the protocol driver */
Found = FALSE;
for (i = 0; i < MediumArraySize; i++) {
- if (Adapter->MediaType == MediumArray[i]) {
+ if (Adapter->NdisMiniportBlock.MediaType == MediumArray[i]) {
*SelectedMediumIndex = i;
Found = TRUE;
break;
AdapterBinding->ProtocolBinding = Protocol;
AdapterBinding->Adapter = Adapter;
- AdapterBinding->ProtocolBindingContext = ProtocolBindingContext;
+ AdapterBinding->NdisOpenBlock.ProtocolBindingContext = ProtocolBindingContext;
/* 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) */
- AdapterBinding->RequestHandler = ProRequest;
- AdapterBinding->ResetHandler = ProReset;
- AdapterBinding->u1.SendHandler = ProSend;
- AdapterBinding->SendPacketsHandler = ProSendPackets;
- AdapterBinding->TransferDataHandler = ProTransferData;
+ AdapterBinding->NdisOpenBlock.RequestHandler = ProRequest;
+ AdapterBinding->NdisOpenBlock.ResetHandler = ProReset;
+ AdapterBinding->NdisOpenBlock.u1.SendHandler = ProSend;
+ AdapterBinding->NdisOpenBlock.SendPacketsHandler = ProSendPackets;
+ AdapterBinding->NdisOpenBlock.TransferDataHandler = ProTransferData;
/* Put on protocol's bound adapters list */
ExInterlockedInsertTailList(&Protocol->AdapterListHead,
/* Put protocol on adapter's bound protocols list */
ExInterlockedInsertTailList(&Adapter->ProtocolListHead,
&AdapterBinding->AdapterListEntry,
- &Adapter->Lock);
+ &Adapter->NdisMiniportBlock.Lock);
*NdisBindingHandle = (NDIS_HANDLE)AdapterBinding;
cp services/fs/vfat/vfatfs.sys $1
cp services/dd/ide/ide.sys $1
#cp services/dd/floppy/floppy.sys $1
-cp ntoskrnl/ntoskrnl.exe $1/reactos/system32/
-cp services/fs/vfat/vfatfs.sys $1/reactos/system32/drivers/
-cp services/dd/ide/ide.sys $1/reactos/system32/drivers/
+#cp ntoskrnl/ntoskrnl.exe $1/reactos/system32/
+#cp services/fs/vfat/vfatfs.sys $1/reactos/system32/drivers/
+#cp services/dd/ide/ide.sys $1/reactos/system32/drivers/
* please read EDIT.TODO (and update it when you change things)
*/
+#include <ntos/minmax.h>
+
#include <windows.h>
#include <user32/win.h>
#include <user32/class.h>
current_def->length = current_def->net_length;
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;
*previous_next = current_def;
previous_next = ¤t_def->next;
*/
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);
- *y = MIN(MAX(*y, es->format_rect.top), es->format_rect.bottom - 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);
}
EDIT_UnlockBuffer(wnd, es, TRUE);
if (es->text) {
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
es->buffer_size = 0;
} else if (es->hloc) {
if ((hNew = LocalReAlloc(es->hloc, size + 1, 0))) {
DPRINT( "Old bit handle %08x, new handle %08x\n", 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) {
s = es->selection_start;
e = es->selection_end;
ORDER_INT(s, e);
- s = MIN(li + ll, MAX(li, s));
- e = MIN(li + ll, MAX(li, e));
+ s = min(li + ll, max(li, s));
+ e = min(li + ll, max(li, e));
if (rev && (s != e) &&
((es->flags & EF_FOCUSED) || (es->style & ES_NOHIDESEL))) {
x += EDIT_PaintText(wnd, es, dc, x, y, line, 0, s - li, FALSE);
}
es->format_rect.left += es->left_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)
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
es->format_rect.bottom = es->format_rect.top + es->line_height;
if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
DPRINT( "could not allocate new bit buffer\n");
return 0;
}
- newSize = MIN(LocalSize(newBuf) - 1, es->buffer_limit);
+ newSize = min(LocalSize(newBuf) - 1, es->buffer_limit);
if (!(newText = LocalLock(newBuf))) {
DPRINT( "could not lock new bit buffer\n");
LocalFree(newBuf);
line = 0;
i = EDIT_EM_LineIndex(wnd, es, line);
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++) {
*lpch = *src;
src++;
if (index > lstrlenA(es->text))
return es->line_count - 1;
if (index == -1)
- index = MIN(es->selection_start, es->selection_end);
+ index = min(es->selection_start, es->selection_end);
line = 0;
line_def = es->first_line_def;
dx = -es->x_offset;
if (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)
nyoff = es->line_count - 1;
dy = (es->y_offset - nyoff) * es->line_height;
HFONT old_font = 0;
SIZE size;
- index = MIN(index, len);
+ index = min(index, len);
dc = GetDC(wnd->hwndSelf);
if (es->font)
old_font = SelectObject(dc, es->font);
{
if (es->style & ES_MULTILINE) {
if (limit)
- es->buffer_limit = MIN(limit, BUFLIMIT_MULTI);
+ es->buffer_limit = min(limit, BUFLIMIT_MULTI);
else
es->buffer_limit = BUFLIMIT_MULTI;
} else {
if (limit)
- es->buffer_limit = MIN(limit, BUFLIMIT_SINGLE);
+ es->buffer_limit = min(limit, BUFLIMIT_SINGLE);
else
es->buffer_limit = BUFLIMIT_SINGLE;
}
start = es->selection_end;
end = es->selection_end;
} else {
- start = MIN(start, len);
- end = MIN(end, len);
+ start = min(start, len);
+ end = min(end, len);
}
es->selection_start = start;
es->selection_end = end;
GetClipBox(dc, &rcRgn);
if (es->style & ES_MULTILINE) {
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);
if (IntersectRect(&rc, &rcRgn, &rcLine))
EDIT_PaintLine(wnd, es, dc, i, rev);
* Copyright 1996 Alexandre Julliard
*/
+#include <ntos/minmax.h>
+#define MIN min
+#define MAX max
+
#include <string.h>
#include <windows.h>
#include <user32/win.h>
* This is probably not the meaning this style has in MS-Windows.
*/
+#include <ntos/minmax.h>
#include <ctype.h>
#include <stdlib.h>
* Copyright 1994, 1996 Alexandre Julliard
*/
+#include <ntos/minmax.h>
+#define MAX max
+#define MIN min
+
#include <windows.h>
#include <user32/sysmetr.h>
#include <user32/scroll.h>
*
*/
+#include <ntos/minmax.h>
+#define MIN min
+#define MAX max
+
#include <windows.h>
#include <user32/win.h>
+#include <ntos/minmax.h>
+#define MIN min
+#define MAX max
+
#include <windows.h>
#include <user32/dce.h>
#include <user32/win.h>
+#include <ntos/minmax.h>
+#define MAX max
+#define MIN min
+
#include <windows.h>
#include <stdlib.h>
#include <user32/nc.h>
rect->bottom - rect->top - height, rop );
SelectObject( hdc, hbrush );
return TRUE;
-}
\ No newline at end of file
+}
* Copyright 1993, 1994, 1995 Alexandre Julliard
* 1995, 1996 Alex Korobka
*/
+
+#include <ntos/minmax.h>
+#define MIN min
+#define MAX max
+
#include <windows.h>
#include <string.h>
#include <user32/sysmetr.h>
+#include <ntos/minmax.h>
+#define MIN min
+#define MAX max
+
#define UNICODE
#include <windows.h>
#include <user32/win.h>
+#include <ntos/minmax.h>
+#define MIN min
+#define MAX max
+
#include <windows.h>
#include <user32/nc.h>
;
BITS 16
-;%define NDEBUG 1
+%define NDEBUG 1
%macro DPRINT 1+
%ifndef NDEBUG
; Set the address of the start of kernel code
;
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
;
mov di,081h
l1:
- cmp byte [di],0dh
- je l2
+ cmp byte [di], 0
+ je l2
cmp byte [di],' '
jne l12
mov byte [di],0
inc di
jmp l1
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
-l14:
+ jmp l14
+l32:
+ mov dx,081h
+
+ ;
+ ; Check if we have reached the end of the string
+ ;
+l14:
mov bx,dx
cmp byte [bx],0
je l16
;
- ; Process the arguments
+ ; Process the arguments
;
+ cmp byte [di], '/'
+ je l15
+
mov di,loading_msg
call print_string
mov di,dx
call print_string
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
;
mov eax,[kernel_page_directory_base]
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)
;
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 00000h ;
dw 09a00h ; base 0h limit 4gb
dw 09200h ; base 0h limit 4gb
dw 000cfh
-
- ;times NR_TASKS*8 db 0
-
_end:
-/* $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
* PROJECT: ReactOS kernel
/* FUNCTIONS *****************************************************************/
-VOID
-FASTCALL
-EXPORTED
-ExAcquireFastMutex (
- PFAST_MUTEX FastMutex
- )
+VOID FASTCALL EXPORTED
+ExAcquireFastMutex (PFAST_MUTEX FastMutex)
{
KeEnterCriticalRegion();
if (InterlockedDecrement(&(FastMutex->Count))==0)
}
-VOID
-FASTCALL
-EXPORTED
-ExReleaseFastMutex (
- PFAST_MUTEX FastMutex
- )
+VOID FASTCALL EXPORTED
+ExReleaseFastMutex (PFAST_MUTEX FastMutex)
{
assert(FastMutex->Owner == KeGetCurrentThread());
FastMutex->Owner=NULL;
}
-BOOLEAN
-FASTCALL
-EXPORTED
-ExTryToAcquireFastMutex (
- PFAST_MUTEX FastMutex
- )
+BOOLEAN FASTCALL EXPORTED
+ExTryToAcquireFastMutex (PFAST_MUTEX FastMutex)
{
UNIMPLEMENTED;
}
-/* $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
* PROJECT: ReactOS kernel
/* FUNCTIONS ***************************************************************/
-BOOLEAN
-STDCALL
-HalInitSystem (
- ULONG BootPhase,
- PLOADER_PARAMETER_BLOCK LoaderBlock
- )
+BOOLEAN STDCALL
+HalInitSystem (ULONG BootPhase,
+ PLOADER_PARAMETER_BLOCK LoaderBlock)
{
if (BootPhase == 0)
{
HalInitializeDisplay (LoaderBlock);
- HalpCalibrateStallExecution ();
HalpInitPICs ();
}
else
{
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,¤t_mask);
+ current_mask = current_mask | (1 << (HIGH_LEVEL - i));
}
HiSetCurrentPICMask(current_mask);
-/* $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
* PROJECT: ReactOS kernel
/* GLOBALS ******************************************************************/
-#define MICROSECONDS_PER_TICK (54945)
-#define TICKS_TO_CALIBRATE (1)
-#define CALIBRATE_PERIOD (MICROSECONDS_PER_TICK * TICKS_TO_CALIBRATE)
-#define SYSTEM_TIME_UNITS_PER_MSEC (10000)
+static unsigned int delay_count = 1;
-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 **************************************************************/
-VOID HalpCalibrateStallExecution(VOID)
+void init_pit(float h, unsigned char channel)
{
-// unsigned int start_tick;
-// unsigned int end_tick;
-// unsigned int nr_ticks;
-// unsigned int i;
-// unsigned int microseconds;
+ 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));
+}
-#if 0
- for (i=0;i<20;i++)
- {
- start_tick = KiTimerTicks;
- 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(;;);
-#endif
+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
-STDCALL
-KeStallExecutionProcessor(ULONG MicroSeconds)
+VOID HalpCalibrateStallExecution(VOID)
{
+ unsigned int prevtick;
unsigned int i;
- for (i=0; i<(loops_per_microsecond*MicroSeconds) ;i++)
+ unsigned int calib_bit;
+ extern volatile ULONG KiRawTicks;
+
+ 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
+ DbgPrint("About to start delay loop test\n");
+ for (i = 0; i < (10*1000*20); i++)
{
- __asm__("nop\n\t");
+ KeStallExecutionProcessor(50);
}
+ 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
}
/* EOF */
-/* $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
* PROJECT: ReactOS kernel
static BOOLEAN KdpBreakPending = FALSE;
static BOOLEAN KdpBreakRecieved = FALSE;
-static ULONG KdpDebugType = BochsDebug;
+static ULONG KdpDebugType = ScreenDebug | BochsDebug;
/* PRIVATE FUNCTIONS ********************************************************/
/* GLOBALS *******************************************************************/
static ULONG HardwareMathSupport;
-static ULONG x;
/* FUNCTIONS *****************************************************************/
return;
}
/* FIXME: Do fsetpm */
- DbgPrint("Detected FPU\n");
HardwareMathSupport = 1;
- DbgPrint("Testing FPU\n");
- x = x * 6.789456;
}
VOID KeInit1(VOID)
-/* $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
* PROJECT: ReactOS kernel
#include <internal/ps.h>
#include <internal/hal.h>
#include <internal/ke.h>
-#include <internal/io.h>
#include <internal/mmhal.h>
#include <internal/i386/segment.h>
#include <napi/shared_data.h>
-#define NDEBUG
+//#define NDEBUG
#include <internal/debug.h>
/* DATA *********************************************************************/
/* FUNCTIONS ****************************************************************/
-static VOID
-CreateSystemRootLink (PCSZ ParameterLine)
+static VOID CreateSystemRootLink (LPWSTR Device)
{
UNICODE_STRING LinkName;
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,
L"\\SystemRoot");
- Status = IoCreateSymbolicLink (&LinkName,
- &DeviceName);
- RtlFreeUnicodeString (&DeviceName);
- if (!NT_SUCCESS(Status))
- {
- DbgPrint("IoCreateSymbolicLink() failed (Status %x)\n",
- Status);
-
- KeBugCheck (0x0);
- }
-
- /*
- * 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);
+ RtlInitUnicodeString (&DeviceName,
+ Device);
- /* 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);
- }
+ IoCreateSymbolicLink (&LinkName,
+ &DeviceName);
}
-
void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
/*
* FUNCTION: Called by the boot loader to start the kernel
* Initializes the kernel parameter line.
* This should be done by the boot loader.
*/
- strcpy (KeLoaderBlock.kernel_parameters,
- "multi(0)disk(0)rdisk(0)partition(1)\\reactos /DEBUGPORT=SCREEN");
+// strcpy (KeLoaderBlock.kernel_parameters, "/DEBUGPORT=SCREEN");
/*
* Initialization phase 0
HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
KeInit1();
KeLowerIrql(DISPATCH_LEVEL);
-
+
+ DbgPrint("kernel_parameters %s\n",
+ KeLoaderBlock.kernel_parameters);
+
/*
* Display version number and copyright/warranty message
*/
*/
DPRINT1("%d files loaded\n",KeLoaderBlock.nr_files);
- /* Pass 1: load registry chunks passed in */
- start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
- for (i = 1; i < KeLoaderBlock.nr_files; i++)
- {
- if (!strcmp ((PCHAR) start, "REGEDIT4"))
- {
- DPRINT1("process registry chunk at %08lx\n", start);
- CmImportHive((PCHAR) start);
- }
- start = start + KeLoaderBlock.module_length[i];
- }
-
- /* Pass 2: process boot loaded drivers */
- start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
- start1 = start + KeLoaderBlock.module_length[1];
- for (i=1;i<KeLoaderBlock.nr_files;i++)
- {
- if (strcmp ((PCHAR) start, "REGEDIT4"))
- {
- DPRINT1("process module at %08lx\n", start);
- LdrProcessDriver((PVOID)start);
- }
- start = start + KeLoaderBlock.module_length[i];
- }
+ /* Pass 1: load registry chunks passed in */
+ start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
+ for (i = 1; i < KeLoaderBlock.nr_files; i++)
+ {
+ if (!strcmp ((PCHAR) start, "REGEDIT4"))
+ {
+ DPRINT1("process registry chunk at %08lx\n", start);
+ CmImportHive((PCHAR) start);
+ }
+ start = start + KeLoaderBlock.module_length[i];
+ }
+
+ /* Pass 2: process boot loaded drivers */
+ start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
+ start1 = start + KeLoaderBlock.module_length[1];
+ for (i=1;i<KeLoaderBlock.nr_files;i++)
+ {
+ if (strcmp ((PCHAR) start, "REGEDIT4"))
+ {
+ DPRINT1("process module at %08lx\n", start);
+ LdrProcessDriver((PVOID)start);
+ }
+ start = start + KeLoaderBlock.module_length[i];
+ }
/* 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
NULL,
NULL);
- /*
- * Initialize shared user page:
- * - set dos system path, dos device map, etc.
- */
- InitSystemSharedUserPage (KeLoaderBlock.kernel_parameters);
+ /* set system root in shared user page */
+ wcscpy (((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->NtSystemRoot,
+ L"C:\\reactos");
+
+ ((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->NtProductType = NtProductWinNt;
+
/*
* Launch initial process
-/* $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
* PROJECT: ReactOS kernel
* Number of timer interrupts since initialisation
*/
volatile ULONGLONG KiTimerTicks;
+volatile ULONG KiRawTicks = 0;
/*
* The increment in the system clock every timer tick (in system time units)
// extern ULONG PiNrThreads;
// extern ULONG MiNrFreePages;
+ KiRawTicks++;
+
if (TimerInitDone == FALSE)
{
return;
{
TIME_FIELDS TimeFields;
LARGE_INTEGER SystemBootTime;
+ extern VOID HalpCalibrateStallExecution (VOID);
DPRINT("KeInitializeTimerImpl()\n");
+ HalpCalibrateStallExecution ();
+
InitializeListHead(&TimerListHead);
KeInitializeSpinLock(&TimerListLock);
-/* $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
* PROJECT: ReactOS kernel
0,
&kernel_pool_desc);
- DPRINT1("Creating shared data page\n");
BaseAddress = (PVOID)KERNEL_SHARED_DATA_BASE;
Length = PAGESIZE;
MmCreateMemoryArea(NULL,
KeBugCheck(0);
}
((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->TickCountLow = 0xdeadbeef;
- DPRINT1("Finished creating shared data page\n");
// MmDumpMemoryAreas();
DPRINT("MmInitVirtualMemory() done\n");