Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Park Ju Hyung <[email protected]>
  • Loading branch information
arter97 committed Jun 30, 2018
0 parents commit 29d79ca
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.so
*.o
*.efi
41 changes: 41 additions & 0 deletions DisablePROCHOT.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2018 Park Ju Hyung

#include <efibind.h>
#include <efidef.h>
#include <efidevp.h>
#include <eficon.h>
#include <efiprot.h>
#include <efiapi.h>
#include <efierr.h>

static uint64_t AsmWriteMsr64(uint32_t index, uint64_t val)
{
uint32_t low;
uint32_t high;

low = (uint32_t)(val);
high = (uint32_t)(val >> 32);

__asm__ __volatile__ (
"wrmsr"
:
: "c" (index),
"a" (low),
"d" (high)
);

return val;
}

EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systemTable)
{
SIMPLE_TEXT_OUTPUT_INTERFACE *conOut = systemTable->ConOut;
conOut->OutputString(conOut, L"Disabling BD PROCHOT\r\n");

AsmWriteMsr64(0x1FC, 0);

conOut->OutputString(conOut, L"BD PROCHOT disabled\r\n");

return EFI_SUCCESS;
}
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Disable BD PROCHOT UEFI extension
A small EFI executable for disabling BD(Bi-directional) PROCHOT upon boot.

BD PROCHOT causes CPU to lock on the lowest clock speed, if motherboard deems
certain parts are overheated(hence bi-directional).

If a thermal sensor on the motherboard is broken, BD PROCHOT can always be tripped.
If your motherboard is out of warranty, feel free to use this instead.

While modern PC setups are very safe from components overheating so extremely
to cause BD PROCHOT(it's mostly for extremely poorly maintained PCs),
I still hold no responsibilities from possible damages being caused to your PC.

## Why use this instead of ThrottleStop?
ThrottleStop is loaded after the OS has finished booting,
which means your entire OS loading is still done extremely slowly.

This doesn't mean ThrottleStop is no longer needed.
Please read below.

## Usage
This EFI executable must be loaded at the bootloader level.
Please use rEFInd or Clover.

Copying DisablePROCHOT.efi to drivers64UEFI directory is enough for Clover.

## Warning
Entering ACPI S3 state(suspend) causes the BD PROCHOT MSR bit getting re-enabled.
You need to use some userspace tool for disabling BD PROCHOT for such cases.

In case of Windows, use ThrottleStop.
19 changes: 19 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

gcc -I/usr/include/efi -I/usr/include/efi/x86_64 \
-DGNU_EFI_USE_MS_ABI -Dx86_64 \
-fPIC -fshort-wchar -ffreestanding -fno-stack-protector -maccumulate-outgoing-args \
-Wall -Werror \
-m64 -mno-red-zone \
-c -o DisablePROCHOT.o DisablePROCHOT.c

ld -T /usr/lib/elf_x86_64_efi.lds -Bsymbolic -shared -nostdlib -znocombreloc \
/usr/lib/crt0-efi-x86_64.o \
-o DisablePROCHOT.so DisablePROCHOT.o \
$(gcc -print-libgcc-file-name) /usr/lib/libgnuefi.a

objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
-j .rela -j .reloc -S --target=efi-app-x86_64 DisablePROCHOT.so DisablePROCHOT.efi

ls -l DisablePROCHOT.efi
md5sum DisablePROCHOT.efi

0 comments on commit 29d79ca

Please sign in to comment.