-
Notifications
You must be signed in to change notification settings - Fork 961
all: prototype of RAM persistence across reset #1715
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
Draft
kenbell
wants to merge
10
commits into
tinygo-org:dev
Choose a base branch
from
kenbell:low-power-persistence
base: dev
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0d939d2
compiler: add tests for pragmas
aykevl 5d0ae41
compiler: add function and global section pragmas
aykevl 4d872d2
all: prototype of RAM persistence across reset
kenbell 53567b5
Smoketest persistence prototype
kenbell 2d96c27
change to using //go:section pragma
kenbell 723ed69
Update example
kenbell 3a19c02
Use chip-specific RAM for low-power persistence
kenbell ffef2f0
Fix typo
kenbell 9df8125
Update based on `section` pragma
kenbell 3e0e27c
stm32l031k6 added
kenbell 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,66 @@ | ||
package main | ||
|
||
import _ "unsafe" | ||
|
||
// Creates an external global with name extern_global. | ||
//go:extern extern_global | ||
var externGlobal [0]byte | ||
|
||
// Creates a | ||
//go:align 32 | ||
var alignedGlobal [4]uint32 | ||
|
||
// Test conflicting pragmas (the last one counts). | ||
//go:align 64 | ||
//go:align 16 | ||
var alignedGlobal16 [4]uint32 | ||
|
||
// Test exported functions. | ||
//export extern_func | ||
func externFunc() { | ||
} | ||
|
||
// Define a function in a different package using go:linkname. | ||
//go:linkname withLinkageName1 somepkg.someFunction1 | ||
func withLinkageName1() { | ||
} | ||
|
||
// Import a function from a different package using go:linkname. | ||
//go:linkname withLinkageName2 somepkg.someFunction2 | ||
func withLinkageName2() | ||
|
||
// Function has an 'inline hint', similar to the inline keyword in C. | ||
//go:inline | ||
func inlineFunc() { | ||
} | ||
|
||
// Function should never be inlined, equivalent to GCC | ||
// __attribute__((noinline)). | ||
//go:noinline | ||
func noinlineFunc() { | ||
} | ||
|
||
// This function should have the specified section. | ||
//go:section .special_function_section | ||
func functionInSection() { | ||
} | ||
|
||
//export exportedFunctionInSection | ||
//go:section .special_function_section | ||
func exportedFunctionInSection() { | ||
} | ||
|
||
// This function should not: it's only a declaration and not a definition. | ||
//go:section .special_function_section | ||
func undefinedFunctionNotInSection() | ||
|
||
//go:section .special_global_section | ||
var globalInSection uint32 | ||
|
||
//go:section .special_global_section | ||
//go:extern undefinedGlobalNotInSection | ||
var undefinedGlobalNotInSection uint32 | ||
|
||
//go:align 1024 | ||
//go:section .global_section | ||
var multipleGlobalPragmas uint32 |
This file contains hidden or 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,57 @@ | ||
; ModuleID = 'pragma.go' | ||
source_filename = "pragma.go" | ||
target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" | ||
target triple = "i686--linux" | ||
|
||
@extern_global = external global [0 x i8] | ||
@main.alignedGlobal = hidden global [4 x i32] zeroinitializer, align 32 | ||
@main.alignedGlobal16 = hidden global [4 x i32] zeroinitializer, align 16 | ||
@main.globalInSection = hidden global i32 0, section ".special_global_section" | ||
@undefinedGlobalNotInSection = external global i32 | ||
@main.multipleGlobalPragmas = hidden global i32 0, section ".global_section", align 1024 | ||
|
||
declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*) | ||
|
||
define hidden void @main.init(i8* %context, i8* %parentHandle) unnamed_addr { | ||
entry: | ||
ret void | ||
} | ||
|
||
define void @extern_func() { | ||
entry: | ||
ret void | ||
} | ||
|
||
define hidden void @somepkg.someFunction1(i8* %context, i8* %parentHandle) unnamed_addr { | ||
entry: | ||
ret void | ||
} | ||
|
||
declare void @somepkg.someFunction2(i8*, i8*) | ||
|
||
; Function Attrs: inlinehint | ||
define hidden void @main.inlineFunc(i8* %context, i8* %parentHandle) unnamed_addr #0 { | ||
entry: | ||
ret void | ||
} | ||
|
||
; Function Attrs: noinline | ||
define hidden void @main.noinlineFunc(i8* %context, i8* %parentHandle) unnamed_addr #1 { | ||
entry: | ||
ret void | ||
} | ||
|
||
define hidden void @main.functionInSection(i8* %context, i8* %parentHandle) unnamed_addr section ".special_function_section" { | ||
entry: | ||
ret void | ||
} | ||
|
||
define void @exportedFunctionInSection() section ".special_function_section" { | ||
entry: | ||
ret void | ||
} | ||
|
||
declare void @main.undefinedFunctionNotInSection(i8*, i8*) | ||
|
||
attributes #0 = { inlinehint } | ||
attributes #1 = { noinline } |
This file contains hidden or 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,19 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
//go:section .persist | ||
var buffer [32]byte | ||
|
||
func main() { | ||
println("\n*** ** * RESET * ** ***\n") | ||
|
||
for { | ||
time.Sleep(1 * time.Second) | ||
|
||
println("value: ", buffer[0]) | ||
buffer[0]++ | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
I've never understood the convention with these includes, are they both necessary? Wouldn't
*(.persist*)
, or, in this case, simply*(.persist)
be sufficient?Uh oh!
There was an error while loading. Please reload this page.
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.
It's simply a glob. So
.persist
matches exactly the string.persist
while.persist.*
matches anything that starts with.persist.
. This emulates somewhat the similar conventions around-ffunction-sections
and-fdata-sections
but may not be necessary in this case.