Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. void diagnosticFunction(WORD bAddr){
  2. BYTE status;
  3. while (true){
  4. if (status = __inp(bAddr + ATA_STATUS)){
  5. if (((status & STATUS_BSY) == 0) && ((status & STATUS_DRQ) == 0)){
  6. break;
  7. }
  8. }
  9. }
  10. BYTE device = __inp(bAddr + ATA_DEVICE);
  11. device &= (~DEVICE_DEV);
  12. __outp(bAddr + ATA_DEVICE, device);
  13. __outp(bAddr + ATA_COMMAND, ATA_EXEC_DEVICE_DIAG);
  14. Sleep(2);
  15. while (true){
  16. if (status = __inp(bAddr + ATA_STATUS)){
  17. if ((status &STATUS_BSY) == 0){
  18. break;
  19. }
  20. }
  21. }
  22. BYTE myErrorByte = __inp(bAddr + ATA_ERROR);
  23. wsprintf(szBuffer[cLine++], "my error code: %x", myErrorByte);
  24. }
  25.  
  26. void identifyDevice(WORD bCmdAddrs, WORD bCtrlAddr, BYTE drive){
  27. BYTE status;
  28. while (true){
  29. if (status = __inp(bCmdAddrs + ATA_STATUS)){
  30. if (((status & STATUS_BSY) == 0) && ((status & STATUS_DRQ) == 0)){
  31. break;
  32. }
  33. }
  34. }
  35. if (drive == 0){
  36. __outp(bCmdAddrs + ATA_DEVICE, (bCmdAddrs + ATA_DEVICE & (~DEVICE_DEV)));
  37. }
  38. else{
  39. __outp(bCmdAddrs + ATA_DEVICE, (bCmdAddrs + ATA_DEVICE | DEVICE_DEV));
  40. }
  41. __outp(bCmdAddrs + ATA_COMMAND, ATA_ID_DEVICE);
  42. Sleep(2);
  43. while (true){
  44. if (status = __inp(bCmdAddrs + ATA_STATUS)){
  45. if ((status &STATUS_BSY) == 0){
  46. break;
  47. }
  48. }
  49. }
  50. if (status & STATUS_DRQ == 0){
  51.  
  52. }
  53. else {
  54. WORD readData[256];
  55. for (int i = 0; i < 256; ++i){
  56. readData[i] = __inpw(bCmdAddrs + ATA_DATA);
  57. }
  58. wsprintf(szBuffer[cLine++], "Model:");
  59. BYTE mNo[45];
  60. int pos = 0;
  61. for (int i = 27; i <= 46; ++i){
  62. mNo[pos++] = HIBYTE(readData[i]);
  63. mNo[pos++] = LOBYTE(readData[i]);
  64. }
  65. wsprintf(szBuffer[cLine++], "%s", mNo);
  66. pos = 0;
  67. wsprintf(szBuffer[cLine++], "Serial:");
  68. for (int i = 10; i <= 19; ++i){
  69. mNo[pos++] = HIBYTE(readData[i]);
  70. mNo[pos++] = LOBYTE(readData[i]);
  71. }
  72. wsprintf(szBuffer[cLine++], "%s", mNo);
  73. pos = 0;
  74. wsprintf(szBuffer[cLine++], "Revision:");
  75. for (int i = 23; i <= 26; ++i){
  76. mNo[pos++] = HIBYTE(readData[i]);
  77. mNo[pos++] = LOBYTE(readData[i]);
  78. }
  79. wsprintf(szBuffer[cLine++], "%s", mNo);
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement