| 885 | } |
| 886 | |
| 887 | void ScsiController::ParseMessage() |
| 888 | { |
| 889 | int i = 0; |
| 890 | while (i < scsi.msc) { |
| 891 | const uint8_t message_type = scsi.msb[i]; |
| 892 | |
| 893 | if (message_type == 0x06) { |
| 894 | LogTrace("Received ABORT message"); |
| 895 | BusFree(); |
| 896 | return; |
| 897 | } |
| 898 | |
| 899 | if (message_type == 0x0C) { |
| 900 | LogTrace("Received BUS DEVICE RESET message"); |
| 901 | scsi.syncoffset = 0; |
| 902 | if (auto device = GetDeviceForLun(identified_lun); device != nullptr) { |
| 903 | device->DiscardReservation(); |
| 904 | } |
| 905 | BusFree(); |
| 906 | return; |
| 907 | } |
| 908 | |
| 909 | if (message_type >= 0x80) { |
| 910 | identified_lun = static_cast<int>(message_type) & 0x1F; |
| 911 | LogTrace("Received IDENTIFY message for LUN " + to_string(identified_lun)); |
| 912 | } |
| 913 | |
| 914 | if (message_type == 0x01) { |
| 915 | LogTrace("Received EXTENDED MESSAGE"); |
| 916 | |
| 917 | // Check only when synchronous transfer is possible |
| 918 | if (!scsi.syncenable || scsi.msb[i + 2] != 0x01) { |
| 919 | SetLength(1); |
| 920 | SetBlocks(1); |
| 921 | GetBuffer()[0] = 0x07; |
| 922 | MsgIn(); |
| 923 | return; |
| 924 | } |
| 925 | |
| 926 | scsi.syncperiod = scsi.msb[i + 3]; |
| 927 | if (scsi.syncperiod > MAX_SYNC_PERIOD) { |
| 928 | scsi.syncperiod = MAX_SYNC_PERIOD; |
| 929 | } |
| 930 | |
| 931 | scsi.syncoffset = scsi.msb[i + 4]; |
| 932 | if (scsi.syncoffset > MAX_SYNC_OFFSET) { |
| 933 | scsi.syncoffset = MAX_SYNC_OFFSET; |
| 934 | } |
| 935 | |
| 936 | // STDR response message generation |
| 937 | SetLength(5); |
| 938 | SetBlocks(1); |
| 939 | GetBuffer()[0] = 0x01; |
| 940 | GetBuffer()[1] = 0x03; |
| 941 | GetBuffer()[2] = 0x01; |
| 942 | GetBuffer()[3] = scsi.syncperiod; |
| 943 | GetBuffer()[4] = scsi.syncoffset; |
| 944 | MsgIn(); |
nothing calls this directly
no test coverage detected