Skip to content

Commit 2731e24

Browse files
author
Matt Liegey
committed
Commenting out some broken code with higher registers.
1 parent 2e25153 commit 2731e24

File tree

2 files changed

+67
-64
lines changed

2 files changed

+67
-64
lines changed

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![no_std]
2-
#![feature(asm, global_asm, isa_attribute)]
2+
#![feature(isa_attribute)]
33

44
//! This crate helps you write GBA ROMs.
55
//!
@@ -31,11 +31,11 @@ pub mod prelude {
3131
#[cfg(target_arch = "arm")]
3232
pub use crate::mmio_addresses::*;
3333
#[cfg(target_arch = "arm")]
34+
pub use crate::random::*;
35+
#[cfg(target_arch = "arm")]
3436
pub use crate::save::*;
3537
#[cfg(target_arch = "arm")]
3638
pub use crate::sync::*;
37-
#[cfg(target_arch = "arm")]
38-
pub use crate::random::*;
3939
}
4040

4141
pub mod mmio_types;

src/sync/statics.rs

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ unsafe fn transfer<T: Copy>(dst: *mut T, src: *const T) {
2121
// We can do an 4-byte aligned transfer up to 16 bytes.
2222
transfer_align4_thumb(dst, src);
2323
} else if size <= 36 && align % 4 == 0 {
24-
// We can do the same up to 36 bytes, but we need to switch to ARM.
25-
transfer_align4_arm(dst, src);
24+
// // We can do the same up to 36 bytes, but we need to switch to ARM.
25+
// transfer_align4_arm(dst, src);
26+
// TODO(rust-console/gba#158) Cannot optimize larger transfers for now.
27+
with_irqs_disabled(|| ptr::write_volatile(dst, ptr::read_volatile(src)));
2628
} else if size <= 2 && align % 2 == 0 {
2729
// We can do a 2-byte aligned transfer up to 2 bytes.
2830
asm!(
@@ -83,65 +85,66 @@ unsafe fn transfer_align4_thumb<T: Copy>(mut dst: *mut T, mut src: *const T) {
8385
}
8486
}
8587

86-
#[cfg(target_arch = "arm")]
87-
#[instruction_set(arm::a32)]
88-
#[allow(unused_assignments)]
89-
unsafe fn transfer_align4_arm<T: Copy>(mut dst: *mut T, mut src: *const T) {
90-
let size = size_of::<T>();
91-
if size <= 16 {
92-
unimplemented!("This should be done via transfer_thumb.");
93-
} else if size <= 20 {
94-
// Starting at size == 20, we have to switch to ARM due to lack of
95-
// accessible registers in THUMB mode.
96-
asm!(
97-
"ldmia {0}!, {{r2-r5,r8}}",
98-
"stmia {1}!, {{r2-r5,r8}}",
99-
inout(reg) src, inout(reg) dst,
100-
out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
101-
)
102-
} else if size <= 24 {
103-
asm!(
104-
"push {{r9}}",
105-
"ldmia {0}!, {{r2-r5,r8-r9}}",
106-
"stmia {1}!, {{r2-r5,r8-r9}}",
107-
"pop {{r9}}",
108-
inout(reg) src, inout(reg) dst,
109-
out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
110-
)
111-
} else if size <= 28 {
112-
asm!(
113-
"push {{r9}}",
114-
"ldmia {0}!, {{r2-r5,r8-r10}}",
115-
"stmia {1}!, {{r2-r5,r8-r10}}",
116-
"pop {{r9}}",
117-
inout(reg) src, inout(reg) dst,
118-
out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
119-
out("r10") _,
120-
)
121-
} else if size <= 32 {
122-
asm!(
123-
"push {{r9}}",
124-
"ldmia {0}!, {{r2-r5,r8-r10,r12}}",
125-
"stmia {1}!, {{r2-r5,r8-r10,r12}}",
126-
"pop {{r9}}",
127-
inout(reg) src, inout(reg) dst,
128-
out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
129-
out("r10") _, out("r12") _,
130-
)
131-
} else if size <= 36 {
132-
asm!(
133-
"push {{r9}}",
134-
"ldmia {0}!, {{r2-r5,r8-r10,r12,r14}}",
135-
"stmia {1}!, {{r2-r5,r8-r10,r12,r14}}",
136-
"pop {{r9}}",
137-
inout(reg) src, inout(reg) dst,
138-
out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
139-
out("r10") _, out("r12") _, out("r14") _,
140-
)
141-
} else {
142-
unimplemented!("Copy too large for use of ldmia/stmia.");
143-
}
144-
}
88+
// TODO(rust-console/gba#158) Un-comment out this fn when we can use higher registers.
89+
// #[cfg(target_arch = "arm")]
90+
// #[instruction_set(arm::a32)]
91+
// #[allow(unused_assignments)]
92+
// unsafe fn transfer_align4_arm<T: Copy>(mut dst: *mut T, mut src: *const T) {
93+
// let size = size_of::<T>();
94+
// if size <= 16 {
95+
// unimplemented!("This should be done via transfer_thumb.");
96+
// } else if size <= 20 {
97+
// // Starting at size == 20, we have to switch to ARM due to lack of
98+
// // accessible registers in THUMB mode.
99+
// asm!(
100+
// "ldmia {0}!, {{r2-r5,r8}}",
101+
// "stmia {1}!, {{r2-r5,r8}}",
102+
// inout(reg) src, inout(reg) dst,
103+
// out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
104+
// )
105+
// } else if size <= 24 {
106+
// asm!(
107+
// "push {{r9}}",
108+
// "ldmia {0}!, {{r2-r5,r8-r9}}",
109+
// "stmia {1}!, {{r2-r5,r8-r9}}",
110+
// "pop {{r9}}",
111+
// inout(reg) src, inout(reg) dst,
112+
// out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
113+
// )
114+
// } else if size <= 28 {
115+
// asm!(
116+
// "push {{r9}}",
117+
// "ldmia {0}!, {{r2-r5,r8-r10}}",
118+
// "stmia {1}!, {{r2-r5,r8-r10}}",
119+
// "pop {{r9}}",
120+
// inout(reg) src, inout(reg) dst,
121+
// out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
122+
// out("r10") _,
123+
// )
124+
// } else if size <= 32 {
125+
// asm!(
126+
// "push {{r9}}",
127+
// "ldmia {0}!, {{r2-r5,r8-r10,r12}}",
128+
// "stmia {1}!, {{r2-r5,r8-r10,r12}}",
129+
// "pop {{r9}}",
130+
// inout(reg) src, inout(reg) dst,
131+
// out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
132+
// out("r10") _, out("r12") _,
133+
// )
134+
// } else if size <= 36 {
135+
// asm!(
136+
// "push {{r9}}",
137+
// "ldmia {0}!, {{r2-r5,r8-r10,r12,r14}}",
138+
// "stmia {1}!, {{r2-r5,r8-r10,r12,r14}}",
139+
// "pop {{r9}}",
140+
// inout(reg) src, inout(reg) dst,
141+
// out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _,
142+
// out("r10") _, out("r12") _, out("r14") _,
143+
// )
144+
// } else {
145+
// unimplemented!("Copy too large for use of ldmia/stmia.");
146+
// }
147+
// }
145148

146149
/// The internal function for swapping the current value of a [`Static`] with
147150
/// another value.

0 commit comments

Comments
 (0)