aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/sys
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-02-04 12:16:57 -0800
committerH. Peter Anvin <hpa@zytor.com>2019-02-04 12:16:57 -0800
commit35badfce1f4855a32d089e1a9d8c098e3ef343c7 (patch)
treeb114358b6bac8eb97d7b3bf395e7eaeb7a1de1e5 /com32/lib/sys
parent621770d33e6da95556ccfc4f08fd16edb8300c63 (diff)
downloadsyslinux-35badfce1f4855a32d089e1a9d8c098e3ef343c7.tar.gz
syslinux-35badfce1f4855a32d089e1a9d8c098e3ef343c7.tar.xz
syslinux-35badfce1f4855a32d089e1a9d8c098e3ef343c7.zip
Reorganize and clean up a bunch of the x86 code
We were doing a bunch of i386-specific things even on x86-64. Fix this, and merge x86 definitions where possible. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/lib/sys')
-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
5 files changed, 2 insertions, 198 deletions
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