Skip to content

Commit

Permalink
xtensa: implement call0 ABI support in assembly
Browse files Browse the repository at this point in the history
Replace hardcoded register and opcode names with ABI-agnostic macros.
Add register save/restore code where necessary. Conditionalize windowed
only or call0 only code. Add stack initialization matching _switch_to
epilogue to copy_thread.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
  • Loading branch information
Max Filippov committed Oct 19, 2021
1 parent 5cce39b commit 0b53725
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 121 deletions.
68 changes: 36 additions & 32 deletions arch/xtensa/boot/boot-redboot/bootstrap.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <asm/regs.h>
#include <asm/asmmacro.h>
#include <asm/cacheasm.h>
#include <asm/processor.h>
/*
* RB-Data: RedBoot data/bss
* P: Boot-Parameters
Expand Down Expand Up @@ -36,7 +37,7 @@
.globl __start
/* this must be the first byte of the loader! */
__start:
entry sp, 32 # we do not intend to return
abi_entry(32) # we do not intend to return
_call0 _start
__start_a0:
.align 4
Expand All @@ -62,10 +63,12 @@ _start:
wsr a4, windowstart
rsync

movi a4, 0x00040000
movi a4, KERNEL_PS_WOE_MASK
wsr a4, ps
rsync

KABI_C0 mov abi_saved0, abi_arg0

/* copy the loader to its address
* Note: The loader itself is a very small piece, so we assume we
* don't partially overlap. We also assume (even more important)
Expand Down Expand Up @@ -168,52 +171,52 @@ _reloc:

movi a3, __image_load
sub a4, a3, a4
add a8, a0, a4
add abi_arg2, a0, a4

# a1 Stack
# a8(a4) Load address of the image

movi a6, _image_start
movi a10, _image_end
movi a7, 0x1000000
sub a11, a10, a6
movi a9, complen
s32i a11, a9, 0
movi abi_arg0, _image_start
movi abi_arg4, _image_end
movi abi_arg1, 0x1000000
sub abi_tmp0, abi_arg4, abi_arg0
movi abi_arg3, complen
s32i abi_tmp0, abi_arg3, 0

movi a0, 0

# a6 destination
# a7 maximum size of destination
# a8 source
# a9 ptr to length
# abi_arg0 destination
# abi_arg1 maximum size of destination
# abi_arg2 source
# abi_arg3 ptr to length

.extern gunzip
movi a4, gunzip
beqz a4, 1f
movi abi_tmp0, gunzip
beqz abi_tmp0, 1f

callx4 a4
abi_callx abi_tmp0

j 2f


# a6 destination start
# a7 maximum size of destination
# a8 source start
# a9 ptr to length
# a10 destination end
# abi_arg0 destination start
# abi_arg1 maximum size of destination
# abi_arg2 source start
# abi_arg3 ptr to length
# abi_arg4 destination end

1:
l32i a9, a8, 0
l32i a11, a8, 4
s32i a9, a6, 0
s32i a11, a6, 4
l32i a9, a8, 8
l32i a11, a8, 12
s32i a9, a6, 8
s32i a11, a6, 12
addi a6, a6, 16
addi a8, a8, 16
blt a6, a10, 1b
l32i abi_tmp0, abi_arg2, 0
l32i abi_tmp1, abi_arg2, 4
s32i abi_tmp0, abi_arg0, 0
s32i abi_tmp1, abi_arg0, 4
l32i abi_tmp0, abi_arg2, 8
l32i abi_tmp1, abi_arg2, 12
s32i abi_tmp0, abi_arg0, 8
s32i abi_tmp1, abi_arg0, 12
addi abi_arg0, abi_arg0, 16
addi abi_arg2, abi_arg2, 16
blt abi_arg0, abi_arg4, 1b


/* jump to the kernel */
Expand All @@ -230,6 +233,7 @@ _reloc:

# a2 Boot parameter list

KABI_C0 mov abi_arg0, abi_saved0
movi a0, _image_start
jx a0

Expand Down
Loading

0 comments on commit 0b53725

Please sign in to comment.