2 * Copyright 2002-2006, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Copyright 2002, Travis Geiselbrecht. All rights reserved.
6 * Distributed under the terms of the NewOS License.
19 #include <scheduler.h>
28 using BKernel::Thread
;
31 typedef enum cpu_topology_level
{
39 typedef struct cpu_topology_node
{
40 cpu_topology_level level
;
44 cpu_topology_node
** children
;
49 /* CPU local data structure */
51 typedef struct cpu_ent
{
54 // thread.c: used to force a reschedule at quantum expiration time
58 // keeping track of CPU activity
59 seqlock active_time_lock
;
60 bigtime_t active_time
;
62 bigtime_t interrupt_time
;
63 bigtime_t last_kernel_time
;
64 bigtime_t last_user_time
;
68 // used in the kernel debugger
70 addr_t fault_handler_stack_pointer
;
71 jmp_buf fault_jump_buffer
;
73 Thread
* running_thread
;
74 Thread
* previous_thread
;
75 bool invoke_scheduler
;
78 // CPU topology information
79 int topology_id
[CPU_TOPOLOGY_LEVELS
];
80 int cache_id
[CPU_MAX_CACHE_LEVEL
];
82 // IRQs assigned to this CPU
86 // arch-specific stuff
88 } cpu_ent CACHE_LINE_ALIGN
;
91 extern cpu_ent gCPU
[];
92 extern uint32 gCPUCacheLevelCount
;
99 status_t
cpu_preboot_init_percpu(struct kernel_args
*args
, int curr_cpu
);
100 status_t
cpu_init(struct kernel_args
*args
);
101 status_t
cpu_init_percpu(struct kernel_args
*ka
, int curr_cpu
);
102 status_t
cpu_init_post_vm(struct kernel_args
*args
);
103 status_t
cpu_init_post_modules(struct kernel_args
*args
);
104 bigtime_t
cpu_get_active_time(int32 cpu
);
106 cpu_ent
*get_cpu_struct(void);
107 extern inline cpu_ent
*get_cpu_struct(void) { return &gCPU
[smp_get_current_cpu()]; }
109 status_t
cpu_build_topology_tree(void);
110 const cpu_topology_node
* get_cpu_topology(void);
112 void cpu_set_scheduler_mode(enum scheduler_mode mode
);
114 status_t
increase_cpu_performance(int delta
);
115 status_t
decrease_cpu_performance(int delta
);
118 void cpu_wait(int32
* variable
, int32 test
);
128 void _user_clear_caches(void *address
, size_t length
, uint32 flags
);
129 bool _user_cpu_enabled(int32 cpu
);
130 status_t
_user_set_cpu_enabled(int32 cpu
, bool enabled
);
136 #endif /* _KERNEL_CPU_H */