Revision 82579390 hw/scsi-disk.c
b/hw/scsi-disk.c | ||
---|---|---|
522 | 522 |
{ |
523 | 523 |
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); |
524 | 524 |
int buflen = 0; |
525 |
int start; |
|
525 | 526 |
|
526 | 527 |
if (req->cmd.buf[1] & 0x1) { |
527 | 528 |
/* Vital product data */ |
... | ... | |
530 | 531 |
outbuf[buflen++] = s->qdev.type & 0x1f; |
531 | 532 |
outbuf[buflen++] = page_code ; // this page |
532 | 533 |
outbuf[buflen++] = 0x00; |
534 |
outbuf[buflen++] = 0x00; |
|
535 |
start = buflen; |
|
533 | 536 |
|
534 | 537 |
switch (page_code) { |
535 | 538 |
case 0x00: /* Supported page codes, mandatory */ |
536 | 539 |
{ |
537 |
int pages; |
|
538 | 540 |
DPRINTF("Inquiry EVPD[Supported pages] " |
539 | 541 |
"buffer size %zd\n", req->cmd.xfer); |
540 |
pages = buflen++; |
|
541 | 542 |
outbuf[buflen++] = 0x00; // list of supported pages (this page) |
542 | 543 |
if (s->serial) { |
543 | 544 |
outbuf[buflen++] = 0x80; // unit serial number |
... | ... | |
547 | 548 |
outbuf[buflen++] = 0xb0; // block limits |
548 | 549 |
outbuf[buflen++] = 0xb2; // thin provisioning |
549 | 550 |
} |
550 |
outbuf[pages] = buflen - pages - 1; // number of pages |
|
551 | 551 |
break; |
552 | 552 |
} |
553 | 553 |
case 0x80: /* Device serial number, optional */ |
... | ... | |
566 | 566 |
|
567 | 567 |
DPRINTF("Inquiry EVPD[Serial number] " |
568 | 568 |
"buffer size %zd\n", req->cmd.xfer); |
569 |
outbuf[buflen++] = l; |
|
570 | 569 |
memcpy(outbuf+buflen, s->serial, l); |
571 | 570 |
buflen += l; |
572 | 571 |
break; |
... | ... | |
584 | 583 |
DPRINTF("Inquiry EVPD[Device identification] " |
585 | 584 |
"buffer size %zd\n", req->cmd.xfer); |
586 | 585 |
|
587 |
outbuf[buflen++] = 4 + id_len; |
|
588 | 586 |
outbuf[buflen++] = 0x2; // ASCII |
589 | 587 |
outbuf[buflen++] = 0; // not officially assigned |
590 | 588 |
outbuf[buflen++] = 0; // reserved |
... | ... | |
609 | 607 |
return -1; |
610 | 608 |
} |
611 | 609 |
/* required VPD size with unmap support */ |
612 |
outbuf[3] = buflen = 0x3c; |
|
613 |
|
|
610 |
buflen = 0x40; |
|
614 | 611 |
memset(outbuf + 4, 0, buflen - 4); |
615 | 612 |
|
616 | 613 |
/* optimal transfer length granularity */ |
... | ... | |
632 | 629 |
} |
633 | 630 |
case 0xb2: /* thin provisioning */ |
634 | 631 |
{ |
635 |
outbuf[3] = buflen = 8;
|
|
632 |
buflen = 8; |
|
636 | 633 |
outbuf[4] = 0; |
637 | 634 |
outbuf[5] = 0x60; /* write_same 10/16 supported */ |
638 | 635 |
outbuf[6] = s->qdev.conf.discard_granularity ? 2 : 1; |
... | ... | |
643 | 640 |
return -1; |
644 | 641 |
} |
645 | 642 |
/* done with EVPD */ |
643 |
assert(buflen - start <= 255); |
|
644 |
outbuf[start - 1] = buflen - start; |
|
646 | 645 |
return buflen; |
647 | 646 |
} |
648 | 647 |
|
Also available in: Unified diff