rmonint.h 7.3 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.
 * ==========================================================================
 */

#include "ultratypes.h"
#include "os.h"
#include "os_internal.h"
#include "dbgproto.h"
#include "sptask.h"

typedef int (* FUNPTR)( KKHeader * );
typedef void (* VFUNPTR)();

/*
	Messages that may be sent to the rmon message queue
*/

#define MSG_CHARAVAIL		0x01
#define MSG_BREAKPOINT		0x02
#define MSG_SPBREAKPOINT	0x04
#define MSG_CPUFAULT		0x08
#define MSG_THREADCREATE	0x10
#define MSG_THREADDESTROY	0x20

/* 
	Error return codes from the rk API - expected in reply
	packets by DBGIF process.
*/

#define TV_ERROR_NO_ERROR		0
#define TV_ERROR_ILLEGAL_CALL		-1
#define TV_ERROR_INVALID_ID		-2
#define TV_ERROR_INVALID_TYPE		-3
#define TV_ERROR_OP_PROTECTED		-4
#define TV_ERROR_INVALID_ADDRESS	-5
#define TV_ERROR_INVALID_PRIORITY	-6
#define TV_ERROR_INVALID_FLAGS		-7
#define TV_ERROR_INVALID_CAPABILITY	-8
#define TV_ERROR_NO_HANDLER		-9

#define TV_ERROR_NO_MORE_IDS		-10
#define TV_ERROR_NO_MORE_MESSAGES	-11
#define TV_ERROR_NO_MORE_PROCESSES	-12
#define TV_ERROR_NO_MORE_THREADS	-13
#define TV_ERROR_NO_MORE_REGIONS	-14
#define TV_ERROR_NO_MORE_TIMERS		-15
#define TV_ERROR_NO_MORE_LOCKS		-16
#define TV_ERROR_NO_MORE_QUEUES		-17
#define TV_ERROR_NO_MORE_SETS		-18
#define TV_ERROR_NO_MORE_MEMORY		-19

#define TV_ERROR_NOT_LOCKED		-20

#define TV_ERROR_REGION_ALREADY_MAPPED	-30
#define TV_ERROR_ADDRESS_ALREADY_MAPPED	-31
#define TV_ERROR_NOT_MAPPED		-32
#define TV_ERROR_INVALID_SIZE		-33
#define TV_ERROR_INVALID_PADDR		-34

#define TV_ERROR_RESERVED_MESSAGE_TYPE	-40
#define TV_ERROR_QUEUE_FULL		-41

#define TV_ERROR_FULL_SET		-50
#define TV_ERROR_EMPTY_SET		-51

#define TV_ERROR_DEVICE_BUSY		-60
#define TV_ERROR_NOT_NAVIGATOR		-61
#define TV_ERROR_NO_EXECUTABLE		-62
#define	TV_ERROR_DEVICE_INIT		-63
#define	TV_ERROR_DEVICE_NOTOPEN		-64
#define	TV_ERROR_DEVICE_CONFIG		-65
#define	TV_ERROR_INVALID_ARG		-66
#define	TV_ERROR_NOT_READY		-67

#define	TV_ERROR_CM_CHECKSUM		-68
#define	TV_ERROR_CM_BADRSP		-69
#define	TV_ERROR_CM_BADRSPLEN		-70

#define TV_ERROR_ATM_OUT_OF_VCC		-71
#define TV_ERROR_ATM_VCC_INUSE		-72
#define TV_ERROR_ATM_DEVICE_DOWN	-73
#define TV_ERROR_ATM_INVALID_OP		-74
#define TV_ERROR_ATM_VIDEO_INUSE	-75
#define TV_ERROR_ATM_INVALID_SERVICE	-76

#define	TV_ERROR_NV_BAD_NVRAM		-77
#define	TV_ERROR_NV_VAL_TOO_LONG	-78
#define	TV_ERROR_NV_NOT_FOUND		-79
#define	TV_ERROR_NV_FULL		-80

#define TV_ERROR_LOG_BUF_EMPTY		-81

#define __TV_LAST_KERNEL_ERROR		-99

#define EV_BREAK 1	/* Event: a breakpoint has been hit */

#define VERSION 2

/*
	Memory regions
*/

#define RAM_START	0
#define RAM_END		0x03efffff
#define ROM_START	0x05000000
#define ROM_END		0x7fffffff
#define DMEM_START	0x4000000
#define DMEM_END	0x4000fff
#define IMEM_START	0x4001000
#define IMEM_END	0x4001fff
#define RCPMEM_START	0x4000000	/* any */
#define RCPMEM_END	0x4ffffff

#define METHOD_NORMAL	0
#define METHOD_RSP	1
#define METHOD_VECT	2

#define RSP_PROC	1001
#define RSP_THREAD	1000	/* scalar space */
#define CPU_PROC	1002
#define CPU_THREAD	1003

#define BREAKMASK 0xfc00003f

#define MEMBASE	0x88200000

#if defined( RMONDEBUG )
#define Debug rmonPrintf
#else	/* not RMONDEBUG, do nothing */
#ifdef __GNUC__
#define Debug(arg...)
#else
#define Debug
#endif
#endif

#define MEMK 0

#define MAXMEMREQ 1024
#define MAXPACKET MAXMEMREQ+16
#define MAXENCODED ((MAXPACKET*5)/4)+16

#define _PTYPE u32 *

/*	Function Prototypes	*/

/* exports from rcp.s */

extern u32		__rmonRCPrunning( void );
extern void		__rmonIdleRCP( void );
extern void		__rmonRunRCP( void );
extern void		__rmonStepRCP( void );

/* exports from rmonbrk.c */

extern void		__rmonHitBreak( void );
extern void		__rmonHitSpBreak( void );
extern void		__rmonHitCpuFault( void );
extern u32		__rmonGetBranchTarget( int, int, char * );
extern int		__rmonSetSingleStep( int, u32 * );
extern void		__rmonGetExceptionStatus( KKStatusEvent * );
extern int		__rmonSetBreak( KKHeader * );
extern int		__rmonClearBreak( KKHeader * );
extern int		__rmonListBreak( KKHeader * );

extern u8		__rmonRcpAtBreak;

/* exports from rmoncmd.c */

extern int		__rmonExecute( KKHeader * );

/* exports from rmonmain.c */

extern void		__rmonSendReply( KKHeader * const, u32, u32 );
extern void		__rmonSendHeader( KKHeader * const, u32, u32 );
extern void		__rmonSendData( const char *, unsigned int );

extern int		__rmonActive;

/* exports from rmonmem.c */

extern u32		__rmonReadWordAt( u32 * );
extern void		__rmonWriteWordTo( u32 *, u32 );
extern void		__rmonMemcpy( u8 *, u8 *, u32 );
extern void		__rmonCopyWords( u32 *, u32 *, u32 );
extern int		__rmonLoadProgram( KKHeader * );
extern int		__rmonReadMem( KKHeader * );
extern int		__rmonWriteMem( KKHeader * );
extern int		__rmonListProcesses( KKHeader * );
extern int		__rmonGetExeName( KKHeader * );
extern int		__rmonGetRegionCount( KKHeader * );
extern int		__rmonGetRegions( KKHeader * );

extern u8		__rmonUtilityBuffer[];	/* 256 bytes -watch it if it
						   gets to about 50 tasks! */

/* exports from rmonmisc.c */

extern void		__rmonInit( void );
extern void		__rmonPanic( void );
extern int		__rmonSetFault( KKHeader * );
extern int		__rmonSetComm( KKHeader * );

extern OSMesgQueue	__rmonMQ;

/* exports from rmonregs.c */

extern u32		__rmonGetRegisterContents( int, int, int );
extern int		__rmonGetGRegisters( KKHeader * );
extern int		__rmonSetGRegisters( KKHeader * );
extern int		__rmonGetFRegisters( KKHeader * );
extern int		__rmonSetFRegisters( KKHeader * );
extern int		__rmonGetSRegs( KKHeader * );
extern int		__rmonSetSRegs( KKHeader * );
extern int		__rmonGetVRegs( KKHeader * );
extern int		__rmonSetVRegs( KKHeader * );


/* exports from rmonsio.c */

extern void		__rmonAcquirePrintf( void );
extern void		__rmonReleasePrintf( void );
extern int		__rmonIOread( u32 * );
extern void		__rmonPflush( void );
extern void		__rmonSendFault( OSThread * );
extern void		__rmonIOflush( void );
extern void		__rmonIOputw( u32 );
extern void		__rmonPputw( u32 );
extern void		__rmonIOhandler( void );

extern OSMesgQueue	rmonCalloutMQ;
extern OSMesgQueue	__rmonLogAckMesgQueue;
extern OSMesgQueue	__rmonDataAckMesgQueue;
extern OSMesgQueue	__rmonProfReqMesgQueue;
extern OSMesgQueue	__rmonProfAckMesgQueue;

/* exports from rmontask.c */

extern void		__rmonMaskIdleThreadInts( void );
extern OSThread *	__rmonGetTCB( int );
extern int		__rmonStopUserThreads( int );
extern int		__rmonGetThreadStatus( int, int, KKStatusEvent * );
extern int		__rmonListThreads( KKHeader * );
extern int		__rmonThreadStatus( KKHeader * );
extern int		__rmonStopThread( KKHeader * );
extern int		__rmonRunThread( KKHeader * );