Changeset 15667 in vbox
- Timestamp:
- Dec 18, 2008 5:41:26 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA.cpp
r15665 r15667 84 84 /** Some fixes to ensure that logical scan-line lengths are not overwritten. */ 85 85 #define KEEP_SCAN_LINE_LENGTH 86 87 /** Check buffer if an VRAM offset is within the right range or not. */ 88 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 89 # define VERIFY_VRAM_WRITE_OFF_RETURN(pThis, off) \ 90 do { \ 91 if ((off) >= VGA_MAPPING_SIZE) \ 92 { \ 93 AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), VINF_SUCCESS); \ 94 Log2(("%Rfn[%d]: %RX32 -> R3\n", __PRETTY_FUNCTION__, __LINE__, (off))); \ 95 return VINF_IOM_HC_MMIO_WRITE; \ 96 } \ 97 } while (0) 98 #else 99 # define VERIFY_VRAM_WRITE_OFF_RETURN(pThis, off) \ 100 AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), VINF_SUCCESS) 101 #endif 102 103 /** Check buffer if an VRAM offset is within the right range or not. */ 104 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 105 # define VERIFY_VRAM_READ_OFF_RETURN(pThis, off, rcVar) \ 106 do { \ 107 if ((off) >= VGA_MAPPING_SIZE) \ 108 { \ 109 AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), 0xff); \ 110 Log2(("%Rfn[%d]: %RX32 -> R3\n", __PRETTY_FUNCTION__, __LINE__, (off))); \ 111 (rcVar) = VINF_IOM_HC_MMIO_READ; \ 112 return 0; \ 113 } \ 114 } while (0) 115 #else 116 # define VERIFY_VRAM_READ_OFF_RETURN(pThis, off, rcVar) \ 117 AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), 0xff) 118 #endif 86 119 87 120 … … 1109 1142 /* called for accesses between 0xa0000 and 0xc0000 */ 1110 1143 #ifdef VBOX 1111 static 1144 static uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr, int *prc) 1145 #else 1146 uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr) 1112 1147 #endif /* VBOX */ 1113 uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr)1114 1148 { 1115 1149 VGAState *s = (VGAState*)opaque; … … 1147 1181 } 1148 1182 1149 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)1150 if (addr >= VGA_MAPPING_SIZE)1151 return VINF_IOM_HC_MMIO_WRITE;1152 #endif1153 1154 1183 if (s->sr[4] & 0x08) { 1155 1184 /* chain 4 mode : simplest access */ … … 1157 1186 ret = s->vram_ptr[addr]; 1158 1187 #else /* VBOX */ 1159 ret = s->CTX_SUFF(vram_ptr)[addr];1160 1188 # ifdef IN_RING0 1161 1189 /* If all planes are accessible, then map the page to the frame buffer and make it writable. */ 1162 1190 if ((s->sr[2] & 3) == 3) 1163 1191 { 1164 /* @todo only allow read access (doesn't work now) */1192 /** @todo only allow read access (doesn't work now) */ 1165 1193 IOMMMIOModifyPage(PDMDevHlpGetVM(s->CTX_SUFF(pDevIns)), GCPhys, s->GCPhysVRAM + addr, X86_PTE_RW|X86_PTE_P); 1166 1194 vga_set_dirty(s, addr); … … 1168 1196 } 1169 1197 # endif /* IN_RING0 */ 1198 VERIFY_VRAM_READ_OFF_RETURN(s, addr, *prc); 1199 ret = s->CTX_SUFF(vram_ptr)[addr]; 1170 1200 #endif /* VBOX */ 1171 1201 } else if (!(s->sr[4] & 0x04)) { /* Host access is controlled by SR4, not GR5! */ … … 1176 1206 #else /* VBOX */ 1177 1207 /* See the comment for a similar line in vga_mem_writeb. */ 1178 ret = s->CTX_SUFF(vram_ptr)[((addr & ~1) << 2) | plane]; 1208 RTGCPHYS off = ((addr & ~1) << 2) | plane; 1209 VERIFY_VRAM_READ_OFF_RETURN(s, off, *prc); 1210 ret = s->CTX_SUFF(vram_ptr)[off]; 1179 1211 #endif /* VBOX */ 1180 1212 } else { … … 1183 1215 s->latch = ((uint32_t *)s->vram_ptr)[addr]; 1184 1216 #else /* VBOX */ 1217 VERIFY_VRAM_READ_OFF_RETURN(s, addr, *prc); 1185 1218 s->latch = ((uint32_t *)s->CTX_SUFF(vram_ptr))[addr]; 1186 1219 #endif /* VBOX */ … … 1284 1317 s->vram_ptr[addr] = val; 1285 1318 #else /* VBOX */ 1286 # if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)1287 if (addr >= VGA_MAPPING_SIZE)1288 return VINF_IOM_HC_MMIO_WRITE;1289 # else1290 if (addr >= s->vram_size)1291 {1292 AssertMsgFailed(("addr=%RGp - this needs to be done in HC! bank_offset=%08x memory_map_mode=%d\n",1293 addr, s->bank_offset, memory_map_mode));1294 return VINF_SUCCESS;1295 }1296 # endif1297 s->CTX_SUFF(vram_ptr)[addr] = val;1298 1299 1319 # ifdef IN_RING0 1300 1320 /* If all planes are accessible, then map the page to the frame buffer and make it writable. */ … … 1306 1326 # endif /* IN_RING0 */ 1307 1327 1328 VERIFY_VRAM_WRITE_OFF_RETURN(s, addr); 1329 s->CTX_SUFF(vram_ptr)[addr] = val; 1308 1330 #endif /* VBOX */ 1309 1331 #ifdef DEBUG_VGA_MEM … … 1335 1357 s->vram_ptr[addr] = val; 1336 1358 #else /* VBOX */ 1337 # if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 1338 if (addr >= VGA_MAPPING_SIZE) 1339 return VINF_IOM_HC_MMIO_WRITE; 1340 # else 1341 if (addr >= s->vram_size) 1342 { 1343 AssertMsgFailed(("addr=%RGp - this needs to be done in HC! bank_offset=%08x memory_map_mode=%d\n", 1344 addr, s->bank_offset, memory_map_mode)); 1345 return VINF_SUCCESS; 1346 } 1347 # endif 1359 VERIFY_VRAM_WRITE_OFF_RETURN(s, addr); 1348 1360 s->CTX_SUFF(vram_ptr)[addr] = val; 1349 1361 #endif /* VBOX */ … … 1359 1371 } 1360 1372 } else { 1361 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)1362 if (addr * 4 >= VGA_MAPPING_SIZE)1363 return VINF_IOM_HC_MMIO_WRITE;1364 #else1365 if (addr * 4 >= s->vram_size)1366 {1367 AssertMsgFailed(("addr=%RGp - this needs to be done in HC! bank_offset=%08x memory_map_mode=%d\n",1368 addr * 4, s->bank_offset, memory_map_mode));1369 return VINF_SUCCESS;1370 }1371 #endif1372 1373 1373 /* standard VGA latched access */ 1374 VERIFY_VRAM_WRITE_OFF_RETURN(s, addr * 4 + 3); 1375 1374 1376 write_mode = s->gr[5] & 3; 1375 1377 switch(write_mode) { … … 3320 3322 if (pThis->sr[4] & 0x08) { 3321 3323 /* chain 4 mode : simplest access */ 3322 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 3323 if (GCPhysAddr + cItems * cbItem >= VGA_MAPPING_SIZE) 3324 return VINF_IOM_HC_MMIO_WRITE; 3325 #else 3326 if (GCPhysAddr + cItems * cbItem >= pThis->vram_size) 3327 { 3328 AssertMsgFailed(("GCPhysAddr=%RGp cItems=%#x cbItem=%d\n", GCPhysAddr, cItems, cbItem)); 3329 return VINF_SUCCESS; 3330 } 3331 #endif 3324 VERIFY_VRAM_WRITE_OFF_RETURN(pThis, GCPhysAddr + cItems * cbItem - 1); 3332 3325 3333 3326 while (cItems-- > 0) … … 3343 3336 } else if (pThis->gr[5] & 0x10) { 3344 3337 /* odd/even mode (aka text mode mapping) */ 3345 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 3346 if (GCPhysAddr * 2 + cItems * cbItem >= VGA_MAPPING_SIZE) 3347 return VINF_IOM_HC_MMIO_WRITE; 3348 #else 3349 if (GCPhysAddr * 2 + cItems * cbItem >= pThis->vram_size) 3350 { 3351 AssertMsgFailed(("GCPhysAddr=%RGp cItems=%#x cbItem=%d\n", GCPhysAddr, cItems, cbItem)); 3352 return VINF_SUCCESS; 3353 } 3354 #endif 3338 VERIFY_VRAM_WRITE_OFF_RETURN(pThis, GCPhysAddr * 2 + cItems * cbItem - 1); 3355 3339 while (cItems-- > 0) 3356 3340 for (i = 0; i < cbItem; i++) … … 3365 3349 } 3366 3350 } else { 3367 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)3368 if (GCPhysAddr + cItems * cbItem >= VGA_MAPPING_SIZE)3369 return VINF_IOM_HC_MMIO_WRITE;3370 #else3371 if (GCPhysAddr + cItems * cbItem >= pThis->vram_size)3372 {3373 AssertMsgFailed(("GCPhysAddr=%RGp cItems=%#x cbItem=%d\n", GCPhysAddr, cItems, cbItem));3374 return VINF_SUCCESS;3375 }3376 #endif3377 3378 3351 /* standard VGA latched access */ 3352 VERIFY_VRAM_WRITE_OFF_RETURN(pThis, GCPhysAddr + cItems * cbItem - 1); 3353 3379 3354 switch(pThis->gr[5] & 3) { 3380 3355 default: … … 3491 3466 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 3492 3467 STAM_PROFILE_START(&pThis->CTX_MID_Z(Stat,MemoryRead), a); 3468 int rc = VINF_SUCCESS; 3493 3469 NOREF(pvUser); 3494 3470 switch (cb) 3495 3471 { 3496 3472 case 1: 3497 *(uint8_t *)pv = vga_mem_readb(pThis, GCPhysAddr ); break;3473 *(uint8_t *)pv = vga_mem_readb(pThis, GCPhysAddr, &rc); break; 3498 3474 case 2: 3499 *(uint16_t *)pv = vga_mem_readb(pThis, GCPhysAddr )3500 | (vga_mem_readb(pThis, GCPhysAddr + 1 ) << 8);3475 *(uint16_t *)pv = vga_mem_readb(pThis, GCPhysAddr, &rc) 3476 | (vga_mem_readb(pThis, GCPhysAddr + 1, &rc) << 8); 3501 3477 break; 3502 3478 case 4: 3503 *(uint32_t *)pv = vga_mem_readb(pThis, GCPhysAddr )3504 | (vga_mem_readb(pThis, GCPhysAddr + 1 ) << 8)3505 | (vga_mem_readb(pThis, GCPhysAddr + 2 ) << 16)3506 | (vga_mem_readb(pThis, GCPhysAddr + 3 ) << 24);3479 *(uint32_t *)pv = vga_mem_readb(pThis, GCPhysAddr, &rc) 3480 | (vga_mem_readb(pThis, GCPhysAddr + 1, &rc) << 8) 3481 | (vga_mem_readb(pThis, GCPhysAddr + 2, &rc) << 16) 3482 | (vga_mem_readb(pThis, GCPhysAddr + 3, &rc) << 24); 3507 3483 break; 3508 3484 3509 3485 case 8: 3510 *(uint64_t *)pv = (uint64_t)vga_mem_readb(pThis, GCPhysAddr )3511 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 1 ) << 8)3512 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 2 ) << 16)3513 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 3 ) << 24)3514 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 4 ) << 32)3515 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 5 ) << 40)3516 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 6 ) << 48)3517 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 7 ) << 56);3486 *(uint64_t *)pv = (uint64_t)vga_mem_readb(pThis, GCPhysAddr, &rc) 3487 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 1, &rc) << 8) 3488 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 2, &rc) << 16) 3489 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 3, &rc) << 24) 3490 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 4, &rc) << 32) 3491 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 5, &rc) << 40) 3492 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 6, &rc) << 48) 3493 | ((uint64_t)vga_mem_readb(pThis, GCPhysAddr + 7, &rc) << 56); 3518 3494 break; 3519 3495 … … 3522 3498 uint8_t *pu8Data = (uint8_t *)pv; 3523 3499 while (cb-- > 0) 3524 *pu8Data++ = vga_mem_readb(pThis, GCPhysAddr++); 3500 { 3501 *pu8Data++ = vga_mem_readb(pThis, GCPhysAddr++, &rc); 3502 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 3503 break; 3504 } 3525 3505 } 3526 3506 } 3527 3507 STAM_PROFILE_STOP(&pThis->CTX_MID_Z(Stat,MemoryRead), a); 3528 return VINF_SUCCESS;3508 return rc; 3529 3509 } 3530 3510
Note:
See TracChangeset
for help on using the changeset viewer.