OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [Open8 Tools/] [open8_src/] [open8_link/] [memory.c] - Blame information for rev 279

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 178 jshamlet
 
2
#include <ctype.h>
3
#include <stdio.h>
4
#include <stdlib.h>
5
#include <string.h>
6
 
7
#include "defines.h"
8
#include "files.h"
9
 
10
 
11
 
12
extern unsigned char *rom, *rom_usage;
13
extern int romsize, banksize, section_overwrite;
14
extern int pc_bank, pc_full, pc_slot, pc_slot_max;
15
extern struct object_file *obj_tmp;
16
 
17
int memory_file_id, memory_file_id_source, memory_line_number;
18
 
19
 
20
 
21
int mem_insert(int address, unsigned char data) {
22
 
23
  if (rom[address] == data) {
24
    rom_usage[address]++;
25
    return SUCCEEDED;
26
  }
27
  if (rom_usage[address] != 0)
28
    fprintf(stderr, "%s: MEM_INSERT: Overwrite at $%x (old $%.2x new $%.2x).\n", get_file_name(memory_file_id), address, rom[address], data);
29
 
30
  rom_usage[address]++;
31
  rom[address] = data;
32
 
33
  return SUCCEEDED;
34
}
35
 
36
 
37
int mem_insert_ref(int address, unsigned char data) {
38
 
39
  if (address > romsize || address < 0) {
40
    fprintf(stderr, "%s:%s:%d: MEM_INSERT: Address $%x is out of the output range $0-$%x.\n",
41
            get_file_name(memory_file_id), get_source_file_name(memory_file_id, memory_file_id_source), memory_line_number, address, romsize);
42
    return FAILED;
43
  }
44
  if (rom_usage[address] > 1 && rom[address] != data) {
45
    if (memory_line_number != 0)
46
      fprintf(stderr, "%s:%s:%d: MEM_INSERT: Overwrite at $%x (old $%.2x new $%.2x).\n",
47
              get_file_name(memory_file_id), get_source_file_name(memory_file_id, memory_file_id_source), memory_line_number, address, rom[address], data);
48
    else
49
      fprintf(stderr, "%s:%s:[WLA]: MEM_INSERT: Overwrite at $%x (old $%.2x new $%.2x).\n",
50
              get_file_name(memory_file_id), get_source_file_name(memory_file_id, memory_file_id_source), address, rom[address], data);
51
  }
52
 
53
  rom_usage[address]++;
54
  rom[address] = data;
55
 
56
  return SUCCEEDED;
57
}
58
 
59
 
60
int mem_insert_pc(unsigned char d, int slot_current, int bank_current) {
61
 
62
  if (pc_slot >= pc_slot_max) {
63
    fprintf(stderr, "%s: MEM_INSERT: Overflow from slot %d.\n", get_file_name(memory_file_id), slot_current);
64
    return FAILED;
65
  }
66
  if (pc_bank >= banksize) {
67
    fprintf(stderr, "%s: MEM_INSERT: Overflow from bank %d.\n", get_file_name(memory_file_id), bank_current);
68
    return FAILED;
69
  }
70
  if (rom_usage[pc_full] != 0 && rom[pc_full] != d && section_overwrite == OFF)
71
    fprintf(stderr, "%s: MEM_INSERT: Overwrite at $%x, old $%x new $%x\n", get_file_name(memory_file_id), pc_full, rom[pc_full], d);
72
 
73
  if (section_overwrite == OFF)
74
    rom_usage[pc_full]++;
75
  rom[pc_full] = d;
76
  pc_slot++;
77
  pc_bank++;
78
  pc_full++;
79
 
80
  return SUCCEEDED;
81
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.