/usr/include/gpsim/intcon.h is in gpsim-dev 0.29.0-2+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | /*
Copyright (C) 1998-2003 Scott Dattalo
2003 Mike Durian
This file is part of the libgpsim library of gpsim
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see
<http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
#ifndef INTCON_H
#define INTCON_H
#include <iostream> // for cout used in breakpoints.h
#include "gpsim_classes.h"
#include "registers.h"
#include "breakpoints.h"
#include "pic-ioports.h"
class IOCxF;
class PicPortGRegister;
//---------------------------------------------------------
// INTCON - Interrupt control register
class INTCON : public sfr_register
{
public:
unsigned int interrupt_trace;
bool in_interrupt;
enum
{
RBIF = 1<<0,
INTF = 1<<1,
T0IF = 1<<2,
RBIE = 1<<3,
INTE = 1<<4,
T0IE = 1<<5,
XXIE = 1<<6, // Processor dependent
GIE = 1<<7
};
INTCON(Processor *pCpu, const char *pName, const char *pDesc);
virtual void set_gie()
{
put(value.get() | GIE);
}
virtual void clear_gie()
{
put(value.get() & ~GIE);
}
void set_T0IF();
/*
// Bit 6 of intcon depends on the processor that's being simulated,
// This generic function will get called whenever interrupt flag upon
// which bit 6 enables becomes true. (e.g. for the c84, this
// routine is called when EEIF goes high.)
*/
virtual void peripheral_interrupt ( bool hi_pri = false );
virtual void set_rbif(bool b);
inline void set_intf(bool b)
{
bool current = (value.get() & INTF) == INTF;
if (b && !current)
put(value.get() | INTF);
if (!b && current)
put(value.get() & ~INTF);
}
inline void set_t0if()
{
put(value.get() | T0IF);
}
inline void set_rbie()
{
put(value.get() | RBIE);
}
inline void set_inte()
{
put(value.get() | INTE);
}
inline void set_t0ie()
{
put(value.get() | T0IE);
}
void set_portGReg( PicPortGRegister *_portGReg)
{
portGReg = _portGReg;
}
virtual int check_peripheral_interrupt()=0;
virtual void put(unsigned int new_value);
virtual void put_value(unsigned int new_value);
virtual void aocxf_val(IOCxF *, unsigned int val){}
PicPortGRegister *portGReg;
};
//---------------------------------------------------------
class INTCON2 : public sfr_register
{
public:
INTCON2(Processor *pCpu, const char *pName, const char *pDesc);
virtual void put_value(unsigned int new_value);
virtual void put(unsigned int new_value);
virtual bool assignBitSink(unsigned int bitPosition, BitSink *);
virtual bool releaseBitSink(unsigned int bitPosition, BitSink *);
enum
{
RBIP = 1<<0,
INT3IP = 1<<1,
TMR0IP = 1<<2,
INTEDG3 = 1<<3,
INTEDG2 = 1<<4,
INTEDG1 = 1<<5,
INTEDG0 = 1<<6,
RBPU = 1<<7
};
private:
BitSink *m_bsRBPU;
};
class INTCON3 : public sfr_register
{
public:
INTCON3(Processor *pCpu, const char *pName, const char *pDesc);
virtual void put_value(unsigned int new_value);
virtual void put(unsigned int new_value);
inline void set_int1f(bool b)
{
bool current = (value.get() & INT1IF) == INT1IF;
if (b && !current)
put(value.get() | INT1IF);
if (!b && current)
put(value.get() & ~INT1IF);
}
inline void set_int2f(bool b)
{
bool current = (value.get() & INT2IF) == INT2IF;
if (b && !current)
put(value.get() | INT2IF);
if (!b && current)
put(value.get() & ~INT2IF);
}
inline void set_int3f(bool b)
{
bool current = (value.get() & INT3IF) == INT3IF;
if (b && !current)
put(value.get() | INT3IF);
if (!b && current)
put(value.get() & ~INT3IF);
}
inline void set_int1e()
{
put(value.get() | INT1IE);
}
inline void set_int2e()
{
put(value.get() | INT2IE);
}
inline void set_int3e()
{
put(value.get() | INT3IE);
}
enum
{
INT1IF = 1<<0,
INT2IF = 1<<1,
INT3IF = 1<<2,
INT1IE = 1<<3,
INT2IE = 1<<4,
INT3IE = 1<<5,
INT1IP = 1<<6,
INT2IP = 1<<7
};
};
class PIR_SET;
// A 14-bit intcon with pir registers
class INTCON_14_PIR : public INTCON
{
public:
INTCON_14_PIR(Processor *pCpu, const char *pName, const char *pDesc);
virtual void put(unsigned int new_value);
virtual void put_value(unsigned int new_value);
inline void set_pir_set(PIR_SET *p) { pir_set = p; }
virtual int check_peripheral_interrupt();
virtual void set_rbif(bool b);
virtual void set_gie() { put_value(value.get() | GIE); }
virtual void clear_gie() { put_value(value.get() & ~GIE); }
virtual void aocxf_val(IOCxF *, unsigned int val);
enum
{
IOCIF = 1<<0,
INTF = 1<<1,
T0IF = 1<<2,
IOCIE = 1<<3,
INTE = 1<<4,
T0IE = 1<<5,
PEIE = 1<<6,
GIE = 1<<7
};
//private:
PIR_SET *pir_set;
unsigned int write_mask; // Bits that instructions can modify
struct aocxf
{
struct IOCxF *ptr_iocxf;
unsigned int val;
};
vector<aocxf>aocxf_list;
};
//---------------------------------------------------------
// INTCON_16 - Interrupt control register for the 16-bit core
class RCON;
class INTCON_16 : public INTCON
{
public:
enum {
GIEH = GIE,
GIEL = XXIE,
TMR0IE = T0IE,
INT0IE = INTE,
TMR0IF = T0IF,
INT0IF = INTF
};
#define INTERRUPT_VECTOR_LO (0x18 >> 1)
#define INTERRUPT_VECTOR_HI (0x08 >> 1)
INTCON_16(Processor *pCpu, const char *pName, const char *pDesc);
inline void set_rcon(RCON *r) { rcon = r; }
inline void set_intcon2(INTCON2 *ic) { intcon2 = ic; }
inline void set_pir_set(PIR_SET *p) { pir_set = p; }
virtual void put(unsigned int new_value);
virtual void put_value(unsigned int new_value);
virtual void peripheral_interrupt ( bool hi_pri = false );
void clear_gies();
void set_gies();
virtual int check_peripheral_interrupt();
unsigned int get_interrupt_vector()
{
return interrupt_vector;
}
bool isHighPriorityInterrupt()
{
return ( interrupt_vector == INTERRUPT_VECTOR_HI );
}
void set_interrupt_vector(unsigned int new_int_vect)
{
interrupt_vector = new_int_vect;
}
private:
unsigned int interrupt_vector; // Starting address of the interrupt
RCON *rcon;
INTCON2 *intcon2;
PIR_SET *pir_set;
};
#endif /* INTCON_H */
|