mp-r0drv-nt.cpp revision 41c15aa44c4acfe6760552150eb931319835cfaf
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * IPRT - Multiprocessor, Ring-0 Driver, NT.
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * Copyright (C) 2008 Sun Microsystems, Inc.
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * available from http://www.virtualbox.org. This file is free software;
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * General Public License (GPL) as published by the Free Software
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * The contents of this file may alternatively be used under the terms
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * of the Common Development and Distribution License Version 1.0
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * VirtualBox OSE distribution, in which case the provisions of the
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * CDDL are applicable instead of those of the GPL.
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * You may elect to license modified versions of this file under the
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * terms and conditions of either the GPL or the CDDL or both.
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * additional information or have any questions.
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync/*******************************************************************************
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync* Header Files *
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync*******************************************************************************/
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync/*******************************************************************************
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync* Structures and Typedefs *
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync*******************************************************************************/
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsynctypedef enum
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync/* test a couple of assumption. */
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsyncAssertCompile(MAXIMUM_PROCESSORS <= RTCPUSET_MAX_CPUS);
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * We cannot do other than assume a 1:1 relationship between the
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * affinity mask and the process despite the vagueness/warnings in
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * the docs. If someone knows a better way to get this done, please
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync * let bird know.
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync /* WDK upgrade warning: PCR->Number changed from BYTE to WORD. */
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync return idCpu < MAXIMUM_PROCESSORS ? (int)idCpu : -1;
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync return (unsigned)iCpu < MAXIMUM_PROCESSORS ? iCpu : NIL_RTCPUID;
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync /** @todo use KeQueryMaximumProcessorCount on vista+ */
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync return false;
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync#if 0 /* this isn't safe at all IRQLs (great work guys) */
df5f1b4303be82a000284349e9392beb9f1b6f11vboxsync /* Cannot easily distinguish between online and offline cpus. */
b0ab7e3ff45cca3c9755432dde464562cdde61f0vboxsync /** @todo online/present cpu stuff must be corrected for proper W2K8 support
df5f1b4303be82a000284349e9392beb9f1b6f11vboxsync * (KeQueryMaximumProcessorCount). */
return RTMpGetOnlineCount();
return pSet;
_asm {
pDpcData++;
static VOID rtmpNtDPCWrapper(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
static int rtMpCall(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2, RT_NT_CPUID enmCpuid, RTCPUID idCpu)
AssertMsg(KeGetCurrentIrql() == PASSIVE_LEVEL, ("%d != %d (PASSIVE_LEVEL)\n", KeGetCurrentIrql(), PASSIVE_LEVEL));
#ifdef IPRT_TARGET_NT4
return VERR_NOT_SUPPORTED;
/* KeFlushQueuedDpcs is not present in Windows 2000; import it dynamically so we can just fail this call. */
return VERR_NOT_SUPPORTED;
pArgs = (PRTMPARGS)ExAllocatePoolWithTag(NonPagedPool, MAXIMUM_PROCESSORS*sizeof(KDPC) + sizeof(RTMPARGS), (ULONG)'RTMp');
if (!pArgs)
return VERR_NO_MEMORY;
for (unsigned i = 0; i < MAXIMUM_PROCESSORS; i++)
for (unsigned i = 0; i < MAXIMUM_PROCESSORS; i++)
if ( (i != iSelf)
return VINF_SUCCESS;
static bool fPokeDPCsInitialized = false;
static VOID rtMpNtPokeCpuDummy(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
#ifndef IPRT_TARGET_NT4
return VINF_SUCCESS;
return VINF_SUCCESS;
return VERR_NOT_IMPLEMENTED;
return rc;
if (!fPokeDPCsInitialized)
fPokeDPCsInitialized = true;