-
Notifications
You must be signed in to change notification settings - Fork 167
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
Sample of how to generate the function #1531
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "lpc55-hashcrypt" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
cfg-if = { workspace = true } | ||
proc-macro2 = { workspace = true } | ||
quote = { workspace = true } | ||
zerocopy = { workspace = true } | ||
syn = { workspace = true } | ||
|
||
[build-dependencies] | ||
build-util = { path = "../../build/util" } | ||
|
||
[lib] | ||
proc-macro = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
/// proc macro to generate iocon function for LPC55 | ||
extern crate proc_macro; | ||
use proc_macro::TokenStream; | ||
extern crate proc_macro2; | ||
use quote::quote; | ||
|
||
#[proc_macro] | ||
pub fn dynamic_hashcrypt(_item: TokenStream) -> TokenStream { | ||
let code = quote! { | ||
static mut USE_ROM: core::sync::atomic::AtomicBool = core::sync::atomic::AtomicBool::new(false); | ||
|
||
pub fn set_hashcrypt_default() { | ||
unsafe { | ||
USE_ROM.store(false, core::sync::atomic::Ordering::Relaxed); | ||
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. nit: improve readability w/ |
||
} | ||
} | ||
|
||
pub fn set_hashcrypt_rom() { | ||
unsafe { | ||
USE_ROM.store(true, core::sync::atomic::Ordering::Relaxed); | ||
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. same as above |
||
} | ||
} | ||
|
||
#[allow(non_snake_case)] | ||
#[no_mangle] | ||
pub unsafe extern "C" fn HASHCRYPT() { | ||
if USE_ROM.load(core::sync::atomic::Ordering::Relaxed) { | ||
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. same as above |
||
lpc55_romapi::skboot_hashcrypt_handler(); | ||
} else { | ||
kern::arch::DefaultHandler(); | ||
} | ||
|
||
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. nit: whitespace |
||
} | ||
|
||
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. nit: whitespace |
||
}; | ||
|
||
code.into() | ||
} |
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.
nit: improve readability w/
use core::sync::atomic::AtomicBool;