Home | History | Annotate | Line # | Download | only in ddb
      1  1.42    andvar /*	$NetBSD: db_command.h,v 1.42 2021/08/09 20:49:09 andvar Exp $	*/
      2  1.28    martin 
      3  1.28    martin /*-
      4  1.28    martin  * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
      5  1.28    martin  * All rights reserved.
      6  1.28    martin  *
      7  1.28    martin  * This code is derived from software contributed to The NetBSD Foundation
      8  1.28    martin  * by Adam Hamsik.
      9  1.28    martin  *
     10  1.28    martin  * Redistribution and use in source and binary forms, with or without
     11  1.28    martin  * modification, are permitted provided that the following conditions
     12  1.28    martin  * are met:
     13  1.28    martin  * 1. Redistributions of source code must retain the above copyright
     14  1.28    martin  *    notice, this list of conditions and the following disclaimer.
     15  1.28    martin  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.28    martin  *    notice, this list of conditions and the following disclaimer in the
     17  1.28    martin  *    documentation and/or other materials provided with the distribution.
     18  1.28    martin  *
     19  1.28    martin  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.28    martin  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.28    martin  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.28    martin  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.28    martin  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.28    martin  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.28    martin  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.28    martin  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.28    martin  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.28    martin  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.28    martin  * POSSIBILITY OF SUCH DAMAGE.
     30  1.28    martin  */
     31   1.5       cgd 
     32  1.22    simonb /*
     33   1.1       cgd  * Mach Operating System
     34   1.1       cgd  * Copyright (c) 1991,1990 Carnegie Mellon University
     35   1.1       cgd  * All Rights Reserved.
     36  1.22    simonb  *
     37   1.1       cgd  * Permission to use, copy, modify and distribute this software and its
     38   1.1       cgd  * documentation is hereby granted, provided that both the copyright
     39   1.1       cgd  * notice and this permission notice appear in all copies of the
     40   1.1       cgd  * software, derivative works or modified versions, and any portions
     41   1.1       cgd  * thereof, and that both notices appear in supporting documentation.
     42  1.22    simonb  *
     43  1.12        pk  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     44   1.1       cgd  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
     45   1.1       cgd  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     46  1.22    simonb  *
     47   1.1       cgd  * Carnegie Mellon requests users of this software to return to
     48  1.22    simonb  *
     49   1.1       cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     50   1.1       cgd  *  School of Computer Science
     51   1.1       cgd  *  Carnegie Mellon University
     52   1.1       cgd  *  Pittsburgh PA 15213-3890
     53  1.22    simonb  *
     54   1.1       cgd  * any improvements or extensions that they make and grant Carnegie the
     55   1.1       cgd  * rights to redistribute these changes.
     56   1.1       cgd  *
     57   1.1       cgd  *	Author: David B. Golub, Carnegie Mellon University
     58   1.1       cgd  *	Date:	7/90
     59   1.1       cgd  */
     60   1.3   mycroft 
     61  1.28    martin #ifndef _DDB_COMMAND_
     62  1.28    martin #define _DDB_COMMAND_
     63   1.1       cgd 
     64  1.22    simonb void	db_skip_to_eol(void);
     65  1.22    simonb void	db_command_loop(void);
     66  1.31     perry void	db_error(const char *) __dead;
     67  1.22    simonb 
     68  1.22    simonb extern db_addr_t db_dot;	/* current location */
     69  1.22    simonb extern db_addr_t db_last_addr;	/* last explicit address typed */
     70  1.22    simonb extern db_addr_t db_prev;	/* last address examined
     71   1.7   mycroft 				   or written */
     72  1.22    simonb extern db_addr_t db_next;	/* next address to be examined
     73   1.7   mycroft 				   or written */
     74   1.1       cgd 
     75  1.25      yamt extern char db_cmd_on_enter[];
     76  1.25      yamt 
     77  1.28    martin struct db_command;
     78  1.28    martin 
     79  1.28    martin 
     80  1.28    martin 
     81  1.28    martin /*
     82  1.28    martin  * Macro include help when DDB_VERBOSE_HELP option(9) is used
     83  1.28    martin  */
     84  1.28    martin #ifdef DDB_VERBOSE_HELP
     85  1.28    martin #define DDB_ADD_CMD(name,funct,type,cmd_descr,cmd_arg,arg_desc)\
     86  1.28    martin  name,funct,type,cmd_descr,cmd_arg,arg_desc
     87  1.28    martin #else
     88  1.28    martin #define DDB_ADD_CMD(name,funct,type,cmd_descr,cmd_arg,arg_desc)\
     89  1.28    martin  name,funct,type
     90  1.28    martin #endif
     91  1.39     skrll 
     92  1.41       mrg /* End of list for ddb command arrays. */
     93  1.41       mrg #define DDB_END_CMD DDB_ADD_CMD(NULL, NULL, 0, NULL, NULL, NULL)
     94  1.28    martin 
     95  1.28    martin 
     96  1.28    martin /*
     97  1.28    martin  * we have two types of lists one for base commands like reboot
     98  1.28    martin  * and another list for show subcommands.
     99  1.28    martin  */
    100  1.28    martin 
    101  1.28    martin #define DDB_BASE_CMD 0
    102  1.28    martin #define DDB_SHOW_CMD 1
    103  1.28    martin #define DDB_MACH_CMD 2
    104  1.28    martin 
    105  1.28    martin 
    106  1.28    martin int db_register_tbl(uint8_t, const struct db_command *);
    107  1.28    martin int db_unregister_tbl(uint8_t, const struct db_command *);
    108  1.28    martin 
    109   1.4        pk /*
    110   1.4        pk  * Command table
    111   1.4        pk  */
    112   1.4        pk struct db_command {
    113  1.19  jdolecek 	const char	*name;		/* command name */
    114  1.39     skrll 
    115   1.8  christos 	/* function to call */
    116  1.27      matt 	void		(*fcn)(db_expr_t, bool, db_expr_t, const char *);
    117  1.28    martin 	/*
    118  1.34      haad 	 * Flag is used for modifing command behaviour.
    119  1.34      haad 	 * CS_OWN && CS_MORE are specify type of command arguments.
    120  1.34      haad 	 * CS_OWN commandmanage arguments in own way.
    121  1.34      haad 	 * CS_MORE db_command() prepare argument list.
    122  1.28    martin 	 *
    123  1.34      haad 	 * CS_COMPAT is set for all level 2 commands with level 3 childs (show all pages)
    124  1.28    martin 	 *
    125  1.34      haad 	 * CS_SHOW identify show command in BASE command list
    126  1.34      haad 	 * CS_MACH identify mach command in BASE command list
    127  1.28    martin 	 *
    128  1.34      haad 	 * CS_SET_DOT specify if this command is put to last added command memory.
    129  1.34      haad 	 * CS_NOREPEAT this command does not repeat
    130  1.28    martin 	 */
    131  1.40     skrll 	uint16_t	flag;		/* extra info: */
    132  1.40     skrll #define	CS_OWN		0x1		/* non-standard syntax */
    133  1.40     skrll #define	CS_MORE		0x2		/* standard syntax, but may have other
    134  1.40     skrll 								words at end */
    135  1.42    andvar #define CS_COMPAT	0x4		/* is set for compatibility with old
    136  1.40     skrll 								ddb versions */
    137  1.40     skrll #define CS_SHOW		0x8		/* select show list */
    138  1.34      haad #define CS_MACH		0x10		/* select machine dependent list */
    139  1.28    martin 
    140   1.4        pk #define	CS_SET_DOT	0x100		/* set dot after command */
    141  1.28    martin #define	CS_NOREPEAT	0x200		/* don't set last_command */
    142  1.28    martin #ifdef DDB_VERBOSE_HELP
    143  1.40     skrll 	const char *cmd_descr;		/* description of command */
    144  1.40     skrll 	const char *cmd_arg;		/* command arguments */
    145  1.28    martin 	const char *cmd_arg_help;	/* arguments description */
    146  1.28    martin #endif
    147   1.4        pk };
    148  1.28    martin 
    149  1.38       rin void	*db_alloc(size_t);
    150  1.38       rin void	*db_zalloc(size_t);
    151  1.38       rin void	db_free(void *, size_t);
    152  1.38       rin 
    153  1.36  christos #ifndef _KERNEL
    154  1.36  christos #define db_kernelonly() \
    155  1.36  christos     db_printf("%s: can only be used in-kernel.\n", __func__)
    156  1.36  christos #endif
    157  1.36  christos 
    158  1.28    martin #endif /*_DDB_COMMAND_*/
    159