VirtualBox

Changeset 6013 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Dec 8, 2007 12:39:13 AM (17 years ago)
Author:
vboxsync
Message:

Created generic templates for compiling guest additions (for new ports): VBOXGUESTR3EXE, VBOXGUESTR3LIB, VBOXGUESTR0LIB and VBOXGUESTR0.

Location:
trunk/src/VBox/Runtime
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r6012 r6013  
    3333 # Only build the additions, sort out the legacy names first.
    3434 #
    35  ifeq ($(BUILD_TARGET),linux)
    36   LIBRARIES  = RuntimeLnx32GuestR0 RuntimeLnx32GuestR3
    37  else ifeq ($(BUILD_TARGET),os2)
    38   LIBRARIES  = RuntimeOS2GuestR0 RuntimeOS2GuestR3 #RuntimeOS2Warp3GuestR0
    39  else ifeq ($(BUILD_TARGET),win)
    40   LIBRARIES = RuntimeW32GuestR0 RuntimeW32GuestR3 RuntimeW32NT4GuestR0
    41  else
     35# ifeq ($(BUILD_TARGET),linux)
     36#  LIBRARIES  = RuntimeLnx32GuestR0 RuntimeLnx32GuestR3
     37# else ifeq ($(BUILD_TARGET),os2)
     38#  LIBRARIES  = RuntimeOS2GuestR0 RuntimeOS2GuestR3 #RuntimeOS2Warp3GuestR0
     39# else ifeq ($(BUILD_TARGET),win)
     40#  LIBRARIES = RuntimeW32GuestR0 RuntimeW32GuestR3 RuntimeW32NT4GuestR0
     41# else
    4242  LIBRARIES = RuntimeGuestR0 RuntimeGuestR3
    43  endif
     43# endif
    4444
    4545 #
     
    448448        r3/solaris/alloc-solaris.cpp
    449449
    450 
    451450## PORTME: Porters add their selection of platform specific files for Ring-3 here.
    452451
     
    493492        r3/posix/time-posix.cpp \
    494493        r3/posix/timelocal-posix.cpp
     494
     495
     496#
     497# RuntimeGuestR3 - Guest Additions Runtime (static).
     498#
     499RuntimeGuestR3_TEMPLATE             := VBOXGUESTR3LIB
     500RuntimeGuestR3_SDKS.win             := $(RuntimeR3_SDKS.win)
     501RuntimeGuestR3_DEFS                 := $(filter-out RTCRITSECT_STRICT, $(RuntimeR3_DEFS))
     502RuntimeGuestR3_DEFS.$(BUILD_TARGET) := $(RuntimeR3_DEFS.$(BUILD_TARGET))
     503RuntimeGuestR3_INCS                 := $(RuntimeR3_INCS)
     504RuntimeGuestR3_INCS.$(BUILD_TARGET) := $(RuntimeR3_INCS.$(BUILD_TARGET))
     505RuntimeGuestR3_SOURCES              := $(filter-out \
     506        common/time/timesupref.cpp \
     507        common/time/timesupA.asm \
     508        common/time/timesup.cpp \
     509        , $(RuntimeR3_SOURCES))
     510RuntimeGuestR3_SOURCES              += \
     511        common/time/timesysalias.cpp
     512RuntimeGuestR3_SOURCES.$(BUILD_TARGET) := $(RuntimeR3_SOURCES.$(BUILD_TARGET))
     513RuntimeGuestR3_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH) := $(RuntimeR3_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
     514
    495515
    496516#
     
    931951        r0drv/solaris/timer-r0drv-solaris.c
    932952
    933 
    934953## PORTME: Porters create and add their selection of platform specific Ring-0 Driver files here.
     954
     955
     956#
     957# RuntimeGuestR0 - Guest driver runtime.
     958#                  This is almost the same as the RuntimeR0Drv, the main difference
     959#                  is in the backdoor logging and the lack of sup.h (which should be
     960#                  made irrelevant even for RuntimeR0Rdrv).
     961#
     962# TODO: RuntimeGuestR0_EXTENDS = RuntimeR0Drv (kBuild)
     963#
     964RuntimeGuestR0_TEMPLATE                := VBOXGUESTR0LIB
     965RuntimeGuestR0_SDKS.win                := W2K3DDKX86 WINPSDKINCS
     966RuntimeGuestR0_DEFS                    := $(RuntimeR0Drv_DEFS)
     967RuntimeGuestR0_DEFS.$(BUILD_TARGET)    := $(RuntimeR0Drv_DEFS.$(BUILD_TARGET))
     968RuntimeGuestR0_INCS                    := $(PATH_SUB_CURRENT)
     969RuntimeGuestR0_INCS.$(BUILD_TARGET)    := $(RuntimeR0Drv_INCS.$(BUILD_TARGET))
     970RuntimeGuestR0_SOURCES                 := $(filter-out generic/RTLogWriteUser-generic.cpp, $(RuntimeR0Drv_SOURCES))
     971RuntimeGuestR0_SOURCES                 += VBox/logbackdoor.cpp
     972RuntimeGuestR0_SOURCES.$(BUILD_TARGET) := $(RuntimeR0Drv_SOURCES.$(BUILD_TARGET))
     973RuntimeGuestR0_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH) := $(RuntimeR0Drv_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
     974ifdef VBOX_USE_VCC80
     975RuntimeGuestR0_SOURCES.win += \
     976        common/string/memchr.cpp \
     977        common/string/memcmp.cpp \
     978        common/string/memcpy.cpp \
     979        common/string/memset.cpp \
     980        common/string/strlen.cpp
     981endif
     982
    935983
    936984#
     
    940988RuntimeW32GuestR0_SDKS          = W2K3DDKX86 WINPSDKINCS
    941989RuntimeW32GuestR0_INCS         := $(PATH_SUB_CURRENT)
    942 RuntimeW32GuestR0_DEFS          = IN_RT_R0 RT_WITH_VBOX RT_WITHOUT_NOCRT_WRAPPERS  IN_SUP_R0
     990RuntimeW32GuestR0_DEFS          = IN_RT_R0 RT_WITH_VBOX RT_WITHOUT_NOCRT_WRAPPERS IN_SUP_R0
     991RuntimeW32GuestR0_DEFS.$(BUILD_TARGET) =
    943992RuntimeW32GuestR0_SOURCES       = \
    944993        $(filter-out generic/RTLogWriteUser-generic.cpp,$(RuntimeR0Drv_SOURCES)) \
  • trunk/src/VBox/Runtime/common/time/timesysalias.cpp

    r6009 r6013  
    11/* $Id$ */
    22/** @file
    3  * innotek Portable Runtime - Time using SUPLib.
     3 * innotek Portable Runtime - Time using RTTimeSystem*.
    44 */
    55
     
    2929*   Header Files                                                               *
    3030*******************************************************************************/
    31 #define LOG_GROUP RTLOGGROUP_TIME
    3231#include <iprt/time.h>
    33 #include <iprt/asm.h>
    34 #include <iprt/assert.h>
    35 #include <iprt/err.h>
    36 #include <iprt/log.h>
    37 #ifndef IN_GUEST
    38 # include <VBox/sup.h>
    39 # include <VBox/x86.h>
    40 #endif
    41 #include "internal/time.h"
    42 
    43 
    44 /*******************************************************************************
    45 *   Internal Functions                                                         *
    46 *******************************************************************************/
    47 #ifndef IN_GUEST
    48 static DECLCALLBACK(void)     rtTimeNanoTSInternalBitch(PRTTIMENANOTSDATA pData, uint64_t u64NanoTS, uint64_t u64DeltaPrev, uint64_t u64PrevNanoTS);
    49 static DECLCALLBACK(uint64_t) rtTimeNanoTSInternalFallback(PRTTIMENANOTSDATA pData);
    50 static DECLCALLBACK(uint64_t) rtTimeNanoTSInternalRediscover(PRTTIMENANOTSDATA pData);
    51 #endif
    52 
    53 
    54 /*******************************************************************************
    55 *   Global Variables                                                           *
    56 *******************************************************************************/
    57 #ifndef IN_GUEST
    58 /** The previous timestamp value returned by RTTimeNanoTS. */
    59 static uint64_t         g_TimeNanoTSPrev = 0;
    60 
    61 /** The RTTimeNanoTS data structure that's passed down to the worker functions.  */
    62 static RTTIMENANOTSDATA g_TimeNanoTSData =
    63 {
    64     /* .pu64Prev      = */ &g_TimeNanoTSPrev,
    65     /* .pfnBad        = */ rtTimeNanoTSInternalBitch,
    66     /* .pfnRediscover = */ rtTimeNanoTSInternalRediscover,
    67     /* .pvDummy       = */ NULL,
    68     /* .c1nsSteps     = */ 0,
    69     /* .cExpired      = */ 0,
    70     /* .cBadPrev      = */ 0,
    71     /* .cUpdateRaces  = */ 0
    72 };
    73 
    74 /** The index into g_apfnWorkers for the function to use.
    75  * This cannot be a pointer because that'll break down in GC due to code relocation. */
    76 static uint32_t             g_iWorker = 0;
    77 /** Array of rtTimeNanoTSInternal worker functions.
    78  * This array is indexed by g_iWorker. */
    79 static const PFNTIMENANOTSINTERNAL g_apfnWorkers[] =
    80 {
    81 #define RTTIMENANO_WORKER_DETECT        0
    82     rtTimeNanoTSInternalRediscover,
    83 #define RTTIMENANO_WORKER_SYNC_CPUID    1
    84     RTTimeNanoTSLegacySync,
    85 #define RTTIMENANO_WORKER_ASYNC_CPUID   2
    86     RTTimeNanoTSLegacyAsync,
    87 #define RTTIMENANO_WORKER_SYNC_LFENCE   3
    88     RTTimeNanoTSLFenceSync,
    89 #define RTTIMENANO_WORKER_ASYNC_LFENCE  4
    90     RTTimeNanoTSLFenceAsync,
    91 #define RTTIMENANO_WORKER_FALLBACK      5
    92     rtTimeNanoTSInternalFallback,
    93 };
    94 
    95 
    96 /**
    97  * Helper function that's used by the assembly routines when something goes bust.
    98  *
    99  * @param   pData           Pointer to the data structure.
    100  * @param   u64NanoTS       The calculated nano ts.
    101  * @param   u64DeltaPrev    The delta relative to the previously returned timestamp.
    102  * @param   u64PrevNanoTS   The previously returned timestamp (as it was read it).
    103  */
    104 static DECLCALLBACK(void) rtTimeNanoTSInternalBitch(PRTTIMENANOTSDATA pData, uint64_t u64NanoTS, uint64_t u64DeltaPrev, uint64_t u64PrevNanoTS)
    105 {
    106     pData->cBadPrev++;
    107     if ((int64_t)u64DeltaPrev < 0)
    108         LogRel(("TM: u64DeltaPrev=%RI64 u64PrevNanoTS=0x%016RX64 u64NanoTS=0x%016RX64\n",
    109                 u64DeltaPrev, u64PrevNanoTS, u64NanoTS));
    110     else
    111         Log(("TM: u64DeltaPrev=%RI64 u64PrevNanoTS=0x%016RX64 u64NanoTS=0x%016RX64 (debugging?)\n",
    112              u64DeltaPrev, u64PrevNanoTS, u64NanoTS));
    113 }
    114 
    115 /**
    116  * Fallback function.
    117  */
    118 static DECLCALLBACK(uint64_t) rtTimeNanoTSInternalFallback(PRTTIMENANOTSDATA pData)
    119 {
    120     PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
    121     if (    pGip
    122         &&  pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC
    123         &&  (   pGip->u32Mode == SUPGIPMODE_SYNC_TSC
    124              || pGip->u32Mode == SUPGIPMODE_ASYNC_TSC))
    125         return rtTimeNanoTSInternalRediscover(pData);
    126     NOREF(pData);
    127 #if defined(IN_RING3) /** @todo Add ring-0 RTTimeSystemNanoTS to all hosts. */
    128     return RTTimeSystemNanoTS();
    129 #else
    130     return 0;
    131 #endif
    132 }
    133 
    134 
    135 /**
    136  * Called the first time somebody asks for the time or when the GIP
    137  * is mapped/unmapped.
    138  */
    139 static DECLCALLBACK(uint64_t) rtTimeNanoTSInternalRediscover(PRTTIMENANOTSDATA pData)
    140 {
    141     uint32_t iWorker;
    142     PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
    143     if (    pGip
    144         &&  pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC
    145         &&  (   pGip->u32Mode == SUPGIPMODE_SYNC_TSC
    146              || pGip->u32Mode == SUPGIPMODE_ASYNC_TSC))
    147     {
    148         if (ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_SSE2)
    149             iWorker = pGip->u32Mode == SUPGIPMODE_SYNC_TSC
    150                     ? RTTIMENANO_WORKER_SYNC_LFENCE
    151                     : RTTIMENANO_WORKER_ASYNC_LFENCE;
    152         else
    153             iWorker = pGip->u32Mode == SUPGIPMODE_SYNC_TSC
    154                     ? RTTIMENANO_WORKER_SYNC_CPUID
    155                     : RTTIMENANO_WORKER_ASYNC_CPUID;
    156     }
    157     else
    158         iWorker = RTTIMENANO_WORKER_FALLBACK;
    159 
    160     ASMAtomicXchgU32((uint32_t volatile *)&g_iWorker, iWorker);
    161     return g_apfnWorkers[iWorker](pData);
    162 }
    163 
    164 #endif /* !IN_GUEST */
    165 
    166 
    167 /**
    168  * Internal worker for getting the current nanosecond timestamp.
    169  */
    170 DECLINLINE(uint64_t) rtTimeNanoTSInternal(void)
    171 {
    172 #ifndef IN_GUEST
    173     return g_apfnWorkers[g_iWorker](&g_TimeNanoTSData);
    174 #else
    175     return RTTimeSystemNanoTS();
    176 #endif
    177 }
    17832
    17933
     
    18539RTDECL(uint64_t) RTTimeNanoTS(void)
    18640{
    187     return rtTimeNanoTSInternal();
     41    return RTTimeSystemNanoTS();
    18842}
    18943
     
    19650RTDECL(uint64_t) RTTimeMilliTS(void)
    19751{
    198     return rtTimeNanoTSInternal() / 1000000;
     52    return RTTimeSystemMilliTS();
    19953}
    20054
    201 
    202 #ifndef IN_GUEST
    203 /**
    204  * Debugging the time api.
    205  *
    206  * @returns the number of 1ns steps which has been applied by RTTimeNanoTS().
    207  */
    208 RTDECL(uint32_t) RTTimeDbgSteps(void)
    209 {
    210     return g_TimeNanoTSData.c1nsSteps;
    211 }
    212 
    213 
    214 /**
    215  * Debugging the time api.
    216  *
    217  * @returns the number of times the TSC interval expired RTTimeNanoTS().
    218  */
    219 RTDECL(uint32_t) RTTimeDbgExpired(void)
    220 {
    221     return g_TimeNanoTSData.cExpired;
    222 }
    223 
    224 
    225 /**
    226  * Debugging the time api.
    227  *
    228  * @returns the number of bad previous values encountered by RTTimeNanoTS().
    229  */
    230 RTDECL(uint32_t) RTTimeDbgBad(void)
    231 {
    232     return g_TimeNanoTSData.cBadPrev;
    233 }
    234 
    235 
    236 /**
    237  * Debugging the time api.
    238  *
    239  * @returns the number of update races in RTTimeNanoTS().
    240  */
    241 RTDECL(uint32_t) RTTimeDbgRaces(void)
    242 {
    243     return g_TimeNanoTSData.cUpdateRaces;
    244 }
    245 #endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette