diff --git a/headers/private/kernel/arch/sparc/arch_debug.h b/headers/private/kernel/arch/sparc/arch_debug.h index e69de29bb2..7a05f1e82e 100644 --- a/headers/private/kernel/arch/sparc/arch_debug.h +++ b/headers/private/kernel/arch/sparc/arch_debug.h @@ -0,0 +1,18 @@ +/* + * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_SPARC_DEBUG_H +#define _KERNEL_ARCH_SPARC_DEBUG_H + + +#include + + +struct arch_debug_registers { + // TODO + addr_t r1; +}; + + +#endif // _KERNEL_ARCH_SPARC_DEBUG_H diff --git a/headers/private/kernel/arch/sparc/arch_kernel.h b/headers/private/kernel/arch/sparc/arch_kernel.h index 25d49ae0d2..bf2838bf1d 100644 --- a/headers/private/kernel/arch/sparc/arch_kernel.h +++ b/headers/private/kernel/arch/sparc/arch_kernel.h @@ -8,27 +8,29 @@ #include -// memory layout -#define KERNEL_BASE 0x80000000 -#define KERNEL_SIZE 0x80000000 -#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1)) +// Base of the kernel address space. +// KERNEL_BASE is the base of the kernel address space. This differs from the +// address where the kernel is loaded to: the kernel is loaded in the top 2GB +// of the virtual address space as required by GCC's kernel code model. The +// whole kernel address space is the top 512GB of the address space. +#define KERNEL_BASE 0xffffff0000000000 +#define KERNEL_SIZE 0x10000000000 +#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1)) +#define KERNEL_LOAD_BASE 0xffffffff80000000 -/* -** User space layout is a little special: -** The user space does not completely cover the space not covered by the kernel. -** This is accomplished by starting user space at 1Mb and running to 64kb short of kernel space. -** The lower 1Mb reserved spot makes it easy to find null pointer references and guarantees a -** region wont be placed there. The 64kb region assures a user space thread cannot pass -** a buffer into the kernel as part of a syscall that would cross into kernel space. -*/ -#define USER_BASE 0x100000 -#define USER_BASE_ANY USER_BASE -#define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) -#define USER_TOP (USER_BASE + (USER_SIZE - 1)) -#define KERNEL_USER_DATA_BASE 0x60000000 -#define USER_STACK_REGION 0x70000000 -#define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) +// Userspace address space layout. +// There is a 2MB hole just before the end of the bottom half of the address +// space. This means that if userland passes in a buffer that crosses into the +// uncanonical address region, it will be caught through a page fault. +#define USER_BASE 0x100000 +#define USER_BASE_ANY USER_BASE +#define USER_SIZE (0x800000000000 - (0x200000 + 0x100000)) +#define USER_TOP (USER_BASE + (USER_SIZE - 1)) + +#define KERNEL_USER_DATA_BASE 0x7f0000000000 +#define USER_STACK_REGION 0x7f0000000000 +#define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) #endif /* _KERNEL_ARCH_SPARC_KERNEL_H */ diff --git a/headers/private/system/arch/sparc/arch_config.h b/headers/private/system/arch/sparc/arch_config.h index e69de29bb2..3cdb67ea26 100644 --- a/headers/private/system/arch/sparc/arch_config.h +++ b/headers/private/system/arch/sparc/arch_config.h @@ -0,0 +1,12 @@ +/* + * Copyright 2019 Adrien Destugues, pulkomandy@pulkomandy.tk. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_SPARC_CONFIG_H +#define _KERNEL_ARCH_SPARC_CONFIG_H + + +#define STACK_GROWS_DOWNWARDS + + +#endif /* _KERNEL_ARCH_SPARC_CONFIG_H */ diff --git a/headers/private/system/arch/sparc/arch_cpu_defs.h b/headers/private/system/arch/sparc/arch_cpu_defs.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/system/kernel/debug/core_dump.cpp b/src/system/kernel/debug/core_dump.cpp index 664d6cba9f..6ea28d38ce 100644 --- a/src/system/kernel/debug/core_dump.cpp +++ b/src/system/kernel/debug/core_dump.cpp @@ -1125,6 +1125,8 @@ private: header.e_machine = EM_MIPS; #elif defined(__HAIKU_ARCH_ARM) header.e_machine = EM_ARM; +#elif defined(__HAIKU_ARCH_SPARC) + header.e_machine = EM_SPARCV9; #else # error Unsupported architecture! #endif diff --git a/src/system/libroot/os/arch/sparc/syscalls.inc b/src/system/libroot/os/arch/sparc/syscalls.inc new file mode 100644 index 0000000000..031585d2d7 --- /dev/null +++ b/src/system/libroot/os/arch/sparc/syscalls.inc @@ -0,0 +1,33 @@ +/* +** Copyright 2001-2007, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the MIT License. +*/ + +/* TODO actuall syscalls? */ +#define _SYSCALL(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL0(name, n) _SYSCALL(name, n) +#define SYSCALL1(name, n) _SYSCALL(name, n) +#define SYSCALL2(name, n) _SYSCALL(name, n) +#define SYSCALL3(name, n) _SYSCALL(name, n) +#define SYSCALL4(name, n) _SYSCALL(name, n) +#define SYSCALL5(name, n) _SYSCALL(name, n) +#define SYSCALL6(name, n) _SYSCALL(name, n) +#define SYSCALL7(name, n) _SYSCALL(name, n) +#define SYSCALL8(name, n) _SYSCALL(name, n) +#define SYSCALL9(name, n) _SYSCALL(name, n) +#define SYSCALL10(name, n) _SYSCALL(name, n) +#define SYSCALL11(name, n) _SYSCALL(name, n) +#define SYSCALL12(name, n) _SYSCALL(name, n) +#define SYSCALL13(name, n) _SYSCALL(name, n) +#define SYSCALL14(name, n) _SYSCALL(name, n) +#define SYSCALL15(name, n) _SYSCALL(name, n) +#define SYSCALL16(name, n) _SYSCALL(name, n) +#define SYSCALL17(name, n) _SYSCALL(name, n) +#define SYSCALL18(name, n) _SYSCALL(name, n) +#define SYSCALL19(name, n) _SYSCALL(name, n) +#define SYSCALL20(name, n) _SYSCALL(name, n) diff --git a/src/system/libroot/posix/glibc/include/arch/sparc/bits/endian.h b/src/system/libroot/posix/glibc/include/arch/sparc/bits/endian.h new file mode 100644 index 0000000000..a55de950f8 --- /dev/null +++ b/src/system/libroot/posix/glibc/include/arch/sparc/bits/endian.h @@ -0,0 +1,7 @@ +/* sparc is big-endian. */ + +#ifndef _ENDIAN_H +# error "Never use directly; include instead." +#endif + +#define __BYTE_ORDER __BIG_ENDIAN diff --git a/src/system/libroot/posix/glibc/include/arch/sparc/bits/huge_val.h b/src/system/libroot/posix/glibc/include/arch/sparc/bits/huge_val.h new file mode 100644 index 0000000000..4870e3c4ff --- /dev/null +++ b/src/system/libroot/posix/glibc/include/arch/sparc/bits/huge_val.h @@ -0,0 +1,8 @@ +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + + +# define HUGE_VAL (__builtin_huge_val()) +# define HUGE_VALF (__builtin_huge_valf()) +# define HUGE_VALL (__builtin_huge_vall()) diff --git a/src/system/libroot/posix/glibc/include/arch/sparc/bits/mathdef.h b/src/system/libroot/posix/glibc/include/arch/sparc/bits/mathdef.h new file mode 100644 index 0000000000..13b271dec2 --- /dev/null +++ b/src/system/libroot/posix/glibc/include/arch/sparc/bits/mathdef.h @@ -0,0 +1,31 @@ +#if !defined _MATH_H && !defined _COMPLEX_H +# error "Never use directly; include instead" +#endif + +#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF +# define _MATH_H_MATHDEF 1 + +typedef float float_t; +typedef double double_t; + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +# define FP_ILOGB0 (-2147483647) +# define FP_ILOGBNAN (2147483647) + +# define INFINITY (__builtin_inff()) + +/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l} + builtins are supported. */ +# if __FP_FAST_FMA +# define FP_FAST_FMA 1 +# endif + +# if __FP_FAST_FMAF +# define FP_FAST_FMAF 1 +# endif + +# if __FP_FAST_FMAL +# define FP_FAST_FMAL 1 +# endif + +#endif /* ISO C99 */ diff --git a/src/system/libroot/posix/glibc/include/arch/sparc/bits/mathinline.h b/src/system/libroot/posix/glibc/include/arch/sparc/bits/mathinline.h new file mode 100644 index 0000000000..b9b3f6efab --- /dev/null +++ b/src/system/libroot/posix/glibc/include/arch/sparc/bits/mathinline.h @@ -0,0 +1,22 @@ +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +#define __NTH(fct) __attribute__ ((__nothrow__)) fct + +#ifndef __extern_always_inline +# define __MATH_INLINE __inline +#else +# define __MATH_INLINE __extern_always_inline +#endif + +#if defined __USE_ISOC99 + +# define isgreater(x, y) __builtin_isgreater (x, y) +# define isgreaterequal(x, y) __builtin_isgreaterequal (x, y) +# define isless(x, y) __builtin_isless (x, y) +# define islessequal(x, y) __builtin_islessequal (x, y) +# define islessgreater(x, y) __builtin_islessgreater (x, y) +# define isunordered(x, y) __builtin_isunordered (x, y) + +#endif diff --git a/src/system/libroot/posix/glibc/include/arch/sparc/bits/nan.h b/src/system/libroot/posix/glibc/include/arch/sparc/bits/nan.h new file mode 100644 index 0000000000..c17012bcaa --- /dev/null +++ b/src/system/libroot/posix/glibc/include/arch/sparc/bits/nan.h @@ -0,0 +1,5 @@ +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +# define NAN (__builtin_nanf ("")) diff --git a/src/system/libroot/posix/glibc/include/arch/sparc/bits/wordsize.h b/src/system/libroot/posix/glibc/include/arch/sparc/bits/wordsize.h new file mode 100644 index 0000000000..2778a0e3fc --- /dev/null +++ b/src/system/libroot/posix/glibc/include/arch/sparc/bits/wordsize.h @@ -0,0 +1 @@ +# define __WORDSIZE 64 diff --git a/src/system/libroot/posix/glibc/include/arch/sparc/config.h b/src/system/libroot/posix/glibc/include/arch/sparc/config.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/system/libroot/posix/glibc/include/arch/sparc/math_ldbl.h b/src/system/libroot/posix/glibc/include/arch/sparc/math_ldbl.h new file mode 100644 index 0000000000..1cd9d6752d --- /dev/null +++ b/src/system/libroot/posix/glibc/include/arch/sparc/math_ldbl.h @@ -0,0 +1,4 @@ +#ifndef _MATH_PRIVATE_H_ +#error "Never use directly; include instead." +#endif + diff --git a/src/system/libroot/posix/glibc/include/arch/sparc/stackinfo.h b/src/system/libroot/posix/glibc/include/arch/sparc/stackinfo.h new file mode 100644 index 0000000000..265063f96b --- /dev/null +++ b/src/system/libroot/posix/glibc/include/arch/sparc/stackinfo.h @@ -0,0 +1,8 @@ +#ifndef _STACKINFO_H +#define _STACKINFO_H 1 + +/* On sparc the stack grows down. */ +#define _STACK_GROWS_DOWN 1 + +#endif /* stackinfo.h */ +