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
|
2019-03-08 09:00:55 +01:00
|
|
|
#error "Kaleid's kernel won't compile in C++"
|
2019-02-16 23:36:33 +01:00
|
|
|
#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-03-08 09:00:55 +01:00
|
|
|
typedef struct Processor_t Processor_t;
|
2019-03-19 00:25:22 +01:00
|
|
|
typedef struct BootInfo_t BootInfo_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;
|
2019-01-21 15:00:04 +01:00
|
|
|
|
|
|
|
//------------------------------------------//
|
|
|
|
// Multiprocessor misc. //
|
|
|
|
//------------------------------------------//
|
|
|
|
|
|
|
|
#ifndef NCPUS
|
2019-03-08 09:00:55 +01:00
|
|
|
#define NCPUS 1
|
2019-01-21 15:00:04 +01:00
|
|
|
#endif
|
|
|
|
|
2019-03-08 09:00:55 +01:00
|
|
|
// Current CPU number
|
|
|
|
// Will return a CPU-local variable later
|
|
|
|
#define _GetCurCPU() 0
|
|
|
|
|
|
|
|
// Get Process_t structure of current CPU
|
|
|
|
#define GetCurCPU() (cpuTable[_GetCurCPU()])
|
2019-03-11 19:22:37 +01:00
|
|
|
#define PANICSTR_SIZE 1024
|
2019-03-08 09:00:55 +01:00
|
|
|
|
2019-03-19 00:25:22 +01:00
|
|
|
//Get the BootInfo_t structure
|
2019-03-19 12:24:27 +01:00
|
|
|
#define GetBootInfo(x) bootTab.x
|
2019-03-08 09:00:55 +01:00
|
|
|
//------------------------------------------//
|
2019-01-21 15:00:04 +01:00
|
|
|
|
|
|
|
//
|
2019-03-08 09:00:55 +01:00
|
|
|
// Holds all CPU-local variables
|
2019-01-21 15:00:04 +01:00
|
|
|
//
|
2019-03-08 09:00:55 +01:00
|
|
|
struct Processor_t
|
|
|
|
{
|
|
|
|
// CPU number, index in CPU list
|
|
|
|
int index;
|
2019-01-21 15:00:04 +01:00
|
|
|
|
2019-03-08 09:00:55 +01:00
|
|
|
// Panic string
|
2019-03-11 19:22:37 +01:00
|
|
|
char panicStr[PANICSTR_SIZE];
|
2019-01-21 15:00:04 +01:00
|
|
|
|
2019-03-08 09:00:55 +01:00
|
|
|
// Number of ticks since boot time
|
|
|
|
ulong ticks;
|
2019-01-21 15:00:04 +01:00
|
|
|
|
2019-03-08 09:00:55 +01:00
|
|
|
// 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;
|
|
|
|
};
|
|
|
|
|
2019-03-19 00:25:22 +01:00
|
|
|
#define FB_EGA_TEXT 2
|
|
|
|
#define FB_INDEXED 0
|
|
|
|
#define FB_RGB 1
|
2019-03-19 12:24:27 +01:00
|
|
|
#define BINFO_SIZE 4096
|
2019-03-19 00:25:22 +01:00
|
|
|
struct BootInfo_t
|
2019-03-18 17:43:41 +01:00
|
|
|
{
|
2019-03-19 00:25:22 +01:00
|
|
|
// The Bootloader infos (GRUB in our case)
|
|
|
|
struct {
|
|
|
|
uint grubFlags; //flags
|
|
|
|
uint modulesCount; //mods_count
|
2019-03-19 12:24:27 +01:00
|
|
|
void *modulesAddr; //mods_addr
|
2019-03-19 00:25:22 +01:00
|
|
|
uint grubName; //boot_loader_name
|
2019-03-19 12:24:27 +01:00
|
|
|
void *mbHeaderAddr;
|
2019-03-19 00:25:22 +01:00
|
|
|
} btldr;
|
|
|
|
|
|
|
|
// Informations about drives
|
|
|
|
struct {
|
|
|
|
uint bootDrv; //boot_device
|
|
|
|
uint bufferLength; //drives_length
|
2019-03-19 12:24:27 +01:00
|
|
|
void *bufferAddr; //drives_addr
|
2019-03-19 00:25:22 +01:00
|
|
|
} drives;
|
|
|
|
|
|
|
|
// Informations about memory
|
|
|
|
struct {
|
|
|
|
//BIOS provided low and up memory
|
|
|
|
uint lowMemory; //mem_lower
|
|
|
|
uint upMemory; //mem_upper
|
|
|
|
|
|
|
|
//GRUB provided memory map
|
|
|
|
uint mapLength; //mmap_length
|
2019-03-19 12:24:27 +01:00
|
|
|
void *mapAddr; //mmap_addr
|
2019-03-19 00:25:22 +01:00
|
|
|
} memory;
|
|
|
|
|
|
|
|
// Informations about the video drive
|
|
|
|
struct {
|
|
|
|
uint vbeControl; //vbe_control_info
|
2019-03-19 12:24:27 +01:00
|
|
|
uint vbeModeInfo; //vbe_mode_info
|
2019-03-19 00:25:22 +01:00
|
|
|
ushort vbeMode; //vbe_mode
|
|
|
|
ushort vbeInterfaceSeg; //vbe_interface_seg
|
|
|
|
ushort vbeInterfaceOff; //vbe_interface_off
|
|
|
|
ushort vbeInterfaceLen; //vbe_interface_len
|
2019-03-19 12:24:27 +01:00
|
|
|
void* framebufferAddr; //framebuffer_addr
|
2019-03-19 00:25:22 +01:00
|
|
|
uint framebufferPitch; //framebuffer_pitch
|
|
|
|
uint framebufferWidth; //framebuffer_width
|
|
|
|
uint framebufferHeight; //framebuffer_height
|
|
|
|
uchar framebufferBpp; //framebuffer_bpp
|
|
|
|
uchar framebufferType; //framebuffer_type
|
|
|
|
} video;
|
|
|
|
|
|
|
|
// Informations about the microcode firmware (BIOS/EFI)
|
|
|
|
struct {
|
|
|
|
uint apmTable; //apm_table
|
|
|
|
uint romTable; //config_table
|
|
|
|
} firmware;
|
2019-03-18 17:43:41 +01:00
|
|
|
};
|
|
|
|
|
2019-03-08 09:00:55 +01:00
|
|
|
//------------------------------------------//
|
|
|
|
|
|
|
|
extern int cpuCount;
|
|
|
|
extern Processor_t cpuTable[NCPUS];
|
2019-03-19 00:25:22 +01:00
|
|
|
extern BootInfo_t bootTab;
|
2019-03-08 09:00:55 +01:00
|
|
|
//------------------------------------------//
|
|
|
|
|
|
|
|
#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; }
|
2019-01-21 15:00:04 +01:00
|
|
|
|
|
|
|
//------------------------------------------//
|
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
|
2019-03-08 09:00:55 +01:00
|
|
|
|