VirtualBox

Changeset 3194 in vbox


Ignore:
Timestamp:
Jun 21, 2007 3:52:13 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
22139
Message:

OS/2 port; documenting IOCtl trouble that's been brewing for a while and proposing a new more portable layout.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuest.h

    r3153 r3194  
    3939typedef uint32_t vmmDevHypPhys;
    4040
    41 #ifdef __WIN__
     41#if defined(__LINUX__)
     42/** The support device name. */
     43# define VBOXGUEST_DEVICE_NAME        "/dev/vboxadd"
     44
     45#elif defined(__OS2__)
     46/** The support device name. */
     47# define VBOXGUEST_DEVICE_NAME        "\\Dev\VBoxGst$"
     48
     49#elif defined(__WIN__)
    4250/** The support service name. */
    43 #define VBOXGUEST_SERVICE_NAME       "VBoxGuest"
     51# define VBOXGUEST_SERVICE_NAME       "VBoxGuest"
    4452/** Win32 Device name. */
    45 #define VBOXGUEST_DEVICE_NAME        "\\\\.\\VBoxGuest"
     53# define VBOXGUEST_DEVICE_NAME        "\\\\.\\VBoxGuest"
    4654/** Global name for Win2k+ */
    47 #define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
     55# define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
    4856/** Win32 driver name */
    49 #define VBOXGUEST_DEVICE_NAME_NT     L"\\Device\\VBoxGuest"
     57# define VBOXGUEST_DEVICE_NAME_NT     L"\\Device\\VBoxGuest"
    5058/** device name */
    51 #define VBOXGUEST_DEVICE_NAME_DOS    L"\\DosDevices\\VBoxGuest"
    52 #else /* !__WIN__ */
    53 #define VBOXGUEST_DEVICE_NAME        "/dev/vboxadd"
     59# define VBOXGUEST_DEVICE_NAME_DOS    L"\\DosDevices\\VBoxGuest"
     60
     61#else
     62/* PORTME */
    5463#endif
    5564
     
    862871/**
    863872 * VBoxGuest IOCTL codes and structures.
     873 *
     874 * The range 0..15 is for basic driver communication.
     875 * The range 16..31 is for HGCM communcation.
     876 * The range 32..47 is reserved for future use.
     877 * The range 48..63 is for OS specific communcation.
     878 * The 7th bit is reserved for future hacks.
     879 * The 8th bit is reserved for distinguishing between 32-bit and 64-bit
     880 * processes in future 64-bit guest additions.
     881 *
     882 * While windows IOCTL function number has to start at 2048 and stop at 4096 there
     883 * never was any need to do this for everyone. A simple ((Function) | 0x800) would
     884 * have sufficed. On Linux we're now intruding upon the type field. Fortunately
     885 * this hasn't caused any trouble because the FILE_DEVICE_UNKNOWN value was set
     886 * to 0x22 (if it were 0x2C it would not have worked soo smoothly). The situation
     887 * would've been the same for *BSD and Darwin since they seems to share common
     888 * _IOC() heritage.
     889 *
     890 * However, on good old OS/2 we only have 8-bit handy for the function number. The
     891 * result from using the old IOCTL function numbers her would've been overlapping
     892 * between the two ranges.
     893 *
     894 * To fix this problem and get rid of all the unnecessary windowsy crap that I
     895 * bet was copied from my SUPDRVIOC.h once upon a time (although the concept of
     896 * prefixing macros with the purpose of avoid clashes with system stuff and
     897 * to indicate exactly how owns them seems to have been lost somewhere along
     898 * the way), I've introduced a VBOXGUEST_IOCTL_CODE for defining generic IN/OUT
     899 * IOCtls on new ports of the additions.
     900 *
     901 * @remark  When creating new IOCtl interfaces keep in mind that not all OSes supports
     902 *          reporting back the output size. (This got messed up a little bit in VBoxDrv.)
     903 *
     904 *          OS/2 restricts the in/out data size to 64KB, while Linux, BSD and Darwin are
     905 *          limited by a 14 bits size field (16KB). So, special considerations need to
     906 *          be taken if more input/output needs to be passed around.
     907 *
     908 *          When passing variable sized input/output special care need to be taken on
     909 *          Unix platforms (if we're going to play by the rules) since the size is
     910 *          passed as part of the IOCtl code there. IIRC Darwin will use the size to
     911 *          perform locking and in/out copying, I don't quite know about linux and *BSD.
     912 *         
     913 * @remark  If adding interfaces that only has input or only has output, some new macros
     914 *          needs to be created so the most efficient IOCtl data buffering method can be
     915 *          used.
     916 *
    864917 * @{
    865  * IOCTL function numbers start from 2048, because MSDN says the
    866  * second parameter of CTL_CODE macro (function) must be <= 2048 and <= 4095 for IHVs.
    867  * The IOCTL number algorithm corresponds to CTL_CODE on Windows but for Linux IOCTLs,
    868  * we also encode the data size, so we need an additional parameter.
    869  */
     918 */
     919#ifdef __AMD64__
     920# define VBOXGUEST_IOCTL_FLAG     128
     921#elif defined(__X86__)
     922# define VBOXGUEST_IOCTL_FLAG     0
     923#else
     924# error "dunno which arch this is!"
     925#endif
     926
    870927#if defined(__WIN__)
    871 #define IOCTL_CODE(DeviceType, Function, Method, Access, DataSize_ignored) \
     928# define IOCTL_CODE(DeviceType, Function, Method, Access, DataSize_ignored) \
    872929    ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
    873 #else /* unix: */
    874 #define IOCTL_CODE(DeviceType, Function, Method_ignored, Access_ignored, DataSize) \
     930
     931#elif defined(__OS2__)
     932# define VBOXGUEST_IOCTL_CATEGORY                   0xc2
     933# define VBOXGUEST_IOCTL_CODE(Function, Size)       ((unsigned char)(Function))
     934# define VBOXGUEST_IOCTL_CATEGORY_FAST              0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
     935# define VBOXGUEST_IOCTL_CODE_FAST(Function)        ((unsigned char)(Function))
     936
     937#elif defined(__LINUX__)
     938# define IOCTL_CODE(DeviceType, Function, Method_ignored, Access_ignored, DataSize) \
    875939    ( (3 << 30) | ((DeviceType) << 8) | (Function) | ((DataSize) << 16) )
    876 #define METHOD_BUFFERED        0
    877 #define FILE_WRITE_ACCESS      0x0002
    878 #define FILE_DEVICE_UNKNOWN    0x00000022
     940# define METHOD_BUFFERED        0
     941# define FILE_WRITE_ACCESS      0x0002
     942# define FILE_DEVICE_UNKNOWN    0x00000022
     943
     944#elif 0 /* BSD style - needs some adjusting _IORW takes a type and not a size. */
     945# include <sys/ioccom.h>
     946# define VBOXGUEST_IOCTL_CODE(Function, Size)   _IORW('V', (Function) | VBOXGUEST_IOCTL_FLAG, (Size))
     947# define VBOXGUEST_IOCTL_CODE_FAST(Function)    _IO(  'V', (Function) | VBOXGUEST_IOCTL_FLAG)
     948
     949#else
     950# error "Port Me"
    879951#endif
    880952
    881953/** IOCTL to VBoxGuest to query the VMMDev IO port region start. */
    882 #define IOCTL_VBOXGUEST_GETVMMDEVPORT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestPortInfo))
     954#ifdef VBOXGUEST_IOCTL_CODE
     955# define VBOXGUEST_IOCTL_GETVMMDEVPORT  VBOXGUEST_IOCTL_CODE(1, sizeof(VBoxGuestPortInfo))
     956# define IOCTL_VBOXGUEST_GETVMMDEVPORT  VBOXGUEST_IOCTL_GETVMMDEVPORT
     957#else
     958# define IOCTL_VBOXGUEST_GETVMMDEVPORT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestPortInfo))
     959#endif
    883960
    884961#pragma pack(4)
     
    890967
    891968/** IOCTL to VBoxGuest to wait for a VMMDev host notification */
    892 #define IOCTL_VBOXGUEST_WAITEVENT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2049, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestWaitEventInfo))
     969#ifdef VBOXGUEST_IOCTL_CODE
     970# define VBOXGUEST_IOCTL_WAITEVENT      VBOXGUEST_IOCTL_CODE(2, sizeof(VBoxGuestWaitEventInfo))
     971# define IOCTL_VBOXGUEST_WAITEVENT      VBOXGUEST_IOCTL_WAITEVENT
     972#else
     973# define IOCTL_VBOXGUEST_WAITEVENT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2049, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestWaitEventInfo))
     974#endif
    893975
    894976/**
     
    9191001} VBoxGuestWaitEventInfo;
    9201002
    921 /** IOCTL to VBoxGuest to perform a VMM request */
    922 #define IOCTL_VBOXGUEST_VMMREQUEST IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2050, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VMMDevRequestHeader))
    923 
    924 /** IOCTL to VBoxGuest to control event filter mask */
    925 
     1003/** IOCTL to VBoxGuest to perform a VMM request
     1004 * @remark  The data buffer for this IOCtl has an variable size, keep this in mind
     1005 *          on systems where this matters. */
     1006#ifdef VBOXGUEST_IOCTL_CODE
     1007# define VBOXGUEST_IOCTL_VMMREQUEST(Size)   VBOXGUEST_IOCTL_CODE(3, sizeof(VMMDevRequestHeader))
     1008# define IOCTL_VBOXGUEST_VMMREQUEST         VBOXGUEST_IOCTL_VMMREQUEST(sizeof(VMMDevRequestHeader))
     1009#else
     1010# define IOCTL_VBOXGUEST_VMMREQUEST IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2050, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VMMDevRequestHeader))
     1011#endif
     1012
     1013/** Input and output buffer layout of the IOCTL_VBOXGUEST_CTL_FILTER_MASK. */
    9261014typedef struct _VBoxGuestFilterMaskInfo
    9271015{
     
    9311019#pragma pack()
    9321020
    933 #define IOCTL_VBOXGUEST_CTL_FILTER_MASK IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2051, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof (VBoxGuestFilterMaskInfo))
     1021/** IOCTL to VBoxGuest to control event filter mask */
     1022#ifdef VBOXGUEST_IOCTL_CODE
     1023# define VBOXGUEST_IOCTL_CTL_FILTER_MASK    VBOXGUEST_IOCTL_CODE(4, sizeof(VBoxGuestFilterMaskInfo))
     1024# define IOCTL_VBOXGUEST_CTL_FILTER_MASK    VBOXGUEST_IOCTL_CTL_FILTER_MASK
     1025#else
     1026# define IOCTL_VBOXGUEST_CTL_FILTER_MASK IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2051, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof (VBoxGuestFilterMaskInfo))
     1027#endif
    9341028
    9351029#ifdef VBOX_HGCM
     
    9611055#pragma pack()
    9621056
    963 #define IOCTL_VBOXGUEST_HGCM_CONNECT      IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3072, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMConnectInfo))
    964 #define IOCTL_VBOXGUEST_HGCM_DISCONNECT   IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3073, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMDisconnectInfo))
    965 #define IOCTL_VBOXGUEST_HGCM_CALL         IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3074, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMCallInfo))
    966 #define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3075, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(uint32_t))
     1057#ifdef VBOXGUEST_IOCTL_CODE
     1058# define VBOXGUEST_IOCTL_HGCM_CONNECT       VBOXGUEST_IOCTL_CODE(16, sizeof(VBoxGuestHGCMConnectInfo))
     1059# define IOCTL_VBOXGUEST_HGCM_CONNECT       VBOXGUEST_IOCTL_HGCM_CONNECT
     1060# define VBOXGUEST_IOCTL_HGCM_DISCONNECT    VBOXGUEST_IOCTL_CODE(17, sizeof(VBoxGuestHGCMDisconnectInfo))
     1061# define IOCTL_VBOXGUEST_HGCM_DISCONNECT    VBOXGUEST_IOCTL_HGCM_DISCONNECT
     1062# define VBOXGUEST_IOCTL_HGCM_CALL(Size)    VBOXGUEST_IOCTL_CODE(18, (Size))
     1063# define IOCTL_VBOXGUEST_HGCM_CALL          VBOXGUEST_IOCTL_HGCM_CALL(sizeof(VBoxGuestHGCMCallInfo))
     1064# define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT  VBOXGUEST_IOCTL_CODE(19, sizeof(uint32_t))
     1065# define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT  VBOXGUEST_IOCTL_CLIPBOARD_CONNECT
     1066#else
     1067# define IOCTL_VBOXGUEST_HGCM_CONNECT      IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3072, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMConnectInfo))
     1068# define IOCTL_VBOXGUEST_HGCM_DISCONNECT   IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3073, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMDisconnectInfo))
     1069# define IOCTL_VBOXGUEST_HGCM_CALL         IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3074, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMCallInfo))
     1070# define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3075, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(uint32_t))
     1071#endif
    9671072
    9681073#define VBOXGUEST_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
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