Changeset 11725 in vbox for trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp
- Timestamp:
- Aug 27, 2008 10:21:47 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 35466
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp
r10720 r11725 1 1 /* $Id$ */ 2 2 /** @file 3 * SUPLib - Support Library, OS/2 backend.3 * VirtualBox Support Library - OS/2 specific parts. 4 4 */ 5 5 … … 29 29 */ 30 30 31 32 31 /******************************************************************************* 33 32 * Header Files * … … 37 36 #include <os2.h> 38 37 #undef RT_MAX 38 39 #ifdef IN_SUP_HARDENED_R3 40 # undef DEBUG /* Warning: disables RT_STRICT */ 41 # define LOG_DISABLED 42 /** @todo RTLOGREL_DISABLED */ 43 # include <iprt/log.h> 44 # undef LogRelIt 45 # define LogRelIt(pvInst, fFlags, iGroup, fmtargs) do { } while (0) 46 #endif 39 47 40 48 #include <VBox/types.h> … … 62 70 63 71 64 /******************************************************************************* 65 * Global Variables * 66 *******************************************************************************/ 67 /** Handle to the open device. */ 68 static HFILE g_hDevice = (HFILE)-1; 69 70 71 /******************************************************************************* 72 * Internal Functions * 73 *******************************************************************************/ 74 75 76 /** 77 * Initialize the OS specific part of the library. 78 * On Linux this involves: 79 * - loading the module. 80 * - open driver. 81 * 82 * @returns 0 on success. 83 * @returns current -1 on failure but this must be changed to proper error codes. 84 * @param cbReserve Ignored on OS/2. 85 */ 86 int suplibOsInit(size_t cbReserve) 72 int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited) 87 73 { 88 74 /* 89 * Check if already initialized.75 * Nothing to do if pre-inited. 90 76 */ 91 if ( g_hDevice != (HFILE)-1)92 return 0;77 if (fPreInited) 78 return VINF_SUCCESS; 93 79 94 80 /* … … 117 103 return vrc; 118 104 } 119 g_hDevice = hDevice;120 105 121 NOREF(cbReserve);106 pThis->hDevice = (RTFILE)hDevice; 122 107 return VINF_SUCCESS; 123 108 } 124 109 125 110 126 int suplibOsTerm(void) 111 #ifndef IN_SUP_HARDENED_R3 112 113 int suplibOsTerm(PSUPLIBDATA pThis) 127 114 { 128 115 /* 129 116 * Check if we're initited at all. 130 117 */ 131 if ( g_hDevice != (HFILE)-1)118 if (pThis->hDevice != NIL_RTFILE) 132 119 { 133 APIRET rc = DosClose( g_hDevice);120 APIRET rc = DosClose((HFILE)pThis->hDevice); 134 121 AssertMsg(rc == NO_ERROR, ("%d\n", rc)); NOREF(rc); 135 g_hDevice = (HFILE)-1;122 pThis->hDevice = NIL_RTFILE; 136 123 } 137 124 … … 154 141 155 142 156 int suplibOsIOCtl( uintptr_t uFunction, void *pvReq, size_t cbReq)143 int suplibOsIOCtl(PSUPLIBDATA pThis, uintptr_t uFunction, void *pvReq, size_t cbReq) 157 144 { 158 AssertMsg(g_hDevice != (HFILE)-1, ("SUPLIB not initiated successfully!\n"));159 160 145 ULONG cbReturned = sizeof(SUPREQHDR); 161 int rc = DosDevIOCtl( g_hDevice, SUP_CTL_CATEGORY, uFunction,146 int rc = DosDevIOCtl((HFILE)pThis->hDevice, SUP_CTL_CATEGORY, uFunction, 162 147 pvReq, cbReturned, &cbReturned, 163 148 NULL, 0, NULL); … … 168 153 169 154 170 int suplibOsIOCtlFast( uintptr_t uFunction)155 int suplibOsIOCtlFast(PSUPLIBDATA pThis, uintptr_t uFunction) 171 156 { 172 157 int32_t rcRet = VERR_INTERNAL_ERROR; 173 int rc = DosDevIOCtl( g_hDevice, SUP_CTL_CATEGORY_FAST, uFunction,158 int rc = DosDevIOCtl((HFILE)pThis->hDevice, SUP_CTL_CATEGORY_FAST, uFunction, 174 159 NULL, 0, NULL, 175 160 NULL, 0, NULL); … … 182 167 183 168 184 int suplibOsPageAlloc( size_t cPages, void **ppvPages)169 int suplibOsPageAlloc(PSUPLIBDATA pThis, size_t cPages, void **ppvPages) 185 170 { 171 NOREF(pThis); 186 172 *ppvPages = NULL; 187 173 int rc = DosAllocMem(ppvPages, cPages << PAGE_SHIFT, PAG_READ | PAG_WRITE | PAG_EXECUTE | PAG_COMMIT | OBJ_ANY); … … 196 182 197 183 198 int suplibOsPageFree( void *pvPages, size_t /* cPages */)184 int suplibOsPageFree(PSUPLIBDATA pThis, void *pvPages, size_t /* cPages */) 199 185 { 186 NOREF(pThis); 200 187 if (pvPages) 201 188 { … … 206 193 } 207 194 195 #endif /* !IN_SUP_HARDENED_R3 */ 196
Note:
See TracChangeset
for help on using the changeset viewer.