-Source: http://ports.ubuntu.com/pool/multiverse/v/virtualbox/virtualbox-guest-dkms_5.0.0-dfsg-1_all.deb
-Version: 5.0.0-dfsg-1
+Source: http://ports.ubuntu.com/pool/multiverse/v/virtualbox/virtualbox-guest-dkms_5.0.14-dfsg-2_all.deb
+Version: 5.0.14-dfsg-2
#include <VBox/VBoxGuest2.h>
-/** @defgroup grp_vboxguest VirtualBox Guest Additions Driver Interface
+/** @defgroup grp_vboxguest VirtualBox Guest Additions Device Driver
+ *
+ * Also know as VBoxGuest.
+ *
+ * @{
+ */
+
+/** @defgroup grp_vboxguest_ioc VirtualBox Guest Additions Driver Interface
* @{
*/
/** @} */
+/** @} */
#endif
#ifdef VBOX_WITH_HGCM
# include <VBox/VMMDev2.h>
+/** @addtogroup grp_vmmdev
+ * @{ */
/**
* HGCM connect info structure.
AssertCompileSize(VBoxGuestHGCMCallInfoTimed, 8+16);
# pragma pack()
+/** @} */
+
#endif /* VBOX_WITH_HGCM */
#endif
#endif
-/** @defgroup grp_guest_lib VirtualBox Guest Additions Library
+/** @defgroup grp_vboxguest_lib VirtualBox Guest Additions Library
+ * @ingroup grp_vboxguest
* @{
*/
RT_C_DECLS_BEGIN
-/** @defgroup grp_guest_lib_r0 Ring-0 interface.
+/** HGCM client ID.
+ * @todo Promote to VBox/types.h */
+typedef uint32_t HGCMCLIENTID;
+
+
+/** @defgroup grp_vboxguest_lib_r0 Ring-0 interface.
* @{
*/
#if defined(IN_RING0) && !defined(IN_RING0_AGNOSTIC)
# endif
# define DECLVBGL(type) DECLR0VBGL(type)
-typedef uint32_t VBGLIOPORT; /**< @todo r=bird: We have RTIOPORT (uint16_t) for this. */
-
# ifdef VBGL_VBOXGUEST
*
* @return VBox status code.
*/
-DECLVBGL(int) VbglInit (VBGLIOPORT portVMMDev, struct VMMDevMemory *pVMMDevMemory);
+DECLVBGL(int) VbglInitPrimary(RTIOPORT portVMMDev, struct VMMDevMemory *pVMMDevMemory);
# else
*
* @return VBox status code.
*/
-DECLVBGL(int) VbglInit (void);
+DECLVBGL(int) VbglInitClient(void);
# endif
/**
* The library termination function.
*/
-DECLVBGL(void) VbglTerminate (void);
+DECLVBGL(void) VbglTerminate(void);
/** @name Generic request functions.
/**
* Allocate memory for generic request and initialize the request header.
*
- * @param ppReq pointer to resulting memory address.
- * @param cbSize size of memory block required for the request.
- * @param reqType the generic request type.
- *
- * @return VBox status code.
+ * @returns VBox status code.
+ * @param ppReq Where to return the pointer to the allocated memory.
+ * @param cbReq Size of memory block required for the request.
+ * @param enmReqType the generic request type.
*/
-DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType);
+DECLVBGL(int) VbglGRAlloc(VMMDevRequestHeader **ppReq, size_t cbReq, VMMDevRequestType enmReqType);
/**
* Perform the generic request.
*
* @return VBox status code.
*/
-DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq);
+DECLVBGL(int) VbglGRPerform(VMMDevRequestHeader *pReq);
/**
* Free the generic request memory.
*
* @return VBox status code.
*/
-DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq);
+DECLVBGL(void) VbglGRFree(VMMDevRequestHeader *pReq);
/**
* Verify the generic request header.
*
* @return VBox status code.
*/
-DECLVBGL(int) VbglGRVerify (const VMMDevRequestHeader *pReq, size_t cbReq);
+DECLVBGL(int) VbglGRVerify(const VMMDevRequestHeader *pReq, size_t cbReq);
/** @} */
# ifdef VBOX_WITH_HGCM
* @return VBox status code.
*/
-DECLR0VBGL(int) VbglR0HGCMInternalConnect (VBoxGuestHGCMConnectInfo *pConnectInfo,
- PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
+DECLR0VBGL(int) VbglR0HGCMInternalConnect(VBoxGuestHGCMConnectInfo *pConnectInfo,
+ PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
/**
* @return VBox status code.
*/
-DECLR0VBGL(int) VbglR0HGCMInternalDisconnect (VBoxGuestHGCMDisconnectInfo *pDisconnectInfo,
- PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
+DECLR0VBGL(int) VbglR0HGCMInternalDisconnect(VBoxGuestHGCMDisconnectInfo *pDisconnectInfo,
+ PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
/** Call a HGCM service.
*
*
* @return VBox status code.
*/
-DECLR0VBGL(int) VbglR0HGCMInternalCall (VBoxGuestHGCMCallInfo *pCallInfo, uint32_t cbCallInfo, uint32_t fFlags,
- PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
+DECLR0VBGL(int) VbglR0HGCMInternalCall(VBoxGuestHGCMCallInfo *pCallInfo, uint32_t cbCallInfo, uint32_t fFlags,
+ PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
/** Call a HGCM service. (32 bits packet structure in a 64 bits guest)
*
*
* @return VBox status code.
*/
-DECLR0VBGL(int) VbglR0HGCMInternalCall32 (VBoxGuestHGCMCallInfo *pCallInfo, uint32_t cbCallInfo, uint32_t fFlags,
- PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
+DECLR0VBGL(int) VbglR0HGCMInternalCall32(VBoxGuestHGCMCallInfo *pCallInfo, uint32_t cbCallInfo, uint32_t fFlags,
+ PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
/** @name VbglR0HGCMInternalCall flags
* @{ */
*
* @return VBox status code.
*/
-DECLVBGL(int) VbglHGCMConnect (VBGLHGCMHANDLE *pHandle, VBoxGuestHGCMConnectInfo *pData);
+DECLVBGL(int) VbglHGCMConnect(VBGLHGCMHANDLE *pHandle, VBoxGuestHGCMConnectInfo *pData);
/**
* Connect to a service.
*
* @return VBox status code.
*/
-DECLVBGL(int) VbglHGCMDisconnect (VBGLHGCMHANDLE handle, VBoxGuestHGCMDisconnectInfo *pData);
+DECLVBGL(int) VbglHGCMDisconnect(VBGLHGCMHANDLE handle, VBoxGuestHGCMDisconnectInfo *pData);
/**
* Call to a service.
*
* @return VBox status code.
*/
-DECLVBGL(int) VbglHGCMCall (VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData);
+DECLVBGL(int) VbglHGCMCall(VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData);
/**
* Call to a service with user-mode data received by the calling driver from the User-Mode process.
*
* @return VBox status code.
*/
-DECLVBGL(int) VbglHGCMCallUserData (VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData);
+DECLVBGL(int) VbglHGCMCallUserData(VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData);
/**
* Call to a service with timeout.
*
* @return VBox status code.
*/
-DECLVBGL(int) VbglHGCMCallTimed (VBGLHGCMHANDLE handle,
- VBoxGuestHGCMCallInfoTimed *pData, uint32_t cbData);
+DECLVBGL(int) VbglHGCMCallTimed(VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfoTimed *pData, uint32_t cbData);
+/** @} */
+
+/** @name Undocumented helpers for talking to the Chromium OpenGL Host Service
+ * @{ */
+typedef VBGLHGCMHANDLE VBGLCRCTLHANDLE;
+DECLVBGL(int) VbglR0CrCtlCreate(VBGLCRCTLHANDLE *phCtl);
+DECLVBGL(int) VbglR0CrCtlDestroy(VBGLCRCTLHANDLE hCtl);
+DECLVBGL(int) VbglR0CrCtlConConnect(VBGLCRCTLHANDLE hCtl, HGCMCLIENTID *pidClient);
+DECLVBGL(int) VbglR0CrCtlConDisconnect(VBGLCRCTLHANDLE hCtl, HGCMCLIENTID idClient);
+DECLVBGL(int) VbglR0CrCtlConCall(VBGLCRCTLHANDLE hCtl, struct VBoxGuestHGCMCallInfo *pCallInfo, int cbCallInfo);
+DECLVBGL(int) VbglR0CrCtlConCallUserData(VBGLCRCTLHANDLE hCtl, struct VBoxGuestHGCMCallInfo *pCallInfo, int cbCallInfo);
/** @} */
# endif /* !VBGL_VBOXGUEST */
/**
* Initialize the heap.
*
- * @return VBox error code.
+ * @returns VBox status code.
*/
-DECLVBGL(int) VbglPhysHeapInit (void);
+DECLVBGL(int) VbglPhysHeapInit(void);
/**
* Shutdown the heap.
*/
-DECLVBGL(void) VbglPhysHeapTerminate (void);
-
+DECLVBGL(void) VbglPhysHeapTerminate(void);
/**
* Allocate a memory block.
*
- * @param cbSize Size of block to be allocated.
- * @return Virtual address of allocated memory block.
+ * @returns Virtual address of the allocated memory block.
+ * @param cbSize Size of block to be allocated.
*/
-DECLVBGL(void *) VbglPhysHeapAlloc (uint32_t cbSize);
+DECLVBGL(void *) VbglPhysHeapAlloc(uint32_t cbSize);
/**
- * Get physical address of memory block pointed by
- * the virtual address.
+ * Get physical address of memory block pointed by the virtual address.
*
* @note WARNING!
* The function does not acquire the Heap mutex!
- * When calling the function make sure that
- * the pointer is a valid one and is not being
- * deallocated.
- * This function can NOT be used for verifying
- * if the given pointer is a valid one allocated
- * from the heap.
- *
+ * When calling the function make sure that the pointer is a valid one and
+ * is not being deallocated. This function can NOT be used for verifying
+ * if the given pointer is a valid one allocated from the heap.
*
- * @param p Virtual address of memory block.
- * @return Physical address of the memory block.
+ * @param pv Virtual address of memory block.
+ * @returns Physical address of the memory block.
*/
-DECLVBGL(uint32_t) VbglPhysHeapGetPhysAddr (void *p);
+DECLVBGL(uint32_t) VbglPhysHeapGetPhysAddr(void *pv);
/**
* Free a memory block.
*
- * @param p Virtual address of memory block.
+ * @param pv Virtual address of memory block.
*/
-DECLVBGL(void) VbglPhysHeapFree (void *p);
+DECLVBGL(void) VbglPhysHeapFree(void *pv);
-DECLVBGL(int) VbglQueryVMMDevMemory (VMMDevMemory **ppVMMDevMemory);
-DECLR0VBGL(bool) VbglR0CanUsePhysPageList(void);
+DECLVBGL(int) VbglQueryVMMDevMemory(VMMDevMemory **ppVMMDevMemory);
+DECLR0VBGL(bool) VbglR0CanUsePhysPageList(void);
# ifndef VBOX_GUEST
/** @name Mouse
* @{ */
-DECLVBGL(int) VbglSetMouseNotifyCallback(PFNVBOXGUESTMOUSENOTIFY pfnNotify, void *pvUser);
-DECLVBGL(int) VbglGetMouseStatus(uint32_t *pfFeatures, uint32_t *px, uint32_t *py);
-DECLVBGL(int) VbglSetMouseStatus(uint32_t fFeatures);
+DECLVBGL(int) VbglSetMouseNotifyCallback(PFNVBOXGUESTMOUSENOTIFY pfnNotify, void *pvUser);
+DECLVBGL(int) VbglGetMouseStatus(uint32_t *pfFeatures, uint32_t *px, uint32_t *py);
+DECLVBGL(int) VbglSetMouseStatus(uint32_t fFeatures);
/** @} */
# endif /* VBOX_GUEST */
#endif /* IN_RING0 && !IN_RING0_AGNOSTIC */
+
/** @} */
-/** @defgroup grp_guest_lib_r3 Ring-3 interface.
+/** @defgroup grp_vboxguest_lib_r3 Ring-3 interface.
* @{
*/
#ifdef IN_RING3
VBGLR3DECL(int) VbglR3SetGuestCaps(uint32_t fOr, uint32_t fNot);
VBGLR3DECL(int) VbglR3WaitEvent(uint32_t fMask, uint32_t cMillies, uint32_t *pfEvents);
-VBGLR3DECL(int) VbglR3ReportAdditionsStatus(VBoxGuestFacilityType Facility, VBoxGuestFacilityStatus StatusCurrent, uint32_t uFlags);
+VBGLR3DECL(int) VbglR3ReportAdditionsStatus(VBoxGuestFacilityType Facility, VBoxGuestFacilityStatus StatusCurrent,
+ uint32_t fFlags);
VBGLR3DECL(int) VbglR3GetAdditionsVersion(char **ppszVer, char **ppszVerEx, char **ppszRev);
VBGLR3DECL(int) VbglR3GetAdditionsInstallationPath(char **ppszPath);
VBGLR3DECL(int) VbglR3GetSessionId(uint64_t *pu64IdSession);
/** @name Shared clipboard
* @{ */
-VBGLR3DECL(int) VbglR3ClipboardConnect(uint32_t *pu32ClientId);
-VBGLR3DECL(int) VbglR3ClipboardDisconnect(uint32_t u32ClientId);
-VBGLR3DECL(int) VbglR3ClipboardGetHostMsg(uint32_t u32ClientId, uint32_t *pMsg, uint32_t *pfFormats);
-VBGLR3DECL(int) VbglR3ClipboardReadData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcb);
-VBGLR3DECL(int) VbglR3ClipboardReportFormats(uint32_t u32ClientId, uint32_t fFormats);
-VBGLR3DECL(int) VbglR3ClipboardWriteData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb);
+VBGLR3DECL(int) VbglR3ClipboardConnect(HGCMCLIENTID *pidClient);
+VBGLR3DECL(int) VbglR3ClipboardDisconnect(HGCMCLIENTID idClient);
+VBGLR3DECL(int) VbglR3ClipboardGetHostMsg(HGCMCLIENTID idClient, uint32_t *pMsg, uint32_t *pfFormats);
+VBGLR3DECL(int) VbglR3ClipboardReadData(HGCMCLIENTID idClient, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcb);
+VBGLR3DECL(int) VbglR3ClipboardReportFormats(HGCMCLIENTID idClient, uint32_t fFormats);
+VBGLR3DECL(int) VbglR3ClipboardWriteData(HGCMCLIENTID idClient, uint32_t fFormat, void *pv, uint32_t cb);
/** @} */
/** @name Seamless mode
* @{ */
VBGLR3DECL(int) VbglR3VideoAccelEnable(bool fEnable);
VBGLR3DECL(int) VbglR3VideoAccelFlush(void);
-VBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbImg);
+VBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy,
+ const void *pvImg, size_t cbImg);
VBGLR3DECL(int) VbglR3SetPointerShapeReq(struct VMMDevReqMousePointer *pReq);
/** @} */
/** @name Display
* @{ */
/** The folder for the video mode hint unix domain socket on Unix-like guests.
- */
-/** @note This can be safely changed as all users are rebuilt in lock-step. */
-#define VBGLR3HOSTDISPSOCKETPATH "/tmp/.VBoxService"
+ * @note This can be safely changed as all users are rebuilt in lock-step. */
+#define VBGLR3HOSTDISPSOCKETPATH "/tmp/.VBoxService"
/** The path to the video mode hint unix domain socket on Unix-like guests. */
-#define VBGLR3HOSTDISPSOCKET VBGLR3VIDEOMODEHINTSOCKETPATH \
- "/VideoModeHint"
+#define VBGLR3HOSTDISPSOCKET VBGLR3VIDEOMODEHINTSOCKETPATH "/VideoModeHint"
/** The folder for saving video mode hints to between sessions. */
#define VBGLR3HOSTDISPSAVEDMODEPATH "/var/lib/VBoxGuestAdditions"
/** The path to the file for saving video mode hints to between sessions. */
-#define VBGLR3HOSTDISPSAVEDMODE VBGLR3HOSTDISPSAVEDMODEPATH \
- "/SavedVideoModes"
-
-VBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy,
- uint32_t *pcBits,
- uint32_t *piDisplay,
- uint32_t *pdx, uint32_t *pdy,
- bool *pfEnabled,
- bool *pfChangeOrigin,
- bool fAck);
+#define VBGLR3HOSTDISPSAVEDMODE VBGLR3HOSTDISPSAVEDMODEPATH "/SavedVideoModes"
+
+VBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay,
+ uint32_t *pdx, uint32_t *pdy, bool *pfEnabled, bool *pfChangeOrigin, bool fAck);
VBGLR3DECL(bool) VbglR3HostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits);
VBGLR3DECL(int) VbglR3VideoModeGetHighestSavedScreen(unsigned *pcScreen);
-VBGLR3DECL(int) VbglR3SaveVideoMode(unsigned cScreen, unsigned cx,
- unsigned cy, unsigned cBits, unsigned x,
- unsigned y, bool fEnabled);
-VBGLR3DECL(int) VbglR3RetrieveVideoMode(unsigned cScreen, unsigned *pcx,
- unsigned *pcy, unsigned *pcBits,
- unsigned *px, unsigned *py,
- bool *pfEnabled);
+VBGLR3DECL(int) VbglR3SaveVideoMode(unsigned cScreen, unsigned cx, unsigned cy, unsigned cBits,
+ unsigned x, unsigned y, bool fEnabled);
+VBGLR3DECL(int) VbglR3RetrieveVideoMode(unsigned cScreen, unsigned *pcx, unsigned *pcy, unsigned *pcBits,
+ unsigned *px, unsigned *py, bool *pfEnabled);
/** @} */
/** @name VM Statistics
typedef struct VBGLR3GUESTPROPENUM VBGLR3GUESTPROPENUM;
/** @todo Docs. */
typedef VBGLR3GUESTPROPENUM *PVBGLR3GUESTPROPENUM;
-VBGLR3DECL(int) VbglR3GuestPropConnect(uint32_t *pu32ClientId);
-VBGLR3DECL(int) VbglR3GuestPropDisconnect(uint32_t u32ClientId);
-VBGLR3DECL(int) VbglR3GuestPropWrite(uint32_t u32ClientId, const char *pszName, const char *pszValue, const char *pszFlags);
-VBGLR3DECL(int) VbglR3GuestPropWriteValue(uint32_t u32ClientId, const char *pszName, const char *pszValue);
-VBGLR3DECL(int) VbglR3GuestPropWriteValueV(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, va_list va);
-VBGLR3DECL(int) VbglR3GuestPropWriteValueF(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, ...);
-VBGLR3DECL(int) VbglR3GuestPropRead(uint32_t u32ClientId, const char *pszName, void *pvBuf, uint32_t cbBuf, char **ppszValue, uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual);
-VBGLR3DECL(int) VbglR3GuestPropReadValue(uint32_t ClientId, const char *pszName, char *pszValue, uint32_t cchValue, uint32_t *pcchValueActual);
-VBGLR3DECL(int) VbglR3GuestPropReadValueAlloc(uint32_t u32ClientId, const char *pszName, char **ppszValue);
+VBGLR3DECL(int) VbglR3GuestPropConnect(uint32_t *pidClient);
+VBGLR3DECL(int) VbglR3GuestPropDisconnect(HGCMCLIENTID idClient);
+VBGLR3DECL(int) VbglR3GuestPropWrite(HGCMCLIENTID idClient, const char *pszName, const char *pszValue, const char *pszFlags);
+VBGLR3DECL(int) VbglR3GuestPropWriteValue(HGCMCLIENTID idClient, const char *pszName, const char *pszValue);
+VBGLR3DECL(int) VbglR3GuestPropWriteValueV(HGCMCLIENTID idClient, const char *pszName,
+ const char *pszValueFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);
+VBGLR3DECL(int) VbglR3GuestPropWriteValueF(HGCMCLIENTID idClient, const char *pszName,
+ const char *pszValueFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
+VBGLR3DECL(int) VbglR3GuestPropRead(HGCMCLIENTID idClient, const char *pszName, void *pvBuf, uint32_t cbBuf, char **ppszValue,
+ uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual);
+VBGLR3DECL(int) VbglR3GuestPropReadValue(uint32_t ClientId, const char *pszName, char *pszValue, uint32_t cchValue,
+ uint32_t *pcchValueActual);
+VBGLR3DECL(int) VbglR3GuestPropReadValueAlloc(HGCMCLIENTID idClient, const char *pszName, char **ppszValue);
VBGLR3DECL(void) VbglR3GuestPropReadValueFree(char *pszValue);
-VBGLR3DECL(int) VbglR3GuestPropEnumRaw(uint32_t u32ClientId, const char *paszPatterns, char *pcBuf, uint32_t cbBuf, uint32_t *pcbBufActual);
-VBGLR3DECL(int) VbglR3GuestPropEnum(uint32_t u32ClientId, char const * const *ppaszPatterns, uint32_t cPatterns, PVBGLR3GUESTPROPENUM *ppHandle,
- char const **ppszName, char const **ppszValue, uint64_t *pu64Timestamp, char const **ppszFlags);
-VBGLR3DECL(int) VbglR3GuestPropEnumNext(PVBGLR3GUESTPROPENUM pHandle, char const **ppszName, char const **ppszValue, uint64_t *pu64Timestamp,
- char const **ppszFlags);
+VBGLR3DECL(int) VbglR3GuestPropEnumRaw(HGCMCLIENTID idClient, const char *paszPatterns, char *pcBuf, uint32_t cbBuf,
+ uint32_t *pcbBufActual);
+VBGLR3DECL(int) VbglR3GuestPropEnum(HGCMCLIENTID idClient, char const * const *ppaszPatterns, uint32_t cPatterns,
+ PVBGLR3GUESTPROPENUM *ppHandle, char const **ppszName, char const **ppszValue,
+ uint64_t *pu64Timestamp, char const **ppszFlags);
+VBGLR3DECL(int) VbglR3GuestPropEnumNext(PVBGLR3GUESTPROPENUM pHandle, char const **ppszName, char const **ppszValue,
+ uint64_t *pu64Timestamp, char const **ppszFlags);
VBGLR3DECL(void) VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle);
-VBGLR3DECL(int) VbglR3GuestPropDelete(uint32_t u32ClientId, const char *pszName);
-VBGLR3DECL(int) VbglR3GuestPropDelSet(uint32_t u32ClientId, char const * const *papszPatterns, uint32_t cPatterns);
-VBGLR3DECL(int) VbglR3GuestPropWait(uint32_t u32ClientId, const char *pszPatterns, void *pvBuf, uint32_t cbBuf, uint64_t u64Timestamp, uint32_t cMillies, char ** ppszName, char **ppszValue, uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual);
+VBGLR3DECL(int) VbglR3GuestPropDelete(HGCMCLIENTID idClient, const char *pszName);
+VBGLR3DECL(int) VbglR3GuestPropDelSet(HGCMCLIENTID idClient, char const * const *papszPatterns, uint32_t cPatterns);
+VBGLR3DECL(int) VbglR3GuestPropWait(HGCMCLIENTID idClient, const char *pszPatterns, void *pvBuf, uint32_t cbBuf,
+ uint64_t u64Timestamp, uint32_t cMillies, char ** ppszName, char **ppszValue,
+ uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual);
/** @} */
/** @name Guest user handling / reporting.
* @{ */
-VBGLR3DECL(int) VbglR3GuestUserReportState(const char *pszUser, const char *pszDomain, VBoxGuestUserState enmState, uint8_t *puDetails, uint32_t cbDetails);
+VBGLR3DECL(int) VbglR3GuestUserReportState(const char *pszUser, const char *pszDomain, VBoxGuestUserState enmState,
+ uint8_t *pbDetails, uint32_t cbDetails);
/** @} */
/** @name Host version handling
* @{ */
-VBGLR3DECL(int) VbglR3HostVersionCheckForUpdate(uint32_t u32ClientId, bool *pfUpdate, char **ppszHostVersion, char **ppszGuestVersion);
-VBGLR3DECL(int) VbglR3HostVersionLastCheckedLoad(uint32_t u32ClientId, char **ppszVer);
-VBGLR3DECL(int) VbglR3HostVersionLastCheckedStore(uint32_t u32ClientId, const char *pszVer);
+VBGLR3DECL(int) VbglR3HostVersionCheckForUpdate(HGCMCLIENTID idClient, bool *pfUpdate, char **ppszHostVersion,
+ char **ppszGuestVersion);
+VBGLR3DECL(int) VbglR3HostVersionLastCheckedLoad(HGCMCLIENTID idClient, char **ppszVer);
+VBGLR3DECL(int) VbglR3HostVersionLastCheckedStore(HGCMCLIENTID idClient, const char *pszVer);
/** @} */
# endif /* VBOX_WITH_GUEST_PROPS defined */
/** Root handle. */
uint32_t u32Root;
} VBGLR3SHAREDFOLDERMAPPING;
-/** Pointer to a shared folder mapping information struct. */
+/** Pointer to a shared folder mapping information structure. */
typedef VBGLR3SHAREDFOLDERMAPPING *PVBGLR3SHAREDFOLDERMAPPING;
+/** Pointer to a const shared folder mapping information structure. */
+typedef VBGLR3SHAREDFOLDERMAPPING const *PCVBGLR3SHAREDFOLDERMAPPING;
-VBGLR3DECL(int) VbglR3SharedFolderConnect(uint32_t *pu32ClientId);
-VBGLR3DECL(int) VbglR3SharedFolderDisconnect(uint32_t u32ClientId);
-VBGLR3DECL(bool) VbglR3SharedFolderExists(uint32_t u32ClientId, const char *pszShareName);
-VBGLR3DECL(int) VbglR3SharedFolderGetMappings(uint32_t u32ClientId, bool fAutoMountOnly,
+VBGLR3DECL(int) VbglR3SharedFolderConnect(uint32_t *pidClient);
+VBGLR3DECL(int) VbglR3SharedFolderDisconnect(HGCMCLIENTID idClient);
+VBGLR3DECL(bool) VbglR3SharedFolderExists(HGCMCLIENTID idClient, const char *pszShareName);
+VBGLR3DECL(int) VbglR3SharedFolderGetMappings(HGCMCLIENTID idClient, bool fAutoMountOnly,
PVBGLR3SHAREDFOLDERMAPPING *ppaMappings, uint32_t *pcMappings);
VBGLR3DECL(void) VbglR3SharedFolderFreeMappings(PVBGLR3SHAREDFOLDERMAPPING paMappings);
-VBGLR3DECL(int) VbglR3SharedFolderGetName(uint32_t u32ClientId,uint32_t u32Root, char **ppszName);
+VBGLR3DECL(int) VbglR3SharedFolderGetName(HGCMCLIENTID idClient,uint32_t u32Root, char **ppszName);
VBGLR3DECL(int) VbglR3SharedFolderGetMountPrefix(char **ppszPrefix);
VBGLR3DECL(int) VbglR3SharedFolderGetMountDir(char **ppszDir);
/** @} */
} VBGLR3GUESTCTRLCMDCTX, *PVBGLR3GUESTCTRLCMDCTX;
/* General message handling on the guest. */
-VBGLR3DECL(int) VbglR3GuestCtrlConnect(uint32_t *puClientId);
+VBGLR3DECL(int) VbglR3GuestCtrlConnect(uint32_t *pidClient);
VBGLR3DECL(int) VbglR3GuestCtrlDisconnect(uint32_t uClientId);
VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId, uint32_t uValue, uint32_t uMaskAdd, uint32_t uMaskRemove);
VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterUnset(uint32_t uClientId);
VBGLR3DECL(int) VbglR3GuestCtrlMsgReply(PVBGLR3GUESTCTRLCMDCTX pCtx, int rc);
-VBGLR3DECL(int) VbglR3GuestCtrlMsgReplyEx(PVBGLR3GUESTCTRLCMDCTX pCtx, int rc, uint32_t uType, void *pvPayload, uint32_t cbPayload);
+VBGLR3DECL(int) VbglR3GuestCtrlMsgReplyEx(PVBGLR3GUESTCTRLCMDCTX pCtx, int rc, uint32_t uType,
+ void *pvPayload, uint32_t cbPayload);
VBGLR3DECL(int) VbglR3GuestCtrlMsgSkip(uint32_t uClientId);
VBGLR3DECL(int) VbglR3GuestCtrlMsgWaitFor(uint32_t uClientId, uint32_t *puMsg, uint32_t *puNumParms);
-VBGLR3DECL(int) VbglR3GuestCtrlCancelPendingWaits(uint32_t u32ClientId);
+VBGLR3DECL(int) VbglR3GuestCtrlCancelPendingWaits(HGCMCLIENTID idClient);
/* Guest session handling. */
-VBGLR3DECL(int) VbglR3GuestCtrlSessionClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uFlags);
+VBGLR3DECL(int) VbglR3GuestCtrlSessionClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t fFlags);
VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uType, uint32_t uResult);
-VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puProtocol, char *pszUser, uint32_t cbUser, char *pszPassword, uint32_t cbPassword, char *pszDomain, uint32_t cbDomain, uint32_t *puFlags, uint32_t *puSessionID);
-VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puFlags, uint32_t *puSessionID);
+VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puProtocol, char *pszUser, uint32_t cbUser,
+ char *pszPassword, uint32_t cbPassword, char *pszDomain, uint32_t cbDomain,
+ uint32_t *pfFlags, uint32_t *pidSession);
+VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *pfFlags, uint32_t *pidSession);
/* Guest path handling. */
-VBGLR3DECL(int) VbglR3GuestCtrlPathGetRename(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszSource, uint32_t cbSource, char *pszDest, uint32_t cbDest, uint32_t *puFlags);
+VBGLR3DECL(int) VbglR3GuestCtrlPathGetRename(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszSource, uint32_t cbSource, char *pszDest,
+ uint32_t cbDest, uint32_t *pfFlags);
/* Guest process execution. */
-VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszCmd, uint32_t cbCmd, uint32_t *puFlags, char *pszArgs, uint32_t cbArgs, uint32_t *puNumArgs, char *pszEnv, uint32_t *pcbEnv, uint32_t *puNumEnvVars, char *pszUser, uint32_t cbUser, char *pszPassword, uint32_t cbPassword, uint32_t *puTimeoutMS, uint32_t *puPriority, uint64_t *puAffinity, uint32_t cbAffinity, uint32_t *pcAffinity);
+VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszCmd, uint32_t cbCmd, uint32_t *pfFlags,
+ char *pszArgs, uint32_t cbArgs, uint32_t *puNumArgs, char *pszEnv, uint32_t *pcbEnv,
+ uint32_t *puNumEnvVars, char *pszUser, uint32_t cbUser, char *pszPassword,
+ uint32_t cbPassword, uint32_t *puTimeoutMS, uint32_t *puPriority,
+ uint64_t *puAffinity, uint32_t cbAffinity, uint32_t *pcAffinity);
VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID);
-VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID, uint32_t *puFlags, void *pvData, uint32_t cbData, uint32_t *pcbSize);
-VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID, uint32_t *puHandle, uint32_t *puFlags);
-VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS);
+VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID, uint32_t *pfFlags, void *pvData,
+ uint32_t cbData, uint32_t *pcbSize);
+VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID, uint32_t *puHandle, uint32_t *pfFlags);
+VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID, uint32_t *puWaitFlags,
+ uint32_t *puTimeoutMS);
/* Guest native directory handling. */
-VBGLR3DECL(int) VbglR3GuestCtrlDirGetRemove(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszPath, uint32_t cbPath, uint32_t *puFlags);
+VBGLR3DECL(int) VbglR3GuestCtrlDirGetRemove(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszPath, uint32_t cbPath, uint32_t *pfFlags);
/* Guest native file handling. */
-VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszFileName, uint32_t cbFileName, char *pszOpenMode, uint32_t cbOpenMode, char *pszDisposition, uint32_t cbDisposition, char *pszSharing, uint32_t cbSharing, uint32_t *puCreationMode, uint64_t *puOffset);
+VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszFileName, uint32_t cbFileName, char *pszOpenMode,
+ uint32_t cbOpenMode, char *pszDisposition, uint32_t cbDisposition, char *pszSharing,
+ uint32_t cbSharing, uint32_t *puCreationMode, uint64_t *puOffset);
VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle);
VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, uint32_t *puToRead);
-VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, uint32_t *puToRead, uint64_t *puOffset);
-VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, void *pvData, uint32_t cbData, uint32_t *pcbSize);
-VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, void *pvData, uint32_t cbData, uint32_t *pcbSize, uint64_t *puOffset);
-VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, uint32_t *puSeekMethod, uint64_t *puOffset);
+VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
+ uint32_t *puToRead, uint64_t *poffRead);
+VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
+ void *pvData, uint32_t cbData, uint32_t *pcbActual);
+VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, void *pvData, uint32_t cbData,
+ uint32_t *pcbActual, uint64_t *poffWrite);
+VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
+ uint32_t *puSeekMethod, uint64_t *poffSeek);
VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle);
/* Guest -> Host. */
VBGLR3DECL(int) VbglR3GuestCtrlFileCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint32_t uFileHandle);
VBGLR3DECL(int) VbglR3GuestCtrlFileCbWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint32_t uWritten);
VBGLR3DECL(int) VbglR3GuestCtrlFileCbSeek(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint64_t uOffActual);
VBGLR3DECL(int) VbglR3GuestCtrlFileCbTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint64_t uOffActual);
-VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uPID, uint32_t uStatus, uint32_t uFlags, void *pvData, uint32_t cbData);
-VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uPID, uint32_t uHandle, uint32_t uFlags, void *pvData, uint32_t cbData);
-VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t u32PID, uint32_t uStatus, uint32_t uFlags, uint32_t cbWritten);
+VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uPID, uint32_t uStatus, uint32_t fFlags,
+ void *pvData, uint32_t cbData);
+VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uPID, uint32_t uHandle, uint32_t fFlags,
+ void *pvData, uint32_t cbData);
+VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t u32PID, uint32_t uStatus,
+ uint32_t fFlags, uint32_t cbWritten);
/** @} */
# endif /* VBOX_WITH_GUEST_CONTROL defined */
/** @name Page sharing
* @{ */
-VBGLR3DECL(int) VbglR3RegisterSharedModule(char *pszModuleName, char *pszVersion, RTGCPTR64 GCBaseAddr, uint32_t cbModule, unsigned cRegions, VMMDEVSHAREDREGIONDESC *pRegions);
+VBGLR3DECL(int) VbglR3RegisterSharedModule(char *pszModuleName, char *pszVersion, RTGCPTR64 GCBaseAddr, uint32_t cbModule,
+ unsigned cRegions, VMMDEVSHAREDREGIONDESC *pRegions);
VBGLR3DECL(int) VbglR3UnregisterSharedModule(char *pszModuleName, char *pszVersion, RTGCPTR64 GCBaseAddr, uint32_t cbModule);
VBGLR3DECL(int) VbglR3CheckSharedModules(void);
VBGLR3DECL(bool) VbglR3PageSharingIsEnabled(void);
VBGLR3DECL(int) VbglR3DnDProcessNextMessage(PVBGLR3GUESTDNDCMDCTX pCtx, CPVBGLR3DNDHGCMEVENT pEvent);
VBGLR3DECL(int) VbglR3DnDHGAcknowledgeOperation(PVBGLR3GUESTDNDCMDCTX pCtx, uint32_t uAction);
-VBGLR3DECL(int) VbglR3DnDHGRequestData(PVBGLR3GUESTDNDCMDCTX pCtx, const char* pcszFormat);
+VBGLR3DECL(int) VbglR3DnDHGRequestData(PVBGLR3GUESTDNDCMDCTX pCtx, const char *pszFormat);
VBGLR3DECL(int) VbglR3DnDHGSetProgress(PVBGLR3GUESTDNDCMDCTX pCtx, uint32_t uStatus, uint8_t uPercent, int rcErr);
# ifdef VBOX_WITH_DRAG_AND_DROP_GH
-VBGLR3DECL(int) VbglR3DnDGHAcknowledgePending(PVBGLR3GUESTDNDCMDCTX pCtx, uint32_t uDefAction, uint32_t uAllActions, const char* pcszFormats);
+VBGLR3DECL(int) VbglR3DnDGHAcknowledgePending(PVBGLR3GUESTDNDCMDCTX pCtx, uint32_t uDefAction,
+ uint32_t uAllActions, const char *pszFormats);
VBGLR3DECL(int) VbglR3DnDGHSendData(PVBGLR3GUESTDNDCMDCTX pCtx, const char *pszFormat, void *pvData, uint32_t cbData);
VBGLR3DECL(int) VbglR3DnDGHSendError(PVBGLR3GUESTDNDCMDCTX pCtx, int rcOp);
# endif /* VBOX_WITH_DRAG_AND_DROP_GH */
--- /dev/null
+/* $Id: VBoxGuestLibSharedFolders.h $ */
+/** @file
+ * VBoxGuestLib - Central calls header.
+ */
+
+/*
+ * Copyright (C) 2006-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef ___VBox_VBoxGuestLibSharedFolders_h_
+#define ___VBox_VBoxGuestLibSharedFolders_h_
+
+#include <VBox/VBoxGuestLib.h>
+#include <VBox/shflsvc.h>
+
+RT_C_DECLS_BEGIN
+
+
+/** @addtogroup grp_vboxguest_lib_r0
+ * @{
+ */
+
+typedef struct VBGLSFCLIENT
+{
+ HGCMCLIENTID idClient;
+ VBGLHGCMHANDLE handle;
+} VBGLSFCLIENT;
+typedef VBGLSFCLIENT *PVBGLSFCLIENT;
+
+typedef struct VBGLSFMAP
+{
+ SHFLROOT root;
+} VBGLSFMAP, *PVBGLSFMAP;
+
+DECLVBGL(int) VbglR0SfInit(void);
+DECLVBGL(void) VbglR0SfTerm(void);
+DECLVBGL(int) VbglR0SfConnect(PVBGLSFCLIENT pClient);
+DECLVBGL(void) VbglR0SfDisconnect(PVBGLSFCLIENT pClient);
+
+DECLVBGL(int) VbglR0SfQueryMappings(PVBGLSFCLIENT pClient, SHFLMAPPING paMappings[], uint32_t *pcMappings);
+
+DECLVBGL(int) VbglR0SfQueryMapName(PVBGLSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size);
+
+/**
+ * Create a new file or folder or open an existing one in a shared folder. Proxies
+ * to vbsfCreate in the host shared folder service.
+ *
+ * @returns IPRT status code, but see note below
+ * @param pClient Host-guest communication connection
+ * @param pMap The mapping for the shared folder in which the file
+ * or folder is to be created
+ * @param pParsedPath The path of the file or folder relative to the shared
+ * folder
+ * @param pCreateParms Parameters for file/folder creation. See the
+ * structure description in shflsvc.h
+ * @retval pCreateParms See the structure description in shflsvc.h
+ *
+ * @note This function reports errors as follows. The return value is always
+ * VINF_SUCCESS unless an exceptional condition occurs - out of
+ * memory, invalid arguments, etc. If the file or folder could not be
+ * opened or created, pCreateParms->Handle will be set to
+ * SHFL_HANDLE_NIL on return. In this case the value in
+ * pCreateParms->Result provides information as to why (e.g.
+ * SHFL_FILE_EXISTS). pCreateParms->Result is also set on success
+ * as additional information.
+ */
+DECLVBGL(int) VbglR0SfCreate(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms);
+
+DECLVBGL(int) VbglR0SfClose(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE Handle);
+DECLVBGL(int) VbglR0SfRemove(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pParsedPath, uint32_t flags);
+DECLVBGL(int) VbglR0SfRename(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags);
+DECLVBGL(int) VbglR0SfFlush(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile);
+
+DECLVBGL(int) VbglR0SfRead(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked);
+DECLVBGL(int) VbglR0SfReadPageList(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer,
+ uint16_t offFirstPage, uint16_t cPages, RTGCPHYS64 *paPages);
+DECLVBGL(int) VbglR0SfWrite(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset,
+ uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked);
+DECLVBGL(int) VbglR0SfWritePhysCont(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset,
+ uint32_t *pcbBuffer, RTCCPHYS PhysBuffer);
+DECLVBGL(int) VbglR0SfWritePageList(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer,
+ uint16_t offFirstPage, uint16_t cPages, RTGCPHYS64 *paPages);
+
+DECLVBGL(int) VbglR0SfLock(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint64_t cbSize, uint32_t fLock);
+
+DECLVBGL(int) VbglR0SfDirInfo(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile,PSHFLSTRING ParsedPath, uint32_t flags,
+ uint32_t index, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer, uint32_t *pcFiles);
+DECLVBGL(int) VbglR0SfFsInfo(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer);
+
+DECLVBGL(int) VbglR0SfMapFolder(PVBGLSFCLIENT pClient, PSHFLSTRING szFolderName, PVBGLSFMAP pMap);
+DECLVBGL(int) VbglR0SfUnmapFolder(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap);
+DECLVBGL(int) VbglR0SfSetUtf8(PVBGLSFCLIENT pClient);
+
+DECLVBGL(int) VbglR0SfReadLink(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING ParsedPath, uint32_t pcbBuffer, uint8_t *pBuffer);
+DECLVBGL(int) VbglR0SfSymlink(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pNewPath, PSHFLSTRING pOldPath, PSHFLFSOBJINFO pBuffer);
+DECLVBGL(int) VbglR0SfSetSymlinks(PVBGLSFCLIENT pClient);
+
+/** @} */
+
+RT_C_DECLS_END
+
+#endif
+
/** @defgroup grp_vmmdev VMM Device
*
- * Note! This interface cannot be changed, it can only be extended!
+ * @note This interface cannot be changed, it can only be extended!
*
* @{
*/
/**
* The current guest status of a facility.
* This needs to be kept in sync with AdditionsFacilityStatus of the Main API!
+ *
+ * @remarks r=bird: Pretty please, for future types like this, simply do a
+ * linear allocation without any gaps. This stuff is impossible work
+ * efficiently with, let alone validate. Applies to the other facility
+ * enums too.
*/
typedef enum
{
#include <iprt/assert.h>
+
+/** @addtogroup grp_vmmdev
+ * @{
+ */
+
+
/**
* Seamless mode.
*
struct VMMDevReqMousePointer;
struct VMMDevMemory;
+/** @} */
+
#endif
#include <iprt/cdefs.h>
+/** @defgroup VBox Common Defintions and Macros
+ * @{
+ */
+
/** @def VBOX_WITH_STATISTICS
* When defined all statistics will be included in the build.
* This is enabled by default in all debug builds.
# define VBOXDDU_DECL(type) DECLIMPORT(type) VBOXCALL
#endif
+/** @} */
+
+
+/** @defgroup grp_devdrv Device Emulations and Drivers
+ * @{ */
+/** @} */
#endif
#include <iprt/err.h>
-/** @defgroup grp_err Error Codes
+/** @defgroup grp_err VBox Error Codes
* @{
*/
#define VERR_EM_CANNOT_EXEC_GUEST (-1156)
/** Reason for leaving RC: Inject a TRPM event. */
#define VINF_EM_RAW_INJECT_TRPM_EVENT 1157
+/** Guest tried to trigger a CPU hang. The guest is probably up to no good. */
+#define VERR_EM_GUEST_CPU_HANG (-1158)
/** @} */
#define VINF_PGM_PHYS_TLB_CATCH_WRITE 1635
/** Catch write access and route it thru PGM. */
#define VERR_PGM_PHYS_TLB_CATCH_WRITE (-1635)
-/** No CR3 root shadow page table.. */
+/** No CR3 root shadow page table. */
#define VERR_PGM_NO_CR3_SHADOW_ROOT (-1636)
/** Trying to free a page with an invalid Page ID. */
#define VERR_PGM_PHYS_INVALID_PAGE_ID (-1637)
#define VERR_VMM_RING3_CALL_DISABLED (-2703)
/** The VMMR0.r0 module version does not match VBoxVMM.dll/so/dylib.
* If you just upgraded VirtualBox, please terminate all VMs and make sure
- * VBoxNetDHCP is not running. Then try again. If this error persists, try
- * re-installing VirtualBox. */
+ * that neither VBoxNetDHCP nor VBoxNetNAT is running. Then try again.
+ * If this error persists, try re-installing VirtualBox. */
#define VERR_VMM_R0_VERSION_MISMATCH (-2704)
/** The VMMRC.rc module version does not match VBoxVMM.dll/so/dylib.
* Re-install if you are a user. Developers should make sure the build is
#define VERR_VMM_SWITCHER_STUB (-2715)
/** HM returned in the wrong state. */
#define VERR_VMM_WRONG_HM_VMCPU_STATE (-2716)
+/** SMAP enabled, but the AC flag was found to be clear - check the kernel
+ * log for details. */
+#define VERR_VMM_SMAP_BUT_AC_CLEAR (-2717)
/** @} */
#define VERR_VD_DMG_XML_PARSE_ERROR (-3284)
/** Unable to locate a usable DMG file within the XAR archive. */
#define VERR_VD_DMG_NOT_FOUND_INSIDE_XAR (-3285)
+/** The size of the raw image is not dividable by 512 */
+#define VERR_VD_RAW_SIZE_MODULO_512 (-3286)
+/** The size of the raw image is not dividable by 2048 */
+#define VERR_VD_RAW_SIZE_MODULO_2048 (-3287)
+/** The size of the raw optical image is too small (<= 32K) */
+#define VERR_VD_RAW_SIZE_OPTICAL_TOO_SMALL (-3288)
+/** The size of the raw floppy image is too big (>2.88MB) */
+#define VERR_VD_RAW_SIZE_FLOPPY_TOO_BIG (-3289)
+
/** @} */
#define VWRN_SUPDRV_TSC_DELTA_MEASUREMENT_FAILED 3746
/** A TSC-delta measurement request is currently being serviced. */
#define VERR_SUPDRV_TSC_DELTA_MEASUREMENT_BUSY (-3747)
+/** The process trying to open VBoxDrv is not a budding VM process (1). */
+#define VERR_SUPDRV_NOT_BUDDING_VM_PROCESS_1 (-3748)
+/** The process trying to open VBoxDrv is not a budding VM process (2). */
+#define VERR_SUPDRV_NOT_BUDDING_VM_PROCESS_2 (-3749)
/** @} */
/** Internal VMX processing error no 5. */
#define VERR_VMX_IPE_5 (-4027)
/** VT-x features for all modes (SMX and non-SMX) disabled by the BIOS. */
-#define VERR_VMX_MSR_ALL_VMXON_DISABLED (-4028)
+#define VERR_VMX_MSR_ALL_VMX_DISABLED (-4028)
/** VT-x features disabled by the BIOS. */
-#define VERR_VMX_MSR_VMXON_DISABLED (-4029)
+#define VERR_VMX_MSR_VMX_DISABLED (-4029)
/** VM-Entry Controls internal cache invalid. */
#define VERR_VMX_ENTRY_CTLS_CACHE_INVALID (-4030)
/** VM-Exit Controls internal cache invalid. */
/** VM-Execution Secondary Processor-based Controls internal
* cache invalid. */
#define VERR_VMX_PROC_EXEC2_CTLS_CACHE_INVALID (-4034)
+/** Failed to set VMXON enable bit while enabling VT-x through the MSR. */
+#define VERR_VMX_MSR_VMX_ENABLE_FAILED (-4035)
+/** Failed to enable VMXON-in-SMX bit while enabling VT-x through the MSR. */
+#define VERR_VMX_MSR_SMX_VMX_ENABLE_FAILED (-4036)
/** @} */
#define VINF_DBGC_BP_NO_COMMAND 5406
/** Generic debugger command failure. */
#define VERR_DBGC_COMMAND_FAILED (-5407)
-/** Logic bug in the DBGC code.. */
+/** Logic bug in the DBGC code. */
#define VERR_DBGC_IPE (-5408)
/** The lowest parse status code. */
#define VERR_GIM_HYPERCALL_ACCESS_DENIED (-6311)
/** @} */
+
/** @name Main API Status Codes
* @{
*/
#define VERR_MAIN_CONFIG_CONSTRUCTOR_IPE (-6401)
/** @} */
+
/** @name VBox Drag and Drop Status Codes
* @{
*/
/** @} */
+/** @name Audio Status Codes
+ * @{
+ */
+/** Host backend couldn't be initialized. Happen if the audio server is not
+ * reachable, audio hardware is not available or similar. We should use the
+ * NULL audio driver. */
+#define VERR_AUDIO_BACKEND_INIT_FAILED (-6600)
+/** @} */
+
+
/* SED-END */
/** @} */
typedef struct VBOXHGCMCALLHANDLE_TYPEDEF *VBOXHGCMCALLHANDLE;
/** Service helpers pointers table. */
-typedef struct _VBOXHGCMSVCHELPERS
+typedef struct VBOXHGCMSVCHELPERS
{
/** The service has processed the Call request. */
DECLR3CALLBACKMEMBER(void, pfnCallComplete, (VBOXHGCMCALLHANDLE callHandle, int32_t rc));
*/
/* The structure is used in separately compiled binaries so an explicit packing is required. */
-#pragma pack(1)
-typedef struct _VBOXHGCMSVCFNTABLE
+#pragma pack(1) /** @todo r=bird: The pragma pack(1) is not at all required!! */
+typedef struct VBOXHGCMSVCFNTABLE
{
- /** Filled by HGCM */
+ /** @name Filled by HGCM
+ * @{ */
/** Size of the structure. */
uint32_t cbSize;
uint32_t u32Version;
PVBOXHGCMSVCHELPERS pHelpers;
+ /** @} */
- /** Filled by the service. */
+ /** @name Filled in by the service.
+ * @{ */
/** Size of client information the service want to have. */
uint32_t cbClient;
/** User/instance data pointer for the service. */
void *pvService;
+ /** @} */
} VBOXHGCMSVCFNTABLE;
#pragma pack()
#include <iprt/log.h>
-/** @defgroup grp_rt_vbox_log VirtualBox Logging
+/** @defgroup grp_rt_vbox_log VBox Logging
* @ingroup grp_rt_vbox
* @{
*/
/** USB webcam. */
LOG_GROUP_USB_WEBCAM,
/** VBox Guest Additions Driver (VBoxGuest). */
- LOG_GROUP_VBGD,
+ LOG_GROUP_VGDRV,
/** VBox Guest Additions Library. */
LOG_GROUP_VBGL,
/** Generic virtual disk layer. */
"USB_MSD", \
"USB_REMOTE", \
"USB_WEBCAM", \
- "VBGD", \
+ "VGDRV", \
"VBGL", \
"VD", \
"VD_DMG", \
/** Write access requested. */
#define SHFL_CF_ACCESS_ATTR_WRITE (0x00020000)
/** Read/Write access requested. */
-#define SHFL_CF_ACCESS_ATTR_READWRITE (SHFL_CF_ACCESS_READ | SHFL_CF_ACCESS_WRITE)
+#define SHFL_CF_ACCESS_ATTR_READWRITE (SHFL_CF_ACCESS_ATTR_READ | SHFL_CF_ACCESS_ATTR_WRITE)
/** The file is opened in append mode. Ignored if SHFL_CF_ACCESS_WRITE is not set. */
#define SHFL_CF_ACCESS_APPEND (0x00040000)
#include <iprt/types.h>
-/** @defgroup grp_types Basic VBox Types
+/** @defgroup grp_types VBox Basic Types
* @{
*/
/**
* Sets the content of the GDTR CPU register.
- * @param pIdtr Where to load the GDTR contents from
+ * @param pGdtr Where to load the GDTR contents from
*/
#if RT_INLINE_ASM_EXTERNAL
DECLASM(void) ASMSetGDTR(const RTGDTR *pGdtr);
#endif
+/**
+ * Modifies the [RE]FLAGS register.
+ * @returns Original value.
+ * @param fAndEfl Flags to keep (applied first).
+ * @param fOrEfl Flags to be set.
+ */
+#if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < 15
+DECLASM(RTCCUINTREG) ASMChangeFlags(RTCCUINTREG fAndEfl, RTCCUINTREG fOrEfl);
+#else
+DECLINLINE(RTCCUINTREG) ASMChangeFlags(RTCCUINTREG fAndEfl, RTCCUINTREG fOrEfl)
+{
+ RTCCUINTREG fOldEfl;
+# if RT_INLINE_ASM_GNU_STYLE
+# ifdef RT_ARCH_AMD64
+ __asm__ __volatile__("pushfq\n\t"
+ "movq (%%rsp), %0\n\t"
+ "andq %0, %1\n\t"
+ "orq %3, %1\n\t"
+ "mov %1, (%%rsp)\n\t"
+ "popfq\n\t"
+ : "=&r" (fOldEfl),
+ "=r" (fAndEfl)
+ : "1" (fAndEfl),
+ "rn" (fOrEfl) );
+# else
+ __asm__ __volatile__("pushfl\n\t"
+ "movl (%%esp), %0\n\t"
+ "andl %1, (%%esp)\n\t"
+ "orl %2, (%%esp)\n\t"
+ "popfl\n\t"
+ : "=&r" (fOldEfl)
+ : "rn" (fAndEfl),
+ "rn" (fOrEfl) );
+# endif
+# elif RT_INLINE_ASM_USES_INTRIN >= 15
+ fOldEfl = __readeflags();
+ __writeeflags((fOldEfl & fAndEfl) | fOrEfl);
+# else
+ __asm
+ {
+# ifdef RT_ARCH_AMD64
+ mov rdx, [fAndEfl]
+ mov rcx, [fOrEfl]
+ pushfq
+ mov rax, [rsp]
+ and rdx, rax
+ or rdx, rcx
+ mov [rsp], rdx
+ popfq
+ mov [fOldEfl], rax
+# else
+ mov edx, [fAndEfl]
+ mov ecx, [fOrEfl]
+ pushfd
+ mov eax, [esp]
+ and edx, eax
+ or edx, ecx
+ mov [esp], edx
+ popfd
+ mov [fOldEfl], eax
+# endif
+ }
+# endif
+ return fOldEfl;
+}
+#endif
+
+
+/**
+ * Modifies the [RE]FLAGS register by ORing in one or more flags.
+ * @returns Original value.
+ * @param fOrEfl The flags to be set (ORed in).
+ */
+#if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < 15
+DECLASM(RTCCUINTREG) ASMAddFlags(RTCCUINTREG fOrEfl);
+#else
+DECLINLINE(RTCCUINTREG) ASMAddFlags(RTCCUINTREG fOrEfl)
+{
+ RTCCUINTREG fOldEfl;
+# if RT_INLINE_ASM_GNU_STYLE
+# ifdef RT_ARCH_AMD64
+ __asm__ __volatile__("pushfq\n\t"
+ "movq (%%rsp), %0\n\t"
+ "orq %1, (%%rsp)\n\t"
+ "popfq\n\t"
+ : "=&r" (fOldEfl)
+ : "rn" (fOrEfl) );
+# else
+ __asm__ __volatile__("pushfl\n\t"
+ "movl (%%esp), %0\n\t"
+ "orl %1, (%%esp)\n\t"
+ "popfl\n\t"
+ : "=&r" (fOldEfl)
+ : "rn" (fOrEfl) );
+# endif
+# elif RT_INLINE_ASM_USES_INTRIN >= 15
+ fOldEfl = __readeflags();
+ __writeeflags(fOldEfl | fOrEfl);
+# else
+ __asm
+ {
+# ifdef RT_ARCH_AMD64
+ mov rcx, [fOrEfl]
+ pushfq
+ mov rdx, [rsp]
+ or [rsp], rcx
+ popfq
+ mov [fOldEfl], rax
+# else
+ mov ecx, [fOrEfl]
+ pushfd
+ mov edx, [esp]
+ or [esp], ecx
+ popfd
+ mov [fOldEfl], eax
+# endif
+ }
+# endif
+ return fOldEfl;
+}
+#endif
+
+
+/**
+ * Modifies the [RE]FLAGS register by AND'ing out one or more flags.
+ * @returns Original value.
+ * @param fAndEfl The flags to keep.
+ */
+#if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < 15
+DECLASM(RTCCUINTREG) ASMClearFlags(RTCCUINTREG fAndEfl);
+#else
+DECLINLINE(RTCCUINTREG) ASMClearFlags(RTCCUINTREG fAndEfl)
+{
+ RTCCUINTREG fOldEfl;
+# if RT_INLINE_ASM_GNU_STYLE
+# ifdef RT_ARCH_AMD64
+ __asm__ __volatile__("pushfq\n\t"
+ "movq (%%rsp), %0\n\t"
+ "andq %1, (%%rsp)\n\t"
+ "popfq\n\t"
+ : "=&r" (fOldEfl)
+ : "rn" (fAndEfl) );
+# else
+ __asm__ __volatile__("pushfl\n\t"
+ "movl (%%esp), %0\n\t"
+ "andl %1, (%%esp)\n\t"
+ "popfl\n\t"
+ : "=&r" (fOldEfl)
+ : "rn" (fAndEfl) );
+# endif
+# elif RT_INLINE_ASM_USES_INTRIN >= 15
+ fOldEfl = __readeflags();
+ __writeeflags(fOldEfl & fAndEfl);
+# else
+ __asm
+ {
+# ifdef RT_ARCH_AMD64
+ mov rdx, [fAndEfl]
+ pushfq
+ mov rdx, [rsp]
+ and [rsp], rdx
+ popfq
+ mov [fOldEfl], rax
+# else
+ mov edx, [fAndEfl]
+ pushfd
+ mov edx, [esp]
+ and [esp], edx
+ popfd
+ mov [fOldEfl], eax
+# endif
+ }
+# endif
+ return fOldEfl;
+}
+#endif
+
+
/**
* Gets the content of the CPU timestamp counter register.
*
# define RT_INLINE_ASM_GCC_4_3_X_X86 0
#endif
-/** @def RT_INLINE_DONT_USE_CMPXCHG8B
+/** @def RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC
* i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493) screws up
* RTSemRWRequestWrite semsemrw-lockless-generic.cpp in release builds. PIC
* mode, x86.
int iStart = iBitStart & ~31;
int iEnd = iBitEnd & ~31;
if (iStart == iEnd)
- *pu32 &= ((1 << (iBitStart & 31)) - 1) | ~((1 << (iBitEnd & 31)) - 1);
+ *pu32 &= ((1U << (iBitStart & 31)) - 1) | ~((1U << (iBitEnd & 31)) - 1);
else
{
/* bits in first dword. */
if (iBitStart & 31)
{
- *pu32 &= (1 << (iBitStart & 31)) - 1;
+ *pu32 &= (1U << (iBitStart & 31)) - 1;
pu32++;
iBitStart = iStart + 32;
}
if (iBitEnd & 31)
{
pu32 = (volatile uint32_t *)pvBitmap + (iBitEnd >> 5);
- *pu32 &= ~((1 << (iBitEnd & 31)) - 1);
+ *pu32 &= ~((1U << (iBitEnd & 31)) - 1);
}
}
}
int iStart = iBitStart & ~31;
int iEnd = iBitEnd & ~31;
if (iStart == iEnd)
- *pu32 |= ((1 << (iBitEnd - iBitStart)) - 1) << iBitStart;
+ *pu32 |= ((1U << (iBitEnd - iBitStart)) - 1) << (iBitStart & 31);
else
{
/* bits in first dword. */
if (iBitStart & 31)
{
- *pu32 |= ~((1 << (iBitStart & 31)) - 1);
+ *pu32 |= ~((1U << (iBitStart & 31)) - 1);
pu32++;
iBitStart = iStart + 32;
}
if (iBitEnd & 31)
{
pu32 = (volatile uint32_t *)pvBitmap + (iBitEnd >> 5);
- *pu32 |= (1 << (iBitEnd & 31)) - 1;
+ *pu32 |= (1U << (iBitEnd & 31)) - 1;
}
}
}
* @param pszFormat Printf like format string.
* @param ... Arguments to that string.
*/
-RTDECL(void) RTAssertMsg2(const char *pszFormat, ...);
+RTDECL(void) RTAssertMsg2(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/**
* Weak version of RTAssertMsg2 that forwards to RTAssertMsg2WeakV.
*
*
* @copydoc RTAssertMsg2
*/
-RTDECL(void) RTAssertMsg2Weak(const char *pszFormat, ...);
+RTDECL(void) RTAssertMsg2Weak(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/**
* The 2nd (optional) part of an assert message.
* @param pszFormat Printf like format string.
* @param va Arguments to that string.
*/
-RTDECL(void) RTAssertMsg2V(const char *pszFormat, va_list va);
+RTDECL(void) RTAssertMsg2V(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
/**
* Weak version of RTAssertMsg2V that can be overridden locally in a module to
* modify, redirect or otherwise mess with the assertion output.
*
* @copydoc RTAssertMsg2V
*/
-RTDECL(void) RTAssertMsg2WeakV(const char *pszFormat, va_list va);
+RTDECL(void) RTAssertMsg2WeakV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
/**
* Additional information which should be appended to the 2nd part of an
* @param pszFormat Printf like format string.
* @param ... Arguments to that string.
*/
-RTDECL(void) RTAssertMsg2Add(const char *pszFormat, ...);
+RTDECL(void) RTAssertMsg2Add(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/**
* Weak version of RTAssertMsg2Add that forwards to RTAssertMsg2AddWeakV.
*
*
* @copydoc RTAssertMsg2Add
*/
-RTDECL(void) RTAssertMsg2AddWeak(const char *pszFormat, ...);
+RTDECL(void) RTAssertMsg2AddWeak(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/**
* Additional information which should be appended to the 2nd part of an
* @param pszFormat Printf like format string.
* @param va Arguments to that string.
*/
-RTDECL(void) RTAssertMsg2AddV(const char *pszFormat, va_list va);
+RTDECL(void) RTAssertMsg2AddV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
/**
* Weak version of RTAssertMsg2AddV that can be overridden locally in a module
* to modify, redirect or otherwise mess with the assertion output.
*
* @copydoc RTAssertMsg2AddV
*/
-RTDECL(void) RTAssertMsg2AddWeakV(const char *pszFormat, va_list va);
+RTDECL(void) RTAssertMsg2AddWeakV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
#ifdef IN_RING0
/**
return (rc); \
} while (0)
-/** @def AssertLogRelMsgFailedReturn
+/** @def AssertLogRelMsgFailedReturnStmt
* An assertion failed, execute @a stmt and return @a rc.
* Strict builds will hit a breakpoint, non-strict will only do LogRel.
*
return; \
} while (0)
-/** @def AssertLogRelMsgFailedReturnVoid
+/** @def AssertLogRelMsgFailedReturnVoidStmt
* An assertion failed, execute @a stmt and return void.
* Strict builds will hit a breakpoint, non-strict will only do LogRel.
*
*/
#define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
-/** @def AssertRCReturn
+/** @def AssertRCReturnStmt
* Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
* @a stmt and returns @a rcRet if it isn't.
*
*/
#define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
-/** @def AssertReturnVoidStmt
+/** @def AssertRCReturnVoidStmt
* Asserts a iprt status code successful, bitch (RT_STRICT mode only), and
* execute the given statement/return if it isn't.
*
# define __X86__
# define RT_ARCH_AMD64
# define RT_ARCH_X86
+# define RT_ARCH_SPARC
+# define RT_ARCH_SPARC64
# define IN_RING0
# define IN_RING3
# define IN_RC
# define RT_LOCK_NO_STRICT
# define RT_LOCK_STRICT_ORDER
# define RT_LOCK_NO_STRICT_ORDER
-# define Breakpoint
+# define RT_BREAKPOINT
# define RT_NO_DEPRECATED_MACROS
# define RT_EXCEPTIONS_ENABLED
# define RT_BIG_ENDIAN
# define RT_COMPILER_GROKS_64BIT_BITFIELDS
# define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
# define RT_NO_VISIBILITY_HIDDEN
+# define RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
+# define RT_COMPILER_SUPPORTS_LAMBDA
#endif /* DOXYGEN_RUNNING */
/** @def RT_ARCH_X86
* Replace: # elif defined(RT_OS_\1)\n# define RT_OPSYS RT_OPSYS_\1
*/
#ifndef RT_OPSYS
-# if defined(RT_OS_UNKNOWN)
+# if defined(RT_OS_UNKNOWN) || defined(DOXYGEN_RUNNING)
# define RT_OPSYS RT_OPSYS_UNKNOWN
# elif defined(RT_OS_AGNOSTIC)
# define RT_OPSYS RT_OPSYS_AGNOSTIC
# define RT_EXCEPTIONS_ENABLED
#endif
-/** @def RT_NO_THROW
+/** @def RT_NO_THROW_PROTO
* How to express that a function doesn't throw C++ exceptions
* and the compiler can thus save itself the bother of trying
* to catch any of them. Put this between the closing parenthesis
* and the semicolon in function prototypes (and implementation if C++).
+ *
+ * @remarks May not work on C++ methods, mainly intented for C-style APIs.
+ *
+ * @remarks The use of the nothrow attribute with GCC is because old compilers
+ * (4.1.1, 32-bit) leaking the nothrow into global space or something
+ * when used with RTDECL or similar. Using this forces use to have two
+ * macros, as the nothrow attribute is not for the function definition.
*/
#ifdef RT_EXCEPTIONS_ENABLED
-# define RT_NO_THROW throw()
+# ifdef __GNUC__
+# define RT_NO_THROW_PROTO __attribute__((__nothrow__))
+# else
+# define RT_NO_THROW_PROTO throw()
+# endif
+#else
+# define RT_NO_THROW_PROTO
+#endif
+
+/** @def RT_NO_THROW_DEF
+ * The counter part to RT_NO_THROW_PROTO that is added to the function
+ * definition.
+ */
+#if defined(RT_EXCEPTIONS_ENABLED) && !defined(__GNUC__)
+# define RT_NO_THROW_DEF RT_NO_THROW_PROTO
#else
-# define RT_NO_THROW
+# define RT_NO_THROW_DEF
#endif
/** @def RT_THROW
# define RT_THROW(type)
#endif
+/** @def RT_IPRT_FORMAT_ATTR
+ * Identifies a function taking an IPRT format string.
+ * @param a_iFmt The index (1-based) of the format string argument.
+ * @param a_iArgs The index (1-based) of the first format argument, use 0 for
+ * va_list.
+ */
+#if defined(__GNUC__) && defined(WITH_IPRT_FORMAT_ATTRIBUTE)
+# define RT_IPRT_FORMAT_ATTR(a_iFmt, a_iArgs) __attribute__((__iprt_format__(a_iFmt, a_iArgs)))
+#else
+# define RT_IPRT_FORMAT_ATTR(a_iFmt, a_iArgs)
+#endif
+
+/** @def RT_IPRT_FORMAT_ATTR_MAYBE_NULL
+ * Identifies a function taking an IPRT format string, NULL is allowed.
+ * @param a_iFmt The index (1-based) of the format string argument.
+ * @param a_iArgs The index (1-based) of the first format argument, use 0 for
+ * va_list.
+ */
+#if defined(__GNUC__) && defined(WITH_IPRT_FORMAT_ATTRIBUTE)
+# define RT_IPRT_FORMAT_ATTR_MAYBE_NULL(a_iFmt, a_iArgs) __attribute__((__iprt_format_maybe_null__(a_iFmt, a_iArgs)))
+#else
+# define RT_IPRT_FORMAT_ATTR_MAYBE_NULL(a_iFmt, a_iArgs)
+#endif
+
+
/** @def RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
* Indicates that the "hidden" visibility attribute can be used (GCC) */
#if defined(__GNUC__)
/** @def RTCALL
* The standard calling convention for the Runtime interfaces.
+ *
+ * @remarks The regparm(0) in the X86/GNUC variant deals with -mregparm=x use in
+ * the linux kernel and potentially elsewhere (3rd party).
*/
#ifdef _MSC_VER
-# define RTCALL __cdecl
+# define RTCALL __cdecl
#elif defined(RT_OS_OS2)
-# define RTCALL __cdecl
-#elif defined(__GNUC__) && defined(IN_RING0) && defined(RT_ARCH_X86) /** @todo consider dropping IN_RING0 here. */
-# define RTCALL __attribute__((cdecl,regparm(0))) /* regparm(0) deals with -mregparm=x use in the linux kernel. */
+# define RTCALL __cdecl
+#elif defined(__GNUC__) && defined(RT_ARCH_X86)
+# define RTCALL __attribute__((cdecl,regparm(0)))
#else
# define RTCALL
#endif
* @param type The return type of the function declaration.
*/
#ifdef __cplusplus
-# if defined(_MSC_VER) || defined(RT_OS_OS2)
-# define DECLASM(type) extern "C" type __cdecl
-# elif defined(__GNUC__) && defined(RT_ARCH_X86)
-# define DECLASM(type) extern "C" type __attribute__((cdecl,regparm(0)))
-# else
-# define DECLASM(type) extern "C" type
-# endif
+# define DECLASM(type) extern "C" type RTCALL
#else
-# if defined(_MSC_VER) || defined(RT_OS_OS2)
-# define DECLASM(type) type __cdecl
-# elif defined(__GNUC__) && defined(RT_ARCH_X86)
-# define DECLASM(type) type __attribute__((cdecl,regparm(0)))
-# else
-# define DECLASM(type) type
-# endif
+# define DECLASM(type) type RTCALL
#endif
/** @def DECLASMTYPE
* How to declare an internal assembly function type.
* @param type The return type of the function.
*/
-# if defined(_MSC_VER) || defined(RT_OS_OS2)
-# define DECLASMTYPE(type) type __cdecl
-#else
-# define DECLASMTYPE(type) type
-#endif
+#define DECLASMTYPE(type) type RTCALL
/** @def DECLNORETURN
* How to declare a function which does not return.
#define RT_STR(str) #str
/** @def RT_XSTR
* Returns the expanded argument as a string.
- * @param str Argument to expand and stringy. */
+ * @param str Argument to expand and stringify. */
#define RT_XSTR(str) RT_STR(str)
+/** @def RT_LSTR_2
+ * Helper for RT_WSTR that gets the expanded @a str.
+ * @param str String litteral to prefix with 'L'. */
+#define RT_LSTR_2(str) L##str
+/** @def RT_LSTR
+ * Returns the expanded argument with a L string prefix.
+ *
+ * Intended for converting ASCII string \#defines into wide char string
+ * litterals on Windows.
+ *
+ * @param str String litteral to . */
+#define RT_LSTR(str) RT_LSTR_2(str)
+
/** @def RT_CONCAT
* Concatenate the expanded arguments without any extra spaces in between.
*
/** RT_CONCAT helper, don't use. */
#define RT_CONCAT_HLP(a,b) a##b
-/** @def RT_CONCAT
+/** @def RT_CONCAT3
* Concatenate the expanded arguments without any extra spaces in between.
*
* @param a The 1st part.
/** RT_CONCAT3 helper, don't use. */
#define RT_CONCAT3_HLP(a,b,c) a##b##c
-/** @def RT_CONCAT
+/** @def RT_CONCAT4
* Concatenate the expanded arguments without any extra spaces in between.
*
* @param a The 1st part.
* @param b The 2nd part.
* @param c The 3rd part.
+ * @param d The 4th part.
*/
#define RT_CONCAT4(a,b,c,d) RT_CONCAT4_HLP(a,b,c,d)
/** RT_CONCAT4 helper, don't use. */
* String constant tuple - string constant, strlen(string constant).
*
* @param a_szConst String constant.
+ * @sa RTSTRTUPLE
*/
#define RT_STR_TUPLE(a_szConst) a_szConst, (sizeof(a_szConst) - 1)
* @param pszFormat The format string.
* @param ... The format arguments.
*/
-RTDECL(int) RTErrInfoSetF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...);
+RTDECL(int) RTErrInfoSetF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
/**
* Fills in the error info details, with a vsprintf style message.
* @param pszFormat The format string.
* @param va The format arguments.
*/
-RTDECL(int) RTErrInfoSetV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va);
+RTDECL(int) RTErrInfoSetV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);
/**
* Adds more error info details.
* @param pszFormat The format string to add.
* @param ... The format arguments.
*/
-RTDECL(int) RTErrInfoAddF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...);
+RTDECL(int) RTErrInfoAddF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
/**
* Adds more error info details, with a vsprintf style message.
* @param pszFormat The format string to add.
* @param va The format arguments.
*/
-RTDECL(int) RTErrInfoAddV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va);
+RTDECL(int) RTErrInfoAddV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);
/**
* Checks if the error info is set.
#define VERR_MISMATCH (-22408)
/** Wrong type. */
#define VERR_WRONG_TYPE (-22409)
+/** This indicates that the process does not have sufficient privileges to
+ * perform the operation. */
+#define VERR_PRIVILEGE_NOT_HELD (-22410)
+/** Process does not have the trusted code base (TCB) privilege needed for user
+ * authentication or/and process creation as a given user. TCB is also called
+ * 'Act as part of the operating system'. */
+#define VERR_PROC_TCB_PRIV_NOT_HELD (-22411)
+/** Process does not have the assign primary token (APT) privilege needed
+ * for creating process as a given user. APT is also called 'Replace a process
+ * level token'. */
+#define VERR_PROC_APT_PRIV_NOT_HELD (-22412)
+/** Process does not have the increase quota (IQ) privilege needed for
+ * creating a process as a given user. IQ is also called 'Increase quotas'. */
+#define VERR_PROC_IQ_PRIV_NOT_HELD (-22413)
/** @} */
#define VERR_HTTP_ABORTED (-893)
/** Request was redirected. */
#define VERR_HTTP_REDIRECTED (-894)
+/** Proxy couldn't be resolved. */
+#define VERR_HTTP_PROXY_NOT_FOUND (-895)
+/** The remote host couldn't be resolved. */
+#define VERR_HTTP_HOST_NOT_FOUND (-896)
+/** Unexpected cURL error configure the proxy. */
+#define VERR_HTTP_CURL_PROXY_CONFIG (-897)
+/** Generic CURL error. */
+#define VERR_HTTP_CURL_ERROR (-899)
/** @} */
/** @name RTManifest status codes
/** @name RTCrDigest status codes.
* @{ */
-/** OpenSSL failed to initialize the digest algorithm contextn. */
+/** OpenSSL failed to initialize the digest algorithm context. */
#define VERR_CR_DIGEST_OSSL_DIGEST_INIT_ERROR (-24200)
/** OpenSSL failed to clone the digest algorithm context. */
#define VERR_CR_DIGEST_OSSL_DIGEST_CTX_COPY_ERROR (-24201)
/** @} */
+/** @name RTPath status codes.
+ * @{ */
+/** Unknown glob variable. */
+#define VERR_PATH_MATCH_UNKNOWN_VARIABLE (-24400)
+/** The specified glob variable must be first in the pattern. */
+#define VERR_PATH_MATCH_VARIABLE_MUST_BE_FIRST (-24401)
+/** Hit unimplemented glob pattern matching feature. */
+#define VERR_PATH_MATCH_FEATURE_NOT_IMPLEMENTED (-24402)
+/** Unknown character class in glob pattern. */
+#define VERR_PATH_GLOB_UNKNOWN_CHAR_CLASS (-24403)
+/** @} */
+
+/** @name RTUri status codes.
+ * @{ */
+/** The URI is empty */
+#define VERR_URI_EMPTY (-24600)
+/** The URI is too short to be a valid URI. */
+#define VERR_URI_TOO_SHORT (-24601)
+/** Invalid scheme. */
+#define VERR_URI_INVALID_SCHEME (-24602)
+/** Invalid port number. */
+#define VERR_URI_INVALID_PORT_NUMBER (-24603)
+/** Invalid escape sequence. */
+#define VERR_URI_INVALID_ESCAPE_SEQ (-24604)
+/** Escape URI char decodes as zero (the C string terminator). */
+#define VERR_URI_ESCAPED_ZERO (-24605)
+/** Escaped URI characters does not decode to valid UTF-8. */
+#define VERR_URI_ESCAPED_CHARS_NOT_VALID_UTF8 (-24606)
+/** Escaped URI character is not a valid UTF-8 lead byte. */
+#define VERR_URI_INVALID_ESCAPED_UTF8_LEAD_BYTE (-24607)
+/** Escaped URI character sequence with invalid UTF-8 continutation byte. */
+#define VERR_URI_INVALID_ESCAPED_UTF8_CONTINUATION_BYTE (-24608)
+/** Missing UTF-8 continutation in escaped URI character sequence. */
+#define VERR_URI_MISSING_UTF8_CONTINUATION_BYTE (-24609)
+/** Expected URI using the 'file:' scheme. */
+#define VERR_URI_NOT_FILE_SCHEME (-24610)
+/** @} */
+
/* SED-END */
/** @} */
#define RTFS_TYPE_WHITEOUT 0160000U
/** Type mask (S_IFMT). */
#define RTFS_TYPE_MASK 0170000U
+/** The shift count to convert between RTFS_TYPE_MASK and DIRENTRYTYPE. */
+#define RTFS_TYPE_DIRENTRYTYPE_SHIFT 12
/** Unix attribute mask. */
#define RTFS_UNIX_MASK 0xffffU
*/
RTR3DECL(int) RTFsQueryProperties(const char *pszFsPath, PRTFSPROPERTIES pProperties);
+/**
+ * Checks if the given volume is case sensitive or not.
+ *
+ * This may be misleading in some cases as we lack the necessary APIs to query
+ * the information on some system (or choose not to use them) and are instead
+ * returning the general position on case sensitive file name of the system.
+ *
+ * @returns @c true if case sensitive, @c false if not.
+ * @param pszFsPath Path within the mounted file system.
+ */
+RTR3DECL(bool) RTFsIsCaseSensitive(const char *pszFsPath);
/**
* Mountpoint enumerator callback.
* @param pszFormat IPRT format string.
* @param ... Format arguments.
*/
-typedef DECLCALLBACK(void) FNRTHEAPSIMPLEPRINTF(const char *pszFormat, ...);
+typedef DECLCALLBACK(void) FNRTHEAPSIMPLEPRINTF(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/** Pointer to a FNRTHEAPSIMPLEPRINTF function. */
typedef FNRTHEAPSIMPLEPRINTF *PFNRTHEAPSIMPLEPRINTF;
* @param pszFormat IPRT format string.
* @param ... Format arguments.
*/
-typedef DECLCALLBACK(void) FNRTHEAPOFFSETPRINTF(const char *pszFormat, ...);
+typedef DECLCALLBACK(void) FNRTHEAPOFFSETPRINTF(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/** Pointer to a FNRTHEAPOFFSETPRINTF function. */
typedef FNRTHEAPOFFSETPRINTF *PFNRTHEAPOFFSETPRINTF;
* @{
*/
-/** @defgroup grp_rt_initterm Init / Term
+/** @defgroup grp_rt_initterm RTInit/RTTerm - Initialization and Termination
+ *
+ * APIs for initializing and terminating the IPRT, optionally it can also
+ * convert input arguments to UTF-8 (in ring-3).
+ *
+ * @sa RTOnce, RTOnceEx.
+ *
* @{
*/
#define RTR3INIT_FLAGS_UNOBTRUSIVE RT_BIT(2)
/** The caller ensures that the argument bector is UTF-8. */
#define RTR3INIT_FLAGS_UTF8_ARGV RT_BIT(3)
+/** Indicates that this is a standalone application without any additional
+ * shared libraries in the application directory. Mainly windows loader mess. */
+#define RTR3INIT_FLAGS_STANDALONE_APP RT_BIT(4)
/** @} */
/** @name RTR3InitEx version
* @param ppapszArgs Pointer to the argument vector pointer.
* @param fFlags Flags, see RTR3INIT_XXX.
*/
-RTR3DECL(int) RTR3InitExe(int cArgs, char ***papszArgs, uint32_t fFlags);
+RTR3DECL(int) RTR3InitExe(int cArgs, char ***ppapszArgs, uint32_t fFlags);
/**
* Initializes the runtime library.
* @param pszProgramPath The program path. Pass NULL if we're to figure it
* out ourselves.
*/
-RTR3DECL(int) RTR3InitEx(uint32_t iVersion, uint32_t fFlags, int cArgs, char ***papszArgs, const char *pszProgramPath);
+RTR3DECL(int) RTR3InitEx(uint32_t iVersion, uint32_t fFlags, int cArgs, char ***ppapszArgs, const char *pszProgramPath);
/**
* Terminates the runtime library.
--- /dev/null
+/** @file
+ * IPRT - String Manipulation, Latin-1 (ISO-8859-1) encoding.
+ */
+
+/*
+ * Copyright (C) 2006-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef ___iprt_latin1_h
+#define ___iprt_latin1_h
+
+#include <iprt/string.h>
+
+RT_C_DECLS_BEGIN
+
+
+/** @defgroup rt_str_latin1 Latin-1 (ISO-8859-1) String Manipulation
+ * @ingroup grp_rt_str
+ *
+ * Deals with Latin-1 encoded strings.
+ *
+ * @warning Make sure to name all variables dealing with Latin-1 strings
+ * suchthat there is no way to mistake them for normal UTF-8 strings.
+ * There may be severe security issues resulting from mistaking Latin-1
+ * for UTF-8!
+ *
+ * @{
+ */
+
+/**
+ * Get the unicode code point at the given string position.
+ *
+ * @returns unicode code point.
+ * @returns RTUNICP_INVALID if the encoding is invalid.
+ * @param pszLatin1 The Latin-1 string.
+ */
+DECLINLINE(RTUNICP) RTLatin1GetCp(const char *pszLatin1)
+{
+ return *(const unsigned char *)pszLatin1;
+}
+
+/**
+ * Get the unicode code point at the given string position.
+ *
+ * @returns iprt status code.
+ * @param ppszLatin1 Pointer to the string pointer. This will be updated to
+ * point to the char following the current code point. This
+ * is advanced one character forward on failure.
+ * @param pCp Where to store the code point. RTUNICP_INVALID is stored
+ * here on failure.
+ */
+DECLINLINE(int) RTLatin1GetCpEx(const char **ppszLatin1, PRTUNICP pCp)
+{
+ const unsigned char uch = **(const unsigned char **)ppszLatin1;
+ (*ppszLatin1)++;
+ *pCp = uch;
+ return VINF_SUCCESS;
+}
+
+/**
+ * Get the unicode code point at the given string position for a string of a
+ * given maximum length.
+ *
+ * @returns iprt status code.
+ * @retval VERR_END_OF_STRING if *pcch is 0. *pCp is set to RTUNICP_INVALID.
+ *
+ * @param ppszLatin1 Pointer to the string pointer. This will be updated to
+ * point to the char following the current code point.
+ * @param pcchLatin1 Pointer to the maximum string length. This will be
+ * decremented by the size of the code point found.
+ * @param pCp Where to store the code point.
+ * RTUNICP_INVALID is stored here on failure.
+ */
+DECLINLINE(int) RTLatin1GetCpNEx(const char **ppszLatin1, size_t *pcchLatin1, PRTUNICP pCp)
+{
+ if (RT_LIKELY(*pcchLatin1 != 0))
+ {
+ const unsigned char uch = **(const unsigned char **)ppszLatin1;
+ (*ppszLatin1)++;
+ (*pcchLatin1)--;
+ *pCp = uch;
+ return VINF_SUCCESS;
+ }
+ *pCp = RTUNICP_INVALID;
+ return VERR_END_OF_STRING;
+}
+
+/**
+ * Get the Latin-1 size in characters of a given Unicode code point.
+ *
+ * The code point is expected to be a valid Unicode one, but not necessarily in
+ * the range supported by Latin-1.
+ *
+ * @returns the size in characters, or zero if there is no Latin-1 encoding
+ */
+DECLINLINE(size_t) RTLatin1CpSize(RTUNICP CodePoint)
+{
+ if (CodePoint < 0x100)
+ return 1;
+ return 0;
+}
+
+/**
+ * Put the unicode code point at the given string position
+ * and return the pointer to the char following it.
+ *
+ * This function will not consider anything at or following the
+ * buffer area pointed to by psz. It is therefore not suitable for
+ * inserting code points into a string, only appending/overwriting.
+ *
+ * @returns pointer to the char following the written code point.
+ * @param pszLatin1 The string.
+ * @param CodePoint The code point to write.
+ * This should not be RTUNICP_INVALID or any other
+ * character out of the Latin-1 range.
+ */
+DECLINLINE(char *) RTLatin1PutCp(char *pszLatin1, RTUNICP CodePoint)
+{
+ AssertReturn(CodePoint < 0x100, NULL);
+ *pszLatin1++ = (unsigned char)CodePoint;
+ return pszLatin1;
+}
+
+/**
+ * Skips ahead, past the current code point.
+ *
+ * @returns Pointer to the char after the current code point.
+ * @param pszLatin1 Pointer to the current code point.
+ * @remark This will not move the next valid code point, only past the current one.
+ */
+DECLINLINE(char *) RTLatin1NextCp(const char *pszLatin1)
+{
+ pszLatin1++;
+ return (char *)pszLatin1;
+}
+
+/**
+ * Skips back to the previous code point.
+ *
+ * @returns Pointer to the char before the current code point.
+ * @returns pszLatin1Start on failure.
+ * @param pszLatin1Start Pointer to the start of the string.
+ * @param pszLatin1 Pointer to the current code point.
+ */
+DECLINLINE(char *) RTLatin1PrevCp(const char *pszLatin1Start, const char *pszLatin1)
+{
+ if ((uintptr_t)pszLatin1 > (uintptr_t)pszLatin1Start)
+ {
+ pszLatin1--;
+ return (char *)pszLatin1;
+ }
+ return (char *)pszLatin1Start;
+}
+
+/**
+ * Translate a Latin1 string into a UTF-8 allocating the result buffer (default
+ * tag).
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 Latin1 string to convert.
+ * @param ppszString Receives pointer of allocated UTF-8 string on
+ * success, and is always set to NULL on failure.
+ * The returned pointer must be freed using RTStrFree().
+ */
+#define RTLatin1ToUtf8(pszLatin1, ppszString) RTLatin1ToUtf8Tag((pszLatin1), (ppszString), RTSTR_TAG)
+
+/**
+ * Translate a Latin-1 string into a UTF-8 allocating the result buffer.
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 Latin-1 string to convert.
+ * @param ppszString Receives pointer of allocated UTF-8 string on
+ * success, and is always set to NULL on failure.
+ * The returned pointer must be freed using RTStrFree().
+ * @param pszTag Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTLatin1ToUtf8Tag(const char *pszLatin1, char **ppszString, const char *pszTag);
+
+/**
+ * Translates Latin-1 to UTF-8 using buffer provided by the caller or a fittingly
+ * sized buffer allocated by the function (default tag).
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 The Latin-1 string to convert.
+ * @param cchLatin1 The number of Latin-1 characters to translate from
+ * pszLatin1. The translation will stop when reaching
+ * cchLatin1 or the terminator ('\\0'). Use RTSTR_MAX
+ * to translate the entire string.
+ * @param ppsz If @a cch is non-zero, this must either be pointing
+ * to a pointer to a buffer of the specified size, or
+ * pointer to a NULL pointer. If *ppsz is NULL or
+ * @a cch is zero a buffer of at least @a cch chars
+ * will be allocated to hold the translated string. If
+ * a buffer was requested it must be freed using
+ * RTStrFree().
+ * @param cch The buffer size in chars (the type). This includes the terminator.
+ * @param pcch Where to store the length of the translated string,
+ * excluding the terminator. (Optional)
+ *
+ * This may be set under some error conditions,
+ * however, only for VERR_BUFFER_OVERFLOW and
+ * VERR_NO_STR_MEMORY will it contain a valid string
+ * length that can be used to resize the buffer.
+ */
+#define RTLatin1ToUtf8Ex(pszLatin1, cchLatin1, ppsz, cch, pcch) \
+ RTLatin1ToUtf8ExTag((pszLatin1), (cchLatin1), (ppsz), (cch), (pcch), RTSTR_TAG)
+
+/**
+ * Translates Latin1 to UTF-8 using buffer provided by the caller or a fittingly
+ * sized buffer allocated by the function (custom tag).
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 The Latin1 string to convert.
+ * @param cchLatin1 The number of Latin1 characters to translate from
+ * pwszString. The translation will stop when
+ * reaching cchLatin1 or the terminator ('\\0'). Use
+ * RTSTR_MAX to translate the entire string.
+ * @param ppsz If cch is non-zero, this must either be pointing to
+ * a pointer to a buffer of the specified size, or
+ * pointer to a NULL pointer. If *ppsz is NULL or cch
+ * is zero a buffer of at least cch chars will be
+ * allocated to hold the translated string. If a
+ * buffer was requested it must be freed using
+ * RTStrFree().
+ * @param cch The buffer size in chars (the type). This includes
+ * the terminator.
+ * @param pcch Where to store the length of the translated string,
+ * excluding the terminator. (Optional)
+ *
+ * This may be set under some error conditions,
+ * however, only for VERR_BUFFER_OVERFLOW and
+ * VERR_NO_STR_MEMORY will it contain a valid string
+ * length that can be used to resize the buffer.
+ * @param pszTag Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTLatin1ToUtf8ExTag(const char *pszLatin1, size_t cchLatin1, char **ppsz, size_t cch, size_t *pcch,
+ const char *pszTag);
+
+/**
+ * Calculates the length of the Latin-1 string in UTF-8 chars (bytes).
+ *
+ * The primary purpose of this function is to help allocate buffers for
+ * RTLatin1ToUtf8() of the correct size. For most other purposes
+ * RTLatin1ToUtf8Ex() should be used.
+ *
+ * @returns Number of chars (bytes).
+ * @returns 0 if the string was incorrectly encoded.
+ * @param pszLatin1 The Latin-1 string.
+ */
+RTDECL(size_t) RTLatin1CalcUtf8Len(const char *pszLatin1);
+
+/**
+ * Calculates the length of the Latin-1 string in UTF-8 chars (bytes).
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 The Latin-1 string.
+ * @param cchLatin1 The max string length. Use RTSTR_MAX to process the
+ * entire string.
+ * @param pcch Where to store the string length (in bytes). Optional.
+ * This is undefined on failure.
+ */
+RTDECL(int) RTLatin1CalcUtf8LenEx(const char *pszLatin1, size_t cchLatin1, size_t *pcch);
+
+/**
+ * Calculates the length of the Latin-1 (ISO-8859-1) string in RTUTF16 items.
+ *
+ * @returns Number of RTUTF16 items.
+ * @param pszLatin1 The Latin-1 string.
+ */
+RTDECL(size_t) RTLatin1CalcUtf16Len(const char *pszLatin1);
+
+/**
+ * Calculates the length of the Latin-1 (ISO-8859-1) string in RTUTF16 items.
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 The Latin-1 string.
+ * @param cchLatin1 The max string length. Use RTSTR_MAX to process the
+ * entire string.
+ * @param pcwc Where to store the string length. Optional.
+ * This is undefined on failure.
+ */
+RTDECL(int) RTLatin1CalcUtf16LenEx(const char *pszLatin1, size_t cchLatin1, size_t *pcwc);
+
+/**
+ * Translate a Latin-1 (ISO-8859-1) string into a UTF-16 allocating the result
+ * buffer (default tag).
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 The Latin-1 string to convert.
+ * @param ppwszString Receives pointer to the allocated UTF-16 string. The
+ * returned string must be freed using RTUtf16Free().
+ */
+#define RTLatin1ToUtf16(pszLatin1, ppwszString) RTLatin1ToUtf16Tag((pszLatin1), (ppwszString), RTSTR_TAG)
+
+/**
+ * Translate a Latin-1 (ISO-8859-1) string into a UTF-16 allocating the result
+ * buffer (custom tag).
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 The Latin-1 string to convert.
+ * @param ppwszString Receives pointer to the allocated UTF-16 string. The
+ * returned string must be freed using RTUtf16Free().
+ * @param pszTag Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTLatin1ToUtf16Tag(const char *pszLatin1, PRTUTF16 *ppwszString, const char *pszTag);
+
+/**
+ * Translates pszLatin1 from Latin-1 (ISO-8859-1) to UTF-16, allocating the
+ * result buffer if requested (default tag).
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 The Latin-1 string to convert.
+ * @param cchLatin1 The maximum size in chars (the type) to convert. The
+ * conversion stops when it reaches cchLatin1 or the
+ * string terminator ('\\0'). Use RTSTR_MAX to
+ * translate the entire string.
+ * @param ppwsz If cwc is non-zero, this must either be pointing
+ * to pointer to a buffer of the specified size, or
+ * pointer to a NULL pointer.
+ * If *ppwsz is NULL or cwc is zero a buffer of at
+ * least cwc items will be allocated to hold the
+ * translated string. If a buffer was requested it
+ * must be freed using RTUtf16Free().
+ * @param cwc The buffer size in RTUTF16s. This includes the
+ * terminator.
+ * @param pcwc Where to store the length of the translated string,
+ * excluding the terminator. (Optional)
+ *
+ * This may be set under some error conditions,
+ * however, only for VERR_BUFFER_OVERFLOW and
+ * VERR_NO_STR_MEMORY will it contain a valid string
+ * length that can be used to resize the buffer.
+ */
+#define RTLatin1ToUtf16Ex(pszLatin1, cchLatin1, ppwsz, cwc, pcwc) \
+ RTLatin1ToUtf16ExTag((pszLatin1), (cchLatin1), (ppwsz), (cwc), (pcwc), RTSTR_TAG)
+
+/**
+ * Translates pszLatin1 from Latin-1 (ISO-8859-1) to UTF-16, allocating the
+ * result buffer if requested.
+ *
+ * @returns iprt status code.
+ * @param pszLatin1 The Latin-1 string to convert.
+ * @param cchLatin1 The maximum size in chars (the type) to convert. The
+ * conversion stops when it reaches cchLatin1 or the
+ * string terminator ('\\0'). Use RTSTR_MAX to
+ * translate the entire string.
+ * @param ppwsz If cwc is non-zero, this must either be pointing
+ * to pointer to a buffer of the specified size, or
+ * pointer to a NULL pointer.
+ * If *ppwsz is NULL or cwc is zero a buffer of at
+ * least cwc items will be allocated to hold the
+ * translated string. If a buffer was requested it
+ * must be freed using RTUtf16Free().
+ * @param cwc The buffer size in RTUTF16s. This includes the
+ * terminator.
+ * @param pcwc Where to store the length of the translated string,
+ * excluding the terminator. (Optional)
+ *
+ * This may be set under some error conditions,
+ * however, only for VERR_BUFFER_OVERFLOW and
+ * VERR_NO_STR_MEMORY will it contain a valid string
+ * length that can be used to resize the buffer.
+ * @param pszTag Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTLatin1ToUtf16ExTag(const char *pszLatin1, size_t cchLatin1,
+ PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag);
+
+/** @} */
+
+RT_C_DECLS_END
+
+/** @} */
+
+#endif
+
/** Pointer to a const doubly linked list anchor. */
typedef RTLISTANCHOR const *PCRTLISTANCHOR;
+/** Version of RTLISTNODE for holding a ring-3 only list in data which gets
+ * shared between multiple contexts */
+#if defined(IN_RING3)
+typedef RTLISTNODE RTLISTNODER3;
+#else
+typedef struct { RTR3PTR aOffLimits[2]; } RTLISTNODER3;
+#endif
+/** Version of RTLISTANCHOR for holding a ring-3 only list in data which gets
+ * shared between multiple contexts */
+typedef RTLISTNODER3 RTLISTANCHORR3;
+
/**
* Initialize a list.
/**
* Checks if a node is the last element in the list.
*
- * @retval @c true if the node is the last element in the list.
- * @retval @c false otherwise
+ * @retval true if the node is the last element in the list.
+ * @retval false otherwise
*
* @param pList The list.
* @param pNode The node to check.
/**
* Checks if a node is the first element in the list.
*
- * @retval @c true if the node is the first element in the list.
- * @retval @c false otherwise.
+ * @retval true if the node is the first element in the list.
+ * @retval false otherwise.
*
* @param pList The list.
* @param pNode The node to check.
/**
* Checks if a type converted node is actually the dummy element (@a pList).
*
- * @retval @c true if the node is the dummy element in the list.
- * @retval @c false otherwise.
+ * @retval true if the node is the dummy element in the list.
+ * @retval false otherwise.
*
* @param pList The list.
- * @param pNodeStruct The node structure to check. Typically
+ * @param pNode The node structure to check. Typically
* something obtained from RTListNodeGetNext() or
* RTListNodeGetPrev(). This is NOT a PRTLISTNODE
* but something that contains a RTLISTNODE member!
/**
* Checks if a list is empty.
*
- * @retval @c true if the list is empty.
- * @retval @c false otherwise.
+ * @retval true if the list is empty.
+ * @retval false otherwise.
*
* @param pList The list to check.
*/
* optional (NULL). Max length is 32 bytes.
* @param ... Format string arguments.
*/
-RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
- void *hLock, bool fEnabled, const char *pszNameFmt, ...);
+RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass, void *hLock,
+ bool fEnabled, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(6, 7);
/**
* Initialize a lock validator record.
*
* optional (NULL). Max length is 32 bytes.
* @param va Format string arguments.
*/
-RTDECL(void) RTLockValidatorRecExclInitV(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
- void *hLock, bool fEnabled, const char *pszNameFmt, va_list va);
+RTDECL(void) RTLockValidatorRecExclInitV(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass, void *hLock,
+ bool fEnabled, const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(6, 0);
/**
* Uninitialize a lock validator record previously initialized by
* RTLockRecValidatorInit.
* optional (NULL). Max length is 32 bytes.
* @param ... Format string arguments.
*/
-RTDECL(int) RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
- void *hLock, bool fEnabled, const char *pszNameFmt, ...);
+RTDECL(int) RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass, void *hLock,
+ bool fEnabled, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(6, 7);
/**
* Create and initialize a lock validator record.
* optional (NULL). Max length is 32 bytes.
* @param va Format string arguments.
*/
-RTDECL(int) RTLockValidatorRecExclCreateV(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
- void *hLock, bool fEnabled, const char *pszNameFmt, va_list va);
+RTDECL(int) RTLockValidatorRecExclCreateV(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass, void *hLock,
+ bool fEnabled, const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(6, 0);
/**
* Deinitialize and destroy a record created by RTLockValidatorRecExclCreate.
* @param ... Format string arguments.
*/
RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
- void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, ...);
+ void *hLock, bool fSignaller, bool fEnabled,
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(7, 8);
/**
* Initialize a lock validator record for a shared lock.
* @param va Format string arguments.
*/
RTDECL(void) RTLockValidatorRecSharedInitV(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
- void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, va_list va);
+ void *hLock, bool fSignaller, bool fEnabled,
+ const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(7, 0);
/**
* Uninitialize a lock validator record previously initialized by
* @param ... Format string arguments.
*/
RTDECL(int) RTLockValidatorRecSharedCreate(PRTLOCKVALRECSHRD *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
- void *pvLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, ...);
+ void *pvLock, bool fSignaller, bool fEnabled,
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(7, 8);
/**
* Create and initialize a lock validator record for a shared lock.
* @param va Format string arguments.
*/
RTDECL(int) RTLockValidatorRecSharedCreateV(PRTLOCKVALRECSHRD *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
- void *pvLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, va_list va);
+ void *pvLock, bool fSignaller, bool fEnabled,
+ const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(7, 0);
/**
* Deinitialize and destroy a record created by RTLockValidatorRecSharedCreate.
* @param hThreadSelf The handle of the calling thread. If not known,
* pass NIL_RTTHREAD and we'll figure it out.
* @param pSrcPos The source position of the lock operation.
+ * @param cMillies Intended sleep time in milliseconds.
*/
RTDECL(int) RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies);
* @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
* @param pSrcPos The source position of the lock operation.
* @param fRecursiveOk Whether it's ok to recurse.
+ * @param cMillies Intended sleep time in milliseconds.
* @param enmSleepState The sleep state to enter on successful return.
* @param fReallySleeping Is it really going to sleep now or not. Use
* false before calls to other IPRT synchronization
* @param hThreadSelf The current thread. Shall not be NIL_RTTHREAD!
* @param pSrcPos The source position of the lock operation.
* @param fRecursiveOk Whether it's ok to recurse.
+ * @param cMillies Intended sleep time in milliseconds.
* @param enmSleepState The sleep state to enter on successful return.
* @param fReallySleeping Is it really going to sleep now or not. Use
* false before calls to other IPRT synchronization
RTDECL(int) RTLockValidatorClassCreateEx(PRTLOCKVALCLASS phClass, PCRTLOCKVALSRCPOS pSrcPos,
bool fAutodidact, bool fRecursionOk, bool fStrictReleaseOrder,
RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder,
- const char *pszNameFmt, ...);
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(8, 9);
/**
* Creates a new lock validator class, all properties specified.
RTDECL(int) RTLockValidatorClassCreateExV(PRTLOCKVALCLASS phClass, PCRTLOCKVALSRCPOS pSrcPos,
bool fAutodidact, bool fRecursionOk, bool fStrictReleaseOrder,
RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder,
- const char *pszNameFmt, va_list va);
+ const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(8, 0);
/**
* Creates a new lock validator class.
* @param fAutodidact Whether the class should be allowed to teach
* itself new locking order rules (true), or if the
* user will teach it all it needs to know (false).
- * @param pszFile The source position of the call, file.
- * @param iLine The source position of the call, line.
- * @param pszFunction The source position of the call, function.
+ * @param SRC_POS The source position where call is being made from.
+ * Use RT_SRC_POS when possible. Optional.
* @param pszNameFmt Class name format string, optional (NULL). Max
* length is 32 bytes.
* @param ... Format string arguments.
*/
-RTDECL(int) RTLockValidatorClassCreate(PRTLOCKVALCLASS phClass, bool fAutodidact, RT_SRC_POS_DECL, const char *pszNameFmt, ...);
+RTDECL(int) RTLockValidatorClassCreate(PRTLOCKVALCLASS phClass, bool fAutodidact, RT_SRC_POS_DECL,
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(6, 7);
/**
* Creates a new lock validator class with a reference that is consumed by the
* @returns Class handle with a reference that is automatically consumed by the
* first retainer. NIL_RTLOCKVALCLASS if we run into trouble.
*
- * @param pszFile The source position of the call, file.
- * @param iLine The source position of the call, line.
- * @param pszFunction The source position of the call, function.
+ * @param SRC_POS The source position where call is being made from.
+ * Use RT_SRC_POS when possible. Optional.
* @param pszNameFmt Class name format string, optional (NULL). Max
* length is 32 bytes.
* @param ... Format string arguments.
*/
-RTDECL(RTLOCKVALCLASS) RTLockValidatorClassCreateUnique(RT_SRC_POS_DECL, const char *pszNameFmt, ...);
+RTDECL(RTLOCKVALCLASS) RTLockValidatorClassCreateUnique(RT_SRC_POS_DECL,
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(4, 5);
/**
* Finds a class for the specified source position.
* Finds or creates a class given the source position.
*
* @returns Class handle (not retained!) or NIL_RTLOCKVALCLASS.
- * @param pszFile The source file.
- * @param iLine The line in that source file.
- * @param pszFunction The function name.
+ * @param SRC_POS The source position where call is being made from.
+ * Use RT_SRC_POS when possible. Optional.
* @param pszNameFmt Class name format string, optional (NULL). Max
* length is 32 bytes.
* @param ... Format string arguments.
*/
-RTDECL(RTLOCKVALCLASS) RTLockValidatorClassForSrcPos(RT_SRC_POS_DECL, const char *pszNameFmt, ...);
+RTDECL(RTLOCKVALCLASS) RTLockValidatorClassForSrcPos(RT_SRC_POS_DECL,
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(4, 5);
/**
* Retains a reference to a lock validator class.
/**
* Teaches the class @a hClass that locks in the class @a hPriorClass can be
- * held when taking a lock of class @hClass
+ * held when taking a lock of class @a hClass
*
* @returns IPRT status.
* @param hClass Handle to the pupil class.
*
* @returns IPRT status.
* @param hClass Handle to the class to change.
- * @param fEnable Enable it (true) or disable it (false).
+ * @param fEnabled Enable it (true) or disable it (false).
*/
RTDECL(int) RTLockValidatorClassEnforceStrictReleaseOrder(RTLOCKVALCLASS hClass, bool fEnabled);
{
/** Default logging group. */
RTLOGGROUP_DEFAULT,
+ RTLOGGROUP_CRYPTO,
RTLOGGROUP_DBG,
RTLOGGROUP_DBG_DWARF,
RTLOGGROUP_DIR,
RTLOGGROUP_FILE,
RTLOGGROUP_FS,
+ RTLOGGROUP_HTTP,
RTLOGGROUP_LDR,
RTLOGGROUP_PATH,
RTLOGGROUP_PROCESS,
*/
#define RT_LOGGROUP_NAMES \
"DEFAULT", \
+ "RT_CRYPTO", \
"RT_DBG", \
"RT_DBG_DWARF", \
"RT_DIR", \
"RT_FILE", \
"RT_FS", \
+ "RT_HTTP", \
"RT_LDR", \
"RT_PATH", \
"RT_PROCESS", \
"RT_THREAD", \
"RT_TIME", \
"RT_TIMER", \
- "RT_13", \
- "RT_14", \
"RT_15", \
"RT_16", \
"RT_17", \
* @param pszFormat Format string.
* @param ... Optional arguments as specified in the format string.
*/
-typedef DECLCALLBACK(void) FNRTLOGGER(const char *pszFormat, ...);
+typedef DECLCALLBACK(void) FNRTLOGGER(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/** Pointer to logger function. */
typedef FNRTLOGGER *PFNRTLOGGER;
* @param pszFormat Format string.
* @param ... Optional arguments specified in the format string.
*/
-typedef DECLCALLBACK(void) FNRTLOGPHASEMSG(PRTLOGGER pLogger, const char *pszFormat, ...);
+typedef DECLCALLBACK(void) FNRTLOGPHASEMSG(PRTLOGGER pLogger, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3);
/** Pointer to header/footer message callback function. */
typedef FNRTLOGPHASEMSG *PFNRTLOGPHASEMSG;
} RTLOGDEST;
-RTDECL(void) RTLogPrintfEx(void *pvInstance, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
+RTDECL(void) RTLogPrintfEx(void *pvInstance, unsigned fFlags, unsigned iGroup,
+ const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5);
#ifdef DOXYGEN_RUNNING
#ifdef LOG_USE_C99
# define LogFunc(a) _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define LogFunc(a) do { Log((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log(a); } while (0)
+# define LogFunc(a) do { Log((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
#endif
/** @def Log2Func
#ifdef LOG_USE_C99
# define Log2Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log2Func(a) do { Log2((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log2(a); } while (0)
+# define Log2Func(a) do { Log2((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log2(a); } while (0)
#endif
/** @def Log3Func
#ifdef LOG_USE_C99
# define Log3Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log3Func(a) do { Log3((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log3(a); } while (0)
+# define Log3Func(a) do { Log3((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log3(a); } while (0)
#endif
/** @def Log4Func
#ifdef LOG_USE_C99
# define Log4Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log4Func(a) do { Log4((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log4(a); } while (0)
+# define Log4Func(a) do { Log4((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log4(a); } while (0)
#endif
/** @def Log5Func
#ifdef LOG_USE_C99
# define Log5Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log5Func(a) do { Log5((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log5(a); } while (0)
+# define Log5Func(a) do { Log5((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log5(a); } while (0)
#endif
/** @def Log6Func
#ifdef LOG_USE_C99
# define Log6Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log6Func(a) do { Log6((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log6(a); } while (0)
+# define Log6Func(a) do { Log6((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log6(a); } while (0)
#endif
/** @def Log7Func
#ifdef LOG_USE_C99
# define Log7Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log7Func(a) do { Log7((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log7(a); } while (0)
+# define Log7Func(a) do { Log7((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log7(a); } while (0)
#endif
/** @def Log8Func
#ifdef LOG_USE_C99
# define Log8Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log8Func(a) do { Log8((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log8(a); } while (0)
+# define Log8Func(a) do { Log8((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log8(a); } while (0)
#endif
/** @def Log9Func
#ifdef LOG_USE_C99
# define Log9Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log9Func(a) do { Log9((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log9(a); } while (0)
+# define Log9Func(a) do { Log9((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log9(a); } while (0)
#endif
/** @def Log10Func
#ifdef LOG_USE_C99
# define Log10Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log10Func(a) do { Log10((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log10(a); } while (0)
+# define Log10Func(a) do { Log10((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log10(a); } while (0)
#endif
/** @def Log11Func
#ifdef LOG_USE_C99
# define Log11Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log11Func(a) do { Log11((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log11(a); } while (0)
+# define Log11Func(a) do { Log11((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log11(a); } while (0)
#endif
/** @def Log12Func
#ifdef LOG_USE_C99
# define Log12Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define Log12Func(a) do { Log12((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log12(a); } while (0)
+# define Log12Func(a) do { Log12((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log12(a); } while (0)
#endif
/** @def LogFlowFunc
_LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
# define LogFlowFunc(a) \
- do { LogFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
+ do { LogFlow((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
#endif
/** @def LogWarnFunc
/** @name Misc Logging Macros
* @{ */
-/** @def LogWarning1
+/** @def Log1Warning
* The same as Log(), but prepents a <tt>"WARNING! "</tt> string to the message.
*
* @param a Custom log message in format <tt>("string\n" [, args])</tt>.
# define Log1Warning(a) do { Log(("WARNING! ")); Log(a); } while (0)
#endif
-/** @def LogWarningFunc
+/** @def Log1WarningFunc
* The same as LogWarning(), but prepents the log message with the function name.
*
* @param a Log message in format <tt>("string\n" [, args])</tt>.
do { Log((LOG_FN_FMT ": WARNING! ", __PRETTY_FUNCTION__)); Log(a); } while (0)
#endif
-/** @def LogWarningThisFunc
+/** @def Log1WarningThisFunc
* The same as LogWarningFunc() but for class functions (methods): the resulting
* log line is additionally prepended with a hex value of |this| pointer.
*
# define LogRelFunc(a) \
_LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
#else
-# define LogRelFunc(a) do { LogRel((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRel(a); } while (0)
+# define LogRelFunc(a) do { LogRel((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRel(a); } while (0)
#endif
/** @def LogRelFlowFunc
* @param ... Format arguments.
* @remark This is a worker function for LogRelIt.
*/
-RTDECL(void) RTLogRelLogger(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
+RTDECL(void) RTLogRelLogger(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
+ const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5);
/**
* Write to a logger instance, defaulting to the release one.
* @param pszFormat Format string.
* @param args Format arguments.
*/
-RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args);
+RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
+ const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(4, 0);
/**
* printf like function for writing to the default release log.
*
* @remark The API doesn't support formatting of floating point numbers at the moment.
*/
-RTDECL(void) RTLogRelPrintf(const char *pszFormat, ...);
+RTDECL(void) RTLogRelPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/**
* vprintf like function for writing to the default release log.
*
* @remark The API doesn't support formatting of floating point numbers at the moment.
*/
-RTDECL(void) RTLogRelPrintfV(const char *pszFormat, va_list args);
+RTDECL(void) RTLogRelPrintfV(const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(1, 0);
/**
* Changes the buffering setting of the default release logger.
*/
RTDECL(int) RTLogCreate(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
- uint32_t fDestFlags, const char *pszFilenameFmt, ...);
+ uint32_t fDestFlags, const char *pszFilenameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(8, 9);
/**
* Create a logger instance.
RTDECL(int) RTLogCreateEx(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
- uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
- char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...);
+ uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot, char *pszErrorMsg, size_t cchErrorMsg,
+ const char *pszFilenameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(14, 15);
/**
* Create a logger instance.
RTDECL(int) RTLogCreateExV(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
- uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
- char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args);
+ uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot, char *pszErrorMsg, size_t cchErrorMsg,
+ const char *pszFilenameFmt, va_list args) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(14, 0);
/**
* Create a logger instance for singled threaded ring-0 usage.
* @param pszFormat Format string.
* @param ... Format arguments.
*/
-RTDECL(void) RTLogLogger(PRTLOGGER pLogger, void *pvCallerRet, const char *pszFormat, ...);
+RTDECL(void) RTLogLogger(PRTLOGGER pLogger, void *pvCallerRet, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
/**
* Write to a logger instance.
* @param pszFormat Format string.
* @param args Format arguments.
*/
-RTDECL(void) RTLogLoggerV(PRTLOGGER pLogger, const char *pszFormat, va_list args);
+RTDECL(void) RTLogLoggerV(PRTLOGGER pLogger, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(3, 0);
/**
* Write to a logger instance.
* @param ... Format arguments.
* @remark This is a worker function of LogIt.
*/
-RTDECL(void) RTLogLoggerEx(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
+RTDECL(void) RTLogLoggerEx(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
+ const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5);
/**
* Write to a logger instance.
* @param pszFormat Format string.
* @param args Format arguments.
*/
-RTDECL(void) RTLogLoggerExV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args);
+RTDECL(void) RTLogLoggerExV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
+ const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(4, 0);
/**
* printf like function for writing to the default log.
*
* @remark The API doesn't support formatting of floating point numbers at the moment.
*/
-RTDECL(void) RTLogPrintf(const char *pszFormat, ...);
+RTDECL(void) RTLogPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/**
* vprintf like function for writing to the default log.
*
* @param pszFormat Printf like format string.
- * @param args Optional arguments as specified in pszFormat.
+ * @param va Optional arguments as specified in pszFormat.
*
* @remark The API doesn't support formatting of floating point numbers at the moment.
*/
-RTDECL(void) RTLogPrintfV(const char *pszFormat, va_list args);
+RTDECL(void) RTLogPrintfV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
/**
* Dumper vprintf-like function outputting to a logger.
* @param pszFormat Format string.
* @param va Format arguments.
*/
-RTDECL(void) RTLogDumpPrintfV(void *pvUser, const char *pszFormat, va_list va);
+RTDECL(void) RTLogDumpPrintfV(void *pvUser, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
#ifndef DECLARED_FNRTSTROUTPUT /* duplicated in iprt/string.h */
* @param pszFormat Format string.
* @param args Argument list.
*/
-RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArg, const char *pszFormat, va_list args);
+RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArg, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(3, 0);
/**
* Write log buffer to COM port.
* @param pszFormat Format string.
* @param ... Optional arguments specified in the format string.
*/
-RTDECL(size_t) RTLogComPrintf(const char *pszFormat, ...);
+RTDECL(size_t) RTLogComPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/**
* Prints a formatted string to the serial port used for logging.
* @param pszFormat Format string.
* @param args Optional arguments specified in the format string.
*/
-RTDECL(size_t) RTLogComPrintfV(const char *pszFormat, va_list args);
+RTDECL(size_t) RTLogComPrintfV(const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(1, 0);
#if 0 /* not implemented yet */
* @param pszFormat Format string.
* @param ... Optional arguments specified in the format string.
*/
-RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat, ...);
+RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
/**
* Prints a formatted string to the backdoor port.
* @param pszFormat Format string.
* @param args Optional arguments specified in the format string.
*/
-RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat, va_list args);
+RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(1, 0);
#endif /* VBOX */
# define RTDvmVolumeCreateVfsFile RT_MANGLER(RTDvmVolumeCreateVfsFile)
# define RTEnvApplyChanges RT_MANGLER(RTEnvApplyChanges)
# define RTEnvClone RT_MANGLER(RTEnvClone)
+# define RTEnvCloneUtf16Block RT_MANGLER(RTEnvCloneUtf16Block)
# define RTEnvCountEx RT_MANGLER(RTEnvCountEx)
# define RTEnvCreate RT_MANGLER(RTEnvCreate)
# define RTEnvCreateChangeRecord RT_MANGLER(RTEnvCreateChangeRecord)
# define RTFileOpenBitBucket RT_MANGLER(RTFileOpenBitBucket)
# define RTFileOpenF RT_MANGLER(RTFileOpenF)
# define RTFileOpenV RT_MANGLER(RTFileOpenV)
+# define RTFileOpenTemp RT_MANGLER(RTFileOpenTemp)
# define RTFileQueryFsSizes RT_MANGLER(RTFileQueryFsSizes)
# define RTFileQueryInfo RT_MANGLER(RTFileQueryInfo)
# define RTFileQuerySize RT_MANGLER(RTFileQuerySize)
# define RTFileWrite RT_MANGLER(RTFileWrite)
# define RTFileWriteAt RT_MANGLER(RTFileWriteAt)
# define RTFilesystemVfsFromFile RT_MANGLER(RTFilesystemVfsFromFile)
+# define RTFsIsCaseSensitive RT_MANGLER(RTFsIsCaseSensitive)
# define RTFsQueryProperties RT_MANGLER(RTFsQueryProperties)
# define RTFsQuerySerial RT_MANGLER(RTFsQuerySerial)
# define RTFsQuerySizes RT_MANGLER(RTFsQuerySizes)
# define RTNetUDPChecksum RT_MANGLER(RTNetUDPChecksum)
# define RTNetStrToMacAddr RT_MANGLER(RTNetStrToMacAddr)
# define RTNetIsIPv4AddrStr RT_MANGLER(RTNetIsIPv4AddrStr)
+# define RTNetStrIsIPv4AddrAny RT_MANGLER(RTNetStrIsIPv4AddrAny)
# define RTNetStrToIPv4AddrEx RT_MANGLER(RTNetStrToIPv4AddrEx)
# define RTNetStrToIPv4Addr RT_MANGLER(RTNetStrToIPv4Addr)
# define RTNetIsIPv6AddrStr RT_MANGLER(RTNetIsIPv6AddrStr)
+# define RTNetStrIsIPv6AddrAny RT_MANGLER(RTNetStrIsIPv6AddrAny)
# define RTNetStrToIPv6AddrEx RT_MANGLER(RTNetStrToIPv6AddrEx)
# define RTNetStrToIPv6Addr RT_MANGLER(RTNetStrToIPv6Addr)
# define RTOnceSlow RT_MANGLER(RTOnceSlow)
# define RTPathCompare RT_MANGLER(RTPathCompare)
# define RTPathCopyComponents RT_MANGLER(RTPathCopyComponents)
# define RTPathCountComponents RT_MANGLER(RTPathCountComponents)
+# define RTPathEnsureTrailingSeparator RT_MANGLER(RTPathEnsureTrailingSeparator)
# define RTPathExecDir RT_MANGLER(RTPathExecDir)
# define RTPathExists RT_MANGLER(RTPathExists)
# define RTPathExistsEx RT_MANGLER(RTPathExistsEx)
# define RTPathGetCurrentDrive RT_MANGLER(RTPathGetCurrentDrive)
# define RTPathGetCurrentOnDrive RT_MANGLER(RTPathGetCurrentOnDrive)
# define RTPathGetMode RT_MANGLER(RTPathGetMode)
+# define RTPathGlob RT_MANGLER(RTPathGlob)
+# define RTPathGlobFree RT_MANGLER(RTPathGlobFree)
# define RTPathHasSuffix RT_MANGLER(RTPathHasSuffix)
# define RTPathHasPath RT_MANGLER(RTPathHasPath)
# define RTPathIsSame RT_MANGLER(RTPathIsSame)
# define RTPipeCreate RT_MANGLER(RTPipeCreate)
# define RTPipeFlush RT_MANGLER(RTPipeFlush)
# define RTPipeFromNative RT_MANGLER(RTPipeFromNative)
+# define RTPipeQueryInfo RT_MANGLER(RTPipeQueryInfo)
# define RTPipeQueryReadable RT_MANGLER(RTPipeQueryReadable)
# define RTPipeRead RT_MANGLER(RTPipeRead)
# define RTPipeReadBlocking RT_MANGLER(RTPipeReadBlocking)
# define RTR0AssertPanicSystem RT_MANGLER(RTR0AssertPanicSystem) /* r0drv */
# define RTR0DbgKrnlInfoOpen RT_MANGLER(RTR0DbgKrnlInfoOpen) /* r0drv */
# define RTR0DbgKrnlInfoQueryMember RT_MANGLER(RTR0DbgKrnlInfoQueryMember) /* r0drv */
+# define RTR0DbgKrnlInfoQuerySize RT_MANGLER(RTR0DbgKrnlInfoQuerySize) /* r0drv */
# define RTR0DbgKrnlInfoQuerySymbol RT_MANGLER(RTR0DbgKrnlInfoQuerySymbol) /* r0drv */
# define RTR0DbgKrnlInfoRelease RT_MANGLER(RTR0DbgKrnlInfoRelease) /* r0drv */
# define RTR0DbgKrnlInfoRetain RT_MANGLER(RTR0DbgKrnlInfoRetain) /* r0drv */
# define RTSgBufSet RT_MANGLER(RTSgBufSet)
# define RTSgBufGetNextSegment RT_MANGLER(RTSgBufGetNextSegment)
# define RTSha1 RT_MANGLER(RTSha1)
+# define RTSha1Check RT_MANGLER(RTSha1Check)
# define RTSha1Digest RT_MANGLER(RTSha1Digest)
# define RTSha1DigestFromFile RT_MANGLER(RTSha1DigestFromFile)
# define RTSha1Final RT_MANGLER(RTSha1Final)
# define RTSha1ToString RT_MANGLER(RTSha1ToString)
# define RTSha1Update RT_MANGLER(RTSha1Update)
# define RTSha224 RT_MANGLER(RTSha224)
+# define RTSha224Check RT_MANGLER(RTSha224Check)
# define RTSha224Final RT_MANGLER(RTSha224Final)
# define RTSha224FromString RT_MANGLER(RTSha224FromString)
# define RTSha224Init RT_MANGLER(RTSha224Init)
# define RTSha224Digest RT_MANGLER(RTSha224Digest)
# define RTSha224DigestFromFile RT_MANGLER(RTSha224DigestFromFile)
# define RTSha256 RT_MANGLER(RTSha256)
+# define RTSha256Check RT_MANGLER(RTSha256Check)
# define RTSha256Final RT_MANGLER(RTSha256Final)
# define RTSha256FromString RT_MANGLER(RTSha256FromString)
# define RTSha256Init RT_MANGLER(RTSha256Init)
# define RTSha256Digest RT_MANGLER(RTSha256Digest)
# define RTSha256DigestFromFile RT_MANGLER(RTSha256DigestFromFile)
# define RTSha384 RT_MANGLER(RTSha384)
+# define RTSha384Check RT_MANGLER(RTSha384Check)
# define RTSha384Final RT_MANGLER(RTSha384Final)
# define RTSha384FromString RT_MANGLER(RTSha384FromString)
# define RTSha384Init RT_MANGLER(RTSha384Init)
# define RTSha384ToString RT_MANGLER(RTSha384ToString)
# define RTSha384Update RT_MANGLER(RTSha384Update)
# define RTSha512 RT_MANGLER(RTSha512)
+# define RTSha512Check RT_MANGLER(RTSha512Check)
# define RTSha512Final RT_MANGLER(RTSha512Final)
# define RTSha512FromString RT_MANGLER(RTSha512FromString)
# define RTSha512Init RT_MANGLER(RTSha512Init)
# define RTSha512ToString RT_MANGLER(RTSha512ToString)
# define RTSha512Update RT_MANGLER(RTSha512Update)
# define RTSha512t224 RT_MANGLER(RTSha512t224)
+# define RTSha512t224Check RT_MANGLER(RTSha512t224Check)
# define RTSha512t224Final RT_MANGLER(RTSha512t224Final)
# define RTSha512t224FromString RT_MANGLER(RTSha512t224FromString)
# define RTSha512t224Init RT_MANGLER(RTSha512t224Init)
# define RTSha512t224ToString RT_MANGLER(RTSha512t224ToString)
# define RTSha512t224Update RT_MANGLER(RTSha512t224Update)
# define RTSha512t256 RT_MANGLER(RTSha512t256)
+# define RTSha512t256Check RT_MANGLER(RTSha512t256Check)
# define RTSha512t256Final RT_MANGLER(RTSha512t256Final)
# define RTSha512t256FromString RT_MANGLER(RTSha512t256FromString)
# define RTSha512t256Init RT_MANGLER(RTSha512t256Init)
# define RTSymlinkIsDangling RT_MANGLER(RTSymlinkIsDangling)
# define RTSymlinkRead RT_MANGLER(RTSymlinkRead)
# define RTSymlinkReadA RT_MANGLER(RTSymlinkReadA)
+# define RTSystemIsInsideVM RT_MANGLER(RTSystemIsInsideVM)
# define RTSystemQueryAvailableRam RT_MANGLER(RTSystemQueryAvailableRam)
# define RTSystemQueryDmiString RT_MANGLER(RTSystemQueryDmiString)
# define RTSystemQueryOSInfo RT_MANGLER(RTSystemQueryOSInfo)
# define RTUdpServerShutdown RT_MANGLER(RTUdpServerShutdown)
# define RTUdpWrite RT_MANGLER(RTUdpWrite)
# define RTUniFree RT_MANGLER(RTUniFree)
-# define RTUriAuthority RT_MANGLER(RTUriAuthority)
# define RTUriCreate RT_MANGLER(RTUriCreate)
# define RTUriFileCreate RT_MANGLER(RTUriFileCreate)
-# define RTUriFileNPath RT_MANGLER(RTUriFileNPath)
+# define RTUriFileCreateEx RT_MANGLER(RTUriFileCreateEx)
# define RTUriFilePath RT_MANGLER(RTUriFilePath)
-# define RTUriFragment RT_MANGLER(RTUriFragment)
-# define RTUriHasScheme RT_MANGLER(RTUriHasScheme)
-# define RTUriPath RT_MANGLER(RTUriPath)
-# define RTUriQuery RT_MANGLER(RTUriQuery)
-# define RTUriScheme RT_MANGLER(RTUriScheme)
+# define RTUriFilePathEx RT_MANGLER(RTUriFilePathEx)
+# define RTUriParse RT_MANGLER(RTUriParse)
+# define RTUriParsedAuthority RT_MANGLER(RTUriParsedAuthority)
+# define RTUriParsedAuthorityHost RT_MANGLER(RTUriParsedAuthorityHost)
+# define RTUriParsedAuthorityPassword RT_MANGLER(RTUriParsedAuthorityPassword)
+# define RTUriParsedAuthorityPort RT_MANGLER(RTUriParsedAuthorityPort)
+# define RTUriParsedAuthorityUsername RT_MANGLER(RTUriParsedAuthorityUsername)
+# define RTUriParsedFragment RT_MANGLER(RTUriParsedFragment)
+# define RTUriParsedPath RT_MANGLER(RTUriParsedPath)
+# define RTUriParsedScheme RT_MANGLER(RTUriParsedScheme)
+# define RTUriParsedQuery RT_MANGLER(RTUriParsedQuery)
+# define RTUriIsSchemeMatch RT_MANGLER(RTUriIsSchemeMatch)
# define RTUtf16AllocTag RT_MANGLER(RTUtf16AllocTag)
# define RTUtf16CalcLatin1Len RT_MANGLER(RTUtf16CalcLatin1Len)
# define RTUtf16CalcLatin1LenEx RT_MANGLER(RTUtf16CalcLatin1LenEx)
# define RTVfsIoStreamToPrivate RT_MANGLER(RTVfsIoStreamToPrivate)
# define RTVfsIoStrmFlush RT_MANGLER(RTVfsIoStrmFlush)
# define RTVfsIoStrmFromRTFile RT_MANGLER(RTVfsIoStrmFromRTFile)
+# define RTVfsIoStrmFromRTPipe RT_MANGLER(RTVfsIoStrmFromRTPipe)
# define RTVfsIoStrmFromStdHandle RT_MANGLER(RTVfsIoStrmFromStdHandle)
# define RTVfsIoStrmIsAtEnd RT_MANGLER(RTVfsIoStrmIsAtEnd)
# define RTVfsIoStrmOpenNormal RT_MANGLER(RTVfsIoStrmOpenNormal)
# define RTCrRsaPrivateKey_CheckSanity RT_MANGLER(RTCrRsaPrivateKey_CheckSanity)
# define RTCrRsaPublicKey_CheckSanity RT_MANGLER(RTCrRsaPublicKey_CheckSanity)
# define RTCrPemFreeSections RT_MANGLER(RTCrPemFreeSections)
+# define RTCrPemParseContent RT_MANGLER(RTCrPemParseContent)
# define RTCrPemReadFile RT_MANGLER(RTCrPemReadFile)
# define RTCrPkcs7Attribute_DecodeAsn1 RT_MANGLER(RTCrPkcs7Attribute_DecodeAsn1)
# define RTCrPkcs7Attributes_DecodeAsn1 RT_MANGLER(RTCrPkcs7Attributes_DecodeAsn1)
# define RTCrCertCtxRetain RT_MANGLER(RTCrCertCtxRetain)
# define RTCrStoreCertAddEncoded RT_MANGLER(RTCrStoreCertAddEncoded)
# define RTCrStoreCertByIssuerAndSerialNo RT_MANGLER(RTCrStoreCertByIssuerAndSerialNo)
+# define RTCrStoreCertCount RT_MANGLER(RTCrStoreCertCount)
# define RTCrStoreCertFindAll RT_MANGLER(RTCrStoreCertFindAll)
# define RTCrStoreCertFindBySubjectOrAltSubjectByRfc5280 RT_MANGLER(RTCrStoreCertFindBySubjectOrAltSubjectByRfc5280)
# define RTCrStoreCertSearchDestroy RT_MANGLER(RTCrStoreCertSearchDestroy)
# define RTCrStoreRelease RT_MANGLER(RTCrStoreRelease)
# define RTCrStoreRetain RT_MANGLER(RTCrStoreRetain)
# define RTCrStoreCreateInMem RT_MANGLER(RTCrStoreCreateInMem)
+# define RTCrStoreCreateSnapshotById RT_MANGLER(RTCrStoreCreateSnapshotById)
+# define RTCrStoreCertAddFromDir RT_MANGLER(RTCrStoreCertAddFromDir)
# define RTCrStoreCertAddFromFile RT_MANGLER(RTCrStoreCertAddFromFile)
+# define RTCrStoreCertAddFromJavaKeyStore RT_MANGLER(RTCrStoreCertAddFromJavaKeyStore)
+# define RTCrStoreCertAddFromJavaKeyStoreInMem RT_MANGLER(RTCrStoreCertAddFromJavaKeyStoreInMem)
+# define RTCrStoreCertAddFromStore RT_MANGLER(RTCrStoreCertAddFromStore)
+# define RTCrStoreCertAddWantedFromDir RT_MANGLER(RTCrStoreCertAddWantedFromDir)
+# define RTCrStoreCertAddWantedFromFile RT_MANGLER(RTCrStoreCertAddWantedFromFile)
+# define RTCrStoreCertAddWantedFromStore RT_MANGLER(RTCrStoreCertAddWantedFromStore)
+# define RTCrStoreCertAddWantedFromFishingExpedition RT_MANGLER(RTCrStoreCertAddWantedFromFishingExpedition)
+# define RTCrStoreCertCheckWanted RT_MANGLER(RTCrStoreCertCheckWanted)
+# define RTCrStoreCertExportAsPem RT_MANGLER(RTCrStoreCertExportAsPem)
# define RTErrInfoAdd RT_MANGLER(RTErrInfoAdd)
# define RTErrInfoAddF RT_MANGLER(RTErrInfoAddF)
# define RTErrInfoAddV RT_MANGLER(RTErrInfoAddV)
* @param cb Size in bytes of the memory block to allocated.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Allocates zero'd temporary memory with default tag.
* @param cb Size in bytes of the memory block to allocated.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Free temporary memory.
*
* @param pv Pointer to memory block.
*/
-RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW;
+RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW_PROTO;
/** @} */
* @returns Pointer to the allocated memory.
* @returns NULL on failure, assertion raised in strict builds.
* @param cb Size in bytes of the memory block to allocated.
- * @param pszTag Allocation tag used for statistics and such.
*/
#define RTMemAlloc(cb) RTMemAllocTag((cb), RTMEM_TAG)
* @param cb Size in bytes of the memory block to allocated.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Allocates zero'd memory with default tag.
* @param cb Size in bytes of the memory block to allocated.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Wrapper around RTMemAlloc for automatically aligning variable sized
* @param cbUnaligned The unaligned size.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Wrapper around RTMemAllocZ for automatically aligning variable sized
* @param cbUnaligned The unaligned size.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Duplicates a chunk of memory into a new heap block (default tag).
* @param cb The amount of memory to duplicate.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Duplicates a chunk of memory into a new heap block with some additional
* @param cbExtra The amount of extra memory to allocate and zero.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Reallocates memory with default tag.
* @param cbNew The new block size (in bytes).
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Frees memory.
*
* @param pv Pointer to memory block.
*/
-RTDECL(void) RTMemFree(void *pv) RT_NO_THROW;
+RTDECL(void) RTMemFree(void *pv) RT_NO_THROW_PROTO;
-/** @def RTR0MemAllocEx and RTR0MemAllocExTag flags.
+/** @name RTR0MemAllocEx and RTR0MemAllocExTag flags.
* @{ */
/** The returned memory should be zeroed. */
#define RTMEMALLOCEX_FLAGS_ZEROED RT_BIT(0)
* @param pszTag The tag.
* @param ppv Where to return the memory.
*/
-RTDECL(int) RTMemAllocExTag(size_t cb, size_t cbAlignment, uint32_t fFlags, const char *pszTag, void **ppv) RT_NO_THROW;
+RTDECL(int) RTMemAllocExTag(size_t cb, size_t cbAlignment, uint32_t fFlags, const char *pszTag, void **ppv) RT_NO_THROW_PROTO;
/**
* For freeing memory allocated by RTMemAllocEx or RTMemAllocExTag.
*
* @param pv What to free, NULL is fine.
* @param cb The amount of allocated memory.
- * @param fFlags The flags specified when allocating the memory.
- * Whether the exact flags are requires depends on
- * the implementation, but in general, ring-0
- * doesn't require anything while ring-3 requires
- * RTMEMALLOCEX_FLAGS_EXEC if used.
*/
-RTDECL(void) RTMemFreeEx(void *pv, size_t cb) RT_NO_THROW;
+RTDECL(void) RTMemFreeEx(void *pv, size_t cb) RT_NO_THROW_PROTO;
* @param cb Size in bytes of the memory block to allocate.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Free executable/read/write memory allocated by RTMemExecAlloc().
* @param pv Pointer to memory block.
* @param cb The allocation size.
*/
-RTDECL(void) RTMemExecFree(void *pv, size_t cb) RT_NO_THROW;
+RTDECL(void) RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_PROTO;
#if defined(IN_RING0) && defined(RT_ARCH_AMD64) && defined(RT_OS_LINUX)
/**
* @param pvMemory Pointer to the memory block.
* @param cb The size of the memory block.
*/
-RTR0DECL(int) RTR0MemExecDonate(void *pvMemory, size_t cb) RT_NO_THROW;
+RTR0DECL(int) RTR0MemExecDonate(void *pvMemory, size_t cb) RT_NO_THROW_PROTO;
#endif /* R0+AMD64+LINUX */
/**
* @param cb Size of the memory block. Will be rounded up to page size.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Allocate zero'd page aligned memory with default tag.
* @param cb Size of the memory block. Will be rounded up to page size.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Free a memory block allocated with RTMemPageAlloc() or RTMemPageAllocZ().
* @param cb The allocation size. Will be rounded up to page size.
* Ignored if @a pv is NULL.
*/
-RTDECL(void) RTMemPageFree(void *pv, size_t cb) RT_NO_THROW;
+RTDECL(void) RTMemPageFree(void *pv, size_t cb) RT_NO_THROW_PROTO;
/** Page level protection flags for RTMemProtect().
* @{
* @param cb Size of the region. Will be rounded up to the nearest page boundary.
* @param fProtect The new protection, a combination of the RTMEM_PROT_* defines.
*/
-RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect) RT_NO_THROW;
+RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect) RT_NO_THROW_PROTO;
/**
* Goes thru some pains to make sure the specified memory block is thoroughly
* @param cb The size of the memory block.
* @param cMinPasses The minimum number of passes to make.
*/
-RTDECL(void) RTMemWipeThoroughly(void *pv, size_t cb, size_t cMinPasses) RT_NO_THROW;
+RTDECL(void) RTMemWipeThoroughly(void *pv, size_t cb, size_t cMinPasses) RT_NO_THROW_PROTO;
#ifdef IN_RING0
* @param cb The allocation size in bytes. This is always
* rounded up to PAGE_SIZE.
*/
-RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb) RT_NO_THROW;
+RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb) RT_NO_THROW_PROTO;
/**
* Frees memory allocated ysing RTMemContAlloc().
* @param pv Pointer to return from RTMemContAlloc().
* @param cb The cb parameter passed to RTMemContAlloc().
*/
-RTR0DECL(void) RTMemContFree(void *pv, size_t cb) RT_NO_THROW;
+RTR0DECL(void) RTMemContFree(void *pv, size_t cb) RT_NO_THROW_PROTO;
/**
* Copy memory from an user mode buffer into a kernel buffer.
* @returns NULL on failure.
* @param cb Size in bytes of the memory block to allocate.
* @param pszTag Allocation tag used for statistics and such.
+ * @param SRC_POS The source position where call is being made from.
+ * Use RT_SRC_POS when possible. Optional.
*/
-RTDECL(void *) RTMemEfTmpAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void *) RTMemEfTmpAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Same as RTMemTmpAllocZTag() except that it's fenced.
* @returns NULL on failure.
* @param cb Size in bytes of the memory block to allocate.
* @param pszTag Allocation tag used for statistics and such.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void *) RTMemEfTmpAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void *) RTMemEfTmpAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Same as RTMemTmpFree() except that it's for fenced memory.
*
* @param pv Pointer to memory block.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void) RTMemEfTmpFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void) RTMemEfTmpFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Same as RTMemAllocTag() except that it's fenced.
* @returns NULL on failure.
* @param cb Size in bytes of the memory block to allocate.
* @param pszTag Allocation tag used for statistics and such.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void *) RTMemEfAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void *) RTMemEfAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Same as RTMemAllocZTag() except that it's fenced.
* @returns NULL on failure.
* @param cb Size in bytes of the memory block to allocate.
* @param pszTag Allocation tag used for statistics and such.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void *) RTMemEfAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void *) RTMemEfAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Same as RTMemAllocVarTag() except that it's fenced.
* @returns NULL on failure.
* @param cbUnaligned Size in bytes of the memory block to allocate.
* @param pszTag Allocation tag used for statistics and such.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void *) RTMemEfAllocVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void *) RTMemEfAllocVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Same as RTMemAllocZVarTag() except that it's fenced.
* @returns NULL on failure.
* @param cbUnaligned Size in bytes of the memory block to allocate.
* @param pszTag Allocation tag used for statistics and such.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void *) RTMemEfAllocZVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void *) RTMemEfAllocZVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Same as RTMemReallocTag() except that it's fenced.
* @param pvOld The memory block to reallocate.
* @param cbNew The new block size (in bytes).
* @param pszTag Allocation tag used for statistics and such.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void *) RTMemEfRealloc(void *pvOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void *) RTMemEfRealloc(void *pvOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Free memory allocated by any of the RTMemEf* allocators.
*
* @param pv Pointer to memory block.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void) RTMemEfFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void) RTMemEfFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Same as RTMemDupTag() except that it's fenced.
* @param pvSrc The memory to duplicate.
* @param cb The amount of memory to duplicate.
* @param pszTag Allocation tag used for statistics and such.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/**
* Same as RTMemEfDupExTag except that it's fenced.
* @param cbSrc The amount of memory to duplicate.
* @param cbExtra The amount of extra memory to allocate and zero.
* @param pszTag Allocation tag used for statistics and such.
+ * @param SRC_POS The source position where call is being made from. Use
+ * RT_SRC_POS when possible. Optional.
*/
-RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
/** @def RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF
* Define RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF to enable electric fence new and
return pv; \
throw std::bad_alloc(); \
} \
- void *operator new(size_t cb, const std::nothrow_t ¬hrow_constant) RT_NO_THROW \
+ void *operator new(size_t cb, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
{ \
NOREF(nothrow_constant); \
return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
return pv; \
throw std::bad_alloc(); \
} \
- void *operator new[](size_t cb, const std::nothrow_t ¬hrow_constant) RT_NO_THROW \
+ void *operator new[](size_t cb, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
{ \
NOREF(nothrow_constant); \
return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
} \
\
- void operator delete(void *pv) RT_NO_THROW \
+ void operator delete(void *pv) RT_NO_THROW_DEF \
{ \
RTMemEfFree(pv, RT_SRC_POS); \
} \
- void operator delete(void *pv, const std::nothrow_t ¬hrow_constant) RT_NO_THROW \
+ void operator delete(void *pv, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
{ \
NOREF(nothrow_constant); \
RTMemEfFree(pv, RT_SRC_POS); \
} \
- void operator delete[](void *pv) RT_NO_THROW \
+ void operator delete[](void *pv) RT_NO_THROW_DEF \
{ \
RTMemEfFree(pv, RT_SRC_POS); \
} \
- void operator delete[](void *pv, const std::nothrow_t ¬hrow_constant) RT_NO_THROW \
+ void operator delete[](void *pv, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
{ \
NOREF(nothrow_constant); \
RTMemEfFree(pv, RT_SRC_POS); \
* Fenced drop-in replacement for RTMemTmpAllocTag.
* @copydoc RTMemTmpAllocTag
*/
-RTDECL(void *) RTMemEfTmpAllocNP(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemEfTmpAllocNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemTmpAllocZTag.
* @copydoc RTMemTmpAllocZTag
*/
-RTDECL(void *) RTMemEfTmpAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemEfTmpAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemTmpFreeTag.
- * @copydoc RTMemTmpFreeTag
+ * @copydoc RTMemTmpFree
*/
-RTDECL(void) RTMemEfTmpFreeNP(void *pv) RT_NO_THROW;
+RTDECL(void) RTMemEfTmpFreeNP(void *pv) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemAllocTag.
* @copydoc RTMemAllocTag
*/
-RTDECL(void *) RTMemEfAllocNP(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemEfAllocNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemAllocZTag.
* @copydoc RTMemAllocZTag
*/
-RTDECL(void *) RTMemEfAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemEfAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemAllocVarTag
* @copydoc RTMemAllocVarTag
*/
-RTDECL(void *) RTMemEfAllocVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemEfAllocVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemAllocZVarTag.
* @copydoc RTMemAllocZVarTag
*/
-RTDECL(void *) RTMemEfAllocZVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemEfAllocZVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemReallocTag.
* @copydoc RTMemReallocTag
*/
-RTDECL(void *) RTMemEfReallocNP(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemEfReallocNP(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemFree.
* @copydoc RTMemFree
*/
-RTDECL(void) RTMemEfFreeNP(void *pv) RT_NO_THROW;
+RTDECL(void) RTMemEfFreeNP(void *pv) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemDupExTag.
- * @copydoc RTMemDupExTag
+ * @copydoc RTMemDupTag
*/
-RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
/**
* Fenced drop-in replacement for RTMemDupExTag.
* @copydoc RTMemDupExTag
*/
-RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW;
+RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW_PROTO;
/** @} */
* @returns VINF_SUCCESS on success, VERR_GETOPT_INVALID_ARGUMENT_FORMAT on
* failure.
*
- * @param pszValue The value to convert.
- * @param pAddr Where to store the result.
+ * @param pszAddr The address string to convert.
+ * @param pMacAddr Where to store the result.
*/
RTDECL(int) RTNetStrToMacAddr(const char *pszAddr, PRTMAC pMacAddr);
*/
RTDECL(bool) RTNetIsIPv4AddrStr(const char *pcszAddr);
+/**
+ * Tests if the given string is a wildcard IPv4 address.
+ *
+ * @returns boolean.
+ * @param pcszAddr String which may be an IPv4 address.
+ */
+RTDECL(bool) RTNetStrIsIPv4AddrAny(const char *pcszAddr);
+
/**
* Parses dotted-decimal IPv4 address into RTNETADDRIPV4 representation.
*
*/
RTDECL(bool) RTNetIsIPv6AddrStr(const char *pszAddress);
+/**
+ * Tests if the given string is a wildcard IPv6 address.
+ *
+ * @returns @c true if it is, @c false if not.
+ * @param pszAddress String which may be an IPv6 address.
+ */
+RTDECL(bool) RTNetStrIsIPv6AddrAny(const char *pszAddress);
+
/**
* Parses IPv6 address into RTNETADDRIPV6 representation.
*
*/
RTDECL(size_t) RTPathStripTrailingSlash(char *pszPath);
+/**
+ * Ensures that the path has a trailing path separator such that file names can
+ * be appended without further work.
+ *
+ * This can be helpful when preparing for efficiently combining a directory path
+ * with the filenames returned by RTDirRead. The return value gives you the
+ * position at which you copy the RTDIRENTRY::szName to construct a valid path
+ * to it.
+ *
+ * @returns The length of the path, 0 on buffer overflow.
+ * @param pszPath The path.
+ * @param cbPath The length of the path buffer @a pszPath points to.
+ */
+RTDECL(size_t) RTPathEnsureTrailingSeparator(char *pszPath, size_t cbPath);
+
/**
* Changes all the slashes in the specified path to DOS style.
*
*
* The first component is the root, volume or UNC specifier, if present. Use
* RTPATH_PROP_HAS_ROOT_SPEC() on RTPATHPARSED::fProps to determine its
- * precense.
+ * presence.
*
* Other than the root component, no component will include directory separators
* (slashes).
* @retval VERR_BUFFER_OVERFLOW if @a cbDstPath is less than or equal to
* RTPATHSPLIT::cchPath.
*
- * @param pParsed The parser output for @a pszSrcPath.
+ * @param pSplit A split path (see RTPathSplit, RTPathSplitA).
* @param fFlags Combination of RTPATH_STR_F_STYLE_XXX.
* Most users will pass 0.
* @param pszDstPath Pointer to the buffer where the path is to be
*/
RTDECL(int) RTPathTemp(char *pszPath, size_t cchPath);
+
+/**
+ * RTPathGlobl result entry.
+ */
+typedef struct RTPATHGLOBENTRY
+{
+ /** List entry. */
+ struct RTPATHGLOBENTRY *pNext;
+ /** RTDIRENTRYTYPE value. */
+ uint8_t uType;
+ /** Unused explicit padding. */
+ uint8_t bUnused;
+ /** The length of the path. */
+ uint16_t cchPath;
+ /** The path to the file (variable length). */
+ char szPath[1];
+} RTPATHGLOBENTRY;
+/** Pointer to a GLOB result entry. */
+typedef RTPATHGLOBENTRY *PRTPATHGLOBENTRY;
+/** Pointer to a const GLOB result entry. */
+typedef RTPATHGLOBENTRY const *PCRTPATHGLOBENTRY;
+/** Pointer to a GLOB result entry pointer. */
+typedef PCRTPATHGLOBENTRY *PPCRTPATHGLOBENTRY;
+
+/**
+ * Performs wildcard expansion on a path pattern.
+ *
+ * @returns IPRT status code.
+ *
+ * @param pszPattern The pattern to expand.
+ * @param fFlags RTPATHGLOB_F_XXX.
+ * @param ppHead Where to return the head of the result list. This
+ * is always set to NULL on failure.
+ * @param pcResults Where to return the number of the result. Optional.
+ */
+RTDECL(int) RTPathGlob(const char *pszPattern, uint32_t fFlags, PPCRTPATHGLOBENTRY ppHead, uint32_t *pcResults);
+
+/** @name RTPATHGLOB_F_XXX - RTPathGlob flags
+ * @{ */
+/** Case insensitive. */
+#define RTPATHGLOB_F_IGNORE_CASE RT_BIT_32(0)
+/** Do not expand \${EnvOrSpecialVariable} in the pattern. */
+#define RTPATHGLOB_F_NO_VARIABLES RT_BIT_32(1)
+/** Do not interpret a leading tilde as a home directory reference. */
+#define RTPATHGLOB_F_NO_TILDE RT_BIT_32(2)
+/** Only return the first match. */
+#define RTPATHGLOB_F_FIRST_ONLY RT_BIT_32(3)
+/** Only match directories (implied if pattern ends with slash). */
+#define RTPATHGLOB_F_ONLY_DIRS RT_BIT_32(4)
+/** Do not match directories. (Can't be used with RTPATHGLOB_F_ONLY_DIRS or
+ * patterns containing a trailing slash.) */
+#define RTPATHGLOB_F_NO_DIRS RT_BIT_32(5)
+/** Disables the '**' wildcard pattern for matching zero or more subdirs. */
+#define RTPATHGLOB_F_NO_STARSTAR RT_BIT_32(6)
+/** Mask of valid flags. */
+#define RTPATHGLOB_F_MASK UINT32_C(0x0000007f)
+/** @} */
+
+/**
+ * Frees the results produced by RTPathGlob.
+ *
+ * @param pHead What RTPathGlob returned. NULL ignored.
+ */
+RTDECL(void) RTPathGlobFree(PCRTPATHGLOBENTRY pHead);
+
+
/**
* Query information about a file system object.
*
* guest.
* @param pszAsUser User to run the process as. Pass NULL to use the same
* user as the current process.
- * Windows: Use user@domain format to specify a domain.
+ * Windows: Use user\@domain format to specify a domain.
* @param pszPassword Password to use to authenticate @a pszAsUser. Must be
* NULL wif pszAsUser is NULL. Whether this is actually
* used or not depends on the platform.
* be possible to wait for it, i.e. @a phProcess shall be NULL. */
#define RTPROC_FLAGS_DETACHED RT_BIT(0)
/** Don't show the started process.
- * This is a window (and maybe OS/2) concept, do not use on other platforms. */
+ * This is a Windows (and maybe OS/2) concept, do not use on other platforms. */
#define RTPROC_FLAGS_HIDDEN RT_BIT(1)
/** Use special code path for starting child processes from a service (daemon).
* This is a windows concept for dealing with the so called "Session 0"
* on Solaris. Without this flag the contract id is always changed, as that's
* the more frequently used case. */
#define RTPROC_FLAGS_SAME_CONTRACT RT_BIT(3)
-/** Do not load user profile data when executing a process.
- * This bit at the moment only is valid on Windows. */
-#define RTPROC_FLAGS_NO_PROFILE RT_BIT(4)
+/** Load user profile data when executing a process.
+ * This redefines the meaning of RTENV_DEFAULT to the profile environment.
+ * @remarks On non-windows platforms, the resulting environment maybe very
+ * different from what you see in your shell. Among other reasons,
+ * we cannot run shell profile scripts which typically sets up the
+ * environment. */
+#define RTPROC_FLAGS_PROFILE RT_BIT(4)
/** Create process without a console window.
* This is a Windows (and OS/2) concept, do not use on other platforms. */
#define RTPROC_FLAGS_NO_WINDOW RT_BIT(5)
* just join up argv with a space between each. Ignored on platforms
* passing argument the vector. */
#define RTPROC_FLAGS_UNQUOTED_ARGS RT_BIT(7)
+/** Consider hEnv an environment change record to be applied to RTENV_DEFAULT.
+ * If hEnv is RTENV_DEFAULT, the flag has no effect. */
+#define RTPROC_FLAGS_ENV_CHANGE_RECORD RT_BIT(8)
/** Valid flag mask. */
-#define RTPROC_FLAGS_VALID_MASK UINT32_C(0xff)
+#define RTPROC_FLAGS_VALID_MASK UINT32_C(0x1ff)
/** @} */
* @returns IPRT status code. On success it is normal for the caller to exit
* the process by returning from main().
*
- * @param papszArgs The argument vector of the calling process.
- * @param pszDaemonized The daemonized option. This is appended to the end
- * of the parameter list of the daemonized process.
+ * @param papszArgs The argument vector of the calling process.
+ * @param pszDaemonizedOpt The daemonized option. This is appended to the
+ * end of the parameter list of the daemonized process.
*/
RTR3DECL(int) RTProcDaemonize(const char * const *papszArgs, const char *pszDaemonizedOpt);
* @returns IPRT status code.
* @retval VERR_BUFFER_OVERFLOW if the given buffer size is to small for the username.
* @param hProcess The process handle to query the username for.
+ * NIL_PROCESS is an alias for the current process.
* @param pszUser Where to store the user name on success.
* @param cbUser The size of the user name buffer.
* @param pcbUser Where to store the username length on success
* or the required buffer size if VERR_BUFFER_OVERFLOW
* is returned.
*/
-RTR3DECL(int) RTProcQueryUsername(RTPROCESS hProcess, char *pszUser, size_t cbUser,
- size_t *pcbUser);
+RTR3DECL(int) RTProcQueryUsername(RTPROCESS hProcess, char *pszUser, size_t cbUser, size_t *pcbUser);
/**
* Query the username of the given process allocating the string for the username.
* optional (NULL). Max length is 32 bytes.
* @param ... Format string arguments.
*/
-RTDECL(int) RTSemEventCreateEx(PRTSEMEVENT phEventSem, uint32_t fFlags, RTLOCKVALCLASS hClass, const char *pszNameFmt, ...);
+RTDECL(int) RTSemEventCreateEx(PRTSEMEVENT phEventSem, uint32_t fFlags, RTLOCKVALCLASS hClass,
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(4, 5);
/** @name RTSemMutexCreateEx flags
* @{ */
* @param uTimeout See RTSemEventWaitEx.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemEventWaitExDebug(RTSEMEVENT hEventSem, uint32_t fFlags, uint64_t uTimeout,
RTHCUINTPTR uId, RT_SRC_POS_DECL);
* @param ... Format string arguments.
*/
RTDECL(int) RTSemEventMultiCreateEx(PRTSEMEVENTMULTI phEventMultiSem, uint32_t fFlags, RTLOCKVALCLASS hClass,
- const char *pszNameFmt, ...);
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(4, 5);
/** @name RTSemMutexCreateEx flags
* @{ */
* @param uTimeout See RTSemEventMultiWaitEx.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemEventMultiWaitExDebug(RTSEMEVENTMULTI hEventMultiSem, uint32_t fFlags, uint64_t uTimeout,
RTHCUINTPTR uId, RT_SRC_POS_DECL);
* Creates a read/write semaphore.
*
* @returns iprt status code.
- * @param phRWSem Where to store the handle to the newly created
- * RW semaphore.
+ * @param phMutexSem Where to store the handle to the newly created
+ * mutex semaphore.
* @param fFlags Flags, any combination of the
* RTSEMMUTEX_FLAGS_XXX \#defines.
* @param hClass The class (no reference consumed). If NIL, no
* optional (NULL). Max length is 32 bytes.
* @param ... Format string arguments.
*/
-RTDECL(int) RTSemMutexCreateEx(PRTSEMMUTEX phMutexSem, uint32_t fFlags,
- RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszNameFmt, ...);
+RTDECL(int) RTSemMutexCreateEx(PRTSEMMUTEX phMutexSem, uint32_t fFlags, RTLOCKVALCLASS hClass, uint32_t uSubClass,
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(5, 6);
/** @name RTSemMutexCreateEx flags
* @{ */
* @param cMillies The number of milliseconds to wait.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemMutexRequestDebug(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL);
* @param cMillies The number of milliseconds to wait.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL);
* @param uTimeout See RTSemMutexRequestEx.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemMutexRequestExDebug(RTSEMMUTEX hMutexSem, uint32_t fFlags, uint64_t uTimeout,
RTHCUINTPTR uId, RT_SRC_POS_DECL);
* optional (NULL). Max length is 32 bytes.
* @param ... Format string arguments.
*/
-RTDECL(int) RTSemRWCreateEx(PRTSEMRW phRWSem, uint32_t fFlags,
- RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszNameFmt, ...);
+RTDECL(int) RTSemRWCreateEx(PRTSEMRW phRWSem, uint32_t fFlags, RTLOCKVALCLASS hClass, uint32_t uSubClass,
+ const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(5, 6);
/** @name RTSemRWCreateEx flags
* @{ */
* @param cMillies The number of milliseconds to wait.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemRWRequestReadDebug(RTSEMRW hRWSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL);
* @param cMillies The number of milliseconds to wait.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemRWRequestReadNoResumeDebug(RTSEMRW hRWSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL);
* @param uTimeout See RTSemRWRequestReadEx.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemRWRequestReadExDebug(RTSEMRW hRWSem, uint32_t fFlags, uint64_t uTimeout,
RTHCUINTPTR uId, RT_SRC_POS_DECL);
* @param cMillies The number of milliseconds to wait.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemRWRequestWriteDebug(RTSEMRW hRWSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL);
* @param cMillies The number of milliseconds to wait.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemRWRequestWriteNoResumeDebug(RTSEMRW hRWSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL);
* @param uTimeout See RTSemRWRequestWriteEx.
* @param uId Some kind of locking location ID. Typically a
* return address up the stack. Optional (0).
- * @param pszFile The file where the lock is being acquired from.
- * Optional.
- * @param iLine The line number in that file. Optional (0).
- * @param pszFunction The function where the lock is being acquired
- * from. Optional.
+ * @param SRC_POS The source position where call is being made
+ * from. Use RT_SRC_POS when possible. Optional.
*/
RTDECL(int) RTSemRWRequestWriteExDebug(RTSEMRW hRWSem, uint32_t fFlags, uint64_t uTimeout,
RTHCUINTPTR uId, RT_SRC_POS_DECL);
#include <iprt/err.h> /* for VINF_SUCCESS */
#if defined(RT_OS_LINUX) && defined(__KERNEL__)
RT_C_DECLS_BEGIN
+# define new newhack /* string.h: strreplace */
# include <linux/string.h>
+# undef new
RT_C_DECLS_END
#elif defined(IN_XF86_MODULE) && !defined(NO_ANSIC)
# include <string.h>
#endif
+/* For the time being: */
+#include <iprt/utf16.h>
+#include <iprt/latin1.h>
+
/*
* Supply prototypes for standard string functions provided by
* IPRT instead of the operating environment.
RT_C_DECLS_END
#endif
+#if !defined(RT_OS_LINUX) || !defined(_GNU_SOURCE)
+RT_C_DECLS_BEGIN
+void *memrchr(const char *pv, int ch, size_t cb);
+RT_C_DECLS_END
+#endif
+
+
/** @def RT_USE_RTC_3629
* When defined the UTF-8 range will stop at 0x10ffff. If not defined, the
* range stops at 0x7fffffff.
* the pointer to the current file name. The string API will make of use of
* this as pointer to a volatile but read-only string.
*/
-#ifndef RTSTR_TAG
+#if !defined(RTSTR_TAG) || defined(DOXYGEN_RUNNING)
# define RTSTR_TAG (__FILE__)
#endif
RTDECL(int) RTStrValidateEncoding(const char *psz);
/** @name Flags for RTStrValidateEncodingEx and RTUtf16ValidateEncodingEx
+ * @{
*/
/** Check that the string is zero terminated within the given size.
* VERR_BUFFER_OVERFLOW will be returned if the check fails. */
* string is not correctly encoded. In this last case the string
* may be partially processed.
* @param psz The string to sanitise.
- * @param puszValidSets A zero-terminated array of pairs of Unicode points.
+ * @param puszValidSet A zero-terminated array of pairs of Unicode points.
* Each pair is the start and end point of a range,
* and the union of these ranges forms the white list.
* @param chReplacement The ASCII replacement character.
* @param pcch Where to store the string length. Optional.
* This is undefined on failure.
*/
-RTDECL(int) RTStrCalcLatin1LenEx(const char *psz, size_t cch, size_t *pcwc);
+RTDECL(int) RTStrCalcLatin1LenEx(const char *psz, size_t cch, size_t *pcch);
/**
* Translate a UTF-8 string into a Latin-1 allocating the result buffer (default
*/
RTDECL(int) RTStrToLatin1ExTag(const char *pszString, size_t cchString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
-
-/**
- * Translate a Latin1 string into a UTF-8 allocating the result buffer (default
- * tag).
- *
- * @returns iprt status code.
- * @param pszString Latin1 string to convert.
- * @param ppszString Receives pointer of allocated UTF-8 string on
- * success, and is always set to NULL on failure.
- * The returned pointer must be freed using RTStrFree().
- */
-#define RTLatin1ToUtf8(pszString, ppszString) RTLatin1ToUtf8Tag((pszString), (ppszString), RTSTR_TAG)
-
-/**
- * Translate a Latin-1 string into a UTF-8 allocating the result buffer.
- *
- * @returns iprt status code.
- * @param pszString Latin-1 string to convert.
- * @param ppszString Receives pointer of allocated UTF-8 string on
- * success, and is always set to NULL on failure.
- * The returned pointer must be freed using RTStrFree().
- * @param pszTag Allocation tag used for statistics and such.
- */
-RTDECL(int) RTLatin1ToUtf8Tag(const char *pszString, char **ppszString, const char *pszTag);
-
-/**
- * Translates Latin-1 to UTF-8 using buffer provided by the caller or a fittingly
- * sized buffer allocated by the function (default tag).
- *
- * @returns iprt status code.
- * @param pszString The Latin-1 string to convert.
- * @param cchString The number of Latin-1 characters to translate from
- * pszString. The translation will stop when reaching
- * cchString or the terminator ('\\0'). Use RTSTR_MAX
- * to translate the entire string.
- * @param ppsz If cch is non-zero, this must either be pointing to
- * a pointer to a buffer of the specified size, or
- * pointer to a NULL pointer. If *ppsz is NULL or cch
- * is zero a buffer of at least cch chars will be
- * allocated to hold the translated string. If a
- * buffer was requested it must be freed using
- * RTStrFree().
- * @param cch The buffer size in chars (the type). This includes the terminator.
- * @param pcch Where to store the length of the translated string,
- * excluding the terminator. (Optional)
- *
- * This may be set under some error conditions,
- * however, only for VERR_BUFFER_OVERFLOW and
- * VERR_NO_STR_MEMORY will it contain a valid string
- * length that can be used to resize the buffer.
- */
-#define RTLatin1ToUtf8Ex(pszString, cchString, ppsz, cch, pcch) \
- RTLatin1ToUtf8ExTag((pszString), (cchString), (ppsz), (cch), (pcch), RTSTR_TAG)
-
-/**
- * Translates Latin1 to UTF-8 using buffer provided by the caller or a fittingly
- * sized buffer allocated by the function (custom tag).
- *
- * @returns iprt status code.
- * @param pszString The Latin1 string to convert.
- * @param cchString The number of Latin1 characters to translate from
- * pwszString. The translation will stop when
- * reaching cchString or the terminator ('\\0'). Use
- * RTSTR_MAX to translate the entire string.
- * @param ppsz If cch is non-zero, this must either be pointing to
- * a pointer to a buffer of the specified size, or
- * pointer to a NULL pointer. If *ppsz is NULL or cch
- * is zero a buffer of at least cch chars will be
- * allocated to hold the translated string. If a
- * buffer was requested it must be freed using
- * RTStrFree().
- * @param cch The buffer size in chars (the type). This includes
- * the terminator.
- * @param pcch Where to store the length of the translated string,
- * excluding the terminator. (Optional)
- *
- * This may be set under some error conditions,
- * however, only for VERR_BUFFER_OVERFLOW and
- * VERR_NO_STR_MEMORY will it contain a valid string
- * length that can be used to resize the buffer.
- * @param pszTag Allocation tag used for statistics and such.
- */
-RTDECL(int) RTLatin1ToUtf8ExTag(const char *pszString, size_t cchString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
-
-/**
- * Calculates the length of the Latin-1 string in UTF-8 chars (bytes).
- *
- * The primary purpose of this function is to help allocate buffers for
- * RTLatin1ToUtf8() of the correct size. For most other purposes
- * RTLatin1ToUtf8Ex() should be used.
- *
- * @returns Number of chars (bytes).
- * @returns 0 if the string was incorrectly encoded.
- * @param psz The Latin-1 string.
- */
-RTDECL(size_t) RTLatin1CalcUtf8Len(const char *psz);
-
-/**
- * Calculates the length of the Latin-1 string in UTF-8 chars (bytes).
- *
- * @returns iprt status code.
- * @param psz The string.
- * @param cch The max string length. Use RTSTR_MAX to process the entire string.
- * @param pcch Where to store the string length (in bytes). Optional.
- * This is undefined on failure.
- */
-RTDECL(int) RTLatin1CalcUtf8LenEx(const char *psz, size_t cch, size_t *pcch);
-
/**
* Get the unicode code point at the given string position.
*
*/
RTDECL(char *) RTStrPrevCp(const char *pszStart, const char *psz);
-/**
- * Get the unicode code point at the given string position.
- *
- * @returns unicode code point.
- * @returns RTUNICP_INVALID if the encoding is invalid.
- * @param psz The string.
- */
-DECLINLINE(RTUNICP) RTLatin1GetCp(const char *psz)
-{
- return *(const unsigned char *)psz;
-}
-
-/**
- * Get the unicode code point at the given string position.
- *
- * @returns iprt status code.
- * @param ppsz Pointer to the string pointer. This will be updated to
- * point to the char following the current code point.
- * This is advanced one character forward on failure.
- * @param pCp Where to store the code point.
- * RTUNICP_INVALID is stored here on failure.
- *
- * @remark We optimize this operation by using an inline function for
- * the most frequent and simplest sequence, the rest is
- * handled by RTStrGetCpExInternal().
- */
-DECLINLINE(int) RTLatin1GetCpEx(const char **ppsz, PRTUNICP pCp)
-{
- const unsigned char uch = **(const unsigned char **)ppsz;
- (*ppsz)++;
- *pCp = uch;
- return VINF_SUCCESS;
-}
-
-/**
- * Get the unicode code point at the given string position for a string of a
- * given maximum length.
- *
- * @returns iprt status code.
- * @retval VERR_END_OF_STRING if *pcch is 0. *pCp is set to RTUNICP_INVALID.
- *
- * @param ppsz Pointer to the string pointer. This will be updated to
- * point to the char following the current code point.
- * @param pcch Pointer to the maximum string length. This will be
- * decremented by the size of the code point found.
- * @param pCp Where to store the code point.
- * RTUNICP_INVALID is stored here on failure.
- */
-DECLINLINE(int) RTLatin1GetCpNEx(const char **ppsz, size_t *pcch, PRTUNICP pCp)
-{
- if (RT_LIKELY(*pcch != 0))
- {
- const unsigned char uch = **(const unsigned char **)ppsz;
- (*ppsz)++;
- (*pcch)--;
- *pCp = uch;
- return VINF_SUCCESS;
- }
- *pCp = RTUNICP_INVALID;
- return VERR_END_OF_STRING;
-}
-
-/**
- * Get the Latin-1 size in characters of a given Unicode code point.
- *
- * The code point is expected to be a valid Unicode one, but not necessarily in
- * the range supported by Latin-1.
- *
- * @returns the size in characters, or zero if there is no Latin-1 encoding
- */
-DECLINLINE(size_t) RTLatin1CpSize(RTUNICP CodePoint)
-{
- if (CodePoint < 0x100)
- return 1;
- return 0;
-}
-
-/**
- * Put the unicode code point at the given string position
- * and return the pointer to the char following it.
- *
- * This function will not consider anything at or following the
- * buffer area pointed to by psz. It is therefore not suitable for
- * inserting code points into a string, only appending/overwriting.
- *
- * @returns pointer to the char following the written code point.
- * @param psz The string.
- * @param CodePoint The code point to write.
- * This should not be RTUNICP_INVALID or any other
- * character out of the Latin-1 range.
- */
-DECLINLINE(char *) RTLatin1PutCp(char *psz, RTUNICP CodePoint)
-{
- AssertReturn(CodePoint < 0x100, NULL);
- *psz++ = (unsigned char)CodePoint;
- return psz;
-}
-
-/**
- * Skips ahead, past the current code point.
- *
- * @returns Pointer to the char after the current code point.
- * @param psz Pointer to the current code point.
- * @remark This will not move the next valid code point, only past the current one.
- */
-DECLINLINE(char *) RTLatin1NextCp(const char *psz)
-{
- psz++;
- return (char *)psz;
-}
-
-/**
- * Skips back to the previous code point.
- *
- * @returns Pointer to the char before the current code point.
- * @returns pszStart on failure.
- * @param pszStart Pointer to the start of the string.
- * @param psz Pointer to the current code point.
- */
-DECLINLINE(char *) RTLatin1PrevCp(const char *psz)
-{
- psz--;
- return (char *)psz;
-}
-
/** @page pg_rt_str_format The IPRT Format Strings
*
typedef FNRTSTROUTPUT *PFNRTSTROUTPUT;
#endif
-/** Format flag.
+/** @name Format flag.
* These are used by RTStrFormat extensions and RTStrFormatNumber, mind
* that not all flags makes sense to both of the functions.
* @{ */
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param InArgs Argument list.
*/
-RTDECL(size_t) RTStrFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRFORMAT pfnFormat, void *pvArgFormat, const char *pszFormat, va_list InArgs);
+RTDECL(size_t) RTStrFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRFORMAT pfnFormat, void *pvArgFormat,
+ const char *pszFormat, va_list InArgs) RT_IPRT_FORMAT_ATTR(5, 0);
/**
* Partial implementation of a printf like formatter.
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param ... Argument list.
*/
-RTDECL(size_t) RTStrFormat(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRFORMAT pfnFormat, void *pvArgFormat, const char *pszFormat, ...);
+RTDECL(size_t) RTStrFormat(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRFORMAT pfnFormat, void *pvArgFormat,
+ const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(5, 6);
/**
* Formats an integer number according to the parameters.
* @param cchPrecision Precision.
* @param fFlags Flags, RTSTR_F_XXX.
*/
-RTDECL(int) RTStrFormatNumber(char *psz, uint64_t u64Value, unsigned int uiBase, signed int cchWidth, signed int cchPrecision, unsigned int fFlags);
+RTDECL(int) RTStrFormatNumber(char *psz, uint64_t u64Value, unsigned int uiBase, signed int cchWidth, signed int cchPrecision,
+ unsigned int fFlags);
/**
* Formats an unsigned 8-bit number.
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param args The format argument.
*/
-RTDECL(size_t) RTStrPrintfV(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args);
+RTDECL(size_t) RTStrPrintfV(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(3, 0);
/**
* String printf.
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param ... The format argument.
*/
-RTDECL(size_t) RTStrPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...);
+RTDECL(size_t) RTStrPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
/**
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param args The format argument.
*/
-RTDECL(size_t) RTStrPrintfExV(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args);
+RTDECL(size_t) RTStrPrintfExV(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer,
+ const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(5, 0);
/**
* String printf with custom formatting.
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param ... The format argument.
*/
-RTDECL(size_t) RTStrPrintfEx(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...);
+RTDECL(size_t) RTStrPrintfEx(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer,
+ const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(5, 6);
/**
* @param args The format argument.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(int) RTStrAPrintfVTag(char **ppszBuffer, const char *pszFormat, va_list args, const char *pszTag);
+RTDECL(int) RTStrAPrintfVTag(char **ppszBuffer, const char *pszFormat, va_list args, const char *pszTag) RT_IPRT_FORMAT_ATTR(2, 0);
/**
* Allocating string printf.
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param ... The format argument.
*/
-DECLINLINE(int) RTStrAPrintf(char **ppszBuffer, const char *pszFormat, ...)
+DECLINLINE(int) RT_IPRT_FORMAT_ATTR(2, 3) RTStrAPrintf(char **ppszBuffer, const char *pszFormat, ...)
{
int cbRet;
va_list va;
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param ... The format argument.
*/
-DECLINLINE(int) RTStrAPrintfTag(char **ppszBuffer, const char *pszTag, const char *pszFormat, ...)
+DECLINLINE(int) RT_IPRT_FORMAT_ATTR(3, 4) RTStrAPrintfTag(char **ppszBuffer, const char *pszTag, const char *pszFormat, ...)
{
int cbRet;
va_list va;
* @param args The format argument.
* @param pszTag Allocation tag used for statistics and such.
*/
-RTDECL(char *) RTStrAPrintf2VTag(const char *pszFormat, va_list args, const char *pszTag);
+RTDECL(char *) RTStrAPrintf2VTag(const char *pszFormat, va_list args, const char *pszTag) RT_IPRT_FORMAT_ATTR(1, 0);
/**
* Allocating string printf, version 2 (default tag).
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param ... The format argument.
*/
-DECLINLINE(char *) RTStrAPrintf2(const char *pszFormat, ...)
+DECLINLINE(char *) RT_IPRT_FORMAT_ATTR(1, 2) RTStrAPrintf2(const char *pszFormat, ...)
{
char *pszRet;
va_list va;
* @param pszFormat Pointer to the format string, @see pg_rt_str_format.
* @param ... The format argument.
*/
-DECLINLINE(char *) RTStrAPrintf2Tag(const char *pszTag, const char *pszFormat, ...)
+DECLINLINE(char *) RT_IPRT_FORMAT_ATTR(2, 3) RTStrAPrintf2Tag(const char *pszTag, const char *pszFormat, ...)
{
char *pszRet;
va_list va;
RT_C_DECLS_BEGIN
+/**
+ * Finds the offset at which a simple character first occurs in a string.
+ *
+ * @returns The offset of the first occurence or the terminator offset.
+ * @param pszHaystack The string to search.
+ * @param chNeedle The character to search for.
+ */
+DECLINLINE(size_t) RTStrOffCharOrTerm(const char *pszHaystack, char chNeedle)
+{
+ const char *psz = pszHaystack;
+ char ch;
+ while ( (ch = *psz) != chNeedle
+ && ch != '\0')
+ psz++;
+ return psz - pszHaystack;
+}
+
+
/**
* Matches a simple string pattern.
*
/** @} */
-
-/** @defgroup rt_str_utf16 UTF-16 String Manipulation
- * @{
- */
-
-/**
- * Allocates memory for UTF-16 string storage (default tag).
- *
- * You should normally not use this function, except if there is some very
- * custom string handling you need doing that isn't covered by any of the other
- * APIs.
- *
- * @returns Pointer to the allocated UTF-16 string. The first wide char is
- * always set to the string terminator char, the contents of the
- * remainder of the memory is undefined. The string must be freed by
- * calling RTUtf16Free.
- *
- * NULL is returned if the allocation failed. Please translate this to
- * VERR_NO_UTF16_MEMORY and not VERR_NO_MEMORY. Also consider
- * RTUtf16AllocEx if an IPRT status code is required.
- *
- * @param cb How many bytes to allocate, will be rounded up
- * to a multiple of two. If this is zero, we will
- * allocate a terminator wide char anyway.
- */
-#define RTUtf16Alloc(cb) RTUtf16AllocTag((cb), RTSTR_TAG)
-
-/**
- * Allocates memory for UTF-16 string storage (custom tag).
- *
- * You should normally not use this function, except if there is some very
- * custom string handling you need doing that isn't covered by any of the other
- * APIs.
- *
- * @returns Pointer to the allocated UTF-16 string. The first wide char is
- * always set to the string terminator char, the contents of the
- * remainder of the memory is undefined. The string must be freed by
- * calling RTUtf16Free.
- *
- * NULL is returned if the allocation failed. Please translate this to
- * VERR_NO_UTF16_MEMORY and not VERR_NO_MEMORY. Also consider
- * RTUtf16AllocExTag if an IPRT status code is required.
- *
- * @param cb How many bytes to allocate, will be rounded up
- * to a multiple of two. If this is zero, we will
- * allocate a terminator wide char anyway.
- * @param pszTag Allocation tag used for statistics and such.
- */
-RTDECL(PRTUTF16) RTUtf16AllocTag(size_t cb, const char *pszTag);
-
-
-/**
- * Free a UTF-16 string allocated by RTStrToUtf16(), RTStrToUtf16Ex(),
- * RTLatin1ToUtf16(), RTLatin1ToUtf16Ex(), RTUtf16Dup() or RTUtf16DupEx().
- *
- * @returns iprt status code.
- * @param pwszString The UTF-16 string to free. NULL is accepted.
- */
-RTDECL(void) RTUtf16Free(PRTUTF16 pwszString);
-
-/**
- * Allocates a new copy of the specified UTF-16 string (default tag).
- *
- * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it.
- * @returns NULL when out of memory.
- * @param pwszString UTF-16 string to duplicate.
- * @remark This function will not make any attempt to validate the encoding.
- */
-#define RTUtf16Dup(pwszString) RTUtf16DupTag((pwszString), RTSTR_TAG)
-
-/**
- * Allocates a new copy of the specified UTF-16 string (custom tag).
- *
- * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it.
- * @returns NULL when out of memory.
- * @param pwszString UTF-16 string to duplicate.
- * @param pszTag Allocation tag used for statistics and such.
- * @remark This function will not make any attempt to validate the encoding.
- */
-RTDECL(PRTUTF16) RTUtf16DupTag(PCRTUTF16 pwszString, const char *pszTag);
-
-/**
- * Allocates a new copy of the specified UTF-16 string (default tag).
- *
- * @returns iprt status code.
- * @param ppwszString Receives pointer of the allocated UTF-16 string.
- * The returned pointer must be freed using RTUtf16Free().
- * @param pwszString UTF-16 string to duplicate.
- * @param cwcExtra Number of extra RTUTF16 items to allocate.
- * @remark This function will not make any attempt to validate the encoding.
- */
-#define RTUtf16DupEx(ppwszString, pwszString, cwcExtra) \
- RTUtf16DupExTag((ppwszString), (pwszString), (cwcExtra), RTSTR_TAG)
-
-/**
- * Allocates a new copy of the specified UTF-16 string (custom tag).
- *
- * @returns iprt status code.
- * @param ppwszString Receives pointer of the allocated UTF-16 string.
- * The returned pointer must be freed using RTUtf16Free().
- * @param pwszString UTF-16 string to duplicate.
- * @param cwcExtra Number of extra RTUTF16 items to allocate.
- * @param pszTag Allocation tag used for statistics and such.
- * @remark This function will not make any attempt to validate the encoding.
- */
-RTDECL(int) RTUtf16DupExTag(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra, const char *pszTag);
-
-/**
- * Returns the length of a UTF-16 string in UTF-16 characters
- * without trailing '\\0'.
- *
- * Surrogate pairs counts as two UTF-16 characters here. Use RTUtf16CpCnt()
- * to get the exact number of code points in the string.
- *
- * @returns The number of RTUTF16 items in the string.
- * @param pwszString Pointer the UTF-16 string.
- * @remark This function will not make any attempt to validate the encoding.
- */
-RTDECL(size_t) RTUtf16Len(PCRTUTF16 pwszString);
-
-/**
- * Find the length of a zero-terminated byte string, given a max string length.
- *
- * @returns The string length or cbMax. The returned length does not include
- * the zero terminator if it was found.
- *
- * @param pwszString The string.
- * @param cwcMax The max string length in RTUTF16s.
- * @sa RTUtf16NLenEx, RTStrNLen.
- */
-RTDECL(size_t) RTUtf16NLen(PCRTUTF16 pwszString, size_t cwcMax);
-
-/**
- * Find the length of a zero-terminated byte string, given
- * a max string length.
- *
- * @returns IPRT status code.
- * @retval VINF_SUCCESS if the string has a length less than cchMax.
- * @retval VERR_BUFFER_OVERFLOW if the end of the string wasn't found
- * before cwcMax was reached.
- *
- * @param pwszString The string.
- * @param cwcMax The max string length in RTUTF16s.
- * @param pcwc Where to store the string length excluding the
- * terminator. This is set to cwcMax if the terminator
- * isn't found.
- * @sa RTUtf16NLen, RTStrNLenEx.
- */
-RTDECL(int) RTUtf16NLenEx(PCRTUTF16 pwszString, size_t cwcMax, size_t *pcwc);
-
-/**
- * Find the zero terminator in a string with a limited length.
- *
- * @returns Pointer to the zero terminator.
- * @returns NULL if the zero terminator was not found.
- *
- * @param pwszString The string.
- * @param cwcMax The max string length. RTSTR_MAX is fine.
- */
-RTDECL(PCRTUTF16) RTUtf16End(PCRTUTF16 pwszString, size_t cwcMax);
-
-/**
- * Strips blankspaces from both ends of the string.
- *
- * @returns Pointer to first non-blank char in the string.
- * @param pwsz The string to strip.
- */
-RTDECL(PRTUTF16) RTUtf16Strip(PRTUTF16 pwsz);
-
-/**
- * Strips blankspaces from the start of the string.
- *
- * @returns Pointer to first non-blank char in the string.
- * @param pwsz The string to strip.
- */
-RTDECL(PRTUTF16) RTUtf16StripL(PCRTUTF16 pwsz);
-
-/**
- * Strips blankspaces from the end of the string.
- *
- * @returns pwsz.
- * @param pwsz The string to strip.
- */
-RTDECL(PRTUTF16) RTUtf16StripR(PRTUTF16 pwsz);
-
-/**
- * String copy with overflow handling.
- *
- * @retval VINF_SUCCESS on success.
- * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
- * buffer will contain as much of the string as it can hold, fully
- * terminated.
- *
- * @param pwszDst The destination buffer.
- * @param cwcDst The size of the destination buffer in RTUTF16s.
- * @param pwszSrc The source string. NULL is not OK.
- */
-RTDECL(int) RTUtf16Copy(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc);
-
-/**
- * String copy with overflow handling, ASCII source.
- *
- * @retval VINF_SUCCESS on success.
- * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
- * buffer will contain as much of the string as it can hold, fully
- * terminated.
- *
- * @param pwszDst The destination buffer.
- * @param cwcDst The size of the destination buffer in RTUTF16s.
- * @param pszSrc The source string, pure ASCII. NULL is not OK.
- */
-RTDECL(int) RTUtf16CopyAscii(PRTUTF16 pwszDst, size_t cwcDst, const char *pszSrc);
-
-/**
- * String copy with overflow handling.
- *
- * @retval VINF_SUCCESS on success.
- * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
- * buffer will contain as much of the string as it can hold, fully
- * terminated.
- *
- * @param pwszDst The destination buffer.
- * @param cwcDst The size of the destination buffer in RTUTF16s.
- * @param pwszSrc The source string. NULL is not OK.
- * @param cwcSrcMax The maximum number of chars (not code points) to
- * copy from the source string, not counting the
- * terminator as usual.
- */
-RTDECL(int) RTUtf16CopyEx(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc, size_t cwcSrcMax);
-
-/**
- * String concatenation with overflow handling.
- *
- * @retval VINF_SUCCESS on success.
- * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
- * buffer will contain as much of the string as it can hold, fully
- * terminated.
- *
- * @param pszDst The destination buffer.
- * @param cwcDst The size of the destination buffer in RTUTF16s.
- * @param pwszSrc The source string. NULL is not OK.
- */
-RTDECL(int) RTUtf16Cat(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc);
-
-/**
- * String concatenation with overflow handling, ASCII source.
- *
- * @retval VINF_SUCCESS on success.
- * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
- * buffer will contain as much of the string as it can hold, fully
- * terminated.
- *
- * @param pszDst The destination buffer.
- * @param cwcDst The size of the destination buffer in RTUTF16s.
- * @param pszSrc The source string, pure ASCII. NULL is not OK.
- */
-RTDECL(int) RTUtf16CatAscii(PRTUTF16 pwszDst, size_t cwcDst, const char *pwszSrc);
-
-/**
- * String concatenation with overflow handling.
- *
- * @retval VINF_SUCCESS on success.
- * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
- * buffer will contain as much of the string as it can hold, fully
- * terminated.
- *
- * @param pwszDst The destination buffer.
- * @param cwcDst The size of the destination buffer in RTUTF16s.
- * @param pwszSrc The source string. NULL is not OK.
- * @param cwcSrcMax The maximum number of UTF-16 chars (not code
- * points) to copy from the source string, not
- * counting the terminator as usual.
- */
-RTDECL(int) RTUtf16CatEx(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc, size_t cwcSrcMax);
-
-/**
- * Performs a case sensitive string compare between two UTF-16 strings.
- *
- * @returns < 0 if the first string less than the second string.s
- * @returns 0 if the first string identical to the second string.
- * @returns > 0 if the first string greater than the second string.
- * @param pwsz1 First UTF-16 string. Null is allowed.
- * @param pwsz2 Second UTF-16 string. Null is allowed.
- * @remark This function will not make any attempt to validate the encoding.
- */
-RTDECL(int) RTUtf16Cmp(PCRTUTF16 pwsz1, PCRTUTF16 pwsz2);
-
-/**
- * Performs a case sensitive string compare between an UTF-16 string and a pure
- * ASCII string.
- *
- * @returns < 0 if the first string less than the second string.s
- * @returns 0 if the first string identical to the second string.
- * @returns > 0 if the first string greater than the second string.
- * @param pwsz1 First UTF-16 string. Null is allowed.
- * @param psz2 Second string, pure ASCII. Null is allowed.
- * @remark This function will not make any attempt to validate the encoding.
- */
-RTDECL(int) RTUtf16CmpAscii(PCRTUTF16 pwsz1, const char *psz2);
-
-/**
- * Performs a case insensitive string compare between two UTF-16 strings.
- *
- * This is a simplified compare, as only the simplified lower/upper case folding
- * specified by the unicode specs are used. It does not consider character pairs
- * as they are used in some languages, just simple upper & lower case compares.
- *
- * @returns < 0 if the first string less than the second string.
- * @returns 0 if the first string identical to the second string.
- * @returns > 0 if the first string greater than the second string.
- * @param pwsz1 First UTF-16 string. Null is allowed.
- * @param pwsz2 Second UTF-16 string. Null is allowed.
- */
-RTDECL(int) RTUtf16ICmp(PCRTUTF16 pwsz1, PCRTUTF16 pwsz2);
-
-/**
- * Performs a case insensitive string compare between an UTF-16 string and an
- * pure ASCII string.
- *
- * Since this compare only takes cares about the first 128 codepoints in
- * unicode, no tables are needed and there aren't any real complications.
- *
- * @returns < 0 if the first string less than the second string.
- * @returns 0 if the first string identical to the second string.
- * @returns > 0 if the first string greater than the second string.
- * @param pwsz1 First UTF-16 string. Null is allowed.
- * @param psz2 Second string, pure ASCII. Null is allowed.
- */
-RTDECL(int) RTUtf16ICmpAscii(PCRTUTF16 pwsz1, const char *psz2);
-
-/**
- * Performs a case insensitive string compare between two UTF-16 strings
- * using the current locale of the process (if applicable).
- *
- * This differs from RTUtf16ICmp() in that it will try, if a locale with the
- * required data is available, to do a correct case-insensitive compare. It
- * follows that it is more complex and thereby likely to be more expensive.
- *
- * @returns < 0 if the first string less than the second string.
- * @returns 0 if the first string identical to the second string.
- * @returns > 0 if the first string greater than the second string.
- * @param pwsz1 First UTF-16 string. Null is allowed.
- * @param pwsz2 Second UTF-16 string. Null is allowed.
- */
-RTDECL(int) RTUtf16LocaleICmp(PCRTUTF16 pwsz1, PCRTUTF16 pwsz2);
-
-/**
- * Folds a UTF-16 string to lowercase.
- *
- * This is a very simple folding; is uses the simple lowercase
- * code point, it is not related to any locale just the most common
- * lowercase codepoint setup by the unicode specs, and it will not
- * create new surrogate pairs or remove existing ones.
- *
- * @returns Pointer to the passed in string.
- * @param pwsz The string to fold.
- */
-RTDECL(PRTUTF16) RTUtf16ToLower(PRTUTF16 pwsz);
-
-/**
- * Folds a UTF-16 string to uppercase.
- *
- * This is a very simple folding; is uses the simple uppercase
- * code point, it is not related to any locale just the most common
- * uppercase codepoint setup by the unicode specs, and it will not
- * create new surrogate pairs or remove existing ones.
- *
- * @returns Pointer to the passed in string.
- * @param pwsz The string to fold.
- */
-RTDECL(PRTUTF16) RTUtf16ToUpper(PRTUTF16 pwsz);
-
-/**
- * Validates the UTF-16 encoding of the string.
- *
- * @returns iprt status code.
- * @param pwsz The string.
- */
-RTDECL(int) RTUtf16ValidateEncoding(PCRTUTF16 pwsz);
-
-/**
- * Validates the UTF-16 encoding of the string.
- *
- * @returns iprt status code.
- * @param pwsz The string.
- * @param cwc The max string length (/ size) in UTF-16 units. Use
- * RTSTR_MAX to process the entire string.
- * @param fFlags Combination of RTSTR_VALIDATE_ENCODING_XXX flags.
- */
-RTDECL(int) RTUtf16ValidateEncodingEx(PCRTUTF16 pwsz, size_t cwc, uint32_t fFlags);
-
-/**
- * Checks if the UTF-16 encoding is valid.
- *
- * @returns true / false.
- * @param pwsz The string.
- */
-RTDECL(bool) RTUtf16IsValidEncoding(PCRTUTF16 pwsz);
-
-/**
- * Sanitise a (valid) UTF-16 string by replacing all characters outside a white
- * list in-place by an ASCII replacement character. Multi-byte characters will
- * be replaced byte by byte.
- *
- * @returns The number of code points replaced, or a negative value if the
- * string is not correctly encoded. In this last case the string
- * may be partially processed.
- * @param pwsz The string to sanitise.
- * @param puszValidSets A zero-terminated array of pairs of Unicode points.
- * Each pair is the start and end point of a range,
- * and the union of these ranges forms the white list.
- * @param chReplacement The ASCII replacement character.
- */
-RTDECL(ssize_t) RTUtf16PurgeComplementSet(PRTUTF16 pwsz, PCRTUNICP puszValidSet, char chReplacement);
-
-/**
- * Translate a UTF-16 string into a UTF-8 allocating the result buffer (default
- * tag).
- *
- * @returns iprt status code.
- * @param pwszString UTF-16 string to convert.
- * @param ppszString Receives pointer of allocated UTF-8 string on
- * success, and is always set to NULL on failure.
- * The returned pointer must be freed using RTStrFree().
- */
-#define RTUtf16ToUtf8(pwszString, ppszString) RTUtf16ToUtf8Tag((pwszString), (ppszString), RTSTR_TAG)
-
-/**
- * Translate a UTF-16 string into a UTF-8 allocating the result buffer.
- *
- * @returns iprt status code.
- * @param pwszString UTF-16 string to convert.
- * @param ppszString Receives pointer of allocated UTF-8 string on
- * success, and is always set to NULL on failure.
- * The returned pointer must be freed using RTStrFree().
- * @param pszTag Allocation tag used for statistics and such.
- */
-RTDECL(int) RTUtf16ToUtf8Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag);
-
-/**
- * Translates UTF-16 to UTF-8 using buffer provided by the caller or a fittingly
- * sized buffer allocated by the function (default tag).
- *
- * @returns iprt status code.
- * @param pwszString The UTF-16 string to convert.
- * @param cwcString The number of RTUTF16 items to translate from pwszString.
- * The translation will stop when reaching cwcString or the terminator ('\\0').
- * Use RTSTR_MAX to translate the entire string.
- * @param ppsz If cch is non-zero, this must either be pointing to a pointer to
- * a buffer of the specified size, or pointer to a NULL pointer.
- * If *ppsz is NULL or cch is zero a buffer of at least cch chars
- * will be allocated to hold the translated string.
- * If a buffer was requested it must be freed using RTStrFree().
- * @param cch The buffer size in chars (the type). This includes the terminator.
- * @param pcch Where to store the length of the translated string,
- * excluding the terminator. (Optional)
- *
- * This may be set under some error conditions,
- * however, only for VERR_BUFFER_OVERFLOW and
- * VERR_NO_STR_MEMORY will it contain a valid string
- * length that can be used to resize the buffer.
- */
-#define RTUtf16ToUtf8Ex(pwszString, cwcString, ppsz, cch, pcch) \
- RTUtf16ToUtf8ExTag((pwszString), (cwcString), (ppsz), (cch), (pcch), RTSTR_TAG)
-
-/**
- * Translates UTF-16 to UTF-8 using buffer provided by the caller or a fittingly
- * sized buffer allocated by the function (custom tag).
- *
- * @returns iprt status code.
- * @param pwszString The UTF-16 string to convert.
- * @param cwcString The number of RTUTF16 items to translate from pwszString.
- * The translation will stop when reaching cwcString or the terminator ('\\0').
- * Use RTSTR_MAX to translate the entire string.
- * @param ppsz If cch is non-zero, this must either be pointing to a pointer to
- * a buffer of the specified size, or pointer to a NULL pointer.
- * If *ppsz is NULL or cch is zero a buffer of at least cch chars
- * will be allocated to hold the translated string.
- * If a buffer was requested it must be freed using RTStrFree().
- * @param cch The buffer size in chars (the type). This includes the terminator.
- * @param pcch Where to store the length of the translated string,
- * excluding the terminator. (Optional)
- *
- * This may be set under some error conditions,
- * however, only for VERR_BUFFER_OVERFLOW and
- * VERR_NO_STR_MEMORY will it contain a valid string
- * length that can be used to resize the buffer.
- * @param pszTag Allocation tag used for statistics and such.
- */
-RTDECL(int) RTUtf16ToUtf8ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
-
-/**
- * Calculates the length of the UTF-16 string in UTF-8 chars (bytes).
- *
- * This function will validate the string, and incorrectly encoded UTF-16
- * strings will be rejected. The primary purpose of this function is to
- * help allocate buffers for RTUtf16ToUtf8() of the correct size. For most
- * other purposes RTUtf16ToUtf8Ex() should be used.
- *
- * @returns Number of char (bytes).
- * @returns 0 if the string was incorrectly encoded.
- * @param pwsz The UTF-16 string.
- */
-RTDECL(size_t) RTUtf16CalcUtf8Len(PCRTUTF16 pwsz);
-
-/**
- * Calculates the length of the UTF-16 string in UTF-8 chars (bytes).
- *
- * This function will validate the string, and incorrectly encoded UTF-16
- * strings will be rejected.
- *
- * @returns iprt status code.
- * @param pwsz The string.
- * @param cwc The max string length. Use RTSTR_MAX to process the entire string.
- * @param pcch Where to store the string length (in bytes). Optional.
- * This is undefined on failure.
- */
-RTDECL(int) RTUtf16CalcUtf8LenEx(PCRTUTF16 pwsz, size_t cwc, size_t *pcch);
-
-/**
- * Translate a UTF-16 string into a Latin-1 (ISO-8859-1) allocating the result
- * buffer (default tag).
- *
- * @returns iprt status code.
- * @param pwszString UTF-16 string to convert.
- * @param ppszString Receives pointer of allocated Latin1 string on
- * success, and is always set to NULL on failure.
- * The returned pointer must be freed using RTStrFree().
- */
-#define RTUtf16ToLatin1(pwszString, ppszString) RTUtf16ToLatin1Tag((pwszString), (ppszString), RTSTR_TAG)
-
-/**
- * Translate a UTF-16 string into a Latin-1 (ISO-8859-1) allocating the result
- * buffer (custom tag).
- *
- * @returns iprt status code.
- * @param pwszString UTF-16 string to convert.
- * @param ppszString Receives pointer of allocated Latin1 string on
- * success, and is always set to NULL on failure.
- * The returned pointer must be freed using RTStrFree().
- * @param pszTag Allocation tag used for statistics and such.
- */
-RTDECL(int) RTUtf16ToLatin1Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag);
-
-/**
- * Translates UTF-16 to Latin-1 (ISO-8859-1) using buffer provided by the caller
- * or a fittingly sized buffer allocated by the function (default tag).
- *
- * @returns iprt status code.
- * @param pwszString The UTF-16 string to convert.
- * @param cwcString The number of RTUTF16 items to translate from
- * pwszString. The translation will stop when reaching
- * cwcString or the terminator ('\\0'). Use RTSTR_MAX
- * to translate the entire string.
- * @param ppsz Pointer to the pointer to the Latin-1 string. The
- * buffer can optionally be preallocated by the caller.
- *
- * If cch is zero, *ppsz is undefined.
- *
- * If cch is non-zero and *ppsz is not NULL, then this
- * will be used as the output buffer.
- * VERR_BUFFER_OVERFLOW will be returned if this is
- * insufficient.
- *
- * If cch is zero or *ppsz is NULL, then a buffer of
- * sufficient size is allocated. cch can be used to
- * specify a minimum size of this buffer. Use
- * RTUtf16Free() to free the result.
- *
- * @param cch The buffer size in chars (the type). This includes
- * the terminator.
- * @param pcch Where to store the length of the translated string,
- * excluding the terminator. (Optional)
- *
- * This may be set under some error conditions,
- * however, only for VERR_BUFFER_OVERFLOW and
- * VERR_NO_STR_MEMORY will it contain a valid string
- * length that can be used to resize the buffer.
- */
-#define RTUtf16ToLatin1Ex(pwszString, cwcString, ppsz, cch, pcch) \
- RTUtf16ToLatin1ExTag((pwszString), (cwcString), (ppsz), (cch), (pcch), RTSTR_TAG)
-
-/**
- * Translates UTF-16 to Latin-1 (ISO-8859-1) using buffer provided by the caller
- * or a fittingly sized buffer allocated by the function (custom tag).
- *
- * @returns iprt status code.
- * @param pwszString The UTF-16 string to convert.
- * @param cwcString The number of RTUTF16 items to translate from
- * pwszString. The translation will stop when reaching
- * cwcString or the terminator ('\\0'). Use RTSTR_MAX
- * to translate the entire string.
- * @param ppsz Pointer to the pointer to the Latin-1 string. The
- * buffer can optionally be preallocated by the caller.
- *
- * If cch is zero, *ppsz is undefined.
- *
- * If cch is non-zero and *ppsz is not NULL, then this
- * will be used as the output buffer.
- * VERR_BUFFER_OVERFLOW will be returned if this is
- * insufficient.
- *
- * If cch is zero or *ppsz is NULL, then a buffer of
- * sufficient size is allocated. cch can be used to
- * specify a minimum size of this buffer. Use
- * RTUtf16Free() to free the result.
- *
- * @param cch The buffer size in chars (the type). This includes
- * the terminator.
- * @param pcch Where to store the length of the translated string,
- * excluding the terminator. (Optional)
- *
- * This may be set under some error conditions,
- * however, only for VERR_BUFFER_OVERFLOW and
- * VERR_NO_STR_MEMORY will it contain a valid string
- * length that can be used to resize the buffer.
- * @param pszTag Allocation tag used for statistics and such.
- */
-RTDECL(int) RTUtf16ToLatin1ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
-
-/**
- * Calculates the length of the UTF-16 string in Latin-1 (ISO-8859-1) chars.
- *
- * This function will validate the string, and incorrectly encoded UTF-16
- * strings will be rejected. The primary purpose of this function is to
- * help allocate buffers for RTUtf16ToLatin1() of the correct size. For most
- * other purposes RTUtf16ToLatin1Ex() should be used.
- *
- * @returns Number of char (bytes).
- * @returns 0 if the string was incorrectly encoded.
- * @param pwsz The UTF-16 string.
- */
-RTDECL(size_t) RTUtf16CalcLatin1Len(PCRTUTF16 pwsz);
-
-/**
- * Calculates the length of the UTF-16 string in Latin-1 (ISO-8859-1) chars.
- *
- * This function will validate the string, and incorrectly encoded UTF-16
- * strings will be rejected.
- *
- * @returns iprt status code.
- * @param pwsz The string.
- * @param cwc The max string length. Use RTSTR_MAX to process the
- * entire string.
- * @param pcch Where to store the string length (in bytes). Optional.
- * This is undefined on failure.
- */
-RTDECL(int) RTUtf16CalcLatin1LenEx(PCRTUTF16 pwsz, size_t cwc, size_t *pcch);
-
-/**
- * Get the unicode code point at the given string position.
- *
- * @returns unicode code point.
- * @returns RTUNICP_INVALID if the encoding is invalid.
- * @param pwsz The string.
- *
- * @remark This is an internal worker for RTUtf16GetCp().
- */
-RTDECL(RTUNICP) RTUtf16GetCpInternal(PCRTUTF16 pwsz);
-
-/**
- * Get the unicode code point at the given string position.
- *
- * @returns iprt status code.
- * @param ppwsz Pointer to the string pointer. This will be updated to
- * point to the char following the current code point.
- * @param pCp Where to store the code point.
- * RTUNICP_INVALID is stored here on failure.
- *
- * @remark This is an internal worker for RTUtf16GetCpEx().
- */
-RTDECL(int) RTUtf16GetCpExInternal(PCRTUTF16 *ppwsz, PRTUNICP pCp);
-
-/**
- * Put the unicode code point at the given string position
- * and return the pointer to the char following it.
- *
- * This function will not consider anything at or following the
- * buffer area pointed to by pwsz. It is therefore not suitable for
- * inserting code points into a string, only appending/overwriting.
- *
- * @returns pointer to the char following the written code point.
- * @param pwsz The string.
- * @param CodePoint The code point to write.
- * This should not be RTUNICP_INVALID or any other
- * character out of the UTF-16 range.
- *
- * @remark This is an internal worker for RTUtf16GetCpEx().
- */
-RTDECL(PRTUTF16) RTUtf16PutCpInternal(PRTUTF16 pwsz, RTUNICP CodePoint);
-
-/**
- * Get the unicode code point at the given string position.
- *
- * @returns unicode code point.
- * @returns RTUNICP_INVALID if the encoding is invalid.
- * @param pwsz The string.
- *
- * @remark We optimize this operation by using an inline function for
- * everything which isn't a surrogate pair or an endian indicator.
- */
-DECLINLINE(RTUNICP) RTUtf16GetCp(PCRTUTF16 pwsz)
-{
- const RTUTF16 wc = *pwsz;
- if (wc < 0xd800 || (wc > 0xdfff && wc < 0xfffe))
- return wc;
- return RTUtf16GetCpInternal(pwsz);
-}
-
-/**
- * Get the unicode code point at the given string position.
- *
- * @returns iprt status code.
- * @param ppwsz Pointer to the string pointer. This will be updated to
- * point to the char following the current code point.
- * @param pCp Where to store the code point.
- * RTUNICP_INVALID is stored here on failure.
- *
- * @remark We optimize this operation by using an inline function for
- * everything which isn't a surrogate pair or and endian indicator.
- */
-DECLINLINE(int) RTUtf16GetCpEx(PCRTUTF16 *ppwsz, PRTUNICP pCp)
-{
- const RTUTF16 wc = **ppwsz;
- if (wc < 0xd800 || (wc > 0xdfff && wc < 0xfffe))
- {
- (*ppwsz)++;
- *pCp = wc;
- return VINF_SUCCESS;
- }
- return RTUtf16GetCpExInternal(ppwsz, pCp);
-}
-
-/**
- * Put the unicode code point at the given string position
- * and return the pointer to the char following it.
- *
- * This function will not consider anything at or following the
- * buffer area pointed to by pwsz. It is therefore not suitable for
- * inserting code points into a string, only appending/overwriting.
- *
- * @returns pointer to the char following the written code point.
- * @param pwsz The string.
- * @param CodePoint The code point to write.
- * This should not be RTUNICP_INVALID or any other
- * character out of the UTF-16 range.
- *
- * @remark We optimize this operation by using an inline function for
- * everything which isn't a surrogate pair or and endian indicator.
- */
-DECLINLINE(PRTUTF16) RTUtf16PutCp(PRTUTF16 pwsz, RTUNICP CodePoint)
-{
- if (CodePoint < 0xd800 || (CodePoint > 0xd800 && CodePoint < 0xfffe))
- {
- *pwsz++ = (RTUTF16)CodePoint;
- return pwsz;
- }
- return RTUtf16PutCpInternal(pwsz, CodePoint);
-}
-
-/**
- * Skips ahead, past the current code point.
- *
- * @returns Pointer to the char after the current code point.
- * @param pwsz Pointer to the current code point.
- * @remark This will not move the next valid code point, only past the current one.
- */
-DECLINLINE(PRTUTF16) RTUtf16NextCp(PCRTUTF16 pwsz)
-{
- RTUNICP Cp;
- RTUtf16GetCpEx(&pwsz, &Cp);
- return (PRTUTF16)pwsz;
-}
-
-/**
- * Skips backwards, to the previous code point.
- *
- * @returns Pointer to the char after the current code point.
- * @param pwszStart Pointer to the start of the string.
- * @param pwsz Pointer to the current code point.
- */
-RTDECL(PRTUTF16) RTUtf16PrevCp(PCRTUTF16 pwszStart, PCRTUTF16 pwsz);
-
-
-/**
- * Checks if the UTF-16 char is the high surrogate char (i.e.
- * the 1st char in the pair).
- *
- * @returns true if it is.
- * @returns false if it isn't.
- * @param wc The character to investigate.
- */
-DECLINLINE(bool) RTUtf16IsHighSurrogate(RTUTF16 wc)
-{
- return wc >= 0xd800 && wc <= 0xdbff;
-}
-
-/**
- * Checks if the UTF-16 char is the low surrogate char (i.e.
- * the 2nd char in the pair).
- *
- * @returns true if it is.
- * @returns false if it isn't.
- * @param wc The character to investigate.
- */
-DECLINLINE(bool) RTUtf16IsLowSurrogate(RTUTF16 wc)
-{
- return wc >= 0xdc00 && wc <= 0xdfff;
-}
-
-
-/**
- * Checks if the two UTF-16 chars form a valid surrogate pair.
- *
- * @returns true if they do.
- * @returns false if they doesn't.
- * @param wcHigh The high (1st) character.
- * @param wcLow The low (2nd) character.
- */
-DECLINLINE(bool) RTUtf16IsSurrogatePair(RTUTF16 wcHigh, RTUTF16 wcLow)
-{
- return RTUtf16IsHighSurrogate(wcHigh)
- && RTUtf16IsLowSurrogate(wcLow);
-}
-
-/**
- * Formats a buffer stream as hex bytes.
- *
- * The default is no separating spaces or line breaks or anything.
- *
- * @returns IPRT status code.
- * @retval VERR_INVALID_POINTER if any of the pointers are wrong.
- * @retval VERR_BUFFER_OVERFLOW if the buffer is insufficent to hold the bytes.
- *
- * @param pwszBuf Output string buffer.
- * @param cwcBuf The size of the output buffer in RTUTF16 units.
- * @param pv Pointer to the bytes to stringify.
- * @param cb The number of bytes to stringify.
- * @param fFlags Combination of RTSTRPRINTHEXBYTES_F_XXX values.
- * @sa RTStrPrintHexBytes.
- */
-RTDECL(int) RTUtf16PrintHexBytes(PRTUTF16 pwszBuf, size_t cwcBuf, void const *pv, size_t cb, uint32_t fFlags);
-
-/** @} */
-
-
-/** @defgroup rt_str_latin1 Latin-1 (ISO-8859-1) String Manipulation
- * @{
- */
-
-/**
- * Calculates the length of the Latin-1 (ISO-8859-1) string in RTUTF16 items.
- *
- * @returns Number of RTUTF16 items.
- * @param psz The Latin-1 string.
- */
-RTDECL(size_t) RTLatin1CalcUtf16Len(const char *psz);
-
-/**
- * Calculates the length of the Latin-1 (ISO-8859-1) string in RTUTF16 items.
- *
- * @returns iprt status code.
- * @param psz The Latin-1 string.
- * @param cch The max string length. Use RTSTR_MAX to process the
- * entire string.
- * @param pcwc Where to store the string length. Optional.
- * This is undefined on failure.
- */
-RTDECL(int) RTLatin1CalcUtf16LenEx(const char *psz, size_t cch, size_t *pcwc);
-
-/**
- * Translate a Latin-1 (ISO-8859-1) string into a UTF-16 allocating the result
- * buffer (default tag).
- *
- * @returns iprt status code.
- * @param pszString The Latin-1 string to convert.
- * @param ppwszString Receives pointer to the allocated UTF-16 string. The
- * returned string must be freed using RTUtf16Free().
- */
-#define RTLatin1ToUtf16(pszString, ppwszString) RTLatin1ToUtf16Tag((pszString), (ppwszString), RTSTR_TAG)
-
-/**
- * Translate a Latin-1 (ISO-8859-1) string into a UTF-16 allocating the result
- * buffer (custom tag).
- *
- * @returns iprt status code.
- * @param pszString The Latin-1 string to convert.
- * @param ppwszString Receives pointer to the allocated UTF-16 string. The
- * returned string must be freed using RTUtf16Free().
- * @param pszTag Allocation tag used for statistics and such.
- */
-RTDECL(int) RTLatin1ToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag);
-
-/**
- * Translates pszString from Latin-1 (ISO-8859-1) to UTF-16, allocating the
- * result buffer if requested (default tag).
- *
- * @returns iprt status code.
- * @param pszString The Latin-1 string to convert.
- * @param cchString The maximum size in chars (the type) to convert.
- * The conversion stops when it reaches cchString or
- * the string terminator ('\\0').
- * Use RTSTR_MAX to translate the entire string.
- * @param ppwsz If cwc is non-zero, this must either be pointing
- * to pointer to a buffer of the specified size, or
- * pointer to a NULL pointer.
- * If *ppwsz is NULL or cwc is zero a buffer of at
- * least cwc items will be allocated to hold the
- * translated string. If a buffer was requested it
- * must be freed using RTUtf16Free().
- * @param cwc The buffer size in RTUTF16s. This includes the
- * terminator.
- * @param pcwc Where to store the length of the translated string,
- * excluding the terminator. (Optional)
- *
- * This may be set under some error conditions,
- * however, only for VERR_BUFFER_OVERFLOW and
- * VERR_NO_STR_MEMORY will it contain a valid string
- * length that can be used to resize the buffer.
- */
-#define RTLatin1ToUtf16Ex(pszString, cchString, ppwsz, cwc, pcwc) \
- RTLatin1ToUtf16ExTag((pszString), (cchString), (ppwsz), (cwc), (pcwc), RTSTR_TAG)
-
-/**
- * Translates pszString from Latin-1 (ISO-8859-1) to UTF-16, allocating the
- * result buffer if requested.
- *
- * @returns iprt status code.
- * @param pszString The Latin-1 string to convert.
- * @param cchString The maximum size in chars (the type) to convert.
- * The conversion stops when it reaches cchString or
- * the string terminator ('\\0').
- * Use RTSTR_MAX to translate the entire string.
- * @param ppwsz If cwc is non-zero, this must either be pointing
- * to pointer to a buffer of the specified size, or
- * pointer to a NULL pointer.
- * If *ppwsz is NULL or cwc is zero a buffer of at
- * least cwc items will be allocated to hold the
- * translated string. If a buffer was requested it
- * must be freed using RTUtf16Free().
- * @param cwc The buffer size in RTUTF16s. This includes the
- * terminator.
- * @param pcwc Where to store the length of the translated string,
- * excluding the terminator. (Optional)
- *
- * This may be set under some error conditions,
- * however, only for VERR_BUFFER_OVERFLOW and
- * VERR_NO_STR_MEMORY will it contain a valid string
- * length that can be used to resize the buffer.
- * @param pszTag Allocation tag used for statistics and such.
- */
-RTDECL(int) RTLatin1ToUtf16ExTag(const char *pszString, size_t cchString,
- PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag);
-
-/** @} */
-
-#ifndef ___iprt_nocrt_string_h
-# if defined(RT_OS_WINDOWS)
-RTDECL(void *) mempcpy(void *pvDst, const void *pvSrc, size_t cb);
-# endif
-#endif
-
+/** @} */
RT_C_DECLS_END
-/** @} */
-
#endif
* @param va Format arguments.
*/
RTDECL(int) RTThreadCreateV(PRTTHREAD pThread, PFNRTTHREAD pfnThread, void *pvUser, size_t cbStack,
- RTTHREADTYPE enmType, uint32_t fFlags, const char *pszNameFmt, va_list va);
+ RTTHREADTYPE enmType, uint32_t fFlags, const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(7, 0);
/**
* Create a new thread.
* @param ... Format arguments.
*/
RTDECL(int) RTThreadCreateF(PRTTHREAD pThread, PFNRTTHREAD pfnThread, void *pvUser, size_t cbStack,
- RTTHREADTYPE enmType, uint32_t fFlags, const char *pszNameFmt, ...);
+ RTTHREADTYPE enmType, uint32_t fFlags, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(7, 8);
/**
* Gets the native thread id of a IPRT thread.
# endif
# include <sys/types.h>
# ifndef offsetof
-# error "offsetof is not defined..."
+# error "offsetof is not defined!"
# endif
# elif defined(RT_OS_FREEBSD) && HC_ARCH_BITS == 64 && defined(RT_ARCH_X86)
typedef const RTUTF16 *PCRTUTF16;
+/**
+ * String tuple to go with the RT_STR_TUPLE macro.
+ */
+typedef struct RTSTRTUPLE
+{
+ /** The string. */
+ const char *psz;
+ /** The string length. */
+ size_t cch;
+} RTSTRTUPLE;
+/** Pointer to a string tuple. */
+typedef RTSTRTUPLE *PRTSTRTUPLE;
+/** Pointer to a const string tuple. */
+typedef RTSTRTUPLE const *PCRTSTRTUPLE;
+
/**
* Wait for ever if we have to.
*/
* @param pszFormat The format string.
* @param va Arguments for the format string.
*/
-typedef DECLCALLBACK(void) FNRTDUMPPRINTFV(void *pvUser, const char *pszFormat, va_list va);
+typedef DECLCALLBACK(void) FNRTDUMPPRINTFV(void *pvUser, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
/** Pointer to a generic printf-like function for dumping. */
typedef FNRTDUMPPRINTFV *PFNRTDUMPPRINTFV;
*/
typedef union RTPTRUNION
{
- /** Pointer into the void... */
+ /** Pointer into the void. */
void *pv;
/** As a signed integer. */
intptr_t i;
*/
typedef union RTCPTRUNION
{
- /** Pointer into the void... */
+ /** Pointer into the void. */
void const *pv;
/** As a signed integer. */
intptr_t i;
*/
typedef union RTVPTRUNION
{
- /** Pointer into the void... */
+ /** Pointer into the void. */
void volatile *pv;
/** As a signed integer. */
intptr_t i;
*/
typedef union RTCVPTRUNION
{
- /** Pointer into the void... */
+ /** Pointer into the void. */
void const volatile *pv;
/** As a signed integer. */
intptr_t i;
--- /dev/null
+/** @file
+ * IPRT - String Manipulation, UTF-16 encoding.
+ */
+
+/*
+ * Copyright (C) 2006-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef ___iprt_utf16_h
+#define ___iprt_utf16_h
+
+#include <iprt/string.h>
+
+RT_C_DECLS_BEGIN
+
+
+/** @defgroup rt_str_utf16 UTF-16 String Manipulation
+ * @ingroup grp_rt_str
+ * @{
+ */
+
+/**
+ * Allocates memory for UTF-16 string storage (default tag).
+ *
+ * You should normally not use this function, except if there is some very
+ * custom string handling you need doing that isn't covered by any of the other
+ * APIs.
+ *
+ * @returns Pointer to the allocated UTF-16 string. The first wide char is
+ * always set to the string terminator char, the contents of the
+ * remainder of the memory is undefined. The string must be freed by
+ * calling RTUtf16Free.
+ *
+ * NULL is returned if the allocation failed. Please translate this to
+ * VERR_NO_UTF16_MEMORY and not VERR_NO_MEMORY. Also consider
+ * RTUtf16AllocEx if an IPRT status code is required.
+ *
+ * @param cb How many bytes to allocate, will be rounded up
+ * to a multiple of two. If this is zero, we will
+ * allocate a terminator wide char anyway.
+ */
+#define RTUtf16Alloc(cb) RTUtf16AllocTag((cb), RTSTR_TAG)
+
+/**
+ * Allocates memory for UTF-16 string storage (custom tag).
+ *
+ * You should normally not use this function, except if there is some very
+ * custom string handling you need doing that isn't covered by any of the other
+ * APIs.
+ *
+ * @returns Pointer to the allocated UTF-16 string. The first wide char is
+ * always set to the string terminator char, the contents of the
+ * remainder of the memory is undefined. The string must be freed by
+ * calling RTUtf16Free.
+ *
+ * NULL is returned if the allocation failed. Please translate this to
+ * VERR_NO_UTF16_MEMORY and not VERR_NO_MEMORY. Also consider
+ * RTUtf16AllocExTag if an IPRT status code is required.
+ *
+ * @param cb How many bytes to allocate, will be rounded up
+ * to a multiple of two. If this is zero, we will
+ * allocate a terminator wide char anyway.
+ * @param pszTag Allocation tag used for statistics and such.
+ */
+RTDECL(PRTUTF16) RTUtf16AllocTag(size_t cb, const char *pszTag);
+
+
+/**
+ * Free a UTF-16 string allocated by RTStrToUtf16(), RTStrToUtf16Ex(),
+ * RTLatin1ToUtf16(), RTLatin1ToUtf16Ex(), RTUtf16Dup() or RTUtf16DupEx().
+ *
+ * @returns iprt status code.
+ * @param pwszString The UTF-16 string to free. NULL is accepted.
+ */
+RTDECL(void) RTUtf16Free(PRTUTF16 pwszString);
+
+/**
+ * Allocates a new copy of the specified UTF-16 string (default tag).
+ *
+ * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it.
+ * @returns NULL when out of memory.
+ * @param pwszString UTF-16 string to duplicate.
+ * @remark This function will not make any attempt to validate the encoding.
+ */
+#define RTUtf16Dup(pwszString) RTUtf16DupTag((pwszString), RTSTR_TAG)
+
+/**
+ * Allocates a new copy of the specified UTF-16 string (custom tag).
+ *
+ * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it.
+ * @returns NULL when out of memory.
+ * @param pwszString UTF-16 string to duplicate.
+ * @param pszTag Allocation tag used for statistics and such.
+ * @remark This function will not make any attempt to validate the encoding.
+ */
+RTDECL(PRTUTF16) RTUtf16DupTag(PCRTUTF16 pwszString, const char *pszTag);
+
+/**
+ * Allocates a new copy of the specified UTF-16 string (default tag).
+ *
+ * @returns iprt status code.
+ * @param ppwszString Receives pointer of the allocated UTF-16 string.
+ * The returned pointer must be freed using RTUtf16Free().
+ * @param pwszString UTF-16 string to duplicate.
+ * @param cwcExtra Number of extra RTUTF16 items to allocate.
+ * @remark This function will not make any attempt to validate the encoding.
+ */
+#define RTUtf16DupEx(ppwszString, pwszString, cwcExtra) \
+ RTUtf16DupExTag((ppwszString), (pwszString), (cwcExtra), RTSTR_TAG)
+
+/**
+ * Allocates a new copy of the specified UTF-16 string (custom tag).
+ *
+ * @returns iprt status code.
+ * @param ppwszString Receives pointer of the allocated UTF-16 string.
+ * The returned pointer must be freed using RTUtf16Free().
+ * @param pwszString UTF-16 string to duplicate.
+ * @param cwcExtra Number of extra RTUTF16 items to allocate.
+ * @param pszTag Allocation tag used for statistics and such.
+ * @remark This function will not make any attempt to validate the encoding.
+ */
+RTDECL(int) RTUtf16DupExTag(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra, const char *pszTag);
+
+/**
+ * Returns the length of a UTF-16 string in UTF-16 characters
+ * without trailing '\\0'.
+ *
+ * Surrogate pairs counts as two UTF-16 characters here. Use RTUtf16CpCnt()
+ * to get the exact number of code points in the string.
+ *
+ * @returns The number of RTUTF16 items in the string.
+ * @param pwszString Pointer the UTF-16 string.
+ * @remark This function will not make any attempt to validate the encoding.
+ */
+RTDECL(size_t) RTUtf16Len(PCRTUTF16 pwszString);
+
+/**
+ * Find the length of a zero-terminated byte string, given a max string length.
+ *
+ * @returns The string length or cbMax. The returned length does not include
+ * the zero terminator if it was found.
+ *
+ * @param pwszString The string.
+ * @param cwcMax The max string length in RTUTF16s.
+ * @sa RTUtf16NLenEx, RTStrNLen.
+ */
+RTDECL(size_t) RTUtf16NLen(PCRTUTF16 pwszString, size_t cwcMax);
+
+/**
+ * Find the length of a zero-terminated byte string, given
+ * a max string length.
+ *
+ * @returns IPRT status code.
+ * @retval VINF_SUCCESS if the string has a length less than cchMax.
+ * @retval VERR_BUFFER_OVERFLOW if the end of the string wasn't found
+ * before cwcMax was reached.
+ *
+ * @param pwszString The string.
+ * @param cwcMax The max string length in RTUTF16s.
+ * @param pcwc Where to store the string length excluding the
+ * terminator. This is set to cwcMax if the terminator
+ * isn't found.
+ * @sa RTUtf16NLen, RTStrNLenEx.
+ */
+RTDECL(int) RTUtf16NLenEx(PCRTUTF16 pwszString, size_t cwcMax, size_t *pcwc);
+
+/**
+ * Find the zero terminator in a string with a limited length.
+ *
+ * @returns Pointer to the zero terminator.
+ * @returns NULL if the zero terminator was not found.
+ *
+ * @param pwszString The string.
+ * @param cwcMax The max string length. RTSTR_MAX is fine.
+ */
+RTDECL(PCRTUTF16) RTUtf16End(PCRTUTF16 pwszString, size_t cwcMax);
+
+/**
+ * Strips blankspaces from both ends of the string.
+ *
+ * @returns Pointer to first non-blank char in the string.
+ * @param pwsz The string to strip.
+ */
+RTDECL(PRTUTF16) RTUtf16Strip(PRTUTF16 pwsz);
+
+/**
+ * Strips blankspaces from the start of the string.
+ *
+ * @returns Pointer to first non-blank char in the string.
+ * @param pwsz The string to strip.
+ */
+RTDECL(PRTUTF16) RTUtf16StripL(PCRTUTF16 pwsz);
+
+/**
+ * Strips blankspaces from the end of the string.
+ *
+ * @returns pwsz.
+ * @param pwsz The string to strip.
+ */
+RTDECL(PRTUTF16) RTUtf16StripR(PRTUTF16 pwsz);
+
+/**
+ * String copy with overflow handling.
+ *
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
+ * buffer will contain as much of the string as it can hold, fully
+ * terminated.
+ *
+ * @param pwszDst The destination buffer.
+ * @param cwcDst The size of the destination buffer in RTUTF16s.
+ * @param pwszSrc The source string. NULL is not OK.
+ */
+RTDECL(int) RTUtf16Copy(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc);
+
+/**
+ * String copy with overflow handling, ASCII source.
+ *
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
+ * buffer will contain as much of the string as it can hold, fully
+ * terminated.
+ *
+ * @param pwszDst The destination buffer.
+ * @param cwcDst The size of the destination buffer in RTUTF16s.
+ * @param pszSrc The source string, pure ASCII. NULL is not OK.
+ */
+RTDECL(int) RTUtf16CopyAscii(PRTUTF16 pwszDst, size_t cwcDst, const char *pszSrc);
+
+/**
+ * String copy with overflow handling.
+ *
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
+ * buffer will contain as much of the string as it can hold, fully
+ * terminated.
+ *
+ * @param pwszDst The destination buffer.
+ * @param cwcDst The size of the destination buffer in RTUTF16s.
+ * @param pwszSrc The source string. NULL is not OK.
+ * @param cwcSrcMax The maximum number of chars (not code points) to
+ * copy from the source string, not counting the
+ * terminator as usual.
+ */
+RTDECL(int) RTUtf16CopyEx(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc, size_t cwcSrcMax);
+
+/**
+ * String concatenation with overflow handling.
+ *
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
+ * buffer will contain as much of the string as it can hold, fully
+ * terminated.
+ *
+ * @param pwszDst The destination buffer.
+ * @param cwcDst The size of the destination buffer in RTUTF16s.
+ * @param pwszSrc The source string. NULL is not OK.
+ */
+RTDECL(int) RTUtf16Cat(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc);
+
+/**
+ * String concatenation with overflow handling, ASCII source.
+ *
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
+ * buffer will contain as much of the string as it can hold, fully
+ * terminated.
+ *
+ * @param pwszDst The destination buffer.
+ * @param cwcDst The size of the destination buffer in RTUTF16s.
+ * @param pszSrc The source string, pure ASCII. NULL is not OK.
+ */
+RTDECL(int) RTUtf16CatAscii(PRTUTF16 pwszDst, size_t cwcDst, const char *pszSrc);
+
+/**
+ * String concatenation with overflow handling.
+ *
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_BUFFER_OVERFLOW if the destination buffer is too small. The
+ * buffer will contain as much of the string as it can hold, fully
+ * terminated.
+ *
+ * @param pwszDst The destination buffer.
+ * @param cwcDst The size of the destination buffer in RTUTF16s.
+ * @param pwszSrc The source string. NULL is not OK.
+ * @param cwcSrcMax The maximum number of UTF-16 chars (not code
+ * points) to copy from the source string, not
+ * counting the terminator as usual.
+ */
+RTDECL(int) RTUtf16CatEx(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc, size_t cwcSrcMax);
+
+/**
+ * Performs a case sensitive string compare between two UTF-16 strings.
+ *
+ * @returns < 0 if the first string less than the second string.s
+ * @returns 0 if the first string identical to the second string.
+ * @returns > 0 if the first string greater than the second string.
+ * @param pwsz1 First UTF-16 string. Null is allowed.
+ * @param pwsz2 Second UTF-16 string. Null is allowed.
+ * @remark This function will not make any attempt to validate the encoding.
+ */
+RTDECL(int) RTUtf16Cmp(PCRTUTF16 pwsz1, PCRTUTF16 pwsz2);
+
+/**
+ * Performs a case sensitive string compare between an UTF-16 string and a pure
+ * ASCII string.
+ *
+ * @returns < 0 if the first string less than the second string.s
+ * @returns 0 if the first string identical to the second string.
+ * @returns > 0 if the first string greater than the second string.
+ * @param pwsz1 First UTF-16 string. Null is allowed.
+ * @param psz2 Second string, pure ASCII. Null is allowed.
+ * @remark This function will not make any attempt to validate the encoding.
+ */
+RTDECL(int) RTUtf16CmpAscii(PCRTUTF16 pwsz1, const char *psz2);
+
+/**
+ * Performs a case insensitive string compare between two UTF-16 strings.
+ *
+ * This is a simplified compare, as only the simplified lower/upper case folding
+ * specified by the unicode specs are used. It does not consider character pairs
+ * as they are used in some languages, just simple upper & lower case compares.
+ *
+ * @returns < 0 if the first string less than the second string.
+ * @returns 0 if the first string identical to the second string.
+ * @returns > 0 if the first string greater than the second string.
+ * @param pwsz1 First UTF-16 string. Null is allowed.
+ * @param pwsz2 Second UTF-16 string. Null is allowed.
+ */
+RTDECL(int) RTUtf16ICmp(PCRTUTF16 pwsz1, PCRTUTF16 pwsz2);
+
+/**
+ * Performs a case insensitive string compare between an UTF-16 string and an
+ * pure ASCII string.
+ *
+ * Since this compare only takes cares about the first 128 codepoints in
+ * unicode, no tables are needed and there aren't any real complications.
+ *
+ * @returns < 0 if the first string less than the second string.
+ * @returns 0 if the first string identical to the second string.
+ * @returns > 0 if the first string greater than the second string.
+ * @param pwsz1 First UTF-16 string. Null is allowed.
+ * @param psz2 Second string, pure ASCII. Null is allowed.
+ */
+RTDECL(int) RTUtf16ICmpAscii(PCRTUTF16 pwsz1, const char *psz2);
+
+/**
+ * Performs a case insensitive string compare between two UTF-16 strings
+ * using the current locale of the process (if applicable).
+ *
+ * This differs from RTUtf16ICmp() in that it will try, if a locale with the
+ * required data is available, to do a correct case-insensitive compare. It
+ * follows that it is more complex and thereby likely to be more expensive.
+ *
+ * @returns < 0 if the first string less than the second string.
+ * @returns 0 if the first string identical to the second string.
+ * @returns > 0 if the first string greater than the second string.
+ * @param pwsz1 First UTF-16 string. Null is allowed.
+ * @param pwsz2 Second UTF-16 string. Null is allowed.
+ */
+RTDECL(int) RTUtf16LocaleICmp(PCRTUTF16 pwsz1, PCRTUTF16 pwsz2);
+
+/**
+ * Folds a UTF-16 string to lowercase.
+ *
+ * This is a very simple folding; is uses the simple lowercase
+ * code point, it is not related to any locale just the most common
+ * lowercase codepoint setup by the unicode specs, and it will not
+ * create new surrogate pairs or remove existing ones.
+ *
+ * @returns Pointer to the passed in string.
+ * @param pwsz The string to fold.
+ */
+RTDECL(PRTUTF16) RTUtf16ToLower(PRTUTF16 pwsz);
+
+/**
+ * Folds a UTF-16 string to uppercase.
+ *
+ * This is a very simple folding; is uses the simple uppercase
+ * code point, it is not related to any locale just the most common
+ * uppercase codepoint setup by the unicode specs, and it will not
+ * create new surrogate pairs or remove existing ones.
+ *
+ * @returns Pointer to the passed in string.
+ * @param pwsz The string to fold.
+ */
+RTDECL(PRTUTF16) RTUtf16ToUpper(PRTUTF16 pwsz);
+
+/**
+ * Validates the UTF-16 encoding of the string.
+ *
+ * @returns iprt status code.
+ * @param pwsz The string.
+ */
+RTDECL(int) RTUtf16ValidateEncoding(PCRTUTF16 pwsz);
+
+/**
+ * Validates the UTF-16 encoding of the string.
+ *
+ * @returns iprt status code.
+ * @param pwsz The string.
+ * @param cwc The max string length (/ size) in UTF-16 units. Use
+ * RTSTR_MAX to process the entire string.
+ * @param fFlags Combination of RTSTR_VALIDATE_ENCODING_XXX flags.
+ */
+RTDECL(int) RTUtf16ValidateEncodingEx(PCRTUTF16 pwsz, size_t cwc, uint32_t fFlags);
+
+/**
+ * Checks if the UTF-16 encoding is valid.
+ *
+ * @returns true / false.
+ * @param pwsz The string.
+ */
+RTDECL(bool) RTUtf16IsValidEncoding(PCRTUTF16 pwsz);
+
+/**
+ * Sanitise a (valid) UTF-16 string by replacing all characters outside a white
+ * list in-place by an ASCII replacement character. Multi-byte characters will
+ * be replaced byte by byte.
+ *
+ * @returns The number of code points replaced, or a negative value if the
+ * string is not correctly encoded. In this last case the string
+ * may be partially processed.
+ * @param pwsz The string to sanitise.
+ * @param puszValidSet A zero-terminated array of pairs of Unicode points.
+ * Each pair is the start and end point of a range,
+ * and the union of these ranges forms the white list.
+ * @param chReplacement The ASCII replacement character.
+ */
+RTDECL(ssize_t) RTUtf16PurgeComplementSet(PRTUTF16 pwsz, PCRTUNICP puszValidSet, char chReplacement);
+
+/**
+ * Translate a UTF-16 string into a UTF-8 allocating the result buffer (default
+ * tag).
+ *
+ * @returns iprt status code.
+ * @param pwszString UTF-16 string to convert.
+ * @param ppszString Receives pointer of allocated UTF-8 string on
+ * success, and is always set to NULL on failure.
+ * The returned pointer must be freed using RTStrFree().
+ */
+#define RTUtf16ToUtf8(pwszString, ppszString) RTUtf16ToUtf8Tag((pwszString), (ppszString), RTSTR_TAG)
+
+/**
+ * Translate a UTF-16 string into a UTF-8 allocating the result buffer.
+ *
+ * @returns iprt status code.
+ * @param pwszString UTF-16 string to convert.
+ * @param ppszString Receives pointer of allocated UTF-8 string on
+ * success, and is always set to NULL on failure.
+ * The returned pointer must be freed using RTStrFree().
+ * @param pszTag Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTUtf16ToUtf8Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag);
+
+/**
+ * Translates UTF-16 to UTF-8 using buffer provided by the caller or a fittingly
+ * sized buffer allocated by the function (default tag).
+ *
+ * @returns iprt status code.
+ * @param pwszString The UTF-16 string to convert.
+ * @param cwcString The number of RTUTF16 items to translate from pwszString.
+ * The translation will stop when reaching cwcString or the terminator ('\\0').
+ * Use RTSTR_MAX to translate the entire string.
+ * @param ppsz If cch is non-zero, this must either be pointing to a pointer to
+ * a buffer of the specified size, or pointer to a NULL pointer.
+ * If *ppsz is NULL or cch is zero a buffer of at least cch chars
+ * will be allocated to hold the translated string.
+ * If a buffer was requested it must be freed using RTStrFree().
+ * @param cch The buffer size in chars (the type). This includes the terminator.
+ * @param pcch Where to store the length of the translated string,
+ * excluding the terminator. (Optional)
+ *
+ * This may be set under some error conditions,
+ * however, only for VERR_BUFFER_OVERFLOW and
+ * VERR_NO_STR_MEMORY will it contain a valid string
+ * length that can be used to resize the buffer.
+ */
+#define RTUtf16ToUtf8Ex(pwszString, cwcString, ppsz, cch, pcch) \
+ RTUtf16ToUtf8ExTag((pwszString), (cwcString), (ppsz), (cch), (pcch), RTSTR_TAG)
+
+/**
+ * Translates UTF-16 to UTF-8 using buffer provided by the caller or a fittingly
+ * sized buffer allocated by the function (custom tag).
+ *
+ * @returns iprt status code.
+ * @param pwszString The UTF-16 string to convert.
+ * @param cwcString The number of RTUTF16 items to translate from pwszString.
+ * The translation will stop when reaching cwcString or the terminator ('\\0').
+ * Use RTSTR_MAX to translate the entire string.
+ * @param ppsz If cch is non-zero, this must either be pointing to a pointer to
+ * a buffer of the specified size, or pointer to a NULL pointer.
+ * If *ppsz is NULL or cch is zero a buffer of at least cch chars
+ * will be allocated to hold the translated string.
+ * If a buffer was requested it must be freed using RTStrFree().
+ * @param cch The buffer size in chars (the type). This includes the terminator.
+ * @param pcch Where to store the length of the translated string,
+ * excluding the terminator. (Optional)
+ *
+ * This may be set under some error conditions,
+ * however, only for VERR_BUFFER_OVERFLOW and
+ * VERR_NO_STR_MEMORY will it contain a valid string
+ * length that can be used to resize the buffer.
+ * @param pszTag Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTUtf16ToUtf8ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
+
+/**
+ * Calculates the length of the UTF-16 string in UTF-8 chars (bytes).
+ *
+ * This function will validate the string, and incorrectly encoded UTF-16
+ * strings will be rejected. The primary purpose of this function is to
+ * help allocate buffers for RTUtf16ToUtf8() of the correct size. For most
+ * other purposes RTUtf16ToUtf8Ex() should be used.
+ *
+ * @returns Number of char (bytes).
+ * @returns 0 if the string was incorrectly encoded.
+ * @param pwsz The UTF-16 string.
+ */
+RTDECL(size_t) RTUtf16CalcUtf8Len(PCRTUTF16 pwsz);
+
+/**
+ * Calculates the length of the UTF-16 string in UTF-8 chars (bytes).
+ *
+ * This function will validate the string, and incorrectly encoded UTF-16
+ * strings will be rejected.
+ *
+ * @returns iprt status code.
+ * @param pwsz The string.
+ * @param cwc The max string length. Use RTSTR_MAX to process the entire string.
+ * @param pcch Where to store the string length (in bytes). Optional.
+ * This is undefined on failure.
+ */
+RTDECL(int) RTUtf16CalcUtf8LenEx(PCRTUTF16 pwsz, size_t cwc, size_t *pcch);
+
+/**
+ * Translate a UTF-16 string into a Latin-1 (ISO-8859-1) allocating the result
+ * buffer (default tag).
+ *
+ * @returns iprt status code.
+ * @param pwszString UTF-16 string to convert.
+ * @param ppszString Receives pointer of allocated Latin1 string on
+ * success, and is always set to NULL on failure.
+ * The returned pointer must be freed using RTStrFree().
+ */
+#define RTUtf16ToLatin1(pwszString, ppszString) RTUtf16ToLatin1Tag((pwszString), (ppszString), RTSTR_TAG)
+
+/**
+ * Translate a UTF-16 string into a Latin-1 (ISO-8859-1) allocating the result
+ * buffer (custom tag).
+ *
+ * @returns iprt status code.
+ * @param pwszString UTF-16 string to convert.
+ * @param ppszString Receives pointer of allocated Latin1 string on
+ * success, and is always set to NULL on failure.
+ * The returned pointer must be freed using RTStrFree().
+ * @param pszTag Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTUtf16ToLatin1Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag);
+
+/**
+ * Translates UTF-16 to Latin-1 (ISO-8859-1) using buffer provided by the caller
+ * or a fittingly sized buffer allocated by the function (default tag).
+ *
+ * @returns iprt status code.
+ * @param pwszString The UTF-16 string to convert.
+ * @param cwcString The number of RTUTF16 items to translate from
+ * pwszString. The translation will stop when reaching
+ * cwcString or the terminator ('\\0'). Use RTSTR_MAX
+ * to translate the entire string.
+ * @param ppsz Pointer to the pointer to the Latin-1 string. The
+ * buffer can optionally be preallocated by the caller.
+ *
+ * If cch is zero, *ppsz is undefined.
+ *
+ * If cch is non-zero and *ppsz is not NULL, then this
+ * will be used as the output buffer.
+ * VERR_BUFFER_OVERFLOW will be returned if this is
+ * insufficient.
+ *
+ * If cch is zero or *ppsz is NULL, then a buffer of
+ * sufficient size is allocated. cch can be used to
+ * specify a minimum size of this buffer. Use
+ * RTUtf16Free() to free the result.
+ *
+ * @param cch The buffer size in chars (the type). This includes
+ * the terminator.
+ * @param pcch Where to store the length of the translated string,
+ * excluding the terminator. (Optional)
+ *
+ * This may be set under some error conditions,
+ * however, only for VERR_BUFFER_OVERFLOW and
+ * VERR_NO_STR_MEMORY will it contain a valid string
+ * length that can be used to resize the buffer.
+ */
+#define RTUtf16ToLatin1Ex(pwszString, cwcString, ppsz, cch, pcch) \
+ RTUtf16ToLatin1ExTag((pwszString), (cwcString), (ppsz), (cch), (pcch), RTSTR_TAG)
+
+/**
+ * Translates UTF-16 to Latin-1 (ISO-8859-1) using buffer provided by the caller
+ * or a fittingly sized buffer allocated by the function (custom tag).
+ *
+ * @returns iprt status code.
+ * @param pwszString The UTF-16 string to convert.
+ * @param cwcString The number of RTUTF16 items to translate from
+ * pwszString. The translation will stop when reaching
+ * cwcString or the terminator ('\\0'). Use RTSTR_MAX
+ * to translate the entire string.
+ * @param ppsz Pointer to the pointer to the Latin-1 string. The
+ * buffer can optionally be preallocated by the caller.
+ *
+ * If cch is zero, *ppsz is undefined.
+ *
+ * If cch is non-zero and *ppsz is not NULL, then this
+ * will be used as the output buffer.
+ * VERR_BUFFER_OVERFLOW will be returned if this is
+ * insufficient.
+ *
+ * If cch is zero or *ppsz is NULL, then a buffer of
+ * sufficient size is allocated. cch can be used to
+ * specify a minimum size of this buffer. Use
+ * RTUtf16Free() to free the result.
+ *
+ * @param cch The buffer size in chars (the type). This includes
+ * the terminator.
+ * @param pcch Where to store the length of the translated string,
+ * excluding the terminator. (Optional)
+ *
+ * This may be set under some error conditions,
+ * however, only for VERR_BUFFER_OVERFLOW and
+ * VERR_NO_STR_MEMORY will it contain a valid string
+ * length that can be used to resize the buffer.
+ * @param pszTag Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTUtf16ToLatin1ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
+
+/**
+ * Calculates the length of the UTF-16 string in Latin-1 (ISO-8859-1) chars.
+ *
+ * This function will validate the string, and incorrectly encoded UTF-16
+ * strings will be rejected. The primary purpose of this function is to
+ * help allocate buffers for RTUtf16ToLatin1() of the correct size. For most
+ * other purposes RTUtf16ToLatin1Ex() should be used.
+ *
+ * @returns Number of char (bytes).
+ * @returns 0 if the string was incorrectly encoded.
+ * @param pwsz The UTF-16 string.
+ */
+RTDECL(size_t) RTUtf16CalcLatin1Len(PCRTUTF16 pwsz);
+
+/**
+ * Calculates the length of the UTF-16 string in Latin-1 (ISO-8859-1) chars.
+ *
+ * This function will validate the string, and incorrectly encoded UTF-16
+ * strings will be rejected.
+ *
+ * @returns iprt status code.
+ * @param pwsz The string.
+ * @param cwc The max string length. Use RTSTR_MAX to process the
+ * entire string.
+ * @param pcch Where to store the string length (in bytes). Optional.
+ * This is undefined on failure.
+ */
+RTDECL(int) RTUtf16CalcLatin1LenEx(PCRTUTF16 pwsz, size_t cwc, size_t *pcch);
+
+/**
+ * Get the unicode code point at the given string position.
+ *
+ * @returns unicode code point.
+ * @returns RTUNICP_INVALID if the encoding is invalid.
+ * @param pwsz The string.
+ *
+ * @remark This is an internal worker for RTUtf16GetCp().
+ */
+RTDECL(RTUNICP) RTUtf16GetCpInternal(PCRTUTF16 pwsz);
+
+/**
+ * Get the unicode code point at the given string position.
+ *
+ * @returns iprt status code.
+ * @param ppwsz Pointer to the string pointer. This will be updated to
+ * point to the char following the current code point.
+ * @param pCp Where to store the code point.
+ * RTUNICP_INVALID is stored here on failure.
+ *
+ * @remark This is an internal worker for RTUtf16GetCpEx().
+ */
+RTDECL(int) RTUtf16GetCpExInternal(PCRTUTF16 *ppwsz, PRTUNICP pCp);
+
+/**
+ * Put the unicode code point at the given string position
+ * and return the pointer to the char following it.
+ *
+ * This function will not consider anything at or following the
+ * buffer area pointed to by pwsz. It is therefore not suitable for
+ * inserting code points into a string, only appending/overwriting.
+ *
+ * @returns pointer to the char following the written code point.
+ * @param pwsz The string.
+ * @param CodePoint The code point to write.
+ * This should not be RTUNICP_INVALID or any other
+ * character out of the UTF-16 range.
+ *
+ * @remark This is an internal worker for RTUtf16GetCpEx().
+ */
+RTDECL(PRTUTF16) RTUtf16PutCpInternal(PRTUTF16 pwsz, RTUNICP CodePoint);
+
+/**
+ * Get the unicode code point at the given string position.
+ *
+ * @returns unicode code point.
+ * @returns RTUNICP_INVALID if the encoding is invalid.
+ * @param pwsz The string.
+ *
+ * @remark We optimize this operation by using an inline function for
+ * everything which isn't a surrogate pair or an endian indicator.
+ */
+DECLINLINE(RTUNICP) RTUtf16GetCp(PCRTUTF16 pwsz)
+{
+ const RTUTF16 wc = *pwsz;
+ if (wc < 0xd800 || (wc > 0xdfff && wc < 0xfffe))
+ return wc;
+ return RTUtf16GetCpInternal(pwsz);
+}
+
+/**
+ * Get the unicode code point at the given string position.
+ *
+ * @returns iprt status code.
+ * @param ppwsz Pointer to the string pointer. This will be updated to
+ * point to the char following the current code point.
+ * @param pCp Where to store the code point.
+ * RTUNICP_INVALID is stored here on failure.
+ *
+ * @remark We optimize this operation by using an inline function for
+ * everything which isn't a surrogate pair or and endian indicator.
+ */
+DECLINLINE(int) RTUtf16GetCpEx(PCRTUTF16 *ppwsz, PRTUNICP pCp)
+{
+ const RTUTF16 wc = **ppwsz;
+ if (wc < 0xd800 || (wc > 0xdfff && wc < 0xfffe))
+ {
+ (*ppwsz)++;
+ *pCp = wc;
+ return VINF_SUCCESS;
+ }
+ return RTUtf16GetCpExInternal(ppwsz, pCp);
+}
+
+/**
+ * Put the unicode code point at the given string position
+ * and return the pointer to the char following it.
+ *
+ * This function will not consider anything at or following the
+ * buffer area pointed to by pwsz. It is therefore not suitable for
+ * inserting code points into a string, only appending/overwriting.
+ *
+ * @returns pointer to the char following the written code point.
+ * @param pwsz The string.
+ * @param CodePoint The code point to write.
+ * This should not be RTUNICP_INVALID or any other
+ * character out of the UTF-16 range.
+ *
+ * @remark We optimize this operation by using an inline function for
+ * everything which isn't a surrogate pair or and endian indicator.
+ */
+DECLINLINE(PRTUTF16) RTUtf16PutCp(PRTUTF16 pwsz, RTUNICP CodePoint)
+{
+ if (CodePoint < 0xd800 || (CodePoint > 0xd800 && CodePoint < 0xfffe))
+ {
+ *pwsz++ = (RTUTF16)CodePoint;
+ return pwsz;
+ }
+ return RTUtf16PutCpInternal(pwsz, CodePoint);
+}
+
+/**
+ * Skips ahead, past the current code point.
+ *
+ * @returns Pointer to the char after the current code point.
+ * @param pwsz Pointer to the current code point.
+ * @remark This will not move the next valid code point, only past the current one.
+ */
+DECLINLINE(PRTUTF16) RTUtf16NextCp(PCRTUTF16 pwsz)
+{
+ RTUNICP Cp;
+ RTUtf16GetCpEx(&pwsz, &Cp);
+ return (PRTUTF16)pwsz;
+}
+
+/**
+ * Skips backwards, to the previous code point.
+ *
+ * @returns Pointer to the char after the current code point.
+ * @param pwszStart Pointer to the start of the string.
+ * @param pwsz Pointer to the current code point.
+ */
+RTDECL(PRTUTF16) RTUtf16PrevCp(PCRTUTF16 pwszStart, PCRTUTF16 pwsz);
+
+
+/**
+ * Checks if the UTF-16 char is the high surrogate char (i.e.
+ * the 1st char in the pair).
+ *
+ * @returns true if it is.
+ * @returns false if it isn't.
+ * @param wc The character to investigate.
+ */
+DECLINLINE(bool) RTUtf16IsHighSurrogate(RTUTF16 wc)
+{
+ return wc >= 0xd800 && wc <= 0xdbff;
+}
+
+/**
+ * Checks if the UTF-16 char is the low surrogate char (i.e.
+ * the 2nd char in the pair).
+ *
+ * @returns true if it is.
+ * @returns false if it isn't.
+ * @param wc The character to investigate.
+ */
+DECLINLINE(bool) RTUtf16IsLowSurrogate(RTUTF16 wc)
+{
+ return wc >= 0xdc00 && wc <= 0xdfff;
+}
+
+
+/**
+ * Checks if the two UTF-16 chars form a valid surrogate pair.
+ *
+ * @returns true if they do.
+ * @returns false if they doesn't.
+ * @param wcHigh The high (1st) character.
+ * @param wcLow The low (2nd) character.
+ */
+DECLINLINE(bool) RTUtf16IsSurrogatePair(RTUTF16 wcHigh, RTUTF16 wcLow)
+{
+ return RTUtf16IsHighSurrogate(wcHigh)
+ && RTUtf16IsLowSurrogate(wcLow);
+}
+
+/**
+ * Formats a buffer stream as hex bytes.
+ *
+ * The default is no separating spaces or line breaks or anything.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_INVALID_POINTER if any of the pointers are wrong.
+ * @retval VERR_BUFFER_OVERFLOW if the buffer is insufficent to hold the bytes.
+ *
+ * @param pwszBuf Output string buffer.
+ * @param cwcBuf The size of the output buffer in RTUTF16 units.
+ * @param pv Pointer to the bytes to stringify.
+ * @param cb The number of bytes to stringify.
+ * @param fFlags Combination of RTSTRPRINTHEXBYTES_F_XXX values.
+ * @sa RTStrPrintHexBytes.
+ */
+RTDECL(int) RTUtf16PrintHexBytes(PRTUTF16 pwszBuf, size_t cwcBuf, void const *pv, size_t cb, uint32_t fFlags);
+
+/** @} */
+
+
+RT_C_DECLS_END
+
+/** @} */
+
+#endif
+
/** BIOS update signature (microcode). */
#define MSR_IA32_BIOS_SIGN_ID 0x8B
+/** SMM monitor control. */
+#define MSR_IA32_SMM_MONITOR_CTL 0x9B
+
/** General performance counter no. 0. */
#define MSR_IA32_PMC0 0xC1
/** General performance counter no. 1. */
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define RTMEM_NO_WRAP_TO_EF_APIS
#include <iprt/mem.h>
#include "internal/iprt.h"
#include "r0drv/alloc-r0drv.h"
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
#ifdef RT_STRICT
# define RTR0MEM_STRICT
#endif
#endif
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
#ifdef RTR0MEM_STRICT
/** Fence data. */
static uint8_t const g_abFence[RTR0MEM_FENCE_EXTRA] =
}
-RTDECL(void *) RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
+RTDECL(void *) RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
{
return RTMemAllocTag(cb, pszTag);
}
RT_EXPORT_SYMBOL(RTMemTmpAllocTag);
-RTDECL(void *) RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
+RTDECL(void *) RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
{
return RTMemAllocZTag(cb, pszTag);
}
RT_EXPORT_SYMBOL(RTMemTmpAllocZTag);
-RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW
+RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW_DEF
{
return RTMemFree(pv);
}
-RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
+RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
{
PRTMEMHDR pHdr;
RT_ASSERT_INTS_ON();
RT_EXPORT_SYMBOL(RTMemAllocTag);
-RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
+RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
{
PRTMEMHDR pHdr;
RT_ASSERT_INTS_ON();
RT_EXPORT_SYMBOL(RTMemAllocZVarTag);
-RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW
+RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW_DEF
{
PRTMEMHDR pHdrOld;
RT_EXPORT_SYMBOL(RTMemReallocTag);
-RTDECL(void) RTMemFree(void *pv) RT_NO_THROW
+RTDECL(void) RTMemFree(void *pv) RT_NO_THROW_DEF
{
PRTMEMHDR pHdr;
RT_ASSERT_INTS_ON();
-RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
+RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
{
PRTMEMHDR pHdr;
#ifdef RT_OS_SOLARIS /** @todo figure out why */
RT_EXPORT_SYMBOL(RTMemExecAllocTag);
-RTDECL(void) RTMemExecFree(void *pv, size_t cb) RT_NO_THROW
+RTDECL(void) RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_DEF
{
PRTMEMHDR pHdr;
RT_ASSERT_INTS_ON();
-RTDECL(int) RTMemAllocExTag(size_t cb, size_t cbAlignment, uint32_t fFlags, const char *pszTag, void **ppv) RT_NO_THROW
+RTDECL(int) RTMemAllocExTag(size_t cb, size_t cbAlignment, uint32_t fFlags, const char *pszTag, void **ppv) RT_NO_THROW_DEF
{
uint32_t fHdrFlags = RTMEMHDR_FLAG_ALLOC_EX;
PRTMEMHDR pHdr;
RT_EXPORT_SYMBOL(RTMemAllocExTag);
-RTDECL(void) RTMemFreeEx(void *pv, size_t cb) RT_NO_THROW
+RTDECL(void) RTMemFreeEx(void *pv, size_t cb) RT_NO_THROW_DEF
{
PRTMEMHDR pHdr;
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#ifdef RT_OS_WINDOWS
# include "../nt/the-nt-kernel.h"
#endif
#include "internal/magics.h"
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Saved state information.
*/
} RTSEMSPINMUTEXINTERNAL;
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
/*#define RTSEMSPINMUTEX_INT_FLAGS_MUST*/
/** Validates the handle, returning if invalid. */
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/initterm.h>
#include "internal/iprt.h"
#include "internal/thread.h"
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** Count of current IPRT users.
* In ring-0 several drivers / kmods / kexts / wossnames may share the
* same runtime code. So, we need to keep count in order not to terminate
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#include <iprt/log.h>
RTDECL(void) RTLogWriteDebugger(const char *pch, size_t cb)
{
+ IPRT_LINUX_SAVE_EFL_AC();
printk("%.*s", (int)cb, pch);
+ IPRT_LINUX_RESTORE_EFL_AC();
}
RT_EXPORT_SYMBOL(RTLogWriteDebugger);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#include <iprt/mem.h>
#endif
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
#ifdef RTMEMALLOC_EXEC_VM_AREA
/**
* Extended header used for headers marked with RTMEMHDR_FLAG_EXEC_VM_AREA.
#endif
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
#ifdef RTMEMALLOC_EXEC_HEAP
/** The heap. */
static RTHEAPSIMPLE g_HeapExec = NIL_RTHEAPSIMPLE;
DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
{
PRTMEMHDR pHdr;
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* Allocate.
pHdr = vmalloc(cb + sizeof(*pHdr));
}
if (RT_UNLIKELY(!pHdr))
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }
/*
* Initialize.
pHdr->cbReq = cb;
*ppHdr = pHdr;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
*/
DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
pHdr->u32Magic += 1;
if (pHdr->fFlags & RTMEMHDR_FLAG_KMALLOC)
kfree(pHdr);
#endif
else
vfree(pHdr);
+
+ IPRT_LINUX_RESTORE_EFL_AC();
}
int cOrder;
unsigned cPages;
struct page *paPages;
+ void *pvRet;
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* validate input.
#endif
}
*pPhys = page_to_phys(paPages);
- return phys_to_virt(page_to_phys(paPages));
+ pvRet = phys_to_virt(page_to_phys(paPages));
}
+ else
+ pvRet = NULL;
- return NULL;
+ IPRT_LINUX_RESTORE_EFL_AC();
+ return pvRet;
}
RT_EXPORT_SYMBOL(RTMemContAlloc);
unsigned cPages;
unsigned iPage;
struct page *paPages;
+ IPRT_LINUX_SAVE_EFL_AC();
/* validate */
AssertMsg(!((uintptr_t)pv & PAGE_OFFSET_MASK), ("pv=%p\n", pv));
#endif
}
__free_pages(paPages, cOrder);
+ IPRT_LINUX_RESTORE_EFL_AC();
}
}
RT_EXPORT_SYMBOL(RTMemContFree);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
DECLHIDDEN(void) rtR0AssertNativeMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
{
+ IPRT_LINUX_SAVE_EFL_AC();
printk(KERN_EMERG
"\r\n!!Assertion Failed!!\r\n"
"Expression: %s\r\n"
"Location : %s(%d) %s\r\n",
pszExpr, pszFile, uLine, pszFunction);
+ IPRT_LINUX_RESTORE_EFL_AC();
}
DECLHIDDEN(void) rtR0AssertNativeMsg2V(bool fInitial, const char *pszFormat, va_list va)
{
char szMsg[256];
+ IPRT_LINUX_SAVE_EFL_AC();
RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, va);
szMsg[sizeof(szMsg) - 1] = '\0';
printk(KERN_EMERG "%s", szMsg);
NOREF(fInitial);
+ IPRT_LINUX_RESTORE_EFL_AC();
}
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#include <iprt/err.h>
#include "internal/initterm.h"
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** The IPRT work queue. */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
static struct workqueue_struct *g_prtR0LnxWorkQueue;
#endif
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
/* in alloc-r0drv0-linux.c */
DECLHIDDEN(void) rtR0MemExecCleanup(void);
*/
DECLHIDDEN(void) rtR0LnxWorkqueuePush(RTR0LNXWORKQUEUEITEM *pWork, void (*pfnWorker)(RTR0LNXWORKQUEUEITEM *))
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
INIT_WORK(pWork, pfnWorker);
INIT_TQUEUE(pWork, (void (*)(void *))pfnWorker, pWork);
queue_task(pWork, &g_rtR0LnxWorkQueue);
#endif
+
+ IPRT_LINUX_RESTORE_EFL_AC();
}
*/
DECLHIDDEN(void) rtR0LnxWorkqueueFlush(void)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
flush_workqueue(g_prtR0LnxWorkQueue);
#else
run_task_queue(&g_rtR0LnxWorkQueue);
#endif
+
+ IPRT_LINUX_RESTORE_EFL_AC();
}
DECLHIDDEN(int) rtR0InitNative(void)
{
+ int rc = VINF_SUCCESS;
+ IPRT_LINUX_SAVE_EFL_AC();
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxWQueue");
g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxQ");
#endif
if (!g_prtR0LnxWorkQueue)
- return VERR_NO_MEMORY;
+ rc = VERR_NO_MEMORY;
#endif
- return VINF_SUCCESS;
+ IPRT_LINUX_RESTORE_EFL_AC();
+ return rc;
}
DECLHIDDEN(void) rtR0TermNative(void)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
rtR0LnxWorkqueueFlush();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
destroy_workqueue(g_prtR0LnxWorkQueue);
#endif
rtR0MemExecCleanup();
+
+ IPRT_LINUX_RESTORE_EFL_AC();
}
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include <iprt/memobj.h>
#include "internal/memobj.h"
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
/* early 2.6 kernels */
#ifndef PAGE_SHARED_EXEC
# define PAGE_SHARED_EXEC PAGE_SHARED
#endif
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* The Darwin version of the memory object structure.
*/
DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
{
+ IPRT_LINUX_SAVE_EFL_AC();
PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)pMem;
/*
AssertMsgFailed(("enmType=%d\n", pMemLnx->Core.enmType));
return VERR_INTERNAL_ERROR;
}
+ IPRT_LINUX_RESTORE_EFL_ONLY_AC();
return VINF_SUCCESS;
}
DECLHIDDEN(int) rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
{
+ IPRT_LINUX_SAVE_EFL_AC();
PRTR0MEMOBJLNX pMemLnx;
int rc;
if (RT_SUCCESS(rc))
{
*ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
rtR0MemObjDelete(&pMemLnx->Core);
}
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
DECLHIDDEN(int) rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
{
+ IPRT_LINUX_SAVE_EFL_AC();
PRTR0MEMOBJLNX pMemLnx;
int rc;
if (RT_SUCCESS(rc))
{
*ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
rtR0MemObjDelete(&pMemLnx->Core);
}
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
DECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
{
+ IPRT_LINUX_SAVE_EFL_AC();
PRTR0MEMOBJLNX pMemLnx;
int rc;
#endif
pMemLnx->Core.u.Cont.Phys = page_to_phys(pMemLnx->apPages[0]);
*ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
rtR0MemObjDelete(&pMemLnx->Core);
}
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
/**
* Worker for rtR0MemObjLinuxAllocPhysSub that tries one allocation strategy.
*
- * @returns IPRT status.
+ * @returns IPRT status code.
* @param ppMemLnx Where to
* @param enmType The object type.
* @param cb The size of the allocation.
/**
* Worker for rtR0MemObjNativeAllocPhys and rtR0MemObjNativeAllocPhysNC.
*
- * @returns IPRT status.
+ * @returns IPRT status code.
* @param ppMem Where to store the memory object pointer on success.
* @param enmType The object type.
* @param cb The size of the allocation.
size_t cb, size_t uAlignment, RTHCPHYS PhysHighest)
{
int rc;
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* There are two clear cases and that's the <=16MB and anything-goes ones.
/* ZONE_DMA: 0-16MB */
rc = rtR0MemObjLinuxAllocPhysSub2(ppMem, enmType, cb, uAlignment, PhysHighest, GFP_DMA);
}
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
DECLHIDDEN(int) rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
/*
* All we need to do here is to validate that we can use
* ioremap on the specified address (32/64-bit dma_addr_t).
pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_PHYS, NULL, cb);
if (!pMemLnx)
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }
pMemLnx->Core.u.Phys.PhysBase = PhysAddr;
pMemLnx->Core.u.Phys.fAllocated = false;
pMemLnx->Core.u.Phys.uCachePolicy = uCachePolicy;
Assert(!pMemLnx->cPages);
*ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
DECLHIDDEN(int) rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process)
{
+ IPRT_LINUX_SAVE_EFL_AC();
const int cPages = cb >> PAGE_SHIFT;
struct task_struct *pTask = rtR0ProcessToLinuxTask(R0Process);
struct vm_area_struct **papVMAs;
*/
pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(RT_OFFSETOF(RTR0MEMOBJLNX, apPages[cPages]), RTR0MEMOBJTYPE_LOCK, (void *)R3Ptr, cb);
if (!pMemLnx)
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }
papVMAs = (struct vm_area_struct **)RTMemAlloc(sizeof(*papVMAs) * cPages);
if (papVMAs)
Assert(!pMemLnx->fMappedToRing0);
*ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
}
rtR0MemObjDelete(&pMemLnx->Core);
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
DECLHIDDEN(int) rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess)
{
+ IPRT_LINUX_SAVE_EFL_AC();
void *pvLast = (uint8_t *)pv + cb - 1;
size_t const cPages = cb >> PAGE_SHIFT;
PRTR0MEMOBJLNX pMemLnx;
*/
pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(RT_OFFSETOF(RTR0MEMOBJLNX, apPages[cPages]), RTR0MEMOBJTYPE_LOCK, pv, cb);
if (!pMemLnx)
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }
/*
* Gather the pages.
Assert(!pMemLnx->fMappedToRing0);
*ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
rtR0MemObjDelete(&pMemLnx->Core);
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
DECLHIDDEN(int) rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
+ IPRT_LINUX_SAVE_EFL_AC();
const size_t cPages = cb >> PAGE_SHIFT;
struct page *pDummyPage;
struct page **papPages;
* the dummy page is mapped all over the reserved area.
*/
pDummyPage = alloc_page(GFP_HIGHUSER | __GFP_NOWARN);
- if (!pDummyPage)
- return VERR_NO_MEMORY;
- papPages = RTMemAlloc(sizeof(*papPages) * cPages);
- if (papPages)
+ if (pDummyPage)
{
- void *pv;
- size_t iPage = cPages;
- while (iPage-- > 0)
- papPages[iPage] = pDummyPage;
+ papPages = RTMemAlloc(sizeof(*papPages) * cPages);
+ if (papPages)
+ {
+ void *pv;
+ size_t iPage = cPages;
+ while (iPage-- > 0)
+ papPages[iPage] = pDummyPage;
# ifdef VM_MAP
- pv = vmap(papPages, cPages, VM_MAP, PAGE_KERNEL_RO);
+ pv = vmap(papPages, cPages, VM_MAP, PAGE_KERNEL_RO);
# else
- pv = vmap(papPages, cPages, VM_ALLOC, PAGE_KERNEL_RO);
+ pv = vmap(papPages, cPages, VM_ALLOC, PAGE_KERNEL_RO);
# endif
- RTMemFree(papPages);
- if (pv)
- {
- PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
- if (pMemLnx)
+ RTMemFree(papPages);
+ if (pv)
{
- pMemLnx->Core.u.ResVirt.R0Process = NIL_RTR0PROCESS;
- pMemLnx->cPages = 1;
- pMemLnx->apPages[0] = pDummyPage;
- *ppMem = &pMemLnx->Core;
- return VINF_SUCCESS;
+ PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
+ if (pMemLnx)
+ {
+ pMemLnx->Core.u.ResVirt.R0Process = NIL_RTR0PROCESS;
+ pMemLnx->cPages = 1;
+ pMemLnx->apPages[0] = pDummyPage;
+ *ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+ vunmap(pv);
}
- vunmap(pv);
}
+ __free_page(pDummyPage);
}
- __free_page(pDummyPage);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
#else /* < 2.4.22 */
DECLHIDDEN(int) rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
{
+ IPRT_LINUX_SAVE_EFL_AC();
PRTR0MEMOBJLNX pMemLnx;
void *pv;
struct task_struct *pTask = rtR0ProcessToLinuxTask(R0Process);
*/
pv = rtR0MemObjLinuxDoMmap(R3PtrFixed, cb, uAlignment, pTask, RTMEM_PROT_NONE);
if (pv == (void *)-1)
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }
pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
if (!pMemLnx)
{
rtR0MemObjLinuxDoMunmap(pv, cb, pTask);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
}
pMemLnx->Core.u.ResVirt.R0Process = R0Process;
*ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
int rc = VERR_NO_MEMORY;
PRTR0MEMOBJLNX pMemLnxToMap = (PRTR0MEMOBJLNX)pMemToMap;
PRTR0MEMOBJLNX pMemLnx;
+ IPRT_LINUX_SAVE_EFL_AC();
/* Fail if requested to do something we can't. */
AssertMsgReturn(!offSub && !cbSub, ("%#x %#x\n", offSub, cbSub), VERR_NOT_SUPPORTED);
{
pMemLnx->Core.u.Mapping.R0Process = NIL_RTR0PROCESS;
*ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
rtR0MemObjDelete(&pMemLnx->Core);
}
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
struct page *pDummyPage;
RTHCPHYS DummyPhys;
#endif
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* Check for restrictions.
*/
pDummyPage = alloc_page(GFP_USER | __GFP_NOWARN);
if (!pDummyPage)
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }
SetPageReserved(pDummyPage);
DummyPhys = page_to_phys(pDummyPage);
#endif
pMemLnx->Core.pv = pv;
pMemLnx->Core.u.Mapping.R0Process = R0Process;
*ppMem = &pMemLnx->Core;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
__free_page(pDummyPage);
#endif
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb)
{
+ IPRT_LINUX_SAVE_EFL_AC();
if (RT_LIKELY(copy_from_user(pvDst, (void *)R3PtrSrc, cb) == 0))
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
+ }
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_ACCESS_DENIED;
}
RT_EXPORT_SYMBOL(RTR0MemUserCopyFrom);
RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb)
{
+ IPRT_LINUX_SAVE_EFL_AC();
if (RT_LIKELY(copy_to_user((void *)R3PtrDst, pvSrc, cb) == 0))
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
+ }
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_ACCESS_DENIED;
}
RT_EXPORT_SYMBOL(RTR0MemUserCopyTo);
RTR0DECL(bool) RTR0MemUserIsValidAddr(RTR3PTR R3Ptr)
{
- return access_ok(VERIFY_READ, (void *)R3Ptr, 1);
+ IPRT_LINUX_SAVE_EFL_AC();
+ bool fRc = access_ok(VERIFY_READ, (void *)R3Ptr, 1);
+ IPRT_LINUX_RESTORE_EFL_AC();
+ return fRc;
}
RT_EXPORT_SYMBOL(RTR0MemUserIsValidAddr);
# endif
# endif /* !_ASM_EXTABLE */
int rc;
+ IPRT_LINUX_SAVE_EFL_AC(); /* paranoia */
if (!cb)
return VINF_SUCCESS;
"2" (pvSrc),
"3" (cb)
: "memory");
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
#else
return VERR_NOT_SUPPORTED;
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
{
+ IPRT_LINUX_SAVE_EFL_AC();
int rc;
RTMPARGS Args;
RTCPUSET OnlineSet;
}
RTThreadPreemptRestore(&PreemptState);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTMpOnAll);
RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
{
+ IPRT_LINUX_SAVE_EFL_AC();
int rc;
RTMPARGS Args;
RTThreadPreemptRestore(&PreemptState);
Assert(rc == 0); NOREF(rc);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTMpOnOthers);
RTDECL(int) RTMpOnPair(RTCPUID idCpu1, RTCPUID idCpu2, uint32_t fFlags, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
{
+ IPRT_LINUX_SAVE_EFL_AC();
int rc;
RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;
else
rc = VERR_CPU_NOT_FOUND;
RTThreadPreemptRestore(&PreemptState);;
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
RT_EXPORT_SYMBOL(RTMpOnPair);
RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
{
+ IPRT_LINUX_SAVE_EFL_AC();
int rc;
RTMPARGS Args;
RTThreadPreemptRestore(&PreemptState);;
NOREF(rc);
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
RT_EXPORT_SYMBOL(RTMpOnSpecific);
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
int rc;
+ IPRT_LINUX_SAVE_EFL_AC();
if (!RTMpIsCpuPossible(idCpu))
return VERR_CPU_NOT_FOUND;
# endif /* older kernels */
NOREF(rc);
Assert(rc == 0);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
#else /* older kernels */
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 71) && defined(CONFIG_SMP)
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu);
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/**
* The notifier block we use for registering the callback.
*/
DECLHIDDEN(int) rtR0MpNotificationNativeInit(void)
{
int rc;
+ IPRT_LINUX_SAVE_EFL_AC();
# ifdef CPU_DOWN_FAILED
RTCpuSetEmpty(&g_MpPendingOfflineSet);
# endif
rc = register_cpu_notifier(&g_NotifierBlock);
+ IPRT_LINUX_RESTORE_EFL_AC();
AssertMsgReturn(!rc, ("%d\n", rc), RTErrConvertFromErrno(rc));
return VINF_SUCCESS;
}
DECLHIDDEN(void) rtR0MpNotificationNativeTerm(void)
{
+ IPRT_LINUX_SAVE_EFL_AC();
unregister_cpu_notifier(&g_NotifierBlock);
+ IPRT_LINUX_RESTORE_EFL_AC();
}
#else /* Not supported / Not needed */
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define RTSEMEVENT_WITHOUT_REMAPPING
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#include "internal/magics.h"
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Linux event semaphore.
*/
RTDECL(int) RTSemEventCreateEx(PRTSEMEVENT phEventSem, uint32_t fFlags, RTLOCKVALCLASS hClass, const char *pszNameFmt, ...)
{
PRTSEMEVENTINTERNAL pThis;
+ IPRT_LINUX_SAVE_EFL_AC();
AssertReturn(!(fFlags & ~(RTSEMEVENT_FLAGS_NO_LOCK_VAL | RTSEMEVENT_FLAGS_BOOTSTRAP_HACK)), VERR_INVALID_PARAMETER);
Assert(!(fFlags & RTSEMEVENT_FLAGS_BOOTSTRAP_HACK) || (fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL));
init_waitqueue_head(&pThis->Head);
*phEventSem = pThis;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSemEventCreate);
RTDECL(int) RTSemEventDestroy(RTSEMEVENT hEventSem)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
/*
* Validate input.
*/
Assert(!waitqueue_active(&pThis->Head));
wake_up_all(&pThis->Head);
rtR0SemEventLnxRelease(pThis);
+
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSemEventDestroy);
RTDECL(int) RTSemEventSignal(RTSEMEVENT hEventSem)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
/*
* Validate input.
*/
wake_up(&pThis->Head);
rtR0SemEventLnxRelease(pThis);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSemEventSignal);
/*
* We have to wait.
*/
+ IPRT_LINUX_SAVE_EFL_AC();
RTR0SEMLNXWAIT Wait;
rc = rtR0SemLnxWaitInit(&Wait, fFlags, uTimeout, &pThis->Head);
if (RT_SUCCESS(rc))
rtR0SemLnxWaitDelete(&Wait);
IPRT_DEBUG_SEMS_STATE_RC(pThis, 'E', rc);
}
+ IPRT_LINUX_RESTORE_EFL_AC();
}
rtR0SemEventLnxRelease(pThis);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define RTSEMEVENTMULTI_WITHOUT_REMAPPING
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#include "internal/magics.h"
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
/** @name fStateAndGen values
* @{ */
/** The state bit number. */
/** @} */
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Linux event semaphore.
*/
const char *pszNameFmt, ...)
{
PRTSEMEVENTMULTIINTERNAL pThis;
+ IPRT_LINUX_SAVE_EFL_AC();
AssertReturn(!(fFlags & ~RTSEMEVENTMULTI_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
pThis = (PRTSEMEVENTMULTIINTERNAL)RTMemAlloc(sizeof(*pThis));
init_waitqueue_head(&pThis->Head);
*phEventMultiSem = pThis;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
}
RT_EXPORT_SYMBOL(RTSemEventMultiCreate);
RTDECL(int) RTSemEventMultiDestroy(RTSEMEVENTMULTI hEventMultiSem)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
/*
* Validate input.
*/
Assert(!waitqueue_active(&pThis->Head));
wake_up_all(&pThis->Head);
rtR0SemEventMultiLnxRelease(pThis);
+
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSemEventMultiDestroy);
RTDECL(int) RTSemEventMultiSignal(RTSEMEVENTMULTI hEventMultiSem)
{
+ IPRT_LINUX_SAVE_EFL_AC();
uint32_t fNew;
uint32_t fOld;
wake_up_all(&pThis->Head);
rtR0SemEventMultiLnxRelease(pThis);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSemEventMultiSignal);
* We have to wait.
*/
RTR0SEMLNXWAIT Wait;
+ IPRT_LINUX_SAVE_EFL_AC();
rc = rtR0SemLnxWaitInit(&Wait, fFlags, uTimeout, &pThis->Head);
if (RT_SUCCESS(rc))
{
rtR0SemLnxWaitDelete(&Wait);
IPRT_DEBUG_SEMS_STATE_RC(pThis, 'E', rc);
}
+ IPRT_LINUX_RESTORE_EFL_AC();
}
rtR0SemEventMultiLnxRelease(pThis);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#include <iprt/semaphore.h>
#include "internal/magics.h"
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Wrapper for the linux semaphore structure.
*/
RTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX phFastMtx)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
/*
* Allocate.
*/
#endif
*phFastMtx = pThis;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSemFastMutexCreate);
RTDECL(int) RTSemFastMutexRequest(RTSEMFASTMUTEX hFastMtx)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
/*
* Validate.
*/
AssertRelease(pThis->Owner == NIL_RTNATIVETHREAD);
ASMAtomicUoWriteSize(&pThis->Owner, RTThreadNativeSelf());
#endif
+
+ IPRT_LINUX_RESTORE_EFL_ONLY_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSemFastMutexRequest);
RTDECL(int) RTSemFastMutexRelease(RTSEMFASTMUTEX hFastMtx)
{
+ IPRT_LINUX_SAVE_EFL_AC();
+
/*
* Validate.
*/
#endif
up(&pThis->Semaphore);
IPRT_DEBUG_SEMS_STATE(pThis, 'u');
+
+ IPRT_LINUX_RESTORE_EFL_ONLY_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSemFastMutexRelease);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define RTSEMMUTEX_WITHOUT_REMAPPING
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#include "internal/magics.h"
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
typedef struct RTSEMMUTEXLNXWAITER
{
/** The list entry. */
RTDECL(int) RTSemMutexCreate(PRTSEMMUTEX phMtx)
{
+ int rc = VINF_SUCCESS;
+ IPRT_LINUX_SAVE_EFL_AC();
+
/*
* Allocate.
*/
PRTSEMMUTEXINTERNAL pThis;
pThis = (PRTSEMMUTEXINTERNAL)RTMemAlloc(sizeof(*pThis));
- if (!pThis)
- return VERR_NO_MEMORY;
+ if (pThis)
+ {
+ /*
+ * Initialize.
+ */
+ pThis->u32Magic = RTSEMMUTEX_MAGIC;
+ pThis->cRecursions = 0;
+ pThis->pOwnerTask = NULL;
+ pThis->cRefs = 1;
+ RTListInit(&pThis->WaiterList);
+ spin_lock_init(&pThis->Spinlock);
+
+ *phMtx = pThis;
+ }
+ else
+ rc = VERR_NO_MEMORY;
- /*
- * Initialize.
- */
- pThis->u32Magic = RTSEMMUTEX_MAGIC;
- pThis->cRecursions = 0;
- pThis->pOwnerTask = NULL;
- pThis->cRefs = 1;
- RTListInit(&pThis->WaiterList);
- spin_lock_init(&pThis->Spinlock);
-
- *phMtx = pThis;
- return VINF_SUCCESS;
+ IPRT_LINUX_RESTORE_EFL_AC();
+ return rc;
}
RT_EXPORT_SYMBOL(RTSemMutexCreate);
*/
AssertReturn(ASMAtomicCmpXchgU32(&pThis->u32Magic, RTSEMMUTEX_MAGIC_DEAD, RTSEMMUTEX_MAGIC), VERR_INVALID_HANDLE);
+ IPRT_LINUX_SAVE_EFL_AC();
+
spin_lock_irqsave(&pThis->Spinlock, fSavedIrq);
RTListForEach(&pThis->WaiterList, pCur, RTSEMMUTEXLNXWAITER, ListEntry)
{
RTMemFree(pThis);
}
+ IPRT_LINUX_RESTORE_EFL_AC();
+
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSemMutexDestroy);
struct task_struct *pSelf = current;
unsigned long fSavedIrq;
int rc;
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* Validate.
* No, so go to sleep.
*/
else
- return rtSemMutexLinuxRequestSleep(pThis, cMillies, fInterruptible, fSavedIrq);
+ {
+ rc = rtSemMutexLinuxRequestSleep(pThis, cMillies, fInterruptible, fSavedIrq);
+ IPRT_LINUX_RESTORE_EFL_ONLY_AC();
+ return rc;
+ }
IPRT_DEBUG_SEMS_STATE_RC(pThis, 'M', rc);
spin_unlock_irqrestore(&pThis->Spinlock, fSavedIrq);
+ IPRT_LINUX_RESTORE_EFL_ONLY_AC();
return rc;
}
struct task_struct *pSelf = current;
unsigned long fSavedIrq;
int rc;
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* Validate.
spin_unlock_irqrestore(&pThis->Spinlock, fSavedIrq);
AssertRC(rc);
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
RT_EXPORT_SYMBOL(RTSemMutexRelease);
PRTSEMMUTEXINTERNAL pThis = hMutexSem;
unsigned long fSavedIrq;
bool fOwned;
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* Validate.
fOwned = pThis->pOwnerTask != NULL;
spin_unlock_irqrestore(&pThis->Spinlock, fSavedIrq);
+ IPRT_LINUX_RESTORE_EFL_AC();
return fOwned;
}
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#include <iprt/spinlock.h>
#include "internal/magics.h"
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Wrapper for the spinlock_t structure.
*/
RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
{
+ IPRT_LINUX_SAVE_EFL_AC();
PRTSPINLOCKINTERNAL pThis;
AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
spin_lock_init(&pThis->Spinlock);
*pSpinlock = pThis;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTSpinlockCreate);
RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
{
PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
+ IPRT_LINUX_SAVE_EFL_AC();
RT_ASSERT_PREEMPT_CPUID_VAR();
AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC,
("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0));
lockdep_on();
#endif
+ IPRT_LINUX_RESTORE_EFL_ONLY_AC();
RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
}
RT_EXPORT_SYMBOL(RTSpinlockAcquire);
RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock)
{
PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
+ IPRT_LINUX_SAVE_EFL_AC(); /* spin_unlock* may preempt and trash eflags.ac. */
RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS();
AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC,
("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0));
lockdep_on();
#endif
+ IPRT_LINUX_RESTORE_EFL_ONLY_AC();
RT_ASSERT_PREEMPT_CPUID();
}
RT_EXPORT_SYMBOL(RTSpinlockRelease);
* The AMD 64 switch_to in macro in arch/x86/include/asm/switch_to.h stopped
* restoring flags.
* @{ */
-#ifdef CONFIG_X86_SMAP
+#if defined(CONFIG_X86_SMAP) || defined(RT_STRICT) || defined(IPRT_WITH_EFLAGS_AC_PRESERVING)
# include <iprt/asm-amd64-x86.h>
# define IPRT_X86_EFL_AC RT_BIT(18)
-# define IPRT_LINUX_SAVE_EFL_AC() RTCCUINTREG fSavedEfl = ASMGetFlags();
+# define IPRT_LINUX_SAVE_EFL_AC() RTCCUINTREG fSavedEfl = ASMGetFlags()
# define IPRT_LINUX_RESTORE_EFL_AC() ASMSetFlags(fSavedEfl)
-# define IPRT_LINUX_RESTORE_EFL_ONLY_AC() ASMSetFlags((ASMGetFlags() & ~IPRT_X86_EFL_AC) | (fSavedEfl & IPRT_X86_EFL_AC))
+# define IPRT_LINUX_RESTORE_EFL_ONLY_AC() ASMChangeFlags(~IPRT_X86_EFL_AC, fSavedEfl & IPRT_X86_EFL_AC)
#else
# define IPRT_LINUX_SAVE_EFL_AC() do { } while (0)
# define IPRT_LINUX_RESTORE_EFL_AC() do { } while (0)
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#include <iprt/thread.h>
#include <iprt/mp.h>
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
#ifndef CONFIG_PREEMPT
/** Per-cpu preemption counters. */
static int32_t volatile g_acPreemptDisabled[NR_CPUS];
static int rtR0ThreadLnxSleepCommon(RTMSINTERVAL cMillies)
{
+ IPRT_LINUX_SAVE_EFL_AC();
long cJiffies = msecs_to_jiffies(cMillies);
set_current_state(TASK_INTERRUPTIBLE);
cJiffies = schedule_timeout(cJiffies);
+ IPRT_LINUX_RESTORE_EFL_AC();
if (!cJiffies)
return VINF_SUCCESS;
return VERR_INTERRUPTED;
RTDECL(bool) RTThreadYield(void)
{
+ IPRT_LINUX_SAVE_EFL_AC();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 20)
yield();
#else
sys_sched_yield();
schedule();
#endif
+ IPRT_LINUX_RESTORE_EFL_AC();
return true;
}
RT_EXPORT_SYMBOL(RTThreadYield);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 4)
struct task_struct *NativeThread;
+ IPRT_LINUX_SAVE_EFL_AC();
RT_ASSERT_PREEMPTIBLE();
NativeThread = kthread_run(rtThreadNativeMain, pThreadInt, "iprt-%s", pThreadInt->szName);
- if (IS_ERR(NativeThread))
- return VERR_GENERAL_FAILURE;
-
- *pNativeThread = (RTNATIVETHREAD)NativeThread;
- return VINF_SUCCESS;
+ if (!IS_ERR(NativeThread))
+ {
+ *pNativeThread = (RTNATIVETHREAD)NativeThread;
+ IPRT_LINUX_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+ IPRT_LINUX_RESTORE_EFL_AC();
+ return VERR_GENERAL_FAILURE;
#else
return VERR_NOT_IMPLEMENTED;
#endif
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_TIME
#include "the-linux-kernel.h"
#include "internal/iprt.h"
RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
{
+ IPRT_LINUX_SAVE_EFL_AC();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
struct timespec Ts;
ktime_get_real_ts(&Ts);
+ IPRT_LINUX_RESTORE_EFL_AC();
return RTTimeSpecSetTimespec(pTime, &Ts);
#else /* < 2.6.16 */
struct timeval Tv;
do_gettimeofday(&Tv);
+ IPRT_LINUX_RESTORE_EFL_AC();
return RTTimeSpecSetTimeval(pTime, &Tv);
#endif
}
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include "the-linux-kernel.h"
#include "internal/iprt.h"
#endif
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Timer state machine.
*
typedef RTTIMERLINUXSTARTONCPUARGS *PRTTIMERLINUXSTARTONCPUARGS;
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
#ifdef CONFIG_SMP
static DECLCALLBACK(void) rtTimerLinuxMpEvent(RTMPEVENT enmEvent, RTCPUID idCpu, void *pvUser);
#endif
{
RTTIMERLINUXSTARTONCPUARGS Args;
int rc2;
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* Validate.
* Omni timer?
*/
if (pTimer->fAllCpus)
- return rtTimerLnxOmniStart(pTimer, &Args);
+ {
+ rc2 = rtTimerLnxOmniStart(pTimer, &Args);
+ IPRT_LINUX_RESTORE_EFL_AC();
+ return rc2;
+ }
#endif
/*
return rc2;
}
}
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
break;
if (rtTimerLnxCmpXchgState(&pTimer->aSubTimers[0].enmState, RTTIMERLNXSTATE_CB_RESTARTING, enmState))
{
ASMAtomicWriteBool(&pTimer->fSuspended, false);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
break;
default:
AssertMsgFailed(("%d\n", enmState));
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_INTERNAL_ERROR_4;
}
ASMNopPause();
/*
* Validate.
*/
+ IPRT_LINUX_SAVE_EFL_AC();
AssertPtrReturn(pTimer, VERR_INVALID_HANDLE);
AssertReturn(pTimer->u32Magic == RTTIMER_MAGIC, VERR_INVALID_HANDLE);
RTTIMERLNX_LOG(("stop %p\n", pTimer));
return VERR_TIMER_SUSPENDED;
rtTimerLnxStop(pTimer, false /*fForDestroy*/);
+
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTTimerStop);
{
unsigned long cJiffies;
unsigned long flFlags;
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* Validate.
if (pTimer->fHighRes)
{
ASMAtomicWriteU64(&pTimer->u64NanoInterval, u64NanoInterval);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
#endif
pTimer->cJiffies = cJiffies;
ASMAtomicWriteU64(&pTimer->u64NanoInterval, u64NanoInterval);
spin_unlock_irqrestore(&pTimer->ChgIntLock, flFlags);
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTTimerChangeInterval);
RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
{
bool fCanDestroy;
+ IPRT_LINUX_SAVE_EFL_AC();
/*
* Validate. It's ok to pass NULL pointer.
rtTimerLnxDestroyIt(pTimer);
}
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTTimerDestroy);
RTCPUID iCpu;
unsigned cCpus;
int rc;
+ IPRT_LINUX_SAVE_EFL_AC();
rtR0LnxWorkqueueFlush(); /* for 2.4 */
*ppTimer = NULL;
* Validate flags.
*/
if (!RTTIMER_FLAGS_ARE_VALID(fFlags))
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_INVALID_PARAMETER;
+ }
if ( (fFlags & RTTIMER_FLAGS_CPU_SPECIFIC)
&& (fFlags & RTTIMER_FLAGS_CPU_ALL) != RTTIMER_FLAGS_CPU_ALL
&& !RTMpIsCpuPossible(RTMpCpuIdFromSetIndex(fFlags & RTTIMER_FLAGS_CPU_MASK)))
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return VERR_CPU_NOT_FOUND;
+ }
/*
* Allocate the timer handler.
{
cCpus = RTMpGetMaxCpuId() + 1;
Assert(cCpus <= RTCPUSET_MAX_CPUS); /* On linux we have a 1:1 relationship between cpuid and set index. */
- AssertReturn(u64NanoInterval, VERR_NOT_IMPLEMENTED); /* We don't implement single shot on all cpus, sorry. */
+ AssertReturnStmt(u64NanoInterval, IPRT_LINUX_RESTORE_EFL_AC(), VERR_NOT_IMPLEMENTED); /* We don't implement single shot on all cpus, sorry. */
}
#endif
rc = RTMemAllocEx(RT_OFFSETOF(RTTIMER, aSubTimers[cCpus]), 0,
RTMEMALLOCEX_FLAGS_ZEROED | RTMEMALLOCEX_FLAGS_ANY_CTX_FREE, (void **)&pTimer);
if (RT_FAILURE(rc))
+ {
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
+ }
/*
* Initialize it.
if (RT_FAILURE(rc))
{
RTTimerDestroy(pTimer);
+ IPRT_LINUX_RESTORE_EFL_AC();
return rc;
}
}
RTTIMERLNX_LOG(("create %p hires=%d fFlags=%#x cCpus=%u\n", pTimer, pTimer->fHighRes, fFlags, cCpus));
*ppTimer = pTimer;
+ IPRT_LINUX_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
RT_EXPORT_SYMBOL(RTTimerCreateEx);
#if 0 /** @todo Not sure if this is what we want or not... Add new API for
* querying the resolution of the high res timers? */
struct timespec Ts;
- int rc = hrtimer_get_res(CLOCK_MONOTONIC, &Ts);
+ int rc;
+ IPRT_LINUX_SAVE_EFL_AC();
+ rc = hrtimer_get_res(CLOCK_MONOTONIC, &Ts);
+ IPRT_LINUX_RESTORE_EFL_AC();
if (!rc)
{
Assert(!Ts.tv_sec);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_DEFAULT ///@todo RTLOGGROUP_MEM
#include <iprt/memobj.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/mp.h>
#include "internal/iprt.h"
#include "r0drv/mp-r0drv.h"
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Notification registration record tracking
* RTMpRegisterNotification() calls.
typedef RTMPNOTIFYREG *PRTMPNOTIFYREG;
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** The spinlock protecting the list. */
static RTSPINLOCK volatile g_hRTMpNotifySpinLock = NIL_RTSPINLOCK;
/** List of callbacks, in registration order. */
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/power.h>
#include "internal/iprt.h"
#include "r0drv/power-r0drv.h"
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Notification registration record tracking
* RTPowerRegisterNotification() calls.
typedef RTPOWERNOTIFYREG *PRTPOWERNOTIFYREG;
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** The spinlock protecting the list. */
static RTSPINLOCK volatile g_hRTPowerNotifySpinLock = NIL_RTSPINLOCK;
/** List of callbacks, in registration order. */
#include <iprt/assert.h>
#include <iprt/string.h>
-DECLVBGL(int) VbglGRVerify (const VMMDevRequestHeader *pReq, size_t cbReq)
+
+DECLVBGL(int) VbglGRVerify(const VMMDevRequestHeader *pReq, size_t cbReq)
{
size_t cbReqExpected;
- if (!pReq || cbReq < sizeof (VMMDevRequestHeader))
+ if (RT_UNLIKELY(!pReq || cbReq < sizeof(VMMDevRequestHeader)))
{
dprintf(("VbglGRVerify: Invalid parameter: pReq = %p, cbReq = %zu\n", pReq, cbReq));
return VERR_INVALID_PARAMETER;
}
- if (pReq->size > cbReq)
+ if (RT_UNLIKELY(pReq->size > cbReq))
{
dprintf(("VbglGRVerify: request size %u > buffer size %zu\n", pReq->size, cbReq));
return VERR_INVALID_PARAMETER;
/* The request size must correspond to the request type. */
cbReqExpected = vmmdevGetRequestSize(pReq->requestType);
-
- if (cbReq < cbReqExpected)
+ if (RT_UNLIKELY(cbReq < cbReqExpected))
{
dprintf(("VbglGRVerify: buffer size %zu < expected size %zu\n", cbReq, cbReqExpected));
return VERR_INVALID_PARAMETER;
if (cbReqExpected == cbReq)
{
- /* This is most likely a fixed size request, and in this case the request size
- * must be also equal to the expected size.
+ /*
+ * This is most likely a fixed size request, and in this case the
+ * request size must be also equal to the expected size.
*/
- if (pReq->size != cbReqExpected)
+ if (RT_UNLIKELY(pReq->size != cbReqExpected))
{
dprintf(("VbglGRVerify: request size %u != expected size %zu\n", pReq->size, cbReqExpected));
return VERR_INVALID_PARAMETER;
|| pReq->requestType == VMMDevReq_HGCMCall64
#else
|| pReq->requestType == VMMDevReq_HGCMCall
-#endif /* VBOX_WITH_64_BITS_GUESTS */
+#endif
|| pReq->requestType == VMMDevReq_RegisterSharedModule
|| pReq->requestType == VMMDevReq_ReportGuestUserState
|| pReq->requestType == VMMDevReq_LogString
|| pReq->requestType == VMMDevReq_SetPointerShape
|| pReq->requestType == VMMDevReq_VideoSetVisibleRegion)
{
- if (cbReq > VMMDEV_MAX_VMMDEVREQ_SIZE)
+ if (RT_UNLIKELY(cbReq > VMMDEV_MAX_VMMDEVREQ_SIZE))
{
dprintf(("VbglGRVerify: VMMDevReq_LogString: buffer size %zu too big\n", cbReq));
- return VERR_BUFFER_OVERFLOW; /* @todo is this error code ok? */
+ return VERR_BUFFER_OVERFLOW; /** @todo is this error code ok? */
}
}
else
{
dprintf(("VbglGRVerify: request size %u > buffer size %zu\n", pReq->size, cbReq));
- return VERR_IO_BAD_LENGTH; /* @todo is this error code ok? */
+ return VERR_IO_BAD_LENGTH; /** @todo is this error code ok? */
}
return VINF_SUCCESS;
}
-DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType)
+DECLVBGL(int) VbglGRAlloc(VMMDevRequestHeader **ppReq, size_t cbReq, VMMDevRequestType enmReqType)
{
- VMMDevRequestHeader *pReq;
- int rc = vbglR0Enter ();
-
- if (RT_FAILURE(rc))
- return rc;
-
- if (!ppReq || cbSize < sizeof (VMMDevRequestHeader))
- {
- dprintf(("VbglGRAlloc: Invalid parameter: ppReq = %p, cbSize = %u\n", ppReq, cbSize));
- return VERR_INVALID_PARAMETER;
- }
-
- pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc (cbSize);
- if (!pReq)
+ int rc = vbglR0Enter();
+ if (RT_SUCCESS(rc))
{
- AssertMsgFailed(("VbglGRAlloc: no memory\n"));
- rc = VERR_NO_MEMORY;
- }
- else
- {
- memset(pReq, 0xAA, cbSize);
-
- pReq->size = cbSize;
- pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
- pReq->requestType = reqType;
- pReq->rc = VERR_GENERAL_FAILURE;
- pReq->reserved1 = 0;
- pReq->reserved2 = 0;
-
- *ppReq = pReq;
+ if ( ppReq
+ && cbReq >= sizeof(VMMDevRequestHeader)
+ && cbReq == (uint32_t)cbReq)
+ {
+ VMMDevRequestHeader *pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc((uint32_t)cbReq);
+ AssertMsgReturn(pReq, ("VbglGRAlloc: no memory (cbReq=%u)\n", cbReq), VERR_NO_MEMORY);
+ memset(pReq, 0xAA, cbReq);
+
+ pReq->size = (uint32_t)cbReq;
+ pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
+ pReq->requestType = enmReqType;
+ pReq->rc = VERR_GENERAL_FAILURE;
+ pReq->reserved1 = 0;
+ pReq->reserved2 = 0;
+
+ *ppReq = pReq;
+ rc = VINF_SUCCESS;
+ }
+ else
+ {
+ dprintf(("VbglGRAlloc: Invalid parameter: ppReq=%p cbReq=%u\n", ppReq, cbReq));
+ rc = VERR_INVALID_PARAMETER;
+ }
}
-
return rc;
}
-DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq)
+DECLVBGL(int) VbglGRPerform(VMMDevRequestHeader *pReq)
{
- RTCCPHYS physaddr;
- int rc = vbglR0Enter ();
-
- if (RT_FAILURE(rc))
- return rc;
-
- if (!pReq)
- return VERR_INVALID_PARAMETER;
-
- physaddr = VbglPhysHeapGetPhysAddr (pReq);
- if ( !physaddr
- || (physaddr >> 32) != 0) /* Port IO is 32 bit. */
+ int rc = vbglR0Enter();
+ if (RT_SUCCESS(rc))
{
- rc = VERR_VBGL_INVALID_ADDR;
- }
- else
- {
- ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)physaddr);
- /* Make the compiler aware that the host has changed memory. */
- ASMCompilerBarrier();
- rc = pReq->rc;
+ if (pReq)
+ {
+ RTCCPHYS PhysAddr = VbglPhysHeapGetPhysAddr(pReq);
+ if ( PhysAddr != 0
+ && PhysAddr < _4G) /* Port IO is 32 bit. */
+ {
+ ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)PhysAddr);
+ /* Make the compiler aware that the host has changed memory. */
+ ASMCompilerBarrier();
+ rc = pReq->rc;
+ }
+ else
+ rc = VERR_VBGL_INVALID_ADDR;
+ }
+ else
+ rc = VERR_INVALID_PARAMETER;
}
return rc;
}
-DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq)
+DECLVBGL(void) VbglGRFree(VMMDevRequestHeader *pReq)
{
- int rc = vbglR0Enter ();
-
- if (RT_FAILURE(rc))
- return;
-
- VbglPhysHeapFree (pReq);
+ int rc = vbglR0Enter();
+ if (RT_SUCCESS(rc))
+ VbglPhysHeapFree(pReq);
}
/* Entire file is ifdef'ed with VBGL_VBOXGUEST */
#ifdef VBGL_VBOXGUEST
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP LOG_GROUP_HGCM
#include "VBGLInternal.h"
#include <iprt/thread.h>
#include <iprt/time.h>
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
/** The max parameter buffer size for a user request. */
#define VBGLR0_MAX_HGCM_USER_PARM (24*_1M)
/** The max parameter buffer size for a kernel request. */
#endif
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Lock info structure used by VbglR0HGCMInternalCall and its helpers.
*/
HGCMFunctionParameter const *pSrcParm = VBOXGUEST_HGCM_CALL_PARMS(pCallInfo);
HGCMFunctionParameter *pDstParm = VMMDEV_HGCM_CALL_PARMS(pHGCMCall);
uint32_t cParms = pCallInfo->cParms;
- uint32_t offExtra = (uintptr_t)(pDstParm + cParms) - (uintptr_t)pHGCMCall;
+ uint32_t offExtra = (uint32_t)((uintptr_t)(pDstParm + cParms) - (uintptr_t)pHGCMCall);
uint32_t iLockBuf = 0;
uint32_t iParm;
else
#endif
pDstPgLst->offFirstPage = pSrcParm->u.Pointer.u.linearAddr & PAGE_OFFSET_MASK;
- pDstPgLst->cPages = cPages; Assert(pDstPgLst->cPages == cPages);
+ pDstPgLst->cPages = (uint32_t)cPages; Assert(pDstPgLst->cPages == cPages);
for (iPage = 0; iPage < cPages; iPage++)
{
pDstPgLst->aPages[iPage] = RTR0MemObjGetPagePhysAddr(hObj, iPage);
* terms and conditions of either the GPL or the CDDL or both.
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define VBGL_DECL_DATA
#include "VBGLInternal.h"
#include <iprt/assert.h>
#include <iprt/semaphore.h>
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** The global VBGL instance data. */
VBGLDATA g_vbgldata;
{
dprintf (("port = 0x%04X, mem = %p\n", port.portAddress, port.pVMMDevMemory));
- g_vbgldata.portVMMDev = port.portAddress;
+ g_vbgldata.portVMMDev = (RTIOPORT)port.portAddress;
g_vbgldata.pVMMDevMemory = port.pVMMDevMemory;
g_vbgldata.status = VbglStatusReady;
#ifdef VBGL_VBOXGUEST
-DECLVBGL(int) VbglInit (VBGLIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory)
+DECLVBGL(int) VbglInitPrimary(RTIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory)
{
int rc = VINF_SUCCESS;
# ifdef RT_OS_WINDOWS /** @todo r=bird: this doesn't make sense. Is there something special going on on windows? */
dprintf(("vbglInit: starts g_vbgldata.status %d\n", g_vbgldata.status));
- if (g_vbgldata.status == VbglStatusInitializing
+ if ( g_vbgldata.status == VbglStatusInitializing
|| g_vbgldata.status == VbglStatusReady)
{
/* Initialization is already in process. */
#else /* !VBGL_VBOXGUEST */
-DECLVBGL(int) VbglInit (void)
+DECLVBGL(int) VbglInitClient(void)
{
int rc = VINF_SUCCESS;
- if (g_vbgldata.status == VbglStatusInitializing
+ if ( g_vbgldata.status == VbglStatusInitializing
|| g_vbgldata.status == VbglStatusReady)
{
/* Initialization is already in process. */
return physAddr;
}
-DECLVBGL(void) VbglPhysHeapFree (void *p)
+DECLVBGL(void) VbglPhysHeapFree(void *p)
{
VBGLPHYSHEAPBLOCK *pBlock;
VBGLPHYSHEAPBLOCK *pNeighbour;
* @param fWriteAccess Lock for read-write (true) or readonly (false).
* @param fFlags HGCM call flags, VBGLR0_HGCM_F_XXX.
*/
-int vbglLockLinear (void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess, uint32_t fFlags)
+int vbglLockLinear(void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess, uint32_t fFlags)
{
int rc = VINF_SUCCESS;
#ifndef RT_OS_WINDOWS
/** @todo just use IPRT here. the extra allocation shouldn't matter much...
* Then we can move all this up one level even. */
#ifdef RT_OS_WINDOWS
- PMDL pMdl = IoAllocateMdl (pv, u32Size, FALSE, FALSE, NULL);
+ PMDL pMdl = IoAllocateMdl(pv, u32Size, FALSE, FALSE, NULL);
if (pMdl == NULL)
{
{
__try {
/* Calls to MmProbeAndLockPages must be enclosed in a try/except block. */
- MmProbeAndLockPages (pMdl,
- /** @todo (fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER? UserMode: KernelMode */
- KernelMode,
- (fWriteAccess) ? IoModifyAccess : IoReadAccess);
+ MmProbeAndLockPages(pMdl,
+ /** @todo (fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER? UserMode: KernelMode */
+ KernelMode,
+ (fWriteAccess) ? IoModifyAccess : IoReadAccess);
*ppvCtx = pMdl;
} __except(EXCEPTION_EXECUTE_HANDLER) {
- IoFreeMdl (pMdl);
+ IoFreeMdl(pMdl);
/** @todo */
rc = VERR_INVALID_PARAMETER;
AssertMsgFailed(("MmProbeAndLockPages %p %x failed!!\n", pv, u32Size));
return rc;
}
-void vbglUnlockLinear (void *pvCtx, void *pv, uint32_t u32Size)
+void vbglUnlockLinear(void *pvCtx, void *pv, uint32_t u32Size)
{
#ifdef RT_OS_WINDOWS
PMDL pMdl = (PMDL)pvCtx;
Assert(pMdl);
if (pMdl != NULL)
{
- MmUnlockPages (pMdl);
- IoFreeMdl (pMdl);
+ MmUnlockPages(pMdl);
+ IoFreeMdl(pMdl);
}
#else
# if !defined(RT_OS_OS2) \
&& !defined(RT_OS_WINDOWS)
RT_C_DECLS_BEGIN
-extern DECLVBGL(void *) VBoxGuestIDCOpen (uint32_t *pu32Version);
-extern DECLVBGL(void) VBoxGuestIDCClose (void *pvOpaque);
-extern DECLVBGL(int) VBoxGuestIDCCall (void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn);
+extern DECLVBGL(void *) VBoxGuestIDCOpen(uint32_t *pu32Version);
+extern DECLVBGL(void) VBoxGuestIDCClose(void *pvOpaque);
+extern DECLVBGL(int) VBoxGuestIDCCall(void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn);
RT_C_DECLS_END
# endif
-bool vbglDriverIsOpened (VBGLDRIVER *pDriver)
+bool vbglDriverIsOpened(VBGLDRIVER *pDriver)
{
# ifdef RT_OS_WINDOWS
return pDriver->pFileObject != NULL;
# endif
}
-int vbglDriverOpen (VBGLDRIVER *pDriver)
+int vbglDriverOpen(VBGLDRIVER *pDriver)
{
# ifdef RT_OS_WINDOWS
UNICODE_STRING uszDeviceName;
- RtlInitUnicodeString (&uszDeviceName, L"\\Device\\VBoxGuest");
+ RtlInitUnicodeString(&uszDeviceName, L"\\Device\\VBoxGuest");
PDEVICE_OBJECT pDeviceObject = NULL;
PFILE_OBJECT pFileObject = NULL;
- NTSTATUS rc = IoGetDeviceObjectPointer (&uszDeviceName, FILE_ALL_ACCESS,
- &pFileObject, &pDeviceObject);
-
- if (NT_SUCCESS (rc))
+ NTSTATUS rc = IoGetDeviceObjectPointer(&uszDeviceName, FILE_ALL_ACCESS, &pFileObject, &pDeviceObject);
+ if (NT_SUCCESS(rc))
{
Log(("vbglDriverOpen VBoxGuest successful pDeviceObject=%x\n", pDeviceObject));
pDriver->pDeviceObject = pDeviceObject;
/*
* Just check whether the connection was made or not.
*/
- if ( g_VBoxGuestIDC.u32Version == VMMDEV_VERSION
- && VALID_PTR(g_VBoxGuestIDC.u32Session)
- && VALID_PTR(g_VBoxGuestIDC.pfnServiceEP))
+ if ( g_VBoxGuestIDC.u32Version == VMMDEV_VERSION
+ && RT_VALID_PTR(g_VBoxGuestIDC.u32Session)
+ && RT_VALID_PTR(g_VBoxGuestIDC.pfnServiceEP))
{
pDriver->u32Session = g_VBoxGuestIDC.u32Session;
return VINF_SUCCESS;
# else
uint32_t u32VMMDevVersion;
- pDriver->pvOpaque = VBoxGuestIDCOpen (&u32VMMDevVersion);
- if ( pDriver->pvOpaque
- && u32VMMDevVersion == VMMDEV_VERSION)
+ pDriver->pvOpaque = VBoxGuestIDCOpen(&u32VMMDevVersion);
+ if ( pDriver->pvOpaque
+ && u32VMMDevVersion == VMMDEV_VERSION)
return VINF_SUCCESS;
Log(("vbglDriverOpen: failed\n"));
}
# ifdef RT_OS_WINDOWS
-static NTSTATUS vbglDriverIOCtlCompletion (IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
+static NTSTATUS vbglDriverIOCtlCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
{
Log(("VBGL completion %x\n", Irp));
KEVENT *pEvent = (KEVENT *)Context;
- KeSetEvent (pEvent, IO_NO_INCREMENT, FALSE);
+ KeSetEvent(pEvent, IO_NO_INCREMENT, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}
# endif
-int vbglDriverIOCtl (VBGLDRIVER *pDriver, uint32_t u32Function, void *pvData, uint32_t cbData)
+int vbglDriverIOCtl(VBGLDRIVER *pDriver, uint32_t u32Function, void *pvData, uint32_t cbData)
{
Log(("vbglDriverIOCtl: pDriver: %p, Func: %x, pvData: %p, cbData: %d\n", pDriver, u32Function, pvData, cbData));
# ifdef RT_OS_WINDOWS
KEVENT Event;
- KeInitializeEvent (&Event, NotificationEvent, FALSE);
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
/* Have to use the IoAllocateIRP method because this code is generic and
* must work in any thread context.
* The IoBuildDeviceIoControlRequest, which was used here, does not work
* when APCs are disabled, for example.
*/
- PIRP irp = IoAllocateIrp (pDriver->pDeviceObject->StackSize, FALSE);
+ PIRP irp = IoAllocateIrp(pDriver->pDeviceObject->StackSize, FALSE);
Log(("vbglDriverIOCtl: irp %p, IRQL = %d\n", irp, KeGetCurrentIrql()));
* Setup the IRP_MJ_DEVICE_CONTROL IRP.
*/
- PIO_STACK_LOCATION nextStack = IoGetNextIrpStackLocation (irp);
+ PIO_STACK_LOCATION nextStack = IoGetNextIrpStackLocation(irp);
nextStack->MajorFunction = IRP_MJ_DEVICE_CONTROL;
nextStack->MinorFunction = 0;
irp->MdlAddress = NULL;
/* A completion routine is required to signal the Event. */
- IoSetCompletionRoutine (irp, vbglDriverIOCtlCompletion, &Event, TRUE, TRUE, TRUE);
+ IoSetCompletionRoutine(irp, vbglDriverIOCtlCompletion, &Event, TRUE, TRUE, TRUE);
- NTSTATUS rc = IoCallDriver (pDriver->pDeviceObject, irp);
+ NTSTATUS rc = IoCallDriver(pDriver->pDeviceObject, irp);
if (NT_SUCCESS (rc))
{
/* Wait the event to be signalled by the completion routine. */
- KeWaitForSingleObject (&Event,
- Executive,
- KernelMode,
- FALSE,
- NULL);
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
rc = irp->IoStatus.Status;
Log(("vbglDriverIOCtl: wait completed IRQL = %d\n", KeGetCurrentIrql()));
}
- IoFreeIrp (irp);
+ IoFreeIrp(irp);
if (rc != STATUS_SUCCESS)
Log(("vbglDriverIOCtl: ntstatus=%x\n", rc));
# endif
}
-void vbglDriverClose (VBGLDRIVER *pDriver)
+void vbglDriverClose(VBGLDRIVER *pDriver)
{
# ifdef RT_OS_WINDOWS
Log(("vbglDriverClose pDeviceObject=%x\n", pDriver->pDeviceObject));
- ObDereferenceObject (pDriver->pFileObject);
+ ObDereferenceObject(pDriver->pFileObject);
pDriver->pFileObject = NULL;
pDriver->pDeviceObject = NULL;
pDriver->u32Session = 0;
# else
- VBoxGuestIDCClose (pDriver->pvOpaque);
+ VBoxGuestIDCClose(pDriver->pvOpaque);
pDriver->pvOpaque = NULL;
# endif
}
* terms and conditions of either the GPL or the CDDL or both.
*/
-#ifndef __VBoxGuestLib_SysHlp_h
-#define __VBoxGuestLib_SysHlp_h
+#ifndef ___VBoxGuestLib_SysHlp_h
+#define ___VBoxGuestLib_SysHlp_h
#include <iprt/types.h>
/* XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist on NT4, so...
* The same for ExAllocatePool.
*/
-#undef ExAllocatePool
-#undef ExFreePool
+# undef ExAllocatePool
+# undef ExFreePool
#endif
typedef struct _VBGLDRIVER
#endif
} VBGLDRIVER;
-int vbglLockLinear (void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess, uint32_t fFlags);
-void vbglUnlockLinear (void *pvCtx, void *pv, uint32_t u32Size);
+int vbglLockLinear(void **ppvCtx, void *pv, uint32_t cb, bool fWriteAccess, uint32_t fFlags);
+void vbglUnlockLinear(void *pvCtx, void *pv, uint32_t cb);
#ifndef VBGL_VBOXGUEST
*
* @param pDriver Pointer to the driver structure.
*
- * @return VBox error code
+ * @return VBox status code
*/
-int vbglDriverOpen (VBGLDRIVER *pDriver);
+int vbglDriverOpen(VBGLDRIVER *pDriver);
/**
* Answers whether the VBoxGuest driver is opened
*
* @return true - if opened, false - otherwise
*/
-bool vbglDriverIsOpened (VBGLDRIVER *pDriver);
+bool vbglDriverIsOpened(VBGLDRIVER *pDriver);
/**
* Call VBoxGuest driver.
* @param pvData Pointer to supplied in/out data buffer.
* @param cbData Size of data buffer.
*
- * @return VBox error code
+ * @returns VBox status code
*/
-int vbglDriverIOCtl (VBGLDRIVER *pDriver, uint32_t u32Function, void *pvData, uint32_t cbData);
+int vbglDriverIOCtl(VBGLDRIVER *pDriver, uint32_t u32Function, void *pvData, uint32_t cbData);
/**
* Close VBoxGuest driver.
*
* @param pDriver Pointer to the driver structure.
*
- * @return VBox error code
+ * @returns VBox status code
*/
-void vbglDriverClose (VBGLDRIVER *pDriver);
+void vbglDriverClose(VBGLDRIVER *pDriver);
#endif
-#endif /* !__VBoxGuestLib_SysHlp_h */
+#endif
* Global VBGL ring-0 data.
* Lives in VbglR0Init.cpp.
*/
-typedef struct _VBGLDATA
+typedef struct VBGLDATA
{
enum VbglLibStatus status;
- VBGLIOPORT portVMMDev;
+ RTIOPORT portVMMDev;
VMMDevMemory *pVMMDevMemory;
#ifdef VBOX_WITH_HGCM
# ifndef VBGL_VBOXGUEST
-int vbglR0HGCMInit (void);
-int vbglR0HGCMTerminate (void);
+int vbglR0HGCMInit(void);
+int vbglR0HGCMTerminate(void);
# endif
+struct VBGLHGCMHANDLEDATA *vbglHGCMHandleAlloc(void);
+void vbglHGCMHandleFree(struct VBGLHGCMHANDLEDATA *pHandle);
#endif /* VBOX_WITH_HGCM */
#ifndef VBGL_VBOXGUEST
*
*
*
- * @section sec_logging_destination The Group Specifier.
+ * @section sec_logging_group The Group Specifier.
*
* The {logger-env-base} environment variable can be used to specify which
* logger groups to enable and which to disable. By default all groups are
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#ifdef IN_RING3
# if defined(RT_OS_WINDOWS)
# include <Windows.h>
#endif
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** The default logger. */
static PRTLOGGER g_pLogger = NULL;
/** The default logger groups.
* terms and conditions of either the GPL or the CDDL or both.
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <VBox/log.h>
#include "internal/iprt.h"
#include <iprt/asm-amd64-x86.h>
#endif
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
static DECLCALLBACK(size_t) rtLogBackdoorOutput(void *pv, const char *pachChars, size_t cbChars);
-/* $Rev: 100489 $ */
+/* $Rev: 103598 $ */
/** @file
* VBoxGuest - Linux specifics.
*
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP LOG_GROUP_SUP_DRV
#include "the-linux-kernel.h"
#include <VBox/log.h>
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
/** The device name. */
#define DEVICE_NAME "vboxguest"
-/** The device name for the device node open to everyone.. */
+/** The device name for the device node open to everyone. */
#define DEVICE_NAME_USER "vboxuser"
/** The name of the PCI driver */
#define DRIVER_NAME DEVICE_NAME
#endif
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
-static void vboxguestLinuxTermPci(struct pci_dev *pPciDev);
-static int vboxguestLinuxModInit(void);
-static void vboxguestLinuxModExit(void);
-static int vboxguestLinuxOpen(struct inode *pInode, struct file *pFilp);
-static int vboxguestLinuxRelease(struct inode *pInode, struct file *pFilp);
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
+static void vgdrvLinuxTermPci(struct pci_dev *pPciDev);
+static int vgdrvLinuxProbePci(struct pci_dev *pPciDev, const struct pci_device_id *id);
+static int vgdrvLinuxModInit(void);
+static void vgdrvLinuxModExit(void);
+static int vgdrvLinuxOpen(struct inode *pInode, struct file *pFilp);
+static int vgdrvLinuxRelease(struct inode *pInode, struct file *pFilp);
#ifdef HAVE_UNLOCKED_IOCTL
-static long vboxguestLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg);
+static long vgdrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg);
#else
-static int vboxguestLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg);
+static int vgdrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg);
#endif
-static int vboxguestFAsync(int fd, struct file *pFile, int fOn);
-static unsigned int vboxguestPoll(struct file *pFile, poll_table *pPt);
-static ssize_t vboxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff);
+static int vgdrvLinuxFAsync(int fd, struct file *pFile, int fOn);
+static unsigned int vgdrvLinuxPoll(struct file *pFile, poll_table *pPt);
+static ssize_t vgdrvLinuxRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff);
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/**
* Device extention & session data association structure.
*/
static struct file_operations g_FileOps =
{
owner: THIS_MODULE,
- open: vboxguestLinuxOpen,
- release: vboxguestLinuxRelease,
+ open: vgdrvLinuxOpen,
+ release: vgdrvLinuxRelease,
#ifdef HAVE_UNLOCKED_IOCTL
- unlocked_ioctl: vboxguestLinuxIOCtl,
+ unlocked_ioctl: vgdrvLinuxIOCtl,
#else
- ioctl: vboxguestLinuxIOCtl,
+ ioctl: vgdrvLinuxIOCtl,
#endif
- fasync: vboxguestFAsync,
- read: vboxguestRead,
- poll: vboxguestPoll,
+ fasync: vgdrvLinuxFAsync,
+ read: vgdrvLinuxRead,
+ poll: vgdrvLinuxPoll,
llseek: no_llseek,
};
static struct file_operations g_FileOpsUser =
{
owner: THIS_MODULE,
- open: vboxguestLinuxOpen,
- release: vboxguestLinuxRelease,
+ open: vgdrvLinuxOpen,
+ release: vgdrvLinuxRelease,
#ifdef HAVE_UNLOCKED_IOCTL
- unlocked_ioctl: vboxguestLinuxIOCtl,
+ unlocked_ioctl: vgdrvLinuxIOCtl,
#else
- ioctl: vboxguestLinuxIOCtl,
+ ioctl: vgdrvLinuxIOCtl,
#endif
};
/* empty entry */
}
};
+
MODULE_DEVICE_TABLE(pci, g_VBoxGuestPciId);
+/** Structure for registering the PCI driver. */
+static struct pci_driver g_PciDriver =
+{
+ name: DRIVER_NAME,
+ id_table: g_VBoxGuestPciId,
+ probe: vgdrvLinuxProbePci,
+ remove: vgdrvLinuxTermPci
+};
+
static PVBOXGUESTSESSION g_pKernelSession = NULL;
+
+
/**
* Converts a VBox status code to a linux error code.
*
* @returns corresponding negative linux error code.
* @param rc supdrv error code (SUPDRV_ERR_* defines).
*/
-static int vboxguestLinuxConvertToNegErrno(int rc)
+static int vgdrvLinuxConvertToNegErrno(int rc)
{
if ( rc > -1000
&& rc < 1000)
}
-
/**
* Does the PCI detection and init of the device.
*
* @returns 0 on success, negated errno on failure.
*/
-static int vboxguestLinuxProbePci(struct pci_dev *pPciDev,
- const struct pci_device_id *id)
+static int vgdrvLinuxProbePci(struct pci_dev *pPciDev, const struct pci_device_id *id)
{
- int rc;
+ int rc;
NOREF(id);
AssertReturn(!g_pPciDev, -EINVAL);
/**
* Clean up the usage of the PCI device.
*/
-static void vboxguestLinuxTermPci(struct pci_dev *pPciDev)
+static void vgdrvLinuxTermPci(struct pci_dev *pPciDev)
{
g_pPciDev = NULL;
if (pPciDev)
}
-/** Structure for registering the PCI driver. */
-static struct pci_driver g_PciDriver =
-{
- name: DRIVER_NAME,
- id_table: g_VBoxGuestPciId,
- probe: vboxguestLinuxProbePci,
- remove: vboxguestLinuxTermPci
-};
-
-
/**
* Interrupt service routine.
*
*
* @param iIrq The IRQ number.
* @param pvDevId The device ID, a pointer to g_DevExt.
- * @param pvRegs Register set. Removed in 2.6.19.
+ * @param pRegs Register set. Removed in 2.6.19.
*/
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
-static irqreturn_t vboxguestLinuxISR(int iIrrq, void *pvDevId)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && !defined(DOXYGEN_RUNNING)
+static irqreturn_t vgdrvLinuxISR(int iIrq, void *pvDevId)
#else
-static irqreturn_t vboxguestLinuxISR(int iIrrq, void *pvDevId, struct pt_regs *pRegs)
+static irqreturn_t vgdrvLinuxISR(int iIrq, void *pvDevId, struct pt_regs *pRegs)
#endif
{
- bool fTaken = VbgdCommonISR(&g_DevExt);
+ bool fTaken = VGDrvCommonISR(&g_DevExt);
return IRQ_RETVAL(fTaken);
}
/**
* Registers the ISR and initializes the poll wait queue.
*/
-static int __init vboxguestLinuxInitISR(void)
+static int __init vgdrvLinuxInitISR(void)
{
int rc;
init_waitqueue_head(&g_PollEventQueue);
rc = request_irq(g_pPciDev->irq,
- vboxguestLinuxISR,
+ vgdrvLinuxISR,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
IRQF_SHARED,
#else
/**
* Deregisters the ISR.
*/
-static void vboxguestLinuxTermISR(void)
+static void vgdrvLinuxTermISR(void)
{
free_irq(g_pPciDev->irq, &g_DevExt);
}
#ifdef VBOXGUEST_WITH_INPUT_DRIVER
-/** Calls the kernel IOCtl to report mouse status to the host on behalf of
- * our kernel session. */
-static int vboxguestLinuxSetMouseStatus(uint32_t fStatus)
+
+/**
+ * Reports the mouse integration status to the host.
+ *
+ * Calls the kernel IOCtl to report mouse status to the host on behalf of
+ * our kernel session.
+ *
+ * @param fStatus The mouse status to report.
+ */
+static int vgdrvLinuxSetMouseStatus(uint32_t fStatus)
{
- return VbgdCommonIoCtl(VBOXGUEST_IOCTL_SET_MOUSE_STATUS, &g_DevExt,
- g_pKernelSession, &fStatus, sizeof(fStatus),
- NULL);
+ return VGDrvCommonIoCtl(VBOXGUEST_IOCTL_SET_MOUSE_STATUS, &g_DevExt, g_pKernelSession, &fStatus, sizeof(fStatus), NULL);
}
-/** Called when the input device is first opened. Sets up absolute reporting.
+/**
+ * Called when the input device is first opened.
+ *
+ * Sets up absolute mouse reporting.
*/
static int vboxguestOpenInputDevice(struct input_dev *pDev)
{
- NOREF(pDev);
- if (RT_FAILURE(vboxguestLinuxSetMouseStatus
- ( VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE
- | VMMDEV_MOUSE_NEW_PROTOCOL)))
+ int rc = vgdrvLinuxSetMouseStatus(VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_NEW_PROTOCOL);
+ if (RT_FAILURE(rc))
return ENODEV;
+ NOREF(pDev);
return 0;
}
-/** Called if all open handles to the device are closed, disables absolute
- * reporting. */
+/**
+ * Called if all open handles to the input device are closed.
+ *
+ * Disables absolute reporting.
+ */
static void vboxguestCloseInputDevice(struct input_dev *pDev)
{
NOREF(pDev);
- vboxguestLinuxSetMouseStatus(0);
+ vgdrvLinuxSetMouseStatus(0);
}
/**
* Creates the kernel input device.
*/
-static int __init vboxguestLinuxCreateInputDevice(void)
+static int __init vgdrvLinuxCreateInputDevice(void)
{
- int rc;
-
- rc = VbglGRAlloc((VMMDevRequestHeader **)&g_pMouseStatusReq,
- sizeof(*g_pMouseStatusReq),
- VMMDevReq_GetMouseStatus);
- if (RT_FAILURE(rc))
- return -ENOMEM;
- g_pInputDevice = input_allocate_device();
- if (!g_pInputDevice)
+ int rc = VbglGRAlloc((VMMDevRequestHeader **)&g_pMouseStatusReq, sizeof(*g_pMouseStatusReq), VMMDevReq_GetMouseStatus);
+ if (RT_SUCCESS(rc))
{
- VbglGRFree(&g_pMouseStatusReq->header);
- return -ENOMEM;
- }
- g_pInputDevice->id.bustype = BUS_PCI;
- g_pInputDevice->id.vendor = VMMDEV_VENDORID;
- g_pInputDevice->id.product = VMMDEV_DEVICEID;
- g_pInputDevice->id.version = VBOX_SHORT_VERSION;
- g_pInputDevice->open = vboxguestOpenInputDevice;
- g_pInputDevice->close = vboxguestCloseInputDevice;
+ g_pInputDevice = input_allocate_device();
+ if (g_pInputDevice)
+ {
+ g_pInputDevice->id.bustype = BUS_PCI;
+ g_pInputDevice->id.vendor = VMMDEV_VENDORID;
+ g_pInputDevice->id.product = VMMDEV_DEVICEID;
+ g_pInputDevice->id.version = VBOX_SHORT_VERSION;
+ g_pInputDevice->open = vboxguestOpenInputDevice;
+ g_pInputDevice->close = vboxguestCloseInputDevice;
# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
- g_pInputDevice->cdev.dev = &g_pPciDev->dev;
+ g_pInputDevice->cdev.dev = &g_pPciDev->dev;
# else
- g_pInputDevice->dev.parent = &g_pPciDev->dev;
+ g_pInputDevice->dev.parent = &g_pPciDev->dev;
# endif
- {
- int rc = input_register_device(g_pInputDevice);
- if (rc)
- {
- VbglGRFree(&g_pMouseStatusReq->header);
+ rc = input_register_device(g_pInputDevice);
+ if (rc == 0)
+ {
+ /* Do what one of our competitors apparently does as that works. */
+ ASMBitSet(g_pInputDevice->evbit, EV_ABS);
+ ASMBitSet(g_pInputDevice->evbit, EV_KEY);
+# ifdef EV_SYN
+ ASMBitSet(g_pInputDevice->evbit, EV_SYN);
+# endif
+ input_set_abs_params(g_pInputDevice, ABS_X, VMMDEV_MOUSE_RANGE_MIN, VMMDEV_MOUSE_RANGE_MAX, 0, 0);
+ input_set_abs_params(g_pInputDevice, ABS_Y, VMMDEV_MOUSE_RANGE_MIN, VMMDEV_MOUSE_RANGE_MAX, 0, 0);
+ ASMBitSet(g_pInputDevice->keybit, BTN_MOUSE);
+ /** @todo this string should be in a header file somewhere. */
+ g_pInputDevice->name = "VirtualBox mouse integration";
+ return 0;
+ }
+
input_free_device(g_pInputDevice);
- return rc;
}
+ else
+ rc = -ENOMEM;
+ VbglGRFree(&g_pMouseStatusReq->header);
+ g_pMouseStatusReq = NULL;
}
- /* Do what one of our competitors apparently does as that works. */
- ASMBitSet(g_pInputDevice->evbit, EV_ABS);
- ASMBitSet(g_pInputDevice->evbit, EV_KEY);
-# ifdef EV_SYN
- ASMBitSet(g_pInputDevice->evbit, EV_SYN);
-# endif
- input_set_abs_params(g_pInputDevice, ABS_X, VMMDEV_MOUSE_RANGE_MIN,
- VMMDEV_MOUSE_RANGE_MAX, 0, 0);
- input_set_abs_params(g_pInputDevice, ABS_Y, VMMDEV_MOUSE_RANGE_MIN,
- VMMDEV_MOUSE_RANGE_MAX, 0, 0);
- ASMBitSet(g_pInputDevice->keybit, BTN_MOUSE);
- /** @todo this string should be in a header file somewhere. */
- g_pInputDevice->name = "VirtualBox mouse integration";
- return 0;
+ else
+ rc = -ENOMEM;
+ return rc;
}
/**
* Terminates the kernel input device.
*/
-static void vboxguestLinuxTermInputDevice(void)
+static void vgdrvLinuxTermInputDevice(void)
{
VbglGRFree(&g_pMouseStatusReq->header);
+ g_pMouseStatusReq = NULL;
+
/* See documentation of input_register_device(): input_free_device()
* should not be called after a device has been registered. */
input_unregister_device(g_pInputDevice);
}
+
#endif /* VBOXGUEST_WITH_INPUT_DRIVER */
*
* @returns 0 on success, negated errno on failure.
*/
-static int __init vboxguestLinuxInitDeviceNodes(void)
+static int __init vgdrvLinuxInitDeviceNodes(void)
{
- int rc;
-
/*
* The full feature device node.
*/
- rc = misc_register(&g_MiscDevice);
- if (rc)
- {
- LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME, rc));
- return rc;
- }
-
- /*
- * The device node intended to be accessible by all users.
- */
- rc = misc_register(&g_MiscDeviceUser);
- if (rc)
+ int rc = misc_register(&g_MiscDevice);
+ if (!rc)
{
+ /*
+ * The device node intended to be accessible by all users.
+ */
+ rc = misc_register(&g_MiscDeviceUser);
+ if (!rc)
+ return 0;
LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME_USER, rc));
misc_deregister(&g_MiscDevice);
- return rc;
}
-
- return 0;
+ else
+ LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME, rc));
+ return rc;
}
/**
* Deregisters the device nodes.
*/
-static void vboxguestLinuxTermDeviceNodes(void)
+static void vgdrvLinuxTermDeviceNodes(void)
{
misc_deregister(&g_MiscDevice);
misc_deregister(&g_MiscDeviceUser);
*
* @returns appropriate status code.
*/
-static int __init vboxguestLinuxModInit(void)
+static int __init vgdrvLinuxModInit(void)
{
static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
PRTLOGGER pRelLogger;
/*
* Register the interrupt service routine for it.
*/
- rc = vboxguestLinuxInitISR();
+ rc = vgdrvLinuxInitISR();
if (rc >= 0)
{
/*
# warning "huh? which arch + version is this?"
VBOXOSTYPE enmOsType = VBOXOSTYPE_Linux;
#endif
- rc = VbgdCommonInitDevExt(&g_DevExt,
- g_IOPortBase,
- g_pvMMIOBase,
- g_cbMMIO,
- enmOSType,
- VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
+ rc = VGDrvCommonInitDevExt(&g_DevExt,
+ g_IOPortBase,
+ g_pvMMIOBase,
+ g_cbMMIO,
+ enmOSType,
+ VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
if (RT_SUCCESS(rc))
{
/*
* Create the kernel session for this driver.
*/
- rc = VbgdCommonCreateKernelSession(&g_DevExt,
- &g_pKernelSession);
+ rc = VGDrvCommonCreateKernelSession(&g_DevExt, &g_pKernelSession);
if (RT_SUCCESS(rc))
{
/*
* Create the kernel input device.
*/
#ifdef VBOXGUEST_WITH_INPUT_DRIVER
- rc = vboxguestLinuxCreateInputDevice();
+ rc = vgdrvLinuxCreateInputDevice();
if (rc >= 0)
{
#endif
/*
* Finally, create the device nodes.
*/
- rc = vboxguestLinuxInitDeviceNodes();
+ rc = vgdrvLinuxInitDeviceNodes();
if (rc >= 0)
{
/* some useful information for the user but don't show this on the console */
/* bail out */
#ifdef VBOXGUEST_WITH_INPUT_DRIVER
- vboxguestLinuxTermInputDevice();
+ vgdrvLinuxTermInputDevice();
}
else
{
rc = RTErrConvertFromErrno(rc);
}
#endif
- VbgdCommonCloseSession(&g_DevExt, g_pKernelSession);
+ VGDrvCommonCloseSession(&g_DevExt, g_pKernelSession);
}
- VbgdCommonDeleteDevExt(&g_DevExt);
+ VGDrvCommonDeleteDevExt(&g_DevExt);
}
else
{
- LogRel((DEVICE_NAME ": VbgdCommonInitDevExt failed with rc=%Rrc\n", rc));
+ LogRel((DEVICE_NAME ": VGDrvCommonInitDevExt failed with rc=%Rrc\n", rc));
rc = RTErrConvertFromErrno(rc);
}
- vboxguestLinuxTermISR();
+ vgdrvLinuxTermISR();
}
}
else
/**
* Unload the module.
*/
-static void __exit vboxguestLinuxModExit(void)
+static void __exit vgdrvLinuxModExit(void)
{
/*
* Inverse order of init.
*/
- vboxguestLinuxTermDeviceNodes();
+ vgdrvLinuxTermDeviceNodes();
#ifdef VBOXGUEST_WITH_INPUT_DRIVER
- vboxguestLinuxTermInputDevice();
+ vgdrvLinuxTermInputDevice();
#endif
- VbgdCommonCloseSession(&g_DevExt, g_pKernelSession);
- VbgdCommonDeleteDevExt(&g_DevExt);
- vboxguestLinuxTermISR();
+ VGDrvCommonCloseSession(&g_DevExt, g_pKernelSession);
+ VGDrvCommonDeleteDevExt(&g_DevExt);
+ vgdrvLinuxTermISR();
pci_unregister_driver(&g_PciDriver);
RTLogDestroy(RTLogRelSetDefaultInstance(NULL));
RTLogDestroy(RTLogSetDefaultInstance(NULL));
* @param pInode Pointer to inode info structure.
* @param pFilp Associated file pointer.
*/
-static int vboxguestLinuxOpen(struct inode *pInode, struct file *pFilp)
+static int vgdrvLinuxOpen(struct inode *pInode, struct file *pFilp)
{
int rc;
PVBOXGUESTSESSION pSession;
* Call common code to create the user session. Associate it with
* the file so we can access it in the other methods.
*/
- rc = VbgdCommonCreateUserSession(&g_DevExt, &pSession);
+ rc = VGDrvCommonCreateUserSession(&g_DevExt, &pSession);
if (RT_SUCCESS(rc))
{
pFilp->private_data = pSession;
pSession->fUserSession = true;
}
- Log(("vboxguestLinuxOpen: g_DevExt=%p pSession=%p rc=%d/%d (pid=%d/%d %s)\n",
- &g_DevExt, pSession, rc, vboxguestLinuxConvertToNegErrno(rc),
- RTProcSelf(), current->pid, current->comm));
- return vboxguestLinuxConvertToNegErrno(rc);
+ Log(("vgdrvLinuxOpen: g_DevExt=%p pSession=%p rc=%d/%d (pid=%d/%d %s)\n",
+ &g_DevExt, pSession, rc, vgdrvLinuxConvertToNegErrno(rc), RTProcSelf(), current->pid, current->comm));
+ return vgdrvLinuxConvertToNegErrno(rc);
}
* @param pInode Pointer to inode info structure.
* @param pFilp Associated file pointer.
*/
-static int vboxguestLinuxRelease(struct inode *pInode, struct file *pFilp)
+static int vgdrvLinuxRelease(struct inode *pInode, struct file *pFilp)
{
- Log(("vboxguestLinuxRelease: pFilp=%p pSession=%p pid=%d/%d %s\n",
+ Log(("vgdrvLinuxRelease: pFilp=%p pSession=%p pid=%d/%d %s\n",
pFilp, pFilp->private_data, RTProcSelf(), current->pid, current->comm));
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)
/* This housekeeping was needed in older kernel versions to ensure that
* the file pointer didn't get left on the polling queue. */
- vboxguestFAsync(-1, pFilp, 0);
+ vgdrvLinuxFAsync(-1, pFilp, 0);
#endif
- VbgdCommonCloseSession(&g_DevExt, (PVBOXGUESTSESSION)pFilp->private_data);
+ VGDrvCommonCloseSession(&g_DevExt, (PVBOXGUESTSESSION)pFilp->private_data);
pFilp->private_data = NULL;
return 0;
}
/**
* Device I/O Control entry point.
*
+ * @param pInode Associated inode pointer.
* @param pFilp Associated file pointer.
* @param uCmd The function specified to ioctl().
* @param ulArg The argument specified to ioctl().
*/
#ifdef HAVE_UNLOCKED_IOCTL
-static long vboxguestLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg)
+static long vgdrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg)
#else
-static int vboxguestLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg)
+static int vgdrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg)
#endif
{
PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFilp->private_data;
int rc;
uint64_t au64Buf[32/sizeof(uint64_t)];
- Log6(("vboxguestLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p pid=%d/%d\n", pFilp, uCmd, (void *)ulArg, RTProcSelf(), current->pid));
+ Log6(("vgdrvLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p pid=%d/%d\n", pFilp, uCmd, (void *)ulArg, RTProcSelf(), current->pid));
/*
* Buffer the request.
* Process the IOCtl.
*/
size_t cbDataReturned;
- rc = VbgdCommonIoCtl(uCmd, &g_DevExt, pSession, pvBuf, cbData, &cbDataReturned);
+ rc = VGDrvCommonIoCtl(uCmd, &g_DevExt, pSession, pvBuf, cbData, &cbDataReturned);
/*
* Copy ioctl data and output buffer back to user space.
}
else
{
- Log(("vboxguestLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p failed, rc=%d\n", pFilp, uCmd, (void *)ulArg, rc));
+ Log(("vgdrvLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p failed, rc=%d\n", pFilp, uCmd, (void *)ulArg, rc));
rc = -rc; Assert(rc > 0); /* Positive returns == negated VBox error status codes. */
}
}
if (pvBufFree)
RTMemFree(pvBufFree);
- Log6(("vboxguestLinuxIOCtl: returns %d (pid=%d/%d)\n", rc, RTProcSelf(), current->pid));
+ Log6(("vgdrvLinuxIOCtl: returns %d (pid=%d/%d)\n", rc, RTProcSelf(), current->pid));
return rc;
}
* @param pFile The file structure.
* @param fOn On/off indicator.
*/
-static int vboxguestFAsync(int fd, struct file *pFile, int fOn)
+static int vgdrvLinuxFAsync(int fd, struct file *pFile, int fOn)
{
return fasync_helper(fd, pFile, fOn, &g_pFAsyncQueue);
}
* @remarks This is probably not really used, X11 is said to use the fasync
* interface instead.
*/
-static unsigned int vboxguestPoll(struct file *pFile, poll_table *pPt)
+static unsigned int vgdrvLinuxPoll(struct file *pFile, poll_table *pPt)
{
PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFile->private_data;
uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
*
* @remarks This is probably not really used as X11 lets the driver do its own
* event reading. The poll condition is therefore also cleared when we
- * see VMMDevReq_GetMouseStatus in VbgdCommonIoCtl_VMMRequest.
+ * see VMMDevReq_GetMouseStatus in vgdrvIoCtl_VMMRequest.
*/
-static ssize_t vboxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff)
+static ssize_t vgdrvLinuxRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff)
{
PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFile->private_data;
uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
}
-void VbgdNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
+void VGDrvNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
{
#ifdef VBOXGUEST_WITH_INPUT_DRIVER
int rc;
* Wake up everyone that's in a poll() and post anyone that has
* subscribed to async notifications.
*/
- Log3(("VbgdNativeISRMousePollEvent: wake_up_all\n"));
+ Log3(("VGDrvNativeISRMousePollEvent: wake_up_all\n"));
wake_up_all(&g_PollEventQueue);
- Log3(("VbgdNativeISRMousePollEvent: kill_fasync\n"));
+ Log3(("VGDrvNativeISRMousePollEvent: kill_fasync\n"));
kill_fasync(&g_pFAsyncQueue, SIGIO, POLL_IN);
#ifdef VBOXGUEST_WITH_INPUT_DRIVER
/* Report events to the kernel input device */
# endif
}
#endif
- Log3(("VbgdNativeISRMousePollEvent: done\n"));
+ Log3(("VGDrvNativeISRMousePollEvent: done\n"));
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
/** log and dbg_log parameter setter. */
-static int vboxguestLinuxParamLogGrpSet(const char *pszValue, struct kernel_param *pParam)
+static int vgdrvLinuxParamLogGrpSet(const char *pszValue, struct kernel_param *pParam)
{
if (g_fLoggerCreated)
{
}
/** log and dbg_log parameter getter. */
-static int vboxguestLinuxParamLogGrpGet(char *pszBuf, struct kernel_param *pParam)
+static int vgdrvLinuxParamLogGrpGet(char *pszBuf, struct kernel_param *pParam)
{
PRTLOGGER pLogger = pParam->name[0] == 'd' ? RTLogDefaultInstance() : RTLogRelGetDefaultInstance();
*pszBuf = '\0';
/** log and dbg_log_flags parameter setter. */
-static int vboxguestLinuxParamLogFlagsSet(const char *pszValue, struct kernel_param *pParam)
+static int vgdrvLinuxParamLogFlagsSet(const char *pszValue, struct kernel_param *pParam)
{
if (g_fLoggerCreated)
{
}
/** log and dbg_log_flags parameter getter. */
-static int vboxguestLinuxParamLogFlagsGet(char *pszBuf, struct kernel_param *pParam)
+static int vgdrvLinuxParamLogFlagsGet(char *pszBuf, struct kernel_param *pParam)
{
PRTLOGGER pLogger = pParam->name[0] == 'd' ? RTLogDefaultInstance() : RTLogRelGetDefaultInstance();
*pszBuf = '\0';
/** log and dbg_log_dest parameter setter. */
-static int vboxguestLinuxParamLogDstSet(const char *pszValue, struct kernel_param *pParam)
+static int vgdrvLinuxParamLogDstSet(const char *pszValue, struct kernel_param *pParam)
{
if (g_fLoggerCreated)
{
}
/** log and dbg_log_dest parameter getter. */
-static int vboxguestLinuxParamLogDstGet(char *pszBuf, struct kernel_param *pParam)
+static int vgdrvLinuxParamLogDstGet(char *pszBuf, struct kernel_param *pParam)
{
PRTLOGGER pLogger = pParam->name[0] == 'd' ? RTLogDefaultInstance() : RTLogRelGetDefaultInstance();
*pszBuf = '\0';
/** r3_log_to_host parameter setter. */
-static int vboxguestLinuxParamR3LogToHostSet(const char *pszValue, struct kernel_param *pParam)
+static int vgdrvLinuxParamR3LogToHostSet(const char *pszValue, struct kernel_param *pParam)
{
if ( pszValue == NULL
|| *pszValue == '\0'
}
/** r3_log_to_host parameter getter. */
-static int vboxguestLinuxParamR3LogToHostGet(char *pszBuf, struct kernel_param *pParam)
+static int vgdrvLinuxParamR3LogToHostGet(char *pszBuf, struct kernel_param *pParam)
{
strcpy(pszBuf, g_DevExt.fLoggingEnabled ? "enabled" : "disabled");
return strlen(pszBuf);
/*
* Define module parameters.
*/
-module_param_call(log, vboxguestLinuxParamLogGrpSet, vboxguestLinuxParamLogGrpGet, NULL, 0664);
-module_param_call(log_flags, vboxguestLinuxParamLogFlagsSet, vboxguestLinuxParamLogFlagsGet, NULL, 0664);
-module_param_call(log_dest, vboxguestLinuxParamLogDstSet, vboxguestLinuxParamLogDstGet, NULL, 0664);
+module_param_call(log, vgdrvLinuxParamLogGrpSet, vgdrvLinuxParamLogGrpGet, NULL, 0664);
+module_param_call(log_flags, vgdrvLinuxParamLogFlagsSet, vgdrvLinuxParamLogFlagsGet, NULL, 0664);
+module_param_call(log_dest, vgdrvLinuxParamLogDstSet, vgdrvLinuxParamLogDstGet, NULL, 0664);
# ifdef LOG_ENABLED
-module_param_call(dbg_log, vboxguestLinuxParamLogGrpSet, vboxguestLinuxParamLogGrpGet, NULL, 0664);
-module_param_call(dbg_log_flags, vboxguestLinuxParamLogFlagsSet, vboxguestLinuxParamLogFlagsGet, NULL, 0664);
-module_param_call(dbg_log_dest, vboxguestLinuxParamLogDstSet, vboxguestLinuxParamLogDstGet, NULL, 0664);
+module_param_call(dbg_log, vgdrvLinuxParamLogGrpSet, vgdrvLinuxParamLogGrpGet, NULL, 0664);
+module_param_call(dbg_log_flags, vgdrvLinuxParamLogFlagsSet, vgdrvLinuxParamLogFlagsGet, NULL, 0664);
+module_param_call(dbg_log_dest, vgdrvLinuxParamLogDstSet, vgdrvLinuxParamLogDstGet, NULL, 0664);
# endif
-module_param_call(r3_log_to_host, vboxguestLinuxParamR3LogToHostSet, vboxguestLinuxParamR3LogToHostGet, NULL, 0664);
+module_param_call(r3_log_to_host, vgdrvLinuxParamR3LogToHostSet, vgdrvLinuxParamR3LogToHostGet, NULL, 0664);
#endif /* 2.6.0 and later */
-module_init(vboxguestLinuxModInit);
-module_exit(vboxguestLinuxModExit);
+module_init(vgdrvLinuxModInit);
+module_exit(vgdrvLinuxModExit);
MODULE_AUTHOR(VBOX_VENDOR);
MODULE_DESCRIPTION(VBOX_PRODUCT " Guest Additions for Linux Module");
* terms and conditions of either the GPL or the CDDL or both.
*/
+/** @page pg_vbdrv VBoxGuest
+ *
+ * VBoxGuest is the device driver for VMMDev.
+ *
+ * The device driver is shipped as part of the guest additions. It has roots in
+ * the host VMM support driver (usually known as VBoxDrv), so fixes in platform
+ * specific code may apply to both drivers.
+ *
+ * The common code lives in VBoxGuest.cpp and is compiled both as C++ and C.
+ * The VBoxGuest.cpp source file shall not contain platform specific code,
+ * though it must occationally do a few \#ifdef RT_OS_XXX tests to cater for
+ * platform differences. Though, in those cases, it is common that more than
+ * one platform needs special handling.
+ *
+ * On most platforms the device driver should create two device nodes, one for
+ * full (unrestricted) access to the feature set, and one which only provides a
+ * restrict set of functions. These are generally referred to as 'vboxguest'
+ * and 'vboxuser' respectively. Currently, this two device approach is only
+ * implemented on Linux!
+ *
+ */
+
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP LOG_GROUP_DEFAULT
#include "VBoxGuestInternal.h"
#include <VBox/VMMDev.h> /* for VMMDEV_RAM_SIZE */
#endif
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
#define VBOXGUEST_ACQUIRE_STYLE_EVENTS (VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
#ifdef VBOX_WITH_HGCM
-static DECLCALLBACK(int) vbgdHgcmAsyncWaitCallback(VMMDevHGCMRequestHeader *pHdrNonVolatile, void *pvUser, uint32_t u32User);
+static DECLCALLBACK(int) vgdrvHgcmAsyncWaitCallback(VMMDevHGCMRequestHeader *pHdrNonVolatile, void *pvUser, uint32_t u32User);
#endif
-static int vbgdIoCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
-static void vbgdBitUsageTrackerClear(PVBOXGUESTBITUSAGETRACER pTracker);
-static uint32_t vbgdGetAllowedEventMaskForSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
-static int vbgdResetEventFilterOnHost(PVBOXGUESTDEVEXT pDevExt, uint32_t fFixedEvents);
-static int vbgdResetMouseStatusOnHost(PVBOXGUESTDEVEXT pDevExt);
-static int vbgdResetCapabilitiesOnHost(PVBOXGUESTDEVEXT pDevExt);
-static int vbgdSetSessionEventFilter(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination);
-static int vbgdSetSessionMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination);
-static int vbgdSetSessionCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- uint32_t fOrMask, uint32_t fNoMask, bool fSessionTermination);
-static int vbgdAcquireSessionCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask,
- uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags, bool fSessionTermination);
-static int vbgdDispatchEventsLocked(PVBOXGUESTDEVEXT pDevExt, uint32_t fEvents);
-
-
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+static int vgdrvIoCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
+static void vgdrvBitUsageTrackerClear(PVBOXGUESTBITUSAGETRACER pTracker);
+static uint32_t vgdrvGetAllowedEventMaskForSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
+static int vgdrvResetEventFilterOnHost(PVBOXGUESTDEVEXT pDevExt, uint32_t fFixedEvents);
+static int vgdrvResetMouseStatusOnHost(PVBOXGUESTDEVEXT pDevExt);
+static int vgdrvResetCapabilitiesOnHost(PVBOXGUESTDEVEXT pDevExt);
+static int vgdrvSetSessionEventFilter(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination);
+static int vgdrvSetSessionMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination);
+static int vgdrvSetSessionCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ uint32_t fOrMask, uint32_t fNoMask, bool fSessionTermination);
+static int vgdrvAcquireSessionCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask,
+ uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags, bool fSessionTermination);
+static int vgdrvDispatchEventsLocked(PVBOXGUESTDEVEXT pDevExt, uint32_t fEvents);
+
+
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
static const uint32_t g_cbChangeMemBalloonReq = RT_OFFSETOF(VMMDevChangeMemBalloon, aPhysPage[VMMDEV_MEMORY_BALLOON_CHUNK_PAGES]);
#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS)
* @returns VBox status code (ignored).
* @param pDevExt The device extension.
*/
-static int vbgdInitFixateGuestMappings(PVBOXGUESTDEVEXT pDevExt)
+static int vgdrvInitFixateGuestMappings(PVBOXGUESTDEVEXT pDevExt)
{
/*
* Query the required space.
* instance in VT-x and AMD-V mode.
*/
if (pReq->hypervisorSize == 0)
- Log(("vbgdInitFixateGuestMappings: nothing to do\n"));
+ Log(("vgdrvInitFixateGuestMappings: nothing to do\n"));
else
{
/*
RTR0MEMOBJ ahTries[5];
uint32_t iTry;
bool fBitched = false;
- Log(("vbgdInitFixateGuestMappings: cbHypervisor=%#x\n", cbHypervisor));
+ Log(("vgdrvInitFixateGuestMappings: cbHypervisor=%#x\n", cbHypervisor));
for (iTry = 0; iTry < RT_ELEMENTS(ahTries); iTry++)
{
/*
/**
- * Undo what vbgdInitFixateGuestMappings did.
+ * Undo what vgdrvInitFixateGuestMappings did.
*
* @param pDevExt The device extension.
*/
-static void vbgdTermUnfixGuestMappings(PVBOXGUESTDEVEXT pDevExt)
+static void vgdrvTermUnfixGuestMappings(PVBOXGUESTDEVEXT pDevExt)
{
if (pDevExt->hGuestMappings != NIL_RTR0PTR)
{
AssertRC(rc);
}
else
- LogRel(("vbgdTermUnfixGuestMappings: Failed to unfix the guest mappings! rc=%Rrc\n", rc));
+ LogRel(("vgdrvTermUnfixGuestMappings: Failed to unfix the guest mappings! rc=%Rrc\n", rc));
pDevExt->hGuestMappings = NIL_RTR0MEMOBJ;
}
* @returns IPRT status code.
* @param enmOSType The OS type to report.
*/
-static int vbgdReportGuestInfo(VBOXOSTYPE enmOSType)
+static int vgdrvReportGuestInfo(VBOXOSTYPE enmOSType)
{
/*
* Allocate and fill in the two guest info reports.
VMMDevReportGuestInfo2 *pReqInfo2 = NULL;
VMMDevReportGuestInfo *pReqInfo1 = NULL;
int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReqInfo2, sizeof (VMMDevReportGuestInfo2), VMMDevReq_ReportGuestInfo2);
- Log(("vbgdReportGuestInfo: VbglGRAlloc VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
+ Log(("vgdrvReportGuestInfo: VbglGRAlloc VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
if (RT_SUCCESS(rc))
{
pReqInfo2->guestInfo.additionsMajor = VBOX_VERSION_MAJOR;
RTStrCopy(pReqInfo2->guestInfo.szName, sizeof(pReqInfo2->guestInfo.szName), VBOX_VERSION_STRING);
rc = VbglGRAlloc((VMMDevRequestHeader **)&pReqInfo1, sizeof (VMMDevReportGuestInfo), VMMDevReq_ReportGuestInfo);
- Log(("vbgdReportGuestInfo: VbglGRAlloc VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
+ Log(("vgdrvReportGuestInfo: VbglGRAlloc VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
if (RT_SUCCESS(rc))
{
pReqInfo1->guestInfo.interfaceVersion = VMMDEV_VERSION;
* if not supported by the VMMDev (message ordering requirement).
*/
rc = VbglGRPerform(&pReqInfo2->header);
- Log(("vbgdReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
+ Log(("vgdrvReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
if (RT_SUCCESS(rc))
{
rc = VbglGRPerform(&pReqInfo1->header);
- Log(("vbgdReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
+ Log(("vgdrvReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
}
else if ( rc == VERR_NOT_SUPPORTED
|| rc == VERR_NOT_IMPLEMENTED)
{
rc = VbglGRPerform(&pReqInfo1->header);
- Log(("vbgdReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
+ Log(("vgdrvReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
if (RT_SUCCESS(rc))
{
rc = VbglGRPerform(&pReqInfo2->header);
- Log(("vbgdReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
+ Log(("vgdrvReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
if (rc == VERR_NOT_IMPLEMENTED)
rc = VINF_SUCCESS;
}
* @returns IPRT status code.
* @param fActive Flag whether the driver is now active or not.
*/
-static int vbgdReportDriverStatus(bool fActive)
+static int vgdrvReportDriverStatus(bool fActive)
{
/*
* Report guest status of the VBox driver to the host.
*/
VMMDevReportGuestStatus *pReq2 = NULL;
int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq2, sizeof(*pReq2), VMMDevReq_ReportGuestStatus);
- Log(("vbgdReportDriverStatus: VbglGRAlloc VMMDevReportGuestStatus completed with rc=%Rrc\n", rc));
+ Log(("vgdrvReportDriverStatus: VbglGRAlloc VMMDevReportGuestStatus completed with rc=%Rrc\n", rc));
if (RT_SUCCESS(rc))
{
pReq2->guestStatus.facility = VBoxGuestFacilityType_VBoxGuestDriver;
: VBoxGuestFacilityStatus_Inactive;
pReq2->guestStatus.flags = 0;
rc = VbglGRPerform(&pReq2->header);
- Log(("vbgdReportDriverStatus: VbglGRPerform VMMDevReportGuestStatus completed with fActive=%d, rc=%Rrc\n",
+ Log(("vgdrvReportDriverStatus: VbglGRPerform VMMDevReportGuestStatus completed with fActive=%d, rc=%Rrc\n",
fActive ? 1 : 0, rc));
if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
rc = VINF_SUCCESS;
* @param pMemObj Pointer to the R0 memory object.
* @param pReq The pre-allocated request for performing the VMMDev call.
*/
-static int vbgdBalloonInflate(PRTR0MEMOBJ pMemObj, VMMDevChangeMemBalloon *pReq)
+static int vgdrvBalloonInflate(PRTR0MEMOBJ pMemObj, VMMDevChangeMemBalloon *pReq)
{
uint32_t iPage;
int rc;
rc = VbglGRPerform(&pReq->header);
if (RT_FAILURE(rc))
- LogRel(("vbgdBalloonInflate: VbglGRPerform failed. rc=%Rrc\n", rc));
+ LogRel(("vgdrvBalloonInflate: VbglGRPerform failed. rc=%Rrc\n", rc));
return rc;
}
* The memory object will be freed afterwards.
* @param pReq The pre-allocated request for performing the VMMDev call.
*/
-static int vbgdBalloonDeflate(PRTR0MEMOBJ pMemObj, VMMDevChangeMemBalloon *pReq)
+static int vgdrvBalloonDeflate(PRTR0MEMOBJ pMemObj, VMMDevChangeMemBalloon *pReq)
{
uint32_t iPage;
int rc;
rc = VbglGRPerform(&pReq->header);
if (RT_FAILURE(rc))
{
- LogRel(("vbgdBalloonDeflate: VbglGRPerform failed. rc=%Rrc\n", rc));
+ LogRel(("vgdrvBalloonDeflate: VbglGRPerform failed. rc=%Rrc\n", rc));
return rc;
}
rc = RTR0MemObjFree(*pMemObj, true);
if (RT_FAILURE(rc))
{
- LogRel(("vbgdBalloonDeflate: RTR0MemObjFree(%p,true) -> %Rrc; this is *BAD*!\n", *pMemObj, rc));
+ LogRel(("vgdrvBalloonDeflate: RTR0MemObjFree(%p,true) -> %Rrc; this is *BAD*!\n", *pMemObj, rc));
return rc;
}
/**
* Inflate/deflate the memory balloon and notify the host.
*
- * This is a worker used by vbgdIoCtl_CheckMemoryBalloon - it takes the mutex.
+ * This is a worker used by vgdrvIoCtl_CheckMemoryBalloon - it takes the mutex.
*
* @returns VBox status code.
* @param pDevExt The device extension.
- * @param pSession The session.
* @param cBalloonChunks The new size of the balloon in chunks of 1MB.
* @param pfHandleInR3 Where to return the handle-in-ring3 indicator
* (VINF_SUCCESS if set).
*/
-static int vbgdSetBalloonSizeKernel(PVBOXGUESTDEVEXT pDevExt, uint32_t cBalloonChunks, uint32_t *pfHandleInR3)
+static int vgdrvSetBalloonSizeKernel(PVBOXGUESTDEVEXT pDevExt, uint32_t cBalloonChunks, uint32_t *pfHandleInR3)
{
int rc = VINF_SUCCESS;
if (cBalloonChunks > pDevExt->MemBalloon.cMaxChunks)
{
- LogRel(("vbgdSetBalloonSizeKernel: illegal balloon size %u (max=%u)\n",
+ LogRel(("vgdrvSetBalloonSizeKernel: illegal balloon size %u (max=%u)\n",
cBalloonChunks, pDevExt->MemBalloon.cMaxChunks));
return VERR_INVALID_PARAMETER;
}
pDevExt->MemBalloon.paMemObj = (PRTR0MEMOBJ)RTMemAllocZ(sizeof(RTR0MEMOBJ) * pDevExt->MemBalloon.cMaxChunks);
if (!pDevExt->MemBalloon.paMemObj)
{
- LogRel(("vbgdSetBalloonSizeKernel: no memory for paMemObj!\n"));
+ LogRel(("vgdrvSetBalloonSizeKernel: no memory for paMemObj!\n"));
return VERR_NO_MEMORY;
}
}
break;
}
- rc = vbgdBalloonInflate(&pDevExt->MemBalloon.paMemObj[i], pReq);
+ rc = vgdrvBalloonInflate(&pDevExt->MemBalloon.paMemObj[i], pReq);
if (RT_FAILURE(rc))
{
Log(("vboxGuestSetBalloonSize(inflate): failed, rc=%Rrc!\n", rc));
/* deflate */
for (i = pDevExt->MemBalloon.cChunks; i-- > cBalloonChunks;)
{
- rc = vbgdBalloonDeflate(&pDevExt->MemBalloon.paMemObj[i], pReq);
+ rc = vgdrvBalloonDeflate(&pDevExt->MemBalloon.paMemObj[i], pReq);
if (RT_FAILURE(rc))
{
Log(("vboxGuestSetBalloonSize(deflate): failed, rc=%Rrc!\n", rc));
/**
* Inflate/deflate the balloon by one chunk.
*
- * Worker for vbgdIoCtl_ChangeMemoryBalloon - it takes the mutex.
+ * Worker for vgdrvIoCtl_ChangeMemoryBalloon - it takes the mutex.
*
* @returns VBox status code.
* @param pDevExt The device extension.
* balloon.
* @param fInflate Inflate if true, deflate if false.
*/
-static int vbgdSetBalloonSizeFromUser(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint64_t u64ChunkAddr, bool fInflate)
+static int vgdrvSetBalloonSizeFromUser(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint64_t u64ChunkAddr, bool fInflate)
{
VMMDevChangeMemBalloon *pReq;
int rc = VINF_SUCCESS;
RTMEM_PROT_READ | RTMEM_PROT_WRITE, NIL_RTR0PROCESS);
if (RT_SUCCESS(rc))
{
- rc = vbgdBalloonInflate(pMemObj, pReq);
+ rc = vgdrvBalloonInflate(pMemObj, pReq);
if (RT_SUCCESS(rc))
pDevExt->MemBalloon.cChunks++;
else
}
else
{
- rc = vbgdBalloonDeflate(pMemObj, pReq);
+ rc = vgdrvBalloonDeflate(pMemObj, pReq);
if (RT_SUCCESS(rc))
pDevExt->MemBalloon.cChunks--;
else
* own it already.
*
* @param pDevExt The device extension.
- * @param pDevExt The session. Can be NULL at unload.
+ * @param pSession The session. Can be NULL at unload.
*/
-static void vbgdCloseMemBalloon(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
+static void vgdrvCloseMemBalloon(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
{
RTSemFastMutexRequest(pDevExt->MemBalloon.hMtx);
if ( pDevExt->MemBalloon.pOwner == pSession
uint32_t i;
for (i = pDevExt->MemBalloon.cChunks; i-- > 0;)
{
- rc = vbgdBalloonDeflate(&pDevExt->MemBalloon.paMemObj[i], pReq);
+ rc = vgdrvBalloonDeflate(&pDevExt->MemBalloon.paMemObj[i], pReq);
if (RT_FAILURE(rc))
{
- LogRel(("vbgdCloseMemBalloon: Deflate failed with rc=%Rrc. Will leak %u chunks.\n",
+ LogRel(("vgdrvCloseMemBalloon: Deflate failed with rc=%Rrc. Will leak %u chunks.\n",
rc, pDevExt->MemBalloon.cChunks));
break;
}
VbglGRFree(&pReq->header);
}
else
- LogRel(("vbgdCloseMemBalloon: Failed to allocate VMMDev request buffer (rc=%Rrc). Will leak %u chunks.\n",
+ LogRel(("vgdrvCloseMemBalloon: Failed to allocate VMMDev request buffer (rc=%Rrc). Will leak %u chunks.\n",
rc, pDevExt->MemBalloon.cChunks));
RTMemFree(pDevExt->MemBalloon.paMemObj);
pDevExt->MemBalloon.paMemObj = NULL;
*
* @returns VBox status code.
*/
-static int vbgdHeartbeatSend(PVBOXGUESTDEVEXT pDevExt)
+static int vgdrvHeartbeatSend(PVBOXGUESTDEVEXT pDevExt)
{
int rc;
if (pDevExt->pReqGuestHeartbeat)
{
rc = VbglGRPerform(pDevExt->pReqGuestHeartbeat);
- Log(("vbgdHeartbeatSend: VbglGRPerform vbgdHeartbeatSend completed with rc=%Rrc\n", rc));
+ Log(("vgdrvHeartbeatSend: VbglGRPerform vgdrvHeartbeatSend completed with rc=%Rrc\n", rc));
}
else
rc = VERR_INVALID_STATE;
/**
* Callback for heartbeat timer.
*/
-static DECLCALLBACK(void) vbgdHeartbeatTimerHandler(PRTTIMER hTimer, void *pvUser, uint64_t iTick)
+static DECLCALLBACK(void) vgdrvHeartbeatTimerHandler(PRTTIMER hTimer, void *pvUser, uint64_t iTick)
{
PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvUser;
int rc;
AssertReturnVoid(pDevExt);
- rc = vbgdHeartbeatSend(pDevExt);
+ rc = vgdrvHeartbeatSend(pDevExt);
if (RT_FAILURE(rc))
- Log(("HB Timer: vbgdHeartbeatSend failed: rc=%Rrc\n", rc));
+ Log(("HB Timer: vgdrvHeartbeatSend failed: rc=%Rrc\n", rc));
NOREF(hTimer); NOREF(iTick);
}
* @param pDevExt The device extension.
* @param fEnabled Set true to enable guest heartbeat checks on host.
*/
-static int vbgdHeartbeatHostConfigure(PVBOXGUESTDEVEXT pDevExt, bool fEnabled)
+static int vgdrvHeartbeatHostConfigure(PVBOXGUESTDEVEXT pDevExt, bool fEnabled)
{
VMMDevReqHeartbeat *pReq;
int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof(*pReq), VMMDevReq_HeartbeatConfigure);
- Log(("vbgdHeartbeatHostConfigure: VbglGRAlloc vbgdHeartbeatHostConfigure completed with rc=%Rrc\n", rc));
+ Log(("vgdrvHeartbeatHostConfigure: VbglGRAlloc vgdrvHeartbeatHostConfigure completed with rc=%Rrc\n", rc));
if (RT_SUCCESS(rc))
{
pReq->fEnabled = fEnabled;
pReq->cNsInterval = 0;
rc = VbglGRPerform(&pReq->header);
- Log(("vbgdHeartbeatHostConfigure: VbglGRPerform vbgdHeartbeatHostConfigure completed with rc=%Rrc\n", rc));
+ Log(("vgdrvHeartbeatHostConfigure: VbglGRPerform vgdrvHeartbeatHostConfigure completed with rc=%Rrc\n", rc));
pDevExt->cNsHeartbeatInterval = pReq->cNsInterval;
VbglGRFree(&pReq->header);
}
* @returns VBox status (ignored).
* @param pDevExt The device extension.
*/
-static int vbgdHeartbeatInit(PVBOXGUESTDEVEXT pDevExt)
+static int vgdrvHeartbeatInit(PVBOXGUESTDEVEXT pDevExt)
{
/*
* Make sure that heartbeat checking is disabled.
*/
- int rc = vbgdHeartbeatHostConfigure(pDevExt, false);
+ int rc = vgdrvHeartbeatHostConfigure(pDevExt, false);
if (RT_SUCCESS(rc))
{
- rc = vbgdHeartbeatHostConfigure(pDevExt, true);
+ rc = vgdrvHeartbeatHostConfigure(pDevExt, true);
if (RT_SUCCESS(rc))
{
/*
rc = VbglGRAlloc(&pDevExt->pReqGuestHeartbeat, sizeof(*pDevExt->pReqGuestHeartbeat), VMMDevReq_GuestHeartbeat);
if (RT_SUCCESS(rc))
{
- LogRel(("VbgdCommonInitDevExt: Setting up heartbeat to trigger every %RU64 milliseconds\n",
+ LogRel(("vgdrvHeartbeatInit: Setting up heartbeat to trigger every %RU64 milliseconds\n",
pDevExt->cNsHeartbeatInterval / RT_NS_1MS));
rc = RTTimerCreateEx(&pDevExt->pHeartbeatTimer, pDevExt->cNsHeartbeatInterval, 0 /*fFlags*/,
- (PFNRTTIMER)vbgdHeartbeatTimerHandler, pDevExt);
+ (PFNRTTIMER)vgdrvHeartbeatTimerHandler, pDevExt);
if (RT_SUCCESS(rc))
{
rc = RTTimerStart(pDevExt->pHeartbeatTimer, 0);
if (RT_SUCCESS(rc))
return VINF_SUCCESS;
- LogRel(("VbgdCommonInitDevExt: Heartbeat timer failed to start, rc=%Rrc\n", rc));
+ LogRel(("vgdrvHeartbeatInit: Heartbeat timer failed to start, rc=%Rrc\n", rc));
}
else
- LogRel(("VbgdCommonInitDevExt: Failed to create heartbeat timer: %Rrc\n", rc));
+ LogRel(("vgdrvHeartbeatInit: Failed to create heartbeat timer: %Rrc\n", rc));
VbglGRFree(pDevExt->pReqGuestHeartbeat);
pDevExt->pReqGuestHeartbeat = NULL;
}
else
- LogRel(("VbgdCommonInitDevExt: VbglGRAlloc(VMMDevReq_GuestHeartbeat): %Rrc\n", rc));
+ LogRel(("vgdrvHeartbeatInit: VbglGRAlloc(VMMDevReq_GuestHeartbeat): %Rrc\n", rc));
- LogRel(("VbgdCommonInitDevExt: Failed to set up the timer, guest heartbeat is disabled\n"));
- vbgdHeartbeatHostConfigure(pDevExt, false);
+ LogRel(("vgdrvHeartbeatInit: Failed to set up the timer, guest heartbeat is disabled\n"));
+ vgdrvHeartbeatHostConfigure(pDevExt, false);
}
else
- LogRel(("VbgdCommonInitDevExt: Failed to configure host for heartbeat checking: rc=%Rrc\n", rc));
+ LogRel(("vgdrvHeartbeatInit: Failed to configure host for heartbeat checking: rc=%Rrc\n", rc));
}
return rc;
}
*
* @todo Call this on all platforms, not just windows.
*/
-int VbgdCommonReinitDevExtAfterHibernation(PVBOXGUESTDEVEXT pDevExt, VBOXOSTYPE enmOSType)
+int VGDrvCommonReinitDevExtAfterHibernation(PVBOXGUESTDEVEXT pDevExt, VBOXOSTYPE enmOSType)
{
- int rc = vbgdReportGuestInfo(enmOSType);
+ int rc = vgdrvReportGuestInfo(enmOSType);
if (RT_SUCCESS(rc))
{
- rc = vbgdReportDriverStatus(true /* Driver is active */);
+ rc = vgdrvReportDriverStatus(true /* Driver is active */);
if (RT_FAILURE(rc))
- Log(("VbgdCommonReinitDevExtAfterHibernation: could not report guest driver status, rc=%Rrc\n", rc));
+ Log(("VGDrvCommonReinitDevExtAfterHibernation: could not report guest driver status, rc=%Rrc\n", rc));
}
else
- Log(("VbgdCommonReinitDevExtAfterHibernation: could not report guest information to host, rc=%Rrc\n", rc));
- LogFlow(("VbgdCommonReinitDevExtAfterHibernation: returned with rc=%Rrc\n", rc));
+ Log(("VGDrvCommonReinitDevExtAfterHibernation: could not report guest information to host, rc=%Rrc\n", rc));
+ LogFlow(("VGDrvCommonReinitDevExtAfterHibernation: returned with rc=%Rrc\n", rc));
return rc;
}
* @param fFixedEvents Events that will be enabled upon init and no client
* will ever be allowed to mask.
*/
-int VbgdCommonInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase,
- void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType, uint32_t fFixedEvents)
+int VGDrvCommonInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase,
+ void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType, uint32_t fFixedEvents)
{
int rc, rc2;
pDevExt->pReqGuestHeartbeat = NULL;
pDevExt->fFixedEvents = fFixedEvents;
- vbgdBitUsageTrackerClear(&pDevExt->EventFilterTracker);
+ vgdrvBitUsageTrackerClear(&pDevExt->EventFilterTracker);
pDevExt->fEventFilterHost = UINT32_MAX; /* forces a report */
- vbgdBitUsageTrackerClear(&pDevExt->MouseStatusTracker);
+ vgdrvBitUsageTrackerClear(&pDevExt->MouseStatusTracker);
pDevExt->fMouseStatusHost = UINT32_MAX; /* forces a report */
pDevExt->fAcquireModeGuestCaps = 0;
pDevExt->fSetModeGuestCaps = 0;
pDevExt->fAcquiredGuestCaps = 0;
- vbgdBitUsageTrackerClear(&pDevExt->SetGuestCapsTracker);
+ vgdrvBitUsageTrackerClear(&pDevExt->SetGuestCapsTracker);
pDevExt->fGuestCapsHost = UINT32_MAX; /* forces a report */
/*
&& pVMMDev->u32Size <= cbMMIO)
{
pDevExt->pVMMDevMemory = pVMMDev;
- Log(("VbgdCommonInitDevExt: VMMDevMemory: mapping=%p size=%#RX32 (%#RX32) version=%#RX32\n",
+ Log(("VGDrvCommonInitDevExt: VMMDevMemory: mapping=%p size=%#RX32 (%#RX32) version=%#RX32\n",
pVMMDev, pVMMDev->u32Size, cbMMIO, pVMMDev->u32Version));
}
else /* try live without it. */
- LogRel(("VbgdCommonInitDevExt: Bogus VMMDev memory; u32Version=%RX32 (expected %RX32) u32Size=%RX32 (expected <= %RX32)\n",
+ LogRel(("VGDrvCommonInitDevExt: Bogus VMMDev memory; u32Version=%RX32 (expected %RX32) u32Size=%RX32 (expected <= %RX32)\n",
pVMMDev->u32Version, VMMDEV_MEMORY_VERSION, pVMMDev->u32Size, cbMMIO));
}
rc = RTSpinlockCreate(&pDevExt->SessionSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestSession");
if (RT_FAILURE(rc))
{
- LogRel(("VbgdCommonInitDevExt: failed to create spinlock, rc=%Rrc!\n", rc));
+ LogRel(("VGDrvCommonInitDevExt: failed to create spinlock, rc=%Rrc!\n", rc));
if (pDevExt->EventSpinlock != NIL_RTSPINLOCK)
RTSpinlockDestroy(pDevExt->EventSpinlock);
return rc;
rc = RTSemFastMutexCreate(&pDevExt->MemBalloon.hMtx);
if (RT_FAILURE(rc))
{
- LogRel(("VbgdCommonInitDevExt: failed to create mutex, rc=%Rrc!\n", rc));
+ LogRel(("VGDrvCommonInitDevExt: failed to create mutex, rc=%Rrc!\n", rc));
RTSpinlockDestroy(pDevExt->SessionSpinlock);
RTSpinlockDestroy(pDevExt->EventSpinlock);
return rc;
* set the interrupt control filter mask, and fixate the guest mappings
* made by the VMM.
*/
- rc = VbglInit(pDevExt->IOPortBase, (VMMDevMemory *)pDevExt->pVMMDevMemory);
+ rc = VbglInitPrimary(pDevExt->IOPortBase, (VMMDevMemory *)pDevExt->pVMMDevMemory);
if (RT_SUCCESS(rc))
{
rc = VbglGRAlloc((VMMDevRequestHeader **)&pDevExt->pIrqAckEvents, sizeof(VMMDevEvents), VMMDevReq_AcknowledgeEvents);
pDevExt->PhysIrqAckEvents = VbglPhysHeapGetPhysAddr(pDevExt->pIrqAckEvents);
Assert(pDevExt->PhysIrqAckEvents != 0);
- rc = vbgdReportGuestInfo(enmOSType);
+ rc = vgdrvReportGuestInfo(enmOSType);
if (RT_SUCCESS(rc))
{
/*
* Set the fixed event and make sure the host doesn't have any lingering
* the guest capabilities or mouse status bits set.
*/
- rc = vbgdResetEventFilterOnHost(pDevExt, pDevExt->fFixedEvents);
+ rc = vgdrvResetEventFilterOnHost(pDevExt, pDevExt->fFixedEvents);
if (RT_SUCCESS(rc))
{
- rc = vbgdResetCapabilitiesOnHost(pDevExt);
+ rc = vgdrvResetCapabilitiesOnHost(pDevExt);
if (RT_SUCCESS(rc))
{
- rc = vbgdResetMouseStatusOnHost(pDevExt);
+ rc = vgdrvResetMouseStatusOnHost(pDevExt);
if (RT_SUCCESS(rc))
{
/*
* Initialize stuff which may fail without requiring the driver init to fail.
*/
- vbgdInitFixateGuestMappings(pDevExt);
- vbgdHeartbeatInit(pDevExt);
+ vgdrvInitFixateGuestMappings(pDevExt);
+ vgdrvHeartbeatInit(pDevExt);
/*
* Done!
*/
- rc = vbgdReportDriverStatus(true /* Driver is active */);
+ rc = vgdrvReportDriverStatus(true /* Driver is active */);
if (RT_FAILURE(rc))
- LogRel(("VbgdCommonInitDevExt: VBoxReportGuestDriverStatus failed, rc=%Rrc\n", rc));
+ LogRel(("VGDrvCommonInitDevExt: VBoxReportGuestDriverStatus failed, rc=%Rrc\n", rc));
- LogFlowFunc(("VbgdCommonInitDevExt: returns success\n"));
+ LogFlowFunc(("VGDrvCommonInitDevExt: returns success\n"));
return VINF_SUCCESS;
}
- LogRel(("VbgdCommonInitDevExt: failed to clear mouse status: rc=%Rrc\n", rc));
+ LogRel(("VGDrvCommonInitDevExt: failed to clear mouse status: rc=%Rrc\n", rc));
}
else
- LogRel(("VbgdCommonInitDevExt: failed to clear guest capabilities: rc=%Rrc\n", rc));
+ LogRel(("VGDrvCommonInitDevExt: failed to clear guest capabilities: rc=%Rrc\n", rc));
}
else
- LogRel(("VbgdCommonInitDevExt: failed to set fixed event filter: rc=%Rrc\n", rc));
+ LogRel(("VGDrvCommonInitDevExt: failed to set fixed event filter: rc=%Rrc\n", rc));
}
else
- LogRel(("VbgdCommonInitDevExt: VBoxReportGuestInfo failed: rc=%Rrc\n", rc));
+ LogRel(("VGDrvCommonInitDevExt: VBoxReportGuestInfo failed: rc=%Rrc\n", rc));
VbglGRFree((VMMDevRequestHeader *)pDevExt->pIrqAckEvents);
}
else
- LogRel(("VbgdCommonInitDevExt: VBoxGRAlloc failed: rc=%Rrc\n", rc));
+ LogRel(("VGDrvCommonInitDevExt: VBoxGRAlloc failed: rc=%Rrc\n", rc));
VbglTerminate();
}
else
- LogRel(("VbgdCommonInitDevExt: VbglInit failed: rc=%Rrc\n", rc));
+ LogRel(("VGDrvCommonInitDevExt: VbglInit failed: rc=%Rrc\n", rc));
rc2 = RTSemFastMutexDestroy(pDevExt->MemBalloon.hMtx); AssertRC(rc2);
rc2 = RTSpinlockDestroy(pDevExt->EventSpinlock); AssertRC(rc2);
* Deletes all the items in a wait chain.
* @param pList The head of the chain.
*/
-static void vbgdDeleteWaitList(PRTLISTNODE pList)
+static void vgdrvDeleteWaitList(PRTLISTNODE pList)
{
while (!RTListIsEmpty(pList))
{
*
* @param pDevExt The device extension.
*/
-void VbgdCommonDeleteDevExt(PVBOXGUESTDEVEXT pDevExt)
+void VGDrvCommonDeleteDevExt(PVBOXGUESTDEVEXT pDevExt)
{
int rc2;
- Log(("VbgdCommonDeleteDevExt:\n"));
+ Log(("VGDrvCommonDeleteDevExt:\n"));
Log(("VBoxGuest: The additions driver is terminating.\n"));
/*
if (pDevExt->pHeartbeatTimer)
{
RTTimerDestroy(pDevExt->pHeartbeatTimer);
- vbgdHeartbeatHostConfigure(pDevExt, false);
+ vgdrvHeartbeatHostConfigure(pDevExt, false);
}
VbglGRFree(pDevExt->pReqGuestHeartbeat);
/*
* Clean up the bits that involves the host first.
*/
- vbgdTermUnfixGuestMappings(pDevExt);
+ vgdrvTermUnfixGuestMappings(pDevExt);
if (!RTListIsEmpty(&pDevExt->SessionList))
{
LogRelFunc(("session list not empty!\n"));
}
/* Update the host flags (mouse status etc) not to reflect this session. */
pDevExt->fFixedEvents = 0;
- vbgdResetEventFilterOnHost(pDevExt, 0 /*fFixedEvents*/);
- vbgdResetCapabilitiesOnHost(pDevExt);
- vbgdResetMouseStatusOnHost(pDevExt);
+ vgdrvResetEventFilterOnHost(pDevExt, 0 /*fFixedEvents*/);
+ vgdrvResetCapabilitiesOnHost(pDevExt);
+ vgdrvResetMouseStatusOnHost(pDevExt);
- vbgdCloseMemBalloon(pDevExt, (PVBOXGUESTSESSION)NULL);
+ vgdrvCloseMemBalloon(pDevExt, (PVBOXGUESTSESSION)NULL);
/*
* Cleanup all the other resources.
rc2 = RTSpinlockDestroy(pDevExt->SessionSpinlock); AssertRC(rc2);
rc2 = RTSemFastMutexDestroy(pDevExt->MemBalloon.hMtx); AssertRC(rc2);
- vbgdDeleteWaitList(&pDevExt->WaitList);
+ vgdrvDeleteWaitList(&pDevExt->WaitList);
#ifdef VBOX_WITH_HGCM
- vbgdDeleteWaitList(&pDevExt->HGCMWaitList);
+ vgdrvDeleteWaitList(&pDevExt->HGCMWaitList);
#endif
#ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP
- vbgdDeleteWaitList(&pDevExt->WakeUpList);
+ vgdrvDeleteWaitList(&pDevExt->WakeUpList);
#endif
- vbgdDeleteWaitList(&pDevExt->WokenUpList);
- vbgdDeleteWaitList(&pDevExt->FreeList);
+ vgdrvDeleteWaitList(&pDevExt->WokenUpList);
+ vgdrvDeleteWaitList(&pDevExt->FreeList);
VbglTerminate();
* Creates a VBoxGuest user session.
*
* The native code calls this when a ring-3 client opens the device.
- * Use VbgdCommonCreateKernelSession when a ring-0 client connects.
+ * Use VGDrvCommonCreateKernelSession when a ring-0 client connects.
*
* @returns VBox status code.
* @param pDevExt The device extension.
* @param ppSession Where to store the session on success.
*/
-int VbgdCommonCreateUserSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession)
+int VGDrvCommonCreateUserSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession)
{
PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)RTMemAllocZ(sizeof(*pSession));
if (RT_UNLIKELY(!pSession))
{
- LogRel(("VbgdCommonCreateUserSession: no memory!\n"));
+ LogRel(("VGDrvCommonCreateUserSession: no memory!\n"));
return VERR_NO_MEMORY;
}
RTSpinlockRelease(pDevExt->SessionSpinlock);
*ppSession = pSession;
- LogFlow(("VbgdCommonCreateUserSession: pSession=%p proc=%RTproc (%d) r0proc=%p\n",
+ LogFlow(("VGDrvCommonCreateUserSession: pSession=%p proc=%RTproc (%d) r0proc=%p\n",
pSession, pSession->Process, (int)pSession->Process, (uintptr_t)pSession->R0Process)); /** @todo %RTr0proc */
return VINF_SUCCESS;
}
* Creates a VBoxGuest kernel session.
*
* The native code calls this when a ring-0 client connects to the device.
- * Use VbgdCommonCreateUserSession when a ring-3 client opens the device.
+ * Use VGDrvCommonCreateUserSession when a ring-3 client opens the device.
*
* @returns VBox status code.
* @param pDevExt The device extension.
* @param ppSession Where to store the session on success.
*/
-int VbgdCommonCreateKernelSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession)
+int VGDrvCommonCreateKernelSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession)
{
PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)RTMemAllocZ(sizeof(*pSession));
if (RT_UNLIKELY(!pSession))
{
- LogRel(("VbgdCommonCreateKernelSession: no memory!\n"));
+ LogRel(("VGDrvCommonCreateKernelSession: no memory!\n"));
return VERR_NO_MEMORY;
}
RTSpinlockRelease(pDevExt->SessionSpinlock);
*ppSession = pSession;
- LogFlow(("VbgdCommonCreateKernelSession: pSession=%p proc=%RTproc (%d) r0proc=%p\n",
+ LogFlow(("VGDrvCommonCreateKernelSession: pSession=%p proc=%RTproc (%d) r0proc=%p\n",
pSession, pSession->Process, (int)pSession->Process, (uintptr_t)pSession->R0Process)); /** @todo %RTr0proc */
return VINF_SUCCESS;
}
* @param pDevExt The device extension.
* @param pSession The session to close (and free).
*/
-void VbgdCommonCloseSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
+void VGDrvCommonCloseSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
{
#ifdef VBOX_WITH_HGCM
unsigned i;
#endif
- LogFlow(("VbgdCommonCloseSession: pSession=%p proc=%RTproc (%d) r0proc=%p\n",
+ LogFlow(("VGDrvCommonCloseSession: pSession=%p proc=%RTproc (%d) r0proc=%p\n",
pSession, pSession->Process, (int)pSession->Process, (uintptr_t)pSession->R0Process)); /** @todo %RTr0proc */
RTSpinlockAcquire(pDevExt->SessionSpinlock);
RTListNodeRemove(&pSession->ListNode);
pDevExt->cSessions--;
RTSpinlockRelease(pDevExt->SessionSpinlock);
- vbgdAcquireSessionCapabilities(pDevExt, pSession, 0, UINT32_MAX, VBOXGUESTCAPSACQUIRE_FLAGS_NONE,
+ vgdrvAcquireSessionCapabilities(pDevExt, pSession, 0, UINT32_MAX, VBOXGUESTCAPSACQUIRE_FLAGS_NONE,
true /*fSessionTermination*/);
- vbgdSetSessionCapabilities(pDevExt, pSession, 0 /*fOrMask*/, UINT32_MAX /*fNotMask*/, true /*fSessionTermination*/);
- vbgdSetSessionEventFilter(pDevExt, pSession, 0 /*fOrMask*/, UINT32_MAX /*fNotMask*/, true /*fSessionTermination*/);
- vbgdSetSessionMouseStatus(pDevExt, pSession, 0 /*fOrMask*/, UINT32_MAX /*fNotMask*/, true /*fSessionTermination*/);
+ vgdrvSetSessionCapabilities(pDevExt, pSession, 0 /*fOrMask*/, UINT32_MAX /*fNotMask*/, true /*fSessionTermination*/);
+ vgdrvSetSessionEventFilter(pDevExt, pSession, 0 /*fOrMask*/, UINT32_MAX /*fNotMask*/, true /*fSessionTermination*/);
+ vgdrvSetSessionMouseStatus(pDevExt, pSession, 0 /*fOrMask*/, UINT32_MAX /*fNotMask*/, true /*fSessionTermination*/);
- vbgdIoCtl_CancelAllWaitEvents(pDevExt, pSession);
+ vgdrvIoCtl_CancelAllWaitEvents(pDevExt, pSession);
#ifdef VBOX_WITH_HGCM
for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++)
Info.result = 0;
Info.u32ClientID = pSession->aHGCMClientIds[i];
pSession->aHGCMClientIds[i] = 0;
- Log(("VbgdCommonCloseSession: disconnecting client id %#RX32\n", Info.u32ClientID));
- VbglR0HGCMInternalDisconnect(&Info, vbgdHgcmAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
+ Log(("VGDrvCommonCloseSession: disconnecting client id %#RX32\n", Info.u32ClientID));
+ VbglR0HGCMInternalDisconnect(&Info, vgdrvHgcmAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
}
#endif
pSession->pDevExt = NULL;
pSession->Process = NIL_RTPROCESS;
pSession->R0Process = NIL_RTR0PROCESS;
- vbgdCloseMemBalloon(pDevExt, pSession);
+ vgdrvCloseMemBalloon(pDevExt, pSession);
RTMemFree(pSession);
}
* @param pDevExt The device extension.
* @param pSession The session that's allocating this. Can be NULL.
*/
-static PVBOXGUESTWAIT vbgdWaitAlloc(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
+static PVBOXGUESTWAIT vgdrvWaitAlloc(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
{
/*
* Allocate it one way or the other.
pWait = (PVBOXGUESTWAIT)RTMemAlloc(sizeof(*pWait));
if (!pWait)
{
- LogRelMax(32, ("vbgdWaitAlloc: out-of-memory!\n"));
+ LogRelMax(32, ("vgdrvWaitAlloc: out-of-memory!\n"));
return NULL;
}
rc = RTSemEventMultiCreate(&pWait->Event);
if (RT_FAILURE(rc))
{
- LogRelMax(32, ("VbgdCommonIoCtl: RTSemEventMultiCreate failed with rc=%Rrc!\n", rc));
+ LogRelMax(32, ("vgdrvWaitAlloc: RTSemEventMultiCreate failed with rc=%Rrc!\n", rc));
RTMemFree(pWait);
return NULL;
}
* @param pDevExt The device extension.
* @param pWait The wait-for-event entry to free.
*/
-static void vbgdWaitFreeLocked(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTWAIT pWait)
+static void vgdrvWaitFreeLocked(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTWAIT pWait)
{
pWait->fReqEvents = 0;
pWait->fResEvents = 0;
* @param pDevExt The device extension.
* @param pWait The wait-for-event entry to free.
*/
-static void vbgdWaitFreeUnlocked(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTWAIT pWait)
+static void vgdrvWaitFreeUnlocked(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTWAIT pWait)
{
RTSpinlockAcquire(pDevExt->EventSpinlock);
- vbgdWaitFreeLocked(pDevExt, pWait);
+ vgdrvWaitFreeLocked(pDevExt, pWait);
RTSpinlockRelease(pDevExt->EventSpinlock);
}
*
* @param pDevExt The device extension.
*/
-void VbgdCommonWaitDoWakeUps(PVBOXGUESTDEVEXT pDevExt)
+void VGDrvCommonWaitDoWakeUps(PVBOXGUESTDEVEXT pDevExt)
{
if (!RTListIsEmpty(&pDevExt->WakeUpList))
{
else
{
pWait->fFreeMe = false;
- vbgdWaitFreeLocked(pDevExt, pWait);
+ vgdrvWaitFreeLocked(pDevExt, pWait);
}
}
RTSpinlockRelease(pDevExt->EventSpinlock);
* @param pDevExt The device extension.
* @param pSession The session.
*/
-int VbgdCommonIoCtlFast(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
+int VGDrvCommonIoCtlFast(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
{
- LogFlow(("VbgdCommonIoCtlFast: iFunction=%#x pDevExt=%p pSession=%p\n", iFunction, pDevExt, pSession));
+ LogFlow(("VGDrvCommonIoCtlFast: iFunction=%#x pDevExt=%p pSession=%p\n", iFunction, pDevExt, pSession));
NOREF(iFunction);
NOREF(pDevExt);
* @param pInfo The request info.
* @param pcbDataReturned (out) contains the number of bytes to return.
*/
-static int vbgdIoCtl_GetVMMDevPort(PVBOXGUESTDEVEXT pDevExt, VBoxGuestPortInfo *pInfo, size_t *pcbDataReturned)
+static int vgdrvIoCtl_GetVMMDevPort(PVBOXGUESTDEVEXT pDevExt, VBoxGuestPortInfo *pInfo, size_t *pcbDataReturned)
{
LogFlow(("VBOXGUEST_IOCTL_GETVMMDEVPORT\n"));
* @param pDevExt The device extension.
* @param pNotify The new callback information.
*/
-int vbgdIoCtl_SetMouseNotifyCallback(PVBOXGUESTDEVEXT pDevExt, VBoxGuestMouseSetNotifyCallback *pNotify)
+int vgdrvIoCtl_SetMouseNotifyCallback(PVBOXGUESTDEVEXT pDevExt, VBoxGuestMouseSetNotifyCallback *pNotify)
{
LogFlow(("VBOXGUEST_IOCTL_SET_MOUSE_NOTIFY_CALLBACK: pfnNotify=%p pvUser=%p\n", pNotify->pfnNotify, pNotify->pvUser));
/**
- * Worker vbgdIoCtl_WaitEvent.
+ * Worker vgdrvIoCtl_WaitEvent.
*
* The caller enters the spinlock, we leave it.
*
{
uint32_t fMatches = pDevExt->f32PendingEvents & fReqEvents;
if (fMatches & VBOXGUEST_ACQUIRE_STYLE_EVENTS)
- fMatches &= vbgdGetAllowedEventMaskForSession(pDevExt, pSession);
+ fMatches &= vgdrvGetAllowedEventMaskForSession(pDevExt, pSession);
if (fMatches || pSession->fPendingCancelWaitEvents)
{
ASMAtomicAndU32(&pDevExt->f32PendingEvents, ~fMatches);
}
-static int vbgdIoCtl_WaitEvent(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- VBoxGuestWaitEventInfo *pInfo, size_t *pcbDataReturned, bool fInterruptible)
+static int vgdrvIoCtl_WaitEvent(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ VBoxGuestWaitEventInfo *pInfo, size_t *pcbDataReturned, bool fInterruptible)
{
const uint32_t fReqEvents = pInfo->u32EventMaskIn;
uint32_t fResEvents;
return VERR_TIMEOUT;
}
- pWait = vbgdWaitAlloc(pDevExt, pSession);
+ pWait = vgdrvWaitAlloc(pDevExt, pSession);
if (!pWait)
return VERR_NO_MEMORY;
pWait->fReqEvents = fReqEvents;
rc = vbdgCheckWaitEventCondition(pDevExt, pSession, pInfo, iEvent, fReqEvents);
if (rc == VINF_SUCCESS)
{
- vbgdWaitFreeUnlocked(pDevExt, pWait);
+ vgdrvWaitFreeUnlocked(pDevExt, pWait);
return rc;
}
*/
RTSpinlockAcquire(pDevExt->EventSpinlock);
fResEvents = pWait->fResEvents;
- vbgdWaitFreeLocked(pDevExt, pWait);
+ vgdrvWaitFreeLocked(pDevExt, pWait);
RTSpinlockRelease(pDevExt->EventSpinlock);
/*
}
-static int vbgdIoCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
+static int vgdrvIoCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
{
PVBOXGUESTWAIT pWait;
PVBOXGUESTWAIT pSafe;
NOREF(rc);
#ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP
- VbgdCommonWaitDoWakeUps(pDevExt);
+ VGDrvCommonWaitDoWakeUps(pDevExt);
#endif
return VINF_SUCCESS;
* Checks if the VMM request is allowed in the context of the given session.
*
* @returns VINF_SUCCESS or VERR_PERMISSION_DENIED.
+ * @param pDevExt The device extension.
* @param pSession The calling session.
* @param enmType The request type.
* @param pReqHdr The request.
*/
-static int vbgdCheckIfVmmReqIsAllowed(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VMMDevRequestType enmType,
- VMMDevRequestHeader const *pReqHdr)
+static int vgdrvCheckIfVmmReqIsAllowed(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VMMDevRequestType enmType,
+ VMMDevRequestHeader const *pReqHdr)
{
/*
* Categorize the request being made.
return VERR_PERMISSION_DENIED;
}
-static int vbgdIoCtl_VMMRequest(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- VMMDevRequestHeader *pReqHdr, size_t cbData, size_t *pcbDataReturned)
+static int vgdrvIoCtl_VMMRequest(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ VMMDevRequestHeader *pReqHdr, size_t cbData, size_t *pcbDataReturned)
{
int rc;
VMMDevRequestHeader *pReqCopy;
return rc;
}
- rc = vbgdCheckIfVmmReqIsAllowed(pDevExt, pSession, enmType, pReqHdr);
+ rc = vgdrvCheckIfVmmReqIsAllowed(pDevExt, pSession, enmType, pReqHdr);
if (RT_FAILURE(rc))
{
Log(("VBOXGUEST_IOCTL_VMMREQUEST: Operation not allowed! type=%#x rc=%Rrc\n", enmType, rc));
AssertCompile(RT_INDEFINITE_WAIT == (uint32_t)RT_INDEFINITE_WAIT); /* assumed by code below */
-/** Worker for vbgdHgcmAsyncWaitCallback*. */
-static int vbgdHgcmAsyncWaitCallbackWorker(VMMDevHGCMRequestHeader volatile *pHdr, PVBOXGUESTDEVEXT pDevExt,
- bool fInterruptible, uint32_t cMillies)
+/** Worker for vgdrvHgcmAsyncWaitCallback*. */
+static int vgdrvHgcmAsyncWaitCallbackWorker(VMMDevHGCMRequestHeader volatile *pHdr, PVBOXGUESTDEVEXT pDevExt,
+ bool fInterruptible, uint32_t cMillies)
{
int rc;
}
RTSpinlockRelease(pDevExt->EventSpinlock);
- pWait = vbgdWaitAlloc(pDevExt, NULL);
+ pWait = vgdrvWaitAlloc(pDevExt, NULL);
if (pWait)
break;
if (fInterruptible)
RTListAppend(&pDevExt->HGCMWaitList, &pWait->ListNode);
if ((pHdr->fu32Flags & VBOX_HGCM_REQ_DONE) != 0)
{
- vbgdWaitFreeLocked(pDevExt, pWait);
+ vgdrvWaitFreeLocked(pDevExt, pWait);
RTSpinlockRelease(pDevExt->EventSpinlock);
return VINF_SUCCESS;
}
&& rc != VERR_TIMEOUT
&& ( !fInterruptible
|| rc != VERR_INTERRUPTED))
- LogRel(("vbgdHgcmAsyncWaitCallback: wait failed! %Rrc\n", rc));
+ LogRel(("vgdrvHgcmAsyncWaitCallback: wait failed! %Rrc\n", rc));
- vbgdWaitFreeUnlocked(pDevExt, pWait);
+ vgdrvWaitFreeUnlocked(pDevExt, pWait);
return rc;
}
/**
* This is a callback for dealing with async waits.
*
- * It operates in a manner similar to vbgdIoCtl_WaitEvent.
+ * It operates in a manner similar to vgdrvIoCtl_WaitEvent.
*/
-static DECLCALLBACK(int) vbgdHgcmAsyncWaitCallback(VMMDevHGCMRequestHeader *pHdr, void *pvUser, uint32_t u32User)
+static DECLCALLBACK(int) vgdrvHgcmAsyncWaitCallback(VMMDevHGCMRequestHeader *pHdr, void *pvUser, uint32_t u32User)
{
PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvUser;
- LogFlow(("vbgdHgcmAsyncWaitCallback: requestType=%d\n", pHdr->header.requestType));
- return vbgdHgcmAsyncWaitCallbackWorker((VMMDevHGCMRequestHeader volatile *)pHdr, pDevExt,
- false /* fInterruptible */, u32User /* cMillies */);
+ LogFlow(("vgdrvHgcmAsyncWaitCallback: requestType=%d\n", pHdr->header.requestType));
+ return vgdrvHgcmAsyncWaitCallbackWorker((VMMDevHGCMRequestHeader volatile *)pHdr, pDevExt,
+ false /* fInterruptible */, u32User /* cMillies */);
}
/**
* This is a callback for dealing with async waits with a timeout.
*
- * It operates in a manner similar to vbgdIoCtl_WaitEvent.
+ * It operates in a manner similar to vgdrvIoCtl_WaitEvent.
*/
-static DECLCALLBACK(int) vbgdHgcmAsyncWaitCallbackInterruptible(VMMDevHGCMRequestHeader *pHdr, void *pvUser, uint32_t u32User)
+static DECLCALLBACK(int) vgdrvHgcmAsyncWaitCallbackInterruptible(VMMDevHGCMRequestHeader *pHdr, void *pvUser, uint32_t u32User)
{
PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvUser;
- LogFlow(("vbgdHgcmAsyncWaitCallbackInterruptible: requestType=%d\n", pHdr->header.requestType));
- return vbgdHgcmAsyncWaitCallbackWorker((VMMDevHGCMRequestHeader volatile *)pHdr, pDevExt,
- true /* fInterruptible */, u32User /* cMillies */);
+ LogFlow(("vgdrvHgcmAsyncWaitCallbackInterruptible: requestType=%d\n", pHdr->header.requestType));
+ return vgdrvHgcmAsyncWaitCallbackWorker((VMMDevHGCMRequestHeader volatile *)pHdr, pDevExt,
+ true /* fInterruptible */, u32User /* cMillies */);
}
-static int vbgdIoCtl_HGCMConnect(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- VBoxGuestHGCMConnectInfo *pInfo, size_t *pcbDataReturned)
+static int vgdrvIoCtl_HGCMConnect(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ VBoxGuestHGCMConnectInfo *pInfo, size_t *pcbDataReturned)
{
int rc;
pInfo->Loc.type == VMMDevHGCMLoc_LocalHost || pInfo->Loc.type == VMMDevHGCMLoc_LocalHost_Existing
? pInfo->Loc.u.host.achName : "<not local host>"));
- rc = VbglR0HGCMInternalConnect(pInfo, vbgdHgcmAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
+ rc = VbglR0HGCMInternalConnect(pInfo, vgdrvHgcmAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
if (RT_SUCCESS(rc))
{
Log(("VBOXGUEST_IOCTL_HGCM_CONNECT: u32Client=%RX32 result=%Rrc (rc=%Rrc)\n",
LogRelMax(32, ("VBOXGUEST_IOCTL_HGCM_CONNECT: too many HGCMConnect calls for one session!\n"));
Info.result = 0;
Info.u32ClientID = pInfo->u32ClientID;
- VbglR0HGCMInternalDisconnect(&Info, vbgdHgcmAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
+ VbglR0HGCMInternalDisconnect(&Info, vgdrvHgcmAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
return VERR_TOO_MANY_OPEN_FILES;
}
}
}
-static int vbgdIoCtl_HGCMDisconnect(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- VBoxGuestHGCMDisconnectInfo *pInfo, size_t *pcbDataReturned)
+static int vgdrvIoCtl_HGCMDisconnect(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ VBoxGuestHGCMDisconnectInfo *pInfo, size_t *pcbDataReturned)
{
/*
* Validate the client id and invalidate its entry while we're in the call.
* to deal with cancelled requests.
*/
Log(("VBOXGUEST_IOCTL_HGCM_DISCONNECT: u32Client=%RX32\n", pInfo->u32ClientID));
- rc = VbglR0HGCMInternalDisconnect(pInfo, vbgdHgcmAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
+ rc = VbglR0HGCMInternalDisconnect(pInfo, vgdrvHgcmAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
if (RT_SUCCESS(rc))
{
LogFlow(("VBOXGUEST_IOCTL_HGCM_DISCONNECT: result=%Rrc\n", pInfo->result));
}
-static int vbgdIoCtl_HGCMCall(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VBoxGuestHGCMCallInfo *pInfo,
- uint32_t cMillies, bool fInterruptible, bool f32bit, bool fUserData,
- size_t cbExtra, size_t cbData, size_t *pcbDataReturned)
+static int vgdrvIoCtl_HGCMCall(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VBoxGuestHGCMCallInfo *pInfo,
+ uint32_t cMillies, bool fInterruptible, bool f32bit, bool fUserData,
+ size_t cbExtra, size_t cbData, size_t *pcbDataReturned)
{
const uint32_t u32ClientId = pInfo->u32ClientID;
uint32_t fFlags;
if (f32bit)
{
if (fInterruptible)
- rc = VbglR0HGCMInternalCall32(pInfo, cbInfo, fFlags, vbgdHgcmAsyncWaitCallbackInterruptible, pDevExt, cMillies);
+ rc = VbglR0HGCMInternalCall32(pInfo, cbInfo, fFlags, vgdrvHgcmAsyncWaitCallbackInterruptible, pDevExt, cMillies);
else
- rc = VbglR0HGCMInternalCall32(pInfo, cbInfo, fFlags, vbgdHgcmAsyncWaitCallback, pDevExt, cMillies);
+ rc = VbglR0HGCMInternalCall32(pInfo, cbInfo, fFlags, vgdrvHgcmAsyncWaitCallback, pDevExt, cMillies);
}
else
#endif
{
if (fInterruptible)
- rc = VbglR0HGCMInternalCall(pInfo, cbInfo, fFlags, vbgdHgcmAsyncWaitCallbackInterruptible, pDevExt, cMillies);
+ rc = VbglR0HGCMInternalCall(pInfo, cbInfo, fFlags, vgdrvHgcmAsyncWaitCallbackInterruptible, pDevExt, cMillies);
else
- rc = VbglR0HGCMInternalCall(pInfo, cbInfo, fFlags, vbgdHgcmAsyncWaitCallback, pDevExt, cMillies);
+ rc = VbglR0HGCMInternalCall(pInfo, cbInfo, fFlags, vgdrvHgcmAsyncWaitCallback, pDevExt, cMillies);
}
if (RT_SUCCESS(rc))
{
* @param pcbDataReturned Where to store the amount of returned data. Can
* be NULL.
*/
-static int vbgdIoCtl_CheckMemoryBalloon(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- VBoxGuestCheckBalloonInfo *pInfo, size_t *pcbDataReturned)
+static int vgdrvIoCtl_CheckMemoryBalloon(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ VBoxGuestCheckBalloonInfo *pInfo, size_t *pcbDataReturned)
{
VMMDevGetMemBalloonChangeRequest *pReq;
int rc;
/*
* The first user trying to query/change the balloon becomes the
- * owner and owns it until the session is closed (vbgdCloseMemBalloon).
+ * owner and owns it until the session is closed (vgdrvCloseMemBalloon).
*/
if ( pDevExt->MemBalloon.pOwner != pSession
&& pDevExt->MemBalloon.pOwner == NULL)
pInfo->cBalloonChunks = pReq->cBalloonChunks;
pInfo->fHandleInR3 = false;
- rc = vbgdSetBalloonSizeKernel(pDevExt, pReq->cBalloonChunks, &pInfo->fHandleInR3);
+ rc = vgdrvSetBalloonSizeKernel(pDevExt, pReq->cBalloonChunks, &pInfo->fHandleInR3);
/* Ignore various out of memory failures. */
if ( rc == VERR_NO_MEMORY
|| rc == VERR_NO_PHYS_MEMORY
* @param pcbDataReturned Where to store the amount of returned data. Can
* be NULL.
*/
-static int vbgdIoCtl_ChangeMemoryBalloon(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- VBoxGuestChangeBalloonInfo *pInfo, size_t *pcbDataReturned)
+static int vgdrvIoCtl_ChangeMemoryBalloon(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ VBoxGuestChangeBalloonInfo *pInfo, size_t *pcbDataReturned)
{
int rc;
LogFlow(("VBOXGUEST_IOCTL_CHANGE_BALLOON: fInflate=%RTbool u64ChunkAddr=%#RX64\n", pInfo->fInflate, pInfo->u64ChunkAddr));
{
/*
* The first user trying to query/change the balloon becomes the
- * owner and owns it until the session is closed (vbgdCloseMemBalloon).
+ * owner and owns it until the session is closed (vgdrvCloseMemBalloon).
*/
if ( pDevExt->MemBalloon.pOwner != pSession
&& pDevExt->MemBalloon.pOwner == NULL)
if (pDevExt->MemBalloon.pOwner == pSession)
{
- rc = vbgdSetBalloonSizeFromUser(pDevExt, pSession, pInfo->u64ChunkAddr, !!pInfo->fInflate);
+ rc = vgdrvSetBalloonSizeFromUser(pDevExt, pSession, pInfo->u64ChunkAddr, !!pInfo->fInflate);
if (pcbDataReturned)
*pcbDataReturned = 0;
}
* @param pDevExt The device extension.
* @param pInfo The output buffer.
*/
-static int vbgdIoCtl_WriteCoreDump(PVBOXGUESTDEVEXT pDevExt, VBoxGuestWriteCoreDump *pInfo)
+static int vgdrvIoCtl_WriteCoreDump(PVBOXGUESTDEVEXT pDevExt, VBoxGuestWriteCoreDump *pInfo)
{
VMMDevReqWriteCoreDump *pReq = NULL;
int rc;
* @param pch The log message (need not be NULL terminated).
* @param cbData Size of the buffer.
* @param pcbDataReturned Where to store the amount of returned data. Can be NULL.
+ * @param fUserSession Copy of VBOXGUESTSESSION::fUserSession for the
+ * call. True normal user, false root user.
*/
-static int vbgdIoCtl_Log(PVBOXGUESTDEVEXT pDevExt, const char *pch, size_t cbData, size_t *pcbDataReturned, bool fUserSession)
+static int vgdrvIoCtl_Log(PVBOXGUESTDEVEXT pDevExt, const char *pch, size_t cbData, size_t *pcbDataReturned, bool fUserSession)
{
if (pDevExt->fLoggingEnabled)
RTLogBackdoorPrintf("%.*s", cbData, pch);
*
* @param pTracker The tracker to clear.
*/
-static void vbgdBitUsageTrackerClear(PVBOXGUESTBITUSAGETRACER pTracker)
+static void vgdrvBitUsageTrackerClear(PVBOXGUESTBITUSAGETRACER pTracker)
{
uint32_t iBit;
AssertCompile(sizeof(pTracker->acPerBitUsage) == 32 * sizeof(uint32_t));
* @param cMax Max valid usage value.
* @param pszWhat Identifies the tracker in assertions.
*/
-static void vbgdBitUsageTrackerCheckMask(PCVBOXGUESTBITUSAGETRACER pTracker, uint32_t cMax, const char *pszWhat)
+static void vgdrvBitUsageTrackerCheckMask(PCVBOXGUESTBITUSAGETRACER pTracker, uint32_t cMax, const char *pszWhat)
{
uint32_t fMask = 0;
uint32_t iBit;
* @param cMax The max valid usage value for assertions.
* @param pszWhat Identifies the tracker in assertions.
*/
-static bool vbgdBitUsageTrackerChange(PVBOXGUESTBITUSAGETRACER pTracker, uint32_t fChanged, uint32_t fPrevious,
- uint32_t cMax, const char *pszWhat)
+static bool vgdrvBitUsageTrackerChange(PVBOXGUESTBITUSAGETRACER pTracker, uint32_t fChanged, uint32_t fPrevious,
+ uint32_t cMax, const char *pszWhat)
{
bool fGlobalChange = false;
AssertCompile(sizeof(pTracker->acPerBitUsage) == 32 * sizeof(uint32_t));
}
#ifdef VBOX_STRICT
- vbgdBitUsageTrackerCheckMask(pTracker, cMax, pszWhat);
+ vgdrvBitUsageTrackerCheckMask(pTracker, cMax, pszWhat);
#endif
NOREF(pszWhat); NOREF(cMax);
return fGlobalChange;
* @param pDevExt The device extension.
* @param fFixedEvents Fixed events (init time).
*/
-static int vbgdResetEventFilterOnHost(PVBOXGUESTDEVEXT pDevExt, uint32_t fFixedEvents)
+static int vgdrvResetEventFilterOnHost(PVBOXGUESTDEVEXT pDevExt, uint32_t fFixedEvents)
{
VMMDevCtlGuestFilterMask *pReq;
int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof(*pReq), VMMDevReq_CtlGuestFilterMask);
*
* @remarks Takes the session spinlock.
*/
-static int vbgdSetSessionEventFilter(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination)
+static int vgdrvSetSessionEventFilter(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination)
{
VMMDevCtlGuestFilterMask *pReq;
uint32_t fChanged;
{ /* nothing */ }
else if (!fSessionTermination)
{
- LogRel(("vbgdSetSessionFilterMask: VbglGRAlloc failure: %Rrc\n", rc));
+ LogRel(("vgdrvSetSessionFilterMask: VbglGRAlloc failure: %Rrc\n", rc));
return rc;
}
else
fChanged = fPrevious ^ pSession->fEventFilter;
if (fChanged)
{
- bool fGlobalChange = vbgdBitUsageTrackerChange(&pDevExt->EventFilterTracker, fChanged, fPrevious,
- pDevExt->cSessions, "EventFilterTracker");
+ bool fGlobalChange = vgdrvBitUsageTrackerChange(&pDevExt->EventFilterTracker, fChanged, fPrevious,
+ pDevExt->cSessions, "EventFilterTracker");
/*
* If there are global changes, update the event filter on the host.
pDevExt->fEventFilterHost = UINT32_MAX;
if (!fSessionTermination)
{
- vbgdBitUsageTrackerChange(&pDevExt->EventFilterTracker, fChanged, pSession->fEventFilter,
- pDevExt->cSessions, "EventFilterTracker");
+ vgdrvBitUsageTrackerChange(&pDevExt->EventFilterTracker, fChanged, pSession->fEventFilter,
+ pDevExt->cSessions, "EventFilterTracker");
pSession->fEventFilter = fPrevious;
}
}
* @param pSession The session.
* @param pInfo The request.
*/
-static int vbgdIoCtl_CtlFilterMask(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VBoxGuestFilterMaskInfo *pInfo)
+static int vgdrvIoCtl_CtlFilterMask(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VBoxGuestFilterMaskInfo *pInfo)
{
LogFlow(("VBOXGUEST_IOCTL_CTL_FILTER_MASK: or=%#x not=%#x\n", pInfo->u32OrMask, pInfo->u32NotMask));
return VERR_INVALID_PARAMETER;
}
- return vbgdSetSessionEventFilter(pDevExt, pSession, pInfo->u32OrMask, pInfo->u32NotMask, false /*fSessionTermination*/);
+ return vgdrvSetSessionEventFilter(pDevExt, pSession, pInfo->u32OrMask, pInfo->u32NotMask, false /*fSessionTermination*/);
}
* @returns VBox status code.
* @param pDevExt The device extension.
*/
-static int vbgdResetMouseStatusOnHost(PVBOXGUESTDEVEXT pDevExt)
+static int vgdrvResetMouseStatusOnHost(PVBOXGUESTDEVEXT pDevExt)
{
VMMDevReqMouseStatus *pReq;
int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof(*pReq), VMMDevReq_SetMouseStatus);
*
* @remarks Takes the session spinlock.
*/
-static int vbgdSetSessionMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination)
+static int vgdrvSetSessionMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination)
{
VMMDevReqMouseStatus *pReq;
uint32_t fChanged;
{ /* nothing */ }
else if (!fSessionTermination)
{
- LogRel(("vbgdSetSessionMouseStatus: VbglGRAlloc failure: %Rrc\n", rc));
+ LogRel(("vgdrvSetSessionMouseStatus: VbglGRAlloc failure: %Rrc\n", rc));
return rc;
}
else
fChanged = fPrevious ^ pSession->fMouseStatus;
if (fChanged)
{
- bool fGlobalChange = vbgdBitUsageTrackerChange(&pDevExt->MouseStatusTracker, fChanged, fPrevious,
- pDevExt->cSessions, "MouseStatusTracker");
+ bool fGlobalChange = vgdrvBitUsageTrackerChange(&pDevExt->MouseStatusTracker, fChanged, fPrevious,
+ pDevExt->cSessions, "MouseStatusTracker");
/*
* If there are global changes, update the event filter on the host.
pDevExt->fMouseStatusHost = UINT32_MAX;
if (!fSessionTermination)
{
- vbgdBitUsageTrackerChange(&pDevExt->MouseStatusTracker, fChanged, pSession->fMouseStatus,
- pDevExt->cSessions, "MouseStatusTracker");
+ vgdrvBitUsageTrackerChange(&pDevExt->MouseStatusTracker, fChanged, pSession->fMouseStatus,
+ pDevExt->cSessions, "MouseStatusTracker");
pSession->fMouseStatus = fPrevious;
}
}
* @param pSession The session.
* @param fFeatures New bitmap of enabled features.
*/
-static int vbgdIoCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fFeatures)
+static int vgdrvIoCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fFeatures)
{
LogFlow(("VBOXGUEST_IOCTL_SET_MOUSE_STATUS: features=%#x\n", fFeatures));
if (fFeatures & ~VMMDEV_MOUSE_GUEST_MASK)
return VERR_INVALID_PARAMETER;
- return vbgdSetSessionMouseStatus(pDevExt, pSession, fFeatures, ~fFeatures, false /*fSessionTermination*/);
+ return vgdrvSetSessionMouseStatus(pDevExt, pSession, fFeatures, ~fFeatures, false /*fSessionTermination*/);
}
* @remarks Needs only be called when dispatching events in the
* VBOXGUEST_ACQUIRE_STYLE_EVENTS mask.
*/
-static uint32_t vbgdGetAllowedEventMaskForSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
+static uint32_t vgdrvGetAllowedEventMaskForSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
{
uint32_t fAcquireModeGuestCaps;
uint32_t fAcquiredGuestCaps;
* @returns VBox status code.
* @param pDevExt The device extension.
*/
-static int vbgdResetCapabilitiesOnHost(PVBOXGUESTDEVEXT pDevExt)
+static int vgdrvResetCapabilitiesOnHost(PVBOXGUESTDEVEXT pDevExt)
{
VMMDevReqGuestCapabilities2 *pReq;
int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof(*pReq), VMMDevReq_SetGuestCapabilities);
* we'll simply clear all bits we don't set.
*
* @returns VBox status code.
- * @param fMask The new mask.
+ * @param pDevExt The device extension.
+ * @param pReq The request.
*/
-static int vbgdUpdateCapabilitiesOnHostWithReqAndLock(PVBOXGUESTDEVEXT pDevExt, VMMDevReqGuestCapabilities2 *pReq)
+static int vgdrvUpdateCapabilitiesOnHostWithReqAndLock(PVBOXGUESTDEVEXT pDevExt, VMMDevReqGuestCapabilities2 *pReq)
{
int rc;
*
* @remarks Takes both the session and event spinlocks.
*/
-static int vbgdAcquireSessionCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- uint32_t fOrMask, uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags,
- bool fSessionTermination)
+static int vgdrvAcquireSessionCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ uint32_t fOrMask, uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags,
+ bool fSessionTermination)
{
uint32_t fCurrentOwnedCaps;
uint32_t fSessionRemovedCaps;
| VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING
| VMMDEV_GUEST_SUPPORTS_GRAPHICS ) )
{
- LogRel(("vbgdAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x -- invalid fOrMask\n",
+ LogRel(("vgdrvAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x -- invalid fOrMask\n",
pSession, fOrMask, fNotMask, enmFlags));
return VERR_INVALID_PARAMETER;
}
if ( enmFlags != VBOXGUESTCAPSACQUIRE_FLAGS_CONFIG_ACQUIRE_MODE
&& enmFlags != VBOXGUESTCAPSACQUIRE_FLAGS_NONE)
{
- LogRel(("vbgdAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x: invalid enmFlags %d\n",
+ LogRel(("vgdrvAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x: invalid enmFlags %d\n",
pSession, fOrMask, fNotMask, enmFlags));
return VERR_INVALID_PARAMETER;
}
{ /* do nothing */ }
else if (!fSessionTermination)
{
- LogRel(("vbgdAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x: VbglGRAlloc failure: %Rrc\n",
+ LogRel(("vgdrvAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x: VbglGRAlloc failure: %Rrc\n",
pSession, fOrMask, fNotMask, enmFlags, rc));
return rc;
}
if (pReq)
VbglGRFree(&pReq->header);
AssertMsgFailed(("Trying to change caps mode: %#x\n", fOrMask));
- LogRel(("vbgdAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x: calling caps acquire for set caps\n",
+ LogRel(("vgdrvAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x: calling caps acquire for set caps\n",
pSession, fOrMask, fNotMask, enmFlags));
return VERR_INVALID_STATE;
}
RTSpinlockRelease(pDevExt->EventSpinlock);
Assert(!pReq);
- Log(("vbgdAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x: configured acquire caps: 0x%x\n",
+ Log(("vgdrvAcquireSessionCapabilities: pSession=%p fOrMask=%#x fNotMask=%#x enmFlags=%#x: configured acquire caps: 0x%x\n",
pSession, fOrMask, fNotMask, enmFlags));
return VINF_SUCCESS;
}
Assert(pReq || fSessionTermination);
if (pReq)
{
- rc = vbgdUpdateCapabilitiesOnHostWithReqAndLock(pDevExt, pReq);
+ rc = vgdrvUpdateCapabilitiesOnHostWithReqAndLock(pDevExt, pReq);
if (RT_FAILURE(rc) && !fSessionTermination)
{
/* Failed, roll back. */
}
RTSpinlockRelease(pDevExt->EventSpinlock);
- LogRel(("vbgdAcquireSessionCapabilities: vbgdUpdateCapabilitiesOnHostWithReqAndLock failed: rc=%Rrc\n", rc));
+ LogRel(("vgdrvAcquireSessionCapabilities: vgdrvUpdateCapabilitiesOnHostWithReqAndLock failed: rc=%Rrc\n", rc));
VbglGRFree(&pReq->header);
return rc;
}
{
RTSpinlockRelease(pDevExt->EventSpinlock);
- Log(("vbgdAcquireSessionCapabilities: Caps %#x were busy\n", fOtherConflictingCaps));
+ Log(("vgdrvAcquireSessionCapabilities: Caps %#x were busy\n", fOtherConflictingCaps));
VbglGRFree(&pReq->header);
return VERR_RESOURCE_BUSY;
}
RTSpinlockAcquire(pDevExt->EventSpinlock);
if (fGenFakeEvents || pDevExt->f32PendingEvents)
- vbgdDispatchEventsLocked(pDevExt, fGenFakeEvents);
+ vgdrvDispatchEventsLocked(pDevExt, fGenFakeEvents);
RTSpinlockRelease(pDevExt->EventSpinlock);
#ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP
- VbgdCommonWaitDoWakeUps(pDevExt);
+ VGDrvCommonWaitDoWakeUps(pDevExt);
#endif
}
* @param pSession The session.
* @param pAcquire The request.
*/
-static int vbgdIoCtl_GuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VBoxGuestCapsAquire *pAcquire)
+static int vgdrvIoCtl_GuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VBoxGuestCapsAquire *pAcquire)
{
int rc;
LogFlow(("VBOXGUEST_IOCTL_GUEST_CAPS_ACQUIRE: or=%#x not=%#x flags=%#x\n",
pAcquire->u32OrMask, pAcquire->u32NotMask, pAcquire->enmFlags));
- rc = vbgdAcquireSessionCapabilities(pDevExt, pSession, pAcquire->u32OrMask, pAcquire->u32NotMask, pAcquire->enmFlags,
- false /*fSessionTermination*/);
+ rc = vgdrvAcquireSessionCapabilities(pDevExt, pSession, pAcquire->u32OrMask, pAcquire->u32NotMask, pAcquire->enmFlags,
+ false /*fSessionTermination*/);
if (RT_FAILURE(rc))
- LogRel(("VbgdCommonIoCtl: GUEST_CAPS_ACQUIRE failed rc=%Rrc\n", rc));
+ LogRel(("VGDrvCommonIoCtl: GUEST_CAPS_ACQUIRE failed rc=%Rrc\n", rc));
pAcquire->rc = rc;
return VINF_SUCCESS;
}
*
* @remarks Takes the session spinlock.
*/
-static int vbgdSetSessionCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination)
+static int vgdrvSetSessionCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ uint32_t fOrMask, uint32_t fNotMask, bool fSessionTermination)
{
/*
* Preallocate a request buffer so we can do all in one go without leaving the spinlock.
{ /* nothing */ }
else if (!fSessionTermination)
{
- LogRel(("vbgdSetSessionCapabilities: VbglGRAlloc failure: %Rrc\n", rc));
+ LogRel(("vgdrvSetSessionCapabilities: VbglGRAlloc failure: %Rrc\n", rc));
return rc;
}
else
fChanged = fPrevious ^ pSession->fCapabilities;
if (fChanged)
{
- bool fGlobalChange = vbgdBitUsageTrackerChange(&pDevExt->SetGuestCapsTracker, fChanged, fPrevious,
- pDevExt->cSessions, "SetGuestCapsTracker");
+ bool fGlobalChange = vgdrvBitUsageTrackerChange(&pDevExt->SetGuestCapsTracker, fChanged, fPrevious,
+ pDevExt->cSessions, "SetGuestCapsTracker");
/*
* If there are global changes, update the capabilities on the host.
Assert(pReq || fSessionTermination);
if (pReq)
{
- rc = vbgdUpdateCapabilitiesOnHostWithReqAndLock(pDevExt, pReq);
+ rc = vgdrvUpdateCapabilitiesOnHostWithReqAndLock(pDevExt, pReq);
/* On failure, roll back (unless it's session termination time). */
if (RT_FAILURE(rc) && !fSessionTermination)
{
- vbgdBitUsageTrackerChange(&pDevExt->SetGuestCapsTracker, fChanged, pSession->fCapabilities,
- pDevExt->cSessions, "SetGuestCapsTracker");
+ vgdrvBitUsageTrackerChange(&pDevExt->SetGuestCapsTracker, fChanged, pSession->fCapabilities,
+ pDevExt->cSessions, "SetGuestCapsTracker");
pSession->fCapabilities = fPrevious;
}
}
* @param pSession The session.
* @param pInfo The request.
*/
-static int vbgdIoCtl_SetCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VBoxGuestSetCapabilitiesInfo *pInfo)
+static int vgdrvIoCtl_SetCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, VBoxGuestSetCapabilitiesInfo *pInfo)
{
int rc;
LogFlow(("VBOXGUEST_IOCTL_SET_GUEST_CAPABILITIES: or=%#x not=%#x\n", pInfo->u32OrMask, pInfo->u32NotMask));
if (!((pInfo->u32OrMask | pInfo->u32NotMask) & ~VMMDEV_GUEST_CAPABILITIES_MASK))
- rc = vbgdSetSessionCapabilities(pDevExt, pSession, pInfo->u32OrMask, pInfo->u32NotMask, false /*fSessionTermination*/);
+ rc = vgdrvSetSessionCapabilities(pDevExt, pSession, pInfo->u32OrMask, pInfo->u32NotMask, false /*fSessionTermination*/);
else
rc = VERR_INVALID_PARAMETER;
* @param cbData The max size of the data buffer.
* @param pcbDataReturned Where to store the amount of returned data. Can be NULL.
*/
-int VbgdCommonIoCtl(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- void *pvData, size_t cbData, size_t *pcbDataReturned)
+int VGDrvCommonIoCtl(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ void *pvData, size_t cbData, size_t *pcbDataReturned)
{
int rc;
- LogFlow(("VbgdCommonIoCtl: iFunction=%#x pDevExt=%p pSession=%p pvData=%p cbData=%zu\n",
+ LogFlow(("VGDrvCommonIoCtl: iFunction=%#x pDevExt=%p pSession=%p pvData=%p cbData=%zu\n",
iFunction, pDevExt, pSession, pvData, cbData));
/*
if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_VMMREQUEST(0)))
{
CHECKRET_MIN_SIZE("VMMREQUEST", sizeof(VMMDevRequestHeader));
- rc = vbgdIoCtl_VMMRequest(pDevExt, pSession, (VMMDevRequestHeader *)pvData, cbData, pcbDataReturned);
+ rc = vgdrvIoCtl_VMMRequest(pDevExt, pSession, (VMMDevRequestHeader *)pvData, cbData, pcbDataReturned);
}
#ifdef VBOX_WITH_HGCM
/*
{
bool fInterruptible = pSession->R0Process != NIL_RTR0PROCESS;
CHECKRET_MIN_SIZE("HGCM_CALL", sizeof(VBoxGuestHGCMCallInfo));
- rc = vbgdIoCtl_HGCMCall(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT,
- fInterruptible, false /*f32bit*/, false /* fUserData */,
- 0, cbData, pcbDataReturned);
+ rc = vgdrvIoCtl_HGCMCall(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT,
+ fInterruptible, false /*f32bit*/, false /* fUserData */,
+ 0, cbData, pcbDataReturned);
}
else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_TIMED(0)))
{
VBoxGuestHGCMCallInfoTimed *pInfo = (VBoxGuestHGCMCallInfoTimed *)pvData;
CHECKRET_MIN_SIZE("HGCM_CALL_TIMED", sizeof(VBoxGuestHGCMCallInfoTimed));
- rc = vbgdIoCtl_HGCMCall(pDevExt, pSession, &pInfo->info, pInfo->u32Timeout,
- !!pInfo->fInterruptible || pSession->R0Process != NIL_RTR0PROCESS,
- false /*f32bit*/, false /* fUserData */,
- RT_OFFSETOF(VBoxGuestHGCMCallInfoTimed, info), cbData, pcbDataReturned);
+ rc = vgdrvIoCtl_HGCMCall(pDevExt, pSession, &pInfo->info, pInfo->u32Timeout,
+ !!pInfo->fInterruptible || pSession->R0Process != NIL_RTR0PROCESS,
+ false /*f32bit*/, false /* fUserData */,
+ RT_OFFSETOF(VBoxGuestHGCMCallInfoTimed, info), cbData, pcbDataReturned);
}
else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_USERDATA(0)))
{
bool fInterruptible = true;
CHECKRET_MIN_SIZE("HGCM_CALL", sizeof(VBoxGuestHGCMCallInfo));
- rc = vbgdIoCtl_HGCMCall(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT,
- fInterruptible, false /*f32bit*/, true /* fUserData */,
- 0, cbData, pcbDataReturned);
+ rc = vgdrvIoCtl_HGCMCall(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT,
+ fInterruptible, false /*f32bit*/, true /* fUserData */,
+ 0, cbData, pcbDataReturned);
}
# ifdef RT_ARCH_AMD64
else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_32(0)))
{
bool fInterruptible = pSession->R0Process != NIL_RTR0PROCESS;
CHECKRET_MIN_SIZE("HGCM_CALL", sizeof(VBoxGuestHGCMCallInfo));
- rc = vbgdIoCtl_HGCMCall(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT,
- fInterruptible, true /*f32bit*/, false /* fUserData */,
- 0, cbData, pcbDataReturned);
+ rc = vgdrvIoCtl_HGCMCall(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT,
+ fInterruptible, true /*f32bit*/, false /* fUserData */,
+ 0, cbData, pcbDataReturned);
}
else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_TIMED_32(0)))
{
CHECKRET_MIN_SIZE("HGCM_CALL_TIMED", sizeof(VBoxGuestHGCMCallInfoTimed));
VBoxGuestHGCMCallInfoTimed *pInfo = (VBoxGuestHGCMCallInfoTimed *)pvData;
- rc = vbgdIoCtl_HGCMCall(pDevExt, pSession, &pInfo->info, pInfo->u32Timeout,
- !!pInfo->fInterruptible || pSession->R0Process != NIL_RTR0PROCESS,
- true /*f32bit*/, false /* fUserData */,
- RT_OFFSETOF(VBoxGuestHGCMCallInfoTimed, info), cbData, pcbDataReturned);
+ rc = vgdrvIoCtl_HGCMCall(pDevExt, pSession, &pInfo->info, pInfo->u32Timeout,
+ !!pInfo->fInterruptible || pSession->R0Process != NIL_RTR0PROCESS,
+ true /*f32bit*/, false /* fUserData */,
+ RT_OFFSETOF(VBoxGuestHGCMCallInfoTimed, info), cbData, pcbDataReturned);
}
# endif
#endif /* VBOX_WITH_HGCM */
else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_LOG(0)))
{
CHECKRET_MIN_SIZE("LOG", 1);
- rc = vbgdIoCtl_Log(pDevExt, (char *)pvData, cbData, pcbDataReturned, pSession->fUserSession);
+ rc = vgdrvIoCtl_Log(pDevExt, (char *)pvData, cbData, pcbDataReturned, pSession->fUserSession);
}
else
{
case VBOXGUEST_IOCTL_GETVMMDEVPORT:
CHECKRET_RING0("GETVMMDEVPORT");
CHECKRET_MIN_SIZE("GETVMMDEVPORT", sizeof(VBoxGuestPortInfo));
- rc = vbgdIoCtl_GetVMMDevPort(pDevExt, (VBoxGuestPortInfo *)pvData, pcbDataReturned);
+ rc = vgdrvIoCtl_GetVMMDevPort(pDevExt, (VBoxGuestPortInfo *)pvData, pcbDataReturned);
break;
#ifndef RT_OS_WINDOWS /* Windows has its own implementation of this. */
case VBOXGUEST_IOCTL_SET_MOUSE_NOTIFY_CALLBACK:
CHECKRET_RING0("SET_MOUSE_NOTIFY_CALLBACK");
CHECKRET_SIZE("SET_MOUSE_NOTIFY_CALLBACK", sizeof(VBoxGuestMouseSetNotifyCallback));
- rc = vbgdIoCtl_SetMouseNotifyCallback(pDevExt, (VBoxGuestMouseSetNotifyCallback *)pvData);
+ rc = vgdrvIoCtl_SetMouseNotifyCallback(pDevExt, (VBoxGuestMouseSetNotifyCallback *)pvData);
break;
#endif
case VBOXGUEST_IOCTL_WAITEVENT:
CHECKRET_MIN_SIZE("WAITEVENT", sizeof(VBoxGuestWaitEventInfo));
- rc = vbgdIoCtl_WaitEvent(pDevExt, pSession, (VBoxGuestWaitEventInfo *)pvData,
- pcbDataReturned, pSession->R0Process != NIL_RTR0PROCESS);
+ rc = vgdrvIoCtl_WaitEvent(pDevExt, pSession, (VBoxGuestWaitEventInfo *)pvData,
+ pcbDataReturned, pSession->R0Process != NIL_RTR0PROCESS);
break;
case VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS:
CHECKRET_SIZE("CANCEL_ALL_WAITEVENTS", 0);
- rc = vbgdIoCtl_CancelAllWaitEvents(pDevExt, pSession);
+ rc = vgdrvIoCtl_CancelAllWaitEvents(pDevExt, pSession);
break;
case VBOXGUEST_IOCTL_CTL_FILTER_MASK:
CHECKRET_MIN_SIZE("CTL_FILTER_MASK", sizeof(VBoxGuestFilterMaskInfo));
- rc = vbgdIoCtl_CtlFilterMask(pDevExt, pSession, (VBoxGuestFilterMaskInfo *)pvData);
+ rc = vgdrvIoCtl_CtlFilterMask(pDevExt, pSession, (VBoxGuestFilterMaskInfo *)pvData);
break;
#ifdef VBOX_WITH_HGCM
case VBOXGUEST_IOCTL_HGCM_CONNECT_32:
# endif
CHECKRET_MIN_SIZE("HGCM_CONNECT", sizeof(VBoxGuestHGCMConnectInfo));
- rc = vbgdIoCtl_HGCMConnect(pDevExt, pSession, (VBoxGuestHGCMConnectInfo *)pvData, pcbDataReturned);
+ rc = vgdrvIoCtl_HGCMConnect(pDevExt, pSession, (VBoxGuestHGCMConnectInfo *)pvData, pcbDataReturned);
break;
case VBOXGUEST_IOCTL_HGCM_DISCONNECT:
case VBOXGUEST_IOCTL_HGCM_DISCONNECT_32:
# endif
CHECKRET_MIN_SIZE("HGCM_DISCONNECT", sizeof(VBoxGuestHGCMDisconnectInfo));
- rc = vbgdIoCtl_HGCMDisconnect(pDevExt, pSession, (VBoxGuestHGCMDisconnectInfo *)pvData, pcbDataReturned);
+ rc = vgdrvIoCtl_HGCMDisconnect(pDevExt, pSession, (VBoxGuestHGCMDisconnectInfo *)pvData, pcbDataReturned);
break;
#endif /* VBOX_WITH_HGCM */
case VBOXGUEST_IOCTL_CHECK_BALLOON:
CHECKRET_MIN_SIZE("CHECK_MEMORY_BALLOON", sizeof(VBoxGuestCheckBalloonInfo));
- rc = vbgdIoCtl_CheckMemoryBalloon(pDevExt, pSession, (VBoxGuestCheckBalloonInfo *)pvData, pcbDataReturned);
+ rc = vgdrvIoCtl_CheckMemoryBalloon(pDevExt, pSession, (VBoxGuestCheckBalloonInfo *)pvData, pcbDataReturned);
break;
case VBOXGUEST_IOCTL_CHANGE_BALLOON:
CHECKRET_MIN_SIZE("CHANGE_MEMORY_BALLOON", sizeof(VBoxGuestChangeBalloonInfo));
- rc = vbgdIoCtl_ChangeMemoryBalloon(pDevExt, pSession, (VBoxGuestChangeBalloonInfo *)pvData, pcbDataReturned);
+ rc = vgdrvIoCtl_ChangeMemoryBalloon(pDevExt, pSession, (VBoxGuestChangeBalloonInfo *)pvData, pcbDataReturned);
break;
case VBOXGUEST_IOCTL_WRITE_CORE_DUMP:
CHECKRET_MIN_SIZE("WRITE_CORE_DUMP", sizeof(VBoxGuestWriteCoreDump));
- rc = vbgdIoCtl_WriteCoreDump(pDevExt, (VBoxGuestWriteCoreDump *)pvData);
+ rc = vgdrvIoCtl_WriteCoreDump(pDevExt, (VBoxGuestWriteCoreDump *)pvData);
break;
case VBOXGUEST_IOCTL_SET_MOUSE_STATUS:
CHECKRET_SIZE("SET_MOUSE_STATUS", sizeof(uint32_t));
- rc = vbgdIoCtl_SetMouseStatus(pDevExt, pSession, *(uint32_t *)pvData);
+ rc = vgdrvIoCtl_SetMouseStatus(pDevExt, pSession, *(uint32_t *)pvData);
break;
#ifdef VBOX_WITH_DPC_LATENCY_CHECKER
case VBOXGUEST_IOCTL_DPC_LATENCY_CHECKER:
CHECKRET_SIZE("DPC_LATENCY_CHECKER", 0);
- rc = VbgdNtIOCtl_DpcLatencyChecker();
+ rc = VGDrvNtIOCtl_DpcLatencyChecker();
break;
#endif
case VBOXGUEST_IOCTL_GUEST_CAPS_ACQUIRE:
CHECKRET_SIZE("GUEST_CAPS_ACQUIRE", sizeof(VBoxGuestCapsAquire));
- rc = vbgdIoCtl_GuestCapsAcquire(pDevExt, pSession, (VBoxGuestCapsAquire *)pvData);
+ rc = vgdrvIoCtl_GuestCapsAcquire(pDevExt, pSession, (VBoxGuestCapsAquire *)pvData);
*pcbDataReturned = sizeof(VBoxGuestCapsAquire);
break;
case VBOXGUEST_IOCTL_SET_GUEST_CAPABILITIES:
CHECKRET_MIN_SIZE("SET_GUEST_CAPABILITIES", sizeof(VBoxGuestSetCapabilitiesInfo));
- rc = vbgdIoCtl_SetCapabilities(pDevExt, pSession, (VBoxGuestSetCapabilitiesInfo *)pvData);
+ rc = vgdrvIoCtl_SetCapabilities(pDevExt, pSession, (VBoxGuestSetCapabilitiesInfo *)pvData);
break;
default:
{
- LogRel(("VbgdCommonIoCtl: Unknown request iFunction=%#x stripped size=%#x\n",
+ LogRel(("VGDrvCommonIoCtl: Unknown request iFunction=%#x stripped size=%#x\n",
iFunction, VBOXGUEST_IOCTL_STRIP_SIZE(iFunction)));
rc = VERR_NOT_SUPPORTED;
break;
}
}
- LogFlow(("VbgdCommonIoCtl: returns %Rrc *pcbDataReturned=%zu\n", rc, pcbDataReturned ? *pcbDataReturned : 0));
+ LogFlow(("VGDrvCommonIoCtl: returns %Rrc *pcbDataReturned=%zu\n", rc, pcbDataReturned ? *pcbDataReturned : 0));
return rc;
}
/**
- * Used by VbgdCommonISR as well as the acquire guest capability code.
+ * Used by VGDrvCommonISR as well as the acquire guest capability code.
*
* @returns VINF_SUCCESS on success. On failure, ORed together
* RTSemEventMultiSignal errors (completes processing despite errors).
* @param pDevExt The VBoxGuest device extension.
* @param fEvents The events to dispatch.
*/
-static int vbgdDispatchEventsLocked(PVBOXGUESTDEVEXT pDevExt, uint32_t fEvents)
+static int vgdrvDispatchEventsLocked(PVBOXGUESTDEVEXT pDevExt, uint32_t fEvents)
{
PVBOXGUESTWAIT pWait;
PVBOXGUESTWAIT pSafe;
/* Does this one wait on any of the events we're dispatching? We do a quick
check first, then deal with VBOXGUEST_ACQUIRE_STYLE_EVENTS as applicable. */
if (fHandledEvents & VBOXGUEST_ACQUIRE_STYLE_EVENTS)
- fHandledEvents &= vbgdGetAllowedEventMaskForSession(pDevExt, pWait->pSession);
+ fHandledEvents &= vgdrvGetAllowedEventMaskForSession(pDevExt, pWait->pSession);
if (fHandledEvents)
{
pWait->fResEvents = pWait->fReqEvents & fEvents & fHandledEvents;
* @returns true if it was our interrupt, false if it wasn't.
* @param pDevExt The VBoxGuest device extension.
*/
-bool VbgdCommonISR(PVBOXGUESTDEVEXT pDevExt)
+bool VGDrvCommonISR(PVBOXGUESTDEVEXT pDevExt)
{
VMMDevEvents volatile *pReq = pDevExt->pIrqAckEvents;
bool fMousePositionChanged = false;
{
uint32_t fEvents = pReq->events;
- Log3(("VbgdCommonISR: acknowledge events succeeded %#RX32\n", fEvents));
+ Log3(("VGDrvCommonISR: acknowledge events succeeded %#RX32\n", fEvents));
/*
* VMMDEV_EVENT_MOUSE_POSITION_CHANGED can only be polled for.
/*
* Normal FIFO waiter evaluation.
*/
- rc |= vbgdDispatchEventsLocked(pDevExt, fEvents);
+ rc |= vgdrvDispatchEventsLocked(pDevExt, fEvents);
}
else /* something is serious wrong... */
- Log(("VbgdCommonISR: acknowledge events failed rc=%Rrc (events=%#x)!!\n",
+ Log(("VGDrvCommonISR: acknowledge events failed rc=%Rrc (events=%#x)!!\n",
pReq->header.rc, pReq->events));
}
else
- Log3(("VbgdCommonISR: not ours\n"));
+ Log3(("VGDrvCommonISR: not ours\n"));
RTSpinlockRelease(pDevExt->EventSpinlock);
* Note. On Windows this isn't possible at this IRQL, so a DPC will take
* care of it. Same on darwin, doing it in the work loop callback.
*/
- VbgdCommonWaitDoWakeUps(pDevExt);
+ VGDrvCommonWaitDoWakeUps(pDevExt);
#endif
/*
if (fMousePositionChanged)
{
ASMAtomicIncU32(&pDevExt->u32MousePosChangedSeq);
- VbgdNativeISRMousePollEvent(pDevExt);
+ VGDrvNativeISRMousePollEvent(pDevExt);
}
Assert(rc == 0);
-/* $Rev: 98751 $ */
+/* $Rev: 103598 $ */
/** @file
* VBoxGuest - Inter Driver Communication, unix implementation.
*
mutex_exit(&g_LdiMtx);
#endif
- rc = VbgdCommonCreateKernelSession(&g_DevExt, &pSession);
+ rc = VGDrvCommonCreateKernelSession(&g_DevExt, &pSession);
if (RT_SUCCESS(rc))
{
*pu32Version = VMMDEV_VERSION;
mutex_exit(&g_LdiMtx);
#endif
- LogRel(("VBoxGuestIDCOpen: VbgdCommonCreateKernelSession failed. rc=%d\n", rc));
+ LogRel(("VBoxGuestIDCOpen: VGDrvCommonCreateKernelSession failed. rc=%d\n", rc));
return NULL;
}
* Close an IDC connection.
*
* @returns VBox error code.
- * @param pvState Opaque pointer to the session object.
+ * @param pvSession Opaque pointer to the session object.
*/
DECLEXPORT(int) VBOXCALL VBoxGuestIDCClose(void *pvSession)
{
PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;
- LogFlow(("VBoxGuestIDCClose:\n"));
+ LogFlow(("VBoxGuestIDCClose: pvSession=%p\n", pvSession));
AssertPtrReturn(pSession, VERR_INVALID_POINTER);
- VbgdCommonCloseSession(&g_DevExt, pSession);
+ VGDrvCommonCloseSession(&g_DevExt, pSession);
#ifdef RT_OS_SOLARIS
mutex_enter(&g_LdiMtx);
LogFlow(("VBoxGuestIDCCall: %pvSession=%p Cmd=%u pvData=%p cbData=%d\n", pvSession, iCmd, pvData, cbData));
AssertPtrReturn(pSession, VERR_INVALID_POINTER);
- AssertMsgReturn(pSession->pDevExt == &g_DevExt,
- ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE);
+ AssertMsgReturn(pSession->pDevExt == &g_DevExt, ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE);
- return VbgdCommonIoCtl(iCmd, &g_DevExt, pSession, pvData, cbData, pcbDataReturned);
+ return VGDrvCommonIoCtl(iCmd, &g_DevExt, pSession, pvData, cbData, pcbDataReturned);
}
/* $Id: VBoxGuestInternal.h $ */
/** @file
- * VBoxGuest - Guest Additions Driver.
+ * VBoxGuest - Guest Additions Driver, Internal Header.
*/
/*
#include <VBox/VBoxGuest.h>
#include <VBox/VBoxGuestLib.h>
-/** @def VBOXGUEST_USE_WAKE_UP_LIST
+/** @def VBOXGUEST_USE_DEFERRED_WAKE_UP
* Defer wake-up of waiting thread when defined. */
#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) || defined(DOXYGEN_RUNNING)
# define VBOXGUEST_USE_DEFERRED_WAKE_UP
/** The events we received. */
uint32_t volatile fResEvents;
#ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP
- /** Set by VbgdCommonWaitDoWakeUps before leaving the spinlock to call
+ /** Set by VGDrvCommonWaitDoWakeUps before leaving the spinlock to call
* RTSemEventMultiSignal. */
bool volatile fPendingWakeUp;
/** Set by the requestor thread if it got the spinlock before the
- * signaller. Deals with the race in VbgdCommonWaitDoWakeUps. */
+ * signaller. Deals with the race in VGDrvCommonWaitDoWakeUps. */
bool volatile fFreeMe;
#endif
/** The event semaphore. */
*/
typedef struct VBOXGUESTMEMBALLOON
{
- /** Mutex protecting the members below from concurrent access.. */
+ /** Mutex protecting the members below from concurrent access. */
RTSEMFASTMUTEX hMtx;
/** The current number of chunks in the balloon. */
uint32_t cChunks;
RT_C_DECLS_BEGIN
-int VbgdCommonInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, void *pvMMIOBase, uint32_t cbMMIO,
- VBOXOSTYPE enmOSType, uint32_t fEvents);
-bool VbgdCommonISR(PVBOXGUESTDEVEXT pDevExt);
-void VbgdCommonDeleteDevExt(PVBOXGUESTDEVEXT pDevExt);
-int VbgdCommonReinitDevExtAfterHibernation(PVBOXGUESTDEVEXT pDevExt, VBOXOSTYPE enmOSType);
+int VGDrvCommonInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, void *pvMMIOBase, uint32_t cbMMIO,
+ VBOXOSTYPE enmOSType, uint32_t fEvents);
+bool VGDrvCommonISR(PVBOXGUESTDEVEXT pDevExt);
+void VGDrvCommonDeleteDevExt(PVBOXGUESTDEVEXT pDevExt);
+int VGDrvCommonReinitDevExtAfterHibernation(PVBOXGUESTDEVEXT pDevExt, VBOXOSTYPE enmOSType);
#ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP
-void VbgdCommonWaitDoWakeUps(PVBOXGUESTDEVEXT pDevExt);
+void VGDrvCommonWaitDoWakeUps(PVBOXGUESTDEVEXT pDevExt);
#endif
-int VbgdCommonCreateUserSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession);
-int VbgdCommonCreateKernelSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession);
-void VbgdCommonCloseSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
+int VGDrvCommonCreateUserSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession);
+int VGDrvCommonCreateKernelSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession);
+void VGDrvCommonCloseSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
-int VbgdCommonIoCtlFast(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
-int VbgdCommonIoCtl(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
- void *pvData, size_t cbData, size_t *pcbDataReturned);
+int VGDrvCommonIoCtlFast(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
+int VGDrvCommonIoCtl(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
+ void *pvData, size_t cbData, size_t *pcbDataReturned);
/**
* ISR callback for notifying threads polling for mouse events.
*
* @param pDevExt The device extension.
*/
-void VbgdNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt);
+void VGDrvNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt);
#ifdef VBOX_WITH_DPC_LATENCY_CHECKER
-int VbgdNtIOCtl_DpcLatencyChecker(void);
+int VGDrvNtIOCtl_DpcLatencyChecker(void);
#endif
RT_C_DECLS_END
#include "VBGLInternal.h"
-DECLVBGL(int) VbglQueryVMMDevMemory (VMMDevMemory **ppVMMDevMemory)
+DECLVBGL(int) VbglQueryVMMDevMemory(VMMDevMemory **ppVMMDevMemory)
{
- int rc = vbglR0Enter ();
-
+ int rc = vbglR0Enter();
if (RT_FAILURE(rc))
return rc;
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#ifndef RTMEM_NO_WRAP_TO_EF_APIS
# define RTMEM_NO_WRAP_TO_EF_APIS
#endif
-RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW
+RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW_DEF
{
void *pvDst = RTMemAllocTag(cb, pszTag);
if (pvDst)
RT_EXPORT_SYMBOL(RTMemDupTag);
-RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW
+RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW_DEF
{
void *pvDst = RTMemAllocTag(cbSrc + cbExtra, pszTag);
if (pvDst)
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_DEFAULT
#include <iprt/heap.h>
#include "internal/iprt.h"
#include "internal/magics.h"
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/** Pointer to the heap anchor block. */
typedef struct RTHEAPSIMPLEINTERNAL *PRTHEAPSIMPLEINTERNAL;
/** Pointer to a heap block. */
#define RTHEAPSIMPLE_ALIGNMENT (sizeof(RTHEAPSIMPLEBLOCK))
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
#ifdef RT_STRICT
# define RTHEAPSIMPLE_STRICT 1
#endif
} while (0)
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
#ifdef RTHEAPSIMPLE_STRICT
static void rtHeapSimpleAssertAll(PRTHEAPSIMPLEINTERNAL pHeapInt);
#endif
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/err.h>
#include "internal/iprt.h"
case EINVAL: return VERR_INVALID_PARAMETER;
#endif
#ifdef ENFILE
- case ENFILE: return VERR_TOO_MANY_OPEN_FILES; /**@Todo fix duplicate error */
+ case ENFILE: return VERR_TOO_MANY_OPEN_FILES; /** @todo fix duplicate error */
#endif
#ifdef EMFILE
case EMFILE: return VERR_TOO_MANY_OPEN_FILES;
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/err.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/log.h>
#include "internal/iprt.h"
#endif
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
/** @def RTLOG_RINGBUF_DEFAULT_SIZE
* The default ring buffer size. */
/** @def RTLOG_RINGBUF_MAX_SIZE
AssertCompile(sizeof(RTLOG_RINGBUF_EYE_CATCHER_END) == 16);
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Arguments passed to the output function.
*/
#endif /* !IN_RC */
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
#ifndef IN_RC
static unsigned rtlogGroupFlags(const char *psz);
#endif
#endif
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
#ifdef IN_RC
/** Default logger instance. Make it weak because our RC module loader does not
* necessarily resolve this symbol and the compiler _must_ check if this is
* vprintf like function for writing to the default log.
*
* @param pszFormat Printf like format string.
- * @param args Optional arguments as specified in pszFormat.
+ * @param va Optional arguments as specified in pszFormat.
*
* @remark The API doesn't support formatting of floating point numbers at the moment.
*/
-RTDECL(void) RTLogPrintfV(const char *pszFormat, va_list args)
+RTDECL(void) RTLogPrintfV(const char *pszFormat, va_list va)
{
- RTLogLoggerV(NULL, pszFormat, args);
+ RTLogLoggerV(NULL, pszFormat, va);
}
RT_EXPORT_SYMBOL(RTLogPrintfV);
* Used by the rtlogFlush() function as well as RTLogCreateExV.
*
* @param pLogger The logger instance to update. NULL is not allowed!
- * @param uTimeSlit Current time slot (for tikme based rotation).
+ * @param uTimeSlot Current time slot (for tikme based rotation).
* @param fFirst Flag whether this is the beginning of logging, i.e.
* called from RTLogCreateExV. Prevents pfnPhase from
* being called.
*/
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
#ifndef IPRT_UART_BASE
/** The port address of the COM port to log to.
*
#endif
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/log.h>
#include "internal/iprt.h"
#include <iprt/string.h>
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
static DECLCALLBACK(size_t) rtLogComOutput(void *pv, const char *pachChars, size_t cbChars);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/log.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/log.h>
#include "internal/iprt.h"
#include <iprt/string.h>
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
static DECLCALLBACK(size_t) rtlogFormatStr(void *pvArg, PFNRTSTROUTPUT pfnOutput,
void *pvArgOutput, const char **ppszFormat,
va_list *pArgs, int cchWidth, int cchPrecision,
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/log.h>
#include "internal/iprt.h"
#endif
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
#ifdef IN_RC
/** Default release logger instance. */
extern "C" DECLIMPORT(RTLOGGERRC) g_RelLogger;
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/log.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/assert.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/assert.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/assert.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/assert.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/assert.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/assert.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/assert.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/assert.h>
#include "internal/iprt.h"
#include "internal/assert.h"
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** The last assert message, 1st part. */
RTDATADECL(char) g_szRTAssertMsg1[1024];
RT_EXPORT_SYMBOL(g_szRTAssertMsg1);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_THREAD
#include <iprt/thread.h>
#include "internal/iprt.h"
#endif
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
#ifdef IN_RING0
# define RT_THREAD_LOCK_RW() RTSpinlockAcquire(g_ThreadSpinlock)
# define RT_THREAD_UNLOCK_RW() RTSpinlockRelease(g_ThreadSpinlock)
#endif
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** The AVL thread containing the threads. */
static PAVLPVNODECORE g_ThreadTree;
/** The number of threads in the tree (for ring-0 termination kludge). */
static bool g_frtThreadInitialized;
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
static void rtThreadDestroy(PRTTHREADINT pThread);
#ifdef IN_RING3
static int rtThreadAdopt(RTTHREADTYPE enmType, unsigned fFlags, uint32_t fIntFlags, const char *pszName);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/string.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/string.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/string.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Defined Constants *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants *
+*********************************************************************************************************************************/
#define ISDIGIT(c) ((c) >= '0' && (c) <= '9')
/*#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b)) */
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_STRING
#include <iprt/string.h>
#include "internal/iprt.h"
} KSIZE64;
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
static unsigned _strnlen(const char *psz, unsigned cchMax);
static unsigned _strnlenUtf16(PCRTUTF16 pwsz, unsigned cchMax);
static int rtStrFormatNumber(char *psz, KSIZE64 ullValue, unsigned int uiBase, signed int cchWidth, signed int cchPrecision, unsigned int fFlags);
cchWidth -= cchStr;
while (cchStr-- > 0)
{
-/**@todo #ifndef IN_RC*/
+/**@todo \#ifndef IN_RC*/
#ifdef IN_RING3
RTUNICP Cp;
RTUtf16GetCpEx(&pwszStr, &Cp);
cchWidth -= cchStr;
while (cchStr-- > 0)
{
-/**@todo #ifndef IN_RC*/
+/**@todo \#ifndef IN_RC*/
#ifdef IN_RING3
char szUtf8[8]; /* Cp=0x7fffffff -> 6 bytes. */
char *pszEnd = RTStrPutCp(szUtf8, *puszStr++);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_STRING
#include <iprt/string.h>
#ifndef RT_NO_EXPORT_SYMBOL
#endif
#include "internal/string.h"
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
static char g_szHexDigits[17] = "0123456789abcdef";
*/
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_STRING
#include <iprt/string.h>
#include "internal/iprt.h"
#include "internal/string.h"
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
#ifdef RT_STRICT
# define RTSTRFORMATTYPE_WITH_LOCKING
#endif
#endif
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/**
* Description of a registered formatting type.
*
typedef RTSTRDYNFMT const *PCRTSTRDYNFMT;
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** The registered types, sorted for binary lookup.
* We use a static array here because it avoids RTMemAlloc dependencies+leaks. */
static RTSTRDYNFMT g_aTypes[64];
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/string.h>
#include "internal/iprt.h"
#include <iprt/assert.h>
-/*******************************************************************************
-* Structures and Typedefs *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
/** strbufoutput() argument structure. */
typedef struct STRBUFARG
{
typedef STRBUFARG *PSTRBUFARG;
-/*******************************************************************************
-* Internal Functions *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Internal Functions *
+*********************************************************************************************************************************/
static DECLCALLBACK(size_t) strbufoutput(void *pvArg, const char *pachChars, size_t cbChars);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/string.h>
#include "internal/iprt.h"
#include <iprt/err.h>
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** 8-bit char -> digit. */
static const unsigned char g_auchDigits[256] =
{
static const char szFileId[] = "Id: kAVLPVInt.c,v 1.5 2003/02/13 02:02:35 bird Exp $";
#endif
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
/*
* AVL configuration.
*/
#define KAVL_NE(key1, key2) ( (const char*)(key1) != (const char*)(key2) )
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/avl.h>
#include <iprt/assert.h>
#include <iprt/err.h>
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_TIME
#include <iprt/time.h>
#include "internal/iprt.h"
#include "internal/time.h"
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
/** The max year we possibly could implode. */
#define RTTIME_MAX_YEAR (292 + 1970)
/** The min year we possibly could implode. */
#define RTTIME_MIN_DAY_NANO ( INT64_C(1000000000) * (00*3600 + 12*60 + 43) + 145224192 )
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/**
* Days per month in a common year.
*/
offUTCHour = -offUTCHour;
}
cch = RTStrPrintf(psz, cb,
- "%RI32-%02u-%02uT%02u:%02u:%02u.%09RU32%c%02%02",
+ "%RI32-%02u-%02uT%02u:%02u:%02u.%09RU32%c%02d%02d",
pTime->i32Year, pTime->u8Month, pTime->u8MonthDay,
pTime->u8Hour, pTime->u8Minute, pTime->u8Second, pTime->u32Nanosecond,
chSign, offUTCHour, offUTCMinute);
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/assert.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/log.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/log.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/mp.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_SEM
#define RTSEMEVENTMULTI_WITHOUT_REMAPPING
#include <iprt/semaphore.h>
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_SEM
#define RTSEMEVENTMULTI_WITHOUT_REMAPPING
#include <iprt/semaphore.h>
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_SEM
#define RTSEMEVENT_WITHOUT_REMAPPING
#include <iprt/semaphore.h>
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_SEM
#define RTSEMEVENT_WITHOUT_REMAPPING
#include <iprt/semaphore.h>
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/err.h>
#include "internal/iprt.h"
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#include <iprt/mp.h>
#include "internal/iprt.h"
#define VBOX_VENDOR_SHORT "Oracle"
#define VBOX_PRODUCT "Oracle VM VirtualBox"
#define VBOX_BUILD_PUBLISHER "_Ubuntu"
-#define VBOX_C_YEAR "2015"
+#define VBOX_C_YEAR "2016"
#endif
-#define VBOX_SVN_REV 101573
+#define VBOX_SVN_REV 105127
#define VBOX_VERSION_MAJOR 5
#define VBOX_VERSION_MINOR 0
-#define VBOX_VERSION_BUILD 0
-#define VBOX_VERSION_STRING_RAW "5.0.0"
-#define VBOX_VERSION_STRING "5.0.0_Ubuntu"
+#define VBOX_VERSION_BUILD 14
+#define VBOX_VERSION_STRING_RAW "5.0.14"
+#define VBOX_VERSION_STRING "5.0.14_Ubuntu"
#define VBOX_API_VERSION_STRING "5_0"
#define VBOX_PRIVATE_BUILD_DESC "Private build by root"
#include <iprt/assert.h>
#include <iprt/string.h>
-DECLVBGL(int) VbglGRVerify (const VMMDevRequestHeader *pReq, size_t cbReq)
+
+DECLVBGL(int) VbglGRVerify(const VMMDevRequestHeader *pReq, size_t cbReq)
{
size_t cbReqExpected;
- if (!pReq || cbReq < sizeof (VMMDevRequestHeader))
+ if (RT_UNLIKELY(!pReq || cbReq < sizeof(VMMDevRequestHeader)))
{
dprintf(("VbglGRVerify: Invalid parameter: pReq = %p, cbReq = %zu\n", pReq, cbReq));
return VERR_INVALID_PARAMETER;
}
- if (pReq->size > cbReq)
+ if (RT_UNLIKELY(pReq->size > cbReq))
{
dprintf(("VbglGRVerify: request size %u > buffer size %zu\n", pReq->size, cbReq));
return VERR_INVALID_PARAMETER;
/* The request size must correspond to the request type. */
cbReqExpected = vmmdevGetRequestSize(pReq->requestType);
-
- if (cbReq < cbReqExpected)
+ if (RT_UNLIKELY(cbReq < cbReqExpected))
{
dprintf(("VbglGRVerify: buffer size %zu < expected size %zu\n", cbReq, cbReqExpected));
return VERR_INVALID_PARAMETER;
if (cbReqExpected == cbReq)
{
- /* This is most likely a fixed size request, and in this case the request size
- * must be also equal to the expected size.
+ /*
+ * This is most likely a fixed size request, and in this case the
+ * request size must be also equal to the expected size.
*/
- if (pReq->size != cbReqExpected)
+ if (RT_UNLIKELY(pReq->size != cbReqExpected))
{
dprintf(("VbglGRVerify: request size %u != expected size %zu\n", pReq->size, cbReqExpected));
return VERR_INVALID_PARAMETER;
|| pReq->requestType == VMMDevReq_HGCMCall64
#else
|| pReq->requestType == VMMDevReq_HGCMCall
-#endif /* VBOX_WITH_64_BITS_GUESTS */
+#endif
|| pReq->requestType == VMMDevReq_RegisterSharedModule
|| pReq->requestType == VMMDevReq_ReportGuestUserState
|| pReq->requestType == VMMDevReq_LogString
|| pReq->requestType == VMMDevReq_SetPointerShape
|| pReq->requestType == VMMDevReq_VideoSetVisibleRegion)
{
- if (cbReq > VMMDEV_MAX_VMMDEVREQ_SIZE)
+ if (RT_UNLIKELY(cbReq > VMMDEV_MAX_VMMDEVREQ_SIZE))
{
dprintf(("VbglGRVerify: VMMDevReq_LogString: buffer size %zu too big\n", cbReq));
- return VERR_BUFFER_OVERFLOW; /* @todo is this error code ok? */
+ return VERR_BUFFER_OVERFLOW; /** @todo is this error code ok? */
}
}
else
{
dprintf(("VbglGRVerify: request size %u > buffer size %zu\n", pReq->size, cbReq));
- return VERR_IO_BAD_LENGTH; /* @todo is this error code ok? */
+ return VERR_IO_BAD_LENGTH; /** @todo is this error code ok? */
}
return VINF_SUCCESS;
}
-DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType)
+DECLVBGL(int) VbglGRAlloc(VMMDevRequestHeader **ppReq, size_t cbReq, VMMDevRequestType enmReqType)
{
- VMMDevRequestHeader *pReq;
- int rc = vbglR0Enter ();
-
- if (RT_FAILURE(rc))
- return rc;
-
- if (!ppReq || cbSize < sizeof (VMMDevRequestHeader))
- {
- dprintf(("VbglGRAlloc: Invalid parameter: ppReq = %p, cbSize = %u\n", ppReq, cbSize));
- return VERR_INVALID_PARAMETER;
- }
-
- pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc (cbSize);
- if (!pReq)
+ int rc = vbglR0Enter();
+ if (RT_SUCCESS(rc))
{
- AssertMsgFailed(("VbglGRAlloc: no memory\n"));
- rc = VERR_NO_MEMORY;
- }
- else
- {
- memset(pReq, 0xAA, cbSize);
-
- pReq->size = cbSize;
- pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
- pReq->requestType = reqType;
- pReq->rc = VERR_GENERAL_FAILURE;
- pReq->reserved1 = 0;
- pReq->reserved2 = 0;
-
- *ppReq = pReq;
+ if ( ppReq
+ && cbReq >= sizeof(VMMDevRequestHeader)
+ && cbReq == (uint32_t)cbReq)
+ {
+ VMMDevRequestHeader *pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc((uint32_t)cbReq);
+ AssertMsgReturn(pReq, ("VbglGRAlloc: no memory (cbReq=%u)\n", cbReq), VERR_NO_MEMORY);
+ memset(pReq, 0xAA, cbReq);
+
+ pReq->size = (uint32_t)cbReq;
+ pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
+ pReq->requestType = enmReqType;
+ pReq->rc = VERR_GENERAL_FAILURE;
+ pReq->reserved1 = 0;
+ pReq->reserved2 = 0;
+
+ *ppReq = pReq;
+ rc = VINF_SUCCESS;
+ }
+ else
+ {
+ dprintf(("VbglGRAlloc: Invalid parameter: ppReq=%p cbReq=%u\n", ppReq, cbReq));
+ rc = VERR_INVALID_PARAMETER;
+ }
}
-
return rc;
}
-DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq)
+DECLVBGL(int) VbglGRPerform(VMMDevRequestHeader *pReq)
{
- RTCCPHYS physaddr;
- int rc = vbglR0Enter ();
-
- if (RT_FAILURE(rc))
- return rc;
-
- if (!pReq)
- return VERR_INVALID_PARAMETER;
-
- physaddr = VbglPhysHeapGetPhysAddr (pReq);
- if ( !physaddr
- || (physaddr >> 32) != 0) /* Port IO is 32 bit. */
+ int rc = vbglR0Enter();
+ if (RT_SUCCESS(rc))
{
- rc = VERR_VBGL_INVALID_ADDR;
- }
- else
- {
- ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)physaddr);
- /* Make the compiler aware that the host has changed memory. */
- ASMCompilerBarrier();
- rc = pReq->rc;
+ if (pReq)
+ {
+ RTCCPHYS PhysAddr = VbglPhysHeapGetPhysAddr(pReq);
+ if ( PhysAddr != 0
+ && PhysAddr < _4G) /* Port IO is 32 bit. */
+ {
+ ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)PhysAddr);
+ /* Make the compiler aware that the host has changed memory. */
+ ASMCompilerBarrier();
+ rc = pReq->rc;
+ }
+ else
+ rc = VERR_VBGL_INVALID_ADDR;
+ }
+ else
+ rc = VERR_INVALID_PARAMETER;
}
return rc;
}
-DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq)
+DECLVBGL(void) VbglGRFree(VMMDevRequestHeader *pReq)
{
- int rc = vbglR0Enter ();
-
- if (RT_FAILURE(rc))
- return;
-
- VbglPhysHeapFree (pReq);
+ int rc = vbglR0Enter();
+ if (RT_SUCCESS(rc))
+ VbglPhysHeapFree(pReq);
}
#include <iprt/semaphore.h>
#include <iprt/string.h>
-#define VBGL_HGCM_ASSERTMsg AssertReleaseMsg
+#define VBGL_HGCM_ASSERT_MSG AssertReleaseMsg
/**
* Initializes the HGCM VBGL bits.
*
* @return VBox status code.
*/
-int vbglR0HGCMInit (void)
+int vbglR0HGCMInit(void)
{
return RTSemFastMutexCreate(&g_vbgldata.mutexHGCMHandle);
}
*
* @return VBox status code.
*/
-int vbglR0HGCMTerminate (void)
+int vbglR0HGCMTerminate(void)
{
RTSemFastMutexDestroy(g_vbgldata.mutexHGCMHandle);
g_vbgldata.mutexHGCMHandle = NIL_RTSEMFASTMUTEX;
return VINF_SUCCESS;
}
-DECLINLINE(int) vbglHandleHeapEnter (void)
+DECLINLINE(int) vbglHandleHeapEnter(void)
{
int rc = RTSemFastMutexRequest(g_vbgldata.mutexHGCMHandle);
- VBGL_HGCM_ASSERTMsg(RT_SUCCESS(rc),
- ("Failed to request handle heap mutex, rc = %Rrc\n", rc));
+ VBGL_HGCM_ASSERT_MSG(RT_SUCCESS(rc), ("Failed to request handle heap mutex, rc = %Rrc\n", rc));
return rc;
}
-DECLINLINE(void) vbglHandleHeapLeave (void)
+DECLINLINE(void) vbglHandleHeapLeave(void)
{
RTSemFastMutexRelease(g_vbgldata.mutexHGCMHandle);
}
-struct VBGLHGCMHANDLEDATA *vbglHGCMHandleAlloc (void)
+struct VBGLHGCMHANDLEDATA *vbglHGCMHandleAlloc(void)
{
- struct VBGLHGCMHANDLEDATA *p;
- int rc = vbglHandleHeapEnter ();
- uint32_t i;
-
- if (RT_FAILURE (rc))
- return NULL;
-
- p = NULL;
-
- /** Simple linear search in array. This will be called not so often, only connect/disconnect.
- * @todo bitmap for faster search and other obvious optimizations.
- */
-
- for (i = 0; i < RT_ELEMENTS(g_vbgldata.aHGCMHandleData); i++)
+ struct VBGLHGCMHANDLEDATA *p = NULL;
+ int rc = vbglHandleHeapEnter();
+ if (RT_SUCCESS(rc))
{
- if (!g_vbgldata.aHGCMHandleData[i].fAllocated)
+ uint32_t i;
+
+ /* Simple linear search in array. This will be called not so often, only connect/disconnect. */
+ /** @todo bitmap for faster search and other obvious optimizations. */
+ for (i = 0; i < RT_ELEMENTS(g_vbgldata.aHGCMHandleData); i++)
{
- p = &g_vbgldata.aHGCMHandleData[i];
- p->fAllocated = 1;
- break;
+ if (!g_vbgldata.aHGCMHandleData[i].fAllocated)
+ {
+ p = &g_vbgldata.aHGCMHandleData[i];
+ p->fAllocated = 1;
+ break;
+ }
}
- }
- vbglHandleHeapLeave ();
-
- VBGL_HGCM_ASSERTMsg(p != NULL,
- ("Not enough HGCM handles.\n"));
+ vbglHandleHeapLeave();
+ VBGL_HGCM_ASSERT_MSG(p != NULL, ("Not enough HGCM handles.\n"));
+ }
return p;
}
-void vbglHGCMHandleFree (struct VBGLHGCMHANDLEDATA *pHandle)
+void vbglHGCMHandleFree(struct VBGLHGCMHANDLEDATA *pHandle)
{
- int rc;
-
- if (!pHandle)
- return;
-
- rc = vbglHandleHeapEnter ();
-
- if (RT_FAILURE (rc))
- return;
-
- VBGL_HGCM_ASSERTMsg(pHandle->fAllocated,
- ("Freeing not allocated handle.\n"));
+ if (pHandle)
+ {
+ int rc = vbglHandleHeapEnter();
+ if (RT_SUCCESS(rc))
+ {
+ VBGL_HGCM_ASSERT_MSG(pHandle->fAllocated, ("Freeing not allocated handle.\n"));
- memset(pHandle, 0, sizeof (struct VBGLHGCMHANDLEDATA));
- vbglHandleHeapLeave ();
- return;
+ RT_ZERO(*pHandle);
+ vbglHandleHeapLeave();
+ }
+ }
}
-DECLVBGL(int) VbglHGCMConnect (VBGLHGCMHANDLE *pHandle, VBoxGuestHGCMConnectInfo *pData)
+DECLVBGL(int) VbglHGCMConnect(VBGLHGCMHANDLE *pHandle, VBoxGuestHGCMConnectInfo *pData)
{
int rc;
- struct VBGLHGCMHANDLEDATA *pHandleData;
-
- if (!pHandle || !pData)
- return VERR_INVALID_PARAMETER;
-
- pHandleData = vbglHGCMHandleAlloc();
- if (!pHandleData)
- rc = VERR_NO_MEMORY;
- else
+ if (pHandle && pData)
{
- rc = vbglDriverOpen (&pHandleData->driver);
- if (RT_SUCCESS(rc))
+ struct VBGLHGCMHANDLEDATA *pHandleData = vbglHGCMHandleAlloc();
+ if (pHandleData)
{
- rc = vbglDriverIOCtl (&pHandleData->driver, VBOXGUEST_IOCTL_HGCM_CONNECT, pData, sizeof (*pData));
- if (RT_SUCCESS(rc))
- rc = pData->result;
+ rc = vbglDriverOpen(&pHandleData->driver);
if (RT_SUCCESS(rc))
{
- *pHandle = pHandleData;
- return rc;
+ rc = vbglDriverIOCtl(&pHandleData->driver, VBOXGUEST_IOCTL_HGCM_CONNECT, pData, sizeof(*pData));
+ if (RT_SUCCESS(rc))
+ rc = pData->result;
+ if (RT_SUCCESS(rc))
+ {
+ *pHandle = pHandleData;
+ return rc;
+ }
+
+ vbglDriverClose(&pHandleData->driver);
}
- vbglDriverClose (&pHandleData->driver);
+ vbglHGCMHandleFree(pHandleData);
}
-
- vbglHGCMHandleFree (pHandleData);
+ else
+ rc = VERR_NO_MEMORY;
}
-
+ else
+ rc = VERR_INVALID_PARAMETER;
return rc;
}
-DECLVBGL(int) VbglHGCMDisconnect (VBGLHGCMHANDLE handle, VBoxGuestHGCMDisconnectInfo *pData)
+DECLVBGL(int) VbglHGCMDisconnect(VBGLHGCMHANDLE handle, VBoxGuestHGCMDisconnectInfo *pData)
{
- int rc = VINF_SUCCESS;
-
- rc = vbglDriverIOCtl (&handle->driver, VBOXGUEST_IOCTL_HGCM_DISCONNECT, pData, sizeof (*pData));
+ int rc = vbglDriverIOCtl(&handle->driver, VBOXGUEST_IOCTL_HGCM_DISCONNECT, pData, sizeof(*pData));
- vbglDriverClose (&handle->driver);
+ vbglDriverClose(&handle->driver);
- vbglHGCMHandleFree (handle);
+ vbglHGCMHandleFree(handle);
return rc;
}
-DECLVBGL(int) VbglHGCMCall (VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData)
+DECLVBGL(int) VbglHGCMCall(VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData)
{
- int rc = VINF_SUCCESS;
+ VBGL_HGCM_ASSERT_MSG(cbData >= sizeof(VBoxGuestHGCMCallInfo) + pData->cParms * sizeof(HGCMFunctionParameter),
+ ("cbData = %d, cParms = %d (calculated size %d)\n", cbData, pData->cParms,
+ sizeof(VBoxGuestHGCMCallInfo) + pData->cParms * sizeof(VBoxGuestHGCMCallInfo)));
- VBGL_HGCM_ASSERTMsg(cbData >= sizeof (VBoxGuestHGCMCallInfo) + pData->cParms * sizeof (HGCMFunctionParameter),
- ("cbData = %d, cParms = %d (calculated size %d)\n", cbData, pData->cParms, sizeof (VBoxGuestHGCMCallInfo) + pData->cParms * sizeof (VBoxGuestHGCMCallInfo)));
-
- rc = vbglDriverIOCtl (&handle->driver, VBOXGUEST_IOCTL_HGCM_CALL(cbData), pData, cbData);
-
- return rc;
+ return vbglDriverIOCtl(&handle->driver, VBOXGUEST_IOCTL_HGCM_CALL(cbData), pData, cbData);
}
DECLVBGL(int) VbglHGCMCallUserData (VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData)
{
- int rc = VINF_SUCCESS;
-
- VBGL_HGCM_ASSERTMsg(cbData >= sizeof (VBoxGuestHGCMCallInfo) + pData->cParms * sizeof (HGCMFunctionParameter),
- ("cbData = %d, cParms = %d (calculated size %d)\n", cbData, pData->cParms, sizeof (VBoxGuestHGCMCallInfo) + pData->cParms * sizeof (VBoxGuestHGCMCallInfo)));
-
- rc = vbglDriverIOCtl (&handle->driver, VBOXGUEST_IOCTL_HGCM_CALL_USERDATA(cbData), pData, cbData);
+ VBGL_HGCM_ASSERT_MSG(cbData >= sizeof(VBoxGuestHGCMCallInfo) + pData->cParms * sizeof(HGCMFunctionParameter),
+ ("cbData = %d, cParms = %d (calculated size %d)\n", cbData, pData->cParms,
+ sizeof(VBoxGuestHGCMCallInfo) + pData->cParms * sizeof(VBoxGuestHGCMCallInfo)));
- return rc;
+ return vbglDriverIOCtl(&handle->driver, VBOXGUEST_IOCTL_HGCM_CALL_USERDATA(cbData), pData, cbData);
}
-DECLVBGL(int) VbglHGCMCallTimed (VBGLHGCMHANDLE handle,
- VBoxGuestHGCMCallInfoTimed *pData, uint32_t cbData)
+DECLVBGL(int) VbglHGCMCallTimed(VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfoTimed *pData, uint32_t cbData)
{
- int rc = VINF_SUCCESS;
-
- uint32_t cbExpected = sizeof (VBoxGuestHGCMCallInfoTimed)
- + pData->info.cParms * sizeof (HGCMFunctionParameter);
- VBGL_HGCM_ASSERTMsg(cbData >= cbExpected,
- ("cbData = %d, cParms = %d (calculated size %d)\n",
- cbData, pData->info.cParms, cbExpected));
+ uint32_t cbExpected = sizeof(VBoxGuestHGCMCallInfoTimed)
+ + pData->info.cParms * sizeof(HGCMFunctionParameter);
+ VBGL_HGCM_ASSERT_MSG(cbData >= cbExpected,
+ ("cbData = %d, cParms = %d (calculated size %d)\n", cbData, pData->info.cParms, cbExpected));
+ NOREF(cbExpected);
- rc = vbglDriverIOCtl (&handle->driver, VBOXGUEST_IOCTL_HGCM_CALL_TIMED(cbData),
- pData, cbData);
-
- return rc;
+ return vbglDriverIOCtl(&handle->driver, VBOXGUEST_IOCTL_HGCM_CALL_TIMED(cbData), pData, cbData);
}
#endif /* !VBGL_VBOXGUEST */
* terms and conditions of either the GPL or the CDDL or both.
*/
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define VBGL_DECL_DATA
#include "VBGLInternal.h"
#include <iprt/assert.h>
#include <iprt/semaphore.h>
-/*******************************************************************************
-* Global Variables *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
/** The global VBGL instance data. */
VBGLDATA g_vbgldata;
{
dprintf (("port = 0x%04X, mem = %p\n", port.portAddress, port.pVMMDevMemory));
- g_vbgldata.portVMMDev = port.portAddress;
+ g_vbgldata.portVMMDev = (RTIOPORT)port.portAddress;
g_vbgldata.pVMMDevMemory = port.pVMMDevMemory;
g_vbgldata.status = VbglStatusReady;
#ifdef VBGL_VBOXGUEST
-DECLVBGL(int) VbglInit (VBGLIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory)
+DECLVBGL(int) VbglInitPrimary(RTIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory)
{
int rc = VINF_SUCCESS;
# ifdef RT_OS_WINDOWS /** @todo r=bird: this doesn't make sense. Is there something special going on on windows? */
dprintf(("vbglInit: starts g_vbgldata.status %d\n", g_vbgldata.status));
- if (g_vbgldata.status == VbglStatusInitializing
+ if ( g_vbgldata.status == VbglStatusInitializing
|| g_vbgldata.status == VbglStatusReady)
{
/* Initialization is already in process. */
#else /* !VBGL_VBOXGUEST */
-DECLVBGL(int) VbglInit (void)
+DECLVBGL(int) VbglInitClient(void)
{
int rc = VINF_SUCCESS;
- if (g_vbgldata.status == VbglStatusInitializing
+ if ( g_vbgldata.status == VbglStatusInitializing
|| g_vbgldata.status == VbglStatusReady)
{
/* Initialization is already in process. */
return physAddr;
}
-DECLVBGL(void) VbglPhysHeapFree (void *p)
+DECLVBGL(void) VbglPhysHeapFree(void *p)
{
VBGLPHYSHEAPBLOCK *pBlock;
VBGLPHYSHEAPBLOCK *pNeighbour;
* @param fWriteAccess Lock for read-write (true) or readonly (false).
* @param fFlags HGCM call flags, VBGLR0_HGCM_F_XXX.
*/
-int vbglLockLinear (void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess, uint32_t fFlags)
+int vbglLockLinear(void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess, uint32_t fFlags)
{
int rc = VINF_SUCCESS;
#ifndef RT_OS_WINDOWS
/** @todo just use IPRT here. the extra allocation shouldn't matter much...
* Then we can move all this up one level even. */
#ifdef RT_OS_WINDOWS
- PMDL pMdl = IoAllocateMdl (pv, u32Size, FALSE, FALSE, NULL);
+ PMDL pMdl = IoAllocateMdl(pv, u32Size, FALSE, FALSE, NULL);
if (pMdl == NULL)
{
{
__try {
/* Calls to MmProbeAndLockPages must be enclosed in a try/except block. */
- MmProbeAndLockPages (pMdl,
- /** @todo (fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER? UserMode: KernelMode */
- KernelMode,
- (fWriteAccess) ? IoModifyAccess : IoReadAccess);
+ MmProbeAndLockPages(pMdl,
+ /** @todo (fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER? UserMode: KernelMode */
+ KernelMode,
+ (fWriteAccess) ? IoModifyAccess : IoReadAccess);
*ppvCtx = pMdl;
} __except(EXCEPTION_EXECUTE_HANDLER) {
- IoFreeMdl (pMdl);
+ IoFreeMdl(pMdl);
/** @todo */
rc = VERR_INVALID_PARAMETER;
AssertMsgFailed(("MmProbeAndLockPages %p %x failed!!\n", pv, u32Size));
return rc;
}
-void vbglUnlockLinear (void *pvCtx, void *pv, uint32_t u32Size)
+void vbglUnlockLinear(void *pvCtx, void *pv, uint32_t u32Size)
{
#ifdef RT_OS_WINDOWS
PMDL pMdl = (PMDL)pvCtx;
Assert(pMdl);
if (pMdl != NULL)
{
- MmUnlockPages (pMdl);
- IoFreeMdl (pMdl);
+ MmUnlockPages(pMdl);
+ IoFreeMdl(pMdl);
}
#else
# if !defined(RT_OS_OS2) \
&& !defined(RT_OS_WINDOWS)
RT_C_DECLS_BEGIN
-extern DECLVBGL(void *) VBoxGuestIDCOpen (uint32_t *pu32Version);
-extern DECLVBGL(void) VBoxGuestIDCClose (void *pvOpaque);
-extern DECLVBGL(int) VBoxGuestIDCCall (void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn);
+extern DECLVBGL(void *) VBoxGuestIDCOpen(uint32_t *pu32Version);
+extern DECLVBGL(void) VBoxGuestIDCClose(void *pvOpaque);
+extern DECLVBGL(int) VBoxGuestIDCCall(void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn);
RT_C_DECLS_END
# endif
-bool vbglDriverIsOpened (VBGLDRIVER *pDriver)
+bool vbglDriverIsOpened(VBGLDRIVER *pDriver)
{
# ifdef RT_OS_WINDOWS
return pDriver->pFileObject != NULL;
# endif
}
-int vbglDriverOpen (VBGLDRIVER *pDriver)
+int vbglDriverOpen(VBGLDRIVER *pDriver)
{
# ifdef RT_OS_WINDOWS
UNICODE_STRING uszDeviceName;
- RtlInitUnicodeString (&uszDeviceName, L"\\Device\\VBoxGuest");
+ RtlInitUnicodeString(&uszDeviceName, L"\\Device\\VBoxGuest");
PDEVICE_OBJECT pDeviceObject = NULL;
PFILE_OBJECT pFileObject = NULL;
- NTSTATUS rc = IoGetDeviceObjectPointer (&uszDeviceName, FILE_ALL_ACCESS,
- &pFileObject, &pDeviceObject);
-
- if (NT_SUCCESS (rc))
+ NTSTATUS rc = IoGetDeviceObjectPointer(&uszDeviceName, FILE_ALL_ACCESS, &pFileObject, &pDeviceObject);
+ if (NT_SUCCESS(rc))
{
Log(("vbglDriverOpen VBoxGuest successful pDeviceObject=%x\n", pDeviceObject));
pDriver->pDeviceObject = pDeviceObject;
/*
* Just check whether the connection was made or not.
*/
- if ( g_VBoxGuestIDC.u32Version == VMMDEV_VERSION
- && VALID_PTR(g_VBoxGuestIDC.u32Session)
- && VALID_PTR(g_VBoxGuestIDC.pfnServiceEP))
+ if ( g_VBoxGuestIDC.u32Version == VMMDEV_VERSION
+ && RT_VALID_PTR(g_VBoxGuestIDC.u32Session)
+ && RT_VALID_PTR(g_VBoxGuestIDC.pfnServiceEP))
{
pDriver->u32Session = g_VBoxGuestIDC.u32Session;
return VINF_SUCCESS;
# else
uint32_t u32VMMDevVersion;
- pDriver->pvOpaque = VBoxGuestIDCOpen (&u32VMMDevVersion);
- if ( pDriver->pvOpaque
- && u32VMMDevVersion == VMMDEV_VERSION)
+ pDriver->pvOpaque = VBoxGuestIDCOpen(&u32VMMDevVersion);
+ if ( pDriver->pvOpaque
+ && u32VMMDevVersion == VMMDEV_VERSION)
return VINF_SUCCESS;
Log(("vbglDriverOpen: failed\n"));
}
# ifdef RT_OS_WINDOWS
-static NTSTATUS vbglDriverIOCtlCompletion (IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
+static NTSTATUS vbglDriverIOCtlCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
{
Log(("VBGL completion %x\n", Irp));
KEVENT *pEvent = (KEVENT *)Context;
- KeSetEvent (pEvent, IO_NO_INCREMENT, FALSE);
+ KeSetEvent(pEvent, IO_NO_INCREMENT, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}
# endif
-int vbglDriverIOCtl (VBGLDRIVER *pDriver, uint32_t u32Function, void *pvData, uint32_t cbData)
+int vbglDriverIOCtl(VBGLDRIVER *pDriver, uint32_t u32Function, void *pvData, uint32_t cbData)
{
Log(("vbglDriverIOCtl: pDriver: %p, Func: %x, pvData: %p, cbData: %d\n", pDriver, u32Function, pvData, cbData));
# ifdef RT_OS_WINDOWS
KEVENT Event;
- KeInitializeEvent (&Event, NotificationEvent, FALSE);
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
/* Have to use the IoAllocateIRP method because this code is generic and
* must work in any thread context.
* The IoBuildDeviceIoControlRequest, which was used here, does not work
* when APCs are disabled, for example.
*/
- PIRP irp = IoAllocateIrp (pDriver->pDeviceObject->StackSize, FALSE);
+ PIRP irp = IoAllocateIrp(pDriver->pDeviceObject->StackSize, FALSE);
Log(("vbglDriverIOCtl: irp %p, IRQL = %d\n", irp, KeGetCurrentIrql()));
* Setup the IRP_MJ_DEVICE_CONTROL IRP.
*/
- PIO_STACK_LOCATION nextStack = IoGetNextIrpStackLocation (irp);
+ PIO_STACK_LOCATION nextStack = IoGetNextIrpStackLocation(irp);
nextStack->MajorFunction = IRP_MJ_DEVICE_CONTROL;
nextStack->MinorFunction = 0;
irp->MdlAddress = NULL;
/* A completion routine is required to signal the Event. */
- IoSetCompletionRoutine (irp, vbglDriverIOCtlCompletion, &Event, TRUE, TRUE, TRUE);
+ IoSetCompletionRoutine(irp, vbglDriverIOCtlCompletion, &Event, TRUE, TRUE, TRUE);
- NTSTATUS rc = IoCallDriver (pDriver->pDeviceObject, irp);
+ NTSTATUS rc = IoCallDriver(pDriver->pDeviceObject, irp);
if (NT_SUCCESS (rc))
{
/* Wait the event to be signalled by the completion routine. */
- KeWaitForSingleObject (&Event,
- Executive,
- KernelMode,
- FALSE,
- NULL);
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
rc = irp->IoStatus.Status;
Log(("vbglDriverIOCtl: wait completed IRQL = %d\n", KeGetCurrentIrql()));
}
- IoFreeIrp (irp);
+ IoFreeIrp(irp);
if (rc != STATUS_SUCCESS)
Log(("vbglDriverIOCtl: ntstatus=%x\n", rc));
# endif
}
-void vbglDriverClose (VBGLDRIVER *pDriver)
+void vbglDriverClose(VBGLDRIVER *pDriver)
{
# ifdef RT_OS_WINDOWS
Log(("vbglDriverClose pDeviceObject=%x\n", pDriver->pDeviceObject));
- ObDereferenceObject (pDriver->pFileObject);
+ ObDereferenceObject(pDriver->pFileObject);
pDriver->pFileObject = NULL;
pDriver->pDeviceObject = NULL;
pDriver->u32Session = 0;
# else
- VBoxGuestIDCClose (pDriver->pvOpaque);
+ VBoxGuestIDCClose(pDriver->pvOpaque);
pDriver->pvOpaque = NULL;
# endif
}
* terms and conditions of either the GPL or the CDDL or both.
*/
-#ifndef __VBoxGuestLib_SysHlp_h
-#define __VBoxGuestLib_SysHlp_h
+#ifndef ___VBoxGuestLib_SysHlp_h
+#define ___VBoxGuestLib_SysHlp_h
#include <iprt/types.h>
/* XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist on NT4, so...
* The same for ExAllocatePool.
*/
-#undef ExAllocatePool
-#undef ExFreePool
+# undef ExAllocatePool
+# undef ExFreePool
#endif
typedef struct _VBGLDRIVER
#endif
} VBGLDRIVER;
-int vbglLockLinear (void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess, uint32_t fFlags);
-void vbglUnlockLinear (void *pvCtx, void *pv, uint32_t u32Size);
+int vbglLockLinear(void **ppvCtx, void *pv, uint32_t cb, bool fWriteAccess, uint32_t fFlags);
+void vbglUnlockLinear(void *pvCtx, void *pv, uint32_t cb);
#ifndef VBGL_VBOXGUEST
*
* @param pDriver Pointer to the driver structure.
*
- * @return VBox error code
+ * @return VBox status code
*/
-int vbglDriverOpen (VBGLDRIVER *pDriver);
+int vbglDriverOpen(VBGLDRIVER *pDriver);
/**
* Answers whether the VBoxGuest driver is opened
*
* @return true - if opened, false - otherwise
*/
-bool vbglDriverIsOpened (VBGLDRIVER *pDriver);
+bool vbglDriverIsOpened(VBGLDRIVER *pDriver);
/**
* Call VBoxGuest driver.
* @param pvData Pointer to supplied in/out data buffer.
* @param cbData Size of data buffer.
*
- * @return VBox error code
+ * @returns VBox status code
*/
-int vbglDriverIOCtl (VBGLDRIVER *pDriver, uint32_t u32Function, void *pvData, uint32_t cbData);
+int vbglDriverIOCtl(VBGLDRIVER *pDriver, uint32_t u32Function, void *pvData, uint32_t cbData);
/**
* Close VBoxGuest driver.
*
* @param pDriver Pointer to the driver structure.
*
- * @return VBox error code
+ * @returns VBox status code
*/
-void vbglDriverClose (VBGLDRIVER *pDriver);
+void vbglDriverClose(VBGLDRIVER *pDriver);
#endif
-#endif /* !__VBoxGuestLib_SysHlp_h */
+#endif
* Global VBGL ring-0 data.
* Lives in VbglR0Init.cpp.
*/
-typedef struct _VBGLDATA
+typedef struct VBGLDATA
{
enum VbglLibStatus status;
- VBGLIOPORT portVMMDev;
+ RTIOPORT portVMMDev;
VMMDevMemory *pVMMDevMemory;
#ifdef VBOX_WITH_HGCM
# ifndef VBGL_VBOXGUEST
-int vbglR0HGCMInit (void);
-int vbglR0HGCMTerminate (void);
+int vbglR0HGCMInit(void);
+int vbglR0HGCMTerminate(void);
# endif
+struct VBGLHGCMHANDLEDATA *vbglHGCMHandleAlloc(void);
+void vbglHGCMHandleFree(struct VBGLHGCMHANDLEDATA *pHandle);
#endif /* VBOX_WITH_HGCM */
#ifndef VBGL_VBOXGUEST
/* Entire file is ifdef'ed with !VBGL_VBOXGUEST */
#ifndef VBGL_VBOXGUEST
-/*******************************************************************************
-* Header Files *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
#define LOG_GROUP LOG_GROUP_SHARED_FOLDERS
-#ifdef RT_OS_LINUX
-# include "VBoxGuestR0LibSharedFolders.h"
-#else
-# include "VBoxGuestR0LibSharedFolders.h"
-#endif
+#include <VBox/VBoxGuestLibSharedFolders.h>
#include <VBox/log.h>
#include <iprt/time.h>
#include <iprt/mem.h>
#include <iprt/string.h>
-/*******************************************************************************
-* Defined Constants And Macros *
-*******************************************************************************/
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
#define SHFL_CPARMS_SET_UTF8 0
#define SHFL_CPARMS_SET_SYMLINKS 0
-#define VBOX_INIT_CALL(a, b, c) \
- LogFunc(("%s, u32ClientID=%d\n", "SHFL_FN_" # b, \
- (c)->ulClientID)); \
- (a)->result = VINF_SUCCESS; \
- (a)->u32ClientID = (c)->ulClientID; \
- (a)->u32Function = SHFL_FN_##b; \
+#define VBOX_INIT_CALL(a, b, c) \
+ LogFunc(("%s, idClient=%d\n", "SHFL_FN_" # b, (c)->idClient)); \
+ (a)->result = VINF_SUCCESS; \
+ (a)->u32ClientID = (c)->idClient; \
+ (a)->u32Function = SHFL_FN_##b; \
(a)->cParms = SHFL_CPARMS_##b
-DECLVBGL(int) vboxInit (void)
+DECLVBGL(int) VbglR0SfInit(void)
{
- int rc = VINF_SUCCESS;
-
- rc = VbglInit ();
- return rc;
+ return VbglInitClient();
}
-DECLVBGL(void) vboxUninit (void)
+DECLVBGL(void) VbglR0SfTerm(void)
{
- VbglTerminate ();
+ VbglTerminate();
}
-DECLVBGL(int) vboxConnect (PVBSFCLIENT pClient)
+DECLVBGL(int) VbglR0SfConnect(PVBGLSFCLIENT pClient)
{
int rc;
VBoxGuestHGCMConnectInfo data;
data.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
strcpy (data.Loc.u.host.achName, "VBoxSharedFolders");
- rc = VbglHGCMConnect (&pClient->handle, &data);
-
-/* Log(("VBOXSF: VBoxSF::vboxConnect: VbglHGCMConnect rc = %#x, result = %#x\n",
- rc, data.result));
-*/
- if (RT_SUCCESS (rc))
- {
+ rc = VbglHGCMConnect(&pClient->handle, &data);
+/* Log(("VBOXSF: VbglR0SfConnect: VbglHGCMConnect rc = %#x, result = %#x\n", rc, data.result)); */
+ if (RT_SUCCESS(rc))
rc = data.result;
- }
-
- if (RT_SUCCESS (rc))
+ if (RT_SUCCESS(rc))
{
- pClient->ulClientID = data.u32ClientID;
- LogFunc(("u32ClientID=%d\n", pClient->ulClientID));
+ pClient->idClient = data.u32ClientID;
+ LogFunc(("idClient=%d\n", pClient->idClient));
}
return rc;
}
-DECLVBGL(void) vboxDisconnect (PVBSFCLIENT pClient)
+DECLVBGL(void) VbglR0SfDisconnect(PVBGLSFCLIENT pClient)
{
int rc;
VBoxGuestHGCMDisconnectInfo data;
- LogFunc(("u32ClientID=%d\n", pClient->ulClientID));
+ LogFunc(("u32ClientID=%d\n", pClient->idClient));
if (pClient->handle == NULL)
return; /* not connected */
RT_ZERO(data);
data.result = VINF_SUCCESS;
- data.u32ClientID = pClient->ulClientID;
+ data.u32ClientID = pClient->idClient;
- rc = VbglHGCMDisconnect (pClient->handle, &data);
+ rc = VbglHGCMDisconnect(pClient->handle, &data);
NOREF(rc);
-/* Log(("VBOXSF: VBoxSF::vboxDisconnect: "
- "VbglHGCMDisconnect rc = %#x, result = %#x\n", rc, data.result));
-*/
+/* Log(("VBOXSF: VbglR0SfDisconnect: VbglHGCMDisconnect rc = %#x, result = %#x\n", rc, data.result)); */
return;
}
-DECLVBGL(int) vboxCallQueryMappings (PVBSFCLIENT pClient, SHFLMAPPING paMappings[],
- uint32_t *pcMappings)
+DECLVBGL(int) VbglR0SfQueryMappings(PVBGLSFCLIENT pClient, SHFLMAPPING paMappings[], uint32_t *pcMappings)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFQueryMappings data;
VBOX_INIT_CALL(&data.callInfo, QUERY_MAPPINGS, pClient);
data.numberOfMappings.u.value32 = *pcMappings;
data.mappings.type = VMMDevHGCMParmType_LinAddr;
- data.mappings.u.Pointer.size = sizeof (SHFLMAPPING) * *pcMappings;
+ data.mappings.u.Pointer.size = sizeof(SHFLMAPPING) * *pcMappings;
data.mappings.u.Pointer.u.linearAddr = (uintptr_t)&paMappings[0];
-/* Log(("VBOXSF: in ifs difference %d\n",
- (char *)&data.flags.type - (char *)&data.callInfo.cParms));
-*/
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*
- Log(("VBOXSF: VBoxSF::vboxCallQueryMappings: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
- {
+/* Log(("VBOXSF: in ifs difference %d\n", (char *)&data.flags.type - (char *)&data.callInfo.cParms)); */
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfQueryMappings: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
rc = data.callInfo.result;
- }
-
- if (RT_SUCCESS (rc))
- {
+ if (RT_SUCCESS(rc))
*pcMappings = data.numberOfMappings.u.value32;
- }
return rc;
}
-DECLVBGL(int) vboxCallQueryMapName (PVBSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size)
+DECLVBGL(int) VbglR0SfQueryMapName(PVBGLSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFQueryMapName data;
VBOX_INIT_CALL(&data.callInfo, QUERY_MAP_NAME, pClient);
data.name.u.Pointer.size = size;
data.name.u.Pointer.u.linearAddr = (uintptr_t)pString;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallQueryMapName: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
- {
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfQueryMapName: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
rc = data.callInfo.result;
- }
return rc;
}
-DECLVBGL(int) vboxCallMapFolder(PVBSFCLIENT pClient, PSHFLSTRING szFolderName,
- PVBSFMAP pMap)
+DECLVBGL(int) VbglR0SfMapFolder(PVBGLSFCLIENT pClient, PSHFLSTRING szFolderName, PVBGLSFMAP pMap)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFMapFolder data;
VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER, pClient);
data.path.type = VMMDevHGCMParmType_LinAddr;
- data.path.u.Pointer.size = ShflStringSizeOfBuffer (szFolderName);
+ data.path.u.Pointer.size = ShflStringSizeOfBuffer(szFolderName);
data.path.u.Pointer.u.linearAddr = (uintptr_t)szFolderName;
data.root.type = VMMDevHGCMParmType_32bit;
data.fCaseSensitive.u.value32 = 1;
#endif
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallMapFolder: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfMapFolder: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
{
pMap->root = data.root.u.value32;
rc = data.callInfo.result;
OldData.delimiter.type = VMMDevHGCMParmType_32bit;
OldData.delimiter.u.value32 = RTPATH_DELIMITER;
- rc = VbglHGCMCall (pClient->handle, &OldData.callInfo, sizeof (OldData));
-
- if (RT_SUCCESS (rc))
+ rc = VbglHGCMCall(pClient->handle, &OldData.callInfo, sizeof(OldData));
+ if (RT_SUCCESS(rc))
{
pMap->root = OldData.root.u.value32;
rc = OldData.callInfo.result;
return rc;
}
-DECLVBGL(int) vboxCallUnmapFolder(PVBSFCLIENT pClient, PVBSFMAP pMap)
+DECLVBGL(int) VbglR0SfUnmapFolder(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFUnmapFolder data;
VBOX_INIT_CALL(&data.callInfo, UNMAP_FOLDER, pClient);
data.root.type = VMMDevHGCMParmType_32bit;
data.root.u.value32 = pMap->root;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallUnmapFolder: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
- {
- rc = data.callInfo.result;
- }
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfUnmapFolder: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
+ rc = data.callInfo.result;
return rc;
}
-DECLVBGL(int) vboxCallCreate (PVBSFCLIENT pClient, PVBSFMAP pMap,
- PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms)
+DECLVBGL(int) VbglR0SfCreate(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms)
{
/** @todo copy buffers to physical or mapped memory. */
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFCreate data;
VBOX_INIT_CALL(&data.callInfo, CREATE, pClient);
data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
data.parms.type = VMMDevHGCMParmType_LinAddr;
- data.parms.u.Pointer.size = sizeof (SHFLCREATEPARMS);
+ data.parms.u.Pointer.size = sizeof(SHFLCREATEPARMS);
data.parms.u.Pointer.u.linearAddr = (uintptr_t)pCreateParms;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallCreate: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
- {
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfCreate: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
rc = data.callInfo.result;
- }
return rc;
}
-DECLVBGL(int) vboxCallClose (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE Handle)
+DECLVBGL(int) VbglR0SfClose(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE Handle)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFClose data;
VBOX_INIT_CALL(&data.callInfo, CLOSE, pClient);
data.handle.type = VMMDevHGCMParmType_64bit;
data.handle.u.value64 = Handle;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallClose: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
- {
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfClose: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
rc = data.callInfo.result;
- }
-
return rc;
}
-DECLVBGL(int) vboxCallRemove (PVBSFCLIENT pClient, PVBSFMAP pMap,
- PSHFLSTRING pParsedPath, uint32_t flags)
+DECLVBGL(int) VbglR0SfRemove(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pParsedPath, uint32_t flags)
{
int rc = VINF_SUCCESS;
data.root.u.value32 = pMap->root;
data.path.type = VMMDevHGCMParmType_LinAddr_In;
- data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
+ data.path.u.Pointer.size = ShflStringSizeOfBuffer(pParsedPath);
data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
data.flags.type = VMMDevHGCMParmType_32bit;
data.flags.u.value32 = flags;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallRemove: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfRemove: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
if (RT_SUCCESS (rc))
- {
rc = data.callInfo.result;
- }
-
return rc;
}
-DECLVBGL(int) vboxCallRename (PVBSFCLIENT pClient, PVBSFMAP pMap,
- PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags)
+DECLVBGL(int) VbglR0SfRename(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFRename data;
VBOX_INIT_CALL(&data.callInfo, RENAME, pClient);
data.root.u.value32 = pMap->root;
data.src.type = VMMDevHGCMParmType_LinAddr_In;
- data.src.u.Pointer.size = ShflStringSizeOfBuffer (pSrcPath);
+ data.src.u.Pointer.size = ShflStringSizeOfBuffer(pSrcPath);
data.src.u.Pointer.u.linearAddr = (uintptr_t)pSrcPath;
data.dest.type = VMMDevHGCMParmType_LinAddr_In;
- data.dest.u.Pointer.size = ShflStringSizeOfBuffer (pDestPath);
+ data.dest.u.Pointer.size = ShflStringSizeOfBuffer(pDestPath);
data.dest.u.Pointer.u.linearAddr = (uintptr_t)pDestPath;
data.flags.type = VMMDevHGCMParmType_32bit;
data.flags.u.value32 = flags;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallRename: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfRename: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
if (RT_SUCCESS (rc))
- {
rc = data.callInfo.result;
- }
return rc;
}
-DECLVBGL(int) vboxCallRead(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
+DECLVBGL(int) VbglR0SfRead(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile,
uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFRead data;
VBOX_INIT_CALL(&data.callInfo, READ, pClient);
data.buffer.u.Pointer.size = *pcbBuffer;
data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallRead: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfRead: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
{
rc = data.callInfo.result;
*pcbBuffer = data.cb.u.value32;
return rc;
}
-DECLVBGL(int) VbglR0SharedFolderReadPageList(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
- uint64_t offset, uint32_t *pcbBuffer,
- uint16_t offFirstPage, uint16_t cPages, RTGCPHYS64 *paPages)
+DECLVBGL(int) VbglR0SfReadPageList(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer,
+ uint16_t offFirstPage, uint16_t cPages, RTGCPHYS64 *paPages)
{
uint32_t cbToRead = *pcbBuffer;
uint32_t cbData = (uint32_t)(sizeof(VBoxSFRead) + RT_UOFFSETOF(HGCMPageListInfo, aPages[cPages]));
pPgLst->aPages[iPage] = paPages[iPage];
rc = VbglHGCMCall(pClient->handle, &pData->callInfo, cbData);
- if (RT_SUCCESS (rc))
+/* Log(("VBOXSF: VbglR0SfReadPageList: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
{
rc = pData->callInfo.result;
*pcbBuffer = pData->cb.u.value32;
return rc;
}
-DECLVBGL(int) vboxCallWrite(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
+DECLVBGL(int) VbglR0SfWrite(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile,
uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFWrite data;
VBOX_INIT_CALL(&data.callInfo, WRITE, pClient);
data.offset.u.value64 = offset;
data.cb.type = VMMDevHGCMParmType_32bit;
data.cb.u.value32 = *pcbBuffer;
- data.buffer.type = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_In : VMMDevHGCMParmType_LinAddr_In;
+ data.buffer.type = fLocked ? VMMDevHGCMParmType_LinAddr_Locked_In : VMMDevHGCMParmType_LinAddr_In;
data.buffer.u.Pointer.size = *pcbBuffer;
data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallWrite: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfWrite: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
{
rc = data.callInfo.result;
*pcbBuffer = data.cb.u.value32;
return rc;
}
-DECLVBGL(int) VbglR0SfWritePhysCont(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, RTCCPHYS PhysBuffer)
+DECLVBGL(int) VbglR0SfWritePhysCont(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset,
+ uint32_t *pcbBuffer, RTCCPHYS PhysBuffer)
{
uint32_t cbToWrite = *pcbBuffer;
uint32_t cPages = RT_ALIGN_32((PhysBuffer & PAGE_OFFSET_MASK) + cbToWrite, PAGE_SIZE) >> PAGE_SHIFT;
for (iPage = 0; iPage < cPages; iPage++, PhysBuffer += PAGE_SIZE)
pPgLst->aPages[iPage] = PhysBuffer;
- rc = VbglHGCMCall (pClient->handle, &pData->callInfo, cbData);
- if (RT_SUCCESS (rc))
+ rc = VbglHGCMCall(pClient->handle, &pData->callInfo, cbData);
+/* Log(("VBOXSF: VbglR0SfWritePhysCont: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
{
rc = pData->callInfo.result;
*pcbBuffer = pData->cb.u.value32;
}
-DECLVBGL(int) VbglR0SharedFolderWritePageList(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
- uint64_t offset, uint32_t *pcbBuffer,
- uint16_t offFirstPage, uint16_t cPages, RTGCPHYS64 *paPages)
+DECLVBGL(int) VbglR0SfWritePageList(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer,
+ uint16_t offFirstPage, uint16_t cPages, RTGCPHYS64 *paPages)
{
uint32_t cbToWrite = *pcbBuffer;
uint32_t cbData = (uint32_t)(sizeof(VBoxSFWrite) + RT_UOFFSETOF(HGCMPageListInfo, aPages[cPages]));
for (iPage = 0; iPage < cPages; iPage++)
pPgLst->aPages[iPage] = paPages[iPage];
- rc = VbglHGCMCall (pClient->handle, &pData->callInfo, cbData);
- if (RT_SUCCESS (rc))
+ rc = VbglHGCMCall(pClient->handle, &pData->callInfo, cbData);
+/* Log(("VBOXSF: VbglR0SfWritePageList: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
{
rc = pData->callInfo.result;
*pcbBuffer = pData->cb.u.value32;
return rc;
}
-DECLVBGL(int) vboxCallFlush(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile)
+DECLVBGL(int) VbglR0SfFlush(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFFlush data;
VBOX_INIT_CALL(&data.callInfo, FLUSH, pClient);
data.handle.type = VMMDevHGCMParmType_64bit;
data.handle.u.value64 = hFile;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallFlush: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
- {
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfFlush: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
rc = data.callInfo.result;
- }
return rc;
}
-DECLVBGL(int) vboxCallDirInfo (
- PVBSFCLIENT pClient,
- PVBSFMAP pMap,
+DECLVBGL(int) VbglR0SfDirInfo(
+ PVBGLSFCLIENT pClient,
+ PVBGLSFMAP pMap,
SHFLHANDLE hFile,
PSHFLSTRING ParsedPath,
uint32_t flags,
PSHFLDIRINFO pBuffer,
uint32_t *pcFiles)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFList data;
VBOX_INIT_CALL(&data.callInfo, LIST, pClient);
data.cb.type = VMMDevHGCMParmType_32bit;
data.cb.u.value32 = *pcbBuffer;
data.path.type = VMMDevHGCMParmType_LinAddr_In;
- data.path.u.Pointer.size =
- (ParsedPath) ? ShflStringSizeOfBuffer(ParsedPath) : 0;
+ data.path.u.Pointer.size = ParsedPath ? ShflStringSizeOfBuffer(ParsedPath) : 0;
data.path.u.Pointer.u.linearAddr = (uintptr_t) ParsedPath;
data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
data.cFiles.type = VMMDevHGCMParmType_32bit;
data.cFiles.u.value32 = 0; /* out parameters only */
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallDirInfo: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
- {
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfDirInfo: rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
rc = data.callInfo.result;
- }
*pcbBuffer = data.cb.u.value32;
*pcFiles = data.cFiles.u.value32;
return rc;
}
-DECLVBGL(int) vboxCallFSInfo(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
+DECLVBGL(int) VbglR0SfFsInfo(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile,
uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFInformation data;
VBOX_INIT_CALL(&data.callInfo, INFORMATION, pClient);
data.info.u.Pointer.size = *pcbBuffer;
data.info.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallFileInfo: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
- if (RT_SUCCESS (rc))
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfFsInfo: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
{
rc = data.callInfo.result;
*pcbBuffer = data.cb.u.value32;
return rc;
}
-DECLVBGL(int) vboxCallLock(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
+DECLVBGL(int) VbglR0SfLock(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile,
uint64_t offset, uint64_t cbSize, uint32_t fLock)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFLock data;
VBOX_INIT_CALL(&data.callInfo, LOCK, pClient);
data.flags.type = VMMDevHGCMParmType_32bit;
data.flags.u.value32 = fLock;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallLock: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfLock: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
if (RT_SUCCESS (rc))
- {
rc = data.callInfo.result;
- }
return rc;
}
-DECLVBGL(int) vboxCallSetUtf8 (PVBSFCLIENT pClient)
+DECLVBGL(int) VbglR0SfSetUtf8(PVBGLSFCLIENT pClient)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxGuestHGCMCallInfo callInfo;
- VBOX_INIT_CALL (&callInfo, SET_UTF8, pClient);
- rc = VbglHGCMCall (pClient->handle, &callInfo, sizeof (callInfo));
- if (RT_SUCCESS (rc))
- {
+ VBOX_INIT_CALL(&callInfo, SET_UTF8, pClient);
+ rc = VbglHGCMCall(pClient->handle, &callInfo, sizeof(callInfo));
+/* Log(("VBOXSF: VbglR0SfSetUtf8: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
rc = callInfo.result;
- }
return rc;
}
-DECLVBGL(int) vboxReadLink (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pParsedPath,
- uint32_t cbBuffer, uint8_t *pBuffer)
+DECLVBGL(int) VbglR0SfReadLink(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pParsedPath, uint32_t cbBuffer, uint8_t *pBuffer)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFReadLink data;
VBOX_INIT_CALL(&data.callInfo, READLINK, pClient);
data.buffer.u.Pointer.size = cbBuffer;
data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallReadline: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfReadLink: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
if (RT_SUCCESS (rc))
- {
rc = data.callInfo.result;
- }
return rc;
}
-DECLVBGL(int) vboxCallSymlink (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pNewPath, PSHFLSTRING pOldPath,
- PSHFLFSOBJINFO pBuffer)
+DECLVBGL(int) VbglR0SfSymlink(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pNewPath, PSHFLSTRING pOldPath,
+ PSHFLFSOBJINFO pBuffer)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxSFSymlink data;
VBOX_INIT_CALL(&data.callInfo, SYMLINK, pClient);
data.info.u.Pointer.size = sizeof(SHFLFSOBJINFO);
data.info.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
- rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/* Log(("VBOXSF: VBoxSF::vboxCallSymlink: "
- "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
+ rc = VbglHGCMCall(pClient->handle, &data.callInfo, sizeof(data));
+/* Log(("VBOXSF: VbglR0SfSymlink: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
if (RT_SUCCESS (rc))
- {
rc = data.callInfo.result;
- }
return rc;
}
-DECLVBGL(int) vboxCallSetSymlinks (PVBSFCLIENT pClient)
+DECLVBGL(int) VbglR0SfSetSymlinks(PVBGLSFCLIENT pClient)
{
- int rc = VINF_SUCCESS;
-
+ int rc;
VBoxGuestHGCMCallInfo callInfo;
- VBOX_INIT_CALL (&callInfo, SET_SYMLINKS, pClient);
- rc = VbglHGCMCall (pClient->handle, &callInfo, sizeof (callInfo));
- if (RT_SUCCESS (rc))
- {
+ VBOX_INIT_CALL(&callInfo, SET_SYMLINKS, pClient);
+ rc = VbglHGCMCall(pClient->handle, &callInfo, sizeof(callInfo));
+/* Log(("VBOXSF: VbglR0SfSetSymlinks: VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
+ if (RT_SUCCESS(rc))
rc = callInfo.result;
- }
return rc;
}
#include "VBGLInternal.h"
-DECLVBGL(int) VbglQueryVMMDevMemory (VMMDevMemory **ppVMMDevMemory)
+DECLVBGL(int) VbglQueryVMMDevMemory(VMMDevMemory **ppVMMDevMemory)
{
- int rc = vbglR0Enter ();
-
+ int rc = vbglR0Enter();
if (RT_FAILURE(rc))
return rc;
| SHFL_CF_ACCESS_READ
;
- LogFunc(("sf_dir_open(): calling vboxCallCreate, folder %s, flags %#x\n",
+ LogFunc(("sf_dir_open(): calling VbglR0SfCreate, folder %s, flags %#x\n",
sf_i->path->String.utf8, params.CreateFlags));
- rc = vboxCallCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms);
+ rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms);
if (RT_SUCCESS(rc))
{
if (params.Result == SHFL_FILE_EXISTS)
else
err = -ENOENT;
- rc = vboxCallClose(&client_handle, &sf_g->map, params.Handle);
+ rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle);
if (RT_FAILURE(rc))
- LogFunc(("sf_dir_open(): vboxCallClose(%s) after err=%d failed rc=%Rrc\n",
+ LogFunc(("sf_dir_open(): VbglR0SfClose(%s) after err=%d failed rc=%Rrc\n",
sf_i->path->String.utf8, err, rc));
}
else
return 0;
}
+/**
+ * Translate RTFMODE into DT_xxx (in conjunction to rtDirType())
+ * @param fMode file mode
+ * returns d_type
+ */
+static int sf_get_d_type(RTFMODE fMode)
+{
+ int d_type;
+ switch (fMode & RTFS_TYPE_MASK)
+ {
+ case RTFS_TYPE_FIFO: d_type = DT_FIFO; break;
+ case RTFS_TYPE_DEV_CHAR: d_type = DT_CHR; break;
+ case RTFS_TYPE_DIRECTORY: d_type = DT_DIR; break;
+ case RTFS_TYPE_DEV_BLOCK: d_type = DT_BLK; break;
+ case RTFS_TYPE_FILE: d_type = DT_REG; break;
+ case RTFS_TYPE_SYMLINK: d_type = DT_LNK; break;
+ case RTFS_TYPE_SOCKET: d_type = DT_SOCK; break;
+ case RTFS_TYPE_WHITEOUT: d_type = DT_WHT; break;
+ default: d_type = DT_UNKNOWN; break;
+ }
+ return d_type;
+}
+
/**
* Extract element ([dir]->f_pos) from the directory [dir] into [d_name].
*
* @returns 0 for success, 1 for end reached, Linux error code otherwise.
*/
-static int sf_getdent(struct file *dir, char d_name[NAME_MAX])
+static int sf_getdent(struct file *dir, char d_name[NAME_MAX], int *d_type)
{
loff_t cur;
struct sf_glob_info *sf_g;
| SHFL_CF_ACCESS_READ
;
- LogFunc(("sf_getdent: calling vboxCallCreate, folder %s, flags %#x\n",
+ LogFunc(("sf_getdent: calling VbglR0SfCreate, folder %s, flags %#x\n",
sf_i->path->String.utf8, params.CreateFlags));
- rc = vboxCallCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms);
+ rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms);
if (RT_FAILURE(rc))
{
- LogFunc(("vboxCallCreate(%s) failed rc=%Rrc\n",
+ LogFunc(("VbglR0SfCreate(%s) failed rc=%Rrc\n",
sf_i->path->String.utf8, rc));
return -EPERM;
}
sf_dir_info_empty(sf_d);
err = sf_dir_read_all(sf_g, sf_i, sf_d, params.Handle);
- rc = vboxCallClose(&client_handle, &sf_g->map, params.Handle);
+ rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle);
if (RT_FAILURE(rc))
- LogFunc(("vboxCallClose(%s) failed rc=%Rrc\n", sf_i->path->String.utf8, rc));
+ LogFunc(("VbglR0SfClose(%s) failed rc=%Rrc\n", sf_i->path->String.utf8, rc));
if (err)
return err;
info = (SHFLDIRINFO *) ((uintptr_t) info + size);
}
+ *d_type = sf_get_d_type(info->Info.Attr.fMode);
+
return sf_nlscpy(sf_g, d_name, NAME_MAX,
info->name.String.utf8, info->name.u16Length);
}
ino_t fake_ino;
loff_t sanity;
char d_name[NAME_MAX];
+ int d_type = DT_UNKNOWN;
- err = sf_getdent(dir, d_name);
+ err = sf_getdent(dir, d_name, &d_type);
switch (err)
{
case 1:
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
- if (!dir_emit(ctx, d_name, strlen(d_name), fake_ino, DT_UNKNOWN))
+ if (!dir_emit(ctx, d_name, strlen(d_name), fake_ino, d_type))
{
LogFunc(("dir_emit failed\n"));
return 0;
}
#else
- err = filldir(opaque, d_name, strlen(d_name), dir->f_pos, fake_ino, DT_UNKNOWN);
+ err = filldir(opaque, d_name, strlen(d_name), dir->f_pos, fake_ino, d_type);
if (err)
{
LogFunc(("filldir returned error %d\n", err));
;
params.Info.Attr.enmAdditional = RTFSOBJATTRADD_NOTHING;
- LogFunc(("sf_create_aux: calling vboxCallCreate, folder %s, flags %#x\n",
+ LogFunc(("sf_create_aux: calling VbglR0SfCreate, folder %s, flags %#x\n",
path->String.utf8, params.CreateFlags));
- rc = vboxCallCreate(&client_handle, &sf_g->map, path, ¶ms);
+ rc = VbglR0SfCreate(&client_handle, &sf_g->map, path, ¶ms);
if (RT_FAILURE(rc))
{
if (rc == VERR_WRITE_PROTECT)
goto fail1;
}
err = -EPROTO;
- LogFunc(("(%d): vboxCallCreate(%s) failed rc=%Rrc\n",
+ LogFunc(("(%d): VbglR0SfCreate(%s) failed rc=%Rrc\n",
fDirectory, sf_i->path->String.utf8, rc));
goto fail1;
}
*/
if (fDirectory)
{
- rc = vboxCallClose(&client_handle, &sf_g->map, params.Handle);
+ rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle);
if (RT_FAILURE(rc))
- LogFunc(("(%d): vboxCallClose failed rc=%Rrc\n", fDirectory, rc));
+ LogFunc(("(%d): VbglR0SfClose failed rc=%Rrc\n", fDirectory, rc));
}
sf_i->force_restat = 1;
return 0;
fail2:
- rc = vboxCallClose(&client_handle, &sf_g->map, params.Handle);
+ rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle);
if (RT_FAILURE(rc))
- LogFunc(("(%d): vboxCallClose failed rc=%Rrc\n", fDirectory, rc));
+ LogFunc(("(%d): VbglR0SfClose failed rc=%Rrc\n", fDirectory, rc));
fail1:
kfree(path);
* @param parent inode of the directory
* @param dentry directory cache entry
* @param mode file mode
+ * @param excl Possible O_EXCL...
* @returns 0 on success, Linux error code otherwise
*/
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) || defined(DOXYGEN_RUNNING)
static int sf_create(struct inode *parent, struct dentry *dentry, umode_t mode, bool excl)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
static int sf_create(struct inode *parent, struct dentry *dentry, umode_t mode, struct nameidata *nd)
&& dentry->d_inode
&& ((dentry->d_inode->i_mode & S_IFLNK) == S_IFLNK))
fFlags |= SHFL_REMOVE_SYMLINK;
- rc = vboxCallRemove(&client_handle, &sf_g->map, path, fFlags);
+ rc = VbglR0SfRemove(&client_handle, &sf_g->map, path, fFlags);
if (RT_FAILURE(rc))
{
- LogFunc(("(%d): vboxCallRemove(%s) failed rc=%Rrc\n", fDirectory,
- path->String.utf8, rc));
+ LogFunc(("(%d): VbglR0SfRemove(%s) failed rc=%Rrc\n", fDirectory, path->String.utf8, rc));
err = -RTErrConvertToErrno(rc);
goto fail1;
}
{
int fDir = ((old_dentry->d_inode->i_mode & S_IFDIR) != 0);
- rc = vboxCallRename(&client_handle, &sf_g->map, old_path,
+ rc = VbglR0SfRename(&client_handle, &sf_g->map, old_path,
new_path, fDir ? 0 : SHFL_RENAME_FILE | SHFL_RENAME_REPLACE_IF_EXISTS);
if (RT_SUCCESS(rc))
{
}
else
{
- LogFunc(("vboxCallRename failed rc=%Rrc\n", rc));
+ LogFunc(("VbglR0SfRename failed rc=%Rrc\n", rc));
err = -RTErrConvertToErrno(rc);
kfree(new_path);
}
ssymname->u16Size = symname_len;
memcpy(ssymname->String.utf8, symname, symname_len);
- rc = vboxCallSymlink(&client_handle, &sf_g->map, path, ssymname, &info);
+ rc = VbglR0SfSymlink(&client_handle, &sf_g->map, path, ssymname, &info);
kfree(ssymname);
if (RT_FAILURE(rc))
err = -EROFS;
goto fail1;
}
- LogFunc(("vboxCallSymlink(%s) failed rc=%Rrc\n",
+ LogFunc(("VbglR0SfSymlink(%s) failed rc=%Rrc\n",
sf_i->path->String.utf8, rc));
err = -EPROTO;
goto fail1;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
static const char *sf_follow_link(struct dentry *dentry, void **cookie)
-# else
+# else
static void *sf_follow_link(struct dentry *dentry, struct nameidata *nd)
-# endif
+# endif
{
struct inode *inode = dentry->d_inode;
struct sf_glob_info *sf_g = GET_GLOB_INFO(inode->i_sb);
if (path)
{
error = 0;
- rc = vboxReadLink(&client_handle, &sf_g->map, sf_i->path, PATH_MAX, path);
+ rc = VbglR0SfReadLink(&client_handle, &sf_g->map, sf_i->path, PATH_MAX, path);
if (RT_FAILURE(rc))
{
- LogFunc(("vboxReadLink failed, caller=%s, rc=%Rrc\n", __func__, rc));
+ LogFunc(("VbglR0SfReadLink failed, caller=%s, rc=%Rrc\n", __func__, rc));
free_page((unsigned long)path);
error = -EPROTO;
}
}
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
return error ? ERR_PTR(error) : (*cookie = path);
-# else
+# else
nd_set_link(nd, error ? ERR_PTR(error) : path);
return NULL;
-# endif
+# endif
}
-# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
+# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
static void sf_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
{
char *page = nd_get_link(nd);
if (!IS_ERR(page))
free_page((unsigned long)page);
}
-#endif
+# endif
+
+# else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) */
+static const char *sf_get_link(struct dentry *dentry, struct inode *inode,
+ struct delayed_call *done)
+{
+ struct sf_glob_info *sf_g = GET_GLOB_INFO(inode->i_sb);
+ struct sf_inode_info *sf_i = GET_INODE_INFO(inode);
+ char *path;
+ int rc;
+
+ if (!dentry)
+ return ERR_PTR(-ECHILD);
+ path = kzalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!path)
+ return ERR_PTR(-ENOMEM);
+ rc = VbglR0SfReadLink(&client_handle, &sf_g->map, sf_i->path, PATH_MAX, path);
+ if (RT_FAILURE(rc))
+ {
+ LogFunc(("VbglR0SfReadLink failed, caller=%s, rc=%Rrc\n", __func__, rc));
+ kfree(path);
+ return ERR_PTR(-EPROTO);
+ }
+ set_delayed_call(done, kfree_link, path);
+ return path;
+}
+# endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) */
struct inode_operations sf_lnk_iops =
{
.readlink = generic_readlink,
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
+ .get_link = sf_get_link
+# elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
.follow_link = sf_follow_link,
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
.put_link = free_page_put_link,
# else
+ .follow_link = sf_follow_link,
.put_link = sf_put_link
# endif
};
-#endif
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) */
#define VBOX_VENDOR_SHORT "Oracle"
#define VBOX_PRODUCT "Oracle VM VirtualBox"
#define VBOX_BUILD_PUBLISHER "_Ubuntu"
-#define VBOX_C_YEAR "2015"
+#define VBOX_C_YEAR "2016"
#endif
/** @todo bird: yes, kmap() and kmalloc() input only. Since the buffer is
* contiguous in physical memory (kmalloc or single page), we should
* use a physical address here to speed things up. */
- int rc = vboxCallRead(&client_handle, &sf_g->map, sf_r->handle,
+ int rc = VbglR0SfRead(&client_handle, &sf_g->map, sf_r->handle,
pos, nread, buf, false /* already locked? */);
if (RT_FAILURE(rc))
{
- LogFunc(("vboxCallRead failed. caller=%s, rc=%Rrc\n", caller, rc));
+ LogFunc(("VbglR0SfRead failed. caller=%s, rc=%Rrc\n", caller, rc));
return -EPROTO;
}
return 0;
/** @todo bird: yes, kmap() and kmalloc() input only. Since the buffer is
* contiguous in physical memory (kmalloc or single page), we should
* use a physical address here to speed things up. */
- int rc = vboxCallWrite(&client_handle, &sf_g->map, sf_r->handle,
+ int rc = VbglR0SfWrite(&client_handle, &sf_g->map, sf_r->handle,
pos, nwritten, buf, false /* already locked? */);
if (RT_FAILURE(rc))
{
- LogFunc(("vboxCallWrite failed. caller=%s, rc=%Rrc\n",
+ LogFunc(("VbglR0SfWrite failed. caller=%s, rc=%Rrc\n",
caller, rc));
return -EPROTO;
}
}
params.Info.Attr.fMode = inode->i_mode;
- LogFunc(("sf_reg_open: calling vboxCallCreate, file %s, flags=%#x, %#x\n",
+ LogFunc(("sf_reg_open: calling VbglR0SfCreate, file %s, flags=%#x, %#x\n",
sf_i->path->String.utf8 , file->f_flags, params.CreateFlags));
- rc = vboxCallCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms);
+ rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms);
if (RT_FAILURE(rc))
{
- LogFunc(("vboxCallCreate failed flags=%d,%#x rc=%Rrc\n",
+ LogFunc(("VbglR0SfCreate failed flags=%d,%#x rc=%Rrc\n",
file->f_flags, params.CreateFlags, rc));
kfree(sf_r);
return -RTErrConvertToErrno(rc);
&& filemap_fdatawrite(inode->i_mapping) != -EIO)
filemap_fdatawait(inode->i_mapping);
#endif
- rc = vboxCallClose(&client_handle, &sf_g->map, sf_r->handle);
+ rc = VbglR0SfClose(&client_handle, &sf_g->map, sf_r->handle);
if (RT_FAILURE(rc))
- LogFunc(("vboxCallClose failed rc=%Rrc\n", rc));
+ LogFunc(("VbglR0SfClose failed rc=%Rrc\n", rc));
kfree(sf_r);
sf_i->file = NULL;
}
#endif
- /* Don't use GFP_HIGHUSER as long as sf_reg_read_aux() calls vboxCallRead()
+ /* Don't use GFP_HIGHUSER as long as sf_reg_read_aux() calls VbglR0SfRead()
* which works on virtual addresses. On Linux cannot reliably determine the
* physical address for high memory, see rtR0MemObjNativeLockKernel(). */
page = alloc_page(GFP_USER);
RT_ZERO(params);
params.Handle = SHFL_HANDLE_NIL;
params.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW;
- LogFunc(("sf_stat: calling vboxCallCreate, file %s, flags %#x\n",
+ LogFunc(("sf_stat: calling VbglR0SfCreate, file %s, flags %#x\n",
path->String.utf8, params.CreateFlags));
- rc = vboxCallCreate(&client_handle, &sf_g->map, path, ¶ms);
+ rc = VbglR0SfCreate(&client_handle, &sf_g->map, path, ¶ms);
if (rc == VERR_INVALID_NAME)
{
/* this can happen for names like 'foo*' on a Windows host */
}
if (RT_FAILURE(rc))
{
- LogFunc(("vboxCallCreate(%s) failed. caller=%s, rc=%Rrc\n",
+ LogFunc(("VbglR0SfCreate(%s) failed. caller=%s, rc=%Rrc\n",
path->String.utf8, rc, caller));
return -EPROTO;
}
if (params.Result != SHFL_FILE_EXISTS)
{
if (!ok_to_fail)
- LogFunc(("vboxCallCreate(%s) file does not exist. caller=%s, result=%d\n",
+ LogFunc(("VbglR0SfCreate(%s) file does not exist. caller=%s, result=%d\n",
path->String.utf8, params.Result, caller));
return -ENOENT;
}
if (iattr->ia_valid & ATTR_SIZE)
params.CreateFlags |= SHFL_CF_ACCESS_WRITE;
- rc = vboxCallCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms);
+ rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms);
if (RT_FAILURE(rc))
{
- LogFunc(("vboxCallCreate(%s) failed rc=%Rrc\n",
+ LogFunc(("VbglR0SfCreate(%s) failed rc=%Rrc\n",
sf_i->path->String.utf8, rc));
err = -RTErrConvertToErrno(rc);
goto fail2;
/* ignore ctime (inode change time) as it can't be set from userland anyway */
cbBuffer = sizeof(info);
- rc = vboxCallFSInfo(&client_handle, &sf_g->map, params.Handle,
- SHFL_INFO_SET | SHFL_INFO_FILE, &cbBuffer,
- (PSHFLDIRINFO)&info);
+ rc = VbglR0SfFsInfo(&client_handle, &sf_g->map, params.Handle,
+ SHFL_INFO_SET | SHFL_INFO_FILE, &cbBuffer,
+ (PSHFLDIRINFO)&info);
if (RT_FAILURE(rc))
{
- LogFunc(("vboxCallFSInfo(%s, FILE) failed rc=%Rrc\n",
+ LogFunc(("VbglR0SfFsInfo(%s, FILE) failed rc=%Rrc\n",
sf_i->path->String.utf8, rc));
err = -RTErrConvertToErrno(rc);
goto fail1;
RT_ZERO(info);
info.cbObject = iattr->ia_size;
cbBuffer = sizeof(info);
- rc = vboxCallFSInfo(&client_handle, &sf_g->map, params.Handle,
+ rc = VbglR0SfFsInfo(&client_handle, &sf_g->map, params.Handle,
SHFL_INFO_SET | SHFL_INFO_SIZE, &cbBuffer,
(PSHFLDIRINFO)&info);
if (RT_FAILURE(rc))
{
- LogFunc(("vboxCallFSInfo(%s, SIZE) failed rc=%Rrc\n",
+ LogFunc(("VbglR0SfFsInfo(%s, SIZE) failed rc=%Rrc\n",
sf_i->path->String.utf8, rc));
err = -RTErrConvertToErrno(rc);
goto fail1;
}
}
- rc = vboxCallClose(&client_handle, &sf_g->map, params.Handle);
+ rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle);
if (RT_FAILURE(rc))
- LogFunc(("vboxCallClose(%s) failed rc=%Rrc\n", sf_i->path->String.utf8, rc));
+ LogFunc(("VbglR0SfClose(%s) failed rc=%Rrc\n", sf_i->path->String.utf8, rc));
return sf_inode_revalidate(dentry);
fail1:
- rc = vboxCallClose(&client_handle, &sf_g->map, params.Handle);
+ rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle);
if (RT_FAILURE(rc))
- LogFunc(("vboxCallClose(%s) failed rc=%Rrc\n", sf_i->path->String.utf8, rc));
+ LogFunc(("VbglR0SfClose(%s) failed rc=%Rrc\n", sf_i->path->String.utf8, rc));
fail2:
return err;
buf = b->buf;
cbSize = b->cbFree;
- rc = vboxCallDirInfo(&client_handle, &sf_g->map, handle, mask,
+ rc = VbglR0SfDirInfo(&client_handle, &sf_g->map, handle, mask,
0, 0, &cbSize, buf, &cEntries);
switch (rc)
{
break;
default:
err = -RTErrConvertToErrno(rc);
- LogFunc(("vboxCallDirInfo failed rc=%Rrc\n", rc));
+ LogFunc(("VbglR0SfDirInfo failed rc=%Rrc\n", rc));
goto fail1;
}
sf_g = GET_GLOB_INFO(sb);
cbBuffer = sizeof(SHFLVolumeInfo);
- rc = vboxCallFSInfo(&client_handle, &sf_g->map, 0, SHFL_INFO_GET | SHFL_INFO_VOLUME,
+ rc = VbglR0SfFsInfo(&client_handle, &sf_g->map, 0, SHFL_INFO_GET | SHFL_INFO_VOLUME,
&cbBuffer, (PSHFLDIRINFO)&SHFLVolumeInfo);
if (RT_FAILURE(rc))
return -RTErrConvertToErrno(rc);
#define VBOX_VERSION_MAJOR 5
#define VBOX_VERSION_MINOR 0
-#define VBOX_VERSION_BUILD 0
-#define VBOX_VERSION_STRING_RAW "5.0.0"
-#define VBOX_VERSION_STRING "5.0.0_Ubuntu"
+#define VBOX_VERSION_BUILD 14
+#define VBOX_VERSION_STRING_RAW "5.0.14"
+#define VBOX_VERSION_STRING "5.0.14_Ubuntu"
#define VBOX_API_VERSION_STRING "5_0"
#define VBOX_PRIVATE_BUILD_DESC "Private build by root"
#endif
/* globals */
-VBSFCLIENT client_handle;
+VBGLSFCLIENT client_handle;
/* forward declarations */
static struct super_operations sf_super_ops;
#undef _IS_EMPTY
}
- rc = vboxCallMapFolder(&client_handle, str_name, &sf_g->map);
+ rc = VbglR0SfMapFolder(&client_handle, str_name, &sf_g->map);
kfree(str_name);
if (RT_FAILURE(rc))
{
err = -EPROTO;
- LogFunc(("vboxCallMapFolder failed rc=%d\n", rc));
+ LogFunc(("VbglR0SfMapFolder failed rc=%d\n", rc));
goto fail2;
}
int rc;
TRACE();
- rc = vboxCallUnmapFolder(&client_handle, &sf_g->map);
+ rc = VbglR0SfUnmapFolder(&client_handle, &sf_g->map);
if (RT_FAILURE(rc))
- LogFunc(("vboxCallUnmapFolder failed rc=%d\n", rc));
+ LogFunc(("VbglR0SfUnmapFolder failed rc=%d\n", rc));
if (sf_g->nls)
unload_nls(sf_g->nls);
return err;
}
- rcVBox = vboxInit();
+ rcVBox = VbglR0SfInit();
if (RT_FAILURE(rcVBox))
{
- LogRelFunc(("vboxInit failed, rc=%d\n", rcVBox));
+ LogRelFunc(("VbglR0SfInit failed, rc=%d\n", rcVBox));
rcRet = -EPROTO;
goto fail0;
}
- rcVBox = vboxConnect(&client_handle);
+ rcVBox = VbglR0SfConnect(&client_handle);
if (RT_FAILURE(rcVBox))
{
- LogRelFunc(("vboxConnect failed, rc=%d\n", rcVBox));
+ LogRelFunc(("VbglR0SfConnect failed, rc=%d\n", rcVBox));
rcRet = -EPROTO;
goto fail1;
}
- rcVBox = vboxCallSetUtf8(&client_handle);
+ rcVBox = VbglR0SfSetUtf8(&client_handle);
if (RT_FAILURE(rcVBox))
{
- LogRelFunc(("vboxCallSetUtf8 failed, rc=%d\n", rcVBox));
+ LogRelFunc(("VbglR0SfSetUtf8 failed, rc=%d\n", rcVBox));
rcRet = -EPROTO;
goto fail2;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
if (!follow_symlinks)
{
- rcVBox = vboxCallSetSymlinks(&client_handle);
+ rcVBox = VbglR0SfSetSymlinks(&client_handle);
if (RT_FAILURE(rcVBox))
{
printk(KERN_WARNING
return 0;
fail2:
- vboxDisconnect(&client_handle);
+ VbglR0SfDisconnect(&client_handle);
fail1:
- vboxUninit();
+ VbglR0SfTerm();
fail0:
unregister_filesystem(&vboxsf_fs_type);
{
TRACE();
- vboxDisconnect(&client_handle);
- vboxUninit();
+ VbglR0SfDisconnect(&client_handle);
+ VbglR0SfTerm();
unregister_filesystem(&vboxsf_fs_type);
}
# include <linux/backing-dev.h>
#endif
-#include "VBoxGuestR0LibSharedFolders.h"
+#include <VBox/VBoxGuestLibSharedFolders.h>
#include "vbsfmount.h"
#define DIR_BUFFER_SIZE (16*_1K)
/* per-shared folder information */
struct sf_glob_info
{
- VBSFMAP map;
+ VBGLSFMAP map;
struct nls_table *nls;
int ttl;
int uid;
};
/* globals */
-extern VBSFCLIENT client_handle;
+extern VBGLSFCLIENT client_handle;
/* forward declarations */
extern struct inode_operations sf_dir_iops;
KBUILD_EXTMOD=${srctree}/ubuntu/vbox
-#
+# $Id: Makefile.module $
+## @file
# VirtualBox Guest Additions Module Makefile.
#
# (For 2.6.x this file must be 'Makefile'!)
+#
+
#
# Copyright (C) 2006-2011 Oracle Corporation
#
MOD_CLEAN = . linux r0drv r0drv/linux
include $(obj)/Makefile.include.footer
+
#define VBOX_VENDOR_SHORT "Oracle"
#define VBOX_PRODUCT "Oracle VM VirtualBox"
#define VBOX_BUILD_PUBLISHER "_Ubuntu"
-#define VBOX_C_YEAR "2015"
+#define VBOX_C_YEAR "2016"
#endif
-/** @file $Id: vboxvideo_drm.c $
- *
+/* $Id: vboxvideo_drm.c $ */
+/** @file
* VirtualBox Additions Linux kernel driver, DRM support
*/
# define DRM_NEW_BUS_INIT 1
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
+# ifdef RHEL_RELEASE_CODE
+# if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(7, 2)
+# define DRM_HAVE_DRM_MAP
+# endif
+# else
+# define DRM_HAVE_DRM_MAP
+# endif
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
+# define DRM_WANTS_SET_BUSID
+#else
+# ifdef RHEL_RELEASE_CODE
+# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2)
+# define DRM_WANTS_SET_BUSID
+# endif
+# endif
+#endif
+
static struct pci_device_id pciidlist[] = {
vboxvideo_PCI_IDS
};
.open = drm_open,
.release = drm_release,
.unlocked_ioctl = drm_ioctl,
-# if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
+# ifdef DRM_HAVE_DRM_MAP
/* This shouldn't be necessary even for old kernels as there is
* nothing sensible to mmap. But we play safe and keep it for
* legacy reasons. */
{
/* .driver_features = DRIVER_USE_MTRR, */
.load = vboxvideo_driver_load,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
+#ifdef DRM_WANTS_SET_BUSID
/* If this is missing a warning gets printed to dmesg. We will not
* attempt to make kernels work to which the change (915b4d11b) got back-
* ported, as the problem is only cosmetic. */
-/** @file $Id: vboxvideo_drm.h $
- *
+/* $Id: vboxvideo_drm.h $ */
+/** @file
* VirtualBox Additions Linux kernel driver, DRM support
*/
#define VBOX_VERSION_MAJOR 5
#define VBOX_VERSION_MINOR 0
-#define VBOX_VERSION_BUILD 0
-#define VBOX_VERSION_STRING_RAW "5.0.0"
-#define VBOX_VERSION_STRING "5.0.0_Ubuntu"
+#define VBOX_VERSION_BUILD 14
+#define VBOX_VERSION_STRING_RAW "5.0.14"
+#define VBOX_VERSION_STRING "5.0.14_Ubuntu"
#define VBOX_API_VERSION_STRING "5_0"
#define VBOX_PRIVATE_BUILD_DESC "Private build by root"