2
* $Id: storage.h,v 1.6 2003/12/02 08:25:00 troth Exp $
4
****************************************************************************
6
* simulavr - A simulator for the Atmel AVR family of microcontrollers.
7
* Copyright (C) 2001, 2002, 2003 Theodore A. Roth
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
****************************************************************************
29
/***************************************************************************\
31
* Storage(AvrClass) Object
33
\***************************************************************************/
35
typedef struct _Storage Storage;
40
int base; /* address */
45
extern Storage *storage_new (int base, int size);
46
extern void storage_construct (Storage *stor, int base, int size);
47
extern void storage_destroy (void *stor);
50
storage_readb (Storage *stor, int addr)
52
int _addr = addr - stor->base;
55
avr_error ("passed null ptr");
57
if ((_addr < 0) || (_addr >= stor->size))
58
avr_error ("address out of bounds: 0x%x", addr);
60
return stor->data[_addr];
63
extern inline uint16_t
64
storage_readw (Storage *stor, int addr)
66
int _addr = addr - stor->base;
70
avr_error ("passed null ptr");
72
if ((_addr < 0) || (_addr >= stor->size))
73
avr_error ("address out of bounds: 0x%x", addr);
75
bh = stor->data[_addr];
76
bl = stor->data[_addr + 1];
78
return (uint16_t) ((bh << 8) | bl);
81
extern void storage_writeb (Storage *stor, int addr, uint8_t val);
82
extern void storage_writew (Storage *stor, int addr, uint16_t val);
84
extern int storage_get_size (Storage *stor);
85
extern int storage_get_base (Storage *stor);
87
#endif /* SIM_STORAGE_H */