bvm_dbg.c revision 221905
1221905Sgrehan/*-
2221905Sgrehan * Copyright (c) 2011 NetApp, Inc.
3221905Sgrehan * All rights reserved.
4221905Sgrehan *
5221905Sgrehan * Redistribution and use in source and binary forms, with or without
6221905Sgrehan * modification, are permitted provided that the following conditions
7221905Sgrehan * are met:
8221905Sgrehan * 1. Redistributions of source code must retain the above copyright
9221905Sgrehan *    notice, this list of conditions and the following disclaimer.
10221905Sgrehan * 2. Redistributions in binary form must reproduce the above copyright
11221905Sgrehan *    notice, this list of conditions and the following disclaimer in the
12221905Sgrehan *    documentation and/or other materials provided with the distribution.
13221905Sgrehan *
14221905Sgrehan * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
15221905Sgrehan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16221905Sgrehan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17221905Sgrehan * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
18221905Sgrehan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19221905Sgrehan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20221905Sgrehan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21221905Sgrehan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22221905Sgrehan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23221905Sgrehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24221905Sgrehan * SUCH DAMAGE.
25221905Sgrehan *
26221905Sgrehan * $FreeBSD$
27221905Sgrehan */
28221905Sgrehan
29221905Sgrehan#include <sys/cdefs.h>
30221905Sgrehan__FBSDID("$FreeBSD$");
31221905Sgrehan
32221905Sgrehan#include <sys/param.h>
33221905Sgrehan#include <sys/kernel.h>
34221905Sgrehan#include <sys/bus.h>
35221905Sgrehan
36221905Sgrehan#include <gdb/gdb.h>
37221905Sgrehan
38221905Sgrehan#include <machine/cpufunc.h>
39221905Sgrehan
40221905Sgrehanstatic gdb_probe_f bvm_dbg_probe;
41221905Sgrehanstatic gdb_init_f bvm_dbg_init;
42221905Sgrehanstatic gdb_term_f bvm_dbg_term;
43221905Sgrehanstatic gdb_getc_f bvm_dbg_getc;
44221905Sgrehanstatic gdb_putc_f bvm_dbg_putc;
45221905Sgrehan
46221905SgrehanGDB_DBGPORT(bvm, bvm_dbg_probe, bvm_dbg_init, bvm_dbg_term,
47221905Sgrehan    bvm_dbg_getc, bvm_dbg_putc);
48221905Sgrehan
49221905Sgrehan#define	BVM_DBG_PORT	0x224
50221905Sgrehanstatic int bvm_dbg_port = BVM_DBG_PORT;
51221905Sgrehan
52221905Sgrehanstatic int
53221905Sgrehanbvm_dbg_probe(void)
54221905Sgrehan{
55221905Sgrehan	int disabled, port;
56221905Sgrehan
57221905Sgrehan	disabled = 0;
58221905Sgrehan	resource_int_value("bvmdbg", 0, "disabled", &disabled);
59221905Sgrehan	if (disabled)
60221905Sgrehan		return (-1);
61221905Sgrehan
62221905Sgrehan	if (resource_int_value("bvmdbg", 0, "port", &port) == 0)
63221905Sgrehan		bvm_dbg_port = port;
64221905Sgrehan
65221905Sgrehan	return (0);
66221905Sgrehan}
67221905Sgrehan
68221905Sgrehanstatic void
69221905Sgrehanbvm_dbg_init(void)
70221905Sgrehan{
71221905Sgrehan}
72221905Sgrehan
73221905Sgrehanstatic void
74221905Sgrehanbvm_dbg_term(void)
75221905Sgrehan{
76221905Sgrehan}
77221905Sgrehan
78221905Sgrehanstatic void
79221905Sgrehanbvm_dbg_putc(int c)
80221905Sgrehan{
81221905Sgrehan
82221905Sgrehan	outl(bvm_dbg_port, c);
83221905Sgrehan}
84221905Sgrehan
85221905Sgrehanstatic int
86221905Sgrehanbvm_dbg_getc(void)
87221905Sgrehan{
88221905Sgrehan
89221905Sgrehan	return (inl(bvm_dbg_port));
90221905Sgrehan}
91