1.3 KiB
1.3 KiB
TSC API
Introduction
In order to be able to measure and approximate time as soon as the kernel start the boot process, the TSC API is implemented in a volontary minimal way. The TSC API is defined inside shelter/lib/include/cpu/tsc.h and implemented inside shelter/lib/src/cpu/tsc.c. The API prefix is sh_tsc_.
Overview
The TSC API being intented for measuring time during the boot process, the provided features are extremely basic. In order for any TSC value to start at 0, we define two concept:
kernel_init_tsc: a TSC value initialized at the very start of the kernel boot processkernel_current_tsc: a TSC value which is the result ofkernel_init_tscsubstracted to the value returned bysh_asm_rdtsc()
API content
The API define the following elements:
sh_tsc_TSC_VALUE: a value of the TSC register, which is a wrapper of ash_uint64sh_tsc_read_value(): an inline function reading the TSC register usingsh_asm_rdtsc(), return ash_tsc_TSC_VALUEsh_tsc_init_tsc(): a function initializingkernel_init_tsc. This function should only be called once as soon as the kernel start. Return aSH_STATUSsh_tsc_get_kernel_init_tsc(): returnkernel_init_tscunder ash_tsc_TSC_VALUEsh_tsc_get_kernel_current_tsc(): return the result ofsh_asm_rdtsc()lesskernel_init_tsc, under ash_tsc_TSC_VALUE