Changeset 21511 in vbox
- Timestamp:
- Jul 11, 2009 3:23:24 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49961
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxCalls.c
r21211 r21511 30 30 #endif 31 31 #include <iprt/time.h> 32 #include <iprt/mem.h> 32 33 #include <iprt/path.h> 33 34 #include <iprt/string.h> … … 463 464 } 464 465 return rc; 466 } 467 468 DECLVBGL(int) VbglR0SfWritePhysCont(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, RTCCPHYS PhysBuffer) 469 { 470 uint32_t cbToWrite = *pcbBuffer; 471 uint32_t cPages = RT_ALIGN_32((PhysBuffer & PAGE_OFFSET_MASK) + cbToWrite, PAGE_SIZE) >> PAGE_SHIFT; 472 uint32_t cbData = sizeof(VBoxSFWrite) + RT_UOFFSETOF(HGCMPageListInfo, aPages[cPages]); 473 VBoxSFWrite *pData = (VBoxSFWrite *)RTMemTmpAlloc(cbData); 474 HGCMPageListInfo *pPgLst = (HGCMPageListInfo *)(pData + 1); 475 uint32_t iPage; 476 int rc; 477 478 if (RT_UNLIKELY(!pData)) 479 return VERR_NO_TMP_MEMORY; 480 481 VBOX_INIT_CALL(&pData->callInfo, WRITE, pClient); 482 483 pData->root.type = VMMDevHGCMParmType_32bit; 484 pData->root.u.value32 = pMap->root; 485 486 pData->handle.type = VMMDevHGCMParmType_64bit; 487 pData->handle.u.value64 = hFile; 488 pData->offset.type = VMMDevHGCMParmType_64bit; 489 pData->offset.u.value64 = offset; 490 pData->cb.type = VMMDevHGCMParmType_32bit; 491 pData->cb.u.value32 = cbToWrite; 492 pData->buffer.type = VMMDevHGCMParmType_PageList; 493 pData->buffer.u.PageList.size = cbToWrite; 494 pData->buffer.u.PageList.offset = sizeof(VBoxSFWrite); 495 496 pPgLst->flags = VBOX_HGCM_F_PARM_DIRECTION_TO_HOST; 497 pPgLst->offFirstPage = PhysBuffer & PAGE_OFFSET_MASK; 498 pPgLst->cPages = cPages; 499 PhysBuffer &= ~(RTCCPHYS)PAGE_OFFSET_MASK; 500 for (iPage = 0; iPage < cPages; iPage++, PhysBuffer += PAGE_SIZE) 501 pPgLst->aPages[iPage] = PhysBuffer; 502 503 rc = VbglHGCMCall (pClient->handle, &pData->callInfo, cbData); 504 if (RT_SUCCESS (rc)) 505 { 506 rc = pData->callInfo.result; 507 *pcbBuffer = pData->cb.u.value32; 508 } 509 510 RTMemTmpFree(pData); 511 return rc; 512 465 513 } 466 514 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxCalls.h
r21211 r21511 162 162 DECLVBGL(int) vboxCallRead (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked); 163 163 DECLVBGL(int) vboxCallWrite (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked); 164 DECLVBGL(int) VbglR0SfWritePhysCont(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, RTCCPHYS PhysBuffer); 164 165 165 166 DECLVBGL(int) vboxCallLock (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint64_t cbSize, uint32_t fLock); -
trunk/src/VBox/Additions/linux/sharedfolders/Makefile.module
r21509 r21511 75 75 VMMDev.o \ 76 76 HGCM.o \ 77 VBoxCalls.o 77 VBoxCalls.o \ 78 VbglR0CanUsePhysPageList.o 78 79 ifeq ($(BUILD_TARGET_ARCH),x86) 79 80 OBJS += \ -
trunk/src/VBox/Additions/linux/sharedfolders/files_vboxvfs
r21337 r21511 66 66 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestLog.h=>VBoxGuestLog.h \ 67 67 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VMMDev.cpp=>VMMDev.c \ 68 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VbglR0CanUsePhysPageList.cpp=>VbglR0CanUsePhysPageList.c \ 68 69 ${PATH_ROOT}/src/VBox/Runtime/common/math/gcc/divdi3.c=>divdi3.c \ 69 70 ${PATH_ROOT}/src/VBox/Runtime/common/math/gcc/moddi3.c=>moddi3.c \ -
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r21233 r21511 27 27 #include "vfsmod.h" 28 28 29 #define CHUNK_SIZE 4096 29 30 static void *alloc_bounch_buffer (size_t *tmp_sizep, PRTCCPHYS physp, size_t xfer_size, const char *caller) 31 { 32 size_t tmp_size; 33 void *tmp; 34 35 /* try for big first. */ 36 tmp_size = RT_ALIGN_Z(xfer_size, PAGE_SIZE); 37 if (tmp_size > 16U*_1K) 38 tmp_size = 16U*_1K; 39 tmp = kmalloc (tmp_size, GFP_KERNEL); 40 if (!tmp) { 41 42 /* fall back on a page sized buffer. */ 43 tmp = kmalloc (PAGE_SIZE, GFP_KERNEL); 44 if (!tmp) { 45 LogRel(("%s: could not allocate bounce buffer for xfer_size=%zu %s\n", caller, xfer_size)); 46 return NULL; 47 } 48 tmp_size = PAGE_SIZE; 49 } 50 51 *tmp_sizep = tmp_size; 52 *physp = virt_to_phys(tmp); 53 return tmp; 54 } 55 56 static void free_bounch_buffer (void *tmp) 57 { 58 kfree (tmp); 59 } 60 30 61 31 62 /* fops */ … … 71 102 int err; 72 103 void *tmp; 104 RTCCPHYS tmp_phys; 105 size_t tmp_size; 73 106 size_t left = size; 74 107 ssize_t total_bytes_read = 0; … … 90 123 } 91 124 92 tmp = kmalloc (CHUNK_SIZE, GFP_KERNEL); 93 if (!tmp) { 94 LogRelFunc(("could not allocate bounce buffer memory %d bytes\n", CHUNK_SIZE)); 95 return -ENOMEM; 96 } 125 tmp = alloc_bounch_buffer (&tmp_size, &tmp_phys, size, __PRETTY_FUNCTION__); 126 if (!tmp) 127 return -ENOMEM; 97 128 98 129 while (left) { 99 130 uint32_t to_read, nread; 100 131 101 to_read = CHUNK_SIZE;132 to_read = tmp_size; 102 133 if (to_read > left) { 103 134 to_read = (uint32_t) left; … … 124 155 125 156 *off += total_bytes_read; 126 kfree(tmp);157 free_bounch_buffer (tmp); 127 158 return total_bytes_read; 128 159 129 160 fail: 130 kfree(tmp);161 free_bounch_buffer (tmp); 131 162 return err; 132 163 } … … 137 168 int err; 138 169 void *tmp; 170 RTCCPHYS tmp_phys; 171 size_t tmp_size; 139 172 size_t left = size; 140 173 ssize_t total_bytes_written = 0; … … 164 197 return 0; 165 198 166 tmp = kmalloc (CHUNK_SIZE, GFP_KERNEL); 167 if (!tmp) { 168 LogRelFunc(("could not allocate bounce buffer memory %d bytes\n", CHUNK_SIZE)); 199 tmp = alloc_bounch_buffer (&tmp_size, &tmp_phys, size, __PRETTY_FUNCTION__); 200 if (!tmp) 169 201 return -ENOMEM; 170 }171 202 172 203 while (left) { 173 204 uint32_t to_write, nwritten; 174 205 175 to_write = CHUNK_SIZE;206 to_write = tmp_size; 176 207 if (to_write > left) { 177 208 to_write = (uint32_t) left; … … 184 215 } 185 216 186 err = sf_reg_write_aux (__func__, sf_g, sf_r, tmp, &nwritten, pos); 217 #if 1 218 if (VbglR0CanUsePhysPageList()) { 219 err = VbglR0SfWritePhysCont (&client_handle, &sf_g->map, sf_r->handle, 220 pos, &nwritten, tmp_phys); 221 err = RT_FAILURE(err) ? -EPROTO : 0; 222 } else 223 #endif 224 err = sf_reg_write_aux (__func__, sf_g, sf_r, tmp, &nwritten, pos); 187 225 if (err) 188 226 goto fail; … … 202 240 #endif 203 241 sf_i->force_restat = 1; 204 kfree(tmp);242 free_bounch_buffer (tmp); 205 243 return total_bytes_written; 206 244 207 245 fail: 208 kfree(tmp);246 free_bounch_buffer (tmp); 209 247 return err; 210 248 }
Note:
See TracChangeset
for help on using the changeset viewer.