
/*
 Copyright 1999 by Digi International (www.digi.com)

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the 
 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 PURPOSE.  See the GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
 *	$Id: debugcomm.h,v 1.9 1999/09/03 15:27:16 dickl Exp $
 *
 *	This structure defines all of the global data used for
 *	various and sundry debugging purposes.   This structure
 *	is located at a fixed offset in low memory defined by
 *	GLOBAL_DEBUG_OFFSET in *mmap.h (currently, 0x200, but you
 *	must use the #define in your code).  The structure cannot
 *	go past the GLOBAL_DATA_OFFSET location (currently 0x1000).
 *
 *	Well, I was going to make this structure respect cache line
 *	organization.  But, it turns out that the debugger queue's would
 *	need a lot of code work to work in this way.  Since this is
 *	debug code, we are just going to make the requirement that this
 *	structure always be accessed thru uncached memory.  Thats
 *	probably best, anyway.
 *
 *	I have not yet moved the debugger queues into this.
 *	
 *	Note: to get the number of entries in print_buf[] and
 *	spd_buf[], use asizeof(print_buf) and asizeof(spd_buf).
 *	*Do not* hardcode in the constant 512.  asizeof is defined
 *	elsewhere as:
 *		#define asizeof(X) (sizeof(X)/sizeof(X[0]))
 *	This trick avoids the need to invent a gratuitous #define
 *	name for the number of elements in the array.  The number
 *	of elements is right in the declaration where you want
 *	to see it.
 */
#ifndef _DEBUG_H
#define _DEBUG_H

/*
 *	Computer Science 101 lesson for today:
 *
 *	When speaking of a queue, the "head", "front", or "out"
 *	of a queue is the point at which the consumer of the
 *	queue removes data.  The "tail", "rear", or "in" of a
 *	queue is the point at which the producer inserts new
 *	data.  These terms have a long history in computer
 *	science going back several decades.  The terms are
 *	applicable and mean the same thing regardless of the
 *	actual representation of the queue (list, ring, linked
 *	list, etc.)
 */

typedef struct global_debug_data
{
	/*
	 *	Counters and flags for debugging purposes
	 */
	board_uint32_le	counters[8];	/* Counters for debugging purposes */

	host_uint32_le	flags[8];	/* Flags for debugging purposes */

	/*
	 *	Debugging printf's to host
	 */
	host_uint32_le	print_waits;	/* FEP should block when buf is full */
	board_uint32_le	print_waiting;	/* Counter: increments when waiting */
	host_uint32_le	print_head;	/* Head (out) of circular buffer */
	board_uint32_le	print_tail;	/* Tail (in) of print buffer */
	board_uint32_le	print_mask;	/* Mask for head/tail */
	board_uchar	print_buf[512];	/* buffer for debugging printf's */

	/*
	 *	Debugging getc's from host, this buffer is used as an
	 *	alternative input source to the debug uart.
	 */
	board_uint32_le	get_head ;	/* Head (out) of circular buffer */
	host_uint32_le	get_tail ;	/* Tail (in) of circular buffer */
	board_uint32_le	get_mask ;	/* Mask for head/tail */
	host_uchar	get_buf[128] ;	/* Buffer for debugging getc's */

	/*
	 *	For DMA experiments, it is sometimes very useful if we
	 *	know the address of two buffers in host memory that
	 *	we can play with.  Here is a place for the device driver
	 *	to give us them.
	 */
	shared_uint32_le dma_buf[2];	/* Physaddr of two host dma buffers */
	shared_uint32_le dma_buf_len;	/* Length of them (must be >= 4096) */

	#if not_this_week
		/*
		 *	Debugger command queues
		 */
		CQ		cq_cmd;
		RQ		cq_resp;
	#endif

	/*
	 *	Statistical profiling data
	 *
	 *	If the host can't keep up reading this data, too bad.
	 *	We can't do anything intelligent if it fills up.
	 *	Thus, we keep only a tail (in) pointer.  With a board
	 *	statistics interrupt every 100 usec, this gives the host
	 *	25.6 msec's to empty this data.  So a host polling rate
	 *	of 10 msec's should be very comfortable.
	 */
	board_uint32_le	spd_tail;	/* Tail (in) of circular buffer */
	board_uint32_le	spd_buf[256];

	shared_uint32_le data_watchpoint;	/* Data Watchpoint Address */

} GLOBAL_DEBUG_DATA;


#endif
