VirtualBox

Changeset 46747 in vbox for trunk/src


Ignore:
Timestamp:
Jun 24, 2013 8:09:49 AM (12 years ago)
Author:
vboxsync
Message:

FreeBSD/crOpenGL: 3D acceleration support for FreeBSD guests (thanks to Bernhard Froehlich)

Location:
trunk/src/VBox/Additions/common/crOpenGL
Files:
2 edited

Legend:

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

    r46228 r46747  
    6363if1of ($(KBUILD_TARGET), linux solaris freebsd)
    6464 #VBoxOGL_DRI = 1
    65  ifn1of ($(KBUILD_TARGET),solaris freebsd)   # No DRI on Solaris yet
     65 ifn1of ($(KBUILD_TARGET),solaris)   # No DRI on Solaris yet
    6666  VBoxOGL_FAKEDRI = 1
    6767 endif
     
    229229        $(PATH_STAGE_LIB)/libXext.so
    230230 ifdef VBoxOGL_FAKEDRI
    231   VBoxOGL_LIBS += \
     231  ifeq ($(KBUILD_TARGET), freebsd)
     232    VBoxOGL_LIBS += \
     233        elf
     234  else
     235    VBoxOGL_LIBS += \
    232236        dl
     237  endif
    233238 endif
    234239endif
     
    409414        $(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI)
    410415
     416  else ifeq ($(KBUILD_TARGET),freebsd)
     417$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports.c: \
     418                $(PATH_SUB_CURRENT)/FreeBSD_exports.py \
     419                $(VBOX_CROGL_API_FILES) $(PATH_SUB_CURRENT)/entrypoints.py \
     420                | $$(dir $$@)
     421        $(call MSG_GENERATE,python,$@,$<)
     422        $(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI)
    411423  else
    412424$(VBOX_PATH_CROGL_GENFILES)/linux_exports.c: \
  • trunk/src/VBox/Additions/common/crOpenGL/fakedri_drv.c

    r44529 r46747  
    3030#include <elf.h>
    3131#include <unistd.h>
     32
     33#if defined(BSD)
     34#include <sys/param.h>
     35#include <fcntl.h>
     36#include <gelf.h>
     37#include <libelf.h>
     38#include <string.h>
     39#endif
     40
    3241/** X server message type definitions. */
    3342typedef enum {
     
    5160//@todo this could be different...
    5261#ifdef RT_ARCH_AMD64
    53 # define DRI_DEFAULT_DRIVER_DIR "/usr/lib64/dri:/usr/lib/dri:/usr/lib/x86_64-linux-gnu/dri"
    54 # define DRI_XORG_DRV_DIR "/usr/lib/xorg/modules/drivers/"
     62# ifdef BSD
     63#  define DRI_DEFAULT_DRIVER_DIR "/usr/local/lib/dri"
     64#  define DRI_XORG_DRV_DIR "/usr/local/lib/xorg/modules/drivers/"
     65# else
     66#  define DRI_DEFAULT_DRIVER_DIR "/usr/lib64/dri:/usr/lib/dri:/usr/lib/x86_64-linux-gnu/dri"
     67#  define DRI_XORG_DRV_DIR "/usr/lib/xorg/modules/drivers/"
     68# endif
    5569#else
    56 # define DRI_DEFAULT_DRIVER_DIR "/usr/lib/dri:/usr/lib/i386-linux-gnu/dri"
    57 # define DRI_XORG_DRV_DIR "/usr/lib/xorg/modules/drivers/"
     70# ifdef BSD
     71#  define DRI_DEFAULT_DRIVER_DIR "/usr/local/lib/dri"
     72#  define DRI_XORG_DRV_DIR "/usr/local/lib/xorg/modules/drivers/"
     73# else
     74#  define DRI_DEFAULT_DRIVER_DIR "/usr/lib/dri:/usr/lib/i386-linux-gnu/dri"
     75#  define DRI_XORG_DRV_DIR "/usr/lib/xorg/modules/drivers/"
     76# endif
    5877#endif
    5978
     
    209228
    210229#define FAKEDRI_JMP64_PATCH_SIZE 13
     230
     231#if defined(BSD)
     232/* Provide basic dladdr1 flags */
     233enum {
     234        RTLD_DL_SYMENT  = 1
     235};
     236
     237/* Provide a minimal local version of dladdr1 */
     238static int
     239dladdr1(const void *address, Dl_info *dlip, void **info, int flags)
     240{
     241        static DRI_ELFSYM desym;
     242        GElf_Sym sym;
     243        GElf_Shdr shdr;
     244        Elf *elf;
     245        Elf_Scn *scn;
     246        Elf_Data *data;
     247        int ret, fd, count, i;
     248
     249        /* Initialize variables */
     250        fd = -1;
     251        elf = NULL;
     252
     253        /* Call dladdr first */
     254        ret = dladdr(address, dlip);
     255        if (ret == 0) goto err_exit;
     256
     257        /* Check for supported flags */
     258        if (flags != RTLD_DL_SYMENT) return 1;
     259
     260        /* Open shared library's ELF file */
     261        if (elf_version(EV_CURRENT) == EV_NONE) goto err_exit;
     262        fd = open(dlip->dli_fname, O_RDONLY);
     263        if (fd < 0) goto err_exit;
     264        elf = elf_begin(fd, ELF_C_READ, NULL);
     265        if (elf == NULL) goto err_exit;
     266
     267        /* Find the '.dynsym' section */
     268        scn = elf_nextscn(elf, NULL);
     269        while (scn != NULL) {
     270                if (gelf_getshdr(scn, &shdr) == NULL) goto err_exit;
     271                if (shdr.sh_type == SHT_DYNSYM) break;
     272                scn = elf_nextscn(elf, scn);
     273        }
     274        if (scn == NULL) goto err_exit;
     275
     276        /* Search for the requested symbol by name and offset */
     277        data = elf_getdata(scn, NULL);
     278        count = shdr.sh_size / shdr.sh_entsize;
     279        for (i = 0; i < count; i++) {
     280                gelf_getsym(data, i, &sym);
     281                if ((strcmp(dlip->dli_sname,
     282                        elf_strptr(elf, shdr.sh_link, sym.st_name)) == 0) &&
     283                    (sym.st_value == (dlip->dli_saddr - dlip->dli_fbase))) {
     284                        break;
     285                }
     286        }
     287
     288        /* Close ELF file */
     289        elf_end(elf);
     290        close(fd);
     291
     292        /* Return symbol entry in native format */
     293        desym.st_name = sym.st_name;
     294        desym.st_info = sym.st_info;
     295        desym.st_other = sym.st_other;
     296        desym.st_shndx = sym.st_shndx;
     297        desym.st_value = sym.st_value;
     298        desym.st_size = sym.st_size;
     299        *info = &desym;
     300        return 1;
     301
     302        /* Error handler */
     303err_exit:
     304        if (elf != NULL) elf_end(elf);
     305        if (fd >= 0) close(fd);
     306        return 0;
     307}
     308#endif
    211309
    212310static void
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