From d86282a59b5ad0652c1071c364ed539e3536fb9a Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 17 Apr 2026 04:13:36 -0400 Subject: [PATCH] spi/amd64: Add CPUID helpers Signed-off-by: Ian Moffett --- .gitignore | 1 + usr/src/sp1/Makefile | 7 ++++++- usr/src/sp1/amd64/Makefile | 9 +++++---- usr/src/sp1/common/Makefile | 1 + usr/src/sp1/head/amd64/cpuid.h | 22 ++++++++++++++++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 usr/src/sp1/head/amd64/cpuid.h diff --git a/.gitignore b/.gitignore index 5657ee3..3c0556f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.o /var /usr/src/boot/stand +/usr/src/sp1/head/target diff --git a/usr/src/sp1/Makefile b/usr/src/sp1/Makefile index fd4f73e..889cf67 100644 --- a/usr/src/sp1/Makefile +++ b/usr/src/sp1/Makefile @@ -10,7 +10,12 @@ # .PHONY: all -all: common $(ARCH) +all: target common $(ARCH) + +.PHONY: target +target: + mkdir -p head/target/machine/ + rsync -avr head/$(ARCH)/*.h head/target/machine/ .PHONY: common common: diff --git a/usr/src/sp1/amd64/Makefile b/usr/src/sp1/amd64/Makefile index dde9951..a86aa17 100644 --- a/usr/src/sp1/amd64/Makefile +++ b/usr/src/sp1/amd64/Makefile @@ -24,10 +24,11 @@ CC = \ LD = \ ../../../../$(SYS_LD) -CFLAGS = \ - $(SYS_CFLAGS) \ - -I../../head \ - -I../../sp1/head\ +CFLAGS = \ + $(SYS_CFLAGS) \ + -I../../head \ + -I../../sp1/head/target \ + -I../../sp1/head \ -D_KERNEL .PHONY: all diff --git a/usr/src/sp1/common/Makefile b/usr/src/sp1/common/Makefile index b0738f0..ac0d40a 100644 --- a/usr/src/sp1/common/Makefile +++ b/usr/src/sp1/common/Makefile @@ -22,6 +22,7 @@ CC = ../../../../$(SYS_CC) CFLAGS = \ $(SYS_CFLAGS) \ -I../head \ + -I../head/target/ \ -I../../head \ -I../ext/flanterm/src/ \ -D_KERNEL \ diff --git a/usr/src/sp1/head/amd64/cpuid.h b/usr/src/sp1/head/amd64/cpuid.h new file mode 100644 index 0000000..010a39f --- /dev/null +++ b/usr/src/sp1/head/amd64/cpuid.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * All rights reserved. + * + * The following sources are CONFIDENTIAL and PROPRIETARY + * property of Mirocom Laboratories. Unauthorized copying, + * use, distribution or modification of this file, in whole + * and in part, is strictly prohibited without the prior written + * consent from Mirocom Laboratories. + */ + +#ifndef _MACHINE_CPUID_H_ +#define _MACHINE_CPUID_H_ 1 + +#include + +#define __cpuid(level, a, b, c, d) \ + __asmv("cpuid\n\t" \ + : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ + : "0" (level)) + +#endif /* !_MACHINE_CPUID_H_ */