Changeset 44809 in vbox for trunk/src/VBox/Devices/Serial
- Timestamp:
- Feb 24, 2013 7:31:54 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Serial/DevSerial.cpp
r44528 r44809 6 6 7 7 /* 8 * Copyright (C) 2006-201 2Oracle Corporation8 * Copyright (C) 2006-2013 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 160 160 * @implements PDMICHARPORT 161 161 */ 162 struct SerialState162 typedef struct SerialState 163 163 { 164 164 /** Access critical section. */ … … 227 227 228 228 #ifdef VBOX_SERIAL_PCI 229 PCIDEVICE dev;229 PCIDEVICE PciDev; 230 230 #endif /* VBOX_SERIAL_PCI */ 231 }; 231 } DEVSERIAL; 232 /** Pointer to the serial device state. */ 233 typedef DEVSERIAL *PDEVSERIAL; 232 234 233 235 #ifndef VBOX_DEVICE_STRUCT_TESTCASE 234 236 235 236 #ifdef VBOX_SERIAL_PCI237 #define PCIDEV_2_SERIALSTATE(pPciDev) ( (SerialState *)((uintptr_t)(pPciDev) - RT_OFFSETOF(SerialState, dev)) )238 #endif /* VBOX_SERIAL_PCI */239 #define PDMIBASE_2_SERIALSTATE(pInstance) ( (SerialState *)((uintptr_t)(pInterface) - RT_OFFSETOF(SerialState, IBase)) )240 #define PDMICHARPORT_2_SERIALSTATE(pInstance) ( (SerialState *)((uintptr_t)(pInterface) - RT_OFFSETOF(SerialState, ICharPort)) )241 242 243 /*******************************************************************************244 * Internal Functions *245 *******************************************************************************/246 RT_C_DECLS_BEGIN247 PDMBOTHCBDECL(int) serialIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);248 PDMBOTHCBDECL(int) serialIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);249 RT_C_DECLS_END250 251 237 #ifdef IN_RING3 252 238 253 static int serial_can_receive( SerialState *s);254 static void serial_receive( void *opaque, const uint8_t *buf, int size);255 256 static void fifo_clear( SerialState *s, int fifo)257 { 258 SerialFifo *f = (fifo) ? & s->recv_fifo : &s->xmit_fifo;239 static int serial_can_receive(PDEVSERIAL pThis); 240 static void serial_receive(PDEVSERIAL pThis, const uint8_t *buf, int size); 241 242 static void fifo_clear(PDEVSERIAL pThis, int fifo) 243 { 244 SerialFifo *f = (fifo) ? &pThis->recv_fifo : &pThis->xmit_fifo; 259 245 memset(f->data, 0, UART_FIFO_LENGTH); 260 246 f->count = 0; … … 263 249 } 264 250 265 static int fifo_put( SerialState *s, int fifo, uint8_t chr)266 { 267 SerialFifo *f = (fifo) ? & s->recv_fifo : &s->xmit_fifo;251 static int fifo_put(PDEVSERIAL pThis, int fifo, uint8_t chr) 252 { 253 SerialFifo *f = (fifo) ? &pThis->recv_fifo : &pThis->xmit_fifo; 268 254 269 255 /* Receive overruns do not overwrite FIFO contents. */ … … 280 266 ++f->tail; 281 267 else if (fifo == RECV_FIFO) 282 s->lsr |= UART_LSR_OE;268 pThis->lsr |= UART_LSR_OE; 283 269 284 270 return 1; 285 271 } 286 272 287 static uint8_t fifo_get( SerialState *s, int fifo)288 { 289 SerialFifo *f = (fifo) ? & s->recv_fifo : &s->xmit_fifo;273 static uint8_t fifo_get(PDEVSERIAL pThis, int fifo) 274 { 275 SerialFifo *f = (fifo) ? &pThis->recv_fifo : &pThis->xmit_fifo; 290 276 uint8_t c; 291 277 … … 301 287 } 302 288 303 static void serial_update_irq( SerialState *s)289 static void serial_update_irq(PDEVSERIAL pThis) 304 290 { 305 291 uint8_t tmp_iir = UART_IIR_NO_INT; 306 292 307 if ( ( s->ier & UART_IER_RLSI)308 && ( s->lsr & UART_LSR_INT_ANY)) {293 if ( (pThis->ier & UART_IER_RLSI) 294 && (pThis->lsr & UART_LSR_INT_ANY)) { 309 295 tmp_iir = UART_IIR_RLSI; 310 } else if (( s->ier & UART_IER_RDI) &&s->timeout_ipending) {311 /* Note that( s->ier & UART_IER_RDI) can mask this interrupt,296 } else if ((pThis->ier & UART_IER_RDI) && pThis->timeout_ipending) { 297 /* Note that(pThis->ier & UART_IER_RDI) can mask this interrupt, 312 298 * this is not in the specification but is observed on existing 313 299 * hardware. */ 314 300 tmp_iir = UART_IIR_CTI; 315 } else if ( ( s->ier & UART_IER_RDI)316 && ( s->lsr & UART_LSR_DR)317 && ( !( s->fcr & UART_FCR_FE)318 || s->recv_fifo.count >=s->recv_fifo.itl)) {301 } else if ( (pThis->ier & UART_IER_RDI) 302 && (pThis->lsr & UART_LSR_DR) 303 && ( !(pThis->fcr & UART_FCR_FE) 304 || pThis->recv_fifo.count >= pThis->recv_fifo.itl)) { 319 305 tmp_iir = UART_IIR_RDI; 320 } else if ( ( s->ier & UART_IER_THRI)321 && s->thr_ipending) {306 } else if ( (pThis->ier & UART_IER_THRI) 307 && pThis->thr_ipending) { 322 308 tmp_iir = UART_IIR_THRI; 323 } else if ( ( s->ier & UART_IER_MSI)324 && ( s->msr & UART_MSR_ANY_DELTA)) {309 } else if ( (pThis->ier & UART_IER_MSI) 310 && (pThis->msr & UART_MSR_ANY_DELTA)) { 325 311 tmp_iir = UART_IIR_MSI; 326 312 } 327 s->iir = tmp_iir | (s->iir & 0xF0);313 pThis->iir = tmp_iir | (pThis->iir & 0xF0); 328 314 329 315 /** XXX only call the SetIrq function if the state really changes! */ 330 316 if (tmp_iir != UART_IIR_NO_INT) { 331 Log(("serial_update_irq %d 1\n", s->irq));317 Log(("serial_update_irq %d 1\n", pThis->irq)); 332 318 # ifdef VBOX_SERIAL_PCI 333 PDMDevHlpPCISetIrqNoWait( s->CTX_SUFF(pDevIns), 0, 1);319 PDMDevHlpPCISetIrqNoWait(pThis->CTX_SUFF(pDevIns), 0, 1); 334 320 # else /* !VBOX_SERIAL_PCI */ 335 PDMDevHlpISASetIrqNoWait( s->CTX_SUFF(pDevIns),s->irq, 1);321 PDMDevHlpISASetIrqNoWait(pThis->CTX_SUFF(pDevIns), pThis->irq, 1); 336 322 # endif /* !VBOX_SERIAL_PCI */ 337 323 } else { 338 Log(("serial_update_irq %d 0\n", s->irq));324 Log(("serial_update_irq %d 0\n", pThis->irq)); 339 325 # ifdef VBOX_SERIAL_PCI 340 PDMDevHlpPCISetIrqNoWait( s->CTX_SUFF(pDevIns), 0, 0);326 PDMDevHlpPCISetIrqNoWait(pThis->CTX_SUFF(pDevIns), 0, 0); 341 327 # else /* !VBOX_SERIAL_PCI */ 342 PDMDevHlpISASetIrqNoWait( s->CTX_SUFF(pDevIns),s->irq, 0);328 PDMDevHlpISASetIrqNoWait(pThis->CTX_SUFF(pDevIns), pThis->irq, 0); 343 329 # endif /* !VBOX_SERIAL_PCI */ 344 330 } 345 331 } 346 332 347 static void serial_tsr_retry_update_parameters( SerialState *s, uint64_t tf)348 { 349 s->tsr_retry_bound_max = RT_MAX((tf * MAX_XMIT_RETRY_TIME) /s->char_transmit_time, MIN_XMIT_RETRY);350 s->tsr_retry_bound_min = RT_MAX(s->tsr_retry_bound_max / (1000 * MAX_XMIT_RETRY_TIME), MIN_XMIT_RETRY);333 static void serial_tsr_retry_update_parameters(PDEVSERIAL pThis, uint64_t tf) 334 { 335 pThis->tsr_retry_bound_max = RT_MAX((tf * MAX_XMIT_RETRY_TIME) / pThis->char_transmit_time, MIN_XMIT_RETRY); 336 pThis->tsr_retry_bound_min = RT_MAX(pThis->tsr_retry_bound_max / (1000 * MAX_XMIT_RETRY_TIME), MIN_XMIT_RETRY); 351 337 /* for simplicity just reset to max retry count */ 352 s->tsr_retry_bound =s->tsr_retry_bound_max;353 } 354 355 static void serial_tsr_retry_bound_reached( SerialState *s)338 pThis->tsr_retry_bound = pThis->tsr_retry_bound_max; 339 } 340 341 static void serial_tsr_retry_bound_reached(PDEVSERIAL pThis) 356 342 { 357 343 /* this is most likely means we have some backend connection issues */ 358 344 /* decrement the retry bound */ 359 s->tsr_retry_bound = RT_MAX(s->tsr_retry_bound / (10 * MAX_XMIT_RETRY_TIME),s->tsr_retry_bound_min);360 } 361 362 static void serial_tsr_retry_succeeded( SerialState *s)345 pThis->tsr_retry_bound = RT_MAX(pThis->tsr_retry_bound / (10 * MAX_XMIT_RETRY_TIME), pThis->tsr_retry_bound_min); 346 } 347 348 static void serial_tsr_retry_succeeded(PDEVSERIAL pThis) 363 349 { 364 350 /* success means we have a backend connection working OK, 365 351 * set retry bound to its maximum value */ 366 s->tsr_retry_bound =s->tsr_retry_bound_max;367 } 368 369 static void serial_update_parameters( SerialState *s)352 pThis->tsr_retry_bound = pThis->tsr_retry_bound_max; 353 } 354 355 static void serial_update_parameters(PDEVSERIAL pThis) 370 356 { 371 357 int speed, parity, data_bits, stop_bits, frame_size; 372 358 373 if ( s->divider == 0)359 if (pThis->divider == 0) 374 360 return; 375 361 376 362 frame_size = 1; 377 if ( s->lcr & 0x08) {363 if (pThis->lcr & 0x08) { 378 364 frame_size++; 379 if ( s->lcr & 0x10)365 if (pThis->lcr & 0x10) 380 366 parity = 'E'; 381 367 else … … 384 370 parity = 'N'; 385 371 } 386 if ( s->lcr & 0x04)372 if (pThis->lcr & 0x04) 387 373 stop_bits = 2; 388 374 else 389 375 stop_bits = 1; 390 376 391 data_bits = ( s->lcr & 0x03) + 5;377 data_bits = (pThis->lcr & 0x03) + 5; 392 378 frame_size += data_bits + stop_bits; 393 speed = 115200 / s->divider;394 uint64_t tf = TMTimerGetFreq(CTX_SUFF( s->transmit_timer));395 s->char_transmit_time = (tf / speed) * frame_size;396 serial_tsr_retry_update_parameters( s, tf);379 speed = 115200 / pThis->divider; 380 uint64_t tf = TMTimerGetFreq(CTX_SUFF(pThis->transmit_timer)); 381 pThis->char_transmit_time = (tf / speed) * frame_size; 382 serial_tsr_retry_update_parameters(pThis, tf); 397 383 398 384 Log(("speed=%d parity=%c data=%d stop=%d\n", speed, parity, data_bits, stop_bits)); 399 385 400 if (RT_LIKELY(s->pDrvChar)) 401 s->pDrvChar->pfnSetParameters(s->pDrvChar, speed, parity, data_bits, stop_bits); 402 } 403 404 static void serial_xmit(void *opaque, bool bRetryXmit) 405 { 406 SerialState *s = (SerialState*)opaque; 407 408 if (s->tsr_retry <= 0) { 409 if (s->fcr & UART_FCR_FE) { 410 s->tsr = fifo_get(s, XMIT_FIFO); 411 if (!s->xmit_fifo.count) 412 s->lsr |= UART_LSR_THRE; 386 if (RT_LIKELY(pThis->pDrvChar)) 387 pThis->pDrvChar->pfnSetParameters(pThis->pDrvChar, speed, parity, data_bits, stop_bits); 388 } 389 390 static void serial_xmit(PDEVSERIAL pThis, bool bRetryXmit) 391 { 392 if (pThis->tsr_retry <= 0) { 393 if (pThis->fcr & UART_FCR_FE) { 394 pThis->tsr = fifo_get(pThis, XMIT_FIFO); 395 if (!pThis->xmit_fifo.count) 396 pThis->lsr |= UART_LSR_THRE; 413 397 } else { 414 s->tsr =s->thr;415 s->lsr |= UART_LSR_THRE;416 } 417 } 418 419 if ( s->mcr & UART_MCR_LOOP) {398 pThis->tsr = pThis->thr; 399 pThis->lsr |= UART_LSR_THRE; 400 } 401 } 402 403 if (pThis->mcr & UART_MCR_LOOP) { 420 404 /* in loopback mode, say that we just received a char */ 421 serial_receive( s, &s->tsr, 1);422 } else if ( RT_LIKELY( s->pDrvChar)423 && RT_FAILURE( s->pDrvChar->pfnWrite(s->pDrvChar, &s->tsr, 1))) {424 if (( s->tsr_retry >= 0) && ((!bRetryXmit) || (s->tsr_retry <=s->tsr_retry_bound))) {425 if (! s->tsr_retry)426 s->tsr_retry = 1; /* make sure the retry state is always set */405 serial_receive(pThis, &pThis->tsr, 1); 406 } else if ( RT_LIKELY(pThis->pDrvChar) 407 && RT_FAILURE(pThis->pDrvChar->pfnWrite(pThis->pDrvChar, &pThis->tsr, 1))) { 408 if ((pThis->tsr_retry >= 0) && ((!bRetryXmit) || (pThis->tsr_retry <= pThis->tsr_retry_bound))) { 409 if (!pThis->tsr_retry) 410 pThis->tsr_retry = 1; /* make sure the retry state is always set */ 427 411 else if (bRetryXmit) /* do not increase the retry count if the retry is actually caused by next char write */ 428 s->tsr_retry++;429 430 TMTimerSet(CTX_SUFF( s->transmit_timer), TMTimerGet(CTX_SUFF(s->transmit_timer)) +s->char_transmit_time * 4);412 pThis->tsr_retry++; 413 414 TMTimerSet(CTX_SUFF(pThis->transmit_timer), TMTimerGet(CTX_SUFF(pThis->transmit_timer)) + pThis->char_transmit_time * 4); 431 415 return; 432 416 } else { 433 417 /* drop this character. */ 434 s->tsr_retry = 0;435 serial_tsr_retry_bound_reached( s);418 pThis->tsr_retry = 0; 419 serial_tsr_retry_bound_reached(pThis); 436 420 } 437 421 } 438 422 else { 439 s->tsr_retry = 0;440 serial_tsr_retry_succeeded( s);441 } 442 443 if (!( s->lsr & UART_LSR_THRE))444 TMTimerSet(CTX_SUFF( s->transmit_timer),445 TMTimerGet(CTX_SUFF( s->transmit_timer)) +s->char_transmit_time);446 447 if ( s->lsr & UART_LSR_THRE) {448 s->lsr |= UART_LSR_TEMT;449 s->thr_ipending = 1;450 serial_update_irq( s);423 pThis->tsr_retry = 0; 424 serial_tsr_retry_succeeded(pThis); 425 } 426 427 if (!(pThis->lsr & UART_LSR_THRE)) 428 TMTimerSet(CTX_SUFF(pThis->transmit_timer), 429 TMTimerGet(CTX_SUFF(pThis->transmit_timer)) + pThis->char_transmit_time); 430 431 if (pThis->lsr & UART_LSR_THRE) { 432 pThis->lsr |= UART_LSR_TEMT; 433 pThis->thr_ipending = 1; 434 serial_update_irq(pThis); 451 435 } 452 436 } … … 454 438 #endif /* IN_RING3 */ 455 439 456 static int serial_ioport_write( SerialState *s, uint32_t addr, uint32_t val)440 static int serial_ioport_write(PDEVSERIAL pThis, uint32_t addr, uint32_t val) 457 441 { 458 442 addr &= 7; 459 443 460 444 #ifndef IN_RING3 461 NOREF( s);445 NOREF(pThis); 462 446 return VINF_IOM_R3_IOPORT_WRITE; 463 447 #else … … 465 449 default: 466 450 case 0: 467 if ( s->lcr & UART_LCR_DLAB) {468 s->divider = (s->divider & 0xff00) | val;469 serial_update_parameters( s);451 if (pThis->lcr & UART_LCR_DLAB) { 452 pThis->divider = (pThis->divider & 0xff00) | val; 453 serial_update_parameters(pThis); 470 454 } else { 471 s->thr = (uint8_t) val;472 if ( s->fcr & UART_FCR_FE) {473 fifo_put( s, XMIT_FIFO,s->thr);474 s->thr_ipending = 0;475 s->lsr &= ~UART_LSR_TEMT;476 s->lsr &= ~UART_LSR_THRE;477 serial_update_irq( s);455 pThis->thr = (uint8_t) val; 456 if (pThis->fcr & UART_FCR_FE) { 457 fifo_put(pThis, XMIT_FIFO, pThis->thr); 458 pThis->thr_ipending = 0; 459 pThis->lsr &= ~UART_LSR_TEMT; 460 pThis->lsr &= ~UART_LSR_THRE; 461 serial_update_irq(pThis); 478 462 } else { 479 s->thr_ipending = 0;480 s->lsr &= ~UART_LSR_THRE;481 serial_update_irq( s);463 pThis->thr_ipending = 0; 464 pThis->lsr &= ~UART_LSR_THRE; 465 serial_update_irq(pThis); 482 466 } 483 serial_xmit( s, false);467 serial_xmit(pThis, false); 484 468 } 485 469 break; 486 470 case 1: 487 if ( s->lcr & UART_LCR_DLAB) {488 s->divider = (s->divider & 0x00ff) | (val << 8);489 serial_update_parameters( s);471 if (pThis->lcr & UART_LCR_DLAB) { 472 pThis->divider = (pThis->divider & 0x00ff) | (val << 8); 473 serial_update_parameters(pThis); 490 474 } else { 491 s->ier = val & 0x0f;492 if ( s->lsr & UART_LSR_THRE) {493 s->thr_ipending = 1;494 serial_update_irq( s);475 pThis->ier = val & 0x0f; 476 if (pThis->lsr & UART_LSR_THRE) { 477 pThis->thr_ipending = 1; 478 serial_update_irq(pThis); 495 479 } 496 480 } 497 481 break; 498 482 case 2: 499 if (! s->f16550AEnabled)483 if (!pThis->f16550AEnabled) 500 484 break; 501 485 502 486 val = val & 0xFF; 503 487 504 if ( s->fcr == val)488 if (pThis->fcr == val) 505 489 break; 506 490 507 491 /* Did the enable/disable flag change? If so, make sure FIFOs get flushed */ 508 if ((val ^ s->fcr) & UART_FCR_FE)492 if ((val ^ pThis->fcr) & UART_FCR_FE) 509 493 val |= UART_FCR_XFR | UART_FCR_RFR; 510 494 511 495 /* FIFO clear */ 512 496 if (val & UART_FCR_RFR) { 513 TMTimerStop( s->fifo_timeout_timer);514 s->timeout_ipending = 0;515 fifo_clear( s, RECV_FIFO);497 TMTimerStop(pThis->fifo_timeout_timer); 498 pThis->timeout_ipending = 0; 499 fifo_clear(pThis, RECV_FIFO); 516 500 } 517 501 if (val & UART_FCR_XFR) { 518 fifo_clear( s, XMIT_FIFO);502 fifo_clear(pThis, XMIT_FIFO); 519 503 } 520 504 521 505 if (val & UART_FCR_FE) { 522 s->iir |= UART_IIR_FE;506 pThis->iir |= UART_IIR_FE; 523 507 /* Set RECV_FIFO trigger Level */ 524 508 switch (val & 0xC0) { 525 509 case UART_FCR_ITL_1: 526 s->recv_fifo.itl = 1;510 pThis->recv_fifo.itl = 1; 527 511 break; 528 512 case UART_FCR_ITL_2: 529 s->recv_fifo.itl = 4;513 pThis->recv_fifo.itl = 4; 530 514 break; 531 515 case UART_FCR_ITL_3: 532 s->recv_fifo.itl = 8;516 pThis->recv_fifo.itl = 8; 533 517 break; 534 518 case UART_FCR_ITL_4: 535 s->recv_fifo.itl = 14;519 pThis->recv_fifo.itl = 14; 536 520 break; 537 521 } 538 522 } else 539 s->iir &= ~UART_IIR_FE;523 pThis->iir &= ~UART_IIR_FE; 540 524 541 525 /* Set fcr - or at least the bits in it that are supposed to "stick" */ 542 s->fcr = val & 0xC9;543 serial_update_irq( s);526 pThis->fcr = val & 0xC9; 527 serial_update_irq(pThis); 544 528 break; 545 529 case 3: 546 530 { 547 531 int break_enable; 548 s->lcr = val;549 serial_update_parameters( s);532 pThis->lcr = val; 533 serial_update_parameters(pThis); 550 534 break_enable = (val >> 6) & 1; 551 if (break_enable != s->last_break_enable) {552 s->last_break_enable = break_enable;553 if (RT_LIKELY( s->pDrvChar))535 if (break_enable != pThis->last_break_enable) { 536 pThis->last_break_enable = break_enable; 537 if (RT_LIKELY(pThis->pDrvChar)) 554 538 { 555 539 Log(("serial_ioport_write: Set break %d\n", break_enable)); 556 int rc = s->pDrvChar->pfnSetBreak(s->pDrvChar, !!break_enable);540 int rc = pThis->pDrvChar->pfnSetBreak(pThis->pDrvChar, !!break_enable); 557 541 AssertRC(rc); 558 542 } … … 561 545 break; 562 546 case 4: 563 s->mcr = val & 0x1f;564 if (RT_LIKELY( s->pDrvChar))547 pThis->mcr = val & 0x1f; 548 if (RT_LIKELY(pThis->pDrvChar)) 565 549 { 566 int rc = s->pDrvChar->pfnSetModemLines(s->pDrvChar,567 !!( s->mcr & UART_MCR_RTS),568 !!( s->mcr & UART_MCR_DTR));550 int rc = pThis->pDrvChar->pfnSetModemLines(pThis->pDrvChar, 551 !!(pThis->mcr & UART_MCR_RTS), 552 !!(pThis->mcr & UART_MCR_DTR)); 569 553 AssertRC(rc); 570 554 } … … 575 559 break; 576 560 case 7: 577 s->scr = val;561 pThis->scr = val; 578 562 break; 579 563 } … … 582 566 } 583 567 584 static uint32_t serial_ioport_read(void *opaque, uint32_t addr, int *pRC) 585 { 586 SerialState *s = (SerialState *)opaque; 568 static uint32_t serial_ioport_read(PDEVSERIAL pThis, uint32_t addr, int *pRC) 569 { 587 570 uint32_t ret = ~0U; 588 571 … … 593 576 default: 594 577 case 0: 595 if ( s->lcr & UART_LCR_DLAB) {578 if (pThis->lcr & UART_LCR_DLAB) { 596 579 /* DLAB == 1: divisor latch (LS) */ 597 ret = s->divider & 0xff;580 ret = pThis->divider & 0xff; 598 581 } else { 599 582 #ifndef IN_RING3 600 583 *pRC = VINF_IOM_R3_IOPORT_READ; 601 584 #else 602 if ( s->fcr & UART_FCR_FE) {603 ret = fifo_get( s, RECV_FIFO);604 if ( s->recv_fifo.count == 0)605 s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);585 if (pThis->fcr & UART_FCR_FE) { 586 ret = fifo_get(pThis, RECV_FIFO); 587 if (pThis->recv_fifo.count == 0) 588 pThis->lsr &= ~(UART_LSR_DR | UART_LSR_BI); 606 589 else 607 TMTimerSet( s->fifo_timeout_timer,608 TMTimerGet( s->fifo_timeout_timer) +s->char_transmit_time * 4);609 s->timeout_ipending = 0;590 TMTimerSet(pThis->fifo_timeout_timer, 591 TMTimerGet(pThis->fifo_timeout_timer) + pThis->char_transmit_time * 4); 592 pThis->timeout_ipending = 0; 610 593 } else { 611 Log(("serial_io_port_read: read 0x%X\n", s->rbr));612 ret = s->rbr;613 s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);594 Log(("serial_io_port_read: read 0x%X\n", pThis->rbr)); 595 ret = pThis->rbr; 596 pThis->lsr &= ~(UART_LSR_DR | UART_LSR_BI); 614 597 } 615 serial_update_irq( s);616 if ( s->fRecvWaiting)598 serial_update_irq(pThis); 599 if (pThis->fRecvWaiting) 617 600 { 618 s->fRecvWaiting = false;619 int rc = RTSemEventSignal( s->ReceiveSem);601 pThis->fRecvWaiting = false; 602 int rc = RTSemEventSignal(pThis->ReceiveSem); 620 603 AssertRC(rc); 621 604 } … … 624 607 break; 625 608 case 1: 626 if ( s->lcr & UART_LCR_DLAB) {609 if (pThis->lcr & UART_LCR_DLAB) { 627 610 /* DLAB == 1: divisor latch (MS) */ 628 ret = ( s->divider >> 8) & 0xff;611 ret = (pThis->divider >> 8) & 0xff; 629 612 } else { 630 ret = s->ier;613 ret = pThis->ier; 631 614 } 632 615 break; … … 635 618 *pRC = VINF_IOM_R3_IOPORT_READ; 636 619 #else 637 ret = s->iir;620 ret = pThis->iir; 638 621 if ((ret & UART_IIR_ID) == UART_IIR_THRI) { 639 s->thr_ipending = 0;640 serial_update_irq( s);622 pThis->thr_ipending = 0; 623 serial_update_irq(pThis); 641 624 } 642 625 /* reset msr changed bit */ 643 s->msr_changed = false;626 pThis->msr_changed = false; 644 627 #endif 645 628 break; 646 629 case 3: 647 ret = s->lcr;630 ret = pThis->lcr; 648 631 break; 649 632 case 4: 650 ret = s->mcr;633 ret = pThis->mcr; 651 634 break; 652 635 case 5: 653 if (( s->lsr & UART_LSR_DR) == 0 &&s->fYieldOnLSRRead)636 if ((pThis->lsr & UART_LSR_DR) == 0 && pThis->fYieldOnLSRRead) 654 637 { 655 638 /* No data available and yielding is enabled, so yield in ring3. */ … … 661 644 #endif 662 645 } 663 ret = s->lsr;646 ret = pThis->lsr; 664 647 /* Clear break and overrun interrupts */ 665 if ( s->lsr & (UART_LSR_BI|UART_LSR_OE)) {648 if (pThis->lsr & (UART_LSR_BI|UART_LSR_OE)) { 666 649 #ifndef IN_RING3 667 650 *pRC = VINF_IOM_R3_IOPORT_READ; 668 651 #else 669 s->lsr &= ~(UART_LSR_BI|UART_LSR_OE);670 serial_update_irq( s);652 pThis->lsr &= ~(UART_LSR_BI|UART_LSR_OE); 653 serial_update_irq(pThis); 671 654 #endif 672 655 } 673 656 break; 674 657 case 6: 675 if ( s->mcr & UART_MCR_LOOP) {658 if (pThis->mcr & UART_MCR_LOOP) { 676 659 /* in loopback, the modem output pins are connected to the 677 660 inputs */ 678 ret = ( s->mcr & 0x0c) << 4;679 ret |= ( s->mcr & 0x02) << 3;680 ret |= ( s->mcr & 0x01) << 5;661 ret = (pThis->mcr & 0x0c) << 4; 662 ret |= (pThis->mcr & 0x02) << 3; 663 ret |= (pThis->mcr & 0x01) << 5; 681 664 } else { 682 ret = s->msr;665 ret = pThis->msr; 683 666 /* Clear delta bits & msr int after read, if they were set */ 684 if ( s->msr & UART_MSR_ANY_DELTA) {667 if (pThis->msr & UART_MSR_ANY_DELTA) { 685 668 #ifndef IN_RING3 686 669 *pRC = VINF_IOM_R3_IOPORT_READ; 687 670 #else 688 s->msr &= 0xF0;689 serial_update_irq( s);671 pThis->msr &= 0xF0; 672 serial_update_irq(pThis); 690 673 #endif 691 674 } … … 693 676 break; 694 677 case 7: 695 ret = s->scr;678 ret = pThis->scr; 696 679 break; 697 680 } … … 701 684 #ifdef IN_RING3 702 685 703 static int serial_can_receive( SerialState *s)704 { 705 if ( s->fcr & UART_FCR_FE) {706 if ( s->recv_fifo.count < UART_FIFO_LENGTH)707 return ( s->recv_fifo.count <=s->recv_fifo.itl)708 ? s->recv_fifo.itl -s->recv_fifo.count : 1;686 static int serial_can_receive(PDEVSERIAL pThis) 687 { 688 if (pThis->fcr & UART_FCR_FE) { 689 if (pThis->recv_fifo.count < UART_FIFO_LENGTH) 690 return (pThis->recv_fifo.count <= pThis->recv_fifo.itl) 691 ? pThis->recv_fifo.itl - pThis->recv_fifo.count : 1; 709 692 else 710 693 return 0; 711 694 } else { 712 return !(s->lsr & UART_LSR_DR); 713 } 714 } 715 716 static void serial_receive(void *opaque, const uint8_t *buf, int size) 717 { 718 SerialState *s = (SerialState*)opaque; 719 if (s->fcr & UART_FCR_FE) { 695 return !(pThis->lsr & UART_LSR_DR); 696 } 697 } 698 699 static void serial_receive(PDEVSERIAL pThis, const uint8_t *buf, int size) 700 { 701 if (pThis->fcr & UART_FCR_FE) { 720 702 int i; 721 703 for (i = 0; i < size; i++) { 722 fifo_put( s, RECV_FIFO, buf[i]);723 } 724 s->lsr |= UART_LSR_DR;704 fifo_put(pThis, RECV_FIFO, buf[i]); 705 } 706 pThis->lsr |= UART_LSR_DR; 725 707 /* call the timeout receive callback in 4 char transmit time */ 726 TMTimerSet( s->fifo_timeout_timer, TMTimerGet(s->fifo_timeout_timer) +s->char_transmit_time * 4);708 TMTimerSet(pThis->fifo_timeout_timer, TMTimerGet(pThis->fifo_timeout_timer) + pThis->char_transmit_time * 4); 727 709 } else { 728 if (s->lsr & UART_LSR_DR) 729 s->lsr |= UART_LSR_OE; 730 s->rbr = buf[0]; 731 s->lsr |= UART_LSR_DR; 732 } 733 serial_update_irq(s); 734 } 735 736 /** @copydoc PDMICHARPORT::pfnNotifyRead */ 710 if (pThis->lsr & UART_LSR_DR) 711 pThis->lsr |= UART_LSR_OE; 712 pThis->rbr = buf[0]; 713 pThis->lsr |= UART_LSR_DR; 714 } 715 serial_update_irq(pThis); 716 } 717 718 719 /** 720 * @interface_method_impl{PDMICHARPORT,pfnNotifyRead} 721 */ 737 722 static DECLCALLBACK(int) serialNotifyRead(PPDMICHARPORT pInterface, const void *pvBuf, size_t *pcbRead) 738 723 { 739 SerialState *pThis = PDMICHARPORT_2_SERIALSTATE(pInterface);724 PDEVSERIAL pThis = RT_FROM_MEMBER(pInterface, DEVSERIAL, ICharPort); 740 725 const uint8_t *pu8Buf = (const uint8_t*)pvBuf; 741 726 size_t cbRead = *pcbRead; … … 760 745 } 761 746 762 /** @copydoc PDMICHARPORT::pfnNotifyStatusLinesChanged */ 747 /** 748 * @@interface_method_impl{PDMICHARPORT,pfnNotifyStatusLinesChanged} 749 */ 763 750 static DECLCALLBACK(int) serialNotifyStatusLinesChanged(PPDMICHARPORT pInterface, uint32_t newStatusLines) 764 751 { 765 SerialState *pThis = PDMICHARPORT_2_SERIALSTATE(pInterface);752 PDEVSERIAL pThis = RT_FROM_MEMBER(pInterface, DEVSERIAL, ICharPort); 766 753 uint8_t newMsr = 0; 767 754 … … 799 786 } 800 787 801 /** @copydoc PDMICHARPORT::pfnNotifyBufferFull */ 788 789 /** 790 * @interface_method_impl{PDMICHARPORT,pfnNotifyBufferFull} 791 */ 802 792 static DECLCALLBACK(int) serialNotifyBufferFull(PPDMICHARPORT pInterface, bool fFull) 803 793 { … … 805 795 } 806 796 807 /** @copydoc PDMICHARPORT::pfnNotifyBreak */ 797 798 /** 799 * @interface_method_impl{PDMICHARPORT,pfnNotifyBreak} 800 */ 808 801 static DECLCALLBACK(int) serialNotifyBreak(PPDMICHARPORT pInterface) 809 802 { 810 SerialState *pThis = PDMICHARPORT_2_SERIALSTATE(pInterface);803 PDEVSERIAL pThis = RT_FROM_MEMBER(pInterface, DEVSERIAL, ICharPort); 811 804 812 805 Log(("%s: pInterface=%p\n", __FUNCTION__, pInterface)); … … 822 815 } 823 816 824 /** 825 * Fifo timer functions. 817 818 /* -=-=-=-=-=-=-=-=- Timer callbacks -=-=-=-=-=-=-=-=- */ 819 820 /** 821 * @callback_method_tmpl{FNTMTIMERDEV, Fifo timer function.} 826 822 */ 827 823 static DECLCALLBACK(void) serialFifoTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 828 824 { 829 SerialState *pThis = (SerialState *)pvUser;825 PDEVSERIAL pThis = (PDEVSERIAL)pvUser; 830 826 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 831 827 if (pThis->recv_fifo.count) … … 837 833 838 834 /** 839 * Transmit timer function. 835 * @callback_method_tmpl{FNTMTIMERDEV, Transmit timer function.} 836 * 840 837 * Just retry to transmit a character. 841 *842 * @param pTimer The timer handle.843 * @param pDevIns The device instance.844 * @param pvUser The user pointer.845 838 */ 846 839 static DECLCALLBACK(void) serialTransmitTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 847 840 { 848 SerialState *pThis = (SerialState *)pvUser;841 PDEVSERIAL pThis = (PDEVSERIAL)pvUser; 849 842 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 850 843 serial_xmit(pThis, true); 851 844 } 852 845 853 /**854 * Reset the serial device.855 *856 * @param pDevIns The device instance.857 */858 static DECLCALLBACK(void) serialReset(PPDMDEVINS pDevIns)859 {860 SerialState *s = PDMINS_2_DATA(pDevIns, SerialState *);861 862 s->rbr = 0;863 s->ier = 0;864 s->iir = UART_IIR_NO_INT;865 s->lcr = 0;866 s->lsr = UART_LSR_TEMT | UART_LSR_THRE;867 s->msr = UART_MSR_DCD | UART_MSR_DSR | UART_MSR_CTS;868 /* Default to 9600 baud, 1 start bit, 8 data bits, 1 stop bit, no parity. */869 s->divider = 0x0C;870 s->mcr = UART_MCR_OUT2;871 s->scr = 0;872 s->tsr_retry = 0;873 uint64_t tf = TMTimerGetFreq(CTX_SUFF(s->transmit_timer));874 s->char_transmit_time = (tf / 9600) * 10;875 serial_tsr_retry_update_parameters(s, tf);876 877 fifo_clear(s, RECV_FIFO);878 fifo_clear(s, XMIT_FIFO);879 880 s->thr_ipending = 0;881 s->last_break_enable = 0;882 # ifdef VBOX_SERIAL_PCI883 PDMDevHlpPCISetIrqNoWait(s->CTX_SUFF(pDevIns), 0, 0);884 # else /* !VBOX_SERIAL_PCI */885 PDMDevHlpISASetIrqNoWait(s->CTX_SUFF(pDevIns), s->irq, 0);886 # endif /* !VBOX_SERIAL_PCI */887 }888 889 846 #endif /* IN_RING3 */ 890 847 891 /** 892 * Port I/O Handler for OUT operations. 893 * 894 * @returns VBox status code. 895 * 896 * @param pDevIns The device instance. 897 * @param pvUser User argument. 898 * @param Port Port number used for the IN operation. 899 * @param u32 The value to output. 900 * @param cb The value size in bytes. 901 */ 902 PDMBOTHCBDECL(int) serialIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, 903 RTIOPORT Port, uint32_t u32, unsigned cb) 904 { 905 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *); 848 /* -=-=-=-=-=-=-=-=- I/O Port Access Handlers -=-=-=-=-=-=-=-=- */ 849 850 /** 851 * @callback_method_impl{FNIOMIOPORTOUT} 852 */ 853 PDMBOTHCBDECL(int) serialIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 854 { 855 PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL); 906 856 int rc; 907 857 Assert(PDMCritSectIsOwner(&pThis->CritSect)); … … 921 871 } 922 872 923 /** 924 * Port I/O Handler for IN operations. 925 * 926 * @returns VBox status code. 927 * 928 * @param pDevIns The device instance. 929 * @param pvUser User argument. 930 * @param Port Port number used for the IN operation. 931 * @param u32 The value to output. 932 * @param cb The value size in bytes. 933 */ 934 PDMBOTHCBDECL(int) serialIOPortRead(PPDMDEVINS pDevIns, void *pvUser, 935 RTIOPORT Port, uint32_t *pu32, unsigned cb) 936 { 937 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *); 873 874 /** 875 * @callback_method_impl{FNIOMIOPORTIN} 876 */ 877 PDMBOTHCBDECL(int) serialIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 878 { 879 PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL); 938 880 int rc; 939 881 Assert(PDMCritSectIsOwner(&pThis->CritSect)); … … 952 894 #ifdef IN_RING3 953 895 954 /* *955 * @copydoc FNSSMDEVLIVEEXEC 956 */ 957 static DECLCALLBACK(int) serialLiveExec(PPDMDEVINS pDevIns, 958 PSSMHANDLE pSSM,959 960 { 961 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *);896 /* -=-=-=-=-=-=-=-=- Saved State -=-=-=-=-=-=-=-=- */ 897 898 /** 899 * @callback_method_tmpl{FNSSMDEVLIVEEXEC} 900 */ 901 static DECLCALLBACK(int) serialLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 902 { 903 PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL); 962 904 SSMR3PutS32(pSSM, pThis->irq); 963 905 SSMR3PutU32(pSSM, pThis->base); … … 965 907 } 966 908 967 /** 968 * @copydoc FNSSMDEVSAVEEXEC 969 * /970 static DECLCALLBACK(int) serialSaveExec(PPDMDEVINS pDevIns, 971 972 { 973 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *);909 910 /** 911 * @callback_method_tmpl{FNSSMDEVSAVEEXEC} 912 */ 913 static DECLCALLBACK(int) serialSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 914 { 915 PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL); 974 916 975 917 SSMR3PutU16(pSSM, pThis->divider); … … 996 938 } 997 939 998 /** 999 * @copydoc FNSSMDEVLOADEXEC 1000 */ 1001 static DECLCALLBACK(int) serialLoadExec(PPDMDEVINS pDevIns, 1002 PSSMHANDLE pSSM, 1003 uint32_t uVersion, 1004 uint32_t uPass) 1005 { 1006 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *); 940 941 /** 942 * @callback_method_tmpl{FNSSMDEVLOADEXEC} 943 */ 944 static DECLCALLBACK(int) serialLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 945 { 946 PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL); 1007 947 1008 948 if (uVersion == SERIAL_SAVED_STATE_VERSION_16450) … … 1075 1015 1076 1016 1077 /**1078 * @copydoc FNPDMDEVRELOCATE1079 */1080 static DECLCALLBACK(void) serialRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)1081 {1082 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *);1083 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);1084 pThis->transmit_timerRC = TMTimerRCPtr(pThis->transmit_timerR3);1085 }1086 1087 1017 #ifdef VBOX_SERIAL_PCI 1088 1089 static DECLCALLBACK(int) serialIOPortRegionMap(PPCIDEVICE pPciDev, /* unsigned */ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType) 1090 { 1091 SerialState *pThis = PCIDEV_2_SERIALSTATE(pPciDev); 1018 /* -=-=-=-=-=-=-=-=- PCI Device Callback(s) -=-=-=-=-=-=-=-=- */ 1019 1020 /** 1021 * @callback_method_impl{FNPCIIOREGIONMAP} 1022 */ 1023 static DECLCALLBACK(int) serialIOPortRegionMap(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, 1024 uint32_t cb, PCIADDRESSSPACE enmType) 1025 { 1026 PDEVSERIAL pThis = RT_FROM_MEMBER(pPciDev, DEVSERIAL, PciDev); 1092 1027 int rc = VINF_SUCCESS; 1093 1028 … … 1111 1046 #endif /* VBOX_SERIAL_PCI */ 1112 1047 1048 1049 /* -=-=-=-=-=-=-=-=- PDMIBASE on LUN#1 -=-=-=-=-=-=-=-=- */ 1050 1113 1051 /** 1114 1052 * @interface_method_impl{PDMIBASE, pfnQueryInterface} … … 1116 1054 static DECLCALLBACK(void *) serialQueryInterface(PPDMIBASE pInterface, const char *pszIID) 1117 1055 { 1118 SerialState *pThis = PDMIBASE_2_SERIALSTATE(pInterface);1056 PDEVSERIAL pThis = RT_FROM_MEMBER(pInterface, DEVSERIAL, IBase); 1119 1057 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase); 1120 1058 PDMIBASE_RETURN_INTERFACE(pszIID, PDMICHARPORT, &pThis->ICharPort); … … 1122 1060 } 1123 1061 1124 /** 1125 * Destruct a device instance. 1126 * 1127 * Most VM resources are freed by the VM. This callback is provided so that any non-VM 1128 * resources can be freed correctly. 1129 * 1130 * @returns VBox status. 1131 * @param pDevIns The device instance data. 1062 1063 /* -=-=-=-=-=-=-=-=- PDMDEVREG -=-=-=-=-=-=-=-=- */ 1064 1065 /** 1066 * @interface_method_impl{PDMDEVREG, pfnRelocate} 1067 */ 1068 static DECLCALLBACK(void) serialRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 1069 { 1070 PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL); 1071 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 1072 pThis->transmit_timerRC = TMTimerRCPtr(pThis->transmit_timerR3); 1073 } 1074 1075 1076 /** 1077 * @interface_method_impl{PDMDEVREG, pfnReset} 1078 */ 1079 static DECLCALLBACK(void) serialReset(PPDMDEVINS pDevIns) 1080 { 1081 PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL); 1082 1083 pThis->rbr = 0; 1084 pThis->ier = 0; 1085 pThis->iir = UART_IIR_NO_INT; 1086 pThis->lcr = 0; 1087 pThis->lsr = UART_LSR_TEMT | UART_LSR_THRE; 1088 pThis->msr = UART_MSR_DCD | UART_MSR_DSR | UART_MSR_CTS; 1089 /* Default to 9600 baud, 1 start bit, 8 data bits, 1 stop bit, no parity. */ 1090 pThis->divider = 0x0C; 1091 pThis->mcr = UART_MCR_OUT2; 1092 pThis->scr = 0; 1093 pThis->tsr_retry = 0; 1094 uint64_t tf = TMTimerGetFreq(CTX_SUFF(pThis->transmit_timer)); 1095 pThis->char_transmit_time = (tf / 9600) * 10; 1096 serial_tsr_retry_update_parameters(pThis, tf); 1097 1098 fifo_clear(pThis, RECV_FIFO); 1099 fifo_clear(pThis, XMIT_FIFO); 1100 1101 pThis->thr_ipending = 0; 1102 pThis->last_break_enable = 0; 1103 # ifdef VBOX_SERIAL_PCI 1104 PDMDevHlpPCISetIrqNoWait(pThis->CTX_SUFF(pDevIns), 0, 0); 1105 # else /* !VBOX_SERIAL_PCI */ 1106 PDMDevHlpISASetIrqNoWait(pThis->CTX_SUFF(pDevIns), pThis->irq, 0); 1107 # endif /* !VBOX_SERIAL_PCI */ 1108 } 1109 1110 1111 /** 1112 * @interface_method_impl{PDMDEVREG, pfnDestruct} 1132 1113 */ 1133 1114 static DECLCALLBACK(int) serialDestruct(PPDMDEVINS pDevIns) 1134 1115 { 1135 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *);1116 PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL); 1136 1117 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); 1137 1118 … … 1149 1130 static DECLCALLBACK(int) serialConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 1150 1131 { 1132 PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL); 1151 1133 int rc; 1152 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState*);1153 1134 uint16_t io_base; 1154 1135 uint8_t irq_lvl; … … 1164 1145 pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 1165 1146 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 1147 pThis->ReceiveSem = NIL_RTSEMEVENT; 1166 1148 1167 1149 /* IBase */ … … 1176 1158 #ifdef VBOX_SERIAL_PCI 1177 1159 /* the PCI device */ 1178 pThis-> dev.config[0x00] = 0xee; /* Vendor: ??? */1179 pThis-> dev.config[0x01] = 0x80;1180 pThis-> dev.config[0x02] = 0x01; /* Device: ??? */1181 pThis-> dev.config[0x03] = 0x01;1182 pThis-> dev.config[0x04] = PCI_COMMAND_IOACCESS;1183 pThis-> dev.config[0x09] = 0x01; /* Programming interface: 16450 */1184 pThis-> dev.config[0x0a] = 0x00; /* Subclass: Serial controller */1185 pThis-> dev.config[0x0b] = 0x07; /* Class: Communication controller */1186 pThis-> dev.config[0x0e] = 0x00; /* Header type: standard */1187 pThis-> dev.config[0x3c] = irq_lvl; /* preconfigure IRQ number (0 = autoconfig)*/1188 pThis-> dev.config[0x3d] = 1; /* interrupt pin 0 */1160 pThis->PciDev.config[0x00] = 0xee; /* Vendor: ??? */ 1161 pThis->PciDev.config[0x01] = 0x80; 1162 pThis->PciDev.config[0x02] = 0x01; /* Device: ??? */ 1163 pThis->PciDev.config[0x03] = 0x01; 1164 pThis->PciDev.config[0x04] = PCI_COMMAND_IOACCESS; 1165 pThis->PciDev.config[0x09] = 0x01; /* Programming interface: 16450 */ 1166 pThis->PciDev.config[0x0a] = 0x00; /* Subclass: Serial controller */ 1167 pThis->PciDev.config[0x0b] = 0x07; /* Class: Communication controller */ 1168 pThis->PciDev.config[0x0e] = 0x00; /* Header type: standard */ 1169 pThis->PciDev.config[0x3c] = irq_lvl; /* preconfigure IRQ number (0 = autoconfig)*/ 1170 pThis->PciDev.config[0x3d] = 1; /* interrupt pin 0 */ 1189 1171 #endif /* VBOX_SERIAL_PCI */ 1190 1172 … … 1303 1285 * Register the PCI Device and region. 1304 1286 */ 1305 rc = PDMDevHlpPCIRegister(pDevIns, &pThis-> dev);1287 rc = PDMDevHlpPCIRegister(pDevIns, &pThis->PciDev); 1306 1288 if (RT_FAILURE(rc)) 1307 1289 return rc; … … 1400 1382 UINT32_MAX, 1401 1383 /* cbInstance */ 1402 sizeof( SerialState),1384 sizeof(DEVSERIAL), 1403 1385 /* pfnConstruct */ 1404 1386 serialConstruct,
Note:
See TracChangeset
for help on using the changeset viewer.