rmonmisc.c 4.84 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: regs.c
Author: Kenneth F. Greenberg
Purpose: The access functions that don't fit anywhere else
Revision history:
	94.10.31  Original (Happy Halloween)
************************************************************************/

#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 */
#include <em.h>
#include <rcp.h>

/************************************************************************
Function: __rmonSetFault
Args: KKHeader * req - address of the standard protocol structure for
	setting faults, whatever the heck that means.
Type: int - returns 0 if successful, otherwise error type
Purpose: This function responds to the set fault request with useless
	information - just like the one in the settop box.
************************************************************************/
int __rmonSetFault( KKHeader * req )
{
    KKFaultRequest * request = (KKFaultRequest *) req;
    KKObjectEvent reply;
    
    Debug( "SetFault\n" );
    reply.header.code = request->header.code;
    reply.header.error = TV_ERROR_NO_ERROR;
    reply.object = request->tid;
    __rmonSendReply( (KKHeader * const) &reply, sizeof( KKObjectEvent ), _KK_REPLY );
    return 0;
}

OSMesgQueue __rmonMQ;		/* public - shared by main and IO */

static OSThread rmonIOThread;
static OSMesg rmonMsgs[8];
static double rmonIOStack[0x800];

static OSMesg rmonPiMsgs[8];
static OSMesgQueue rmonPiMQ;

/************************************************************************
Function: rmonInit
Args: none
Type: void
Purpose: This function should always contain all init code for rmon.
************************************************************************/
void __rmonInit(void)
{
    osCreateMesgQueue( &__rmonMQ, rmonMsgs, 8 );
    osSetEventMesg( OS_EVENT_CPU_BREAK, &__rmonMQ, (OSMesg) MSG_BREAKPOINT );
    osSetEventMesg( OS_EVENT_SP_BREAK, &__rmonMQ, (OSMesg) MSG_SPBREAKPOINT );
    osSetEventMesg( OS_EVENT_FAULT, &__rmonMQ, (OSMesg) MSG_CPUFAULT );
    osSetEventMesg( OS_EVENT_THREADSTATUS, &__rmonMQ, (OSMesg) 0 );

    osCreateThread( &rmonIOThread, 0, (VFUNPTR) __rmonIOhandler, 0, 
		    &rmonIOStack[0x800], (OSPri) 255 );

    /*
      Note that Pi manager must start before IO manager, since the
      latter requests the former's command queue address at startup.
      It should be legal to start one, even if one is already 
      running (will just fail).
    */

    osCreatePiManager( (OSPri) 150, &rmonPiMQ, rmonPiMsgs, 8 );
    osStartThread( &rmonIOThread );
}

/************************************************************************
Function: __rmonPanic
Args: none
Type: void
Purpose: This function implements a panic stop for rmon; essentially, it
	stops doing anything when a fatal error occurs, although interrupts
	continue to be processed. By looking at the stack (how?) it may
	be possible to figure out how we got here.
************************************************************************/
void __rmonPanic(void)
{
	Debug( "PANIC!!\n" );
	for ( ;; )
		;
}

/************************************************************************
Function: __rmonSetComm
Args: KKHeader * req - address of the standard protocol structure for
	setting comm, whatever the heck that means.
Type: int - returns 0 if successful, otherwise error type
Purpose: This function responds to the set comm request with useless
	information - just like the one in the settop box.
************************************************************************/
int __rmonSetComm( KKHeader * req )
{
	KKObjectEvent reply;

	Debug( "SetComm\n" );
	reply.header.code = req->code;
	reply.object = KK_TTY;
	reply.header.error = TV_ERROR_NO_ERROR;
	__rmonSendReply( (KKHeader * const) &reply, sizeof( KKObjectEvent ), _KK_REPLY );
	return 0;
}

#endif  /* #ifndef _FINALROM */