* See LICENSE for details.
*/
-#ifndef ROS_INC_SMP_H
-#define ROS_INC_SMP_H
+#pragma once
/* SMP related functions */
#include <syscall.h>
#include <alarm.h>
#include <trace.h>
-#ifdef CONFIG_X86_64
-#include <arch/vm.h>
-#endif
-
-#ifdef __SHARC__
-typedef sharC_env_t;
-#endif
+#include <core_set.h>
+
+#define CPU_STATE_IRQ 0
+#define CPU_STATE_KERNEL 1
+#define CPU_STATE_USER 2
+#define CPU_STATE_IDLE 3
+#define NR_CPU_STATES 4
+
+static char *cpu_state_names[NR_CPU_STATES] =
+{
+ "irq",
+ "kern",
+ "user",
+ "idle",
+};
struct per_cpu_info {
-#ifdef CONFIG_X86_64
- uintptr_t stacktop;
- /* virtual machines */
- /* this is all kind of gross, but so it goes. Kmalloc
- * the vmxarea. It varies in size depending on the architecture.
- */
- struct vmcs *vmxarea;
- struct vmcs *vmcs;
+#ifdef CONFIG_X86
+ uintptr_t stacktop; /* must be first */
+ int coreid; /* must be second */
+ int vmx_enabled;
+ int guest_pcoreid;
#endif
spinlock_t lock;
/* Process management */
struct timer_chain tchain; /* for the per-core alarm */
unsigned int lock_depth;
struct trace_ring traces;
-
-#ifdef __SHARC__
- // held spin-locks. this will have to go elsewhere if multiple kernel
- // threads can share a CPU.
- // zra: Used by Ivy. Let me know if this should go elsewhere.
- sharC_env_t sharC_env;
-#endif
+ int cpu_state;
+ uint64_t last_tick_cnt;
+ uint64_t state_ticks[NR_CPU_STATES];
/* TODO: 64b (not sure if we'll need these at all */
#ifdef CONFIG_X86
taskstate_t *tss;
#endif
/* KMSGs */
spinlock_t immed_amsg_lock;
- struct kernel_msg_list NTPTV(a0t) NTPTV(a1t) NTPTV(a2t) immed_amsgs;
+ struct kernel_msg_list immed_amsgs;
spinlock_t routine_amsg_lock;
- struct kernel_msg_list NTPTV(a0t) NTPTV(a1t) NTPTV(a2t) routine_amsgs;
+ struct kernel_msg_list routine_amsgs;
+ /* profiling -- opaque to all but the profiling code. */
+ void *profiling;
}__attribute__((aligned(ARCH_CL_SIZE)));
/* Allows the kernel to figure out what process is running on this core. Can be
* interrupted contexts via iret/etc. We never do that for user contexts. */
#define current_ctx per_cpu_info[core_id()].cur_ctx
-typedef struct per_cpu_info NTPTV(t) NTPTV(a0t) NTPTV(a1t) NTPTV(a2t) per_cpu_info_t;
-
-extern per_cpu_info_t (RO per_cpu_info)[MAX_NUM_CPUS];
-extern volatile uint32_t RO num_cpus;
+typedef struct per_cpu_info per_cpu_info_t;
+extern per_cpu_info_t per_cpu_info[MAX_NUM_CORES];
/* SMP bootup functions */
void smp_boot(void);
void smp_percpu_init(void); // this must be called by each core individually
void __arch_pcpu_init(uint32_t coreid); /* each arch has one of these */
+void __set_cpu_state(struct per_cpu_info *pcpui, int state);
+void reset_cpu_state_ticks(int coreid);
+
/* SMP utility functions */
int smp_call_function_self(isr_t handler, void *data,
handler_wrapper_t **wait_wrapper);
#endif /* CONFIG_TRACE_LOCKS */
+void smp_do_in_cores(const struct core_set *cset, void (*func)(void *),
+ void *opaque);
+
/* Run the handlers for all events in a pcpui ring. Can run on all cores, or
* just one core. 'type' selects which event type is handled (0 for all). */
void pcpui_tr_foreach(int coreid, int type);
void pcpui_tr_foreach_all(int type);
void pcpui_tr_reset_all(void);
void pcpui_tr_reset_and_clear_all(void);
-
-#endif /* ROS_INC_SMP_H */