This file is indexed.

/usr/include/gpsim/eeprom.h is in gpsim-dev 0.26.1-1.

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
/*
   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 EEPROM_H
#define EEPROM_H

#include <assert.h>

#include "gpsim_classes.h"
#include "registers.h"
#include "breakpoints.h"

class pic_processor;
class EEPROM;
class PIR_SET;
class INTCON;
class PIR;

//---------------------------------------------------------
// EECON1 - EE control register 1
//

class EECON1 : public sfr_register
{
public:
enum
{

 RD    = (1<<0),
 WR    = (1<<1),
 WREN  = (1<<2),
 WRERR = (1<<3),
 EEIF  = (1<<4),
 EEPGD = (1<<7)
};


  EECON1(Processor *pCpu, const char *pName, const char *pDesc);

  void put(unsigned int new_value);
  unsigned int get();

  inline void set_eeprom(EEPROM *ee) { eeprom = ee; }
  inline void set_valid_bits(unsigned int vb) { valid_bits = valid_bits; }
  inline unsigned int get_valid_bits() { return (valid_bits); }
  inline void set_bits(unsigned int b) { valid_bits |= b; }
  inline void clear_bits(unsigned int b) { valid_bits &= ~b; }


  //private:
  unsigned int valid_bits;
  EEPROM *eeprom;
};

const unsigned int EECON1_VALID_BITS = (EECON1::RD | EECON1::WR |
  EECON1::WREN | EECON1::EEIF);

//
// EECON2 - EE control register 2
//

class EECON2 : public sfr_register
{
public:

enum EE_STATES
{
  EENOT_READY,
  EEHAVE_0x55,
  EEREADY_FOR_WRITE,
  EEWRITE_IN_PROGRESS,
  EEUNARMED,
  EEREAD
};

  EECON2(Processor *pCpu, const char *pName, const char *pDesc);

  void put(unsigned int new_value);
  unsigned int get();
  void ee_reset() { eestate = EENOT_READY;};

  inline virtual void set_eeprom(EEPROM *ee) { eeprom = ee; }
  inline enum EE_STATES get_eestate() { return (eestate); }
  inline void unarm() { eestate = EEUNARMED; }
  inline void unready() { eestate = EENOT_READY; }
  inline void read() { eestate = EEREAD; }
  inline void start_write() { eestate = EEWRITE_IN_PROGRESS; }

  inline bool is_unarmed() { return (eestate == EEUNARMED); }
  inline bool is_not_ready() { return (eestate == EENOT_READY); }
  inline bool is_ready_for_write() {
    return (eestate == EEREADY_FOR_WRITE);
  }
  inline bool is_writing() { return (eestate == EEWRITE_IN_PROGRESS); }

  //private:
  EEPROM *eeprom;
  enum EE_STATES eestate;
};

//
// EEDATA - EE data register
//

class EEDATA : public sfr_register
{
public:

  EEDATA(Processor *pCpu, const char *pName, const char *pDesc);

  void put(unsigned int new_value);
  unsigned int get();
  virtual void set_eeprom(EEPROM *ee) { eeprom = ee; }

  //private:
  EEPROM *eeprom;

};

//
// EEADR - EE address register
//

class EEADR : public sfr_register
{
public:

  EEADR(Processor *pCpu, const char *pName, const char *pDesc);

  void put(unsigned int new_value);
  unsigned int get();

  virtual void set_eeprom(EEPROM *ee) { eeprom = ee; }

  //private:
  EEPROM *eeprom;
};


//------------------------------------------------------------------------
//------------------------------------------------------------------------

const int EPROM_WRITE_TIME = 20;

class EEPROM :  public TriggerObject
{
public:

  EEPROM(Processor *pCpu);
  ~EEPROM();
  void reset(RESET_TYPE);
  virtual void set_intcon(INTCON *ic);

  virtual void callback();
  virtual void callback_print(){ cout << " EEPROM\n";}
  virtual void start_write();
  virtual void write_is_complete();
  virtual void start_program_memory_read();  
  virtual void initialize(unsigned int new_rom_size);
  virtual Register *get_register(unsigned int address);
  virtual void save_state();

  inline virtual void change_rom(unsigned int offset, unsigned int val) {
    assert(offset < rom_size);
    rom[offset]->value.put(val);
  }

  inline int register_size() { return (rom_data_size); }
  inline void set_resister_size(int bytes) { rom_data_size = bytes; }
  inline virtual unsigned int get_rom_size() { return (rom_size); }
  // XXX might want to make get_rom a friend only to cli_dump
  inline virtual Register **get_rom() { return (rom); }

  inline virtual EECON1 *get_reg_eecon1() { return (&eecon1); }
  inline virtual EECON2 *get_reg_eecon2() { return (&eecon2); }
  inline virtual EEDATA *get_reg_eedata() { return (&eedata); }
  inline virtual EEADR *get_reg_eeadr() { return (&eeadr); }
  inline virtual EEADR *get_reg_eeadrh() { return 0; }  // No eeadrh on basic EEPROM

  void dump();

  //protected:
  char *name_str;
  Processor *cpu;
  INTCON *intcon;

  EECON1 eecon1;            // The EEPROM consists of 4 control registers
  EECON2 eecon2;            // on the F84 and 6 on the F877
  EEDATA eedata;
  EEADR  eeadr;

  Register **rom;           //  and the data area.
  RegisterCollection *m_UiAccessOfRom; // User access to the rom.

  int rom_data_size;		// data width in bytes
  unsigned int rom_size;
  unsigned int wr_adr,wr_data;  // latched adr and data for eewrites.
  unsigned int rd_adr;          // latched adr for eereads.
  unsigned int abp;             // break point number that's set during eewrites

protected:
  virtual unsigned int get_address(void)   { return eeadr.value.get(); };
};

/**
 *  A class for the EEPROM in later devices with PIR-mapped status. Some of
 *  these devices (e.g. 18F4620) have more than 256 bytes of EEPROM so this
 *  class implements the eeadrh register too. This will not be used if the
 *  EEPROM size is 256 or less.
 */
class EEPROM_PIR : public EEPROM
{
public:

  EEPROM_PIR(Processor *pCpu, PIR *);
  ~EEPROM_PIR();

  // the 16f628 eeprom is identical to the 16f84 eeprom except
  // for the size and the location of EEIF. The size is taken
  // care of when the '628 is constructed, the EEIF is taken
  // care of here:

  virtual void start_write();
  virtual void write_is_complete();
  virtual void callback();

  inline virtual EEADR *get_reg_eeadrh() { return (rom_size>256) ? (&eeadrh) : 0; }
  virtual void initialize(unsigned int new_rom_size);
  virtual void callback_print(){ cout << " EEPROM_PIR\n";}

protected:
  PIR *m_pir;

  EEADR  eeadrh;

  virtual unsigned int get_address(void)   
          { return (rom_size <= 256 ) ? eeadr.value.get() 
                    : (eeadrh.value.get()<<8)+eeadr.value.get(); };
};


class EEPROM_WIDE : public EEPROM_PIR
{
public:
  EEPROM_WIDE(Processor *pCpu, PIR *);
  ~EEPROM_WIDE();

  virtual void start_write();
  virtual void callback();
  virtual void callback_print(){ cout << " EEPROM_WIDE\n";}
  virtual void start_program_memory_read();
  virtual void initialize(unsigned int new_rom_size);

  inline virtual EEADR *get_reg_eeadrh() { return (&eeadrh); }
  inline virtual EEDATA *get_reg_eedatah() { return (&eedatah); }

  //protected:
  EEDATA eedatah;
};



#endif /* EEPROM_H */