summaryrefslogtreecommitdiff
path: root/chip/mt_scp/rv32i_common/ipi_table.c
blob: 8fe3f1e598d907df262c7e58f8bcee14c39ef3f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * IPI handlers declaration
 */

#include "common.h"
#include "ipi_chip.h"

typedef void (*ipi_handler_t)(int32_t id, void *data, uint32_t len);

#ifndef PASS
#define PASS 1
#endif

#define ipi_arguments int32_t id, void *data, uint32_t len

#if PASS == 1
void ipi_handler_undefined(ipi_arguments) { }

const int ipi_wakeup_undefined;

#define table(type, name, x) x

#define ipi_x_func(suffix, args, number)                                       \
	extern void __attribute__(                                             \
		(used, weak, alias(STRINGIFY(ipi_##suffix##_undefined))))      \
		ipi_##number##_##suffix(args);

#define ipi_x_var(suffix, number)                                              \
	extern int __attribute__(                                              \
		(weak, alias(STRINGIFY(ipi_##suffix##_undefined))))            \
		ipi_##number##_##suffix;

#endif /* PASS == 1 */

#if PASS == 2

#undef table
#undef ipi_x_func
#undef ipi_x_var

#define table(type, name, x)                                                   \
	type const name[]                                                      \
		__attribute__((aligned(4), used, section(".rodata.ipi"))) = {x}

#define ipi_x_var(suffix, number)                                              \
	[number < IPI_COUNT ? number : -1] = &ipi_##number##_##suffix,

#define ipi_x_func(suffix, args, number) ipi_x_var(suffix, number)

#endif /* PASS == 2 */

/*
 * Include generated IPI table (by util/gen_ipi_table). The contents originate
 * from IPI_COUNT definition in board.h
 */
#include "ipi_table_gen.inc"

#if PASS == 1
#undef PASS
#define PASS 2
#include "ipi_table.c"
BUILD_ASSERT(ARRAY_SIZE(ipi_handler_table) == IPI_COUNT);
BUILD_ASSERT(ARRAY_SIZE(ipi_wakeup_table) == IPI_COUNT);
#endif