From e5fb1b41eb218058618966a299d433517b364a2a Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Fri, 11 Oct 2024 19:03:27 -0400 Subject: [PATCH] added bochs debug wrappers --- include/util/bochs_magic.inc | 65 ++++++++++++++++++++++++++++++++++++ src/mbr/mbr.nasm | 1 + src/vbr/vbr.nasm | 1 + 3 files changed, 67 insertions(+) create mode 100644 include/util/bochs_magic.inc diff --git a/include/util/bochs_magic.inc b/include/util/bochs_magic.inc new file mode 100644 index 0000000..55b23fd --- /dev/null +++ b/include/util/bochs_magic.inc @@ -0,0 +1,65 @@ +; Copyright (c) 2024 Elaina Claus +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software and associated documentation files (the "Software"), to deal +; in the Software without restriction, including without limitation the rights +; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +; copies of the Software, and to permit persons to whom the Software is +; furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included in all +; copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +; SOFTWARE. + +%ifndef __INC_BOCHS_DEBUG_MAGIC + +; +; port_e9_hack: enabled=1 needs to be set in bochsrc.txt/bxrc +; +%ifnmacro __BOCHS_PRINTC + %macro __BOCHS_PRINTC 1 + mov al, %1 + out 0xe9, byte al + %endmacro +%endif + +; +; port_e9_hack: enabled=1 needs to be set in bochsrc.txt/bxrc +; +%ifnmacro __BOCHS_BREAK + %macro __BOCHS_BREAK 0 + push ax + mov ax, 0x8A00 + out 0x8A00, word ax + pop ax + %endmacro +%endif + +; +; magic_break: enabled=1 needs to be set in bochsrc.txt/bxrc +; +%ifnmacro __BOCHS_MAGIC_DEBUG + %macro __BOCHS_MAGIC_DEBUG 0 + xchg bx, bx + %endmacro +%endif + +%ifnmacro PRINT_FUNC_LABEL + %macro PRINT_FUNC_LABEL 1 + %define label %1 + %assign addr label + %ifnctx __OUTPUT__ + __OUTPUT__ "Entry point for '%1' = %d", addr + %endif + %endmacro +%endif + +%define __INC_BOCHS_DEBUG_MAGIC +%endif \ No newline at end of file diff --git a/src/mbr/mbr.nasm b/src/mbr/mbr.nasm index d02d405..4afe7a5 100755 --- a/src/mbr/mbr.nasm +++ b/src/mbr/mbr.nasm @@ -35,6 +35,7 @@ nop ; ; ############### +%include "util/bochs_magic.inc" %include "cdecl16.inc" %include "entry.inc" %include "config.inc" diff --git a/src/vbr/vbr.nasm b/src/vbr/vbr.nasm index 95101a3..377ba3c 100755 --- a/src/vbr/vbr.nasm +++ b/src/vbr/vbr.nasm @@ -42,6 +42,7 @@ times 54 db 0x00 ; ; ############### +%include "util/bochs_magic.inc" %include "cdecl16.inc" %include "entry.inc" %include "config.inc"