Skip to content

Commit 8ab7d32

Browse files
committed
CM: Move debug related items from cm.h to debug.h
1 parent de534a1 commit 8ab7d32

File tree

4 files changed

+46
-46
lines changed

4 files changed

+46
-46
lines changed

include/cm/cm.h

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,13 @@
1111
#include <types.h>
1212
#include <stdarg.h>
1313

14-
#define INVALID_HANDLE -1
15-
#define MAX_PRINTABLE_STRING_LENGTH 100
16-
17-
/** Length of an array in bytes */
18-
#define ARRAY_LENGTH(ar) (sizeof ((ar)) / sizeof ((ar)[0]))
1914

2015
#define HALT() for (;;)
2116

22-
#if ARCH == x86
23-
#define outb(p, v) __asm__ volatile("out dx, al;" : : "a"(v), "d"(p))
24-
#define inb(p, v) __asm__ volatile("in al, dx" : "=a"(v) : "d"(p))
25-
#endif
2617

2718
INT snprintf (CHAR* dest, size_t size, const CHAR* fmt, ...);
2819
INT vsnprintf (CHAR* dest, size_t size, const CHAR* fmt, va_list l);
2920

30-
/********************************************************************
31-
* Debug specific. Only available for Debug builds of Mos-libc
32-
*******************************************************************/
33-
#if defined(DEBUG) && defined(PORT_E9_ENABLED)
34-
typedef enum DebugLogType {
35-
DEBUG_LOG_TYPE_INFO,
36-
DEBUG_LOG_TYPE_FUNC,
37-
DEBUG_LOG_TYPE_ERROR,
38-
DEBUG_LOG_TYPE_WARN,
39-
} DebugLogType;
40-
41-
void debug_log_ndu (DebugLogType type, const char* func, UINT line, char* fmt, ...);
42-
43-
#define INFO(...) debug_log_ndu (DEBUG_LOG_TYPE_INFO, __func__, __LINE__, __VA_ARGS__)
44-
#define ERROR(...) debug_log_ndu (DEBUG_LOG_TYPE_ERROR, __func__, __LINE__, __VA_ARGS__)
45-
#define FUNC_ENTRY(...) debug_log_ndu (DEBUG_LOG_TYPE_FUNC, __func__, __LINE__, "" __VA_ARGS__)
46-
#define WARN(...) debug_log_ndu (DEBUG_LOG_TYPE_WARN, __func__, __LINE__, __VA_ARGS__)
47-
#else
48-
#define INFO(...) (void)0
49-
#define ERROR(...) (void)0
50-
#define FUNC_ENTRY(...) (void)0
51-
#define WARN(...) (void)0
52-
#endif // PORT_E9_ENABLED
53-
54-
#if defined(DEBUG)
55-
/***************************************************************************************************
56-
* Magic break point used by bochs emulator
57-
*
58-
* @return Nothing
59-
**************************************************************************************************/
60-
#define bochs_breakpoint() __asm__ volatile("xchg bx, bx")
61-
#endif // DEBUG
6221

6322
/***************************************************************************************************
6423
* Halts thread for 'ms' miliseconds

include/cm/debug.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* -------------------------------------------------------------------------------------------------
3+
* Megha Operating System V2 - Mos libc - Library debug
4+
* -------------------------------------------------------------------------------------------------
5+
*/
6+
7+
#pragma once
8+
9+
#if defined(DEBUG) && defined(PORT_E9_ENABLED)
10+
typedef enum DebugLogType {
11+
DEBUG_LOG_TYPE_INFO,
12+
DEBUG_LOG_TYPE_FUNC,
13+
DEBUG_LOG_TYPE_ERROR,
14+
DEBUG_LOG_TYPE_WARN,
15+
} DebugLogType;
16+
17+
void debug_log_ndu (DebugLogType type, const char* func, UINT line, char* fmt, ...);
18+
19+
#define INFO(...) debug_log_ndu (DEBUG_LOG_TYPE_INFO, __func__, __LINE__, __VA_ARGS__)
20+
#define ERROR(...) debug_log_ndu (DEBUG_LOG_TYPE_ERROR, __func__, __LINE__, __VA_ARGS__)
21+
#define FUNC_ENTRY(...) debug_log_ndu (DEBUG_LOG_TYPE_FUNC, __func__, __LINE__, "" __VA_ARGS__)
22+
#define WARN(...) debug_log_ndu (DEBUG_LOG_TYPE_WARN, __func__, __LINE__, __VA_ARGS__)
23+
#else
24+
#define INFO(...) (void)0
25+
#define ERROR(...) (void)0
26+
#define FUNC_ENTRY(...) (void)0
27+
#define WARN(...) (void)0
28+
#endif // PORT_E9_ENABLED
29+
30+
#if defined(DEBUG)
31+
/***************************************************************************************************
32+
* Magic break point used by bochs emulator
33+
*
34+
* @return Nothing
35+
**************************************************************************************************/
36+
#define bochs_breakpoint() __asm__ volatile("xchg bx, bx")
37+
#endif // DEBUG
38+

src/cm/debug.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
#if defined(DEBUG) && defined(PORT_E9_ENABLED)
1616

17-
#define ANSI_COL_GRAY "\x1b[90m"
18-
#define ANSI_COL_YELLOW "\x1b[93m"
19-
#define ANSI_COL_RED "\x1b[31m"
20-
#define ANSI_COL_GREEN "\x1b[32m"
21-
#define ANSI_COL_RESET "\x1b[0m"
17+
#define MAX_PRINTABLE_STRING_LENGTH 100
18+
19+
#define ANSI_COL_GRAY "\x1b[90m"
20+
#define ANSI_COL_YELLOW "\x1b[93m"
21+
#define ANSI_COL_RED "\x1b[31m"
22+
#define ANSI_COL_GREEN "\x1b[32m"
23+
#define ANSI_COL_RESET "\x1b[0m"
2224

2325
static void qemu_putString (const CHAR* string)
2426
{

src/cm/graphics.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <types.h>
99
#include <cm/graphics.h>
1010
#include <cm/cm.h>
11+
#include <cm/debug.h>
1112

1213
typedef U8 IndexColor8Bit;
1314

0 commit comments

Comments
 (0)