📄 memory.~pas
字号:
dev0:=dev0 and $FFFFC000; tmp:=oHWIO.MemReadLong(dev0+$C00); mchcfg:=tmp and $FFFF; tmp:=oHWIO.MemReadLong(dev0+$120); drc:=tmp and $FFFF; DRAMRatio:=1; gRAMInfo.DRAMCoef:='1:1'; mchcfg2:=(mchcfg shr 4) and 3; if ((drc and 3) <> 2) then begin // We are in DDR1 Mode if (mchcfg2 = 1) then begin DRAMRatio:=0.8; gRAMInfo.DRAMCoef:='5:4'; end else begin DRAMRatio:=1; gRAMInfo.DRAMCoef:='1:1'; end; end else begin // We are in DDR2 Mode if (((mchcfg shr 2) and 1) = 1) then begin // We are in FSB1066 Mode if (mchcfg2 = 2) then begin DRAMRatio:=0.75; gRAMInfo.DRAMCoef:='4:3'; end else begin DRAMRatio:=1; gRAMInfo.DRAMCoef:='1:1'; end; end else case mchcfg2 of 1: begin DRAMRatio:=0.66667; gRAMInfo.DRAMCoef:='3:2'; end; 2: if (idetect<>$2590) then begin DRAMRatio:=1; gRAMInfo.DRAMCoef:='1:1'; end else begin DRAMRatio:=1.5; gRAMInfo.DRAMCoef:='2:3'; end; 3: begin // Checking for FSB533 Mode & Alviso if ((mchcfg and 1) = 0) then begin DRAMRatio:=1.33334; gRAMInfo.DRAMCoef:='3:4'; end else if (idetect = $2590) then begin DRAMRatio:=2; gRAMInfo.DRAMCoef:='2:1'; end else begin DRAMRatio:=1.5; gRAMInfo.DRAMCoef:='2:3'; end; end; end end; gRAMInfo.DRAMClock:=FSB*DRAMRatio;end;procedure poll_timings_i925(var Timings: tTimings; var gRAMInfo: tGRAMInfo);var dev0, drt, drc, dcc, idetect, temp, tmp: DWord;begin //Now, read MMR Base Address oHWIO.IPCIIORef.GetPCIRDWord(0, 0, 0, $44, dev0); oHWIO.IPCIIORef.GetPCIRDWord(0, 0, 0, $02, idetect); idetect:=(idetect shr 16) and $FFFF; dev0:=dev0 and $FFFFC000; //Set pointer for DRT tmp:=oHWIO.MemReadLong(dev0+$114); drt:=tmp and $FFFFFFFF; //Set pointer for DRC tmp:=oHWIO.MemReadLong(dev0+$120); drc:=tmp and $FFFFFFFF; //Set pointer for DCC tmp:=oHWIO.MemReadLong(dev0+$200); dcc:=tmp and $FFFFFFFF; //CAS Latency (tCAS) temp:=(drt shr 8) and $3; if ((drc and 3) = 2) then begin // Timings DDR-II gRAMInfo.DRAMType:='DDRII-SDRAM'; if (temp = $0) then Timings.CAS:=5 else if (temp = $1) then Timings.CAS:=4 else Timings.CAS:=3; end else begin // Timings DDR-I gRAMInfo.DRAMType:='DDR-SDRAM'; if (temp = $0) then Timings.CAS:=3 else if (temp = $1) then Timings.CAS:=2.5 else Timings.CAS:=2; end; //RAS-To-CAS (tRCD) Timings.RCD:=((drt shr 4) and $3)+2; //RAS Precharge (tRP) Timings.RP:=(drt and $3)+2; //RAS Active to precharge (tRAS) //If Lakeport, than change tRAS computation (Thanks to CDH, again) if (idetect = $2770) or (idetect = $2774) then Timings.RAS:=(drt shr 19) and $1F else Timings.RAS:=(drt shr 20) and $F; temp:=dcc and $3; if (temp = 1) then gRAMInfo.DRAMCnls:='Dual' else if (temp = 2) then gRAMInfo.DRAMCnls:='Dual' else gRAMInfo.DRAMCnls:='Single';end;//Intel i945 Methodsprocedure poll_fsb_i945(lCPUClock, FSB: double; Mult: single; var gRAMInfo: tGRAMInfo);var mchcfg, dev0, tmp: DWord; DRAMRation: single;begin //Find dramratio oHWIO.IPCIIORef.GetPCIRDWord(0, 0, 0, $44, dev0); dev0:=dev0 and $FFFFC000; tmp:=oHWIO.MemReadLong(dev0+$C00); mchcfg:=tmp and $FFFF; DRAMRation:=1; case ((mchcfg shr 4) and 7) of 1: begin DRAMRation:=1; gRAMInfo.DRAMCoef:='1:1'; end; 2: begin DRAMRation:=1.33334; gRAMInfo.DRAMCoef:='3:4'; end; 3: begin DRAMRation:=1.66667; gRAMInfo.DRAMCoef:='3:5'; end; 4: begin DRAMRation:=2; gRAMInfo.DRAMCoef:='1:2'; end; end; gRAMInfo.DRAMClock:=FSB*DRAMRation;end;//KT266 Methodsprocedure poll_fsb_kt266(lCPUClock, FSB: double; Mult: single; var gRAMInfo: tGRAMInfo);var reg69: Byte;begin oHWIO.IPCIIORef.GetPCIRByte(0, 0, 0, $69, reg69); reg69:=(reg69 shr 6) and $3; case reg69 of 0: begin gRAMInfo.DRAMCoef:='1:1'; gRAMInfo.DRAMClock:=FSB; end; 1: begin gRAMInfo.DRAMCoef:='FSB+33'; gRAMInfo.DRAMClock:=FSB+33; end; 2: begin gRAMInfo.DRAMCoef:='FSB-33'; gRAMInfo.DRAMClock:=FSB-33; end; 3: begin gRAMInfo.DRAMCoef:='FSB+66'; gRAMInfo.DRAMClock:=FSB+66; end; end;end;procedure poll_timings_kt266(var Timings: tTimings; var gRAMInfo: tGRAMInfo);var reg60, reg64: Byte;begin oHWIO.IPCIIORef.GetPCIRByte(0, 0, 0, $60, reg60); oHWIO.IPCIIORef.GetPCIRByte(0, 0, 0, $64, reg64); //CAS Latency (tCAS) reg60:=reg60 and $F; if (reg60 = 0) then //SDR-SDRAM begin gRAMInfo.DRAMType:='SDR-SDRAM'; case ((reg64 shr 4) and $3) of 0: Timings.CAS:=1; 1: Timings.CAS:=2; 2: Timings.CAS:=3; end; end else begin //DDR-SDRAM gRAMInfo.DRAMType:='DDR-SDRAM'; case ((reg64 shr 4) and $3) of 1: Timings.CAS:=2; 2: Timings.CAS:=2.5; 3: Timings.CAS:=3; end; end; //RAS-To-CAS (tRCD) if ((reg64 shr 2) and $1) = 1 then Timings.RCD:=3 else Timings.RCD:=2; //RAS Precharge (tRP) if ((reg64 shr 7) and $1) = 1 then Timings.RP:=3 else Timings.RP:=2; //RAS Active to precharge (tRAS) if ((reg64 shr 6) and $1) = 1 then Timings.RAS:=6 else Timings.RAS:=5;end;//CN333 Methodsprocedure poll_fsb_cn333(lCPUClock, FSB: double; Mult: single; var gRAMInfo: tGRAMInfo);var reg68: Byte;begin oHWIO.IPCIIORef.GetPCIRByte(0, 0, 3, $68, reg68); reg68:=reg68 and $F; case reg68 of 0: begin gRAMInfo.DRAMCoef:='1:1'; gRAMInfo.DRAMClock:=FSB; end; 1: begin gRAMInfo.DRAMCoef:='FSB+33'; gRAMInfo.DRAMClock:=FSB+33; end; 5: begin gRAMInfo.DRAMCoef:='FSB+66'; gRAMInfo.DRAMClock:=FSB+66; end; end;end;procedure poll_timings_cn333(var Timings: tTimings; var gRAMInfo: tGRAMInfo);var reg56: Byte;begin oHWIO.IPCIIORef.GetPCIRByte(0, 0, 3, $56, reg56); //CAS Latency (tCAS) Timings.CAS:=(((reg56 shr 4) and 3)+3)/2; //RAS-To-CAS (tRCD) Timings.RCD:=((reg56 shr 2) and 3)+2; //RAS Precharge (tRP) Timings.RP:=(reg56 and 3)+2; //RAS Active to precharge (tRAS) Timings.RAS:=((reg56 shr 6) and 3)+6;end;const KnownControllers = 27;
var
Controllers: array[1..KnownControllers] of Memory_Controller =
(
//AMD
(VendorID: $1022; DeviceID: $1100; name: 'AMD 8000'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
(VendorID: $1022; DeviceID: $7454; name: 'AMD 8000'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
//ALI
(VendorID: $10b9; DeviceID: $1687; name: 'ALI M1687'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
(VendorID: $10b9; DeviceID: $1689; name: 'ALI M1689'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
(VendorID: $10b9; DeviceID: $1695; name: 'ALI M1695'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
//ATI
(VendorID: $1002; DeviceID: $5950; name: 'ATI RS482'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
//nVidia
(VendorID: $10de; DeviceID: $01A4; name: 'nVidia nForce'; tested: 0; GetFSBMethod: nil; GetTmngsMethod: nil; SetupECCMethod: nil),
(VendorID: $10de; DeviceID: $01E0; name: 'nVidia nForce2 SPP'; tested: 0; GetFSBMethod: poll_fsb_nf2; GetTmngsMethod: poll_timings_nf2; SetupECCMethod: nil),
(VendorID: $10de; DeviceID: $00D1; name: 'nVidia nForce3'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
(VendorID: $10de; DeviceID: $00E1; name: 'nVidia nForce3 250'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
(VendorID: $10de; DeviceID: $005E; name: 'nVidia nForce4'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
(VendorID: $10de; DeviceID: $0071; name: 'nForce4 SLI Intel Edition'; tested: 0; GetFSBMethod: poll_fsb_nf4ie; GetTmngsMethod: poll_timings_nf4ie; SetupECCMethod: nil),
//VIA
(VendorID: $1106; DeviceID: $3099; name: 'VIA KT266(A)/KT333'; tested: 0; GetFSBMethod: poll_fsb_kt266; GetTmngsMethod: poll_timings_kt266; SetupECCMethod: nil),
(VendorID: $1106; DeviceID: $3123; name: 'VIA CLE266'; tested: 0; GetFSBMethod: poll_fsb_kt266; GetTmngsMethod: poll_timings_kt266; SetupECCMethod: nil),
(VendorID: $1106; DeviceID: $0259; name: 'VIA CN333'; tested: 0; GetFSBMethod: poll_fsb_cn333; GetTmngsMethod: poll_timings_cn333; SetupECCMethod: nil),
(VendorID: $1106; DeviceID: $3188; name: 'VIA K8T800'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
(VendorID: $1106; DeviceID: $0282; name: 'VIA K8T800Pro'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil), (VendorID: $1106; DeviceID: $3238; name: 'VIA K8T890'; tested: 0; GetFSBMethod: poll_fsb_amd64; GetTmngsMethod: poll_timings_amd64; SetupECCMethod: nil),
//Intel
(VendorID: $8086; DeviceID: $2588; name: 'Intel E7221'; tested: 0; GetFSBMethod: nil{poll_fsb_i925}; GetTmngsMethod: nil{poll_timings_i925}; SetupECCMethod: nil),
(VendorID: $8086; DeviceID: $2570; name: 'Intel i848/i865'; tested: 0; GetFSBMethod: nil{poll_fsb_i875}; GetTmngsMethod: nil{poll_timings_i875}; SetupECCMethod: nil),
(VendorID: $8086; DeviceID: $2578; name: 'Intel i875P'; tested: 0; GetFSBMethod: nil{poll_fsb_i875}; GetTmngsMethod: nil{poll_timings_i875}; SetupECCMethod: nil),
(VendorID: $8086; DeviceID: $3340; name: 'Intel i855PM'; tested: 0; GetFSBMethod: nil; GetTmngsMethod: nil; SetupECCMethod: nil),
(VendorID: $8086; DeviceID: $2580; name: 'Intel i915P/G'; tested: 0; GetFSBMethod: nil{poll_fsb_i925}; GetTmngsMethod: nil{poll_timings_i925}; SetupECCMethod: nil),
(VendorID: $8086; DeviceID: $2590; name: 'Intel i915PM/GM'; tested: 0; GetFSBMethod: nil{poll_fsb_i925}; GetTmngsMethod: nil{poll_timings_i925}; SetupECCMethod: nil),
(VendorID: $8086; DeviceID: $2584; name: 'Intel i925X/XE'; tested: 0; GetFSBMethod: nil{poll_fsb_i925}; GetTmngsMethod: nil{poll_timings_i925}; SetupECCMethod: nil),
(VendorID: $8086; DeviceID: $2770; name: 'Intel i945P/G'; tested: 0; GetFSBMethod: nil{poll_fsb_i945}; GetTmngsMethod: nil{poll_timings_i925}; SetupECCMethod: nil),
(VendorID: $8086; DeviceID: $2774; name: 'Intel i955X'; tested: 0; GetFSBMethod: nil{poll_fsb_i945}; GetTmngsMethod: nil{poll_timings_i925}; SetupECCMethod: nil)
);
constructor cMemory.Create;
begin
inherited Create;
fCtrl_Info.index:=0;
fCtrl_Info.dwBus:=0;
fCtrl_Info.dwDev:=0;
fCtrl_Info.dwFunc:=0;
DetectMemCtrl;
end;
procedure cMemory.DetectMemCtrl;
var
VendorID, DeviceID: DWord;
pdata: DWord;
i: byte;
begin
oHWIO.IPCIIORef.GetPCIRDWord(fCtrl_Info.dwBus, fCtrl_Info.dwDev, fCtrl_Info.dwFunc, 0, pdata);
VendorID:=Word(pdata);
DeviceID:=Word(pdata shr 16);
for i:=Low(Controllers) to High(Controllers) do
if ((Controllers[i].VendorID = VendorID) and (Controllers[i].DeviceID = DeviceID)) then
begin
fCtrl_Info.index:=i;
break;
end;
end;
function cMemory.GetPhysMemSize: DWord;
var
memStatus: TMemoryStatus;
begin
memStatus.dwLength:=sizeOf(memStatus);
GlobalMemoryStatus(memStatus);
result:=trunc(memStatus.dwTotalPhys/1048576)+1;
end;
procedure cMemory.FillMemCtrlInfo(lCPUClock, FSB: double; Mult: single);
begin
if fCtrl_Info.index<=0 then exit;
fgRAMInfo.RamSize:=GetPhysMemSize;
if Assigned(Controllers[fCtrl_Info.index].GetFSBMethod) then
Controllers[fCtrl_Info.index].GetFSBMethod(lCPUClock, FSB, Mult, fgRAMInfo);
if Assigned(Controllers[fCtrl_Info.index].GetTmngsMethod) then
Controllers[fCtrl_Info.index].GetTmngsMethod(fTimings, fgRAMInfo);
//ShowMessage(format('%x', [oHWIO.MemReadLong($20)]));
//oHWIO.MemReadLong($5)
end;
destructor cMemory.Destroy;
begin
inherited Destroy;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -