vendor.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright (C) 2016 Michael McMaster <michael@codesrc.com>
  2. //
  3. // This file is part of SCSI2SD.
  4. //
  5. // SCSI2SD is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // SCSI2SD is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with SCSI2SD. If not, see <http://www.gnu.org/licenses/>.
  17. #include "scsi.h"
  18. #include "vendor.h"
  19. #include "diagnostic.h"
  20. // Callback after the DATA OUT phase is complete.
  21. static void doAssignDiskParameters(void)
  22. {
  23. if (scsiDev.status == GOOD)
  24. {
  25. scsiDev.phase = STATUS;
  26. }
  27. }
  28. // XEBEC specific commands
  29. // http://www.bitsavers.org/pdf/xebec/104524C_S1410Man_Aug83.pdf
  30. // WD100x seems to be identical to the Xebec but calls this command "Set Parameters"
  31. // http://www.bitsavers.org/pdf/westernDigital/WD100x/79-000004_WD1002-SHD_OEM_Manual_Aug1984.pdf
  32. static void doXebecInitializeDriveCharacteristics()
  33. {
  34. if (scsiDev.status == GOOD)
  35. {
  36. scsiDev.phase = STATUS;
  37. }
  38. }
  39. int scsiVendorCommand()
  40. {
  41. int commandHandled = 1;
  42. uint8_t command = scsiDev.cdb[0];
  43. if (command == 0xC0)
  44. {
  45. // Define flexible disk format
  46. // OMTI-5204 controller
  47. // http://bitsavers.informatik.uni-stuttgart.de/pdf/sms/OMTI_5x00.pdf
  48. // Stub. Sectors-per-track should be configured by scsi2sd-util
  49. }
  50. else if (command == 0xC2)
  51. {
  52. // Assign Disk Parameters command
  53. // OMTI-5204 controller
  54. // http://bitsavers.informatik.uni-stuttgart.de/pdf/sms/OMTI_5x00.pdf
  55. // Stub to read and discard 10 bytes.
  56. scsiDev.dataLen = 10;
  57. scsiDev.phase = DATA_OUT;
  58. scsiDev.postDataOutHook = doAssignDiskParameters;
  59. }
  60. else if (command == 0x0C &&
  61. scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_XEBEC)
  62. {
  63. // XEBEC S1410: "Initialize Drive Characteristics"
  64. // WD100x: "Set Parameters"
  65. scsiDev.dataLen = 8;
  66. scsiDev.phase = DATA_OUT;
  67. scsiDev.postDataOutHook = doXebecInitializeDriveCharacteristics;
  68. }
  69. else if (command == 0x0F &&
  70. scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_XEBEC)
  71. {
  72. // XEBEC S1410, WD100x: "Write Sector Buffer"
  73. scsiDev.dataLen = scsiDev.target->liveCfg.bytesPerSector;
  74. scsiDev.phase = DATA_OUT;
  75. scsiDev.postDataOutHook = doWriteBuffer;
  76. }
  77. else
  78. {
  79. commandHandled = 0;
  80. }
  81. return commandHandled;
  82. }