Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-------------------------------------------------------------------------*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "common.h" // Include everything in the SDCC src directory
-#include "newalloc.h"
-
-
-#include "main.h"
-#include "pcode.h"
-#include "ralloc.h"
#include "device.h"
-extern int Gstack_base_addr;
-extern int Gstack_size;
+/*
+ * Imports
+ */
+extern set *includeDirsSet;
+extern set *userIncDirsSet;
+extern set *libDirsSet;
+extern set *libPathsSet;
#define MAX_PICLIST 200
static PIC_device *Pics[MAX_PICLIST];
+static PIC_device *pic = NULL;
static int num_of_supported_PICS = 0;
-
-static PIC_device *pic=NULL;
-
-int maxRAMaddress = 0;
+static int maxRAMaddress = 0;
#define CONFIG_WORD_ADDRESS 0x2007
#define CONFIG2_WORD_ADDRESS 0x2008
#define PIC14_STRING_LEN 256
#define SPLIT_WORDS_MAX 16
+/* Keep track of whether we found an assignment to the __config words. */
+static int pic14_hasSetConfigWord = 0;
static unsigned int config_word = DEFAULT_CONFIG_WORD;
static unsigned int config2_word = DEFAULT_CONFIG2_WORD;
static memRange *rangeRAM = NULL;
rangeRAM = r;
}
-extern set *includeDirsSet;
-extern set *userIncDirsSet;
-extern set *libDirsSet;
-extern set *libPathsSet;
+static void setMaxRAM(int size)
+{
+ maxRAMaddress = size;
+
+ if (maxRAMaddress < 0) {
+ fprintf(stderr, "invalid maxram 0x%x setting in %s\n",
+ maxRAMaddress, DEVICE_FILE_NAME);
+ return;
+ }
+}
/* read the file with all the pic14 definitions and pick out the definition
* for a processor if specified. if pic_name is NULL reads everything */
return NULL;
}
-void setMaxRAM(int size)
-{
- maxRAMaddress = size;
-
- if (maxRAMaddress < 0) {
- fprintf(stderr, "invalid maxram 0x%x setting in %s\n",
- maxRAMaddress, DEVICE_FILE_NAME);
- return;
- }
-}
-
-/*-----------------------------------------------------------------*
-*-----------------------------------------------------------------*/
-
-int isREGinBank(regs *reg, int bank)
-{
-
- if(!reg || !pic)
- return 0;
-
- if((int)((reg->address | reg->alias) & pic->bankMask & bank) == bank)
- return 1;
-
- return 0;
-}
-
-/*-----------------------------------------------------------------*
-*-----------------------------------------------------------------*/
-int REGallBanks(regs *reg)
-{
-
- if(!reg || !pic)
- return 0;
-
- return ((reg->address | reg->alias) & pic->bankMask);
-
-}
-
/*-----------------------------------------------------------------*
* void list_valid_pics(int ncols, int list_alias)
*
* list_alias - if non-zero, print all of the supported aliases
* for a device (e.g. F84, 16F84, etc...)
*-----------------------------------------------------------------*/
-void list_valid_pics(int ncols)
+static void list_valid_pics(int ncols)
{
int col=0,longest;
int i,k,l;
return pic->name;
}
+#if 0
/*-----------------------------------------------------------------*
*-----------------------------------------------------------------*/
-int validAddress(int address, int reg_size)
+static int validAddress(int address, int reg_size)
{
if (maxRAMaddress < 0) {
fprintf(stderr, "missing maxram setting in %s\n", DEVICE_FILE_NAME);
return 1;
}
+#endif
#if 0
/* The following code should be (and is) implemented in the linker. */
}
#endif
-/* Keep track of whether we found an assignment to the __config words. */
-static int pic14_hasSetConfigWord = 0;
+int IS_CONFIG_ADDRESS(int address)
+{
+
+ return ((address == CONFIG_WORD_ADDRESS)
+ || (address == CONFIG2_WORD_ADDRESS));
+}
/*-----------------------------------------------------------------*
- * void assignConfigWordValue(int address, int value)
+ * void pic14_assignConfigWordValue(int address, int value)
*
* Most midrange PICs have one config word at address 0x2007.
* Newer PIC14s have a second config word at address 0x2008.
pic14_hasSetConfigWord = 1;
}
-/*-----------------------------------------------------------------*
- * int pic14_emitConfigWord (FILE * vFile)
- *
- * Emit the __config directives iff we found a previous assignment
- * to the config word.
- *-----------------------------------------------------------------*/
-extern char *iComments2;
-int pic14_emitConfigWord (FILE * vFile)
-{
- if (pic14_hasSetConfigWord)
- {
- fprintf (vFile, "%s", iComments2);
- fprintf (vFile, "; config word \n");
- fprintf (vFile, "%s", iComments2);
- if (pic14_getHasSecondConfigReg())
- {
- fprintf (vFile, "\t__config _CONFIG1, 0x%x\n", pic14_getConfigWord(0x2007));
- fprintf (vFile, "\t__config _CONFIG2, 0x%x\n", pic14_getConfigWord(0x2008));
- }
- else
- fprintf (vFile, "\t__config 0x%x\n", pic14_getConfigWord(0x2007));
-
- return 1;
- }
- return 0;
-}
-
/*-----------------------------------------------------------------*
* int pic14_getConfigWord(int address)
*
*
*-----------------------------------------------------------------*/
-int pic14_getConfigWord(int address)
+static int pic14_getConfigWord(int address)
{
switch (address)
{
}
}
+#if 0
/*-----------------------------------------------------------------*
*
*-----------------------------------------------------------------*/
-unsigned pic14_getMaxRam(void)
+static unsigned pic14_getMaxRam(void)
{
- return pic->defMaxRAMaddrs;
+ return pic->defMaxRAMaddrs;
}
-
+#endif
/*-----------------------------------------------------------------*
* int getHasSecondConfigReg(void) - check if the device has a
* second config register, rather than just one.
*-----------------------------------------------------------------*/
-int pic14_getHasSecondConfigReg(void)
+static int pic14_getHasSecondConfigReg(void)
{
if(!pic)
return 0;
return pic->hasSecondConfigReg;
}
+/*-----------------------------------------------------------------*
+ * int pic14_emitConfigWord (FILE * vFile)
+ *
+ * Emit the __config directives iff we found a previous assignment
+ * to the config word.
+ *-----------------------------------------------------------------*/
+int pic14_emitConfigWord (FILE * vFile)
+{
+ if (pic14_hasSetConfigWord)
+ {
+ fprintf (vFile, "%s", iComments2);
+ fprintf (vFile, "; config word \n");
+ fprintf (vFile, "%s", iComments2);
+ if (pic14_getHasSecondConfigReg())
+ {
+ fprintf (vFile, "\t__config _CONFIG1, 0x%x\n", pic14_getConfigWord(0x2007));
+ fprintf (vFile, "\t__config _CONFIG2, 0x%x\n", pic14_getConfigWord(0x2008));
+ }
+ else
+ fprintf (vFile, "\t__config 0x%x\n", pic14_getConfigWord(0x2007));
+
+ return 1;
+ }
+ return 0;
+}
+
/*-----------------------------------------------------------------*
* True iff the device has memory aliased in every bank.
* If true, low and high will be set to the low and high address
* occupied by the (last) sharebank found.
*-----------------------------------------------------------------*/
-int pic14_hasSharebank(int *low, int *high, int *size)
+static int pic14_hasSharebank(int *low, int *high, int *size)
{
memRange *r;
/*
* True iff the memory region [low, high] is aliased in all banks.
*/
-int pic14_isShared(int low, int high)
+static int pic14_isShared(int low, int high)
{
memRange *r;