/*
 * flash.i86  -  constants for assembler module of FlashCard programmer
 *
 * Copyright (C) 1997-2007 Gero Kuhlmann   <gero@gkminix.han.de>
 *
 *  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 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; 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: flash.i86,v 1.13 2007/01/06 18:31:18 gkminix Exp $
 *
 *====================================================================
 *
 * This file can also be included into host source files:
 */
#if !defined(_ASSEMBLY_) || !defined(_TARGET_)
# if !defined(MAKEFLASH_H) || !defined(COMMON_H) || !defined(PACK_ENABLED)
#  error This file can only be included into makeflash.h
# endif
#endif



/*
 *====================================================================
 *
 * Internal identification numbers for Flash EPROM chips
 */
#define CHIP_AT29C256   10
#define CHIP_AT29C512	11
#define CHIP_AT29C010	12
#define CHIP_AT49F512	13
#define CHIP_AT49F001N	14
#define CHIP_AT49F001T	15
#define CHIP_AT29LV256  16
#define CHIP_AT29LV512	17
#define CHIP_AT29LV010	18
#define CHIP_AT29C020	80
#define CHIP_AT29LV020	81
#define CHIP_SST29EE010	20
#define CHIP_SST29LE010	21
#define CHIP_SST39SF010	22
#define CHIP_SST39VF010	23
#define CHIP_SST39VF512	24
#define CHIP_AM29LV010	30
#define CHIP_AM29F010	31
#define CHIP_AM29LV001B	32
#define CHIP_AM29LV001T	33
#define CHIP_AM29LV002B	34
#define CHIP_AM29LV002T	35
#define CHIP_STM29F512	40
#define CHIP_STM29F010	41
#define CHIP_STM29W512	42
#define CHIP_STM29W010	43
#define CHIP_I28F512	50
#define CHIP_I28F010	51
#define CHIP_I28F020	52
#define CHIP_AM28F512	60
#define CHIP_AM28F010	61
#define CHIP_CAT28F512	70
#define CHIP_CAT28F010	71
#define CHIP_CAT28F020	72



/*
 *====================================================================
 *
 * Minimum required sizes to cover the address range to identify a
 * certain Flash EPROM. This depends on the Flash EPROM chip family.
 */
#define AMD_MINSIZE	32768
#define INTEL_MINSIZE	8096



/*
 *====================================================================
 *
 * Layout of flash EPROM chip definition structure
 */
#ifdef _ASSEMBLY_
			.struct	0
fstruct_intid:		.struct	.+2	/* internal chip ID */
fstruct_name:		.struct	.+2	/* chip name pointer */
fstruct_romsize:	.struct	.+4	/* size of chip in bytes */
fstruct_int:		.struct	.+0	/* internal data */

#define FSTRUCT_SIZE	0x0008		/* size of structure (w/o internal) */

#endif



/*
 *====================================================================
 *
 * Layout of flash EPROM interface definition structure
 */
#ifdef _ASSEMBLY_
			.struct	0
istruct_id:		.struct	.+2	/* interface name pointer */
istruct_devtype:	.struct	.+2	/* interface bus type */
istruct_devlist:	.struct	.+2	/* list of device IDs */
istruct_detect:		.struct	.+2	/* detection routine */
istruct_read:		.struct	.+2	/* byte read routine */
istruct_write:		.struct	.+2	/* byte write routine */
istruct_vppon:		.struct	.+2	/* VPP-on routine */
istruct_vppoff:		.struct	.+2	/* VPP-off routine */
istruct_init:		.struct	.+2	/* initialization routine */
istruct_clean:		.struct	.+2	/* cleanup routine */
istruct_erase:		.struct	.+2	/* erase routine */
istruct_prog:		.struct	.+2	/* programming routine */
istruct_verify:		.struct	.+2	/* verify routine */
istruct_loader:		.struct	.+2	/* pointer to loader struct */
istruct_flags:		.struct	.+2	/* flag word */

#define ISTRUCT_SIZE	0x001E		/* size of structure */

#else

struct istruct {
  __u16             ifid;		/* offset to interface name */
  __u16             devtype;		/* device type */
  __u16             devlist;		/* offset to device ID list */
  __u16             detect;		/* offset to detect routine */
  __u16             read;		/* offset to read routine */
  __u16             write;		/* offset to write routine */
  __u16             vppon;		/* offset to VPP-on routine */
  __u16             vppoff;		/* offset to VPP-off routine */
  __u16             init;		/* offset to init routine */
  __u16             clean;		/* offset to cleanup routine */
  __u16             erase;		/* offset to erase routine */
  __u16             prog;		/* offset to program routine */
  __u16             verify;		/* offset to verify routine */
  __u16             loader;		/* offset to loader structure */
  __u16             flags;		/* flags */
} PACKED;

#endif


/* Definition of interface flags */
#define IFLAGS_NEEDMEM	0x0001		/* flag if direct memory access needed */
#define IFLAGS_NOTONIF	0x0002		/* flag if flash not on interface card */


/*
 * Definition of interface device types. These types specify the layout of
 * the supported device list pointed to by ISTRUCT_DEVLIST. If its PCI, then
 * ISTRUCT_DEVLIST points to a vendor ID word, followed by a zero terminated
 * list of device IDs. If its ISA, ISTRUCT_DEVLIST points to a list of un-
 * terminated PnP ID strings. If an interface doesnt have an assigned PnP ID
 * string, it has to be IDEVTYPE_NONE.
 */
#define IDEVTYPE_NONE	0x0000		/* no interface device type specified */
#define IDEVTYPE_PCI	0x0001		/* interface device type PCI */
#define IDEVTYPE_ISA	0x0002		/* interface device type ISA */



/*
 *====================================================================
 *
 * Layout of flash EPROM loader definition structure
 */
#ifdef _ASSEMBLY_
			.struct	0
lstruct_iniofs:		.struct	.+2	/* loader start offset */
lstruct_endofs:		.struct	.+2	/* loader end offset */
lstruct_winsize:	.struct	.+4	/* ROM address window size */

#define LSTRUCT_SIZE	0x0008		/* size of structure */

#endif


#define WINMAXSIZE	65536		/* maximum window size (max. 64KB) */

#define WINID_MAGIC	"netboot..toobten"
#define WINID_LEN	16



/*
 *====================================================================
 *
 * Vendor information for the boot rom image.
 */
#ifdef _ASSEMBLY_
# include <netboot.i86>
#else

#define USE_VENDOR

union vendor_data {
  __long     ldsize;			/* length of rom loader */
} PACKED;

#include <netboot.h>

#endif


#define VENDOR_MAGIC	"GK-makerom"		/* vendor ID */
#define VENDOR_SIZE	3			/* size of ID in dwords */

#define PROGRAMNUM	0			/* tag for programmer segment */
#define ROMIMAGENUM	1			/* tag for boot rom image */
#define NUM_RECORDS	2

