From 4e72c78dc1f5fa74bde2521c338490a3c892a22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 9 Jan 2022 21:10:54 +0200 Subject: [PATCH] Support i686 without SSE. Previously Sortix would initialize SSE unconditionally as part of the boot process. Since earlier i686 CPUs like Pentium 2 did not include SSE, Sortix would not run on them. With this SSE is only enabled for CPUs that include it, which should theoretically allow Sortix to boot on all i686 CPUs. Additionally, this removes -msse -msse2 compiler flags from trianglix/Makefile. --- kernel/x86/boot.S | 14 +++++++++++++- share/man/man7/installation.7 | 2 +- trianglix/Makefile | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/kernel/x86/boot.S b/kernel/x86/boot.S index 4f1a2ca4..80d414ed 100644 --- a/kernel/x86/boot.S +++ b/kernel/x86/boot.S @@ -1,5 +1,6 @@ /* * Copyright (c) 2011, 2014, 2015, 2016, 2018 Jonas 'Sortie' Termansen. + * Copyright (c) 2022 Juhani 'nortti' Krekelä. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -145,7 +146,17 @@ __start: mov %ecx, %cr0 fninit - # Enable Streaming SIMD Extensions. + # Check for the presence of Streaming SIMD Extensions (SSE). + push %eax + push %ebx + mov $1, %eax + cpuid + pop %ebx + pop %eax + test $(1 << 25), %edx + jz 3f + + # Enable Streaming SIMD Extensions (SSE). mov %cr0, %ecx and $0xFFFB, %cx or $0x2, %cx @@ -157,6 +168,7 @@ __start: ldmxcsr (%esp) addl $4, %esp +3: # Store a copy of the initialial floating point registers. fxsave fpu_initialized_regs diff --git a/share/man/man7/installation.7 b/share/man/man7/installation.7 index 301323b6..9757cdab 100644 --- a/share/man/man7/installation.7 +++ b/share/man/man7/installation.7 @@ -27,7 +27,7 @@ A computer meeting the system requirements. .Ss System Requirements .Bl -bullet -compact .It -32-bit x86 CPU with SSE (i686 release), or 64-bit x86 CPU (x86_64 release). +32-bit x86 CPU (i686 release) or 64-bit x86 CPU (x86_64 release). .It 1 GiB RAM (recommended) to run iso live environment (including installer) with all ports loaded, or significantly less if unimportant ports are not loaded. diff --git a/trianglix/Makefile b/trianglix/Makefile index 10e542e9..73eca0c1 100644 --- a/trianglix/Makefile +++ b/trianglix/Makefile @@ -7,7 +7,7 @@ include ../build-aux/dirs.mak OPTLEVEL?=-g -O2 CXXFLAGS?=$(OPTLEVEL) -CXXFLAGS:=$(CXXFLAGS) -std=gnu++11 -Wall -Wextra -fno-exceptions -fno-rtti -msse -msse2 +CXXFLAGS:=$(CXXFLAGS) -std=gnu++11 -Wall -Wextra -fno-exceptions -fno-rtti BINARY:=trianglix