xref: /haiku/src/add-ons/kernel/debugger/bochs/bochs.cpp (revision ed6250c95736c0b55da79d6e9dd01369532260c0)
1 /*
2  * Copyright 2008, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		François Revol, revol@free.fr
7  */
8 
9 
10 #include <debug.h>
11 #include <driver_settings.h>
12 #include <ISA.h>
13 
14 static isa_module_info *sISAModule;
15 
16 
17 static int
18 debugger_puts(const char *s, int32 length)
19 {
20 	int i;
21 	for (i = 0; i < length; i++)
22 		sISAModule->write_io_8(0xe9, s[i]);
23 	return i;
24 }
25 
26 
27 static status_t
28 std_ops(int32 op, ...)
29 {
30 	void *handle;
31 	bool load = true;//false;
32 
33 	switch (op) {
34 	case B_MODULE_INIT:
35 		handle = load_driver_settings("kernel");
36 		if (handle) {
37 			load = get_driver_boolean_parameter(handle,
38 				"bochs_debug_output", load, true);
39 			unload_driver_settings(handle);
40 		}
41 		if (load) {
42 			if (get_module(B_ISA_MODULE_NAME, (module_info **)&sISAModule) < B_OK)
43 				return B_ERROR;
44 		}
45 		return load ? B_OK : B_ERROR;
46 	case B_MODULE_UNINIT:
47 		put_module(B_ISA_MODULE_NAME);
48 		return B_OK;
49 	}
50 	return B_BAD_VALUE;
51 }
52 
53 
54 static struct debugger_module_info sModuleInfo = {
55 	{
56 		"debugger/bochs/v1",
57 		0,
58 		&std_ops
59 	},
60 	NULL,
61 	NULL,
62 	debugger_puts,
63 	NULL
64 };
65 
66 module_info *modules[] = {
67 	(module_info *)&sModuleInfo,
68 	NULL
69 };
70 
71