2023-03-17 20:07:19 +00:00
|
|
|
#ifndef SOCKS_CPU_H_
|
|
|
|
|
#define SOCKS_CPU_H_
|
|
|
|
|
|
2023-04-22 21:07:34 +01:00
|
|
|
#include <socks/types.h>
|
2023-03-18 19:35:00 +00:00
|
|
|
#include <socks/machine/cpu.h>
|
2023-04-22 21:07:34 +01:00
|
|
|
#include <stdint.h>
|
2023-03-18 19:35:00 +00:00
|
|
|
#include <socks/sched.h>
|
|
|
|
|
|
2023-03-20 20:41:39 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-04-12 20:17:11 +01:00
|
|
|
enum cpu_flags {
|
2023-03-18 19:35:00 +00:00
|
|
|
CPU_ONLINE = 0x01u,
|
2023-04-12 20:17:11 +01:00
|
|
|
};
|
2023-03-18 19:35:00 +00:00
|
|
|
|
2023-04-12 20:17:11 +01:00
|
|
|
struct cpu_data {
|
|
|
|
|
enum cpu_flags c_flags;
|
2023-03-18 19:35:00 +00:00
|
|
|
unsigned int c_id;
|
2023-03-28 21:39:59 +01:00
|
|
|
unsigned int c_preempt_count;
|
2023-03-18 19:35:00 +00:00
|
|
|
|
2023-04-12 20:17:11 +01:00
|
|
|
struct thread *c_current_thread;
|
|
|
|
|
struct runqueue c_rq;
|
|
|
|
|
};
|
2023-03-17 20:07:19 +00:00
|
|
|
|
|
|
|
|
/* maximum number of processor cores that the kernel can support.
|
|
|
|
|
TODO move to build config option */
|
|
|
|
|
#define CPU_MAX 128
|
|
|
|
|
|
2023-03-18 19:35:00 +00:00
|
|
|
#define this_cpu() (ml_cpu_block_get_id(ml_this_cpu()))
|
|
|
|
|
|
2023-04-12 20:17:11 +01:00
|
|
|
extern struct cpu_data *get_this_cpu(void);
|
|
|
|
|
extern void put_cpu(struct cpu_data *cpu);
|
2023-03-18 19:35:00 +00:00
|
|
|
|
|
|
|
|
extern void cpu_set_available(unsigned int cpu_id);
|
|
|
|
|
extern void cpu_set_online(unsigned int cpu_id);
|
|
|
|
|
|
2023-04-22 21:07:34 +01:00
|
|
|
extern cycles_t get_cycles(void);
|
2023-04-28 21:04:50 +01:00
|
|
|
static inline cycles_t cycles_diff(cycles_t then, cycles_t now)
|
|
|
|
|
{
|
|
|
|
|
return now >= then ? now - then : (CYCLES_MAX - then) + now;
|
|
|
|
|
}
|
2023-04-22 21:07:34 +01:00
|
|
|
|
2023-03-28 19:44:51 +01:00
|
|
|
#define irq_enable() ml_int_enable()
|
|
|
|
|
#define irq_disable() ml_int_disable()
|
|
|
|
|
|
2023-03-28 21:39:59 +01:00
|
|
|
extern void preempt_disable(void);
|
|
|
|
|
extern void preempt_enable(void);
|
|
|
|
|
|
2023-03-18 19:35:00 +00:00
|
|
|
extern unsigned int cpu_get_highest_available(void);
|
2023-03-17 20:07:19 +00:00
|
|
|
|
2023-03-20 20:41:39 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-03-17 20:07:19 +00:00
|
|
|
#endif
|