Skip to content

Commit 964ee6e

Browse files
committed
Code review updates
1 parent 3d2319b commit 964ee6e

File tree

3 files changed

+46
-46
lines changed

3 files changed

+46
-46
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ There are currently three libraries here:
2020
* [cortex-a-rt](./cortex-a-rt/) - run-time library for Cortex-A CPUs (like [cortex-m-rt])
2121
* [arm-targets](./arm-targets/) - a helper library for your build.rs that sets various `--cfg` flags according to the current target
2222

23-
There are also example programs for QEMU in the [examples](./-examples/) folder.
23+
There are also example programs for QEMU in the [examples](./examples/) folder.
2424

2525
[cortex-m]: https://crates.io/crates/cortex-m
2626
[cortex-m-rt]: https://crates.io/crates/cortex-m-rt

cortex-a-rt/src/lib.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,24 @@ macro_rules! save_context {
167167
};
168168
}
169169

170+
/// This macro expands to code for restoring context on exit from an exception
171+
/// handler.
172+
///
173+
/// It should match `save_context!`.
174+
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
175+
macro_rules! restore_context {
176+
() => {
177+
r#"
178+
// restore alignment amount, and preserved register
179+
pop {{r0, r12}}
180+
// restore pre-alignment SP
181+
add sp, r0
182+
// restore more preserved registers
183+
pop {{r0-r3}}
184+
"#
185+
};
186+
}
187+
170188
/// This macro expands to code for saving context on entry to an exception
171189
/// handler.
172190
///
@@ -199,14 +217,22 @@ macro_rules! save_context {
199217
/// handler.
200218
///
201219
/// It should match `save_context!`.
202-
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
220+
#[cfg(all(
221+
any(target_abi = "eabihf", feature = "eabi-fpu"),
222+
not(feature = "vfp-dp")
223+
))]
203224
macro_rules! restore_context {
204225
() => {
205226
r#"
206227
// restore alignment amount, and preserved register
207228
pop {{r0, r12}}
208229
// restore pre-alignment SP
209230
add sp, r0
231+
// pop FPU state
232+
pop {{r0-r1}}
233+
vmsr FPEXC, r1
234+
vmsr FPSCR, r0
235+
vpop {{d0-d7}}
210236
// restore more preserved registers
211237
pop {{r0-r3}}
212238
"#
@@ -239,32 +265,6 @@ macro_rules! save_context {
239265
};
240266
}
241267

242-
/// This macro expands to code for restoring context on exit from an exception
243-
/// handler.
244-
///
245-
/// It should match `save_context!`.
246-
#[cfg(all(
247-
any(target_abi = "eabihf", feature = "eabi-fpu"),
248-
not(feature = "vfp-dp")
249-
))]
250-
macro_rules! restore_context {
251-
() => {
252-
r#"
253-
// restore alignment amount, and preserved register
254-
pop {{r0, r12}}
255-
// restore pre-alignment SP
256-
add sp, r0
257-
// pop FPU state
258-
pop {{r0-r1}}
259-
vmsr FPEXC, r1
260-
vmsr FPSCR, r0
261-
vpop {{d0-d7}}
262-
// restore more preserved registers
263-
pop {{r0-r3}}
264-
"#
265-
};
266-
}
267-
268268
/// This macro expands to code for restoring context on exit from an exception
269269
/// handler.
270270
///

cortex-r-rt/src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ macro_rules! save_context {
157157
};
158158
}
159159

160+
/// This macro expands to code for restoring context on exit from an exception
161+
/// handler.
162+
///
163+
/// It should match `save_context!`.
164+
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
165+
macro_rules! restore_context {
166+
() => {
167+
r#"
168+
// restore alignment amount, and preserved register
169+
pop {{r0, r12}}
170+
// restore pre-alignment SP
171+
add sp, r0
172+
// restore more preserved registers
173+
pop {{r0-r3}}
174+
"#
175+
};
176+
}
177+
160178
/// This macro expands to code for saving context on entry to an exception
161179
/// handler.
162180
///
@@ -182,24 +200,6 @@ macro_rules! save_context {
182200
};
183201
}
184202

185-
/// This macro expands to code for restoring context on exit from an exception
186-
/// handler.
187-
///
188-
/// It should match `save_context!`.
189-
#[cfg(not(any(target_abi = "eabihf", feature = "eabi-fpu")))]
190-
macro_rules! restore_context {
191-
() => {
192-
r#"
193-
// restore alignment amount, and preserved register
194-
pop {{r0, r12}}
195-
// restore pre-alignment SP
196-
add sp, r0
197-
// restore more preserved registers
198-
pop {{r0-r3}}
199-
"#
200-
};
201-
}
202-
203203
/// This macro expands to code for restoring context on exit from an exception
204204
/// handler.
205205
///

0 commit comments

Comments
 (0)