
/*
 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: fepglbl.h,v 1.7 1999/09/03 15:27:18 dickl Exp $
 *
 *	This is the global data which is specific for when the
 *	FEP is running.  It is split out from triglbl.h so that
 *	there could be other things running on the board besides
 *	a FEP.  Thus, "triglbl.h" could be included in the POST
 *	or BOOT without having to drag in all the DXB structures.
 *
 *	#include "triglbl.h"
 *	#include "dxbglbl.h"
 *	#include "fepglbl.h"
 *
 */
#ifndef _FEPGLBL_H
#define _FEPGLBL_H

/*
 *	Before the FEP is loaded, the host fills in this structure.
 *	The physical address of this structure is put at GLOBAL_HOST_OFFSET.
 */
typedef struct global_host_data
{
	/*
	 *	A magic number is provided so that the FEP can insure that
	 *	it is looking at a real DXB initilization structure.
	 *
	 *	Also, the buffer pages themselves are stamped with a magic
	 *	number in the first 32 bit word of the actual buffer page
	 *	and the page number in the second word (host_uint32's).
	 */
	host_uint32	magic;	/* Magic number */
			#define	MAGIC_HOST	MKMAGIC('h','o','s','t')
			#define	MAGIC_HOSTBUF	MKMAGIC('h','b','u','f')

	/*
	 *	The host can request that the FEP cause a host interrupt
	 *	whenever the DXB queue needs servicing.  If this variable
	 *	is non-zero, interrupts are generated with a period not
	 *	exceeding this number in milliseconds.
	 */
	host_uint32	intr_period;

	/*
	 *	The host can request that the FEP erase the parameter
	 *	area of NV memory (flash) before starting.
	 */
	host_uint32	erase_nvm;

	/*
	 *	Preserve multiple of 32 byte size of this structure
	 */
	pad_32		pad1[5];
	
	/*
	 *	Here is the DXB initialization data  -- physical addresses
	 *	of the host2adapter and adapter2host circular buffers,
	 *	as well as the physical addresses of their in/out offset
	 *	variables.
	 */
	DXBPHYS		dxbphys;

} GLOBAL_HOST_DATA;

/*
 *	COREINFO:
 *
 *	Some hosts are unable to take a complete core dump of the
 *	FEP in case of a fatal error.  Go figure.  Anyway, in that
 *	case, the FEP keeps a linked list of core areas that should
 *	be saved in order to have any chance of debugging the problem.
 *	This is the structure that contains one element of that list.
 *
 *	Note that since this information is primarily used by the host,
 *	we keep memory offsets from the start of board memory for all
 *	elements, even the links, instead of FEP virtual addresses.
 *
 *	The FEP will guarantee that all offsets and lengths are
 *	multiples of 4 (32 bit aligned).  A magic number is provided
 *	so that the host may insure that it is looking at a valid
 *	list entry, as opposed to garbage produced by a sick FEP.
 *	Nevertheless, the host should insure the offset and offset+length
 *      are both within the bounds of the FEP memory.
 *
 *	The end of the list is indicated by a next_offset of 0.
 *
 *	It goes without saying that the host must keep the information
 *	in these structures along with each piece of memory that it saves,
 *	in order to have any chance of reconstructing a FEP memory image
 *	with all the pieces in their proper locations.  How the host
 *	does this is beyond the scope or concern of the FEP API.  However,
 *	it is required that a host application program be written to
 *	reconstruct a normal FEP memory image from the COREINFO structures
 *	and the data which they point to.  Areas of memory in the image which
 *	were not saved by the host (the "holes") should be filled with the
 *	recommended CORE_CONSTANT.
 */
typedef struct coreinfo
{
	board_uint32	magic;		/* Magic number */
			#define	MAGIC_COREINFO	MKMAGIC('c','o','r','e')

	board_uint32	offset;		/* Offset of memory area to save */
	board_uint32	length;		/* Length of memory area to save */

	board_uint32	next_offset;	/* Offset to next COREINFO node */
} COREINFO;

#define	CORE_CONSTANT	0xDEAFBEEF	/* Recommended core constant */
	

/*
 *	GLOBAL_FEP_DATA:
 *
 *	When the FEP program is running, this is its global data
 *	that is exposed to the host.  Most everything else goes
 *	through a DXB channel.
 *
 *	This structure is cacheline-32 safe.
 */
typedef struct global_fep_data
{
	/*
	 *	The common data required by all firmware
	 */
	GLOBAL_COMMON	common;

	/*
	 *	The offset to the panic structure, defined
	 *	in fw/libidt/panic.h
	 */
	board_uint32	panic;

	/*
	 *	The offset to the BB_CTRL structure,
	 *	defined in include/blackbox.h
	 */
	board_uint32	blackbox;

	/*
	 *	The offset to the first COREINFO node in the linked list
	 *	of COREINFO structures defined above.
	 *
	 *	Also, the total size of the memory which has been registered
	 *	in the list.  For statistical purposes.
	 */
	board_uint32	coreinfo;
	board_uint32	coresize;

	/*
	 *	Preserve multiple of 32 byte size of this structure
	 */
	pad_32		pad1[4];

} GLOBAL_FEP_DATA;


#endif
