2019-01-21 15:00:04 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
// GNU GPL OS/K //
|
|
|
|
// //
|
2019-02-16 23:36:33 +01:00
|
|
|
// Desc: Kaleid kernel base include file //
|
2019-01-21 15:00:04 +01:00
|
|
|
// //
|
2019-02-16 23:36:33 +01:00
|
|
|
// //
|
|
|
|
// Copyright © 2018-2019 The OS/K Team //
|
|
|
|
// //
|
|
|
|
// This file is part of OS/K. //
|
|
|
|
// //
|
|
|
|
// OS/K 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 //
|
|
|
|
// any later version. //
|
|
|
|
// //
|
|
|
|
// OS/K 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 OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
2019-01-21 15:00:04 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
#ifndef _KALBASE_H
|
|
|
|
#include <kalbase.h>
|
|
|
|
#endif
|
|
|
|
|
2019-02-16 23:36:33 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#error "Kaleid's kernel won't compile in C++ :("
|
|
|
|
#endif
|
2019-01-21 15:00:04 +01:00
|
|
|
|
|
|
|
#ifndef _KALKERN_BASE_H
|
|
|
|
#define _KALKERN_BASE_H
|
|
|
|
|
|
|
|
//------------------------------------------//
|
|
|
|
|
2019-02-16 23:36:33 +01:00
|
|
|
typedef struct Lock_t Lock_t;
|
|
|
|
typedef struct Thread_t Thread_t;
|
|
|
|
typedef struct Process_t Process_t;
|
|
|
|
typedef struct Terminal_t Terminal_t;
|
|
|
|
typedef struct ListHead_t ListHead_t;
|
|
|
|
typedef struct ListNode_t ListNode_t;
|
2019-01-21 15:00:04 +01:00
|
|
|
|
2019-02-16 23:36:33 +01:00
|
|
|
typedef enum ProcState_t ProcState_t;
|
|
|
|
typedef enum TermColor_t TermColor_t;
|
|
|
|
typedef enum KernelState_t KernelState_t;
|
2019-01-21 15:00:04 +01:00
|
|
|
|
|
|
|
//------------------------------------------//
|
|
|
|
// Multiprocessor misc. //
|
|
|
|
//------------------------------------------//
|
|
|
|
|
|
|
|
#ifndef INITOK
|
|
|
|
#define INITOK ((unsigned int)0xCAFEBABE)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NCPUS
|
|
|
|
#define NCPUS 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GetCurCPU() 0
|
|
|
|
|
|
|
|
//
|
|
|
|
// Declare an (extern) CPU-local variable
|
|
|
|
//
|
|
|
|
#define __DECLARE_PER_CPU(_X, _Tp, _Qual) \
|
|
|
|
_Qual _Tp __ ## _X [NCPUS]; \
|
|
|
|
static inline _Tp Get ## _X (void) \
|
|
|
|
{ return __ ## _X [GetCurCPU()]; } \
|
|
|
|
static inline void _Set ## _X (_Tp _Y) \
|
|
|
|
{ (__ ## _X [GetCurCPU()] = _Y); }
|
|
|
|
|
|
|
|
#define DECLARE_PER_CPU(_X, _Tp) \
|
|
|
|
__DECLARE_PER_CPU(_X, _Tp, extern)
|
|
|
|
|
|
|
|
#define LOCAL_DEC_PER_CPU(_X, _Tp) \
|
|
|
|
__DECLARE_PER_CPU(_X, _Tp, static)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Actually creates a CPU-local variable
|
|
|
|
//
|
|
|
|
#define CREATE_PER_CPU(_X, _Tp) \
|
|
|
|
_Tp __ ## _X [NCPUS] = { (_Tp) 0 }
|
|
|
|
|
|
|
|
//------------------------------------------//
|
2019-02-06 14:07:38 +01:00
|
|
|
|
2019-02-16 23:36:33 +01:00
|
|
|
// Needed by basically everyone
|
|
|
|
#ifndef _KALEXTRAS_LOCKS_H
|
|
|
|
#include <extras/locks.h>
|
|
|
|
#endif
|
2019-01-21 15:00:04 +01:00
|
|
|
|
|
|
|
//------------------------------------------//
|
|
|
|
|
|
|
|
#endif
|