VirtualBox

Changeset 43408 in vbox for trunk/src


Ignore:
Timestamp:
Sep 22, 2012 4:53:18 PM (12 years ago)
Author:
vboxsync
Message:

Additions/haiku: cleanup.

Location:
trunk/src/VBox/Additions/haiku/VBoxVideo
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/haiku/VBoxVideo/accelerant/accelerant.cpp

    r43364 r43408  
    4545 */
    4646
     47/*******************************************************************************
     48*   Header Files                                                               *
     49*******************************************************************************/
    4750#include <Accelerant.h>
    4851#include "accelerant.h"
     
    5154#include <errno.h>
    5255
    53 #define TRACE(x...) do { FILE* logfile = fopen("/var/log/vboxvideo.accelerant.log", "a"); fprintf(logfile, x); fflush(logfile); fsync(fileno(logfile)); fclose(logfile); sync(); } while(0)
     56/*******************************************************************************
     57*   Global Variables                                                           *
     58*******************************************************************************/
     59AccelerantInfo gInfo;
     60static engine_token sEngineToken = { 1, 0 /*B_2D_ACCELERATION*/, NULL };
     61
     62/** @todo r=ramshankar: get rid of this and replace with IPRT logging. */
     63#define TRACE(x...) do { \
     64    FILE* logfile = fopen("/var/log/vboxvideo.accelerant.log", "a"); \
     65    fprintf(logfile, x); \
     66    fflush(logfile); \
     67    fsync(fileno(logfile)); \
     68    fclose(logfile); \
     69    sync(); \
     70     } while(0)
    5471
    5572class AreaCloner
    5673{
    5774    public:
    58         AreaCloner() : fArea(-1) { }
     75        AreaCloner()
     76            : fArea(-1)
     77        {
     78        }
     79
    5980        ~AreaCloner()
    6081        {
     
    6990        }
    7091
    71         status_t InitCheck() { return fArea < B_OK ? (status_t)fArea : B_OK; }
    72         void Keep() { fArea = -1; }
     92        status_t InitCheck()
     93        {
     94            return fArea < B_OK ? (status_t)fArea : B_OK;
     95        }
     96
     97        void Keep()
     98        {
     99            fArea = -1;
     100        }
    73101
    74102    private:
    75         area_id    fArea;
     103        area_id fArea;
    76104};
    77 
    78 AccelerantInfo gInfo;
    79 
    80 static engine_token sEngineToken = { 1, 0 /*B_2D_ACCELERATION*/, NULL };
    81105
    82106extern "C"
     
    86110    switch (feature)
    87111    {
    88         /* general */
     112        /* General */
    89113        case B_INIT_ACCELERANT:
    90114            return (void *)vboxvideo_init_accelerant;
     
    102126            return (void *)vboxvideo_accelerant_retrace_semaphore;
    103127
    104             /* mode configuration */
     128        /* Mode configuration */
    105129        case B_ACCELERANT_MODE_COUNT:
    106130            return (void *)vboxvideo_accelerant_mode_count;
     
    118142            return (void *)vboxvideo_get_pixel_clock_limits;
    119143
     144#if 0
    120145            /* cursor managment */
    121             /*case B_SET_CURSOR_SHAPE:
     146            case B_SET_CURSOR_SHAPE:
    122147                return (void*)vboxvideo_set_cursor_shape;
    123148            case B_MOVE_CURSOR:
    124149                return (void*)vboxvideo_move_cursor;
    125150            case B_SHOW_CURSOR:
    126                 return (void*)vboxvideo_show_cursor;*/
    127 
    128             /* engine/synchronization */
     151                return (void*)vboxvideo_show_cursor;
     152#endif
     153
     154        /* Engine/synchronization */
    129155        case B_ACCELERANT_ENGINE_COUNT:
    130156            return (void *)vboxvideo_accelerant_engine_count;
     
    162188
    163189    AreaCloner sharedCloner;
    164     gInfo.sharedInfoArea = sharedCloner.Clone("vboxvideo shared info",
    165                                               (void **)&gInfo.sharedInfo, B_ANY_ADDRESS,
     190    gInfo.sharedInfoArea = sharedCloner.Clone("vboxvideo shared info", (void **)&gInfo.sharedInfo, B_ANY_ADDRESS,
    166191                                              B_READ_AREA | B_WRITE_AREA, sharedArea);
    167192    status_t status = sharedCloner.InitCheck();
     
    176201}
    177202
     203
    178204status_t vboxvideo_init_accelerant(int fd)
    179205{
     
    181207}
    182208
     209
    183210ssize_t vboxvideo_accelerant_clone_info_size(void)
    184211{
     
    187214}
    188215
     216
    189217void vboxvideo_get_accelerant_clone_info(void *data)
    190218{
     
    193221}
    194222
     223
    195224status_t vboxvideo_clone_accelerant(void *data)
    196225{
    197226    TRACE("%s\n", __FUNCTION__);
    198227
    199     // create full device name
     228    /* Create full device name */
    200229    char path[MAXPATHLEN];
    201230    strcpy(path, "/dev/");
     
    209238}
    210239
     240
    211241void vboxvideo_uninit_accelerant(void)
    212242{
     
    220250    TRACE("%s\n", __FUNCTION__);
    221251}
     252
    222253
    223254status_t vboxvideo_get_accelerant_device_info(accelerant_device_info *adi)
     
    231262}
    232263
     264
    233265sem_id vboxvideo_accelerant_retrace_semaphore(void)
    234266{
     
    236268    return -1;
    237269}
     270
    238271
    239272// modes & constraints
     
    244277}
    245278
     279
    246280status_t vboxvideo_get_mode_list(display_mode *dm)
    247281{
     
    250284    return vboxvideo_get_display_mode(dm);
    251285}
     286
    252287
    253288status_t vboxvideo_set_display_mode(display_mode *modeToSet)
     
    258293}
    259294
     295
    260296status_t vboxvideo_get_display_mode(display_mode *currentMode)
    261297{
     
    266302}
    267303
     304
    268305status_t vboxvideo_get_edid_info(void *info, size_t size, uint32 *_version)
    269306{
    270307    TRACE("%s\n", __FUNCTION__);
    271308
    272     // copied from the X11 implementation:
     309    /* Copied from the X11 implementation: */
    273310    static const uint8 edid_data[128] = {
    274311        0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, /* header */
     
    307344        return B_BUFFER_OVERFLOW;
    308345
    309     *_version = 1; /*EDID_VERSION_1*/
     346    *_version = 1; /* EDID_VERSION_1 */
    310347    memcpy(info, edid_data, 128);
    311348    return B_OK;
    312349}
     350
    313351
    314352status_t vboxvideo_get_frame_buffer_config(frame_buffer_config *config)
     
    322360}
    323361
     362
    324363status_t vboxvideo_get_pixel_clock_limits(display_mode *dm, uint32 *low, uint32 *high)
    325364{
     
    331370}
    332371
    333 // cursor
     372
     373/* Cursor */
    334374status_t vboxvideo_set_cursor_shape(uint16 width, uint16 height, uint16 hotX, uint16 hotY, uint8 *andMask, uint8 *xorMask)
    335375{
     
    339379}
    340380
     381
    341382void vboxvideo_move_cursor(uint16 x, uint16 y)
    342383{
     
    344385}
    345386
     387
    346388void vboxvideo_show_cursor(bool is_visible)
    347389{
     
    349391}
    350392
    351 // accelerant engine
     393
     394/* Accelerant engine */
    352395uint32 vboxvideo_accelerant_engine_count(void)
    353396{
     
    362405    return B_OK;
    363406}
     407
    364408
    365409status_t vboxvideo_release_engine(engine_token *et, sync_token *st)
     
    372416}
    373417
     418
    374419void vboxvideo_wait_engine_idle(void)
    375420{
     
    377422}
    378423
     424
    379425status_t vboxvideo_get_sync_token(engine_token *et, sync_token *st)
    380426{
     
    383429}
    384430
     431
    385432status_t vboxvideo_sync_to_token(sync_token *st)
    386433{
     
    389436}
    390437
    391 // 2D acceleration
     438
     439/* 2D acceleration */
    392440void vboxvideo_screen_to_screen_blit(engine_token *et, blit_params *list, uint32 count)
    393441{
     
    395443}
    396444
     445
    397446void vboxvideo_fill_rectangle(engine_token *et, uint32 color, fill_rect_params *list, uint32 count)
    398447{
     
    400449}
    401450
     451
    402452void vboxvideo_invert_rectangle(engine_token *et, fill_rect_params *list, uint32 count)
    403453{
     
    405455}
    406456
     457
    407458void vboxvideo_fill_span(engine_token *et, uint32 color, uint16 *list, uint32 count)
    408459{
  • trunk/src/VBox/Additions/haiku/VBoxVideo/accelerant/accelerant.h

    r43364 r43408  
    4545 */
    4646
    47 #ifndef _ACCELERANT_H
    48 #define _ACCELERANT_H
     47#ifndef ___VBOX_ACCELERANT_H
     48#define ___VBOX_ACCELERANT_H
    4949
    5050#include <Accelerant.h>
     
    5353struct AccelerantInfo
    5454{
    55         int deviceFD;
    56         bool isClone;
     55    /** @todo doxygen document these fields  */
     56    int deviceFD;
     57    bool isClone;
    5758
    58         SharedInfo *sharedInfo;
    59         area_id sharedInfoArea;
     59    SharedInfo *sharedInfo;
     60    area_id sharedInfoArea;
    6061};
    6162extern AccelerantInfo gInfo;
    6263
    63 // general
     64/* General */
    6465status_t vboxvideo_init_accelerant(int fd);
    6566ssize_t vboxvideo_accelerant_clone_info_size(void);
     
    7071sem_id vboxvideo_accelerant_retrace_semaphore(void);
    7172
    72 // modes & constraints
     73/* Modes & constraints */
    7374uint32 vboxvideo_accelerant_mode_count(void);
    7475status_t vboxvideo_get_mode_list(display_mode *dm);
     
    7980status_t vboxvideo_get_pixel_clock_limits(display_mode *dm, uint32 *low, uint32 *high);
    8081
    81 // cursor
     82/* Cursor */
    8283status_t vboxvideo_set_cursor_shape(uint16 width, uint16 height, uint16 hotX, uint16 hotY, uint8 *andMask, uint8 *xorMask);
    8384void vboxvideo_move_cursor(uint16 x, uint16 y);
    8485void vboxvideo_show_cursor(bool is_visible);
    8586
    86 // accelerant engine
     87/* Accelerant engine */
    8788uint32 vboxvideo_accelerant_engine_count(void);
    8889status_t vboxvideo_acquire_engine(uint32 capabilities, uint32 maxWait, sync_token *st, engine_token **et);
     
    9293status_t vboxvideo_sync_to_token(sync_token *st);
    9394
    94 // 2D acceleration
     95/* 2D acceleration */
    9596void vboxvideo_screen_to_screen_blit(engine_token *et, blit_params *list, uint32 count);
    9697void vboxvideo_fill_rectangle(engine_token *et, uint32 color, fill_rect_params *list, uint32 count);
     
    9899void vboxvideo_fill_span(engine_token *et, uint32 color, uint16 *list, uint32 count);
    99100
    100 #endif    /* _ACCELERANT_PROTOS_H */
     101#endif /* ___VBOX_ACCELERANT_H */
     102
  • trunk/src/VBox/Additions/haiku/VBoxVideo/common/VBoxVideo_common.h

    r43364 r43408  
    4545 */
    4646
    47 #ifndef _VBOXVIDEO_COMMON_H
    48 #define _VBOXVIDEO_COMMON_H
     47#ifndef ___VBOXVIDEO_COMMON_H
     48#define ___VBOXVIDEO_COMMON_H
    4949
    5050#include <Drivers.h>
     
    5454struct SharedInfo
    5555{
    56         display_mode currentMode;
    57         area_id framebufferArea;
    58         void *framebuffer;
     56    display_mode currentMode;
     57    area_id framebufferArea;
     58    void *framebuffer;
    5959};
    6060
     
    7272        case 1:  return B_GRAY1;
    7373        case 4:  return B_GRAY8;
    74                 // the app_server is smart enough to translate this to VGA mode
     74        /* The app_server is smart enough to translate this to VGA mode */
    7575        case 8:  return B_CMAP8;
    7676        case 15: return B_RGB15;
     
    9898}
    9999
    100 #endif /* _VBOXVIDEO_COMMON_H */
     100#endif /* ___VBOXVIDEO_COMMON_H */
    101101
  • trunk/src/VBox/Additions/haiku/VBoxVideo/driver/driver.cpp

    r43366 r43408  
    4545 */
    4646
     47/*******************************************************************************
     48*   Header Files                                                               *
     49*******************************************************************************/
    4750#include <KernelExport.h>
    4851#include <PCI.h>
     
    5760#define VENDOR_ID 0x80ee
    5861#define DEVICE_ID 0xbeef
    59 
    60 #define DEVICE_FORMAT "vd_%04X_%04X_%02X%02X%02X"
    61 
     62#define DRIVER_NAME                 "VBoxVideoDriver"
     63#define DEVICE_FORMAT               "vd_%04X_%04X_%02X%02X%02X"
     64
     65/** @todo r=ramshankar: pretty sure IPRT has something for page rounding,
     66 *        replace with IPRT version later. */
    6267#define ROUND_TO_PAGE_SIZE(x) (((x) + (B_PAGE_SIZE) - 1) & ~((B_PAGE_SIZE) - 1))
    6368
     
    109114struct DeviceInfo
    110115{
    111     uint32          openCount;                  // count of how many times device has been opened
    112     uint32          flags;                                      // device flags
    113     area_id         sharedArea;                 // area shared between driver and all accelerants
    114     SharedInfo     *sharedInfo;                 // pointer to shared info area memory
    115     pci_info        pciInfo;                    // copy of pci info for this device
    116     char            name[B_OS_NAME_LENGTH]; // name of device
     116    uint32          openCount;                  /* Count of how many times device has been opened */
     117    uint32          flags;                                      /* Device flags */
     118    area_id         sharedArea;                 /* Area shared between driver and all accelerants */
     119    SharedInfo     *sharedInfo;                 /* Pointer to shared info area memory */
     120    pci_info        pciInfo;                    /* Copy of pci info for this device */
     121    char            name[B_OS_NAME_LENGTH]; /* Name of device */
    117122};
    118123
    119 // at most one virtual video card ever appears, no reason for this to be an array
    120 static DeviceInfo gDeviceInfo;
    121 static char *gDeviceNames[2] = { gDeviceInfo.name, NULL };
    122 static bool gCanHasDevice = false; // is the device present?
    123 static Benaphore gLock;
    124 static pci_module_info *gPCI;
    125 
     124/*******************************************************************************
     125*   Internal Functions                                                         *
     126*******************************************************************************/
    126127status_t device_open(const char *name, uint32 flags, void **cookie);
    127128status_t device_close(void *dev);
     
    132133static uint32 get_color_space_for_depth(uint32 depth);
    133134
     135/*******************************************************************************
     136*   Globals                                                                    *
     137*******************************************************************************/
     138/* At most one virtual video card ever appears, no reason for this to be an array */
     139static DeviceInfo gDeviceInfo;
     140static char *gDeviceNames[2] = { gDeviceInfo.name, NULL };
     141static bool gCanHasDevice = false; /* is the device present? */
     142static Benaphore gLock;
     143static pci_module_info *gPCI;
     144
    134145static device_hooks gDeviceHooks =
    135146{
    136     device_open, // open
    137     device_close, // close
    138     device_free, // free
    139     device_ioctl, // control
    140     device_read, // read
    141     device_write, // write
    142     NULL, // select
    143     NULL, // deselect
    144     NULL, // read_pages
    145     NULL  // write_pages
     147    device_open,
     148    device_close,
     149    device_free,
     150    device_ioctl,
     151    device_read,
     152    device_write,
     153    NULL,          /* select */
     154    NULL,          /* deselect */
     155    NULL,          /* read_pages */
     156    NULL           /* write_pages */
    146157};
    147158
     159
    148160status_t init_hardware()
    149161{
    150     TRACE("init_hardware\n");
    151 
    152     if (get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest) != B_OK)
    153     {
    154         dprintf("get_module(%s) failed\n", VBOXGUEST_MODULE_NAME);
    155         return B_ERROR;
    156     }
    157 
    158     if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPCI) != B_OK)
    159     {
    160         dprintf("get_module(%s) failed\n", B_PCI_MODULE_NAME);
    161         return B_ERROR;
    162     }
    163 
    164     return B_OK;
    165 }
     162    LogFlowFunc(("init_hardware\n"));
     163
     164    status_t err = get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest)
     165    if (err == B_OK)
     166    {
     167        err = get_module(B_PCI_MODULE_NAME, (module_info **)&gPCI);
     168        if (err == B_OK)
     169            return B_OK;
     170
     171        LogRel((DRIVER_NAME ":_init_hardware() get_module(%s) failed. err=%08lx\n", B_PCI_MODULE_NAME));
     172    }
     173    else
     174        LogRel((DRIVER_NAME ":_init_hardware() get_module(%s) failed. err=%08lx\n", VBOXGUEST_MODULE_NAME, err));
     175    return B_ERROR;
     176}
     177
    166178
    167179status_t init_driver()
    168180{
    169     TRACE("init_driver\n");
     181    LogFlowFunc(("init_driver\n"));
    170182
    171183    gLock.Init("VBoxVideo driver lock");
     
    202214            gDeviceInfo.sharedInfo->currentMode.timing.h_display = width;
    203215            gDeviceInfo.sharedInfo->currentMode.timing.v_display = height;
    204             // not used, but this makes a reasonable-sounding refresh rate show in screen prefs:
     216            /* Not used, but this makes a reasonable-sounding refresh rate show in screen prefs: */
    205217            gDeviceInfo.sharedInfo->currentMode.timing.h_total = 1000;
    206218            gDeviceInfo.sharedInfo->currentMode.timing.v_total = 1;
    207219            gDeviceInfo.sharedInfo->currentMode.timing.pixel_clock = 850;
    208220
    209             // map the PCI memory space
     221            /* Map the PCI memory space */
    210222            uint32 command_reg = gPCI->read_pci_config(gDeviceInfo.pciInfo.bus,
    211223                                                       gDeviceInfo.pciInfo.device, gDeviceInfo.pciInfo.function,  PCI_command, 2);
     
    232244const char** publish_devices()
    233245{
    234     TRACE("publish_devices\n");
     246    LogFlowFunc(("publish_devices\n"));
    235247    if (gCanHasDevice)
    236248        return (const char **)gDeviceNames;
     
    241253device_hooks* find_device(const char *name)
    242254{
    243     TRACE("find_device\n");
     255    LogFlowFunc(a("find_device\n"));
    244256    if (gCanHasDevice && strcmp(name, gDeviceInfo.name) == 0)
    245257        return &gDeviceHooks;
     
    251263void uninit_driver()
    252264{
    253     TRACE("uninit_driver\n");
     265    LogFlowFunc(("uninit_driver\n"));
    254266    gLock.Delete();
    255267    put_module(VBOXGUEST_MODULE_NAME);
     
    258270status_t device_open(const char *name, uint32 flags, void **cookie)
    259271{
    260     TRACE("device_open\n");
     272    LogFlowFunc(("device_open\n"));
    261273
    262274    if (!gCanHasDevice || strcmp(name, gDeviceInfo.name) != 0)
    263275        return B_BAD_VALUE;
    264276
    265     // TODO init device!
     277    /* @todo init device! */
    266278
    267279    *cookie = (void *)&gDeviceInfo;
     
    272284status_t device_close(void *dev)
    273285{
    274     TRACE("device_close\n");
     286    LogFlowFunc(("device_close\n"));
    275287    return B_ERROR;
    276288}
     
    279291status_t device_free(void *dev)
    280292{
    281     TRACE("device_free\n");
     293    LogFlowFunc(("device_free\n"));
    282294
    283295    DeviceInfo& di = *(DeviceInfo *)dev;
     
    303315status_t device_read(void *dev, off_t pos, void *buf, size_t *len)
    304316{
    305     TRACE("device_read\n");
     317    LogFlowFunc(("device_read\n"));
    306318    return B_NOT_ALLOWED;
    307319}
     
    310322status_t device_write(void *dev, off_t pos, const void *buf, size_t *len)
    311323{
    312     TRACE("device_write\n");
     324    LogFlowFunc(("device_write\n"));
    313325    return B_NOT_ALLOWED;
    314326}
     
    317329status_t device_ioctl(void *cookie, uint32 msg, void *buf, size_t len)
    318330{
    319     TRACE("device_ioctl\n");
     331    LogFlowFunc(("device_ioctl\n"));
    320332
    321333    DeviceInfo *dev = (DeviceInfo *)cookie;
     
    324336    {
    325337        case B_GET_ACCELERANT_SIGNATURE:
     338        {
    326339            strcpy((char *)buf, "vboxvideo.accelerant");
    327340            return B_OK;
     341        }
    328342
    329343        case VBOXVIDEO_GET_PRIVATE_DATA:
     344        {
     345            /** @todo r=ramshankar: implement RTR0MemUserCopyFrom for haiku. */
    330346            return user_memcpy(buf, &dev->sharedArea, sizeof(area_id));
     347        }
    331348
    332349        case VBOXVIDEO_GET_DEVICE_NAME:
     350        {
     351            /** @todo r=ramshankar: implement RTR0MemUserCopyFrom for haiku. */
    333352            if (user_strlcpy((char *)buf, gDeviceInfo.name, len) < B_OK)
    334353                return B_BAD_ADDRESS;
    335             else
    336                 return B_OK;
     354            return B_OK;
     355        }
    337356
    338357        case VBOXVIDEO_SET_DISPLAY_MODE:
     
    347366            return B_BAD_VALUE;
    348367    }
    349 
    350 }
    351 
     368}
     369
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