-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
649 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# Makefile for libphoenix/arch/armv8 | ||
# | ||
# Copyright 2017, 2020 Phoenix Systems | ||
# Author: Pawel Pisarczyk | ||
# | ||
|
||
OBJS += $(addprefix $(PREFIX_O)arch/armv8m/, syscalls.o jmp.o signal.o string.o reboot.o tls.o) | ||
CRT0_OBJS += $(addprefix $(PREFIX_O)arch/armv8m/, crt0.o) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* libphoenix | ||
* | ||
* Entrypoint (armv8m) | ||
* | ||
* Copyright 2018, 2023 Phoenix Systems | ||
* Author: Aleksander Kaminski, Hubert Badocha | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
#define __ASSEMBLY__ | ||
|
||
.text | ||
.thumb | ||
.syntax unified | ||
|
||
.globl _start | ||
.type _start, %function | ||
_start: | ||
pop {r0-r3} | ||
b _startc | ||
.size _start, .-_start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* libphoenix | ||
* | ||
* | ||
* _setjmp, _longjmp, setjmp, sigsetjmp | ||
* | ||
* Copyright 2018, 2019 Phoenix Systems | ||
* Author: Kamil Amanowicz, Aleksander Kaminski, Jakub Sarzyński | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
/* setjmp env buffer description | ||
* Offset Description | ||
* 0 Signal mask flag - if != 0 then next value stores a signal mask | ||
* 4 Signal mask | ||
* 8 SP register | ||
* 12-43 r4-r11 registers | ||
* 44 LR register | ||
* 48-79 d8-d15 registers | ||
* 80 fpscr register | ||
*/ | ||
|
||
#define __ASSEMBLY__ | ||
|
||
.thumb | ||
.syntax unified | ||
|
||
.text | ||
.align 2 | ||
|
||
|
||
.globl sigsetjmp | ||
.type sigsetjmp, %function | ||
.align 2 | ||
sigsetjmp: | ||
/* Store signal mask if savesigs != 0 */ | ||
movs r2, #0 | ||
cbz r1, 1f | ||
|
||
/* Get signal mask */ | ||
/* Stack must be aligned to 8 bytes */ | ||
push {r0, r1, r3, lr} | ||
movs r0, #0 | ||
mov r1, r0 | ||
bl signalMask | ||
mov r2, r0 | ||
pop {r0, r1, r3, lr} | ||
|
||
1: | ||
/* Store mask (fake or real) and general registers */ | ||
mov r3, sp | ||
stmia r0!, {r1-r11, lr} | ||
|
||
#ifndef __SOFTFP__ | ||
/* Store fpu registers */ | ||
vstm r0!, {d8-d15} | ||
vmrs r2, fpscr | ||
str r2, [r0], #4 | ||
#endif | ||
|
||
movs r0, #0 | ||
bx lr | ||
.size sigsetjmp, .-sigsetjmp | ||
|
||
|
||
.globl _setjmp | ||
.type _setjmp, %function | ||
.align 2 | ||
_setjmp: | ||
movs r1, #0 | ||
b sigsetjmp | ||
.size _setjmp, .-_setjmp | ||
|
||
|
||
.globl setjmp | ||
.type setjmp, %function | ||
.align 2 | ||
setjmp: | ||
movs r1, #1 | ||
b sigsetjmp | ||
.size setjmp, .-setjmp | ||
|
||
|
||
.globl _longjmp | ||
.type _longjmp, %function | ||
.align 2 | ||
_longjmp: | ||
/* Check for signal mask in env buffer, if it's saved restore it */ | ||
ldmia r0!, {r2-r3} | ||
cbz r2, 1f | ||
|
||
/* Restore mask */ | ||
push {r0, r1} | ||
mov r0, r3 | ||
mvn r1, #0 | ||
bl signalMask | ||
pop {r0, r1} | ||
|
||
1: | ||
/* Restore general registers */ | ||
ldmia r0!, {r2, r4-r11, lr} | ||
mov sp, r2 | ||
|
||
#ifndef __SOFTFP__ | ||
/* Restore fpu registers */ | ||
vldm r0!, {d8-d15} | ||
ldr r2, [r0], #4 | ||
vmsr fpscr, r2 | ||
#endif | ||
|
||
/* Set return value */ | ||
movs r0, r1 | ||
it eq | ||
moveq r0, #1 | ||
bx lr | ||
.size _longjmp, .-_longjmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* libphoenix | ||
* | ||
* reboot.c | ||
* | ||
* Copyright 2019 Phoenix Systems | ||
* Author: Jan Sikorski | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
#include <sys/reboot.h> | ||
#include <sys/platform.h> | ||
|
||
#if defined(__CPU_NRF9160) | ||
#include <phoenix/arch/armv8m/nrf/91/nrf9160.h> | ||
#endif | ||
|
||
|
||
int reboot(int magic) | ||
{ | ||
platformctl_t pctl = { | ||
.action = pctl_set, | ||
.type = pctl_reboot, | ||
.reboot = { | ||
.magic = magic | ||
} | ||
}; | ||
|
||
return platformctl(&pctl); | ||
} | ||
|
||
|
||
int reboot_reason(uint32_t *val) | ||
{ | ||
platformctl_t pctl = { | ||
.action = pctl_get, | ||
.type = pctl_reboot, | ||
}; | ||
|
||
*val = 0; | ||
if (platformctl(&pctl) < 0) | ||
return -1; | ||
|
||
*val = pctl.reboot.reason; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* libphoenix | ||
* | ||
* Signal trampoline (armv8) | ||
* | ||
* Copyright 2019 Phoenix Systems | ||
* Author: Jan Sikorski | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
#define __ASSEMBLY__ | ||
|
||
.text | ||
.globl _signal_trampoline | ||
.type _signal_trampoline, %function | ||
_signal_trampoline: | ||
/* Signal number, cpu_context * */ | ||
pop {r0,r4} | ||
blx _signal_handler | ||
|
||
/* Old signal mask in r0 */ | ||
mov r1, r4 | ||
pop {r2,r3} /* pc, sp */ | ||
/* psr on stack */ | ||
bl sigreturn | ||
.size _signal_trampoline, .-_signal_trampoline |
Oops, something went wrong.