Advertisement
Guest User

Untitled

a guest
Apr 9th, 2017
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.26 KB | None | 0 0
  1. {$apptype console}
  2. program testDrv; uses windows,sysutils;
  3.  
  4. var
  5.   r_eax:integer = 0;
  6.   r_ecx:integer = 0;
  7.   r_edx:integer = 0;
  8.  
  9. function inb(port:integer):byte;
  10. asm mov edx, eax
  11.     in al, dx
  12. end;
  13. procedure outb (port,val:integer);//val:byte);
  14. asm  xchg eax, edx
  15.      out dx, al
  16. end;
  17.  
  18. procedure cli;
  19. asm  cli
  20. end;
  21.  
  22. const
  23.  BASE = $18A0;
  24.  ClkGen = $D2;
  25.  SMBHSTSTS = 0;
  26.  SMBHSTCNT = 2;
  27.  SMBHSTCMD = 3;
  28.  SMBHSTADD = 4;
  29.  SMBHSTDAT = 5;
  30.  
  31.  
  32. function smb_read_byte_intel(reg:integer):byte;
  33. var i:integer;
  34. begin  
  35.     outb(BASE + SMBHSTSTS, $01f);// reset SMBus Controller
  36.     outb(base + SMBHSTDAT, $0ff);
  37.  
  38.    for i := 0 to 100000 do
  39.      begin
  40.        if (inb(base + SMBHSTSTS) and 01) = 0 then break;
  41.      end;
  42.  
  43.     outb(base + SMBHSTCMD, $80 +reg);
  44.     outb(base + SMBHSTADD, ClkGen or 1);
  45.     outb(base + SMBHSTCNT, $048 );
  46.  
  47.     for i := 0 to 100000 do
  48.      begin
  49.      if (inb(base + SMBHSTSTS) and 02) = 2 then break;
  50.      end;
  51.  
  52.             result :=  inb(base + SMBHSTDAT);
  53. end;
  54.  
  55. function write_pll(reg,val:integer):byte;
  56. var i:integer;
  57. begin  
  58.     outb(base + SMBHSTSTS, $01f);// reset SMBus Controller
  59.  
  60.     for i := 0 to 100000 do
  61.      begin
  62.        if (inb(base + SMBHSTSTS) and 01) = 0 then break;
  63.      end;
  64.  
  65.     outb(base + SMBHSTDAT, val);
  66.  
  67.     outb(base + SMBHSTCMD, $80+reg); //смещение + регистр
  68.     outb(base + SMBHSTADD, ClkGen);
  69.     outb(base + SMBHSTCNT, $048 );
  70.  
  71.     for i := 0 to 100000 do
  72.      begin
  73.      if (inb(base + SMBHSTSTS) and 02) = 2 then break;
  74.     end;
  75. end;
  76.  
  77. procedure Ring0;
  78. begin
  79.     //cli;
  80. //        write_pll($1C,$AB);
  81.  
  82. //    write_pll($19,$12);
  83.  //   write_pll($1A,$34);
  84.    // write_pll($1B,$56);
  85.     //write_pll($1C,$78);
  86.  
  87. //    write_pll($1C,$78);
  88.  
  89.  
  90.     write_pll($00, $67);
  91.     write_pll($0E, $0D);
  92.     write_pll($0F, $90);
  93.     write_pll($10, $3D);
  94.     write_pll($11, $C0);
  95.  
  96.     r_eax :=  smb_read_byte_intel ($f);
  97. end;
  98.  
  99. {$I-}
  100.  
  101. var
  102.     f:file;  proc :pointer;
  103. begin
  104.     Assign(f,'\\.\\MicroDrv');
  105.     Reset(f,1);
  106.     proc := @ring0;
  107.     BlockWrite(f,proc^,4);
  108.     close(f);
  109. //    readln;
  110.     writeln (inttohex (r_eax,8) );
  111.   //  writeln (  r_eax );//shr 16)  );
  112. //    writeln ( (r_ecx shr 16) and 1 );
  113.    writeln (inttohex ($D200 shr 8 ,8) );
  114. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement