aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--com32/gplinclude/cpuid.h2
-rw-r--r--com32/include/com32.h22
-rw-r--r--com32/include/sys/bitops.h31
-rw-r--r--com32/include/sys/cpu.h57
-rw-r--r--com32/include/sys/fpu.h2
-rw-r--r--com32/include/sys/i386/bitops.h54
-rw-r--r--com32/include/sys/i386/cpu.h114
-rw-r--r--com32/include/sys/module.h4
-rw-r--r--com32/include/sys/module32.h (renamed from com32/include/sys/i386/module.h)0
-rw-r--r--com32/include/sys/module64.h (renamed from com32/include/sys/x86_64/module.h)0
-rw-r--r--com32/include/sys/x86_64/cpu.h128
-rw-r--r--com32/include/x86/bitops.h (renamed from com32/include/sys/x86_64/bitops.h)27
-rw-r--r--com32/include/x86/cpu.h206
-rw-r--r--com32/include/x86/regs.h66
-rw-r--r--com32/lib/i386/math/init_fpu.c37
-rw-r--r--com32/lib/i386/math/pow.S (renamed from com32/lib/math/pow.S)0
-rw-r--r--com32/lib/pci/pci.h2
-rw-r--r--com32/lib/sys/i386/x86_init_fpu.c58
-rw-r--r--com32/lib/sys/vesa/i915resolution.c2
-rw-r--r--com32/lib/sys/vesa/initvesa.c2
-rw-r--r--com32/lib/sys/x86_64/x86_init_fpu.c58
-rw-r--r--com32/lib/sys/x86_init_fpu.c80
-rw-r--r--com32/lib/vdprintf.c2
-rw-r--r--com32/lib/x86_64/math/init_fpu.c31
-rw-r--r--com32/libupload/serial.c2
-rw-r--r--com32/menu/drain.c2
-rw-r--r--com32/modules/cpuid.c2
-rw-r--r--com32/sysdump/cpuid.c2
-rw-r--r--com32/sysdump/main.c2
-rw-r--r--com32/sysdump/memory.c2
-rw-r--r--core/conio.c2
-rw-r--r--core/dmi.c2
-rw-r--r--core/elflink/load_env32.c2
-rw-r--r--core/fs/pxe/dhcp_option.c2
-rw-r--r--core/fs/pxe/ftp.c2
-rw-r--r--core/fs/pxe/idle.c2
-rw-r--r--core/fs/pxe/isr.c2
-rw-r--r--core/fs/pxe/pxe.c2
-rw-r--r--core/idle.c2
-rw-r--r--core/include/thread.h2
-rw-r--r--core/legacynet/idle.c2
-rw-r--r--core/localboot.c2
-rw-r--r--core/thread/idle_thread.c2
-rw-r--r--core/thread/schedule.c2
-rw-r--r--core/thread/semaphore.c2
-rw-r--r--mk/lib.mk7
46 files changed, 422 insertions, 612 deletions
diff --git a/com32/gplinclude/cpuid.h b/com32/gplinclude/cpuid.h
index 0eb2826b..02f3a0b3 100644
--- a/com32/gplinclude/cpuid.h
+++ b/com32/gplinclude/cpuid.h
@@ -21,7 +21,7 @@
#include <stdio.h>
#include <cpufeature.h>
#include <sys/bitops.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <sys/io.h>
#include <klibc/compiler.h>
diff --git a/com32/include/com32.h b/com32/include/com32.h
index adef7126..1a843e0b 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -29,7 +29,7 @@
/*
* com32.h
*
- * Common declarations for com32 programs.
+ * Declarations for the BIOS call interface
*/
#ifndef _COM32_H
@@ -39,6 +39,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <klibc/compiler.h> /* For __cdecl */
+#include <x86/regs.h>
/*
* This structure defines the register frame used by the
@@ -73,25 +74,6 @@ typedef struct {
reg32_t eflags; /* Offset 40 */
} com32sys_t;
-/* EFLAGS definitions */
-#define EFLAGS_CF 0x00000001
-#define EFLAGS_PF 0x00000004
-#define EFLAGS_AF 0x00000010
-#define EFLAGS_ZF 0x00000040
-#define EFLAGS_SF 0x00000080
-#define EFLAGS_TF 0x00000100
-#define EFLAGS_IF 0x00000200
-#define EFLAGS_DF 0x00000400
-#define EFLAGS_OF 0x00000800
-#define EFLAGS_IOPL 0x00003000
-#define EFLAGS_NT 0x00004000
-#define EFLAGS_RF 0x00010000
-#define EFLAGS_VM 0x00020000
-#define EFLAGS_AC 0x00040000
-#define EFLAGS_VIF 0x00080000
-#define EFLAGS_VIP 0x00100000
-#define EFLAGS_ID 0x00200000
-
struct com32_pmapi;
extern struct com32_sys_args {
diff --git a/com32/include/sys/bitops.h b/com32/include/sys/bitops.h
index de30d932..017f600d 100644
--- a/com32/include/sys/bitops.h
+++ b/com32/include/sys/bitops.h
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 2010-2011 Intel Corporation; author: H. Peter Anvin
+ * Copyright 2010-2019 Intel Corporation; author: H. Peter Anvin
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -36,11 +36,30 @@
#include <klibc/compiler.h>
-#if __SIZEOF_POINTER__ == 4
-#include <i386/bitops.h>
-#elif __SIZEOF_POINTER__ == 8
-#include <x86_64/bitops.h>
+#if defined(__i386__) || defined(__x86_64__)
+# include <x86/bitops.h>
#else
-#error "Unable to build for to-be-defined architecture type"
+static inline void set_bit(long __bit, void *__bitmap)
+{
+ char *__cp = (char *)__bitmap;
+
+ __cp[__bit >> 3] |= 1 << (__bit & 7);
+}
+
+static inline void clr_bit(long __bit, void *__bitmap)
+{
+ char *__cp = (char *)__bitmap;
+
+ __cp[__bit >> 3] &= ~(1 << (__bit & 7));
+}
+
+static inline _Bool __purefunc test_bit(long __bit, const void *__bitmap)
+{
+ const char *__cp = (char *)__bitmap;
+
+ return (__cp[__bit >> 3] >> (__bit & 7)) & 1;
+}
+
#endif
+
#endif /* _BITOPS_H */
diff --git a/com32/include/sys/cpu.h b/com32/include/sys/cpu.h
deleted file mode 100644
index 76c45da0..00000000
--- a/com32/include/sys/cpu.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef _CPU_H
-#define _CPU_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <klibc/compiler.h>
-
-#if __SIZEOF_POINTER__ == 4
-#include <i386/cpu.h>
-#elif __SIZEOF_POINTER__ == 8
-#include <x86_64/cpu.h>
-#else
-#error "unsupported architecture"
-#endif
-
-typedef unsigned long irq_state_t;
-
-static inline irq_state_t irq_state(void)
-{
- irq_state_t __st;
-
- asm volatile("pushf ; pop %0" : "=rm" (__st) : : "memory");
- return __st;
-}
-
-static inline irq_state_t irq_save(void)
-{
- irq_state_t __st = irq_state();
- cli();
- return __st;
-}
-
-static inline void irq_restore(irq_state_t __st)
-{
- asm volatile("push %0 ; popf" : : "rm" (__st) : "memory");
-}
-
-/* Standard macro to see if a specific flag is changeable */
-static inline __constfunc bool cpu_has_eflag(unsigned long flag)
-{
- unsigned long f0, f1;
- asm("pushf ; "
- "pushf ; "
- "pop %0 ; "
- "mov %0,%1 ; "
- "xor %2,%1 ; "
- "push %1 ; "
- "popf ; "
- "pushf ; "
- "pop %1 ; "
- "popf"
- : "=&r" (f0), "=&r" (f1)
- : "ri" (flag));
- return !!((f0^f1) & flag);
-}
-
-#endif
diff --git a/com32/include/sys/fpu.h b/com32/include/sys/fpu.h
index 134ae596..7a69be5f 100644
--- a/com32/include/sys/fpu.h
+++ b/com32/include/sys/fpu.h
@@ -1,6 +1,6 @@
#ifndef _SYS_FPU_H
#define _SYS_FPU_H
-extern int x86_init_fpu(void);
+extern int init_fpu(void);
#endif /* _SYS_FPU_H */
diff --git a/com32/include/sys/i386/bitops.h b/com32/include/sys/i386/bitops.h
deleted file mode 100644
index 663b267a..00000000
--- a/com32/include/sys/i386/bitops.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2010-2011 Intel Corporation; author: H. Peter Anvin
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall
- * be included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * i386 bitops.h
- *
- * Simple bitwise operations
- */
-static inline void set_bit(long __bit, void *__bitmap)
-{
- asm volatile("btsl %1,%0"
- : "+m" (*(unsigned char *)__bitmap)
- : "Ir" (__bit) : "memory");
-}
-
-static inline void clr_bit(long __bit, void *__bitmap)
-{
- asm volatile("btcl %1,%0"
- : "+m" (*(unsigned char *)__bitmap)
- : "Ir" (__bit) : "memory");
-}
-
-static inline int __purefunc test_bit(long __bit, const void *__bitmap)
-{
- unsigned char __r;
- asm("btl %2,%1; setc %0"
- : "=qm" (__r)
- : "m" (*(const unsigned char *)__bitmap), "Ir" (__bit));
- return __r;
-}
diff --git a/com32/include/sys/i386/cpu.h b/com32/include/sys/i386/cpu.h
deleted file mode 100644
index a0cedf20..00000000
--- a/com32/include/sys/i386/cpu.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* i386 cpu.h */
-
-static inline uint64_t rdtsc(void)
-{
- uint64_t v;
- asm volatile("rdtsc" : "=A" (v));
- return v;
-}
-
-static inline uint32_t rdtscl(void)
-{
- uint32_t v;
- asm volatile("rdtsc" : "=a" (v) : : "edx");
- return v;
-}
-
-static inline void cpuid_count(uint32_t op, uint32_t cnt,
- uint32_t * eax, uint32_t * ebx,
- uint32_t * ecx, uint32_t * edx)
-{
- asm volatile("movl %%ebx,%1 ; "
- "cpuid ; "
- "xchgl %1,%%ebx"
- : "=a" (*eax), "=SD" (*ebx), "=c" (*ecx), "=d" (*edx)
- : "a"(op), "c"(cnt));
-}
-
-static inline void cpuid(uint32_t op, uint32_t * eax, uint32_t * ebx,
- uint32_t * ecx, uint32_t * edx)
-{
- cpuid_count(op, 0, eax, ebx, ecx, edx);
-}
-
-static inline __constfunc uint32_t cpuid_eax(uint32_t level)
-{
- uint32_t v;
-
- asm volatile("pushl %%ebx ; "
- "cpuid ; "
- "popl %%ebx"
- : "=a" (v)
- : "a"(level)
- : "ecx", "edx");
- return v;
-}
-
-static inline __constfunc uint32_t cpuid_ebx(uint32_t level)
-{
- uint32_t v;
-
- asm volatile("movl %%ebx,%0 ; "
- "cpuid ; "
- "xchgl %0,%%ebx"
- : "=SD" (v), "+a" (level)
- : : "ecx", "edx");
- return v;
-}
-
-static inline __constfunc uint32_t cpuid_ecx(uint32_t level)
-{
- uint32_t v;
-
- asm volatile("pushl %%ebx ; "
- "cpuid ; "
- "popl %%ebx"
- : "=c" (v), "+a" (level)
- : : "edx");
- return v;
-}
-
-static inline __constfunc uint32_t cpuid_edx(uint32_t level)
-{
- uint32_t v;
-
- asm volatile("pushl %%ebx ; "
- "cpuid ; "
- "popl %%ebx"
- : "=d" (v), "+a" (level)
- : : "ecx");
- return v;
-}
-
-static inline uint64_t rdmsr(uint32_t msr)
-{
- uint64_t v;
-
- asm volatile("rdmsr" : "=A" (v) : "c"(msr));
- return v;
-}
-
-static inline void wrmsr(uint64_t v, uint32_t msr)
-{
- asm volatile("wrmsr" : : "A" (v), "c" (msr));
-}
-
-static inline void cpu_relax(void)
-{
- asm volatile("rep ; nop" : : : "memory");
-}
-
-static inline void hlt(void)
-{
- asm volatile("hlt" : : : "memory");
-}
-
-static inline void cli(void)
-{
- asm volatile("cli" : : : "memory");
-}
-
-static inline void sti(void)
-{
- asm volatile("sti" : : : "memory");
-}
diff --git a/com32/include/sys/module.h b/com32/include/sys/module.h
index 48d65b2a..8e48fb2d 100644
--- a/com32/include/sys/module.h
+++ b/com32/include/sys/module.h
@@ -15,9 +15,9 @@
#include <linux/list.h>
#if __SIZEOF_POINTER__ == 4
-#include <i386/module.h>
+#include "module32.h"
#elif __SIZEOF_POINTER__ == 8
-#include <x86_64/module.h>
+#include "module64.h"
#else
#error "unsupported architecture"
#endif
diff --git a/com32/include/sys/i386/module.h b/com32/include/sys/module32.h
index 21988ead..21988ead 100644
--- a/com32/include/sys/i386/module.h
+++ b/com32/include/sys/module32.h
diff --git a/com32/include/sys/x86_64/module.h b/com32/include/sys/module64.h
index 203a6cd0..203a6cd0 100644
--- a/com32/include/sys/x86_64/module.h
+++ b/com32/include/sys/module64.h
diff --git a/com32/include/sys/x86_64/cpu.h b/com32/include/sys/x86_64/cpu.h
deleted file mode 100644
index cbe968f5..00000000
--- a/com32/include/sys/x86_64/cpu.h
+++ /dev/null
@@ -1,128 +0,0 @@
-#ifndef _CPU_X86_64_H
-#define _CPU_X86_64_H
-
-/* x86_64 cpu.h */
-
-static inline uint64_t rdtsc(void)
-{
- uint64_t v;
- asm volatile("rdtsc" : "=A" (v));
- return v;
-}
-
-static inline uint32_t rdtscl(void)
-{
- uint32_t v;
- asm volatile("rdtsc" : "=a" (v) : : "edx");
- return v;
-}
-
-static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- /* ecx is often an input as well as an output. */
- asm volatile("cpuid"
- : "=a" (*eax),
- "=b" (*ebx),
- "=c" (*ecx),
- "=d" (*edx)
- : "0" (*eax), "2" (*ecx)
- : "memory");
-}
-/*
- * Generic CPUID function
- * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
- * resulting in stale register contents being returned.
- */
-static inline void cpuid(uint32_t op,
- uint32_t *eax, uint32_t *ebx,
- uint32_t *ecx, uint32_t *edx)
-{
- *eax = op;
- *ecx = 0;
- native_cpuid(eax, ebx, ecx, edx);
-}
-
-/*
- * CPUID functions returning a single datum
- */
-static inline uint32_t cpuid_eax(uint32_t op)
-{
- uint32_t eax, ebx, ecx, edx;
-
- cpuid(op, &eax, &ebx, &ecx, &edx);
-
- return eax;
-}
-
-static inline uint32_t cpuid_ebx(uint32_t op)
-{
- uint32_t eax, ebx, ecx, edx;
-
- cpuid(op, &eax, &ebx, &ecx, &edx);
-
- return ebx;
-}
-
-static inline uint32_t cpuid_ecx(uint32_t op)
-{
- uint32_t eax, ebx, ecx, edx;
-
- cpuid(op, &eax, &ebx, &ecx, &edx);
-
- return ecx;
-}
-
-static inline uint32_t cpuid_edx(uint32_t op)
-{
- uint32_t eax, ebx, ecx, edx;
-
- cpuid(op, &eax, &ebx, &ecx, &edx);
-
- return edx;
-}
-
-static inline void cpuid_count(uint32_t op, uint32_t cnt,
- uint32_t * eax, uint32_t * ebx,
- uint32_t * ecx, uint32_t * edx)
-{
- asm volatile("movl %%ebx,%1 ; "
- "cpuid ; "
- "xchgl %1,%%ebx"
- : "=a" (*eax), "=SD" (*ebx), "=c" (*ecx), "=d" (*edx)
- : "a"(op), "c"(cnt));
-}
-
-static inline uint64_t rdmsr(uint32_t msr)
-{
- uint64_t v;
-
- asm volatile("rdmsr" : "=A" (v) : "c"(msr));
- return v;
-}
-
-static inline void wrmsr(uint64_t v, uint32_t msr)
-{
- asm volatile("wrmsr" : : "A" (v), "c" (msr));
-}
-
-static inline void cpu_relax(void)
-{
- asm volatile("rep ; nop" : : : "memory");
-}
-
-static inline void hlt(void)
-{
- asm volatile("hlt" : : : "memory");
-}
-
-static inline void cli(void)
-{
- asm volatile("cli" : : : "memory");
-}
-
-static inline void sti(void)
-{
- asm volatile("sti" : : : "memory");
-}
-#endif
diff --git a/com32/include/sys/x86_64/bitops.h b/com32/include/x86/bitops.h
index 7b1cc2b6..7667b6bf 100644
--- a/com32/include/sys/x86_64/bitops.h
+++ b/com32/include/x86/bitops.h
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2010-2011 Intel Corporation; author: H. Peter Anvin
*
* Permission is hereby granted, free of charge, to any person
@@ -10,10 +10,10 @@
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
- *
+ *
* The above copyright notice and this permission notice shall
* be included in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -26,11 +26,14 @@
* ----------------------------------------------------------------------- */
/*
- * bitops.h - i386
+ * x86/bitops.h
*
* Simple bitwise operations
*/
+#ifndef _X86_BITOPS_H
+#define _X86_BITOPS_H
+
static inline void set_bit(long __bit, void *__bitmap)
{
asm volatile("bts %1,%0"
@@ -40,16 +43,26 @@ static inline void set_bit(long __bit, void *__bitmap)
static inline void clr_bit(long __bit, void *__bitmap)
{
- asm volatile("btcl %1,%0"
+ asm volatile("btc %1,%0"
: "+m" (*(unsigned char *)__bitmap)
: "Ir" (__bit) : "memory");
}
-static inline int __purefunc test_bit(long __bit, const void *__bitmap)
+static inline _Bool __purefunc test_bit(long __bit, const void *__bitmap)
{
- unsigned char __r;
+ _Bool __r;
+
+#ifdef __GCC_ASM_FLAG_OUTPUTS__
+ asm("bt %2,%1"
+ : "=@ccc" (__r)
+ : "m" (*(const unsigned char *)__bitmap), "Ir" (__bit));
+#else
asm("bt %2,%1; setc %0"
: "=qm" (__r)
: "m" (*(const unsigned char *)__bitmap), "Ir" (__bit));
+#endif
+
return __r;
}
+
+#endif /* _X86_BITOPS_H */
diff --git a/com32/include/x86/cpu.h b/com32/include/x86/cpu.h
new file mode 100644
index 00000000..5bdc74de
--- /dev/null
+++ b/com32/include/x86/cpu.h
@@ -0,0 +1,206 @@
+#ifndef _X86_CPU_H
+#define _X86_CPU_H
+
+#include <klibc/compiler.h>
+#include <inttypes.h>
+#include <stdbool.h>
+
+static inline bool cpu_has_eflag(unsigned long flag)
+{
+ unsigned long f1, f2;
+
+ asm("pushf ; "
+ "pushf ; "
+ "pop %0 ; "
+ "mov %0,%1 ; "
+ "xor %2,%1 ; "
+ "push %1 ; "
+ "popf ; "
+ "pushf ; "
+ "pop %1 ; "
+ "popf"
+ : "=r" (f1), "=r" (f2) : "ri" (flag));
+
+ return !!((f1 ^ f2) & flag);
+}
+
+static inline uint64_t rdtsc(void)
+{
+ uint32_t eax, edx;
+ asm volatile("rdtsc" : "=a" (eax), "=d" (edx));
+ return eax + ((uint64_t)edx << 32);
+}
+
+static inline uint32_t rdtscl(void)
+{
+ uint32_t v;
+ asm volatile("rdtsc" : "=a" (v) : : "edx");
+ return v;
+}
+
+static inline void cpuid_count(uint32_t op, uint32_t cnt,
+ uint32_t *eax, uint32_t *ebx,
+ uint32_t *ecx, uint32_t *edx)
+{
+#if defined(__i386__) && defined(__PIC__)
+ asm volatile("movl %%ebx,%1 ; "
+ "cpuid ; "
+ "xchgl %1,%%ebx"
+ : "=a" (*eax), "=SD" (*ebx), "=c" (*ecx), "=d" (*edx)
+ : "a"(op), "c"(cnt));
+#else
+ asm volatile("cpuid"
+ : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
+ : "a"(op), "c"(cnt));
+#endif
+}
+
+static inline void cpuid(uint32_t op,
+ uint32_t *eax, uint32_t *ebx,
+ uint32_t *ecx, uint32_t *edx)
+{
+ cpuid_count(op, 0, eax, ebx, ecx, edx);
+}
+
+static inline __constfunc uint32_t cpuid_eax(uint32_t level)
+{
+ uint32_t eax, ebx, ecx, edx;
+
+ cpuid_count(level, 0, &eax, &ebx, &ecx, &edx);
+ return eax;
+}
+
+static inline __constfunc uint32_t cpuid_ebx(uint32_t level)
+{
+ uint32_t eax, ebx, ecx, edx;
+
+ cpuid_count(level, 0, &eax, &ebx, &ecx, &edx);
+ return ebx;
+}
+
+static inline __constfunc uint32_t cpuid_ecx(uint32_t level)
+{
+ uint32_t eax, ebx, ecx, edx;
+
+ cpuid_count(level, 0, &eax, &ebx, &ecx, &edx);
+ return ecx;
+}
+
+static inline __constfunc uint32_t cpuid_edx(uint32_t level)
+{
+ uint32_t eax, ebx, ecx, edx;
+
+ cpuid_count(level, 0, &eax, &ebx, &ecx, &edx);
+ return edx;
+}
+
+static inline uint64_t rdmsr(uint32_t msr)
+{
+ uint32_t eax, edx;
+
+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (msr));
+ return eax + ((uint64_t)edx << 32);
+}
+
+static inline void wrmsr(uint64_t v, uint32_t msr)
+{
+ uint32_t eax = v;
+ uint32_t edx = v >> 32;
+
+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (msr));
+}
+
+static inline unsigned long long get_cr0(void)
+{
+ unsigned long v;
+ asm volatile("mov %%cr0,%0" : "=r" (v));
+ return v;
+}
+
+static inline void set_cr0(unsigned long v)
+{
+ asm volatile("mov %0,%%cr0" : : "r" (v));
+}
+
+static inline unsigned long get_cr4(void)
+{
+ unsigned long v;
+ asm volatile("mov %%cr4,%0" : "=r" (v));
+ return v;
+}
+
+static inline void set_cr4(unsigned long v)
+{
+ asm volatile("mov %0,%%cr4" : : "r" (v));
+}
+
+static inline uint32_t get_mxcsr(void)
+{
+ uint32_t v;
+ asm("stmxcsr %0" : "=m" (v));
+ return v;
+}
+
+static inline void set_mxcsr(uint32_t v)
+{
+ asm volatile("ldmxcsr %0" : : "m" (v));
+}
+
+static inline void fninit(void)
+{
+ asm volatile("fninit");
+}
+
+static inline void cpu_relax(void)
+{
+ asm volatile("rep ; nop");
+}
+
+static inline void hlt(void)
+{
+ asm volatile("hlt" : : : "memory");
+}
+
+static inline void cli(void)
+{
+ asm volatile("cli" : : : "memory");
+}
+
+static inline void sti(void)
+{
+ asm volatile("sti" : : : "memory");
+}
+
+static inline unsigned long get_eflags(void)
+{
+ unsigned long v;
+
+ asm volatile("pushf ; pop %0" : "=rm" (v));
+ return v;
+}
+
+static inline void set_eflags(unsigned long v)
+{
+ asm volatile("push %0 ; popf" : : "g" (v) : "memory");
+}
+
+typedef unsigned long irq_state_t;
+
+static inline irq_state_t irq_state(void)
+{
+ return get_eflags();
+}
+
+static inline irq_state_t irq_save(void)
+{
+ irq_state_t v = irq_state();
+ cli();
+ return v;
+}
+
+static inline void irq_restore(irq_state_t v)
+{
+ set_eflags(v);
+}
+
+#endif /* _X86_CPU_H */
diff --git a/com32/include/x86/regs.h b/com32/include/x86/regs.h
new file mode 100644
index 00000000..62f3a53d
--- /dev/null
+++ b/com32/include/x86/regs.h
@@ -0,0 +1,66 @@
+#ifndef _X86_REGS_H
+#define _X86_REGS_H
+
+/*
+ * Register definitions for x86 - should be assembly-safe
+ */
+
+/* EFLAGS definitions */
+#define EFLAGS_CF 0x00000001
+#define EFLAGS_PF 0x00000004
+#define EFLAGS_AF 0x00000010
+#define EFLAGS_ZF 0x00000040
+#define EFLAGS_SF 0x00000080
+#define EFLAGS_TF 0x00000100
+#define EFLAGS_IF 0x00000200
+#define EFLAGS_DF 0x00000400
+#define EFLAGS_OF 0x00000800
+#define EFLAGS_IOPL 0x00003000
+#define EFLAGS_NT 0x00004000
+#define EFLAGS_RF 0x00010000
+#define EFLAGS_VM 0x00020000
+#define EFLAGS_AC 0x00040000
+#define EFLAGS_VIF 0x00080000
+#define EFLAGS_VIP 0x00100000
+#define EFLAGS_ID 0x00200000
+
+/* CR0 definitions */
+#define CR0_PE 0x00000001
+#define CR0_MP 0x00000002
+#define CR0_EM 0x00000004
+#define CR0_TS 0x00000008
+#define CR0_ET 0x00000010
+#define CR0_NE 0x00000020
+#define CR0_WP 0x00010000
+#define CR0_AM 0x00040000
+#define CR0_NW 0x20000000
+#define CR0_CD 0x40000000
+#define CR0_PG 0x80000000
+
+/* CR4 definitions */
+#define CR4_VME 0x00000001
+#define CR4_PVI 0x00000002
+#define CR4_TSD 0x00000004
+#define CR4_DE 0x00000008
+#define CR4_PSE 0x00000010
+#define CR4_PAE 0x00000020
+#define CR4_MCE 0x00000040
+#define CR4_PGE 0x00000080
+#define CR4_PCE 0x00000100
+#define CR4_OSFXSR 0x00000200
+#define CR4_OSXMMEXCEPT 0x00000400
+#define CR4_UMIP 0x00000800
+#define CR4_VA57 0x00001000
+#define CR4_VMXE 0x00002000
+#define CR4_SMXE 0x00004000
+#define CR4_SEE 0x00008000
+#define CR4_FSGSBASE 0x00010000
+#define CR4_PCIDE 0x00020000
+#define CR4_OSXSAVE 0x00040000
+#define CR4_SMEP 0x00100000
+#define CR4_SMAP 0x00200000
+#define CR4_PKE 0x00400000
+#define CR4_CET 0x00800000
+
+#endif /* _X86_REGS_H */
+
diff --git a/com32/lib/i386/math/init_fpu.c b/com32/lib/i386/math/init_fpu.c
new file mode 100644
index 00000000..8cf19f15
--- /dev/null
+++ b/com32/lib/i386/math/init_fpu.c
@@ -0,0 +1,37 @@
+/*
+ * i386/math/has_fpu.c
+ *
+ * Test for an x87 FPU, and do any necessary setup.
+ */
+
+#include <inttypes.h>
+#include <sys/fpu.h>
+#include <x86/cpu.h>
+#include <x86/regs.h>
+
+int init_fpu(void)
+{
+ uint32_t cr0;
+ uint16_t fsw = 0xffff;
+ uint16_t fcw = 0xf3ff;
+
+ cr0 = get_cr0();
+ cr0 &= ~(CR0_EM | CR0_TS);
+ cr0 |= CR0_MP;
+ set_cr0(cr0);
+
+ fninit();
+
+ asm volatile ("fnstsw %0" : "+m" (fsw));
+ if (fsw != 0)
+ return -1;
+
+ asm volatile ("fnstcw %0" : "+m" (fcw));
+ if ((fcw & 0x103f) != 0x3f)
+ return -1;
+
+ /* Techically, this could be a 386 with a 287. We could add a check
+ for that here... */
+
+ return 0;
+}
diff --git a/com32/lib/math/pow.S b/com32/lib/i386/math/pow.S
index 56f504a7..56f504a7 100644
--- a/com32/lib/math/pow.S
+++ b/com32/lib/i386/math/pow.S
diff --git a/com32/lib/pci/pci.h b/com32/lib/pci/pci.h
index 8d81b0e4..289fbfc0 100644
--- a/com32/lib/pci/pci.h
+++ b/com32/lib/pci/pci.h
@@ -7,7 +7,7 @@
#ifndef PCI_PCI_H
#include <sys/pci.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
extern enum pci_config_type __pci_cfg_type;
extern uint32_t __pci_read_write_bios(uint32_t call, uint32_t v, pciaddr_t a);
diff --git a/com32/lib/sys/i386/x86_init_fpu.c b/com32/lib/sys/i386/x86_init_fpu.c
deleted file mode 100644
index cf336932..00000000
--- a/com32/lib/sys/i386/x86_init_fpu.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * x86_has_fpu.c
- *
- * Test for an x86 FPU, and do any necessary setup.
- */
-
-#include <inttypes.h>
-#include <sys/fpu.h>
-
-static inline uint64_t get_cr0(void)
-{
- uint32_t v;
-asm("movl %%cr0,%0":"=r"(v));
- return v;
-}
-
-static inline void set_cr0(uint32_t v)
-{
- asm volatile ("movl %0,%%cr0"::"r" (v));
-}
-
-#define CR0_PE 0x00000001
-#define CR0_MP 0x00000002
-#define CR0_EM 0x00000004
-#define CR0_TS 0x00000008
-#define CR0_ET 0x00000010
-#define CR0_NE 0x00000020
-#define CR0_WP 0x00010000
-#define CR0_AM 0x00040000
-#define CR0_NW 0x20000000
-#define CR0_CD 0x40000000
-#define CR0_PG 0x80000000
-
-int x86_init_fpu(void)
-{
- uint32_t cr0;
- uint16_t fsw = 0xffff;
- uint16_t fcw = 0xffff;
-
- cr0 = get_cr0();
- cr0 &= ~(CR0_EM | CR0_TS);
- cr0 |= CR0_MP;
- set_cr0(cr0);
-
- asm volatile ("fninit");
- asm volatile ("fnstsw %0":"+m" (fsw));
- if (fsw != 0)
- return -1;
-
- asm volatile ("fnstcw %0":"+m" (fcw));
- if ((fcw & 0x103f) != 0x3f)
- return -1;
-
- /* Techically, this could be a 386 with a 287. We could add a check
- for that here... */
-
- return 0;
-}
diff --git a/com32/lib/sys/vesa/i915resolution.c b/com32/lib/sys/vesa/i915resolution.c
index 6ebb04d3..828ddb56 100644
--- a/com32/lib/sys/vesa/i915resolution.c
+++ b/com32/lib/sys/vesa/i915resolution.c
@@ -51,7 +51,7 @@
#define __USE_GNU
#include <string.h>
#include <sys/io.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <sys/pci.h>
#include <unistd.h>
#include <assert.h>
diff --git a/com32/lib/sys/vesa/initvesa.c b/com32/lib/sys/vesa/initvesa.c
index c2721b8d..c9c9ede1 100644
--- a/com32/lib/sys/vesa/initvesa.c
+++ b/com32/lib/sys/vesa/initvesa.c
@@ -168,7 +168,7 @@ int __vesacon_init(int *x, int *y)
int rv;
/* We need the FPU for graphics, at least libpng et al will need it... */
- if (x86_init_fpu())
+ if (init_fpu())
return 10;
rv = vesacon_set_mode(x, y);
diff --git a/com32/lib/sys/x86_64/x86_init_fpu.c b/com32/lib/sys/x86_64/x86_init_fpu.c
deleted file mode 100644
index c5d3946c..00000000
--- a/com32/lib/sys/x86_64/x86_init_fpu.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * x86_has_fpu.c
- *
- * Test for an x86 FPU, and do any necessary setup.
- */
-
-#include <inttypes.h>
-#include <sys/fpu.h>
-
-static inline uint64_t get_cr0(void)
-{
- uint64_t v;
-asm("movq %%cr0,%0":"=r"(v));
- return v;
-}
-
-static inline void set_cr0(uint32_t v)
-{
- asm volatile ("movq %0,%%cr0"::"r" ((uint64_t)v));
-}
-
-#define CR0_PE 0x00000001
-#define CR0_MP 0x00000002
-#define CR0_EM 0x00000004
-#define CR0_TS 0x00000008
-#define CR0_ET 0x00000010
-#define CR0_NE 0x00000020
-#define CR0_WP 0x00010000
-#define CR0_AM 0x00040000
-#define CR0_NW 0x20000000
-#define CR0_CD 0x40000000
-#define CR0_PG 0x80000000
-
-int x86_init_fpu(void)
-{
- uint32_t cr0;
- uint16_t fsw = 0xffff;
- uint16_t fcw = 0xffff;
-
- cr0 = get_cr0();
- cr0 &= ~(CR0_EM | CR0_TS);
- cr0 |= CR0_MP;
- set_cr0(cr0);
-
- asm volatile ("fninit");
- asm volatile ("fnstsw %0":"+m" (fsw));
- if (fsw != 0)
- return -1;
-
- asm volatile ("fnstcw %0":"+m" (fcw));
- if ((fcw & 0x103f) != 0x3f)
- return -1;
-
- /* Techically, this could be a 386 with a 287. We could add a check
- for that here... */
-
- return 0;
-}
diff --git a/com32/lib/sys/x86_init_fpu.c b/com32/lib/sys/x86_init_fpu.c
deleted file mode 100644
index cacb4ea3..00000000
--- a/com32/lib/sys/x86_init_fpu.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * x86_has_fpu.c
- *
- * Test for an x86 FPU, and do any necessary setup.
- */
-
-#if __SIZEOF_POINTER__ == 4
-#include <i386/x86_init_fpu.c>
-#elif __SIZEOF_POINTER__ == 8
-#include <x86_64/x86_init_fpu.c>
-#else
-#error "Unable to build for to-be-defined architecture type"
-#endif
-#if 0
-#include <inttypes.h>
-#include <sys/fpu.h>
-
-static inline uint64_t get_cr0(void)
-{
-#if __SIZEOF_POINTER__ == 4
- uint32_t v;
-asm("movl %%cr0,%0":"=r"(v));
-#elif __SIZEOF_POINTER__ == 8
- uint64_t v;
-asm("movq %%cr0,%0":"=r"(v));
-#else
-#error "Unable to build for to-be-defined architecture type"
-#endif
- return v;
-}
-
-static inline void set_cr0(uint32_t v)
-{
-#if __SIZEOF_POINTER__ == 4
- asm volatile ("movl %0,%%cr0"::"r" (v));
-#elif __SIZEOF_POINTER__ == 8
- asm volatile ("movq %0,%%cr0"::"r" ((uint64_t)v));
-#else
-#error "Unable to build for to-be-defined architecture type"
-#endif
-}
-
-#define CR0_PE 0x00000001
-#define CR0_MP 0x00000002
-#define CR0_EM 0x00000004
-#define CR0_TS 0x00000008
-#define CR0_ET 0x00000010
-#define CR0_NE 0x00000020
-#define CR0_WP 0x00010000
-#define CR0_AM 0x00040000
-#define CR0_NW 0x20000000
-#define CR0_CD 0x40000000
-#define CR0_PG 0x80000000
-
-int x86_init_fpu(void)
-{
- uint32_t cr0;
- uint16_t fsw = 0xffff;
- uint16_t fcw = 0xffff;
-
- cr0 = get_cr0();
- cr0 &= ~(CR0_EM | CR0_TS);
- cr0 |= CR0_MP;
- set_cr0(cr0);
-
- asm volatile ("fninit");
- asm volatile ("fnstsw %0":"+m" (fsw));
- if (fsw != 0)
- return -1;
-
- asm volatile ("fnstcw %0":"+m" (fcw));
- if ((fcw & 0x103f) != 0x3f)
- return -1;
-
- /* Techically, this could be a 386 with a 287. We could add a check
- for that here... */
-
- return 0;
-}
-#endif
diff --git a/com32/lib/vdprintf.c b/com32/lib/vdprintf.c
index bcf55bb7..6e8c463f 100644
--- a/com32/lib/vdprintf.c
+++ b/com32/lib/vdprintf.c
@@ -8,7 +8,7 @@
#include <unistd.h>
#include <inttypes.h>
#include <sys/io.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#ifdef DEBUG_PORT
diff --git a/com32/lib/x86_64/math/init_fpu.c b/com32/lib/x86_64/math/init_fpu.c
new file mode 100644
index 00000000..116b146e
--- /dev/null
+++ b/com32/lib/x86_64/math/init_fpu.c
@@ -0,0 +1,31 @@
+/*
+ * x86_64/math/init_fpu.c
+ *
+ * Enable the x86-64 FPU if it isn't already
+ * The x86-64 baseline includes SSE2
+ */
+
+#include <inttypes.h>
+#include <sys/fpu.h>
+#include <x86/cpu.h>
+#include <x86/regs.h>
+
+int init_fpu(void)
+{
+ uint64_t cr0, cr4;
+
+ cr0 = get_cr0();
+ cr0 &= ~(CR0_EM | CR0_TS);
+ cr0 |= CR0_MP;
+ set_cr0(cr0);
+
+ cr4 = get_cr4();
+ cr4 |= CR4_OSFXSR;
+ set_cr4(cr4);
+
+ set_mxcsr(0x3f << 7); /* Mask all exceptions */
+
+ fninit(); /* x87 unit initialization */
+
+ return 0;
+}
diff --git a/com32/libupload/serial.c b/com32/libupload/serial.c
index a3987531..88bdd513 100644
--- a/com32/libupload/serial.c
+++ b/com32/libupload/serial.c
@@ -3,7 +3,7 @@
#include <stdio.h>
#include <console.h>
#include <sys/io.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <syslinux/config.h>
#include "serial.h"
diff --git a/com32/menu/drain.c b/com32/menu/drain.c
index 60efd357..2441e57d 100644
--- a/com32/menu/drain.c
+++ b/com32/menu/drain.c
@@ -2,7 +2,7 @@
#include <unistd.h>
#include <errno.h>
#include <string.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
void drain_keyboard(void)
{
diff --git a/com32/modules/cpuid.c b/com32/modules/cpuid.c
index a2438960..452c9e6d 100644
--- a/com32/modules/cpuid.c
+++ b/com32/modules/cpuid.c
@@ -12,7 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <console.h>
#include <com32.h>
diff --git a/com32/sysdump/cpuid.c b/com32/sysdump/cpuid.c
index 846b5408..924ea22b 100644
--- a/com32/sysdump/cpuid.c
+++ b/com32/sysdump/cpuid.c
@@ -6,7 +6,7 @@
#include <string.h>
#include <stdlib.h>
#include <com32.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include "sysdump.h"
struct cpuid_data {
diff --git a/com32/sysdump/main.c b/com32/sysdump/main.c
index eac931e5..373ce6f1 100644
--- a/com32/sysdump/main.c
+++ b/com32/sysdump/main.c
@@ -18,7 +18,7 @@
#include <inttypes.h>
#include <dprintf.h>
#include <console.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <version.h>
#include "sysdump.h"
diff --git a/com32/sysdump/memory.c b/com32/sysdump/memory.c
index 377f9a99..5efd9ee7 100644
--- a/com32/sysdump/memory.c
+++ b/com32/sysdump/memory.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include "sysdump.h"
static char *lowmem;
diff --git a/core/conio.c b/core/conio.c
index 427228ea..e5e0ca76 100644
--- a/core/conio.c
+++ b/core/conio.c
@@ -26,7 +26,7 @@
#include <string.h>
#include <fs.h>
#include <com32.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <syslinux/firmware.h>
#include "bios.h"
diff --git a/core/dmi.c b/core/dmi.c
index 9cbe2832..550b63e2 100644
--- a/core/dmi.c
+++ b/core/dmi.c
@@ -32,7 +32,7 @@
#include <string.h>
#include <stdio.h>
#include <sys/bitops.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <syslinux/sysappend.h>
#include "core.h"
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index db19c7aa..3d54a8b7 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -10,7 +10,7 @@
#include <setjmp.h>
#include <linux/list.h>
#include <netinet/in.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <core.h>
#include <fcntl.h>
#include <sys/file.h>
diff --git a/core/fs/pxe/dhcp_option.c b/core/fs/pxe/dhcp_option.c
index 17f8034f..1b8ec9d8 100644
--- a/core/fs/pxe/dhcp_option.c
+++ b/core/fs/pxe/dhcp_option.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <string.h>
#include <core.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <lwip/opt.h> /* DNS_MAX_SERVERS */
#include <dprintf.h>
#include "pxe.h"
diff --git a/core/fs/pxe/ftp.c b/core/fs/pxe/ftp.c
index 4327e45c..947f2899 100644
--- a/core/fs/pxe/ftp.c
+++ b/core/fs/pxe/ftp.c
@@ -18,7 +18,7 @@
#include <string.h>
#include <fcntl.h>
#include <minmax.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <netinet/in.h>
#include <lwip/api.h>
#include "core.h"
diff --git a/core/fs/pxe/idle.c b/core/fs/pxe/idle.c
index 1d1bb8bc..dbc5b9ab 100644
--- a/core/fs/pxe/idle.c
+++ b/core/fs/pxe/idle.c
@@ -16,7 +16,7 @@
#include <core.h>
#include <fs.h>
#include <minmax.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include "pxe.h"
void pxe_idle_init(void)
diff --git a/core/fs/pxe/isr.c b/core/fs/pxe/isr.c
index 7da0cc73..1fc9c3f2 100644
--- a/core/fs/pxe/isr.c
+++ b/core/fs/pxe/isr.c
@@ -9,7 +9,7 @@
#include "thread.h"
#include "pxe.h"
#include <string.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <sys/io.h>
extern uint8_t pxe_irq_pending;
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index 761a1715..685fcc8f 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -4,7 +4,7 @@
#include <core.h>
#include <fs.h>
#include <fcntl.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include "pxe.h"
#include "thread.h"
#include "url.h"
diff --git a/core/idle.c b/core/idle.c
index c8050554..27cdfc6f 100644
--- a/core/idle.c
+++ b/core/idle.c
@@ -20,7 +20,7 @@
*/
#include "core.h"
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#define TICKS_TO_IDLE 4 /* Also in idle.inc */
diff --git a/core/include/thread.h b/core/include/thread.h
index 8ec4a267..72ebba30 100644
--- a/core/include/thread.h
+++ b/core/include/thread.h
@@ -6,7 +6,7 @@
#include <limits.h>
#include <stdbool.h>
#include <timer.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
/* The idle thread runs at this priority */
#define IDLE_THREAD_PRIORITY INT_MAX
diff --git a/core/legacynet/idle.c b/core/legacynet/idle.c
index e0892379..5a94166d 100644
--- a/core/legacynet/idle.c
+++ b/core/legacynet/idle.c
@@ -16,7 +16,7 @@
#include <core.h>
#include <fs.h>
#include <minmax.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include "pxe.h"
static int pxe_idle_poll(void)
diff --git a/core/localboot.c b/core/localboot.c
index 0b8769e4..c5fb9eca 100644
--- a/core/localboot.c
+++ b/core/localboot.c
@@ -10,7 +10,7 @@
*
* -----------------------------------------------------------------------
*/
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include <sys/io.h>
#include <string.h>
#include <core.h>
diff --git a/core/thread/idle_thread.c b/core/thread/idle_thread.c
index 8faa0719..f709531b 100644
--- a/core/thread/idle_thread.c
+++ b/core/thread/idle_thread.c
@@ -1,6 +1,6 @@
#include "thread.h"
#include <limits.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
static void default_idle_thread_hook(void)
{
diff --git a/core/thread/schedule.c b/core/thread/schedule.c
index 31a2840d..4f0dfe37 100644
--- a/core/thread/schedule.c
+++ b/core/thread/schedule.c
@@ -1,5 +1,5 @@
#include <klibc/compiler.h>
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include "thread.h"
#include "core.h"
#include <dprintf.h>
diff --git a/core/thread/semaphore.c b/core/thread/semaphore.c
index c99af9c5..b85bc1e3 100644
--- a/core/thread/semaphore.c
+++ b/core/thread/semaphore.c
@@ -1,4 +1,4 @@
-#include <sys/cpu.h>
+#include <x86/cpu.h>
#include "thread.h"
void sem_init(struct semaphore *sem, int count)
diff --git a/mk/lib.mk b/mk/lib.mk
index 1a232d77..977c2716 100644
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -60,6 +60,10 @@ else
CFLAGS += -mregparm=3 -DREGPARM=3
endif
+ARCH_MATH_OBJS = \
+ $(patsubst $(com32)/lib/%.c,%.o,$(wildcard $(com32)/lib/$(ARCH)/math/*.c)) \
+ $(patsubst $(com32)/lib/%.S,%.o,$(wildcard $(com32)/lib/$(ARCH)/math/*.S))
+
VPATH = $(SRC)
LIBOTHER_OBJS = \
atoi.o atol.o atoll.o calloc.o creat.o \
@@ -107,7 +111,8 @@ LIBOTHER_OBJS = \
pci/readb.o pci/readw.o pci/readl.o \
pci/writeb.o pci/writew.o pci/writel.o \
\
- sys/x86_init_fpu.o math/pow.o math/strtod.o \
+ math/strtod.o \
+ $(ARCH_MATH_OBJS) \
syslinux/disk.o \
\
syslinux/setup_data.o