summaryrefslogtreecommitdiff
path: root/kern/xcall.c
diff options
context:
space:
mode:
Diffstat (limited to 'kern/xcall.c')
-rw-r--r--kern/xcall.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/kern/xcall.c b/kern/xcall.c
index 364ad0be..cccb9373 100644
--- a/kern/xcall.c
+++ b/kern/xcall.c
@@ -15,12 +15,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
+#include <stdalign.h>
#include <stddef.h>
-#include <kern/assert.h>
#include <kern/atomic.h>
+#include <kern/init.h>
#include <kern/macros.h>
-#include <kern/param.h>
#include <kern/percpu.h>
#include <kern/spinlock.h>
#include <kern/thread.h>
@@ -28,9 +29,9 @@
#include <machine/cpu.h>
struct xcall {
- xcall_fn_t fn;
+ alignas(CPU_L1_SIZE) xcall_fn_t fn;
void *arg;
-} __aligned(CPU_L1_SIZE);
+};
/*
* Per-CPU data.
@@ -49,11 +50,11 @@ struct xcall {
* between multiple cross-calls.
*/
struct xcall_cpu_data {
- struct xcall send_calls[X15_MAX_CPUS];
+ alignas(CPU_L1_SIZE) struct xcall send_calls[X15_MAX_CPUS];
struct xcall *recv_call;
struct spinlock lock;
-} __aligned(CPU_L1_SIZE);
+};
static struct xcall_cpu_data xcall_cpu_data __percpu;
@@ -92,7 +93,8 @@ xcall_cpu_data_get_recv_call(const struct xcall_cpu_data *cpu_data)
}
static void
-xcall_cpu_data_set_recv_call(struct xcall_cpu_data *cpu_data, struct xcall *call)
+xcall_cpu_data_set_recv_call(struct xcall_cpu_data *cpu_data,
+ struct xcall *call)
{
atomic_store(&cpu_data->recv_call, call, ATOMIC_RELEASE);
}
@@ -103,7 +105,7 @@ xcall_cpu_data_clear_recv_call(struct xcall_cpu_data *cpu_data)
xcall_cpu_data_set_recv_call(cpu_data, NULL);
}
-void
+static int __init
xcall_setup(void)
{
unsigned int i;
@@ -111,8 +113,15 @@ xcall_setup(void)
for (i = 0; i < cpu_count(); i++) {
xcall_cpu_data_init(percpu_ptr(xcall_cpu_data, i));
}
+
+ return 0;
}
+INIT_OP_DEFINE(xcall_setup,
+ INIT_OP_DEP(percpu_setup, true),
+ INIT_OP_DEP(thread_bootstrap, true),
+ INIT_OP_DEP(spinlock_setup, true));
+
void
xcall_call(xcall_fn_t fn, void *arg, unsigned int cpu)
{