1 #ifndef _KERNEL_CPU_H 2 #define _KERNEL_CPU_H 3 4 /** 5 * @file kernel/cpu.h 6 * @brief CPU Local per-CPU data structure 7 */ 8 9 #include <stage2.h> 10 #include <smp.h> 11 #include <timer.h> 12 13 /** 14 * @defgroup CPU CPU Structures (not architecture specific) 15 * @ingroup OpenBeOS_Kernel 16 * @{ 17 */ 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif /* __cplusplus */ 22 23 /** 24 * CPU local data structure 25 */ 26 /** 27 * One structure per cpu. 28 * The structure contains data that is local to the CPU, 29 * helping reduce the amount of cache thrashing. 30 */ 31 typedef union cpu_ent { 32 /** The information structure, followed by alignment bytes to make it ?? bytes */ 33 struct { 34 /** Number of this CPU, starting from 0 */ 35 int cpu_num; 36 /** If set this will force a reschedule when the quantum timer expires */ 37 int preempted; 38 /** Quantum timer */ 39 timer quantum_timer; 40 } info; 41 /** Alignment bytes */ 42 uint32 align[16]; 43 } cpu_ent; 44 45 /** 46 * Defined in core/cpu.c 47 */ 48 extern cpu_ent cpu[MAX_BOOT_CPUS]; 49 50 /** 51 * Perform pre-boot initialisation 52 * @param ka The kernel_args structure 53 */ 54 int cpu_preboot_init(kernel_args *ka); 55 /** 56 * Initialise a CPU 57 * @param ka The kernel_args structure 58 */ 59 int cpu_init(kernel_args *ka); 60 61 /** 62 * Get a pointer to the CPU's local data structure 63 */ 64 /** 65 * This is declared as an inline function in this header 66 */ 67 cpu_ent *get_cpu_struct(void); 68 69 /** 70 * Inline declaration of get_cpu_struct(void) 71 */ 72 extern inline cpu_ent *get_cpu_struct(void) { return &cpu[smp_get_current_cpu()]; } 73 74 #ifdef __cplusplus 75 } 76 #endif 77 /** @} */ 78 79 #endif /* _KERNEL_CPU_H */ 80