• Guest, The rules for the P & N subforum have been updated to prohibit "ad hominem" or personal attacks against other posters. See the full details in the post "Politics and News Rules & Guidelines."

What controls Turbo Core in Xeons?

Page 40 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

James Kim

Junior Member
Jun 3, 2017
17
3
41
So when you write "only x32", you think that it's a bad result? You're greedy, man :D

By the way, if I had your motherboard, I would be reluctant to try unlocking two E5-2696 V3 on it. They consume a lot of power (up to 240W in AVX2 applications if you don't use any microcode and up to 200W in regular applications) and this can contribute to VRMs overheating. Supermicro server boards don't seem to have decent VRM cooling including your board, and sometimes their VRMs don't even have a radiator sitting on them (isn't that so in your case?)



If I was you, I would use V3x2_cup39.efi which doesn't have -50mV vccin offset and has microcode built into it, therefore one CPU's TDP can never exceed 200W and probably won't even reach 180W
Hahaha, yeah I may be greedy. I don't need all the power. Just having fun with these mods.

Regarding VRM (Voltage Regulator Module, correct?) overheating, I don't know which sensors I should look for. VCPU1VRM is 39C and VCPU2VRM is 36C in idle. and they can go up to 65C with stress test. CPU VRMs should be seen near each CPU, correct?

I am currently using v3x2_50_39_vcc.efi and it gives me x33 on CPU1 and x31 or CPU2. I have no idea why I get .2 difference. But, it seems that it is best for me now.
Do you know what are different between v3x2_cp39 and v3x2_cup39?
 

traderjay

Senior member
Sep 24, 2015
219
165
116
Hi traderjay,

I have currently have X10DRL-i motherboard. And, I am sure that X10SRL-f is not much different from it. And, I am sure that you can unlock your e5-2696 v3 chip to 3.2Ghz(Spike to 3.8Ghz) all cores with modded BIOS and a EFI file instead of 2.8Ghz.

I have plan to upgrade my Lenovo TS440 system to X10SRL-f (that you have) soon and I have all parts and modded BIOS file. I didn't flash it yet since I just received the motherboard (Newegg was selling it for $175, Open box) yesterday. And, I will use e5-2658 v3. I was able to achieve 2.9Ghz all cores (12C, 24HT) with that chip on X10DRL-i motherboard.

If you can wait a couple of day, I will test the modded BIOS on my X10SRL-f and I will let you know. Or, you can mod it yourself using the tools available in this forum. Just grab the latest UBU and mmtool.exe. X10DRL-i and XSRL-f BIOS files should be very easy with the tools without any hiccup. Other Supermicro BIOS files seems to have issue with the tools and require manual mod using Hex editor.

Also, you may need to change CPU power settings to get optimal performance.
Hey James - Thank you so much for the reply and I look forward to your test results and the modded bios. I hope it will run with 100% stability and will represent a significant performance boost for our CPUs :)
 

sciff

Member
Mar 6, 2017
136
52
71
Hahaha, yeah I may be greedy. I don't need all the power. Just having fun with these mods.

Regarding VRM (Voltage Regulator Module, correct?) overheating, I don't know which sensors I should look for. VCPU1VRM is 39C and VCPU2VRM is 36C in idle. and they can go up to 65C with stress test. CPU VRMs should be seen near each CPU, correct?
Yes

I am currently using v3x2_50_39_vcc.efi and it gives me x33 on CPU1 and x31 or CPU2. I have no idea why I get .2 difference. But, it seems that it is best for me now.
Do you know what are different between v3x2_cp39 and v3x2_cup39?
"cup" versions force uncore to operate at the maximum possible multiplier (x30 in case of 2696). Even under heavy AVX2 load with extreme power consumption, uncore multiplier doesn't drop to x23 or even x12.
 

James Kim

Junior Member
Jun 3, 2017
17
3
41
"cup" versions force uncore to operate at the maximum possible multiplier (x30 in case of 2696). Even under heavy AVX2 load with extreme power consumption, uncore multiplier doesn't drop to x23 or even x12.
Thank you for the answer. It sounds like cup is good for benchmark or performance setting. From the Internet, uncore seems to be related the speed for L3 cache or memory controller and it is different from vcore. You said that "Under heavy load... uncore doesn't drop to x23". In normal operation, is it supposed drop the speed under heavy load? My assumption is that it should be higher as vcore get higher. I am not expert on this so I will appreciate if you can explain. Thanks again,
 

sciff

Member
Mar 6, 2017
136
52
71
James Kim
I said extreme power consumption meaning >200 W when .efi with no microcode is being used, which allows AVX2 to work at the same frequencies. If you use a non-cup or non-vcc .efi, then the uncore multiplier will drop, the CPU tries to lower TDP that way.
 
  • Like
Reactions: James Kim

James Kim

Junior Member
Jun 3, 2017
17
3
41
James Kim
I said extreme power consumption meaning >200 W when .efi with no microcode is being used, which allows AVX2 to work at the same frequencies. If you use a non-cup or non-vcc .efi, then the uncore multiplier will drop, the CPU tries to lower TDP that way.
I see. Thanks again!
 

thupig

Junior Member
Jun 29, 2017
2
0
6
No it doesn't, I am able (in linux) to load the power-save governor and see the expected behavior (idling down to 1200MHz). Interesting tough, the system is in a higher performance state by default with (particularly) the 50_39_vcc EFI MSR writes...

In a stock system (without the ucode exploit), my system comes up by default in the power-saving mode and idles down to 1200MHz quickly. Changing nothing in the OS, but enabling the ucode exploit and EFI driver, it comes up in a performance mode characterized by a few cores at 3.0-3.8 even when the system is relatively quiet/idle.

I would expect the same from windows. With the exploit + EFI drivers, you will find a system using higher idle power unless you intervene and set a power-saving profile.

Hi cekim, I am new here. Spent half day going thru all the posts. Thanks for all the helpful info here. I saw the overclocking is done under Windows, and you are benchmarking your CPU in linux. I too is a linux user. Do you first overclock the board and CPU in windows and then install linux OS? Correct me if my understanding is wrong. Thanks,
 

sciff

Member
Mar 6, 2017
136
52
71
thupig, I'm not cekim, but let me answer your question. Turbo unlock basically consists of two steps:
1) flashing modified bios,
2) loading EFI exploit, which actually does the unlocking.
No OS is needed, step #2 is done from EFI shell (which resembles DOS) that gets loaded from a USB flash drive through bios.
 

James Kim

Junior Member
Jun 3, 2017
17
3
41
Hey James - Thank you so much for the reply and I look forward to your test results and the modded bios. I hope it will run with 100% stability and will represent a significant performance boost for our CPUs :)
traderjay,

Here are the modded BIOS file to unlock the turbo. I tested it on my X10SRL-f motherboard last night and it worked fine.

mod_X10SRL-f.zip

I included EFI files also. So you should load one of them before getting into OS.

Before and After

Cinebench R15 score: Before: 1500, After: 1725.
CPU-Z (v1.79) multi-score: Before: 3934, After 4552.

Again, I am currently using E5-2658 v3 QS chip on this motherboard so there is no different on single core performance, but multi-threads performance is improved from 2.5Ghz all cores to 2.9 all cores after mod.

And, here is my BIOS settings. You may tweak them if it is needed.

CPU Configuration
---------------------------
Hyper-Threading (ALL) - [Enable]
Cores Enabled - [0]

CPU Configuration -> Advanced
---------------------------
Power Technology - [Custom]
Energy Performance Tuning - [Disable]
Energy Performance BIAS setting - [Performance]
Energy Efficient Turbo - [Disable]

Advanced -> CPU P State Control
--------------------------------
EIST (P-States) - [Enable]
Turbo Mode - [Enable]
P-State Coordination - [HW_ALL]

Advanced -> CPU C State Control
--------------------------------
Package C State Limit - [C0/C1 state]
CPU C3 Report - [Disable]
CPU C6 Report - [Enable]
Enhanced Halt State (C1E) - [Disable]

CPU T State Control
-------------------
ACPI T-States - [Enable]

Last, Windows OS Power Options - High Performance


Let me know if you need anything.
 
Last edited:

traderjay

Senior member
Sep 24, 2015
219
165
116
traderjay,

Here are the modded BIOS file to unlock the turbo. I tested it on my X10SRL-f motherboard last night and it worked fine.

mod_X10SRL-f.zip

I included EFI files also. So you should load one of them before getting into OS.

Before and After


Let me know if you need anything.
Hi James - Thank you so much for posting this! A few more questions - how stable is this for long term use? I read through the threads here and some users are experiencing issues but it is on a different motherboard make and model. Since my CPU has 18 cores I guess even with the turbos unlocked, it will only boost the cores within its thermal limit so as to prevent overheating?

Also, how do you go about loading EFI into a pre-existing Windows 10 pro installation?

Thanks again for the help!
 

James Kim

Junior Member
Jun 3, 2017
17
3
41
Hi James - Thank you so much for posting this! A few more questions - how stable is this for long term use? I read through the threads here and some users are experiencing issues but it is on a different motherboard make and model. Since my CPU has 18 cores I guess even with the turbos unlocked, it will only boost the cores within its thermal limit so as to prevent overheating?

Also, how do you go about loading EFI into a pre-existing Windows 10 pro installation?

Thanks again for the help!

On my other system. I have X10DRL-i with 2xE5-2696 v3 (turbo unlocked) and running as Windows Hyper-V server and have couples of VM guests. It has been running for a week without any issue. Again, I am not doing extreme computing all day long on the system so I don't know how much it can handle full load for a long period time. But, so far, all parameters (temperatures or voltages) are within normal ranges. If you want to save some energy, you may play BIOS settings. The settings I mentioned is not energy saving.

Regarding of loading EFI file before OS, you first need to have a flash drive and format it as FAT32. Then copy all files within the folder that I uploaded (Make sure to have startup.nsh file (you can edit it using notepad) and EFI folder to be at the root of the drive).

And, you will need to change boot options to UEFI or dual. I have my OS installed with UEFI so I changed my boot order to be UEFI: flash drive to be 1st and then UEFI: Windows boot manager to be the 2nd. This way, EFI loaded and then go to Windows boot on every boot.

If you want to load it manually, you may Press F11 (boot menu) at the boot time. And, select UEFI: [your flash drive]. By default, it will try to execute the startup.nsh script automatically, if you want to stop it, just press ESC when you have option and then you can execute your own commands.

One thing that I am not sure is that if you have to have OS installed in UEFI mode. You may test it yourself. And, make sure that you disable "Secure Boot" in BIOS.
 

pututu

Member
Jul 1, 2017
76
152
106
Many thanks to all the good work from members here. I managed to turbo boost all the 14 cores on my E5-2683v3 running on Asrock X99M Killer 3.0, Windows 7. I loaded V3.EFI driver and update to microcode 39 instead of 27. The only issue I'm facing now is how to lower the CPU Vcore voltage which in turns lower the power consumption as I'm running distributed computing project pretty much 24/7. BTW, the Asrock BIOS "OC Tweaker" main menu with XEON chip does not show the "FIVR Configuration" menu. Only shows "CPU configuration", "DRAM configuration" and "Voltage configuration" sub-menus. The last sub-menu did not have Vcore voltage tweak but the CPU input voltage. I tried Asrock F-stream tuning to change the Vcore but whenever I changed it back, it defaults to the original value (-21mV which I think is in the V3.EFI driver file?). Can anyone please suggest how to change the CPU vcore voltage? Many thanks!

HWinfo64 screenshot
F-stream screenshot. Note that even there is an override mode, it still doesn't allow me to change the Vcore voltage. Probably this is XEON limitation imposed by the BIOS?
HWinfo64 detail sensor readings. At 100% CPU load running BOINC project (World Community Grid), it consumes 100W with temp about 64°C but when I ran this without the BIOS hack, IIRC, it consumes about 70+W. I know it makes sense that running turbo on all cores will increase power consumption but I wanted to have some degree of control of the CPU Vcore voltage which I understand server XEON chips do not allow except the unlock XEON model.
 

cekim

Member
Mar 6, 2017
87
19
41
Hi cekim, I am new here. Spent half day going thru all the posts. Thanks for all the helpful info here. I saw the overclocking is done under Windows, and you are benchmarking your CPU in linux. I too is a linux user. Do you first overclock the board and CPU in windows and then install linux OS? Correct me if my understanding is wrong. Thanks,
What Sciff said...

1. mod bios
2. copy .EFI file to UEFI boot partition (linux in this case)
3. add driver in UEFI shell (bcfg driver add.... )
4. Boot linux (UEFI install) as usual

No windows on any of my uCoded machines at the moment...
 

Zladimir

Member
Apr 14, 2011
34
3
71
Has anyone else more information on the msr 0x150 ? Sadly there is no official documentation from Intel about it, except mentioning the purpose.
 

sUbZeRo_1337

Junior Member
Jul 4, 2017
3
0
6
Hey Guys! I have been following this a while now. I recently got an ASUS Z10pe D8WS and two Xeon E5 2648l V3 and I want to try this. But sadly i am obviously to stupid to Mod the Damn Bios of the Motherboard?! As i seen someone has done it with the D8! Maybe you can share your BIOS or help me out with modding mine?


Huge THANKS!!!
 

Dufus

Senior member
Sep 20, 2010
675
119
101
Has anyone else more information on the msr 0x150 ? Sadly there is no official documentation from Intel about it, except mentioning the purpose.
Don't have any doc's, just some empirical data. If that's good enough for you let me know.
 

Dufus

Senior member
Sep 20, 2010
675
119
101
Yup, let us know. :)
Use at your own risk and responsibility or not at all. It's mostly derived from guess work so might be some errors. Be careful not to kill the CPU or anything attached to it.


Code:
EDX = Mailbox Function
Bit(s)
7:0    Command
10:8   Domain
31     Run

EDX also returns error codes 7:0? when MSR read back, 0 = Success

EAX = Data


Domains
0      Core
1      Graphics
2      Cache
3      System Agent
4      Ananlogue I/O
5      Digital I/O

Command 0x1 Read Capabilities
Bit(s)
7:0    Maximum Ratio
8      Ratio changeable
9      Static Voltage supported
10     Offset Voltage supported

Command 0x2 Read Turbo ratios (across domains)

Command 0x10 Read Voltages and ratios, 0x11 Set Voltages and ratios
Bit(s)
7:0    Ratio limit
19:8   Static Voltage   ( V / 1024)
20     0 = Dynamic Voltage, 1 = Fixed Voltage
31:21  Offset Voltage, -1024 to 1023 (-1V to +0.999V)

Command 0x12 Read SVID, 0x13 Set SVID
Bit(s)
11:0   SVID (VCCIN),    Voltage divided by 1024, 0 = Dynamic
31     1 = Lock / Disable SVID comm's

Command 0x14 Read FIVR parameters, 0x15 Set FIVR parameters
Bit(s)
0      FIVR Faults,        ignore = 1
1      FIVR Efficiency,   disable = 1


While it appears fixed voltage should be supported for HSW Xeons only offset mode appears to work for my 2683.
Do you have the source of V3 ? ,
Could u send me a copy ?
thanks again
Be aware V3.EFI was only ever meant as a proof of concept and not a solution. Might need some extra work if you plan on using it. Written in FASM. FASM source will need to be modified if you want smaller sections.

Again, use at your own risk and responsibility or not at all.
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; V3.EFI                          ;;
;; Voltage in millivolts           ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

format PE64 dll efiboot at 0 on 'nul'
include 'efi3.inc'
;-------------------------------------------------------------------------------------------------------

 CoreVOffset            = -20
 CoreVStatic            = 0           
 CoreMulti              = 0           
 CoreFixed              = 0            

 if       CoreVOffset   > 999
          CoreVOffset   = 999
 else if  CoreVOffset   < -1000
          CoreVOffset   = -1000
 end if

 CoreAdjVOffset         = ((CoreVOffset shl 15)/1000) and 0ffe0h
 CoreAdjVStatic         = ((CoreVStatic shl 18)/1000) and 0fff00h
 CoreVoltage            = ((CoreAdjVOffset shl 16) or CoreAdjVStatic) or CoreMulti or (CoreFixed shl 20)
;-------------------------------------------------------------------------------------------------------

 CacheVOffset           = -20
 CacheVStatic           = 0
 CacheMulti             = 0
 CacheFixed             = 0

 if      CacheVOffset   > 999
         CacheVOffset   = 999
 else if CacheVOffset   < -1000
         CacheVOffset   = -1000
 end if

 CacheAdjVOffset        = ((CacheVOffset shl 15)/1000) and 0ffe0h
 CacheAdjVStatic        = ((CacheVStatic shl 18)/1000) and 0fff00h
 CacheVoltage           = ((CacheAdjVOffset shl 16) or CacheAdjVStatic) or CacheMulti or (CacheFixed shl 20)
;-------------------------------------------------------------------------------------------------------

section '.text' code readable executable

entry $
        push    rbx
        push    rcx
        push    rdx
        push    rdi
        push    rsi
        push    r15
        push    r14
        push    r13
        push    r12
        push    rbp

        sub     rsp,21h*8
        xor     r12,r12
        mov     r14,rcx                 ; ImageHandle
        mov     r15,rdx                 ; pointer to SystemTable


        mov     ebp,80000000h

        xor     eax,eax
        xor     edx,edx
        mov     ecx,8bh
        wrmsr
        xor     ecx,ecx
        inc     eax
        cpuid
        cmp     eax,306f2h
        jne     WrongCPU

        mov     ecx,8bh
        rdmsr
        cmp     edx,0
        jne     MicroCodePresent

        mov     ecx,194h
        rdmsr
        bt      eax,20
        jc      OC_Locked

        mov     ecx,150h                ; Get Core OC ratio and capabilities
        mov     edx,ebp
        inc     edx
        xor     eax,eax
        wrmsr
        rdmsr
        cmp     dl,0
        jne     MailBoxError
        mov     [TopCore],al

        mov     edx,ebp                 ; Get Cache OC ratio and capabilities
        mov     dx,201h
        xor     eax,eax
        wrmsr
        rdmsr
        cmp     dl,0
        jne     MailBoxError
        mov     [TopCache],al

;        mov     edx,ebp
;        mov     dl,10h
;        xor     eax,eax
;        wrmsr
;        rdmsr
;        cmp     dl,0
;        jne     MailBoxError

        mov     eax,CoreVoltage
        mov     al,[TopCore]
        mov     edx,ebp                 ; Set Core OC ratio
        mov     dl,11h
        wrmsr
        rdmsr
        cmp     dl,0
        jne     MailBoxError


;        mov     edx,ebp
;        mov     dx,210h                 ; Set Cache OC ratio
;        xor     eax,eax
;        wrmsr
;        rdmsr
;        cmp     dl,0
;        jne     MailBoxError

        mov     eax,CacheVoltage
        mov     al,[TopCache]
        mov     edx,ebp
        mov     dx,211h
        wrmsr
        rdmsr
        cmp     dl,0
        jne     MailBoxError

        mov     al,[TopCore]            ; Set turbo ratio's
        mov     ah,al
        mov     dx,ax
        shl     eax,16
        mov     ax,dx
        mov     edx,eax
        mov     ecx,1adh
        wrmsr
        inc     ecx
        wrmsr
        inc     ecx
        or      edx,ebp
        wrmsr


        mov     ecx,620h                ; Set Cache Min/Max Ratios
        rdmsr
        mov     al,[TopCache]
        mov     ah,al
        wrmsr


        mov     ecx,194h                ; Lock OC
        rdmsr
        bts     eax,20
        wrmsr

        lea     rdx,[_Success]
        call    TextOut
        jmp     @f

  WrongCPU:
        lea     rdx,[_WrongCPU]
        call    TextOut
        xor     rax,rax
        jmp     @f

  MicroCodePresent:
        lea     rdx,[_MicroCodePresent]
        call    TextOut
        xor     rax,rax
        jmp     @f

  OC_Locked:
        lea     rdx,[_OC_Locked]
        call    TextOut
        xor     rax,rax
        jmp     @f

  MailBoxError:
        lea     rdx,[_MailBoxError]
        call    TextOut
        xor     rax,rax
        jmp     @f


  @@:

        xor     rax,rax
        add     rsp,21h*8
        pop     rbp
        pop     r12
        pop     r13
        pop     r14
        pop     r15
        pop     rsi
        pop     rdi
        pop     rdx
        pop     rcx
        pop     rbx

        ret

  TextOut:
        sub     rsp,5*8
        mov     rcx, [r15 + EFI_SYSTEM_TABLE.ConOut]
        call    [rcx + SIMPLE_TEXT_OUTPUT_INTERFACE.OutputString]
        add     rsp,5*8
        retn


section '.data' data readable writeable

   TopCore              db ?
   TopCache             db ?
  _WrongCPU             du 13,10,'V3 - Wrong CPU.',13,10,0
  _MicroCodePresent     du 13,10,'V3 - Microcode present.',13,10,0
  _OC_Locked            du 13,10,'V3 - Overclocking Locked.',13,10,0
  _MailBoxError         du 13,10,'V3 - Mailbox Error.',13,10,0
  _Success              du 13,10,'V3 - All Turbo Set',13,10,0
 
Last edited:

youcantsee

Junior Member
Jul 3, 2017
3
1
36
thanks, i will use it in E3V3


Use at your own risk and responsibility or not at all. It's mostly derived from guess work so might be some errors. Be careful not to kill the CPU or anything attached to it.


Code:
EDX = Mailbox Function
Bit(s)
7:0    Command
10:8   Domain
31     Run

EDX also returns error codes 7:0? when MSR read back, 0 = Success

EAX = Data


Domains
0      Core
1      Graphics
2      Cache
3      System Agent
4      Ananlogue I/O
5      Digital I/O

Command 0x1 Read Capabilities
Bit(s)
7:0    Maximum Ratio
8      Ratio changeable
9      Static Voltage supported
10     Offset Voltage supported

Command 0x2 Read Turbo ratios (across domains)

Command 0x10 Read Voltages and ratios, 0x11 Set Voltages and ratios
Bit(s)
7:0    Ratio limit
19:8   Static Voltage   ( V / 1024)
20     0 = Dynamic Voltage, 1 = Fixed Voltage
31:21  Offset Voltage, -1024 to 1023 (-1V to +0.999V)

Command 0x12 Read SVID, 0x13 Set SVID
Bit(s)
11:0   SVID (VCCIN),    Voltage divided by 1024, 0 = Dynamic
31     1 = Lock / Disable SVID comm's

Command 0x14 Read FIVR parameters, 0x15 Set FIVR parameters
Bit(s)
0      FIVR Faults,        ignore = 1
1      FIVR Efficiency,   disable = 1


While it appears fixed voltage should be supported for HSW Xeons only offset mode appears to work for my 2683.


Be aware V3.EFI was only ever meant as a proof of concept and not a solution. Might need some extra work if you plan on using it. Written in FASM. FASM source will need to be modified if you want smaller sections.

Again, use at your own risk and responsibility or not at all.
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; V3.EFI                          ;;
;; Voltage in millivolts           ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

format PE64 dll efiboot at 0 on 'nul'
include 'efi3.inc'
;-------------------------------------------------------------------------------------------------------

 CoreVOffset            = -20
 CoreVStatic            = 0          
 CoreMulti              = 0          
 CoreFixed              = 0           

 if       CoreVOffset   > 999
          CoreVOffset   = 999
 else if  CoreVOffset   < -1000
          CoreVOffset   = -1000
 end if

 CoreAdjVOffset         = ((CoreVOffset shl 15)/1000) and 0ffe0h
 CoreAdjVStatic         = ((CoreVStatic shl 18)/1000) and 0fff00h
 CoreVoltage            = ((CoreAdjVOffset shl 16) or CoreAdjVStatic) or CoreMulti or (CoreFixed shl 20)
;-------------------------------------------------------------------------------------------------------

 CacheVOffset           = -20
 CacheVStatic           = 0
 CacheMulti             = 0
 CacheFixed             = 0

 if      CacheVOffset   > 999
         CacheVOffset   = 999
 else if CacheVOffset   < -1000
         CacheVOffset   = -1000
 end if

 CacheAdjVOffset        = ((CacheVOffset shl 15)/1000) and 0ffe0h
 CacheAdjVStatic        = ((CacheVStatic shl 18)/1000) and 0fff00h
 CacheVoltage           = ((CacheAdjVOffset shl 16) or CacheAdjVStatic) or CacheMulti or (CacheFixed shl 20)
;-------------------------------------------------------------------------------------------------------

section '.text' code readable executable

entry $
        push    rbx
        push    rcx
        push    rdx
        push    rdi
        push    rsi
        push    r15
        push    r14
        push    r13
        push    r12
        push    rbp

        sub     rsp,21h*8
        xor     r12,r12
        mov     r14,rcx                 ; ImageHandle
        mov     r15,rdx                 ; pointer to SystemTable


        mov     ebp,80000000h

        xor     eax,eax
        xor     edx,edx
        mov     ecx,8bh
        wrmsr
        xor     ecx,ecx
        inc     eax
        cpuid
        cmp     eax,306f2h
        jne     WrongCPU

        mov     ecx,8bh
        rdmsr
        cmp     edx,0
        jne     MicroCodePresent

        mov     ecx,194h
        rdmsr
        bt      eax,20
        jc      OC_Locked

        mov     ecx,150h                ; Get Core OC ratio and capabilities
        mov     edx,ebp
        inc     edx
        xor     eax,eax
        wrmsr
        rdmsr
        cmp     dl,0
        jne     MailBoxError
        mov     [TopCore],al

        mov     edx,ebp                 ; Get Cache OC ratio and capabilities
        mov     dx,201h
        xor     eax,eax
        wrmsr
        rdmsr
        cmp     dl,0
        jne     MailBoxError
        mov     [TopCache],al

;        mov     edx,ebp
;        mov     dl,10h
;        xor     eax,eax
;        wrmsr
;        rdmsr
;        cmp     dl,0
;        jne     MailBoxError

        mov     eax,CoreVoltage
        mov     al,[TopCore]
        mov     edx,ebp                 ; Set Core OC ratio
        mov     dl,11h
        wrmsr
        rdmsr
        cmp     dl,0
        jne     MailBoxError


;        mov     edx,ebp
;        mov     dx,210h                 ; Set Cache OC ratio
;        xor     eax,eax
;        wrmsr
;        rdmsr
;        cmp     dl,0
;        jne     MailBoxError

        mov     eax,CacheVoltage
        mov     al,[TopCache]
        mov     edx,ebp
        mov     dx,211h
        wrmsr
        rdmsr
        cmp     dl,0
        jne     MailBoxError

        mov     al,[TopCore]            ; Set turbo ratio's
        mov     ah,al
        mov     dx,ax
        shl     eax,16
        mov     ax,dx
        mov     edx,eax
        mov     ecx,1adh
        wrmsr
        inc     ecx
        wrmsr
        inc     ecx
        or      edx,ebp
        wrmsr


        mov     ecx,620h                ; Set Cache Min/Max Ratios
        rdmsr
        mov     al,[TopCache]
        mov     ah,al
        wrmsr


        mov     ecx,194h                ; Lock OC
        rdmsr
        bts     eax,20
        wrmsr

        lea     rdx,[_Success]
        call    TextOut
        jmp     @f

  WrongCPU:
        lea     rdx,[_WrongCPU]
        call    TextOut
        xor     rax,rax
        jmp     @f

  MicroCodePresent:
        lea     rdx,[_MicroCodePresent]
        call    TextOut
        xor     rax,rax
        jmp     @f

  OC_Locked:
        lea     rdx,[_OC_Locked]
        call    TextOut
        xor     rax,rax
        jmp     @f

  MailBoxError:
        lea     rdx,[_MailBoxError]
        call    TextOut
        xor     rax,rax
        jmp     @f


  @@:

        xor     rax,rax
        add     rsp,21h*8
        pop     rbp
        pop     r12
        pop     r13
        pop     r14
        pop     r15
        pop     rsi
        pop     rdi
        pop     rdx
        pop     rcx
        pop     rbx

        ret

  TextOut:
        sub     rsp,5*8
        mov     rcx, [r15 + EFI_SYSTEM_TABLE.ConOut]
        call    [rcx + SIMPLE_TEXT_OUTPUT_INTERFACE.OutputString]
        add     rsp,5*8
        retn


section '.data' data readable writeable

   TopCore              db ?
   TopCache             db ?
  _WrongCPU             du 13,10,'V3 - Wrong CPU.',13,10,0
  _MicroCodePresent     du 13,10,'V3 - Microcode present.',13,10,0
  _OC_Locked            du 13,10,'V3 - Overclocking Locked.',13,10,0
  _MailBoxError         du 13,10,'V3 - Mailbox Error.',13,10,0
  _Success              du 13,10,'V3 - All Turbo Set',13,10,0
 

ASK THE COMMUNITY