Use 'ao-dbg' instead of 's51' to communicate with TeleMetrum
[fw/sdcc] / src / pic16 / device.h
index f24cb7a8237679bc26180b7505fbe4a8eeebbc20..40361ea0bb281d634d06856c004715011bd7a6df 100644 (file)
@@ -1,6 +1,7 @@
 /*-------------------------------------------------------------------------
 
-   device.c - Accomodates subtle variations in PIC16 devices
+  device.c - Accomodates subtle variations in PIC16 devices
+
    Written By -  Scott Dattalo scott@dattalo.com
 
    This program is free software; you can redistribute it and/or modify it
 #ifndef  __DEVICE_H__
 #define  __DEVICE_H__
 
-/* memRange - a structure to define a range of valid memory addresses 
- * 
- * The Memory of most PICs (and other micros) is a collection of
- * disjoint chunks. The memRange structure will define the start
- * and end address of one of these chunks. The memory map of a
- * particular device is a collection of memRange struct's.
- */
-
-typedef struct memRange {
-  int start_address;      /* first address in range */
-  int end_address;        /* last */
-  int alias;              /* bit mask defining how/if memory range is aliased 
-                          * e.g. alias = 0x80 means start_address is identical
-                          * to the memory location at (0x80 | start_address) */
-  int bank;               /* PIC memory bank this range occupies */
-
-} memRange;
-
-/* AssignedMemory - A structure to keep track of the memory that has been used.
- *
- * When a register gets assigned an address this struct is used to
- * keep track of a few details about the register. There is one of
- * these structures for each memory location in the device.
- */
-
-typedef struct AssignedMemory {
-  regs *reg;        /* Pointer to the register (NULL if this is an invalid address) */
-  int  instance;    /* the i'th byte of a multibyte register */
-  int  alias;       /* Bit mapping of aliased addresses (see memRange) */
-  int  bank;        /* Memory bank of this register */
-  int  isValid:1;   /* True if the address is legal */
-  int  isSFR:1;     /* True if the address is that of a Special Function reg */
-  int  isEmitted:1; /* True if the register has been written to a cBlock */
-
-} AssignedMemory;
+#define CONFIGURATION_WORDS     20
+#define IDLOCATION_BYTES        20
 
+typedef struct {
+  unsigned int mask;
+  int emit;
+  unsigned int value;
+  unsigned int andmask;
+} configRegInfo_t;
 
-/*
- * pic16_finalMapping - Dynamically allocated array that records the register assignments
- */
+typedef struct {
+  int confAddrStart;      /* starting address */
+  int confAddrEnd;        /* ending address */
+  configRegInfo_t crInfo[ CONFIGURATION_WORDS ];
+} configWordsInfo_t;
 
-extern AssignedMemory *pic16_finalMapping;
-#define PROCESSOR_NAMES    4
-/* Processor unique attributes */
-typedef struct PIC_device {
-  char *name[PROCESSOR_NAMES];/* aliases for the processor name */
+typedef struct {
+  unsigned char emit;
+  unsigned char value;
+} idRegInfo_t;
 
-  memRange *ram;              /* RAM memory map */
-  memRange *sfr;              /* SFR memory map */
+typedef struct {
+  int idAddrStart;        /* starting ID address */
+  int idAddrEnd;          /* ending ID address */
+  idRegInfo_t irInfo[ IDLOCATION_BYTES ];
+} idBytesInfo_t;
 
-  int maxRAMaddress;          /* maximum value for a data address */
-  int bankMask;               /* Bitmask that is ANDed with address to extract banking bits */
-  //  int hasAliasedRAM:1;        /* True if there are bank independent registers */
 
-} PIC_device;
+#define PROCESSOR_NAMES    4
+/* Processor unique attributes */
+typedef struct PIC16_device {
+  char *name[PROCESSOR_NAMES];  /* aliases for the processor name */
+  /* RAMsize *must* be the first item to copy for 'using' */
+  int RAMsize;                  /* size of Data RAM - VR 031120 */
+  int acsSplitOfs;              /* access bank split offset */
+  configWordsInfo_t cwInfo;     /* configuration words info */
+  idBytesInfo_t idInfo;         /* ID Locations info */
+  /* next *must* be the first field NOT being copied via 'using' */
+  struct PIC16_device *next;    /* linked list */
+} PIC16_device;
+
+extern PIC16_device *pic16;
 
 /* Given a pointer to a register, this macro returns the bank that it is in */
 #define REG_ADDR(r)        ((r)->isBitField ? (((r)->address)>>3) : (r)->address)
-#define REG_BANK(r)        (pic16_finalMapping[REG_ADDR(r)].bank)
-#define REG_isALIASED(r)   (pic16_finalMapping[REG_ADDR(r)].alias != 0)
-#define REG_isVALID(r)     (pic16_finalMapping[REG_ADDR(r)].isValid)
 
+#define OF_LR_SUPPORT           0x00000001
+#define OF_NO_OPTIMIZE_GOTO     0x00000002
+#define OF_OPTIMIZE_CMP         0x00000004
+#define OF_OPTIMIZE_DF          0x00000008
+
+typedef struct {
+  int no_banksel;
+  int opt_banksel;
+  int omit_configw;
+  int omit_ivt;
+  int leave_reset;
+  int stack_model;
+  int ivt_loc;
+  int nodefaultlibs;
+  int dumpcalltree;
+  char *crt_name;
+  int no_crt;
+  int ip_stack;
+  unsigned long opt_flags;
+  int gstack;
+  unsigned int debgen;
+  int xinst;
+} pic16_options_t;
+
+extern pic16_options_t pic16_options;
+
+#define STACK_MODEL_SMALL       (pic16_options.stack_model == 0)
+#define STACK_MODEL_LARGE       (pic16_options.stack_model == 1)
+
+extern set *fix_idataSymSet;
+extern set *rel_idataSymSet;
+
+#if 0
+/* This is an experimental code for #pragma inline
+   and is temporarily disabled for 2.5.0 release */
+extern set *asmInlineMap;
+#endif  /* 0 */
+
+typedef struct {
+  unsigned long isize;
+  unsigned long adsize;
+  unsigned long udsize;
+  unsigned long idsize;
+  unsigned long intsize;
+} stats_t;
+
+extern stats_t statistics;
 
 /****************************************/
-void pic16_assignConfigWordValue(int address, int value);
-int pic16_getConfigWord(int address);
+void pic16_assignConfigWordValue(int address, unsigned int value);
+void pic16_assignIdByteValue(int address, char value);
 int pic16_isREGinBank(regs *reg, int bank);
 int pic16_REGallBanks(regs *reg);
-void pic16_addMemRange(memRange *r, int type);
-void pic16_setMaxRAM(int size);
+
+int checkAddReg(set **set, regs *reg);
+int checkAddSym(set **set, symbol *reg);
+int checkSym(set *set, symbol *reg);
 
 #endif  /* __DEVICE_H__ */
+