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
705a25ff
Commit
705a25ff
authored
5 years ago
by
Daniel Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Use two FRAM areas to ensure atomicity
parent
b3451dad
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+3
-0
3 additions, 0 deletions
Makefile
src/app/transactiontest/util.S
+65
-43
65 additions, 43 deletions
src/app/transactiontest/util.S
with
68 additions
and
43 deletions
Makefile
+
3
−
0
View file @
705a25ff
...
...
@@ -60,6 +60,9 @@ endif
ifneq
($(findstring sharp96,${drivers}), )
CXX_TARGETS
+=
src/driver/sharp96.cc
sharp96_power_pin
?=
p1_2
sharp96_en_pin
?=
p6_2
sharp96_cs_pin
?=
p1_3
sharp96_power_pin
?=
p4_2
sharp96_en_pin
?=
p4_3
sharp96_cs_pin
?=
p2_4
...
...
This diff is collapsed.
Click to expand it.
src/app/transactiontest/util.S
+
65
−
43
View file @
705a25ff
...
...
@@ -5,15 +5,18 @@
#define SRAM_BASE #1c00h
#define SRAM_SIZE 4096
; SRAM backup space
sram_backup
:
; SRAM and stack pointer backup space
sp_backup1
:
.
space
2
sram_backup1
:
.
space
SRAM_SIZE
; Stack Pointer backup
sp_backup
:
sp_backup2
:
.
space
2
sram_backup2
:
.
space
SRAM_SIZE
; Backup Cookie: Do we have valid data or has the FRAM been wiped?
; Backup Cookie: Do we have valid data (and if yes, where?)
; or has the FRAM been wiped?
backup_cookie
:
.
space
2
...
...
@@ -27,35 +30,40 @@ asm_save_all:
push
r
\
reg
.
endr
; We will soon have valid data
mov
#
1234
h
,
r10
mov
r10
,
&bac
kup_cookie
mov
&bac
kup_cookie
,
r10
; content of backup_cookie -> r10
mov
#
sp_backup1
,
r11
; address of sp_backup1 -> r11
cmp
r10
,
r11
; backup_cookie == addr. of sp_backup1?
jne
do_save_all
; if not, the previous backup went to space 2 or never happened -> write backup to space 1
; otherwise, the previous backup went to space 1 -> write backup to space 2
mov
r1
,
&
sp_backup
mov
#
sp_backup
2
,
r11
mov
SRAM_BASE
,
r10
mov
#
sram_backup
,
r11
; Interrupts may alter global variables in SRAM and thus lead to inconsistencies
do_save_all
:
dint
mov
r1
,
0
(
r11
)
; store stack pointer in sp_backup(1|2)
mov
r11
,
r9
; backup location -> r9
mov
SRAM_BASE
,
r10
; SRAM area start -> r10
save_sram_word
:
mov
@
r10
+,
0
(
r11
)
add
#
2
,
r11
mov
@
r10
+,
0
(
r11
)
cmp
SRAM_BASE
+
SRAM_SIZE
,
r10
jlo
save_sram_word
mov
r9
,
&bac
kup_cookie
; save backup location (addr. of sp_backup(1|2)) in backup_cookie
eint
; revert changes to callee-saved registers
pop
r11
pop
r10
pop
r9
; remove unchanged registers from stack
add
#
1
2
,
r1
add
#
1
0
,
r1
ret
; load entire SRAM and CPU register stat from persistent FRAM,
; load entire SRAM and CPU register stat
e
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
...
...
@@ -64,31 +72,37 @@ asm_load_all:
; check if we have backup data
push
r11
mov
&bac
kup_cookie
,
r1
1
cmp
#
1234
h
,
r1
1
push
r1
0
mov
&bac
kup_cookie
,
r1
0
; yes? -> load it
; ... in location 1?
mov
#
sp_backup1
,
r11
cmp
r10
,
r11
jeq
do_load_all
; ... in location 2?
mov
#
sp_backup2
,
r11
cmp
r10
,
r11
jeq
do_load_all
; no? -> too bad, resume with normal startup
pop
r10
pop
r11
ret
dint
do_load_all
:
dint
; restore stack pointer
mov
@
r11
,
r1
add
#
2
,
r11
; restore SRAM from backup
mov
#
sram_backup
,
r10
mov
SRAM_BASE
,
r11
mov
SRAM_BASE
,
r10
load_sram_word
:
mov
@
r1
0
+,
0
(
r1
1
)
add
#
2
,
r1
1
cmp
SRAM_BASE
+
SRAM_SIZE
,
r1
1
mov
@
r1
1
+,
0
(
r1
0
)
add
#
2
,
r1
0
cmp
SRAM_BASE
+
SRAM_SIZE
,
r1
0
jlo
load_sram_word
; restore stack pointer
mov
&
sp_backup
,
r1
; restore registers
.
irp
reg
,
11
,
10
,
9
,
8
,
7
,
6
,
5
,
4
pop
r
\
reg
...
...
@@ -104,30 +118,38 @@ load_sram_word:
; Stack and CPU registers are left as-is, the program flow is not altered.
asm_load_mem
:
; check if we have backup data
push
r11
mov
&bac
kup_cookie
,
r11
cmp
#
1234
h
,
r11
push
r10
mov
&bac
kup_cookie
,
r10
; ... in location 1?
mov
#
sp_backup1
,
r11
cmp
r10
,
r11
jeq
do_load_mem
; ... in location 2?
mov
#
sp_backup2
,
r11
cmp
r10
,
r11
jeq
do_load_mem
; no? -> too bad, resume with normal startup
pop
r10
pop
r11
ret
dint
do_load_mem
:
push
r10
push
r9
dint
; restore SRAM from backup, excluding stack
; -> everything from SRAM start (inclusive) to @sp (exclusive). Reminder: SP == R1 on MSP430
mov
r1
,
r9
mov
#
sram_backup
,
r10
mov
SRAM_BASE
,
r11
load_sram_word2
:
mov
@
r10
+,
0
(
r11
)
add
#
2
,
r11
cmp
r9
,
r11
mov
SRAM_BASE
,
r10
load_sram_word2
:
mov
@
r11
+,
0
(
r10
)
add
#
2
,
r10
cmp
r1
,
r10
jlo
load_sram_word2
pop
r9
pop
r10
pop
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