1 /* 2 * Copyright 2002-2006, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Copyright 2002, Travis Geiselbrecht. All rights reserved. 6 * Distributed under the terms of the NewOS License. 7 */ 8 #ifndef _KERNEL_CPU_H 9 #define _KERNEL_CPU_H 10 11 12 #include <smp.h> 13 #include <timer.h> 14 #include <boot/kernel_args.h> 15 #include <arch/cpu.h> 16 17 18 // define PAUSE, if not done in arch/cpu.h 19 #ifndef PAUSE 20 # define PAUSE() 21 #endif 22 23 24 /* CPU local data structure */ 25 26 typedef struct cpu_ent { 27 int cpu_num; 28 29 // thread.c: used to force a reschedule at quantum expiration time 30 int preempted; 31 timer quantum_timer; 32 33 // keeping track of CPU activity 34 bigtime_t active_time; 35 bigtime_t last_kernel_time; 36 bigtime_t last_user_time; 37 38 bool invoke_scheduler; 39 bool disabled; 40 41 // arch-specific stuff 42 arch_cpu_info arch; 43 } cpu_ent __attribute__((aligned(64))); 44 45 46 extern cpu_ent gCPU[MAX_BOOT_CPUS]; 47 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 status_t cpu_preboot_init_percpu(struct kernel_args *args, int curr_cpu); 54 status_t cpu_init(struct kernel_args *args); 55 status_t cpu_init_percpu(kernel_args *ka, int curr_cpu); 56 status_t cpu_init_post_vm(struct kernel_args *args); 57 status_t cpu_init_post_modules(struct kernel_args *args); 58 bigtime_t cpu_get_active_time(int32 cpu); 59 60 cpu_ent *get_cpu_struct(void); 61 extern inline cpu_ent *get_cpu_struct(void) { return &gCPU[smp_get_current_cpu()]; } 62 63 void _user_clear_caches(void *address, size_t length, uint32 flags); 64 bool _user_cpu_enabled(int32 cpu); 65 status_t _user_set_cpu_enabled(int32 cpu, bool enabled); 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 #endif /* _KERNEL_CPU_H */ 72