arch/x86: Implement cpu_info in C code

Change-Id: Ic7396b8429e29739e18a189dacea3a76e571cd58
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57049
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Arthur Heymans 2021-08-19 13:06:52 +02:00 committed by Felix Held
parent c33dbc3a40
commit 83eb22e3b1
1 changed files with 4 additions and 14 deletions

View File

@ -3,6 +3,7 @@
#ifndef ARCH_CPU_H
#define ARCH_CPU_H
#include <stdint.h>
#include <types.h>
/*
@ -237,20 +238,9 @@ struct cpu_info {
static inline struct cpu_info *cpu_info(void)
{
struct cpu_info *ci;
__asm__(
#if ENV_X86_64
"and %%rsp,%0; "
"or %2, %0 "
#else
"andl %%esp,%0; "
"orl %2, %0 "
#endif
: "=r" (ci)
: "0" (~(CONFIG_STACK_SIZE - 1)),
"r" (CONFIG_STACK_SIZE - sizeof(struct cpu_info))
);
return ci;
char s;
uintptr_t info = ALIGN_UP((uintptr_t)&s, CONFIG_STACK_SIZE) - sizeof(struct cpu_info);
return (struct cpu_info *)info;
}
struct cpuinfo_x86 {