mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Remove kernel platform.h dependency on libmaxsi platform.h.
This reduces the dependence on libmaxsi with the aim that the Maxsi:: api can be removed and replaced with the standard C library.
This commit is contained in:
parent
3095503b9b
commit
b293fb3171
5 changed files with 124 additions and 70 deletions
|
@ -32,15 +32,15 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Detect which platform we are compiling to and declare some useful macros.
|
// Detect which platform we are compiling to and declare some useful macros.
|
||||||
#ifdef PLATFORM_X86
|
#if !defined(CPU) && defined(PLATFORM_X86)
|
||||||
#define CPU X86
|
#define CPU X86
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PLATFORM_X64
|
#if !defined(CPU) && defined(PLATFORM_X64)
|
||||||
#define CPU X64
|
#define CPU X64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_X86) || defined(PLATFORM_X64)
|
#if !defined(CPU_FAMILY) && defined(PLATFORM_X86) || defined(PLATFORM_X64)
|
||||||
#define PLATFORM_X86_FAMILY
|
#define PLATFORM_X86_FAMILY
|
||||||
#define CPU_FAMILY X86_FAMILY
|
#define CPU_FAMILY X86_FAMILY
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,29 +65,11 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SORTIX_KERNEL
|
#if !defined(SORTIX_KERNEL) && !defined(ASSERT)
|
||||||
#define ASSERT(invariant) \
|
|
||||||
if ( unlikely(!(invariant)) ) \
|
|
||||||
{ \
|
|
||||||
Sortix::PanicF("Assertion failure: %s:%u: %s: %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #invariant); \
|
|
||||||
while ( true ) { } \
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define ASSERT(invariant)
|
#define ASSERT(invariant)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STATIC_ASSERT(condition) static_assert(condition, #condition)
|
|
||||||
|
|
||||||
// Define common datatypes.
|
// Define common datatypes.
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SORTIX_KERNEL
|
|
||||||
#include <sortix/kernel/platform.h>
|
|
||||||
#include <sortix/kernel/log.h>
|
|
||||||
#include <sortix/kernel/panic.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,10 @@
|
||||||
// Maxsi datatype extentions.
|
// Maxsi datatype extentions.
|
||||||
typedef __nat nat;
|
typedef __nat nat;
|
||||||
typedef uint8_t byte;
|
typedef uint8_t byte;
|
||||||
|
#ifndef _ADDR_T_DECLARED
|
||||||
|
#define _ADDR_T_DECLARED
|
||||||
typedef uintptr_t addr_t;
|
typedef uintptr_t addr_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
70
sortix/include/sortix/kernel/decl.h
Normal file
70
sortix/include/sortix/kernel/decl.h
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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
|
36
sortix/include/sortix/kernel/kernel.h
Normal file
36
sortix/include/sortix/kernel/kernel.h
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
kernel.h
|
||||||
|
Base header for the Sortix kernel that includes common stuff.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SORTIX_KERNEL_H
|
||||||
|
#define SORTIX_KERNEL_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sortix/kernel/decl.h>
|
||||||
|
#include <sortix/kernel/log.h>
|
||||||
|
#include <sortix/kernel/panic.h>
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,6 @@
|
||||||
/******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
||||||
|
|
||||||
This file is part of Sortix.
|
This file is part of Sortix.
|
||||||
|
|
||||||
|
@ -14,59 +14,22 @@
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
details.
|
details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
You should have received a copy of the GNU General Public License along with
|
||||||
with Sortix. If not, see <http://www.gnu.org/licenses/>.
|
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
platform.h
|
platform.h
|
||||||
Defines platform specific stuff.
|
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
|
#ifndef SORTIX_PLATFORM_H
|
||||||
#define SORTIX_PLATFORM_H
|
#define SORTIX_PLATFORM_H
|
||||||
|
|
||||||
// Detect if we are using the GNU Compiler Collection
|
#include <sortix/kernel/kernel.h>
|
||||||
#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 <libmaxsi/platform.h>
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue