Lukas Auer | fa33f08 | 2019-03-17 19:28:32 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright (C) 2019 Fraunhofer AISEC, |
| 4 | * Lukas Auer <lukas.auer@aisec.fraunhofer.de> |
| 5 | */ |
| 6 | |
| 7 | #ifndef _ASM_RISCV_SMP_H |
| 8 | #define _ASM_RISCV_SMP_H |
| 9 | |
| 10 | /** |
| 11 | * struct ipi_data - Inter-processor interrupt (IPI) data structure |
| 12 | * |
| 13 | * IPIs are used for SMP support to communicate to other harts what function to |
| 14 | * call. Functions are in the form |
| 15 | * void (*addr)(ulong hart, ulong arg0, ulong arg1). |
| 16 | * |
| 17 | * The function address and the two arguments, arg0 and arg1, are stored in the |
| 18 | * IPI data structure. The hart ID is inserted by the hart handling the IPI and |
| 19 | * calling the function. |
| 20 | * |
| 21 | * @addr: Address of function |
| 22 | * @arg0: First argument of function |
| 23 | * @arg1: Second argument of function |
| 24 | */ |
| 25 | struct ipi_data { |
| 26 | ulong addr; |
| 27 | ulong arg0; |
| 28 | ulong arg1; |
| 29 | }; |
| 30 | |
| 31 | /** |
| 32 | * handle_ipi() - interrupt handler for software interrupts |
| 33 | * |
| 34 | * The IPI interrupt handler must be called to handle software interrupts. It |
| 35 | * calls the function specified in the hart's IPI data structure. |
| 36 | * |
| 37 | * @hart: Hart ID of the current hart |
| 38 | */ |
| 39 | void handle_ipi(ulong hart); |
| 40 | |
| 41 | /** |
| 42 | * smp_call_function() - Call a function on all other harts |
| 43 | * |
| 44 | * Send IPIs with the specified function call to all harts. |
| 45 | * |
| 46 | * @addr: Address of function |
| 47 | * @arg0: First argument of function |
| 48 | * @arg1: Second argument of function |
Lukas Auer | 90ae281 | 2019-12-08 23:28:51 +0100 | [diff] [blame] | 49 | * @wait: Wait for harts to acknowledge request |
Lukas Auer | fa33f08 | 2019-03-17 19:28:32 +0100 | [diff] [blame] | 50 | * @return 0 if OK, -ve on error |
| 51 | */ |
Lukas Auer | 90ae281 | 2019-12-08 23:28:51 +0100 | [diff] [blame] | 52 | int smp_call_function(ulong addr, ulong arg0, ulong arg1, int wait); |
Lukas Auer | fa33f08 | 2019-03-17 19:28:32 +0100 | [diff] [blame] | 53 | |
Sean Anderson | 40686c3 | 2020-06-24 06:41:18 -0400 | [diff] [blame] | 54 | /** |
| 55 | * riscv_init_ipi() - Initialize inter-process interrupt (IPI) driver |
| 56 | * |
| 57 | * Platform code must provide this function. This function is called once after |
| 58 | * the cpu driver is initialized. No other riscv_*_ipi() calls will be made |
| 59 | * before this function is called. |
| 60 | * |
| 61 | * @return 0 if OK, -ve on error |
| 62 | */ |
| 63 | int riscv_init_ipi(void); |
| 64 | |
| 65 | /** |
| 66 | * riscv_send_ipi() - Send inter-processor interrupt (IPI) |
| 67 | * |
| 68 | * Platform code must provide this function. |
| 69 | * |
| 70 | * @hart: Hart ID of receiving hart |
| 71 | * @return 0 if OK, -ve on error |
| 72 | */ |
| 73 | int riscv_send_ipi(int hart); |
| 74 | |
| 75 | /** |
| 76 | * riscv_clear_ipi() - Clear inter-processor interrupt (IPI) |
| 77 | * |
| 78 | * Platform code must provide this function. |
| 79 | * |
| 80 | * @hart: Hart ID of hart to be cleared |
| 81 | * @return 0 if OK, -ve on error |
| 82 | */ |
| 83 | int riscv_clear_ipi(int hart); |
| 84 | |
| 85 | /** |
| 86 | * riscv_get_ipi() - Get status of inter-processor interrupt (IPI) |
| 87 | * |
| 88 | * Platform code must provide this function. |
| 89 | * |
| 90 | * @hart: Hart ID of hart to be checked |
| 91 | * @pending: Pointer to variable with result of the check, |
| 92 | * 1 if IPI is pending, 0 otherwise |
| 93 | * @return 0 if OK, -ve on error |
| 94 | */ |
| 95 | int riscv_get_ipi(int hart, int *pending); |
| 96 | |
Lukas Auer | fa33f08 | 2019-03-17 19:28:32 +0100 | [diff] [blame] | 97 | #endif |