Skip to content

Commit 24b9a45

Browse files
committed
Add non "inline_asm" impl for bochs_breakpoint
Signed-off-by: Joe Richey <[email protected]>
1 parent fe15d60 commit 24b9a45

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/asm/asm.s

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
.text
22
.code64
33

4+
# REMEMBER: This code uses the AMD64 calling convention:
5+
# Arguments: RDI, RSI, RDX, RCX
6+
# Return: RAX
7+
48
.global _x86_64_asm_interrupt_enable
59
.p2align 4
610
_x86_64_asm_interrupt_enable:
@@ -249,6 +253,12 @@ _x86_64_asm_nop:
249253
nop
250254
retq
251255

256+
.global _x86_64_asm_bochs
257+
.p2align 4
258+
_x86_64_asm_bochs:
259+
xchgw %bx, %bx
260+
retq
261+
252262
.global _x86_64_asm_rdfsbase
253263
.p2align 4
254264
_x86_64_asm_rdfsbase:

src/asm/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ extern "C" {
3636
)]
3737
pub(crate) fn x86_64_asm_nop();
3838

39+
#[cfg_attr(
40+
any(target_env = "gnu", target_env = "musl"),
41+
link_name = "_x86_64_asm_bochs"
42+
)]
43+
pub(crate) fn x86_64_asm_bochs();
44+
3945
#[cfg_attr(
4046
any(target_env = "gnu", target_env = "musl"),
4147
link_name = "_x86_64_asm_read_from_port_u8"

src/instructions/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ pub fn nop() {
4040

4141
/// Emits a '[magic breakpoint](https://wiki.osdev.org/Bochs#Magic_Breakpoint)' instruction for the [Bochs](http://bochs.sourceforge.net/) CPU
4242
/// emulator. Make sure to set `magic_break: enabled=1` in your `.bochsrc` file.
43-
#[cfg(feature = "inline_asm")]
4443
#[inline]
4544
pub fn bochs_breakpoint() {
4645
unsafe {
46+
#[cfg(feature = "inline_asm")]
4747
asm!("xchg bx, bx", options(nomem, nostack, preserves_flags));
48+
49+
#[cfg(not(feature = "inline_asm"))]
50+
crate::asm::x86_64_asm_bochs();
4851
}
4952
}
5053

0 commit comments

Comments
 (0)