rust-embedded / cortex-m-semihosting

Semihosting for ARM Cortex-M processors
Apache License 2.0
40 stars 19 forks source link

Add mechanism to properly open host stdio streams #7

Closed alexisvl closed 7 years ago

alexisvl commented 7 years ago

This uses the OPEN semihosting syscall to open stdout/stderr properly instead of assuming their FDs and that they work. pub fn open_streams() is added to do this, and documented. static mut is used for the stream FDs because Cortex-M0 Rust doesn't have atomic types; #[inline(never)] accessors are used to force these to be accessed because stable Rust doesn't have volatile types.

This should be merged after PR #6; it contains the same commit as both touch the same area of the code.

alexisvl commented 7 years ago

Crap, it has come to my attention that stable Rust does have volatile accessors. Fix incoming.

alexisvl commented 7 years ago

Fixed.

pftbest commented 7 years ago

":tt" should have zero byte at the end, because some debuggers don't check the size and read the file name as c string instead.

alexisvl commented 7 years ago

Good point.