1 /* Definitions to support devices that are memory-mapped into the CPU's 2 address space. 3 Copyright 2001, 2003 Brian R. Gaeke. 4 Copyright 2002 Paul Twohey. 5 6 This file is part of VMIPS. 7 8 VMIPS is free software; you can redistribute it and/or modify it 9 under the terms of the GNU General Public License as published by the 10 Free Software Foundation; either version 2 of the License, or (at your 11 option) any later version. 12 13 VMIPS is distributed in the hope that it will be useful, but 14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 for more details. 17 18 You should have received a copy of the GNU General Public License along 19 with VMIPS; if not, write to the Free Software Foundation, Inc., 20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 21 22 #ifndef _DEVICEMAP_H_ 23 #define _DEVICEMAP_H_ 24 25 #include "range.h" 26 27 /* Physical memory map for a device supporting memory-mapped I/O. This is 28 * an abstract class. 29 */ 30 class DeviceMap : public Range { 31 protected: DeviceMap()32 DeviceMap() : Range(0, 0, 0, 0) { } DeviceMap(uint32 _extent)33 DeviceMap(uint32 _extent) : Range(0, _extent, 0, 0) { } 34 35 public: 36 /* Fetch word at byte offset OFFSET as part of load type MODE, which 37 can be either DATALOAD or INSTFETCH (defined in accesstypes.h). 38 CLIENT is responsible for handling any exceptions the fetch 39 may generate. */ 40 virtual uint32 fetch_word(uint32 offset, int mode, DeviceExc *client) = 0; 41 42 /* Fetch halfword at byte offset OFFSET as part of a DATALOAD. CLIENT 43 is responsible for handling any exceptions the fetch may generate. 44 By default, calls fetch_word() and masks off the result. */ 45 virtual uint16 fetch_halfword(uint32 offset, DeviceExc *client); 46 47 /* Fetch byte at byte offset OFFSET as part of a DATALOAD. CLIENT is 48 responsible for handling any exceptions the fetch may generate. By 49 default, calls fetch_word() and masks off the result. */ 50 virtual uint8 fetch_byte(uint32 offset, DeviceExc *client); 51 52 /* Store word DATA at byte offset OFFSET as part of a DATASTORE. 53 CLIENT is responsible for handling any exceptions the store may 54 generate. */ 55 virtual void store_word(uint32 offset,uint32 data,DeviceExc *client) = 0; 56 57 /* Store halfword DATA at byte offset OFFSET as part of a DATASTORE. 58 Client is responsible for handling any exceptions the store may 59 generate. By default, calls store_word() with a zeroed data word 60 with DATA in the appropriate halfword. */ 61 virtual void store_halfword(uint32 offset, uint16 data, DeviceExc *client); 62 63 /* Store byte DATA at byte offset OFFSET as part of a DATASTORE. 64 Client is responsible for handing any exceptions the store may 65 generate. By default, calls store_word() with a zeroed data word 66 with DATA in the appropriate byte. */ 67 virtual void store_byte(uint32 offset, uint8 data, DeviceExc *client); 68 69 /* It should not ordinarily be necessary for DeviceMap ranges to 70 override these functions, except in the case where a device's mapped 71 memory is properly conceived of as being either totally or 72 partially read-only. See the definitions in class Range for details. */ 73 virtual bool canRead(uint32 offset); 74 virtual bool canWrite(uint32 offset); 75 }; 76 77 #endif /* _DEVICEMAP_H_ */ 78