VirtualBox

Ignore:
Timestamp:
Apr 19, 2007 8:54:41 AM (18 years ago)
Author:
vboxsync
Message:

Moved ins/outs handling to the VMMAll directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IOMAll.cpp

    r1828 r2201  
    884884    return VINF_SUCCESS;
    885885}
    886 
    887 
    888886/**
    889887 * Writes the string buffer of an I/O port register.
     
    10051003}
    10061004
    1007 
    1008 //#undef LOG_GROUP
    1009 //#define LOG_GROUP LOG_GROUP_IOM_MMIO
    1010 
    1011 /**
    1012  * Reads a MMIO register.
    1013  *
    1014  * @returns VBox status code.
    1015  *
    1016  * @param   pVM         VM handle.
    1017  * @param   GCPhys      The physical address to read.
    1018  * @param   pu32Value   Where to store the value read.
    1019  * @param   cbValue     The size of the register to read in bytes. 1, 2 or 4 bytes.
    1020  */
    1021 IOMDECL(int) IOMMMIORead(PVM pVM, RTGCPHYS GCPhys, uint32_t *pu32Value, size_t cbValue)
    1022 {
    1023 /** @todo add return to ring-3 statistics when this function is used in GC! */
    1024 
    1025     /*
    1026      * Lookup the current context range node and statistics.
    1027      */
    1028     CTXALLSUFF(PIOMMMIORANGE) pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys);
    1029 #ifdef VBOX_WITH_STATISTICS
    1030     PIOMMMIOSTATS pStats = iomMMIOGetStats(&pVM->iom.s, GCPhys);
    1031     if (!pStats && (!pRange || pRange->cbSize <= PAGE_SIZE))
    1032 # ifdef IN_RING3
    1033         pStats = iomR3MMIOStatsCreate(pVM, GCPhys, pRange ? pRange->pszDesc : NULL);
    1034 # else
    1035         return VINF_IOM_HC_MMIO_READ;
    1036 # endif
    1037 #endif /* VBOX_WITH_STATISTICS */
    1038 #ifdef IN_RING3
    1039     if (pRange)
    1040 #else /* !IN_RING3 */
    1041     if (pRange && pRange->pfnReadCallback)
    1042 #endif /* !IN_RING3 */
    1043     {
    1044         /*
    1045          * Perform the read and deal with the result.
    1046          */
    1047 #ifdef VBOX_WITH_STATISTICS
    1048         if (pStats)
    1049             STAM_PROFILE_ADV_START(&pStats->CTXALLSUFF(ProfRead), a);
    1050 #endif
    1051         int rc = pRange->pfnReadCallback(pRange->pDevIns, pRange->pvUser, GCPhys, pu32Value, cbValue);
    1052 #ifdef VBOX_WITH_STATISTICS
    1053         if (pStats)
    1054             STAM_PROFILE_ADV_STOP(&pStats->CTXALLSUFF(ProfRead), a);
    1055         if (pStats && rc != VINF_IOM_HC_MMIO_READ)
    1056             STAM_COUNTER_INC(&pStats->CTXALLSUFF(Read));
    1057 #endif
    1058         switch (rc)
    1059         {
    1060             case VINF_SUCCESS:
    1061             default:
    1062                 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Vrc\n", GCPhys, *pu32Value, cbValue, rc));
    1063                 return rc;
    1064 
    1065             case VINF_IOM_MMIO_UNUSED_00:
    1066                 switch (cbValue)
    1067                 {
    1068                     case 1: *(uint8_t *)pu32Value  = 0x00; break;
    1069                     case 2: *(uint16_t *)pu32Value = 0x0000; break;
    1070                     case 4: *(uint32_t *)pu32Value = 0x00000000; break;
    1071                     default: AssertReleaseMsgFailed(("cbValue=%d GCPhys=%VGp\n", cbValue, GCPhys)); break;
    1072                 }
    1073                 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Vrc\n", GCPhys, *pu32Value, cbValue, rc));
    1074                 return VINF_SUCCESS;
    1075 
    1076             case VINF_IOM_MMIO_UNUSED_FF:
    1077                 switch (cbValue)
    1078                 {
    1079                     case 1: *(uint8_t *)pu32Value  = 0xff; break;
    1080                     case 2: *(uint16_t *)pu32Value = 0xffff; break;
    1081                     case 4: *(uint32_t *)pu32Value = 0xffffffff; break;
    1082                     default: AssertReleaseMsgFailed(("cbValue=%d GCPhys=%VGp\n", cbValue, GCPhys)); break;
    1083                 }
    1084                 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Vrc\n", GCPhys, *pu32Value, cbValue, rc));
    1085                 return VINF_SUCCESS;
    1086         }
    1087     }
    1088 
    1089 #ifndef IN_RING3
    1090     /*
    1091      * Lookup the ring-3 range.
    1092      */
    1093     PIOMMMIORANGER3 pRangeR3 = iomMMIOGetRangeHC(&pVM->iom.s, GCPhys);
    1094     if (pRangeR3)
    1095     {
    1096         if (pRangeR3->pfnReadCallback)
    1097             return VINF_IOM_HC_MMIO_READ;
    1098 # ifdef VBOX_WITH_STATISTICS
    1099         if (pStats)
    1100             STAM_COUNTER_INC(&pStats->CTXALLSUFF(Read));
    1101 # endif
    1102         *pu32Value = 0;
    1103         Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=VINF_SUCCESS\n", GCPhys, *pu32Value, cbValue));
    1104         return VINF_SUCCESS;
    1105     }
    1106 #endif
    1107 
    1108     AssertMsgFailed(("Handlers and page tables are out of sync or something! GCPhys=%VGp cbValue=%d\n", GCPhys, cbValue));
    1109     return VERR_INTERNAL_ERROR;
    1110 }
    1111 
    1112 
    1113 /**
    1114  * Writes to a MMIO register.
    1115  *
    1116  * @returns VBox status code.
    1117  *
    1118  * @param   pVM         VM handle.
    1119  * @param   GCPhys      The physical address to write to.
    1120  * @param   u32Value    The value to write.
    1121  * @param   cbValue     The size of the register to read in bytes. 1, 2 or 4 bytes.
    1122  */
    1123 IOMDECL(int) IOMMMIOWrite(PVM pVM, RTGCPHYS GCPhys, uint32_t u32Value, size_t cbValue)
    1124 {
    1125 /** @todo add return to ring-3 statistics when this function is used in GC! */
    1126     /*
    1127      * Lookup the current context range node.
    1128      */
    1129     CTXALLSUFF(PIOMMMIORANGE) pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys);
    1130 #ifdef VBOX_WITH_STATISTICS
    1131     PIOMMMIOSTATS pStats = iomMMIOGetStats(&pVM->iom.s, GCPhys);
    1132     if (!pStats && (!pRange || pRange->cbSize <= PAGE_SIZE))
    1133 # ifdef IN_RING3
    1134         pStats = iomR3MMIOStatsCreate(pVM, GCPhys, pRange ? pRange->pszDesc : NULL);
    1135 # else
    1136         return VINF_IOM_HC_MMIO_WRITE;
    1137 # endif
    1138 #endif /* VBOX_WITH_STATISTICS */
    1139 
    1140     /*
    1141      * Perform the write if we found a range.
    1142      */
    1143 #ifdef IN_RING3
    1144     if (pRange)
    1145 #else /* !IN_RING3 */
    1146     if (pRange && pRange->pfnWriteCallback)
    1147 #endif /* !IN_RING3 */
    1148     {
    1149 #ifdef VBOX_WITH_STATISTICS
    1150         if (pStats)
    1151             STAM_PROFILE_ADV_START(&pStats->CTXALLSUFF(ProfWrite), a);
    1152 #endif
    1153         int rc = pRange->pfnWriteCallback(pRange->pDevIns, pRange->pvUser, GCPhys, &u32Value, cbValue);
    1154 #ifdef VBOX_WITH_STATISTICS
    1155         if (pStats)
    1156             STAM_PROFILE_ADV_STOP(&pStats->CTXALLSUFF(ProfWrite), a);
    1157         if (pStats && rc != VINF_IOM_HC_MMIO_WRITE)
    1158             STAM_COUNTER_INC(&pStats->CTXALLSUFF(Write));
    1159 #endif
    1160         Log4(("IOMMMIOWrite: GCPhys=%RGp u32=%08RX32 cb=%d rc=%Vrc\n", GCPhys, u32Value, cbValue, rc));
    1161         return rc;
    1162     }
    1163 
    1164 #ifndef IN_RING3
    1165     /*
    1166      * Lookup the ring-3 range.
    1167      */
    1168     PIOMMMIORANGER3 pRangeR3 = iomMMIOGetRangeHC(&pVM->iom.s, GCPhys);
    1169     if (pRangeR3)
    1170     {
    1171         if (pRangeR3->pfnWriteCallback)
    1172             return VINF_IOM_HC_MMIO_WRITE;
    1173 # ifdef VBOX_WITH_STATISTICS
    1174         if (pStats)
    1175             STAM_COUNTER_INC(&pStats->CTXALLSUFF(Write));
    1176 # endif
    1177         Log4(("IOMMMIOWrite: GCPhys=%RGp u32=%08RX32 cb=%d rc=%Vrc\n", GCPhys, u32Value, cbValue));
    1178         return VINF_SUCCESS;
    1179     }
    1180 #endif
    1181 
    1182     AssertMsgFailed(("Handlers and page tables are out of sync or something! GCPhys=%VGp cbValue=%d\n", GCPhys, cbValue));
    1183     return VERR_INTERNAL_ERROR;
    1184 }
    1185 
    1186 
    11871005/**
    11881006 * Checks that the operation is allowed according to the IOPL
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette