@@ -299,13 +299,6 @@ exception_entry_foo:
b .
.= EXCEPTION_VECTORS_END
- /* This is the OPAL branch table. It's populated at boot time
- * with function pointers to the various OPAL functions from
- * the content of the .opal_table section, indexed by Token.
- */
-.global opal_branch_table
-opal_branch_table:
- .space 8 * (OPAL_LAST + 1)
/* Stores the offset we were started from. Used later on if we want to
* read any unrelocated code/data such as the built-in kernel image
@@ -9,9 +9,19 @@
#include <asm-offsets.h>
#include <processor.h>
#include <stack.h>
+#include <opal-api.h>
#define OLD_BINUTILS 1
+ .section ".rodata"
+ /* This is the OPAL branch table. It's populated at boot time
+ * with function pointers to the various OPAL functions from
+ * the content of the .opal_table section, indexed by Token.
+ */
+.global opal_branch_table
+opal_branch_table:
+ .space 8 * (OPAL_LAST + 1)
+
.section ".text","ax"
.balign 0x10
@@ -28,10 +28,10 @@
uint64_t opal_pending_events;
/* OPAL dispatch table defined in head.S */
-extern uint64_t opal_branch_table[];
+extern const uint64_t opal_branch_table[];
/* Number of args expected for each call. */
-static u8 opal_num_args[OPAL_LAST+1];
+static const u8 opal_num_args[OPAL_LAST+1];
/* OPAL anchor node */
struct dt_node *opal_node;
@@ -53,8 +53,8 @@ void opal_table_init(void)
prlog(PR_DEBUG, "OPAL table: %p .. %p, branch table: %p\n",
s, e, opal_branch_table);
while(s < e) {
- opal_branch_table[s->token] = function_entry_address(s->func);
- opal_num_args[s->token] = s->nargs;
+ ((uint64_t *)opal_branch_table)[s->token] = function_entry_address(s->func);
+ ((u8 *)opal_num_args)[s->token] = s->nargs;
s++;
}
}
@@ -321,8 +321,8 @@ void __opal_register(uint64_t token, void *func, unsigned int nargs)
{
assert(token <= OPAL_LAST);
- opal_branch_table[token] = function_entry_address(func);
- opal_num_args[token] = nargs;
+ ((uint64_t *)opal_branch_table)[token] = function_entry_address(func);
+ ((u8 *)opal_num_args)[token] = nargs;
}
/*
.head is for code and data which must reside at a fixed low address, mainly entry points. These are moved into .rodata. Despite being modified at runtime, this facilitates these tables being write-protected in a later patch. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- asm/head.S | 7 ------- asm/misc.S | 10 ++++++++++ core/opal.c | 12 ++++++------ 3 files changed, 16 insertions(+), 13 deletions(-)