diff --git a/libmaxsi/include/libmaxsi/platform.h b/libmaxsi/include/libmaxsi/platform.h index 6397d473..f7e98200 100644 --- a/libmaxsi/include/libmaxsi/platform.h +++ b/libmaxsi/include/libmaxsi/platform.h @@ -32,15 +32,15 @@ #endif // Detect which platform we are compiling to and declare some useful macros. - #ifdef PLATFORM_X86 + #if !defined(CPU) && defined(PLATFORM_X86) #define CPU X86 #endif - #ifdef PLATFORM_X64 + #if !defined(CPU) && defined(PLATFORM_X64) #define CPU X64 #endif - #if defined(PLATFORM_X86) || defined(PLATFORM_X64) + #if !defined(CPU_FAMILY) && defined(PLATFORM_X86) || defined(PLATFORM_X64) #define PLATFORM_X86_FAMILY #define CPU_FAMILY X86_FAMILY #endif @@ -65,29 +65,11 @@ #endif #endif - #ifdef SORTIX_KERNEL - #define ASSERT(invariant) \ - if ( unlikely(!(invariant)) ) \ - { \ - Sortix::PanicF("Assertion failure: %s:%u: %s: %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #invariant); \ - while ( true ) { } \ - } - #else - + #if !defined(SORTIX_KERNEL) && !defined(ASSERT) #define ASSERT(invariant) - #endif - #define STATIC_ASSERT(condition) static_assert(condition, #condition) - // Define common datatypes. #include "types.h" #endif - -#ifdef SORTIX_KERNEL -#include -#include -#include -#endif - diff --git a/libmaxsi/include/libmaxsi/types.h b/libmaxsi/include/libmaxsi/types.h index 3235a286..e4234627 100644 --- a/libmaxsi/include/libmaxsi/types.h +++ b/libmaxsi/include/libmaxsi/types.h @@ -52,7 +52,10 @@ // Maxsi datatype extentions. typedef __nat nat; typedef uint8_t byte; +#ifndef _ADDR_T_DECLARED +#define _ADDR_T_DECLARED typedef uintptr_t addr_t; +#endif #endif diff --git a/sortix/include/sortix/kernel/decl.h b/sortix/include/sortix/kernel/decl.h new file mode 100644 index 00000000..e61f1dd3 --- /dev/null +++ b/sortix/include/sortix/kernel/decl.h @@ -0,0 +1,70 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + + This file is part of Sortix. + + Sortix is free software: you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation, either version 3 of the License, or (at your option) any later + version. + + Sortix is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + details. + + You should have received a copy of the GNU General Public License along with + Sortix. If not, see . + + decl.h + Various declarations. These should likely be replaced with better names from + standard headers or at least one with a less generic name than decl.h. + +*******************************************************************************/ + +#ifndef SORTIX_DECL_H +#define SORTIX_DECL_H + +#ifndef _ADDR_T_DECLARED +#define _ADDR_T_DECLARED +typedef uintptr_t addr_t; +#endif + +#define SORTIX_NORETURN __attribute__((noreturn)) +#define SORTIX_MAYALIAS __attribute__((__may_alias__)) +#define SORTIX_PACKED __attribute__((packed)) +#define likely(x) __builtin_expect((x),1) +#define unlikely(x) __builtin_expect((x),0) +#define STATIC_ASSERT(condition) static_assert(condition, #condition) + +#define ASSERT(invariant) \ + if ( unlikely(!(invariant)) ) \ + { \ + Sortix::PanicF("Assertion failure: %s:%u: %s: %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #invariant); \ + while ( true ) { } \ + } + +// The following declarations should not be used if possible. They were part of +// what libmaxsi's old platform.h header declared and the kernel continues to +// depend on it. +#if !defined(PLATFORM_X64) && defined(__x86_64__) + #define PLATFORM_X64 +#elif !defined(PLATFORM_X86) && defined(__i386__) + #define PLATFORM_X86 +#endif + +#if !defined(CPU) && defined(PLATFORM_X86) + #define CPU X86 +#endif + +#if !defined(CPU) && defined(PLATFORM_X64) + #define CPU X64 +#endif + +#if !defined(CPU_FAMILY) && defined(PLATFORM_X86) || defined(PLATFORM_X64) + #define PLATFORM_X86_FAMILY + #define CPU_FAMILY X86_FAMILY +#endif + +#endif diff --git a/sortix/include/sortix/kernel/kernel.h b/sortix/include/sortix/kernel/kernel.h new file mode 100644 index 00000000..36350707 --- /dev/null +++ b/sortix/include/sortix/kernel/kernel.h @@ -0,0 +1,36 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + + This file is part of Sortix. + + Sortix is free software: you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation, either version 3 of the License, or (at your option) any later + version. + + Sortix is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + details. + + You should have received a copy of the GNU General Public License along with + Sortix. If not, see . + + kernel.h + Base header for the Sortix kernel that includes common stuff. + +*******************************************************************************/ + +#ifndef SORTIX_KERNEL_H +#define SORTIX_KERNEL_H + +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/sortix/include/sortix/kernel/platform.h b/sortix/include/sortix/kernel/platform.h index 524df8ed..933c479e 100644 --- a/sortix/include/sortix/kernel/platform.h +++ b/sortix/include/sortix/kernel/platform.h @@ -1,6 +1,6 @@ -/****************************************************************************** +/******************************************************************************* - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. This file is part of Sortix. @@ -14,59 +14,22 @@ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Sortix. If not, see . + You should have received a copy of the GNU General Public License along with + Sortix. If not, see . platform.h Defines platform specific stuff. -******************************************************************************/ +*******************************************************************************/ + +// This header is deprecated but was used as a common header to get various +// generic and useful declarations. That purpose is actually fine and useful, +// but the name platform.h isn't fitting for that task since it provides +// generic functionality (though how it is provided depends on the platform). #ifndef SORTIX_PLATFORM_H #define SORTIX_PLATFORM_H - // Detect if we are using the GNU Compiler Collection - #if defined(__GNUC__) - #define COMPILER_GCC - #endif - - #ifdef COMPILER_GCC - #define SORTIX_NORETURN __attribute__((noreturn)) - #define SORTIX_MAYALIAS __attribute__((__may_alias__)) - #define SORTIX_PACKED __attribute__((packed)) - #define likely(x) __builtin_expect((x),1) - #define unlikely(x) __builtin_expect((x),0) - #else - #define SORTIX_NORETURN - #define SORTIX_MAYALIAS - #define SORTIX_PACKED - #define likely(x) (x) - #define unlikely(x) (x) - #endif - - - #include - - #ifdef JSSORTIX - namespace Sortix - { - namespace JSSortix - { - inline void __attribute__((noreturn)) Exit() - { - /* send reset command to the keyboard controller */ - asm volatile("out %%al, %%dx" : : "a" (0xfe), "d" (0x64)); - while (1); - } - } - } - #endif - - #if !defined(PLATFORM_SERIAL) && defined(JSSORTIX) - #define PLATFORM_SERIAL - #endif - - #define USER +#include #endif -