Changeset 6504 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jan 25, 2008 10:11:25 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27513
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r6452 r6504 26 26 #include <sys/stat.h> 27 27 #include <sys/ddi.h> 28 #include <sys/ddi_intr.h> 28 29 #include <sys/sunddi.h> 29 30 #undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */ … … 156 157 /** VMMDev Version. */ 157 158 uint32_t u32Version; 159 /** Interrupt handle vector */ 160 ddi_intr_handle_t *pIntr; 161 /** Number of interrupt handles */ 162 size_t cIntr; 158 163 #ifndef USE_SESSION_HASH 159 164 /** Pointer to the session handle. */ … … 828 833 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip, void *pvState) 829 834 { 830 int rc; 831 VBoxAddDevState *pState = (VBoxAddDevState *)pvState; 832 LogFlow((DEVICE_NAME ":VBoxGuestSolarisAddIRQ %p\n", pvState)); 833 835 #if 0 834 836 /* 835 837 * These calls are supposedly deprecated. But Sun seems to use them all over … … 848 850 Log((DEVICE_NAME ":ddi_get_iblock_cookie failed. Cannot set IRQ for VMMDev.\n")); 849 851 return rc; 852 #endif 853 int rc; 854 int IntrType; 855 VBoxAddDevState *pState = (VBoxAddDevState *)pvState; 856 LogFlow((DEVICE_NAME ":VBoxGuestSolarisAddIRQ %p\n", pvState)); 857 858 rc = ddi_intr_get_supported_types(pDip, &IntrType); 859 if (rc == DDI_SUCCESS) 860 { 861 /* We won't need to bother about MSIs. */ 862 if (IntrType & DDI_INTR_TYPE_FIXED) 863 { 864 int IntrCount; 865 rc = ddi_intr_get_nintrs(pDip, IntrType, &IntrCount); 866 if (rc == DDI_SUCCESS) 867 { 868 int IntrAvail; 869 rc = ddi_intr_get_navail(pDip, IntrType, &IntrAvail); 870 if (rc == DDI_SUCCESS) 871 { 872 /* Allocated kernel memory for the interrupt handles. */ 873 pState->cIntr = IntrCount; 874 pState->pIntr = RTMemAlloc(pState->cIntr * sizeof(ddi_intr_handle_t)); 875 if (pState->pIntr) 876 { 877 int IntrAllocated; 878 rc = ddi_intr_alloc(pDip, pState->pIntr, IntrType, 0, IntrCount, &IntrAllocated, DDI_INTR_ALLOC_NORMAL); 879 if ( rc == DDI_SUCCESS 880 && IntrAllocated > 0) 881 { 882 pState->cIntr = IntrAllocated; 883 uint_t uIntrPriority; 884 rc = ddi_intr_get_pri(pState->pIntr[0], &uIntrPriority); 885 if (rc == DDI_SUCCESS) 886 { 887 /* Initialize the mutex. */ 888 mutex_init(&pState->Mtx, "VBoxGuestMtx", MUTEX_DRIVER, DDI_INTR_PRI(uIntrPriority)); 889 890 /* Assign interrupt handler functions and enable interrupts. */ 891 for (int i = 0; i < IntrAllocated; i++) 892 { 893 rc = ddi_intr_add_handler(pState->pIntr[i], (ddi_intr_handler_t *)VBoxGuestSolarisISR, 894 (caddr_t)pState, NULL); 895 if (rc == DDI_SUCCESS) 896 rc = ddi_intr_enable(pState->pIntr[i]); 897 if (rc != DDI_SUCCESS) 898 { 899 /* Changing local IntrAllocated to hold so-far allocated handles for freeing. */ 900 IntrAllocated = i; 901 break; 902 } 903 } 904 if (rc == DDI_SUCCESS) 905 return rc; 906 907 /* Remove any assigned handlers */ 908 LogRel((DEVICE_NAME ":failed to assign IRQs allocated=%d\n", IntrAllocated)); 909 for (int x = 0; x < IntrAllocated; x++) 910 ddi_intr_remove_handler(pState->pIntr[x]); 911 } 912 else 913 LogRel((DEVICE_NAME ":VBoxGuestSolarisAddIRQ: failed to get priority of interrupt. rc=%d\n", rc)); 914 915 /* Remove allocated IRQs, too bad we can free only one handle at a time. */ 916 for (int k = 0; k < pState->cIntr; k++) 917 ddi_intr_free(pState->pIntr[k]); 918 } 919 else 920 LogRel((DEVICE_NAME ":VBoxGuestSolarisAddIRQ: failed to allocated IRQs. count=%d\n", IntrCount)); 921 RTMemFree(pState->pIntr); 922 } 923 else 924 LogRel((DEVICE_NAME ":VBoxGuestSolarisAddIRQ: failed to allocated IRQs. count=%d\n", IntrCount)); 925 } 926 else 927 LogRel((DEVICE_NAME ":VBoxGuestSolarisAddIRQ: failed to get available IRQs. rc=%d\n", rc)); 928 } 929 else 930 LogRel((DEVICE_NAME ":VBoxGuestSolarisAddIRQ: failed to get number of IRQs. rc=%d\n", rc)); 931 } 932 else 933 LogRel((DEVICE_NAME ":VBoxGuestSolarisAddIRQ: invalid irq type. IntrType=%d\n", IntrType)); 934 } 935 else 936 LogRel((DEVICE_NAME ":VBoxGuestSolarisAddIRQ: failed to get supported interrupt types\n")); 937 return rc; 850 938 } 851 939 … … 859 947 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip, void *pvState) 860 948 { 949 VBoxAddDevState *pState = (VBoxAddDevState *)pvState; 861 950 LogFlow((DEVICE_NAME ":VBoxGuestSolarisRemoveIRQ pvState=%p\n")); 862 951 863 VBoxAddDevState *pState = (VBoxAddDevState *)pvState; 952 #if 0 864 953 ddi_remove_intr(pDip, 0, pState->BlockCookie); 954 mutex_destroy(&pState->Mtx); 955 #endif 956 for (int i = 0; i < pState->cIntr; i++) 957 { 958 int rc = ddi_intr_disable(pState->pIntr[i]); 959 if (rc == DDI_SUCCESS) 960 { 961 rc = ddi_intr_remove_handler(pState->pIntr[i]); 962 if (rc == DDI_SUCCESS) 963 ddi_intr_free(pState->pIntr[i]); 964 } 965 } 966 RTMemFree(pState->pIntr); 865 967 mutex_destroy(&pState->Mtx); 866 968 }
Note:
See TracChangeset
for help on using the changeset viewer.