1/* 2 * Copyright 1999, Be Incorporated. 3 * Copyright 2007, Haiku. 4 * Distributed under the terms of the MIT License. 5 * 6 * Authors: 7 * Be Incorporated 8 * Eric Petit <eric.petit@lapsus.org> 9 * Michael Pfeiffer <laplace@users.sourceforge.net> 10 */ 11 12#ifndef DRIVERINTERFACE_H 13#define DRIVERINTERFACE_H 14 15#include <GraphicsDefs.h> 16#include <Accelerant.h> 17#include <Drivers.h> 18#include <PCI.h> 19#include <OS.h> 20 21#include "vm_device_version.h" 22#include "svga_reg.h" 23 24#define MAX_SAMPLE_DEVICE_NAME_LENGTH 32 25#define CURSOR_ID 1 26 27 28/*--------------------------------------------------------------------*/ 29/* Benaphores */ 30 31typedef struct { 32 sem_id sem; 33 int32 ben; 34} Benaphore; 35#define INIT_BEN(x) x.sem = create_sem(0, "VMware "#x); x.ben = 0; 36#define ACQUIRE_BEN(x) if((atomic_add(&(x.ben), 1)) >= 1) acquire_sem(x.sem); 37#define RELEASE_BEN(x) if((atomic_add(&(x.ben), -1)) > 1) release_sem(x.sem); 38#define DELETE_BEN(x) delete_sem(x.sem); 39 40 41/*--------------------------------------------------------------------*/ 42/* Utils */ 43 44#define ROUND_TO_PAGE_SIZE(x) (((x)+(B_PAGE_SIZE)-1)&~((B_PAGE_SIZE)-1)) 45 46static inline int 47BppForSpace(int space) 48{ 49 switch (space) { 50 case B_RGB32: 51 return 32; 52 case B_RGB24: 53 return 24; 54 case B_RGB16: 55 return 16; 56 case B_RGB15: 57 return 15; 58 case B_CMAP8: 59 return 8; 60 } 61 return 0; 62} 63 64 65/*--------------------------------------------------------------------*/ 66/* Request codes for ioctl() */ 67 68enum { 69 VMWARE_GET_PRIVATE_DATA = B_DEVICE_OP_CODES_END + 1, 70 VMWARE_FIFO_START, 71 VMWARE_FIFO_STOP, 72 VMWARE_FIFO_SYNC, 73 VMWARE_SET_MODE, 74 VMWARE_SHOW_CURSOR, 75 VMWARE_MOVE_CURSOR, 76 VMWARE_GET_DEVICE_NAME, 77 VMWARE_SET_PALETTE 78}; 79 80 81/*--------------------------------------------------------------------*/ 82/* Structure shared between the kernel driver and the accelerant */ 83 84typedef struct { 85 /* Device info and capabilities */ 86 uint16 vendorId; 87 uint16 deviceId; 88 uint8 revision; 89 uint32 maxWidth; 90 uint32 maxHeight; 91 void *fbDma; 92 uint32 fbSize; 93 void *fifoDma; 94 uint32 fifoSize; 95 uint32 fifoMin; 96 uint32 capabilities; 97 uint32 fifoCapabilities; 98 uint32 fifoFlags; 99 100 /* For registers access */ 101 uint16 indexPort; 102 uint16 valuePort; 103 104 /* Mapped areas */ 105 area_id fbArea; 106 void *fb; 107 area_id fifoArea; 108 void *fifo; 109 110 /* This changes when we switch to another mode */ 111 uint32 fbOffset; 112 uint32 bytesPerRow; 113 114 /* Current display mode */ 115 display_mode dm; 116 117 Benaphore engineLock; 118 Benaphore fifoLock; 119 uint32 fifoNext; 120 121 /* Cursor state */ 122 bool cursorShow; 123 uint16 cursorX; 124 uint16 cursorY; 125} SharedInfo; 126 127#endif 128