Kernel: Replace i386 with i686

I don't really want to be working with i386 since it doesn't support
compare exchange instruction
This commit is contained in:
Bananymous 2024-03-26 02:48:26 +02:00
parent 93975fdc45
commit 99e30a4d7d
25 changed files with 31 additions and 26 deletions

View File

@ -86,7 +86,7 @@ namespace LibELF
return BAN::Error::from_errno(ENOEXEC);
}
#if ARCH(i386)
#if ARCH(i686)
if (m_file_header.e_ident[EI_CLASS] != ELFCLASS32)
#elif ARCH(x86_64)
if (m_file_header.e_ident[EI_CLASS] != ELFCLASS64)

View File

@ -42,7 +42,7 @@ namespace LibELF
const Elf32SectionHeader& section_header32(size_t) const;
const char* lookup_section_name32(uint32_t) const;
const char* lookup_string32(size_t, uint32_t) const;
#if ARCH(i386)
#if ARCH(i686)
const Elf32FileHeader& file_header_native() const { return file_header32(); }
const Elf32ProgramHeader& program_header_native(size_t index) const { return program_header32(index); }
const Elf32SectionHeader& section_header_native(size_t index) const { return section_header32(index); }

View File

@ -155,7 +155,7 @@ namespace LibELF
Elf64Xword p_align;
};
#if ARCH(i386)
#if ARCH(i686)
using ElfNativeAddr = Elf32Addr;
using ElfNativeOff = Elf32Off;
using ElfNativeHalf = Elf32Half;

View File

@ -4,7 +4,7 @@ project(kernel CXX C ASM)
if("${BANAN_ARCH}" STREQUAL "x86_64")
set(ELF_FORMAT elf64-x86-64)
elseif("${BANAN_ARCH}" STREQUAL "i386")
elseif("${BANAN_ARCH}" STREQUAL "i686")
set(ELF_FORMAT elf32-i386)
endif()
@ -120,16 +120,16 @@ if("${BANAN_ARCH}" STREQUAL "x86_64")
${LAI_SOURCES}
kernel/lai_host.cpp
)
elseif("${BANAN_ARCH}" STREQUAL "i386")
elseif("${BANAN_ARCH}" STREQUAL "i686")
set(KERNEL_SOURCES
${KERNEL_SOURCES}
arch/i386/boot.S
arch/i386/GDT.cpp
arch/i386/IDT.cpp
arch/i386/PageTable.cpp
arch/i386/Signal.S
arch/i386/Syscall.S
arch/i386/Thread.S
arch/i686/boot.S
arch/i686/GDT.cpp
arch/i686/IDT.cpp
arch/i686/PageTable.cpp
arch/i686/Signal.S
arch/i686/Syscall.S
arch/i686/Thread.S
)
else()
message(FATAL_ERROR "unsupported architecure ${BANAN_ARCH}")
@ -182,8 +182,8 @@ if("${BANAN_ARCH}" STREQUAL "x86_64")
target_compile_options(kernel PUBLIC -mcmodel=kernel -mno-red-zone)
target_link_options(kernel PUBLIC LINKER:-z,max-page-size=4096)
target_link_options(kernel PUBLIC LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/x86_64/linker.ld)
elseif("${BANAN_ARCH}" STREQUAL "i386")
target_link_options(kernel PUBLIC LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/i386/linker.ld)
elseif("${BANAN_ARCH}" STREQUAL "i686")
target_link_options(kernel PUBLIC LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/i686/linker.ld)
endif()
target_link_options(kernel PUBLIC -ffreestanding -nostdlib)

View File

@ -7,6 +7,8 @@
.global signal_trampoline
signal_trampoline:
ud2
pushl %ebp
movl %esp, %ebp
subl $8, %esp

View File

@ -1,5 +1,6 @@
.global sys_fork_trampoline
sys_fork_trampoline:
ud2
subl $4, %esp
pushl %ebx
pushl %ebp

View File

@ -1,11 +1,11 @@
#pragma once
#define x86_64 1
#define i386 2
#define i686 2
#define ARCH(arch) (__arch == arch)
#if !defined(__arch) || (__arch != x86_64 && __arch != i386)
#if !defined(__arch) || (__arch != x86_64 && __arch != i686)
#error "Unsupported architecture"
#endif
@ -13,10 +13,12 @@
#define read_rsp(rsp) asm volatile("movq %%rsp, %0" : "=r"(rsp))
#define push_callee_saved() asm volatile("pushq %rbx; pushq %rbp; pushq %r12; pushq %r13; pushq %r14; pushq %r15")
#define pop_callee_saved() asm volatile("popq %r15; popq %r14; popq %r13; popq %r12; popq %rbp; popq %rbx")
#else
#elif ARCH(i686)
#define read_rsp(rsp) asm volatile("movl %%esp, %0" : "=r"(rsp))
#define push_callee_saved() asm volatile("pushal")
#define pop_callee_saved() asm volatile("popal")
#else
#error
#endif
#include <stdint.h>

View File

@ -28,7 +28,7 @@ namespace Kernel
// 1x triply indirect
BAN::Array<paddr_t, 5> block;
static constexpr size_t direct_block_count = 2;
#elif ARCH(i386)
#elif ARCH(i686)
// 14x direct blocks
// 1x singly indirect
// 1x doubly indirect

View File

@ -4,7 +4,7 @@
#if ARCH(x86_64)
#define KERNEL_OFFSET 0xFFFFFFFF80000000
#elif ARCH(i386)
#elif ARCH(i686)
#define KERNEL_OFFSET 0xC0000000
#else
#error

View File

@ -19,7 +19,7 @@ namespace Kernel
using ProcessorID = uint32_t;
constexpr ProcessorID PROCESSOR_NONE = 0xFFFFFFFF;
#if ARCH(x86_64) || ARCH(i386)
#if ARCH(x86_64) || ARCH(i686)
class Processor
{
BAN_NON_COPYABLE(Processor);

View File

@ -22,7 +22,7 @@ namespace Kernel
{
#if ARCH(x86_64)
asm volatile("rdrand %0" : "=r"(s_rand_seed));
#elif ARCH(i386)
#elif ARCH(i686)
uint32_t lo, hi;
asm volatile(
"rdrand %[lo];"

View File

@ -21,7 +21,7 @@ namespace Kernel
{
#if ARCH(x86_64)
asm volatile("movq %0, %%rsp" :: "rm"(Processor::current_stack_top()));
#elif ARCH(i386)
#elif ARCH(i686)
asm volatile("movl %0, %%esp" :: "rm"(Processor::current_stack_top()));
#else
#error
@ -221,7 +221,7 @@ namespace Kernel
"orq $(1 << 3), %rax;"
"movq %rax, %cr0"
);
#elif ARCH(i386)
#elif ARCH(i686)
asm volatile(
"movl %cr0, %eax;"
"orl $(1 << 3), %eax;"

View File

@ -111,7 +111,7 @@ namespace Kernel
);
save_sse();
asm volatile("movq %0, %%cr0" :: "r"(cr0));
#elif ARCH(i386)
#elif ARCH(i686)
uintptr_t cr0;
asm volatile(
"movl %%cr0, %%eax;"

View File

@ -1,4 +1,4 @@
/* i386 crti.s */
/* i686 crti.s */
.section .init
.global _init
.type _init, @function

View File

@ -1,4 +1,4 @@
/* i386 crtn.s */
/* i686 crtn.s */
.section .init
/* gcc will nicely put the contents of crtend.o's .init section here. */
popl %ebp