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 | |
Karl Meakin | 2ad6b66 | 2024-07-29 20:45:40 +0100 | [diff] [blame] | 13 | #ifndef __ASSEMBLER__ |
Olivier Deprez | 64b421e | 2022-10-06 10:28:20 +0200 | [diff] [blame] | 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. */ |
Karl Meakin | 2ad6b66 | 2024-07-29 20:45:40 +0100 | [diff] [blame] | 18 | /* NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding) */ |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 19 | struct cpu { |
Andrew Walbran | c3910f7 | 2018-11-27 14:24:36 +0000 | [diff] [blame] | 20 | /** CPU identifier. Doesn't have to be contiguous. */ |
Andrew Walbran | 4d3fa28 | 2019-06-26 13:31:15 +0100 | [diff] [blame] | 21 | cpu_id_t id; |
Andrew Scull | 020ae69 | 2018-07-19 16:20:14 +0100 | [diff] [blame] | 22 | |
Andrew Walbran | c3910f7 | 2018-11-27 14:24:36 +0000 | [diff] [blame] | 23 | /** Pointer to bottom of the stack. */ |
Andrew Scull | 020ae69 | 2018-07-19 16:20:14 +0100 | [diff] [blame] | 24 | void *stack_bottom; |
| 25 | |
Andrew Walbran | 0d7a068 | 2018-12-06 16:48:47 +0000 | [diff] [blame] | 26 | /** See api.c for the partial ordering on locks. */ |
Andrew Scull | 020ae69 | 2018-07-19 16:20:14 +0100 | [diff] [blame] | 27 | struct spinlock lock; |
| 28 | |
Fuad Tabba | b0ef2a4 | 2019-12-19 11:19:25 +0000 | [diff] [blame] | 29 | /** Determines whether the CPU is currently on. */ |
Wedson Almeida Filho | 8700964 | 2018-07-02 10:20:07 +0100 | [diff] [blame] | 30 | bool is_on; |
J-Alves | ea8ccfe | 2024-10-09 11:47:24 +0100 | [diff] [blame] | 31 | |
| 32 | /* In case there is a pending SRI for the NWd. */ |
| 33 | bool is_sri_delayed; |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 34 | }; |
| 35 | |
Andrew Walbran | 4d3fa28 | 2019-06-26 13:31:15 +0100 | [diff] [blame] | 36 | 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] | 37 | |
Wedson Almeida Filho | 3fcbcff | 2018-07-10 23:53:39 +0100 | [diff] [blame] | 38 | size_t cpu_index(struct cpu *c); |
Olivier Deprez | 7d5e553 | 2020-09-22 15:06:58 +0200 | [diff] [blame] | 39 | struct cpu *cpu_find_index(size_t index); |
Olivier Deprez | 70f8a4a | 2022-09-26 09:17:56 +0200 | [diff] [blame] | 40 | bool cpu_on(struct cpu *c); |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 41 | void cpu_off(struct cpu *c); |
Andrew Walbran | 4d3fa28 | 2019-06-26 13:31:15 +0100 | [diff] [blame] | 42 | struct cpu *cpu_find(cpu_id_t id); |
Mahesh Bireddy | 8ca5786 | 2020-01-07 13:43:21 +0530 | [diff] [blame] | 43 | uint8_t *cpu_get_buffer(struct cpu *c); |
| 44 | uint32_t cpu_get_buffer_size(struct cpu *c); |
Olivier Deprez | 64b421e | 2022-10-06 10:28:20 +0200 | [diff] [blame] | 45 | |
| 46 | #endif |