Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [diff] [blame] | 1 | /* |
Andrew Walbran | 692b325 | 2019-03-07 15:51:31 +0000 | [diff] [blame] | 2 | * Copyright 2018 The Hafnium Authors. |
Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [diff] [blame] | 3 | * |
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 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. |
Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
Andrew Scull | fbc938a | 2018-08-20 14:09:28 +0100 | [diff] [blame] | 9 | #pragma once |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 10 | |
Olivier Deprez | 64b421e | 2022-10-06 10:28:20 +0200 | [diff] [blame^] | 11 | #define STACK_SIZE (8192) |
| 12 | |
| 13 | #if !defined(__ASSEMBLER__) |
| 14 | |
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 15 | #include "hf/arch/cpu.h" |
| 16 | |
Fuad Tabba | b0ef2a4 | 2019-12-19 11:19:25 +0000 | [diff] [blame] | 17 | /* TODO: Fix alignment such that `cpu` structs are in different cache lines. */ |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 18 | struct cpu { |
Andrew Walbran | c3910f7 | 2018-11-27 14:24:36 +0000 | [diff] [blame] | 19 | /** CPU identifier. Doesn't have to be contiguous. */ |
Andrew Walbran | 4d3fa28 | 2019-06-26 13:31:15 +0100 | [diff] [blame] | 20 | cpu_id_t id; |
Andrew Scull | 020ae69 | 2018-07-19 16:20:14 +0100 | [diff] [blame] | 21 | |
Andrew Walbran | c3910f7 | 2018-11-27 14:24:36 +0000 | [diff] [blame] | 22 | /** Pointer to bottom of the stack. */ |
Andrew Scull | 020ae69 | 2018-07-19 16:20:14 +0100 | [diff] [blame] | 23 | void *stack_bottom; |
| 24 | |
Andrew Walbran | 0d7a068 | 2018-12-06 16:48:47 +0000 | [diff] [blame] | 25 | /** See api.c for the partial ordering on locks. */ |
Andrew Scull | 020ae69 | 2018-07-19 16:20:14 +0100 | [diff] [blame] | 26 | struct spinlock lock; |
| 27 | |
Fuad Tabba | b0ef2a4 | 2019-12-19 11:19:25 +0000 | [diff] [blame] | 28 | /** Determines whether the CPU is currently on. */ |
Wedson Almeida Filho | 8700964 | 2018-07-02 10:20:07 +0100 | [diff] [blame] | 29 | bool is_on; |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 30 | }; |
| 31 | |
Andrew Walbran | 4d3fa28 | 2019-06-26 13:31:15 +0100 | [diff] [blame] | 32 | void cpu_module_init(const cpu_id_t *cpu_ids, size_t count); |
Wedson Almeida Filho | 3fcbcff | 2018-07-10 23:53:39 +0100 | [diff] [blame] | 33 | |
Wedson Almeida Filho | 3fcbcff | 2018-07-10 23:53:39 +0100 | [diff] [blame] | 34 | size_t cpu_index(struct cpu *c); |
Olivier Deprez | 7d5e553 | 2020-09-22 15:06:58 +0200 | [diff] [blame] | 35 | struct cpu *cpu_find_index(size_t index); |
Andrew Scull | 3740287 | 2018-10-24 14:23:06 +0100 | [diff] [blame] | 36 | bool cpu_on(struct cpu *c, ipaddr_t entry, uintreg_t arg); |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 37 | void cpu_off(struct cpu *c); |
Andrew Walbran | 4d3fa28 | 2019-06-26 13:31:15 +0100 | [diff] [blame] | 38 | struct cpu *cpu_find(cpu_id_t id); |
Mahesh Bireddy | 8ca5786 | 2020-01-07 13:43:21 +0530 | [diff] [blame] | 39 | uint8_t *cpu_get_buffer(struct cpu *c); |
| 40 | uint32_t cpu_get_buffer_size(struct cpu *c); |
Olivier Deprez | 64b421e | 2022-10-06 10:28:20 +0200 | [diff] [blame^] | 41 | |
| 42 | #endif |