/*- Flash Memory Read, Write, Erase Operations
 *
 *  Copyright (C) 1993-1995 MCT Paul & Scherer, Berlin.
 *  All rights reserved.
 *
 *  Permission to use this software and its documentation 
 *  is hereby granted, provided that the above copyright 
 *  notice appear in all copies and that both the copyright 
 *  notice and warranty disclaimer appear in supporting 
 *  documentation, and that the names of MCT Paul & Scherer 
 *  GmbH and any of their entities not be used in advertising 
 *  or publicity pertaining to distribution of the software 
 *  without specific, written prior permission.
 * 
 *  MCT disclaims all warranties with regard to this software, 
 *  including all implied warranties of merchantability and 
 *  fitness.  In no event shall MCT be liable for any special, 
 *  indirect or consequential damages or any damages whatsoever 
 *  resulting from loss of use, data or profits, whether in an 
 *  action of contract, negligence or other tortuous action, 
 *  arising out of or in connection with the use or performance 
 *  of this software.
 */

#define HI (printf("Hi: %s: %d\n", __FILE__, __LINE__), \
            _delay(100000), fflush(stdout))

#define IRQ_OFF             asm("movew #0x2700,sr");
#define IRQ_ON              asm("movew #0x2000,sr");

#if defined(scotty08)
    typedef volatile unsigned char fword;
#else
    typedef volatile unsigned short fword;
#endif

#define FLASH_A2F(a)        ( (fword *)((unsigned long)(a) & ~(flash_size-1)) )
#define FLASH_A2B(a)        ( (fword *)((unsigned long)(a) & ~(flash_size/8-1)) )

#define FLASH_EWRITE        (-1)    /* Cannot write */
#define FLASH_EERASE        (-2)    /* Cannot erase */
#define FLASH_EVERIFY       (-3)    /* Verify error */
#define FLASH_EUNKNOWN      (-4)    /* Unknown flash type */
#define FLASH_EMIX          (-5)    /* Don`t like mixed flashs */

extern long flash_size;
extern long flash_block_size;

extern long flash_identify(volatile void *);
extern char *flash_manufacturer(void);
extern char *flash_name(void);
extern int flash_read(volatile void *, void *, long);
extern int flash_write(volatile void *, void *, long);
extern int flash_block_erase(void *);
      
