Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. PSATA_PCI_CFG configHeader(byte busNo, byte deviceNo, byte functionNo){
  2.  
  3. DWORD64 qwFuncAddr = PCI_CONFIG_START;
  4. qwFuncAddr = qwFuncAddr | (busNo << 20);
  5. qwFuncAddr = qwFuncAddr | (deviceNo << 15);
  6. qwFuncAddr = qwFuncAddr | (functionNo << 12);
  7.  
  8. return (PSATA_PCI_CFG)qwFuncAddr;
  9. }
  10.  
  11. DWORD myFunction(byte busNo, byte deviceNo, byte functionNo, int channel){
  12. DWORD result;
  13. PSATA_PCI_CFG sataConfig = configHeader(busNo, deviceNo, functionNo);
  14. if (channel == 0){
  15. DWORD pcmd = _inmdw((DWORD_PTR)&sataConfig->PCMD_BAR);
  16. DWORD pcnl = _inmdw((DWORD_PTR)&sataConfig->PCNL_BAR);
  17. pcmd = pcmd & 0xFFF8;
  18. pcnl = pcnl & 0xFFFC;
  19. result = (pcmd << 16) | pcnl;
  20. }
  21. else if (channel = 1){
  22. DWORD scmd = _inmdw((DWORD_PTR)&sataConfig->SCMD_BAR);
  23. DWORD scnl = _inmdw((DWORD_PTR)&sataConfig->SCNL_BAR);
  24. scmd = scmd & 0xFFF8;
  25. scnl = scnl & 0xFFFC;
  26. result = (scmd << 16) | scnl;
  27. }
  28. return result;
  29. }
  30.  
  31. void myFunction2(WORD bAddr){
  32. BYTE status;
  33. while (true){
  34. if (status = __inp(bAddr + ATA_STATUS)){
  35. status = status & STATUS_BSY;
  36. status = status & STATUS_DRQ;
  37. }
  38. }
  39. }
  40.  
  41. ////////////////////////////////////////
  42.  
  43. DWORD secondaryResult;
  44. secondaryResult = myFunction(0, 31, 2, 1);
  45. WORD secondary1 = HIWORD(secondaryResult);
  46. WORD secondary2 = LOWORD(secondaryResult);
  47. wsprintf(szBuffer[cLine], "SCMD_BLK: %x", secondary1);
  48. cLine += 1;
  49. wsprintf(szBuffer[cLine], "SCNL_BLK: %x", secondary2);
  50. cLine += 2;
  51.  
  52. DWORD primaryResult;
  53. primaryResult = myFunction(0, 31, 2, 0);
  54. WORD primary1 = HIWORD(primaryResult);
  55. WORD primary2 = LOWORD(primaryResult);
  56. wsprintf(szBuffer[cLine], "PCMD_BLK: %x", primary1);
  57. cLine += 1;
  58. wsprintf(szBuffer[cLine], "PCNL_BLK: %x", primary2);
  59. cLine += 2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement