1139749Simp/*- 2131901Smarcel * Copyright (c) 2004 Marcel Moolenaar 3131901Smarcel * All rights reserved. 4131901Smarcel * 5131901Smarcel * Redistribution and use in source and binary forms, with or without 6131901Smarcel * modification, are permitted provided that the following conditions 7131901Smarcel * are met: 8131901Smarcel * 9131901Smarcel * 1. Redistributions of source code must retain the above copyright 10131901Smarcel * notice, this list of conditions and the following disclaimer. 11131901Smarcel * 2. Redistributions in binary form must reproduce the above copyright 12131901Smarcel * notice, this list of conditions and the following disclaimer in the 13131901Smarcel * documentation and/or other materials provided with the distribution. 14131901Smarcel * 15131901Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16131901Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17131901Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18131901Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19131901Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20131901Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21131901Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22131901Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23131901Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24131901Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25131901Smarcel */ 26131901Smarcel 27131901Smarcel#include <sys/cdefs.h> 28131901Smarcel__FBSDID("$FreeBSD$"); 29131901Smarcel 30131901Smarcel#include <sys/param.h> 31131901Smarcel#include <sys/systm.h> 32131901Smarcel#include <sys/bus.h> 33131901Smarcel#include <sys/kernel.h> 34131901Smarcel#include <machine/bus.h> 35131901Smarcel 36131901Smarcel#include <gdb/gdb.h> 37131901Smarcel 38131901Smarcel#include <dev/uart/uart.h> 39131901Smarcel#include <dev/uart/uart_cpu.h> 40131901Smarcel 41131901Smarcelstatic gdb_probe_f uart_dbg_probe; 42131901Smarcelstatic gdb_init_f uart_dbg_init; 43131901Smarcelstatic gdb_term_f uart_dbg_term; 44131901Smarcelstatic gdb_getc_f uart_dbg_getc; 45131901Smarcelstatic gdb_putc_f uart_dbg_putc; 46131901Smarcel 47131901SmarcelGDB_DBGPORT(uart, uart_dbg_probe, uart_dbg_init, uart_dbg_term, 48158950Sphk uart_dbg_getc, uart_dbg_putc); 49131901Smarcel 50131901Smarcelstatic struct uart_devinfo uart_dbgport; 51131901Smarcel 52131901Smarcelstatic int 53131901Smarceluart_dbg_probe(void) 54131901Smarcel{ 55131901Smarcel 56131901Smarcel if (uart_cpu_getdev(UART_DEV_DBGPORT, &uart_dbgport)) 57131901Smarcel return (-1); 58131901Smarcel 59131901Smarcel if (uart_probe(&uart_dbgport)) 60131901Smarcel return (-1); 61131901Smarcel 62131901Smarcel return (0); 63131901Smarcel} 64131901Smarcel 65131901Smarcelstatic void 66131901Smarceluart_dbg_init(void) 67131901Smarcel{ 68131901Smarcel 69131901Smarcel uart_dbgport.type = UART_DEV_DBGPORT; 70131901Smarcel uart_add_sysdev(&uart_dbgport); 71131901Smarcel uart_init(&uart_dbgport); 72131901Smarcel} 73131901Smarcel 74131901Smarcelstatic void 75131901Smarceluart_dbg_term(void) 76131901Smarcel{ 77131901Smarcel 78131901Smarcel uart_term(&uart_dbgport); 79131901Smarcel} 80131901Smarcel 81131901Smarcelstatic void 82131901Smarceluart_dbg_putc(int c) 83131901Smarcel{ 84131901Smarcel 85131901Smarcel uart_putc(&uart_dbgport, c); 86131901Smarcel} 87131901Smarcel 88131901Smarcelstatic int 89158950Sphkuart_dbg_getc(void) 90131901Smarcel{ 91131901Smarcel 92131901Smarcel return (uart_poll(&uart_dbgport)); 93131901Smarcel} 94