VirtualBox

Changeset 6538 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Jan 28, 2008 7:50:14 PM (17 years ago)
Author:
vboxsync
Message:

Additions/R3 Guest library: created a reduced version of the library which depends on the X server runtime instead of ours, for use in old X server drivers

Location:
trunk/src/VBox/Additions/common/VBoxGuestLib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk

    r6494 r6538  
    4848  endif
    4949   LIBRARIES += \
    50         VBoxGuestR3LibLinux
     50        VBoxGuestR3LibLinux \
     51        VBoxGuestR3LibLinuxXFree86
    5152 endif
    5253 ifdef VBOX_WITH_OS2_ADDITIONS
     
    9293
    9394#
    94 # VBoxGuestR3LibBase
     95# VBoxGuestR3Lib
    9596#
    9697VBoxGuestR3Lib_TEMPLATE    = VBOXGUESTR3LIB
     
    107108        VBoxGuestR3LibVideo.cpp
    108109
     110#
     111# VBoxGuestR3LibXFree86 - a reduced version of the guest library which uses
     112# the X server runtime instead of iprt, for use with old servers where the
     113# C library is not available.
     114#
     115VBoxGuestR3LibXFree86_SOURCES    = \
     116        VBoxGuestR3Lib.cpp \
     117        VBoxGuestR3LibGR.cpp \
     118        VBoxGuestR3LibMouse.cpp \
     119        VBoxGuestR3LibMisc.cpp \
     120        VBoxGuestR3LibVideo.cpp
    109121
    110122
     
    154166
    155167#
    156 # VBoxGuestR3LibBaseLinux
     168# VBoxGuestR3LibLinux
    157169#
    158170VBoxGuestR3LibLinux_TEMPLATE = VBOXLNX32GUESTR3LIB
    159171VBoxGuestR3LibLinux_SOURCES  = $(VBoxGuestR3Lib_SOURCES)
    160172VBoxGuestR3LibLinux_DEFS     = VBOX_HGCM
     173
     174
     175#
     176# VBoxGuestR3LibLinuxXFree86
     177#
     178VBoxGuestR3LibLinuxXFree86_TEMPLATE = VBOXLNX32GUESTR3LIB
     179VBoxGuestR3LibLinuxXFree86_SOURCES  = $(VBoxGuestR3LibXFree86_SOURCES)
     180VBoxGuestR3LibLinuxXFree86_DEFS     = VBOX_HGCM VBOX_VBGLR3_XFREE86
     181VBoxGuestR3LibLinuxXFree86_INCS     = \
     182        ../../x11/x11include/4.2/programs/Xserver/hw/xfree86/common/ \
     183        ../../x11/x11include/4.2/programs/Xserver/hw/xfree86/os-support \
     184        ../../x11/x11include/4.2/programs/Xserver/include \
     185        ../../x11/x11include/4.2/exports/include/X11
    161186
    162187
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp

    r6470 r6538  
    3434#include <iprt/asm.h>
    3535#include <iprt/string.h>
    36 #include <iprt/file.h>
    37 #include <iprt/assert.h>
    38 #include <iprt/mem.h>
    39 #include <iprt/alloca.h>
     36#ifdef VBOX_VBGLR3_XFREE86
     37/* Definitions for X server library functions such as xf86open and mappings to C functions. */
     38/* Make the headers C++-compatible */
     39# define class xf86_vbox_class
     40# define bool xf86_vbox_bool
     41# define private xf86_vbox_private
     42# define new xf86_vbox_new
     43extern "C"
     44{
     45# include "xf86.h"
     46# include "xf86_OSproc.h"
     47# include "xf86Resources.h"
     48# include "xf86_ansic.h"
     49}
     50# undef class
     51# undef bool
     52# undef private
     53# undef new
     54#else
     55# include <iprt/file.h>
     56# include <iprt/assert.h>
     57# include <iprt/thread.h>
     58#endif
    4059#include <VBox/VBoxGuest.h>
    4160#include "VBGLR3Internal.h"
     
    4665*******************************************************************************/
    4766/** The VBoxGuest device handle. */
     67#ifdef VBOX_VBGLR3_XFREE86
     68static int g_File = -1;
     69#else
    4870static RTFILE g_File = NIL_RTFILE;
    49 
     71#endif
     72/**
     73 * A counter of the number of times the library has been initialised, for use with
     74 * X.org drivers, where the library may be shared by multiple independant modules
     75 * inside a single process space.
     76 */
     77static uint32_t g_cInits = 0;
    5078
    5179VBGLR3DECL(int) VbglR3Init(void)
    5280{
    53     if (g_File != NIL_RTFILE)
     81    uint32_t cInits = ASMAtomicIncU32(&g_cInits);
     82#ifdef VBOX_VBGLR3_XFREE86
     83    if (1 != cInits)
    5484        return VINF_SUCCESS;
     85    if (-1 != g_File)
     86        return VERR_INTERNAL_ERROR;
     87#else
     88    Assert(cInits > 0);
     89    if (1 > cInits)
     90    {
     91        /* This will not work when the library is shared inside a multi-threaded
     92           process.  Hopefully no-one will try that, as we can't use the threads
     93           APIs here. */
     94        if (NIL_RTFILE == g_File)
     95            return VERR_INTERNAL_ERROR;
     96        return VINF_SUCCESS;
     97    }
     98    if (NIL_RTFILE != g_File)
     99        return VERR_INTERNAL_ERROR;
     100#endif
    55101
    56102#if defined(RT_OS_OS2)
     
    105151    g_File = hf;
    106152
    107      /* PORTME */
     153#elif defined(VBOX_VBGLR3_XFREE86)
     154    int File = open(VBOXGUEST_DEVICE_NAME, O_RDWR);
     155    if (-1 == File)
     156    {
     157        return VERR_UNRESOLVED_ERROR;
     158    }
     159    g_File = File;
     160
    108161#else
    109162    /* the default implemenation. (linux, solaris) */
     
    122175VBGLR3DECL(void) VbglR3Term(void)
    123176{
     177    uint32_t cInits = ASMAtomicDecU32(&g_cInits);
     178    if (cInits > 0)
     179        return;
     180#ifndef VBOX_VBGLR3_XFREE86
     181    AssertReturnVoid(0 == cInits);
    124182    RTFILE File = g_File;
    125183    g_File = NIL_RTFILE;
    126     if (File == NIL_RTFILE)
     184    AssertReturnVoid(NIL_RTFILE != File);
     185#else
     186    int File = g_File;
     187    g_File = -1;
     188    if (-1 == File)
    127189        return;
     190#endif
    128191#if defined(RT_OS_OS2)
    129192    APIRET rc = DosClose(File);
    130193    AssertMsg(!rc, ("%ld\n", rc));
     194#elif defined(VBOX_VBGLR3_XFREE86)
     195    /* if (-1 == close(File))
     196    {
     197        int iErr = errno;
     198        AssertRC(RTErrConvertFromErrno(iErr));
     199    } */
     200    close(File);  /* iprt is not available here. */
     201    File = -1;
    131202#else
    132203    int rc = RTFileClose(File);
     
    171242    int rc = ioctl((int)g_File, iFunction, &Hdr);
    172243    if (rc == -1)
     244    {
    173245        rc = errno;
    174     return rc;
     246        return RTErrConvertFromErrno(rc);
     247    }
     248    return VINF_SUCCESS;
    175249
    176250#else
    177251    /* Default implementation - PORTME: Do not use this without testings that error passing works! */
     252# ifdef VBOX_VBGLR3_XFREE86
     253    int rc = ioctl(g_File, (int) iFunction, pvData);
     254    if (rc == -1)
     255    {
     256        rc = errno;
     257        return RTErrConvertFromErrno(rc);
     258    }
     259    return VINF_SUCCESS;
     260# else
    178261    int rc2 = VERR_INTERNAL_ERROR;
    179262    int rc = RTFileIoCtl(g_File, (int)iFunction, pvData, cbData, &rc2);
     
    181264        rc = rc2;
    182265    return rc;
    183 #endif
    184 }
    185 
     266# endif
     267#endif
     268}
     269
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGR.cpp

    r6470 r6538  
    2020*   Header Files                                                               *
    2121*******************************************************************************/
    22 #include <iprt/mem.h>
    23 #include <iprt/assert.h>
    24 #include <iprt/string.h>
     22#ifdef VBOX_VBGLR3_XFREE86
     23/* For the definitions of standard X server library functions like xalloc. */
     24/* Make the headers C++-compatible */
     25# define class xf86_vbox_class
     26# define bool xf86_vbox_bool
     27# define private xf86_vbox_private
     28# define new xf86_vbox_new
     29extern "C"
     30{
     31# include "xf86.h"
     32# include "xf86_OSproc.h"
     33# include "xf86Resources.h"
     34# include "xf86_ansic.h"
     35}
     36# undef class
     37# undef bool
     38# undef private
     39# undef new
     40#else
     41# include <iprt/mem.h>
     42# include <iprt/assert.h>
     43# include <iprt/string.h>
     44#endif
    2545#include <iprt/err.h>
    2646#include <VBox/VBoxGuest.h>
     
    3252    VMMDevRequestHeader *pReq;
    3353
     54#ifdef VBOX_VBGLR3_XFREE86
     55    pReq = (VMMDevRequestHeader *)xalloc(cb);
     56#else
    3457    AssertPtrReturn(ppReq, VERR_INVALID_PARAMETER);
    3558    AssertMsgReturn(cb >= sizeof(VMMDevRequestHeader), ("%#x vs %#zx\n", cb, sizeof(VMMDevRequestHeader)),
     
    3760
    3861    pReq = (VMMDevRequestHeader *)RTMemTmpAlloc(cb);
     62#endif
    3963    if (RT_UNLIKELY(!pReq))
    4064        return VERR_NO_MEMORY;
     
    6185void vbglR3GRFree(VMMDevRequestHeader *pReq)
    6286{
     87#ifdef VBOX_VBGLR3_XFREE86
     88    xfree(pReq);
     89#else
    6390    RTMemTmpFree(pReq);
     91#endif
    6492}
    6593
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp

    r6531 r6538  
    2020*   Header Files                                                               *
    2121*******************************************************************************/
    22 #include <iprt/assert.h>
     22#ifndef VBOX_VBGLR3_XFREE86
     23# include <iprt/assert.h>
     24#endif
    2325#include "VBGLR3Internal.h"
    2426
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