opuntiaOS - an operating system targeting x86 and ARMv7
at master 1.3 kB view raw
1/* 2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors. 3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com> 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#ifndef _KERNEL_TASKING_BITS_CPU_H 10#define _KERNEL_TASKING_BITS_CPU_H 11 12#include <drivers/generic/fpu.h> 13#include <libkern/types.h> 14#include <mem/kmemzone.h> 15#include <mem/vmm.h> 16#include <platform/generic/tasking/context.h> 17#include <tasking/bits/sched.h> 18 19#define CPU_CNT 4 20#define THIS_CPU (&cpus[system_cpu_id()]) 21#define FPU_ENABLED 22 23struct thread; 24typedef int cpu_state_t; 25enum CPU_STATE { 26 CPU_IN_KERNEL, 27 CPU_IN_USERLAND, 28}; 29 30typedef struct { 31 int id; 32 int int_depth_counter; 33 34 pdirectory_t* pdir; 35 kmemzone_t sched_stack_zone; 36 context_t* sched_context; // context of sched's registers 37 struct thread* running_thread; 38 cpu_state_t current_state; 39 struct thread* idle_thread; 40 41 sched_data_t sched; 42 43 /* Stat */ 44 time_t stat_ticks_since_boot; 45 time_t stat_system_and_idle_ticks; 46 time_t stat_user_ticks; 47 48#ifdef FPU_ENABLED 49 // Information about current state of fpu. 50 struct thread* fpu_for_thread; 51 pid_t fpu_for_pid; 52#endif // FPU_ENABLED 53} cpu_t; 54 55extern cpu_t cpus[CPU_CNT]; 56 57#endif // _KERNEL_TASKING_BITS_CPU_H