1 /* 2 * Copyright 2018 The Hafnium Authors. 3 * 4 * Use of this source code is governed by a BSD-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/BSD-3-Clause. 7 */ 8 9 #pragma once 10 11 #define STACK_SIZE (8192) 12 13 #if !defined(__ASSEMBLER__) 14 15 #include "hf/arch/cpu.h" 16 17 /* TODO: Fix alignment such that `cpu` structs are in different cache lines. */ 18 struct cpu { 19 /** CPU identifier. Doesn't have to be contiguous. */ 20 cpu_id_t id; 21 22 /** Pointer to bottom of the stack. */ 23 void *stack_bottom; 24 25 /** See api.c for the partial ordering on locks. */ 26 struct spinlock lock; 27 28 /** Determines whether the CPU is currently on. */ 29 bool is_on; 30 }; 31 32 void cpu_module_init(const cpu_id_t *cpu_ids, size_t count); 33 34 size_t cpu_index(struct cpu *c); 35 struct cpu *cpu_find_index(size_t index); 36 bool cpu_on(struct cpu *c, ipaddr_t entry, uintreg_t arg); 37 void cpu_off(struct cpu *c); 38 struct cpu *cpu_find(cpu_id_t id); 39 uint8_t *cpu_get_buffer(struct cpu *c); 40 uint32_t cpu_get_buffer_size(struct cpu *c); 41 42 #endif 43