Changeset 43428 in vbox for trunk/src/VBox/Devices/Parallel
- Timestamp:
- Sep 25, 2012 12:35:17 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 80927
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp
r43393 r43428 403 403 hDevInfo = SetupDiGetClassDevs(NULL, 0, 0, DIGCF_PRESENT | DIGCF_ALLCLASSES); 404 404 if (hDevInfo == INVALID_HANDLE_VALUE) 405 { 406 LogFlowFunc(("Invalid Handle \n")); 405 407 return VERR_INVALID_HANDLE; 408 } 406 409 407 410 /* Enumerate through all devices in Set. */ … … 415 418 while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_FRIENDLYNAME, 416 419 (PDWORD)&dwDataType, (uint8_t *)pBuf, 417 dwBufSize, (PDWORD)&dwBufSize) 418 && GetLastError() == ERROR_INSUFFICIENT_BUFFER) 420 dwBufSize, (PDWORD)&dwBufSize)) 419 421 { 420 if (pBuf) 421 RTMemFree(pBuf); 422 /* Max size will never be more than 2048 bytes */ 423 pBuf = (uint8_t *)RTMemAlloc(dwBufSize * 2); 422 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) 423 { 424 LogFlow(("ERROR_INSUFF_BUFF = %d. dwBufSz = %d\n", GetLastError(), dwBufSize)); 425 if (pBuf) 426 RTMemFree(pBuf); 427 /* Max size will never be more than 2048 bytes */ 428 if (dwBufSize > 1024 || dwBufSize < 0) 429 dwBufSize = 1024; 430 pBuf = (uint8_t *)RTMemAlloc(dwBufSize * 2); 431 } 432 else 433 { 434 LogFlow(("GetDevProp Error = %d & dwBufSz = %d\n", GetLastError(), dwBufSize)); 435 break; 436 } 424 437 } 425 438 if(!pBuf) 426 return VERR_NO_MEMORY; 427 439 { 440 LogFlowFunc(("No Memory to save ParportString\n")); 441 /* Trying once more with fixed length, assuming friendly name 442 * will not be bigger than 2048 443 */ 444 pBuf = (uint8_t *)RTMemAlloc(2048); 445 if (!pBuf) 446 { 447 LogFlowFunc(("Fixed allocation failed\n")); 448 return VERR_NO_MEMORY; 449 } 450 if (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_FRIENDLYNAME, 451 (PDWORD)&dwDataType, (uint8_t *)pBuf, 452 2048, NULL)) 453 { 454 LogFlowFunc(("GetDevProp failed with ERR = %d\n", GetLastError())); 455 return VERR_GENERAL_FAILURE; 456 457 } 458 } 428 459 if (RTStrStr((char*)pBuf, "LPT")) 429 460 { … … 472 503 pThis->u32LptAddrStatus = pThis->u32LptAddr + STATUS_REG_OFFSET; 473 504 } 505 else 506 LogFlowFunc(("u32Parport Addr No Available \n")); 474 507 if (pThis->fParportAvail) 508 { 509 LogFlow(("Parport found . Break from inner loop \n")); 475 510 break; 511 } 512 } 513 else 514 { 515 LogFlow(("LPT: Parallel Port not available \n")); 476 516 } 477 517 if (pBuf) … … 479 519 if (pThis->fParportAvail) 480 520 { 521 LogFlow(("Parport Available. Break from outer loop \n")); 481 522 /* Parallel port address has been found. No need to iterate further. */ 482 523 break; … … 586 627 rc = RTErrConvertFromErrno(errno); 587 628 # else /* VBOX_WITH_WIN_PARPORT_SUP */ 588 if (pThis->fParportAvail) 629 if (!pThis->fParportAvail) 630 LogFlowFunc(("Parport Not Available\n")); 631 //if (pThis->fParportAvail) 589 632 { 590 633 for (size_t i = 0; i < cbWrite; i++) … … 629 672 rc = RTErrConvertFromErrno(errno); 630 673 # else /* VBOX_WITH_WIN_PARPORT_SUP */ 631 if (pThis->fParportAvail) 674 if (!pThis->fParportAvail) 675 LogFlowFunc(("Parport Not Available\n")); 676 //if (pThis->fParportAvail) 632 677 { 633 678 *((uint8_t*)(pvBuf)) = 0; /* Initialize the buffer. */ … … 659 704 uint64_t u64Data; 660 705 u64Data = (uint8_t)iMode; 661 LogFlowFunc(("calling R0 to write CTRL, data=%#x\n", u64Data)); 662 if (pThis->fParportAvail) 663 { 706 if (!pThis->fParportAvail) 707 LogFlowFunc(("Parport Not available\n")); 708 //if (pThis->fParportAvail) 709 { 710 LogFlowFunc(("calling R0 to SetPortDirection, data=%#x\n", u64Data)); 664 711 rc = PDMDrvHlpCallR0(pThis->CTX_SUFF(pDrvIns), DRVHOSTPARALLELR0OP_SETPORTDIRECTION, u64Data); 665 712 AssertRC(rc); … … 686 733 uint64_t u64Data; 687 734 u64Data = (uint8_t)fReg; 688 LogFlowFunc(("calling R0 to write CTRL, data=%#x\n", u64Data)); 689 if (pThis->fParportAvail) 690 { 735 if (!pThis->fParportAvail) 736 LogFlowFunc(("Parport Not Available\n")); 737 //if (pThis->fParportAvail) 738 { 739 LogFlowFunc(("calling R0 to write CTRL, data=%#x\n", u64Data)); 691 740 rc = PDMDrvHlpCallR0(pThis->CTX_SUFF(pDrvIns), DRVHOSTPARALLELR0OP_WRITECONTROL, u64Data); 692 741 AssertRC(rc); … … 718 767 # else /* VBOX_WITH_WIN_PARPORT_SUP */ 719 768 *pfReg = 0; /* Initialize the buffer*/ 720 if (pThis->fParportAvail) 769 if (!pThis->fParportAvail) 770 LogFlowFunc(("Parport Not Available\n")); 771 //if (pThis->fParportAvail) 721 772 { 722 773 LogFlowFunc(("calling R0 to read control from parallel port\n")); … … 738 789 int rcLnx = 0; 739 790 uint8_t fReg = 0; 791 LogFlowFunc(("%d Status Reg\n", *pfReg)); 740 792 # ifndef VBOX_WITH_WIN_PARPORT_SUP 741 793 rcLnx = ioctl(RTFileToNative(pThis->hFileDevice), PPRSTATUS, &fReg); … … 749 801 # else /* VBOX_WITH_WIN_PARPORT_SUP */ 750 802 *pfReg = 0; /* Intialize the buffer. */ 751 if (pThis->fParportAvail) 752 { 753 LogFlowFunc(("calling R0 to read status from parallel port\n")); 803 if (!pThis->fParportAvail) 804 LogFlowFunc(("fParport Not Available.. Error!!!!!!!!!! \n")); 805 //if (pThis->fParportAvail) 806 { 807 LogFlowFunc(("calling R0 to read status from parallel port. fParport should be available\n")); 754 808 rc = PDMDrvHlpCallR0(pThis->CTX_SUFF(pDrvIns), DRVHOSTPARALLELR0OP_READSTATUS, 0); 755 809 AssertRC(rc); 810 LogFlow(("value read from status = %d\n", *pfReg)); 756 811 *pfReg = pThis->u8ReadInStatus; 757 812 } 813 758 814 # endif /* VBOX_WITH_WIN_PARPORT_SUP */ 759 815 return rc; … … 995 1051 rc = RTFileOpen(&pThis->hWinFileDevice, (char *)pThis->szParportName, 996 1052 RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 1053 LogFlowFunc(("RTFileOpen Return = %d\n", rc)); 997 1054 } 998 1055 #endif
Note:
See TracChangeset
for help on using the changeset viewer.