Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multipass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
derf
multipass
Commits
42e2809c
Commit
42e2809c
authored
5 years ago
by
Daniel Friesel
Browse files
Options
Downloads
Patches
Plain Diff
SRAM backup: documentation, config for offset+size
parent
5085f973
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/transactiontest/util.S
+46
-17
46 additions, 17 deletions
src/app/transactiontest/util.S
with
46 additions
and
17 deletions
src/app/transactiontest/util.S
+
46
−
17
View file @
42e2809c
...
@@ -2,60 +2,87 @@
...
@@ -2,60 +2,87 @@
.
global
asm_load_all
.
global
asm_load_all
.
global
asm_load_mem
.
global
asm_load_mem
stack_backup
:
#define SRAM_BASE #1c00h
.
space
2048
#define SRAM_SIZE
2048
; SRAM backup space
sram_backup
:
.
space
SRAM_SIZE
; Stack Pointer backup
sp_backup
:
sp_backup
:
.
space
2
.
space
2
; Backup Cookie: Do we have valid data or has the FRAM been wiped?
backup_cookie
:
backup_cookie
:
.
space
2
.
space
2
; save entire SRAM and CPU register state to persistent FRAM
asm_save_all
:
asm_save_all
:
dint
; r4 to r11 are callee saved -> push them to the stack.
; As we will save the entire SRAM (including stack), they are
; included in the SRAM backup and can be popped when restoring it.
.
irp
reg
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
.
irp
reg
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
push
r
\
reg
push
r
\
reg
.
endr
.
endr
; We will soon have valid data
mov
#
1234
h
,
r10
mov
#
1234
h
,
r10
mov
r10
,
&bac
kup_cookie
mov
r10
,
&bac
kup_cookie
mov
r1
,
&
sp_backup
mov
r1
,
&
sp_backup
mov
#
1
c00h
,
r10
mov
SRAM_BASE
,
r10
mov
#
stack_backup
,
r11
mov
#
sram_backup
,
r11
; Interrupts may alter global variables in SRAM and thus lead to inconsistencies
dint
save_sram_word
:
save_sram_word
:
mov
@
r10
+,
0
(
r11
)
mov
@
r10
+,
0
(
r11
)
add
#
2
,
r11
add
#
2
,
r11
cmp
#
1
c00h
+
2048
,
r10
cmp
SRAM_BASE
+
SRAM_SIZE
,
r10
jlo
save_sram_word
jlo
save_sram_word
eint
; revert changes to callee-saved registers
pop
r11
pop
r11
pop
r10
pop
r10
; remove unchanged registers from stack
add
#
12
,
r1
add
#
12
,
r1
eint
ret
ret
; load entire SRAM and CPU register stat from persistent FRAM,
; if it contains valid backup data. Execution will resume at the
; last place where asm_save_all() was called is if nothing in between
; had happened. Does not take possible the state of hardware peripherals
; into account.
asm_load_all
:
asm_load_all
:
dint
; check if we have backup data
push
r11
push
r11
mov
&bac
kup_cookie
,
r11
mov
&bac
kup_cookie
,
r11
cmp
#
1234
h
,
r11
cmp
#
1234
h
,
r11
; yes? -> load it
jeq
do_load_all
jeq
do_load_all
; no? -> too bad, resume with normal startup
pop
r11
pop
r11
eint
ret
ret
do_load_all
:
do_load_all
:
; restore SRAM from backup
; restore SRAM from backup
mov
#
stack_backup
,
r10
mov
#
sram_backup
,
r10
mov
#
1
c00h
,
r11
mov
SRAM_BASE
,
r11
dint
load_sram_word
:
load_sram_word
:
mov
@
r10
+,
0
(
r11
)
mov
@
r10
+,
0
(
r11
)
add
#
2
,
r11
add
#
2
,
r11
cmp
#
1
c00h
+
2048
,
r11
cmp
SRAM_BASE
+
SRAM_SIZE
,
r11
jlo
load_sram_word
jlo
load_sram_word
; restore stack pointer
; restore stack pointer
...
@@ -72,8 +99,9 @@ load_sram_word:
...
@@ -72,8 +99,9 @@ load_sram_word:
; -> execution will continue where asm_save_all was called
; -> execution will continue where asm_save_all was called
ret
ret
; Load global objects from persistent FRAM, if it contains valid backup data.
; Stack and CPU registers are left as-is, the program flow is not altered.
asm_load_mem
:
asm_load_mem
:
dint
push
r11
push
r11
mov
&bac
kup_cookie
,
r11
mov
&bac
kup_cookie
,
r11
...
@@ -86,11 +114,12 @@ asm_load_mem:
...
@@ -86,11 +114,12 @@ asm_load_mem:
do_load_mem
:
do_load_mem
:
push
r10
push
r10
push
r9
push
r9
; restore SRAM from backup, excluding current stack frame
; restore SRAM from backup, excluding stack
; -> everything from SRAM start (inclusive) to @sp (exclusive). Reminder: SP == R1 on MSP430
mov
r1
,
r9
mov
r1
,
r9
sub
6
,
r
9
mov
#
sram_backup
,
r
10
mov
#
stack_backup
,
r1
0
mov
SRAM_BASE
,
r1
1
mov
#
1
c00h
,
r11
dint
load_sram_word2
:
load_sram_word2
:
mov
@
r10
+,
0
(
r11
)
mov
@
r10
+,
0
(
r11
)
add
#
2
,
r11
add
#
2
,
r11
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment