Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1.  
  2. int executeDeviceDiagnostic(WORD adr, int which){
  3. BYTE status;
  4. int time = 0;
  5. do{
  6. status = __inp(adr + ATA_STATUS);
  7. time++;
  8. } while ((status & (STATUS_BSY | STATUS_DRQ)) != 0);
  9.  
  10. //Clear Dev bit
  11. BYTE device = __inp(adr + ATA_DEVICE);
  12. device &= (~DEVICE_DEV);
  13. __outp(adr + ATA_DEVICE, device);
  14.  
  15. //Send command
  16. __outp(adr + ATA_COMMAND, ATA_EXEC_DEVICE_DIAG);
  17. Sleep(4);
  18. time = 0;
  19. do{
  20. status = __inp(adr + ATA_STATUS);
  21.  
  22. time++;
  23. } while ((status & STATUS_BSY) != 0);
  24.  
  25. BYTE code = __inp(adr + ATA_ERROR);
  26. if (which == 0){
  27. wsprintf(szBuffer[cLine], "PRIMARY DIAGNOSIS CODE: %02X", code);
  28. cLine++;
  29. }
  30. else{
  31. wsprintf(szBuffer[cLine], "SECONDARY DIAGNOSIS CODE: %02X", code);
  32. cLine++;
  33. }
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement