rmoncmds.c 5.08 KB
/*
 * ==========================================================================
 * Copyright (c) 1994, Silicon Graphics, Inc.  All Rights Reserved.
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
 * the contents of this file may not be disclosed to third parties, copied
 * or duplicated in any form, in whole or in part, without the prior written
 * permission of Silicon Graphics, Inc. handleSelectExceptions
 *
 * RESTRICTED RIGHTS LEGEND:
 * Use, duplication or disclosure by the Government is subject to restrictions
 * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
 * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
 * successor clauses in the FAR, DOD or NASA FAR Supplement.  Unpublished
 * rights reserved under the Copyright Laws of the United States.
 * ==========================================================================
 */

/************************************************************************
Program: rmon (reality monitor) in-circuit target monitor
File: cmds.c
Author: Kenneth F. Greenberg
Purpose: The command dispatcher/interpreter
Revision history:
	94.10.21  Original
************************************************************************/

#ifndef _FINALROM

#include "dbgdefs.h"	/* definitions needed by the following file */
#include "dbgproto.h"	/* standard protocol definitions */
#include "rmonint.h"	/* needs info in above files */

/************************************************************************
Function: (static) NotImplemented
Args: KKHeader * request - not used but declared for compatibility
Type: int - returns ILLEGAL_CALL always.
Purpose: This function is a placeholder in the dispatch table for
	standard commands provided in the protocol but not implemented
	in the Reality system.
************************************************************************/
static int NotImplemented( KKHeader * dummy )
{
	return TV_ERROR_ILLEGAL_CALL;
}

static FUNPTR dispatchTable[] = {
	__rmonLoadProgram,	/* cmd 0 */
	__rmonListProcesses,	/* cmd 1 */
	__rmonGetExeName,	/* cmd 2 */
	__rmonListThreads,	/* cmd 3 */
	__rmonThreadStatus,	/* cnd 4 */
	NotImplemented,		/* _KK_REQ_STOPPROC */
	__rmonStopThread,	/* cmd 6 */
	__rmonRunThread,	/* cmd 7 */
	NotImplemented,		/* _KK_REQ_RUNPROC */
	NotImplemented,		/* _KK_REQ_KILLPROC */
	__rmonSetFault,		/* cmd 10 */
	NotImplemented,		/* _KK_REQ_GETFAULT */
	__rmonGetRegionCount,	/* cmd 12 */
	__rmonGetRegions,	/* cmd 13 */
	__rmonGetGRegisters,	/* cmd 14 */
	__rmonSetGRegisters,	/* cmd 15 */
	__rmonGetFRegisters,	/* cmd 16 */
	__rmonSetFRegisters,	/* cmd 17 */
	__rmonReadMem,		/* cmd 18 */
	__rmonWriteMem,		/* cmd 19 */
	__rmonSetBreak,		/* cmd 20 */
	__rmonClearBreak,	/* cmd 21 */
	__rmonListBreak,	/* cmd 22 */
	NotImplemented,		/* _KK_REQ_NUMWATCH */
	NotImplemented,		/* _KK_REQ_SETWATCH */
	NotImplemented,		/* _KK_REQ_GETWATCH */
	NotImplemented,		/* _KK_REQ_USAGE */
	NotImplemented,		/* _KK_REQ_GETPATHLIST */
	NotImplemented,		/* _KK_REQ_GETFRAME */
	NotImplemented,		/* _KK_REQ_REBOOT */
	__rmonSetComm,		/* cmd 30 */
	NotImplemented,		/* _KK_REQ_SETSYSENTRY */
	NotImplemented,		/* _KK_REQ_GETSYSENTRY */
	NotImplemented,		/* _KK_REQ_SETSYSEXIT */
	NotImplemented,		/* _KK_REQ_GETSYSEXIT */
	NotImplemented,		/* _KK_REQ_ENABLELOG */
	NotImplemented,		/* _KK_REQ_DISABLELOG */
	NotImplemented,		/* _KK_REQ_FLUSHLOG */
	NotImplemented,		/* _KK_REQ_NEWLOG */
	NotImplemented,		/* _KK_REQ_GETMASK */
	NotImplemented,		/* _KK_REQ_AMCMD */
	NotImplemented,		/* _KK_REQ_REMOTE */
	NotImplemented,		/* _KK_REQ_LOGCONTROL */
	NotImplemented,		/* _KK_REQ_LOGSTATUS */
	NotImplemented,		/* _KK_REQ_GETLOGFILE */
	NotImplemented,		/* _KK_REQ_GETSYSUSAGE */
	NotImplemented,		/* _KK_REQ_SETTRPT */
	NotImplemented,		/* _KK_REQ_CLRTRPT */
	NotImplemented,		/* _KK_REQ_LISTTRPTS */
	__rmonGetSRegs,		/* cmd 49 */
	__rmonSetSRegs,		/* _KK_REQ_SETSREGSET */
	__rmonGetVRegs,		/* _KK_REQ_GETVREGSET */
	__rmonSetVRegs,		/* _KK_REQ_SETVREGSET */

	/* A bunch of missing ones we don't handle */

	NotImplemented		/* _KK_REQ_COUNT */
};

/************************************************************************
Function: rmonExecute
Args: KKHeader * request - address of the standard protocol structure for
	all commands from the host
Type: int - returns whatever status the called function returns
Purpose: This function dispatches a method to execute the requested
	host command and returns its status. The called function should
	only return a negative error code if it wants this function to
	respond to dbgif. Normally, it returns 0. A return of 1 causes
	the application to run.
************************************************************************/
int __rmonExecute( KKHeader * request )
{
    int retval;
    KKHeader reply;
    
    if ( request->code > _KK_REQ_SETVREGSET )
	return TV_ERROR_ILLEGAL_CALL;
    if ( (retval = (*dispatchTable[ request->code ])( request )) < 0 )
    {
	/* Send the generic "Huh?" command */	
	reply.code = request->code;
	reply.error = retval;
	__rmonSendReply( (KKHeader * const) &reply, sizeof( KKHeader ), _KK_REPLY );
    }
    return retval;
}

#endif  /* #ifndef _FINALROM */