11590Srgrimes/*-
21590Srgrimes * SPDX-License-Identifier: BSD-2-Clause
31590Srgrimes *
41590Srgrimes * Copyright (c) 2004 Marcel Moolenaar
51590Srgrimes * All rights reserved.
61590Srgrimes *
71590Srgrimes * Redistribution and use in source and binary forms, with or without
81590Srgrimes * modification, are permitted provided that the following conditions
91590Srgrimes * are met:
101590Srgrimes *
111590Srgrimes * 1. Redistributions of source code must retain the above copyright
121590Srgrimes *    notice, this list of conditions and the following disclaimer.
131590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141590Srgrimes *    notice, this list of conditions and the following disclaimer in the
151590Srgrimes *    documentation and/or other materials provided with the distribution.
161590Srgrimes *
171590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
181590Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
191590Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
201590Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
211590Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
221590Srgrimes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231590Srgrimes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241590Srgrimes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251590Srgrimes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
261590Srgrimes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271590Srgrimes */
281590Srgrimes
291590Srgrimes#ifndef _GDB_GDB_H_
301590Srgrimes#define	_GDB_GDB_H_
311590Srgrimes
321590Srgrimestypedef int gdb_checkc_f(void);
331590Srgrimestypedef int gdb_getc_f(void);
341590Srgrimestypedef void gdb_init_f(void);
3527273Scharniertypedef int gdb_probe_f(void);
361590Srgrimestypedef void gdb_putc_f(int);
371590Srgrimestypedef void gdb_term_f(void);
381590Srgrimes
391590Srgrimesstruct gdb_dbgport {
401590Srgrimes	const char	*gdb_name;
4127273Scharnier	gdb_getc_f	*gdb_getc;
421590Srgrimes	gdb_init_f	*gdb_init;
4327273Scharnier	gdb_probe_f	*gdb_probe;
4427273Scharnier	gdb_putc_f	*gdb_putc;
4540525Sjdp	gdb_term_f	*gdb_term;
461590Srgrimes	int		gdb_active;
471590Srgrimes	void		(*gdb_sendpacket)(const void *, size_t);
481590Srgrimes	int		gdb_dbfeatures;
491590Srgrimes};
501590Srgrimes
511590Srgrimes#define	GDB_DBGP_FEAT_WANTTERM	0x1	/* Want gdb_term() invocation when
521590Srgrimes					   leaving GDB.  gdb_term has been
531590Srgrimes					   deadcode and never invoked for so
541590Srgrimes					   long I don't want to just blindly
551590Srgrimes					   start invoking it without opt-in. */
561590Srgrimes#define	GDB_DBGP_FEAT_RELIABLE	0x2	/* The debugport promises it is a
571590Srgrimes					   reliable transport, which allows GDB
581590Srgrimes					   acks to be turned off. */
591590Srgrimes
601590Srgrimes#define	GDB_DBGPORT(name, probe, init, term, getc, putc)		\
611590Srgrimes	static struct gdb_dbgport name##_gdb_dbgport = {		\
621590Srgrimes		.gdb_name = #name,					\
631590Srgrimes		.gdb_probe = probe,					\
641590Srgrimes		.gdb_init = init,					\
651590Srgrimes		.gdb_term = term,					\
661590Srgrimes		.gdb_getc = getc,					\
671590Srgrimes		.gdb_putc = putc,					\
681590Srgrimes	};								\
6940350Sjdp	DATA_SET(gdb_dbgport_set, name##_gdb_dbgport)
7027273Scharnier
711590Srgrimes#endif /* !_GDB_GDB_H_ */
721590Srgrimes