- Implemented InterlockedBitTestAndReset, InterlockedBitTestAndSet, InterlockedExchan...
[reactos.git] / reactos / ntoskrnl / kd / wrappers / bochs.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/kd/wrappers/bochs.c
5 * PURPOSE: BOCHS Wrapper for Kd
6 *
7 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
8 */
9
10 #include <ntoskrnl.h>
11 #define NDEBUG
12 #include <internal/debug.h>
13
14 /* bochs debug output */
15 #define BOCHS_LOGGER_PORT (0xe9)
16
17 /* FUNCTIONS *****************************************************************/
18
19 VOID
20 STDCALL
21 KdpBochsDebugPrint(IN PCH Message,
22 IN ULONG Length)
23 {
24 while (*Message != 0)
25 {
26 if (*Message == '\n')
27 {
28 #if defined(_M_IX86) && defined(__GNUC__)
29 /* Don't use WRITE_PORT_UCHAR because hal isn't initialized yet in the very early boot phase. */
30 __asm__("outb %b0, %w1\n\t" :: "a" ('\r'), "d" (BOCHS_LOGGER_PORT));
31 #else
32 WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, '\r');
33 #endif
34 }
35 #if defined(_M_IX86) && defined(__GNUC__)
36 /* Don't use WRITE_PORT_UCHAR because hal isn't initialized yet in the very early boot phase. */
37 __asm__("outb %b0, %w1\n\t" :: "a" (*Message), "d" (BOCHS_LOGGER_PORT));
38 #else
39 WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, *Message);
40 #endif
41 Message++;
42 }
43 }
44
45 VOID
46 STDCALL
47 KdpBochsInit(PKD_DISPATCH_TABLE WrapperTable,
48 ULONG BootPhase)
49 {
50 if (!KdpDebugMode.Bochs) return;
51
52 if (BootPhase == 0)
53 {
54 /* Write out the functions that we support for now */
55 WrapperTable->KdpInitRoutine = KdpBochsInit;
56 WrapperTable->KdpPrintRoutine = KdpBochsDebugPrint;
57 }
58 else if (BootPhase == 2)
59 {
60 HalDisplayString("\n Bochs debugging enabled\n\n");
61 }
62 }
63
64 /* EOF */