183fcaefdSAnup Patel /* 283fcaefdSAnup Patel * QEMU RISC-V NUMA Helper 383fcaefdSAnup Patel * 483fcaefdSAnup Patel * Copyright (c) 2020 Western Digital Corporation or its affiliates. 583fcaefdSAnup Patel * 683fcaefdSAnup Patel * This program is free software; you can redistribute it and/or modify it 783fcaefdSAnup Patel * under the terms and conditions of the GNU General Public License, 883fcaefdSAnup Patel * version 2 or later, as published by the Free Software Foundation. 983fcaefdSAnup Patel * 1083fcaefdSAnup Patel * This program is distributed in the hope it will be useful, but WITHOUT 1183fcaefdSAnup Patel * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1283fcaefdSAnup Patel * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 1383fcaefdSAnup Patel * more details. 1483fcaefdSAnup Patel * 1583fcaefdSAnup Patel * You should have received a copy of the GNU General Public License along with 1683fcaefdSAnup Patel * this program. If not, see <http://www.gnu.org/licenses/>. 1783fcaefdSAnup Patel */ 1883fcaefdSAnup Patel 1983fcaefdSAnup Patel #ifndef RISCV_NUMA_H 2083fcaefdSAnup Patel #define RISCV_NUMA_H 2183fcaefdSAnup Patel 227a5951f6SMarkus Armbruster #include "hw/boards.h" 2383fcaefdSAnup Patel #include "hw/sysbus.h" 24*32cad1ffSPhilippe Mathieu-Daudé #include "system/numa.h" 2583fcaefdSAnup Patel 2683fcaefdSAnup Patel /** 2783fcaefdSAnup Patel * riscv_socket_count: 2883fcaefdSAnup Patel * @ms: pointer to machine state 2983fcaefdSAnup Patel * 3083fcaefdSAnup Patel * Returns: number of sockets for a numa system and 1 for a non-numa system 3183fcaefdSAnup Patel */ 3283fcaefdSAnup Patel int riscv_socket_count(const MachineState *ms); 3383fcaefdSAnup Patel 3483fcaefdSAnup Patel /** 3583fcaefdSAnup Patel * riscv_socket_first_hartid: 3683fcaefdSAnup Patel * @ms: pointer to machine state 3783fcaefdSAnup Patel * @socket_id: socket index 3883fcaefdSAnup Patel * 3983fcaefdSAnup Patel * Returns: first hartid for a valid socket and -1 for an invalid socket 4083fcaefdSAnup Patel */ 4183fcaefdSAnup Patel int riscv_socket_first_hartid(const MachineState *ms, int socket_id); 4283fcaefdSAnup Patel 4383fcaefdSAnup Patel /** 4483fcaefdSAnup Patel * riscv_socket_last_hartid: 4583fcaefdSAnup Patel * @ms: pointer to machine state 4683fcaefdSAnup Patel * @socket_id: socket index 4783fcaefdSAnup Patel * 4883fcaefdSAnup Patel * Returns: last hartid for a valid socket and -1 for an invalid socket 4983fcaefdSAnup Patel */ 5083fcaefdSAnup Patel int riscv_socket_last_hartid(const MachineState *ms, int socket_id); 5183fcaefdSAnup Patel 5283fcaefdSAnup Patel /** 5383fcaefdSAnup Patel * riscv_socket_hart_count: 5483fcaefdSAnup Patel * @ms: pointer to machine state 5583fcaefdSAnup Patel * @socket_id: socket index 5683fcaefdSAnup Patel * 5783fcaefdSAnup Patel * Returns: number of harts for a valid socket and -1 for an invalid socket 5883fcaefdSAnup Patel */ 5983fcaefdSAnup Patel int riscv_socket_hart_count(const MachineState *ms, int socket_id); 6083fcaefdSAnup Patel 6183fcaefdSAnup Patel /** 6283fcaefdSAnup Patel * riscv_socket_mem_offset: 6383fcaefdSAnup Patel * @ms: pointer to machine state 6483fcaefdSAnup Patel * @socket_id: socket index 6583fcaefdSAnup Patel * 6683fcaefdSAnup Patel * Returns: offset of ram belonging to given socket 6783fcaefdSAnup Patel */ 6883fcaefdSAnup Patel uint64_t riscv_socket_mem_offset(const MachineState *ms, int socket_id); 6983fcaefdSAnup Patel 7083fcaefdSAnup Patel /** 7183fcaefdSAnup Patel * riscv_socket_mem_size: 7283fcaefdSAnup Patel * @ms: pointer to machine state 7383fcaefdSAnup Patel * @socket_id: socket index 7483fcaefdSAnup Patel * 7583fcaefdSAnup Patel * Returns: size of ram belonging to given socket 7683fcaefdSAnup Patel */ 7783fcaefdSAnup Patel uint64_t riscv_socket_mem_size(const MachineState *ms, int socket_id); 7883fcaefdSAnup Patel 7983fcaefdSAnup Patel /** 8083fcaefdSAnup Patel * riscv_socket_check_hartids: 8183fcaefdSAnup Patel * @ms: pointer to machine state 8283fcaefdSAnup Patel * @socket_id: socket index 8383fcaefdSAnup Patel * 8483fcaefdSAnup Patel * Returns: true if hardids belonging to given socket are contiguous else false 8583fcaefdSAnup Patel */ 8683fcaefdSAnup Patel bool riscv_socket_check_hartids(const MachineState *ms, int socket_id); 8783fcaefdSAnup Patel 8883fcaefdSAnup Patel /** 8983fcaefdSAnup Patel * riscv_socket_fdt_write_id: 9083fcaefdSAnup Patel * @ms: pointer to machine state 9183fcaefdSAnup Patel * @socket_id: socket index 9283fcaefdSAnup Patel * 93fb60b488SDaniel Henrique Barboza * Write NUMA node-id FDT property in MachineState->fdt 9483fcaefdSAnup Patel */ 95fb60b488SDaniel Henrique Barboza void riscv_socket_fdt_write_id(const MachineState *ms, const char *node_name, 96fb60b488SDaniel Henrique Barboza int socket_id); 9783fcaefdSAnup Patel 9883fcaefdSAnup Patel /** 9983fcaefdSAnup Patel * riscv_socket_fdt_write_distance_matrix: 10083fcaefdSAnup Patel * @ms: pointer to machine state 10183fcaefdSAnup Patel * @socket_id: socket index 10283fcaefdSAnup Patel * 1039c3ee7e8SDaniel Henrique Barboza * Write NUMA distance matrix in MachineState->fdt 10483fcaefdSAnup Patel */ 1059c3ee7e8SDaniel Henrique Barboza void riscv_socket_fdt_write_distance_matrix(const MachineState *ms); 10683fcaefdSAnup Patel 10783fcaefdSAnup Patel CpuInstanceProperties 10883fcaefdSAnup Patel riscv_numa_cpu_index_to_props(MachineState *ms, unsigned cpu_index); 10983fcaefdSAnup Patel 11083fcaefdSAnup Patel int64_t riscv_numa_get_default_cpu_node_id(const MachineState *ms, int idx); 11183fcaefdSAnup Patel 11283fcaefdSAnup Patel const CPUArchIdList *riscv_numa_possible_cpu_arch_ids(MachineState *ms); 11383fcaefdSAnup Patel 11483fcaefdSAnup Patel #endif /* RISCV_NUMA_H */ 115