summaryrefslogtreecommitdiffstats
path: root/arch/openrisc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/openrisc')
-rw-r--r--arch/openrisc/Kconfig3
-rw-r--r--arch/openrisc/Makefile6
-rw-r--r--arch/openrisc/boards/generic/Makefile2
-rw-r--r--arch/openrisc/boards/generic/config.h1
-rw-r--r--arch/openrisc/boards/generic/generic.c1
-rw-r--r--arch/openrisc/cpu/.gitignore2
-rw-r--r--arch/openrisc/cpu/Makefile2
-rw-r--r--arch/openrisc/cpu/barebox.lds.S5
-rw-r--r--arch/openrisc/cpu/cache.c3
-rw-r--r--arch/openrisc/cpu/cpu.c5
-rw-r--r--arch/openrisc/cpu/exceptions.c4
-rw-r--r--arch/openrisc/cpu/start.S6
-rw-r--r--arch/openrisc/dts/.gitignore0
-rw-r--r--arch/openrisc/dts/Makefile3
-rw-r--r--arch/openrisc/include/asm/barebox.lds.h5
-rw-r--r--arch/openrisc/include/asm/bitsperlong.h2
-rw-r--r--arch/openrisc/include/asm/byteorder.h2
-rw-r--r--arch/openrisc/include/asm/common.h2
-rw-r--r--arch/openrisc/include/asm/linkage.h9
-rw-r--r--arch/openrisc/include/asm/mmu.h2
-rw-r--r--arch/openrisc/include/asm/posix_types.h2
-rw-r--r--arch/openrisc/include/asm/sections.h2
-rw-r--r--arch/openrisc/include/asm/setjmp.h17
-rw-r--r--arch/openrisc/include/asm/string.h2
-rw-r--r--arch/openrisc/include/asm/swab.h2
-rw-r--r--arch/openrisc/include/asm/types.h48
-rw-r--r--arch/openrisc/include/asm/word-at-a-time.h2
-rw-r--r--arch/openrisc/lib/Makefile3
-rw-r--r--arch/openrisc/lib/ashldi3.S2
-rw-r--r--arch/openrisc/lib/asm-offsets.c2
-rw-r--r--arch/openrisc/lib/board.c6
-rw-r--r--arch/openrisc/lib/clock.c4
-rw-r--r--arch/openrisc/lib/cpuinfo.c5
-rw-r--r--arch/openrisc/lib/dtb.c13
-rw-r--r--arch/openrisc/lib/lshrdi3.S2
-rw-r--r--arch/openrisc/lib/muldi3.S2
-rw-r--r--arch/openrisc/lib/setjmp.S56
37 files changed, 154 insertions, 81 deletions
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 32d23029d8..4ae03b748c 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -1,9 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
config OPENRISC
bool
select OFTREE
select HAS_CACHE
select HAVE_CONFIGURABLE_MEMORY_LAYOUT
select GENERIC_FIND_NEXT_BIT
+ select ARCH_HAS_SJLJ
default y
# not used
diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
index 5394afb7f0..609b998de9 100644
--- a/arch/openrisc/Makefile
+++ b/arch/openrisc/Makefile
@@ -1,6 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
KBUILD_DEFCONFIG := generic_defconfig
-CPPFLAGS += -D__OR1K__ -ffixed-r10 -mhard-mul -mhard-div
+KBUILD_CPPFLAGS += -D__OR1K__ -ffixed-r10 -mhard-mul -mhard-div
board-$(CONFIG_GENERIC) := generic
@@ -28,3 +30,5 @@ dts := arch/openrisc/dts
%.dtb: scripts
$(Q)$(MAKE) $(build)=$(dts) $(dts)/$@
+
+KBUILD_IMAGE := barebox
diff --git a/arch/openrisc/boards/generic/Makefile b/arch/openrisc/boards/generic/Makefile
index d8a3d7f2cc..3cdac31b39 100644
--- a/arch/openrisc/boards/generic/Makefile
+++ b/arch/openrisc/boards/generic/Makefile
@@ -1 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
obj-y += generic.o
diff --git a/arch/openrisc/boards/generic/config.h b/arch/openrisc/boards/generic/config.h
index f6a054beed..2d836d0063 100644
--- a/arch/openrisc/boards/generic/config.h
+++ b/arch/openrisc/boards/generic/config.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _GENERIC_NAMES_H_
#define _GENERIC_NAMES_H_
diff --git a/arch/openrisc/boards/generic/generic.c b/arch/openrisc/boards/generic/generic.c
index ff6f9f4d42..1129a7d52e 100644
--- a/arch/openrisc/boards/generic/generic.c
+++ b/arch/openrisc/boards/generic/generic.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
#include <common.h>
#include <init.h>
diff --git a/arch/openrisc/cpu/.gitignore b/arch/openrisc/cpu/.gitignore
index d1165788c9..03987a7009 100644
--- a/arch/openrisc/cpu/.gitignore
+++ b/arch/openrisc/cpu/.gitignore
@@ -1 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
barebox.lds
diff --git a/arch/openrisc/cpu/Makefile b/arch/openrisc/cpu/Makefile
index 1cd7506003..9828dff95d 100644
--- a/arch/openrisc/cpu/Makefile
+++ b/arch/openrisc/cpu/Makefile
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
obj-y += start.o
obj-y += cpu.o
obj-y += exceptions.o
diff --git a/arch/openrisc/cpu/barebox.lds.S b/arch/openrisc/cpu/barebox.lds.S
index adb0c22f85..3fae1af375 100644
--- a/arch/openrisc/cpu/barebox.lds.S
+++ b/arch/openrisc/cpu/barebox.lds.S
@@ -14,9 +14,10 @@
*/
#include <config.h>
-#include <asm-generic/barebox.lds.h>
+#include <asm/barebox.lds.h>
-OUTPUT_FORMAT("elf32-or1k", "elf32-or1k", "elf32-or1k")
+OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
+ENTRY(__reset)
__DYNAMIC = 0;
MEMORY
diff --git a/arch/openrisc/cpu/cache.c b/arch/openrisc/cpu/cache.c
index 1da2380c03..a124d6612c 100644
--- a/arch/openrisc/cpu/cache.c
+++ b/arch/openrisc/cpu/cache.c
@@ -17,6 +17,7 @@
#include <common.h>
#include <init.h>
#include <asm/system.h>
+#include <asm/cache.h>
void flush_dcache_range(unsigned long addr, unsigned long stop)
{
@@ -130,7 +131,7 @@ void icache_disable(void)
mtspr(SPR_SR, mfspr(SPR_SR) & ~SPR_SR_ICE);
}
-int cache_init(void)
+static int cache_init(void)
{
if (mfspr(SPR_UPR) & SPR_UPR_ICP) {
icache_disable();
diff --git a/arch/openrisc/cpu/cpu.c b/arch/openrisc/cpu/cpu.c
index cae42d41b8..47d8ab4288 100644
--- a/arch/openrisc/cpu/cpu.c
+++ b/arch/openrisc/cpu/cpu.c
@@ -2,9 +2,6 @@
* (C) Copyright 2011, Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
* (C) Copyright 2011, Julius Baxter <julius@opencores.org>
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
@@ -36,6 +33,6 @@ static void __noreturn openrisc_restart_cpu(struct restart_handler *rst)
static int restart_register_feature(void)
{
- return restart_handler_register_fn(openrisc_restart_cpu);
+ return restart_handler_register_fn("vector", openrisc_restart_cpu);
}
coredevice_initcall(restart_register_feature);
diff --git a/arch/openrisc/cpu/exceptions.c b/arch/openrisc/cpu/exceptions.c
index d01fbfbb1c..c69ceafe80 100644
--- a/arch/openrisc/cpu/exceptions.c
+++ b/arch/openrisc/cpu/exceptions.c
@@ -16,6 +16,7 @@
#include <common.h>
#include <asm/system.h>
+#include <asm/openrisc_exc.h>
static const char * const excp_table[] = {
"Unknown exception",
@@ -69,6 +70,9 @@ static void exception_hang(int vect)
hang();
}
+/* Called from assembly */
+void exception_handler(int vect);
+
void exception_handler(int vect)
{
int exception = vect >> 8;
diff --git a/arch/openrisc/cpu/start.S b/arch/openrisc/cpu/start.S
index 7ac790b055..c448d3775f 100644
--- a/arch/openrisc/cpu/start.S
+++ b/arch/openrisc/cpu/start.S
@@ -37,10 +37,10 @@
.org 0x100
__reset:
/* there is no guarantee r0 is hardwired to zero, clear it here */
- l.andi r0, r0, 0
+ l.movhi r0, 0x0
/* reset stack and frame pointers */
- l.andi r1, r0, 0
- l.andi r2, r0, 0
+ l.movhi r1, 0x0
+ l.movhi r2, 0x0
/* set supervisor mode */
l.ori r3,r0,SPR_SR_SM
diff --git a/arch/openrisc/dts/.gitignore b/arch/openrisc/dts/.gitignore
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/arch/openrisc/dts/.gitignore
diff --git a/arch/openrisc/dts/Makefile b/arch/openrisc/dts/Makefile
index 6d6c9a3ce0..6778abe1b4 100644
--- a/arch/openrisc/dts/Makefile
+++ b/arch/openrisc/dts/Makefile
@@ -1,5 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_BUILTIN_DTB_NAME))
obj-$(CONFIG_BUILTIN_DTB) += $(BUILTIN_DTB).dtb.o
-clean-files := *.dtb *.dtb.S
+clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.z
diff --git a/arch/openrisc/include/asm/barebox.lds.h b/arch/openrisc/include/asm/barebox.lds.h
new file mode 100644
index 0000000000..87d868e1ad
--- /dev/null
+++ b/arch/openrisc/include/asm/barebox.lds.h
@@ -0,0 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#define BAREBOX_OUTPUT_FORMAT "elf32-or1k", "elf32-or1k", "elf32-or1k"
+
+#include <asm-generic/barebox.lds.h>
diff --git a/arch/openrisc/include/asm/bitsperlong.h b/arch/openrisc/include/asm/bitsperlong.h
index 6dc0bb0c13..bf000a04cc 100644
--- a/arch/openrisc/include/asm/bitsperlong.h
+++ b/arch/openrisc/include/asm/bitsperlong.h
@@ -1 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#include <asm-generic/bitsperlong.h>
diff --git a/arch/openrisc/include/asm/byteorder.h b/arch/openrisc/include/asm/byteorder.h
index 60d14f7e14..bd60c438a9 100644
--- a/arch/openrisc/include/asm/byteorder.h
+++ b/arch/openrisc/include/asm/byteorder.h
@@ -1 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#include <linux/byteorder/big_endian.h>
diff --git a/arch/openrisc/include/asm/common.h b/arch/openrisc/include/asm/common.h
index 027dca2d56..06bb4824a2 100644
--- a/arch/openrisc/include/asm/common.h
+++ b/arch/openrisc/include/asm/common.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef _ASM_COMMON_H
#define __ASM_COMMON_H
diff --git a/arch/openrisc/include/asm/linkage.h b/arch/openrisc/include/asm/linkage.h
new file mode 100644
index 0000000000..aebd618b27
--- /dev/null
+++ b/arch/openrisc/include/asm/linkage.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_LINKAGE_H
+#define __ASM_LINKAGE_H
+
+#define __ALIGN .align 0
+#define __ALIGN_STR ".align 0"
+
+#endif
diff --git a/arch/openrisc/include/asm/mmu.h b/arch/openrisc/include/asm/mmu.h
index 95af871420..1c2646ebb3 100644
--- a/arch/openrisc/include/asm/mmu.h
+++ b/arch/openrisc/include/asm/mmu.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_MMU_H
#define __ASM_MMU_H
diff --git a/arch/openrisc/include/asm/posix_types.h b/arch/openrisc/include/asm/posix_types.h
index 22cae6230c..feaed42471 100644
--- a/arch/openrisc/include/asm/posix_types.h
+++ b/arch/openrisc/include/asm/posix_types.h
@@ -1 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#include <asm-generic/posix_types.h>
diff --git a/arch/openrisc/include/asm/sections.h b/arch/openrisc/include/asm/sections.h
index 2b8c516038..c6dd0eead2 100644
--- a/arch/openrisc/include/asm/sections.h
+++ b/arch/openrisc/include/asm/sections.h
@@ -1 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#include <asm-generic/sections.h>
diff --git a/arch/openrisc/include/asm/setjmp.h b/arch/openrisc/include/asm/setjmp.h
new file mode 100644
index 0000000000..ee73306d18
--- /dev/null
+++ b/arch/openrisc/include/asm/setjmp.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Define the machine-dependent type `jmp_buf'. OpenRISC version.
+ * Copyright (C) 2021 Free Software Foundation, Inc.
+ * This file is part of the GNU C Library.
+ */
+
+#ifndef _OR1K_BITS_SETJMP_H
+#define _OR1K_BITS_SETJMP_H 1
+
+typedef long int jmp_buf[13];
+
+int setjmp(jmp_buf jmp) __attribute__((returns_twice));
+void longjmp(jmp_buf jmp, int ret) __attribute__((noreturn));
+int initjmp(jmp_buf jmp, void __attribute__((noreturn)) (*func)(void), void *stack_top);
+
+#endif /* _OR1K_BITS_SETJMP_H */
diff --git a/arch/openrisc/include/asm/string.h b/arch/openrisc/include/asm/string.h
index 73e265564a..cfc2ea1f37 100644
--- a/arch/openrisc/include/asm/string.h
+++ b/arch/openrisc/include/asm/string.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_OPENRISC_STRING_H
#define __ASM_OPENRISC_STRING_H
diff --git a/arch/openrisc/include/asm/swab.h b/arch/openrisc/include/asm/swab.h
index b07e1d51f1..0b49949db8 100644
--- a/arch/openrisc/include/asm/swab.h
+++ b/arch/openrisc/include/asm/swab.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef _ASM_SWAB_H
#define _ASM_SWAB_H
diff --git a/arch/openrisc/include/asm/types.h b/arch/openrisc/include/asm/types.h
index 8ee6bb00f9..21a45b74cd 100644
--- a/arch/openrisc/include/asm/types.h
+++ b/arch/openrisc/include/asm/types.h
@@ -16,52 +16,6 @@
#ifndef _ASM_TYPES_H
#define _ASM_TYPES_H
-/*
- * This file is never included by application software unless
- * explicitly requested (e.g., via linux/types.h) in which case the
- * application is Linux specific so (user-) name space pollution is
- * not a major issue. However, for interoperability, libraries still
- * need to be careful to avoid a name clashes.
- */
-
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
-#if defined(__GNUC__)
-__extension__ typedef __signed__ long long __s64;
-__extension__ typedef unsigned long long __u64;
-#endif
-
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-#include <asm/bitsperlong.h>
-
-#endif /* __KERNEL__ */
+#include <asm-generic/int-ll64.h>
#endif /* _ASM_TYPES_H */
diff --git a/arch/openrisc/include/asm/word-at-a-time.h b/arch/openrisc/include/asm/word-at-a-time.h
new file mode 100644
index 0000000000..f6306fb896
--- /dev/null
+++ b/arch/openrisc/include/asm/word-at-a-time.h
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <asm-generic/word-at-a-time.h>
diff --git a/arch/openrisc/lib/Makefile b/arch/openrisc/lib/Makefile
index 62082feed0..a55a9049e6 100644
--- a/arch/openrisc/lib/Makefile
+++ b/arch/openrisc/lib/Makefile
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
obj-y += clock.o
obj-y += board.o
obj-y += cpuinfo.o
@@ -5,4 +7,5 @@ obj-y += muldi3.o
obj-y += lshrdi3.o
obj-y += ashldi3.o
obj-y += ashrdi3.o
+obj-y += setjmp.o
obj-$(CONFIG_BUILTIN_DTB) += dtb.o
diff --git a/arch/openrisc/lib/ashldi3.S b/arch/openrisc/lib/ashldi3.S
index 3e422fadc4..f6b976bff2 100644
--- a/arch/openrisc/lib/ashldi3.S
+++ b/arch/openrisc/lib/ashldi3.S
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
/*
* (C) Copyright 2011 - Franck JULLIEN <elec4fun@gmail.com>
*
diff --git a/arch/openrisc/lib/asm-offsets.c b/arch/openrisc/lib/asm-offsets.c
index 8cee8e00c6..e9d631a35c 100644
--- a/arch/openrisc/lib/asm-offsets.c
+++ b/arch/openrisc/lib/asm-offsets.c
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
/*
* OpenRISC asm-offsets.c
*
diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c
index 25bcc0517b..9591120fee 100644
--- a/arch/openrisc/lib/board.c
+++ b/arch/openrisc/lib/board.c
@@ -1,9 +1,6 @@
/*
* (C) Copyright 2011 - Franck JULLIEN <elec4fun@gmail.com>
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
@@ -22,6 +19,9 @@
#include <memory.h>
#include <asm-generic/memory_layout.h>
+/* Called from assembly */
+void openrisc_start_barebox(void);
+
void __noreturn openrisc_start_barebox(void)
{
mem_malloc_init((void *)(OPENRISC_SOPC_TEXT_BASE - MALLOC_SIZE),
diff --git a/arch/openrisc/lib/clock.c b/arch/openrisc/lib/clock.c
index a171214a53..651b163f13 100644
--- a/arch/openrisc/lib/clock.c
+++ b/arch/openrisc/lib/clock.c
@@ -1,9 +1,6 @@
/*
* (C) Copyright 2011 - Franck JULLIEN <elec4fun@gmail.com>
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
@@ -31,6 +28,7 @@ static struct clocksource cs = {
.read = openrisc_clocksource_read,
.mask = 0xffffffff,
.shift = 12,
+ .priority = 80,
};
static int clocksource_init(void)
diff --git a/arch/openrisc/lib/cpuinfo.c b/arch/openrisc/lib/cpuinfo.c
index 175adc582c..d94178ea59 100644
--- a/arch/openrisc/lib/cpuinfo.c
+++ b/arch/openrisc/lib/cpuinfo.c
@@ -2,9 +2,6 @@
* (C) Copyright 2011, Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
* (C) Copyright 2011, Julius Baxter <julius@opencores.org>
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
@@ -98,7 +95,7 @@ static void cpu_implementation(ulong vr2, char *string)
}
}
-int checkcpu(void)
+static int checkcpu(void)
{
ulong upr = mfspr(SPR_UPR);
ulong vr = mfspr(SPR_VR);
diff --git a/arch/openrisc/lib/dtb.c b/arch/openrisc/lib/dtb.c
index 04bb6d25cc..0507eed1d7 100644
--- a/arch/openrisc/lib/dtb.c
+++ b/arch/openrisc/lib/dtb.c
@@ -4,9 +4,6 @@
* Based on arch/arm/cpu/dtb.c:
* Copyright (C) 2013 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
@@ -31,14 +28,6 @@ static int of_openrisc_init(void)
if (root)
return 0;
- root = of_unflatten_dtb(__dtb_start);
- if (!IS_ERR(root)) {
- pr_debug("using internal DTB\n");
- of_set_root_node(root);
- if (IS_ENABLED(CONFIG_OFDEVICE))
- of_probe();
- }
-
- return 0;
+ return barebox_register_fdt(__dtb_start);
}
core_initcall(of_openrisc_init);
diff --git a/arch/openrisc/lib/lshrdi3.S b/arch/openrisc/lib/lshrdi3.S
index de30445f4e..99aa73ef51 100644
--- a/arch/openrisc/lib/lshrdi3.S
+++ b/arch/openrisc/lib/lshrdi3.S
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
/*
* (C) Copyright 2011 - Franck JULLIEN <elec4fun@gmail.com>
*
diff --git a/arch/openrisc/lib/muldi3.S b/arch/openrisc/lib/muldi3.S
index 902338a242..70d0eacf1e 100644
--- a/arch/openrisc/lib/muldi3.S
+++ b/arch/openrisc/lib/muldi3.S
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
/*
* (C) Copyright 2011 - Franck JULLIEN <elec4fun@gmail.com>
*
diff --git a/arch/openrisc/lib/setjmp.S b/arch/openrisc/lib/setjmp.S
new file mode 100644
index 0000000000..7da3477808
--- /dev/null
+++ b/arch/openrisc/lib/setjmp.S
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <linux/linkage.h>
+
+/* int setjmp (jmp_buf); */
+ENTRY(setjmp)
+ l.sw 0(r3), r1
+ l.sw 4(r3), r2
+ l.sw 8(r3), r9
+ l.sw 12(r3), r10
+ l.sw 16(r3), r14
+ l.sw 20(r3), r16
+ l.sw 24(r3), r18
+ l.sw 28(r3), r20
+ l.sw 32(r3), r22
+ l.sw 36(r3), r24
+ l.sw 40(r3), r26
+ l.sw 44(r3), r28
+ l.sw 48(r3), r30
+ l.jr r9
+ l.movhi r11, 0x0
+END(setjmp)
+
+/* volatile void longjmp (jmp_buf, int); */
+ENTRY(longjmp)
+ l.lwz r1, 0(r3)
+ l.lwz r2, 4(r3)
+
+ /* if r4 is 0, something wrong, so set it to 1 */
+ l.sfeqi r4, 0x0
+ l.bnf 1f /* r4 != 0, longjmp value sensible */
+ l.nop
+ l.ori r4, r0, 0x1 /* make nonzero */
+1:
+ l.lwz r9, 8(r3)
+ l.lwz r10, 12(r3)
+ l.lwz r14, 16(r3)
+ l.lwz r16, 20(r3)
+ l.lwz r18, 24(r3)
+ l.lwz r20, 28(r3)
+ l.lwz r22, 32(r3)
+ l.lwz r24, 36(r3)
+ l.lwz r26, 40(r3)
+ l.lwz r28, 44(r3)
+ l.lwz r30, 48(r3)
+ l.jr r9
+ l.addi r11, r4, 0x0
+END(longjmp)
+
+/* int initjmp(jmp_buf jmp, void __noreturn (*func)(void), void *stack_top); */
+ENTRY(initjmp)
+ l.sw 8(r3), r4
+ l.sw 0(r3), r5
+ l.jr r9
+ l.movhi r11, 0x0
+END(initjmp)