Stefan thinks they don't add value. Command used: sed -i -e '/file is part of /d' $(git grep "file is part of " |egrep ":( */\*.*\*/\$|#|;#|-- | *\* )" | cut -d: -f1 |grep -v crossgcc |grep -v gcov | grep -v /elf.h |grep -v nvramtool) The exceptions are for: - crossgcc (patch file) - gcov (imported from gcc) - elf.h (imported from GNU's libc) - nvramtool (more complicated header) The removed lines are: - fmt.Fprintln(f, "/* This file is part of the coreboot project. */") -# This file is part of a set of unofficial pre-commit hooks available -/* This file is part of coreboot */ -# This file is part of msrtool. -/* This file is part of msrtool. */ - * This file is part of ncurses, designed to be appended after curses.h.in -/* This file is part of pgtblgen. */ - * This file is part of the coreboot project. - /* This file is part of the coreboot project. */ -# This file is part of the coreboot project. -# This file is part of the coreboot project. -## This file is part of the coreboot project. --- This file is part of the coreboot project. -/* This file is part of the coreboot project */ -/* This file is part of the coreboot project. */ -;## This file is part of the coreboot project. -# This file is part of the coreboot project. It originated in the - * This file is part of the coreinfo project. -## This file is part of the coreinfo project. - * This file is part of the depthcharge project. -/* This file is part of the depthcharge project. */ -/* This file is part of the ectool project. */ - * This file is part of the GNU C Library. - * This file is part of the libpayload project. -## This file is part of the libpayload project. -/* This file is part of the Linux kernel. */ -## This file is part of the superiotool project. -/* This file is part of the superiotool project */ -/* This file is part of uio_usbdebug */ Change-Id: I82d872b3b337388c93d5f5bf704e9ee9e53ab3a9 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41194 Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/*
|
|
* udelay() implementation for SMI handlers
|
|
* This is neat in that it never writes to hardware registers, and thus does not
|
|
* modify the state of the hardware while servicing SMIs.
|
|
*/
|
|
|
|
#include <cpu/x86/msr.h>
|
|
#include <cpu/amd/msr.h>
|
|
#include <cpu/x86/tsc.h>
|
|
#include <delay.h>
|
|
#include <stdint.h>
|
|
|
|
void udelay(uint32_t us)
|
|
{
|
|
uint8_t fid, did, pstate_idx;
|
|
uint64_t tsc_clock, tsc_start, tsc_now, tsc_wait_ticks;
|
|
msr_t msr;
|
|
const uint64_t tsc_base = 100000000;
|
|
|
|
/* Get initial timestamp before we do the math */
|
|
tsc_start = rdtscll();
|
|
|
|
/* Get the P-state. This determines which MSR to read */
|
|
msr = rdmsr(PS_STS_REG);
|
|
pstate_idx = msr.lo & 0x07;
|
|
|
|
/* Get FID and VID for current P-State */
|
|
msr = rdmsr(PSTATE_0_MSR + pstate_idx);
|
|
|
|
/* Extract the FID and VID values */
|
|
fid = msr.lo & 0x3f;
|
|
did = (msr.lo >> 6) & 0x7;
|
|
|
|
/* Calculate the CPU clock (from base freq of 100MHz) */
|
|
tsc_clock = tsc_base * (fid + 0x10) / (1 << did);
|
|
|
|
/* Now go on and wait */
|
|
tsc_wait_ticks = (tsc_clock / 1000000) * us;
|
|
|
|
do {
|
|
tsc_now = rdtscll();
|
|
} while (tsc_now - tsc_wait_ticks < tsc_start);
|
|
}
|