120 lines
4.1 KiB
C
120 lines
4.1 KiB
C
//----------------------------------------------------------------------------//
|
|
// GNU GPL OS/K //
|
|
// //
|
|
// Desc: Kaleid kernel base include file //
|
|
// //
|
|
// //
|
|
// 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/>. //
|
|
//----------------------------------------------------------------------------//
|
|
|
|
#ifndef _KALBASE_H
|
|
#include <kalbase.h>
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
#error "Kaleid's kernel won't compile in C++"
|
|
#endif
|
|
|
|
#ifndef _KALKERN_BASE_H
|
|
#define _KALKERN_BASE_H
|
|
|
|
//------------------------------------------//
|
|
|
|
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;
|
|
typedef struct Processor_t Processor_t;
|
|
|
|
typedef enum ProcState_t ProcState_t;
|
|
typedef enum TermColor_t TermColor_t;
|
|
typedef enum KernelState_t KernelState_t;
|
|
|
|
//------------------------------------------//
|
|
// Multiprocessor misc. //
|
|
//------------------------------------------//
|
|
|
|
#ifndef NCPUS
|
|
#define NCPUS 1
|
|
#endif
|
|
|
|
// Current CPU number
|
|
// Will return a CPU-local variable later
|
|
#define _GetCurCPU() 0
|
|
|
|
// Get Process_t structure of current CPU
|
|
#define GetCurCPU() (cpuTable[_GetCurCPU()])
|
|
|
|
//------------------------------------------//
|
|
|
|
//
|
|
// Holds all CPU-local variables
|
|
//
|
|
struct Processor_t
|
|
{
|
|
// CPU number, index in CPU list
|
|
int index;
|
|
|
|
// Panic string
|
|
char panicStr[1024];
|
|
|
|
// Number of ticks since boot time
|
|
ulong ticks;
|
|
|
|
// Current process & thread
|
|
Process_t *process;
|
|
Thread_t *thread;
|
|
|
|
// Need re-schedule?
|
|
bool needReSched;
|
|
|
|
// Is preemption ON? ("PREEMPT_ON" in sched.h)
|
|
ulong preemptCount;
|
|
|
|
// List heads for the four priority classes
|
|
ListHead_t *idlePrioProcs;
|
|
ListHead_t *reglPrioProcs;
|
|
ListHead_t *servPrioProcs;
|
|
ListHead_t *timeCritProcs;
|
|
};
|
|
|
|
//------------------------------------------//
|
|
|
|
extern int cpuCount;
|
|
extern Processor_t cpuTable[NCPUS];
|
|
|
|
//------------------------------------------//
|
|
|
|
#define DEC_PER_CPU(name, field, type) \
|
|
static inline type Get##name() { return GetCurCPU().field; } \
|
|
static inline void _Set##name(type __val) { GetCurCPU().field = __val; }
|
|
|
|
//------------------------------------------//
|
|
|
|
// Needed by basically everyone
|
|
#ifndef _KALEXTRAS_LOCKS_H
|
|
#include <extras/locks.h>
|
|
#endif
|
|
|
|
//------------------------------------------//
|
|
|
|
#endif
|
|
|