-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arch: add armv8m #342
Draft
damianloew
wants to merge
2
commits into
master
Choose a base branch
from
damianloew/nrf9160_port
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
arch: add armv8m #342
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 2024 Phoenix Systems | ||
# Author: Damian Loewnau | ||
# | ||
|
||
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, 2024 Phoenix Systems | ||
* Author: Aleksander Kaminski, Hubert Badocha, Damian Loewnau | ||
* | ||
* 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, 2024 Phoenix Systems | ||||
* Author: Kamil Amanowicz, Aleksander Kaminski, Jakub Sarzyński, Damian Loewnau | ||||
* | ||||
* 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 | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant
Suggested change
|
||||
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, 2024 Phoenix Systems | ||
* Author: Jan Sikorski, Damian Loewnau | ||
* | ||
* 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, 2024 Phoenix Systems | ||
* Author: Jan Sikorski, Damian Loewnau | ||
* | ||
* 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alignment might cause some performance penalty. IMHO better to set it to 4, to make it predictable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to leave 2 for other arm architectures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other arm archs aren't in the scope of this PR. Imho it's best to change alignment to 4 everywhere eventually, as @lukileczo found out it's faster indeed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see that it has been changed recently