+
+ r = Safe_calloc(1, sizeof(memRange));
+ //fprintf (stderr, "%s: %s %s %s\n", __FUNCTION__, word[1], word[2], word[3]);
+
+ r->start_address = parse_config_value(word[1]);
+ r->end_address = parse_config_value(word[2]);
+ r->alias = parse_config_value(word[3]);
+ r->bank = (r->start_address >> 7) & 3;
+
+ // add memRange to device entry for future lookup (sharebanks)
+ r->next = rangeRAM;
+ rangeRAM = r;
+}
+
+extern set *includeDirsSet;
+extern set *userIncDirsSet;
+extern set *libDirsSet;
+extern set *libPathsSet;
+
+/* 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 */
+static PIC_device *find_device(char *pic_name)
+{
+ FILE *pic_file;
+ char pic_buf[PIC14_STRING_LEN];
+ char *pic_buf_pos;
+ int found_processor = FALSE;
+ int done = FALSE;
+ char processor_name[SPLIT_WORDS_MAX][PIC14_STRING_LEN];
+ int num_processor_names = 0;
+ int pic_maxram = 0;
+ int pic_bankmsk = 0;
+ int pic_confsiz = 0;
+ int pic_program = 0;
+ int pic_data = 0;
+ int pic_eeprom = 0;
+ int pic_io = 0;
+ char *simple_pic_name;
+ char *dir;
+ char filename[512];
+ int len = 512;
+
+ /* allow abbreviations of the form "f877" - convert to "16f877" */
+ simple_pic_name = sanitise_processor_name(pic_name);
+ num_of_supported_PICS = 0;
+
+ /* open the piclist file */
+ /* first scan all include directories */
+ pic_file = NULL;
+ //fprintf( stderr, "%s: searching %s\n", __FUNCTION__, DEVICE_FILE_NAME );
+ for (dir = setFirstItem(includeDirsSet);
+ !pic_file && dir;
+ dir = setNextItem(includeDirsSet))
+ {
+ //fprintf( stderr, "searching1 %s\n", dir );
+ SNPRINTF(&filename[0], len, "%s%s%s", dir, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME);
+ pic_file = fopen( filename, "rt" );
+ if (pic_file) break;
+ } // for
+ for (dir = setFirstItem(userIncDirsSet);
+ !pic_file && dir;
+ dir = setNextItem(userIncDirsSet))
+ {
+ //fprintf( stderr, "searching2 %s\n", dir );
+ SNPRINTF(&filename[0], len, "%s%s%s", dir, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME);
+ pic_file = fopen( filename, "rt" );
+ if (pic_file) break;
+ } // for
+ for (dir = setFirstItem(libDirsSet);
+ !pic_file && dir;
+ dir = setNextItem(libDirsSet))
+ {
+ //fprintf( stderr, "searching3 %s\n", dir );
+ SNPRINTF(&filename[0], len, "%s%s%s", dir, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME);
+ pic_file = fopen( filename, "rt" );
+ if (pic_file) break;
+ } // for
+ for (dir = setFirstItem(libPathsSet);
+ !pic_file && dir;
+ dir = setNextItem(libPathsSet))
+ {
+ //fprintf( stderr, "searching4 %s\n", dir );
+ SNPRINTF(&filename[0], len, "%s%s%s", dir, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME);
+ pic_file = fopen( filename, "rt" );
+ if (pic_file) break;
+ } // for
+ if (!pic_file) {
+ pic_file = fopen(DATADIR LIB_DIR_SUFFIX DIR_SEPARATOR_STRING "pic" DIR_SEPARATOR_STRING DEVICE_FILE_NAME, "rt");
+ }
+ if (pic_file == NULL) {
+ /* this second attempt is used when initially building the libraries */
+ pic_file = fopen(".." DIR_SEPARATOR_STRING ".." DIR_SEPARATOR_STRING ".." DIR_SEPARATOR_STRING ".."
+ DIR_SEPARATOR_STRING "src" DIR_SEPARATOR_STRING "pic" DIR_SEPARATOR_STRING
+ DEVICE_FILE_NAME, "rt");
+ if (pic_file == NULL) {
+ fprintf(stderr, "can't find %s\n", DATADIR LIB_DIR_SUFFIX DIR_SEPARATOR_STRING "pic"
+ DIR_SEPARATOR_STRING DEVICE_FILE_NAME);
+ return NULL;
+ }
+ }