VirtualBox

Changeset 331 in vbox for trunk/src


Ignore:
Timestamp:
Jan 25, 2007 8:47:51 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
17884
Message:

Bool and AMD64 hacking.

Location:
trunk/src/VBox
Files:
8 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/Makefile

    r314 r331  
    5151        include/iprt/cdefs.h=$(PATH_ROOT)/include/iprt/cdefs.h \
    5252        include/iprt/err.h=$(PATH_ROOT)/include/iprt/err.h \
     53        include/iprt/heap.h=$(PATH_ROOT)/include/iprt/heap.h \
     54        include/iprt/initterm.h=$(PATH_ROOT)/include/iprt/initterm.h \
    5355        include/iprt/log.h=$(PATH_ROOT)/include/iprt/log.h \
    5456        include/iprt/mem.h=$(PATH_ROOT)/include/iprt/mem.h \
     
    6567        include/VBox/sup.h=$(PATH_ROOT)/include/VBox/sup.h \
    6668        include/VBox/types.h=$(PATH_ROOT)/include/VBox/types.h \
     69        include/internal/initterm.h=$(PATH_ROOT)/src/VBox/Runtime/include/internal/initterm.h \
    6770        linux/SUPDrv-linux.c=$(VBOX_PATH_SUPPORT)/linux/SUPDrv-linux.c \
    6871        Makefile=$(VBOX_PATH_SUPPORT)/linux/Makefile \
     72        alloc/heapsimple.c=$(PATH_ROOT)/src/VBox/Runtime/alloc/heapsimple.cpp \
    6973        r0drv/alloc-r0drv.c=$(PATH_ROOT)/src/VBox/Runtime/r0drv/alloc-r0drv.cpp \
    7074        r0drv/alloc-r0drv.h=$(PATH_ROOT)/src/VBox/Runtime/r0drv/alloc-r0drv.h \
     75        r0drv/initterm-r0drv.c=$(PATH_ROOT)/src/VBox/Runtime/r0drv/initterm-r0drv.cpp \
    7176        r0drv/linux/alloc-r0drv-linux.c=$(PATH_ROOT)/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c \
     77        r0drv/linux/initterm-r0drv-linux.c=$(PATH_ROOT)/src/VBox/Runtime/r0drv/linux/initterm-r0drv-linux.c \
    7278        r0drv/linux/semaphore-r0drv-linux.c=$(PATH_ROOT)/src/VBox/Runtime/r0drv/linux/semaphore-r0drv-linux.c \
    7379        r0drv/linux/spinlock-r0drv-linux.c=$(PATH_ROOT)/src/VBox/Runtime/r0drv/linux/spinlock-r0drv-linux.c \
  • trunk/src/VBox/HostDrivers/Support/linux/Makefile

    r213 r331  
    2121#
    2222
     23#
     24# First, figure out which architecture we're targeting.
     25# (We have to support basic cross building (ARCH=i386|x86_64).)
     26#
     27ifeq ($(filter amd64 x86,$(BUILD_TARGET_ARCH)),)
     28 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
     29 BUILD_TARGET_ARCH :=
     30endif
     31ifeq ($(BUILD_TARGET_ARCH),)
     32 ifeq ($(ARCH),x86_64)
     33  BUILD_TARGET_ARCH := amd64
     34 else ifeq ($(ARCH),i386)
     35  BUILD_TARGET_ARCH := x86
     36 else ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
     37  BUILD_TARGET_ARCH := amd64
     38 else
     39  BUILD_TARGET_ARCH := x86
     40 endif
     41endif
     42
     43
    2344MODULE = vboxdrv
    2445OBJS   = \
     
    2647        SUPDRVShared.o \
    2748        r0drv/alloc-r0drv.o \
     49        r0drv/initterm-r0drv.o \
    2850        r0drv/linux/alloc-r0drv-linux.o \
     51        r0drv/linux/initterm-r0drv-linux.o \
    2952        r0drv/linux/semaphore-r0drv-linux.o \
    3053        r0drv/linux/spinlock-r0drv-linux.o \
    31         r0drv/linux/thread-r0drv-linux.o \
     54        r0drv/linux/thread-r0drv-linux.o
     55ifeq ($(BUILD_TARGET_ARCH),amd64)
     56OBJS  += alloc/heapsimple.o
     57endif
     58
    3259
    3360ifneq ($(MAKECMDGOALS),clean)
     
    94121 KFLAGS  += -DCONFIG_VBOXDRV_AS_MISC
    95122endif
    96 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
     123ifeq ($(BUILD_TARGET_ARCH),amd64)
    97124 KFLAGS  += -D__AMD64__
    98125else
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r260 r331  
    11/** @file
    2  *
    3  * VBox host drivers - Ring-0 support drivers - Linux host:
    4  * Linux host driver code
     2 * The VirtualBox Support Driver - Linux hosts.
    53 */
    64
     
    2826#include <iprt/spinlock.h>
    2927#include <iprt/semaphore.h>
     28#include <iprt/initterm.h>
     29#include <iprt/err.h>
     30#include <iprt/mem.h>
    3031
    3132#include <linux/module.h>
     
    213214#define DEVICE_MAJOR   234
    214215/** Saved major device number */
    215 static int              g_iModuleMajor;
     216static int              g_iModuleMajor;
    216217#endif /* !CONFIG_VBOXDRV_AS_MISC */
    217218
     
    219220#define DEVICE_NAME    "vboxdrv"
    220221
    221 
     222#ifdef __AMD64__
     223/**
     224 * Memory for the executable memory heap (in IPRT).
     225 */
     226extern uint8_t g_abExecMemory[1572864]; /* 1.5 MB */
     227__asm__(".section execmemory, \"awx\", @progbits\n\t"
     228        ".align 32\n\t"
     229        ".globl g_abExecMemory\n"
     230        "g_abExecMemory:\n\t"
     231        ".zero 1572864\n\t"
     232        ".type g_abExecMemory, @object\n\t"
     233        ".size g_abExecMemory, 1572864\n\t"
     234        ".text\n\t");
     235#endif
    222236
    223237
     
    242256static struct file_operations gFileOpsVBoxDrv =
    243257{
    244         owner:          THIS_MODULE,
    245         open:           VBoxSupDrvCreate,
    246         release:        VBoxSupDrvClose,
    247         ioctl:          VBoxSupDrvDeviceControl,
     258    owner:      THIS_MODULE,
     259    open:       VBoxSupDrvCreate,
     260    release:    VBoxSupDrvClose,
     261    ioctl:      VBoxSupDrvDeviceControl,
    248262};
    249263
     
    378392    if (rc < 0)
    379393    {
    380         dprintf(("VBOX_REGISTER_DEVICE failed with rc=%#x!\n", rc));
     394        dprintf(("VBOX_REGISTER_DEVICE failed with rc=%#x!\n", rc));
    381395        return rc;
    382396    }
     
    398412    if (g_hDevFsVBoxDrv == NULL)
    399413    {
    400         dprintf(("devfs_register failed!\n"));
     414        dprintf(("devfs_register failed!\n"));
    401415        rc = -EINVAL;
    402416    }
     
    406420    {
    407421        /*
    408          * Initialize the device extension.
     422         * Initialize the runtime.
     423         * On AMD64 we'll have to donate the high rwx memory block to the exec allocator.
    409424         */
    410         rc = supdrvInitDevExt(&g_DevExt);
    411         if (!rc)
     425        rc = RTR0Init(0);
     426        if (RT_SUCCESS(rc))
    412427        {
     428#ifdef __AMD64__
     429            rc = RTR0MemExecDonate(&g_abExecMemory[0], sizeof(g_abExecMemory));
     430#endif
    413431            /*
    414              * Create the GIP page.
     432             * Initialize the device extension.
    415433             */
    416             rc = VBoxSupDrvInitGip(&g_DevExt);
     434            if (RT_SUCCESS(rc))
     435                rc = supdrvInitDevExt(&g_DevExt);
    417436            if (!rc)
    418437            {
    419                 dprintf(("VBoxDrv::ModuleInit returning %#x\n", rc));
    420                 return rc;
     438                /*
     439                 * Create the GIP page.
     440                 */
     441                rc = VBoxSupDrvInitGip(&g_DevExt);
     442                if (!rc)
     443                {
     444                    dprintf(("VBoxDrv::ModuleInit returning %#x\n", rc));
     445                    return rc;
     446                }
     447
     448                supdrvDeleteDevExt(&g_DevExt);
    421449            }
    422             supdrvDeleteDevExt(&g_DevExt);
     450            else
     451                rc = -EINVAL;
     452            RTR0Term();
    423453        }
    424454        else
     
    476506
    477507    /*
    478      * Destroy GIP and delete the device extension.
     508     * Destroy GIP, delete the device extension and terminate IPRT.
    479509     */
    480510    VBoxSupDrvTermGip(&g_DevExt);
    481511    supdrvDeleteDevExt(&g_DevExt);
     512    RTR0Term();
    482513}
    483514
     
    540571{
    541572    int                 rc;
    542     SUPDRVIOCTLDATA     Args;
     573    SUPDRVIOCTLDATA     Args;
    543574    void               *pvBuf = NULL;
    544575    int                 cbBuf = 0;
     
    686717int  VBOXCALL   supdrvOSLockMemOne(PSUPDRVMEMREF pMem, PSUPPAGE paPages)
    687718{
    688     int         rc;
     719    int         rc;
    689720    struct page **papPages;
    690721    unsigned    iPage;
     
    14811512{
    14821513#if 1
    1483     va_list      args;
    1484     char        szMsg[512];
     1514    va_list args;
     1515    char    szMsg[512];
    14851516
    14861517    va_start(args, pszFormat);
     
    15131544RTDECL(void) AssertMsg2(const char *pszFormat, ...)
    15141545{   /* forwarder. */
    1515     va_list      ap;
    1516     char        msg[256];
     1546    va_list ap;
     1547    char    msg[256];
    15171548
    15181549    va_start(ap, pszFormat);
  • trunk/src/VBox/Runtime/Makefile

    r289 r331  
    533533        VBox/strformat-vbox.cpp \
    534534        r0drv/alloc-r0drv.cpp \
     535        r0drv/initterm-r0drv.cpp \
    535536        generic/RTLogWriteStdErr-stub-generic.cpp \
    536537        generic/RTLogWriteStdOut-stub-generic.cpp \
     
    541542
    542543RuntimeR0Drv_SOURCES.linux = \
     544        alloc/heapsimple.cpp \
    543545        r0drv/linux/alloc-r0drv-linux.c \
     546        r0drv/linux/initterm-r0drv-linux.c \
    544547        r0drv/linux/RTLogWriteDebugger-r0drv-linux.c \
    545548        r0drv/linux/semaphore-r0drv-linux.c \
    546549        r0drv/linux/spinlock-r0drv-linux.c \
    547550        r0drv/linux/thread-r0drv-linux.c
    548 RuntimeR0Drv_SOURCES.linux.amd64 = \
    549         alloc/heapsimple.cpp
    550551
    551552RuntimeR0Drv_SOURCES.win = \
    552553        nt/RTErrConvertFromNtStatus.cpp \
    553554        r0drv/nt/alloc-r0drv-nt.cpp \
     555        r0drv/nt/initterm-r0drv-nt.cpp \
    554556        r0drv/nt/RTLogWriteDebugger-r0drv-nt.cpp \
    555557        r0drv/nt/semaphore-r0drv-nt.cpp \
     
    564566        RTErrConvertFromErrno.cpp \
    565567        string/memchr.asm \
    566         r0drv/initterm-r0drv.cpp \
    567568        r0drv/memobj-r0drv.cpp \
    568569        r0drv/thread-r0drv.cpp \
  • trunk/src/VBox/Runtime/alloc/heapsimple.cpp

    r329 r331  
    311311                     - sizeof(RTHEAPSIMPLEINTERNAL);
    312312    pHeapInt->pFreeTail = pHeapInt->pFreeHead = (PRTHEAPSIMPLEFREE)(pHeapInt + 1);
    313     for (unsigned i = 0; i < ELEMENTS(pHeapInt->auAlignment); i++)
     313    unsigned i;
     314    for (i = 0; i < ELEMENTS(pHeapInt->auAlignment); i++)
    314315        pHeapInt->auAlignment[i] = ~(size_t)0;
    315316
     
    448449     */
    449450    PRTHEAPSIMPLEBLOCK  pRet = NULL;
    450     for (PRTHEAPSIMPLEFREE pFree = pHeapInt->pFreeHead;
     451    PRTHEAPSIMPLEFREE   pFree;
     452    for (pFree = pHeapInt->pFreeHead;
    451453         pFree;
    452454         pFree = pFree->pNext)
     
    768770    PRTHEAPSIMPLEFREE pPrev = NULL;
    769771    PRTHEAPSIMPLEFREE pPrevFree = NULL;
    770     for (PRTHEAPSIMPLEFREE pBlock = (PRTHEAPSIMPLEFREE)(pHeapInt + 1);
     772    PRTHEAPSIMPLEFREE pBlock;
     773    for (pBlock = (PRTHEAPSIMPLEFREE)(pHeapInt + 1);
    771774         pBlock;
    772775         pBlock = (PRTHEAPSIMPLEFREE)pBlock->Core.pNext)
     
    881884              Heap, pHeapInt->cbHeap, pHeapInt->cbFree);
    882885
    883     for (PRTHEAPSIMPLEFREE pBlock = (PRTHEAPSIMPLEFREE)(pHeapInt + 1);
     886    PRTHEAPSIMPLEFREE pBlock;
     887    for (pBlock = (PRTHEAPSIMPLEFREE)(pHeapInt + 1);
    884888         pBlock;
    885889         pBlock = (PRTHEAPSIMPLEFREE)pBlock->Core.pNext)
  • trunk/src/VBox/Runtime/include/internal/initterm.h

    r207 r331  
    2323#define __internal_initterm_h_
    2424
    25 #include <sys/cdefs.h>
     25#include <iprt/cdefs.h>
    2626
    2727__BEGIN_DECLS
  • trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c

    r291 r331  
    2525*******************************************************************************/
    2626#include "the-linux-kernel.h"
    27 #include <iprt/alloc.h>
     27#include <iprt/mem.h>
    2828#include <iprt/assert.h>
    2929#include "r0drv/alloc-r0drv.h"
     
    6060 * This is as RTMemExecDonate specific to AMD64 Linux/GNU.
    6161 */
    62 RTDECL(void) RTMemExecCleanup(void)
     62void rtR0MemExecCleanup(void)
    6363{
    6464    RTSpinlockDestroy(g_HeapExecSpinlock);
     
    8282 * @param   cb          The size of the memory block.
    8383 */
    84 RTDECL(int) RTMemExecDonate(void *pvMemory, size_t cb)
     84RTR0DECL(int) RTR0MemExecDonate(void *pvMemory, size_t cb)
    8585{
    8686    int rc;
     
    9292        rc = RTHeapSimpleInit(&g_HeapExec, pvMemory, cb);
    9393        if (RT_FAILURE(rc))
    94             RTMemExecCleanup();
     94            rtR0MemExecCleanup();
    9595    }
    9696    return rc;
  • trunk/src/VBox/Runtime/r0drv/linux/initterm-r0drv-linux.c

    r303 r331  
    11/* $Id$ */
    22/** @file
    3  * InnoTek Portable Runtime - Initialization & Termination, R0 Driver, Darwin.
     3 * InnoTek Portable Runtime - Initialization & Termination, R0 Driver, Linux.
    44 */
    55
     
    2424*   Header Files                                                               *
    2525*******************************************************************************/
    26 #include "the-darwin-kernel.h"
     26#include "the-linux-kernel.h"
    2727#include <iprt/err.h>
    2828#include <iprt/assert.h>
     
    3131
    3232/*******************************************************************************
    33 *   Global Variables                                                           *
     33*   Internal Functions                                                         *
    3434*******************************************************************************/
    35 /** Pointer to the lock group used by IPRT. */
    36 lck_grp_t *g_pDarwinLockGroup = NULL;
    37 
     35#ifdef __AMD64__
     36/* in alloc-r0drv0-linux.c */
     37extern void rtR0MemExecCleanup(void);
     38#endif
    3839
    3940
    4041int rtR0InitNative(void)
    4142{
    42     /*
    43      * Create the lock group.
    44      */
    45     g_pDarwinLockGroup = lck_grp_alloc_init("IPRT", LCK_GRP_ATTR_NULL);
    46     AssertReturn(g_pDarwinLockGroup, VERR_NO_MEMORY);
    47 
    4843    return VINF_SUCCESS;
    4944}
     
    5247void rtR0TermNative(void)
    5348{
    54     /*
    55      * Free the lock group.
    56      */
    57     if (g_pDarwinLockGroup)
    58     {
    59         lck_grp_free(g_pDarwinLockGroup);
    60         g_pDarwinLockGroup = NULL;
    61     }
     49#ifdef __AMD64__
     50    rtR0MemExecCleanup();
     51#endif
    6252}
    6353
  • trunk/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h

    r260 r331  
    2323#define __the_linux_kernel_h__
    2424
    25 #ifndef bool /* Linux 2.6.19 C++ nightmare */
    26 #define bool bool_type
    27 #define true true_type
    28 #define false false_type
    29 #define _Bool int
    30 #define bool_type_r0drv_the_linux_kernel_h__
    31 #endif
     25/*
     26 * Include iprt/types.h to install the bool wrappers.
     27 * Then use the linux bool type for all the stuff include here.
     28 */
     29#include <iprt/types.h>
     30#define bool linux_bool
    3231
    3332#include <linux/autoconf.h>
     
    5453#  define KBUILD_STR(s) #s
    5554# endif
    56 #endif
    57 #include <iprt/cdefs.h>
    58 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    59 # undef ALIGN
    6055#endif
    6156#include <linux/string.h>
     
    9085#include <asm/div64.h>
    9186
    92 #ifdef bool_type_r0drv_the_linux_kernel_h__
    93 #undef bool
    94 #undef true
    95 #undef false
    96 #undef _Bool
    97 #undef bool_type_r0drv_the_linux_kernel_h__
    98 #endif
    99 
    10087#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
    10188# ifndef page_to_pfn
     
    228215#endif
    229216
    230 #endif
    231 
     217/*
     218 * Stop using the linux bool type.
     219 */
     220#undef bool
     221
     222#endif
     223
  • trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp

    r303 r331  
    11/* $Id$ */
    22/** @file
    3  * InnoTek Portable Runtime - Initialization & Termination, R0 Driver, Darwin.
     3 * InnoTek Portable Runtime - Initialization & Termination, R0 Driver, NT.
    44 */
    55
     
    2424*   Header Files                                                               *
    2525*******************************************************************************/
    26 #include "the-darwin-kernel.h"
     26#include "the-nt-kernel.h"
    2727#include <iprt/err.h>
    2828#include <iprt/assert.h>
    2929#include "internal/initterm.h"
    3030
    31 
    32 /*******************************************************************************
    33 *   Global Variables                                                           *
    34 *******************************************************************************/
    35 /** Pointer to the lock group used by IPRT. */
    36 lck_grp_t *g_pDarwinLockGroup = NULL;
    37 
    38 
    39 
    4031int rtR0InitNative(void)
    4132{
    42     /*
    43      * Create the lock group.
    44      */
    45     g_pDarwinLockGroup = lck_grp_alloc_init("IPRT", LCK_GRP_ATTR_NULL);
    46     AssertReturn(g_pDarwinLockGroup, VERR_NO_MEMORY);
    47 
    4833    return VINF_SUCCESS;
    4934}
     
    5237void rtR0TermNative(void)
    5338{
    54     /*
    55      * Free the lock group.
    56      */
    57     if (g_pDarwinLockGroup)
    58     {
    59         lck_grp_free(g_pDarwinLockGroup);
    60         g_pDarwinLockGroup = NULL;
    61     }
    6239}
    6340
Note: See TracChangeset for help on using the changeset viewer.

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