kernel: add header files

This commit is contained in:
2026-02-19 19:13:44 +00:00
parent f2e128c57e
commit 85006411bd
42 changed files with 3335 additions and 0 deletions

65
include/kernel/cpu.h Normal file
View File

@@ -0,0 +1,65 @@
#ifndef KERNEL_CPU_H_
#define KERNEL_CPU_H_
#include <kernel/types.h>
#include <kernel/machine/cpu.h>
#include <stdint.h>
#include <kernel/sched.h>
#ifdef __cplusplus
extern "C" {
#endif
enum cpu_flags {
CPU_ONLINE = 0x01u,
};
struct cpu_data {
enum cpu_flags c_flags;
unsigned int c_id;
int c_preempt_count;
struct runqueue c_rq;
struct workqueue c_wq;
struct queue c_timers;
};
/* maximum number of processor cores that the kernel can support.
TODO move to build config option */
#define CPU_MAX 128
#define this_cpu() (ml_cpu_block_get_id(ml_this_cpu()))
extern struct cpu_data *get_this_cpu(void);
extern struct cpu_data *get_cpu(unsigned int id);
extern void put_cpu(struct cpu_data *cpu);
extern bool cpu_is_available(unsigned int cpu_id);
extern bool cpu_is_online(unsigned int cpu_id);
extern void cpu_set_available(unsigned int cpu_id);
extern void cpu_set_online(unsigned int cpu_id);
extern unsigned int cpu_nr_available(void);
extern unsigned int cpu_nr_online(void);
extern cycles_t get_cycles(void);
static inline cycles_t cycles_diff(cycles_t then, cycles_t now)
{
return now >= then ? now - then : (CYCLES_MAX - then) + now;
}
#define irq_enable() ml_int_enable()
#define irq_disable() ml_int_disable()
extern void preempt_disable(void);
extern void preempt_enable(void);
extern int preempt_count(void);
extern unsigned int cpu_get_highest_available(void);
#ifdef __cplusplus
}
#endif
#endif