Skip to content

Commit 2b39072

Browse files
committed
Apps: Debug, E9 Build fix after 8ab7d32
1 parent af5d07d commit 2b39072

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

include/cm/debug.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@
3434
* @return Nothing
3535
**************************************************************************************************/
3636
#define bochs_breakpoint() __asm__ volatile("xchg bx, bx")
37-
#endif // DEBUG
3837

38+
#if ARCH == x86
39+
#define x86_outb(p, v) __asm__ volatile("out dx, al;" : : "a"(v), "d"(p))
40+
#define x86_inb(p, v) __asm__ volatile("in al, dx" : "=a"(v) : "d"(p))
41+
#endif
42+
#endif // DEBUG

src/cm/debug.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
#include <types.h>
1212
#include <cm/cm.h>
1313
#include <cm/syscall.h>
14+
#include <cm/debug.h>
1415

1516
#if defined(DEBUG) && defined(PORT_E9_ENABLED)
1617

1718
#define MAX_PRINTABLE_STRING_LENGTH 100
19+
#define ARRAY_LENGTH(ar) (sizeof ((ar)) / sizeof ((ar)[0]))
1820

1921
#define ANSI_COL_GRAY "\x1b[90m"
2022
#define ANSI_COL_YELLOW "\x1b[93m"
@@ -25,8 +27,13 @@
2527
static void qemu_putString (const CHAR* string)
2628
{
2729
CHAR c;
28-
while ((c = *string++))
29-
outb (0xE9, c);
30+
while ((c = *string++)) {
31+
#if ARCH == x86
32+
x86_outb (0xE9, c);
33+
#else
34+
#error "Not implemented"
35+
#endif
36+
}
3037
}
3138

3239
/***************************************************************************************************
@@ -61,7 +68,7 @@ void debug_log_ndu (DebugLogType type, const char* func, UINT line, char* fmt, .
6168
} break;
6269
}
6370

64-
UINT tick_count = os_get_tickcount();
71+
UINT tick_count = cm_get_tickcount();
6572
len = snprintf (buffer, ARRAY_LENGTH (buffer), message, logColor, tick_count, ANSI_COL_GRAY,
6673
func, line, ANSI_COL_RESET);
6774

0 commit comments

Comments
 (0)