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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [sim/] [scarts_32/] [scarts_32-mad.c] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 jlechner
/* SCARTS (32-bit) target-dependent code for the GNU simulator.
2
   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3
   Free Software Foundation, Inc.
4
   Contributed by Martin Walter <mwalter@opencores.org>
5
 
6
   This file is part of the GNU simulators.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
 
21
 
22
#include <stdlib.h>
23
#include "gdb/sim-scarts_32.h"
24
#include "modules.h"
25
#include "scarts_32-tdep.h"
26
#include "scarts_32-bootmem.h"
27
#include "scarts_32-mad.h"
28
#include "scarts_32-plugins.h"
29
 
30
enum scarts_mem_type
31
scarts_codemem_vma_decode (uint32_t vma,
32
                           scarts_codemem_read_fptr_t *read_fptr,
33
                           scarts_codemem_write_fptr_t *write_fptr,
34
                           uint32_t *addr)
35
{
36
  *addr = 0;
37
  *read_fptr = NULL;
38
  *write_fptr = NULL;
39
 
40
  if ((vma >= SCARTS_BOOTMEM_VMA) && (vma < SCARTS_BOOTMEM_VMA + SCARTS_BOOTMEM_SIZE * SCARTS_INSN_SIZE))
41
  {
42
    *read_fptr = &scarts_bootmem_read;
43
    *write_fptr = &scarts_bootmem_write;
44
 
45
    /* The PC counts in bytes, whereas instructions
46
     * are stored in chunks of SCARTS_INSN_SIZE bytes. */
47
    *addr = (vma - SCARTS_BOOTMEM_VMA) / SCARTS_INSN_SIZE;
48
    return SCARTS_BOOTMEM;
49
  }
50
  else if ((vma >= SCARTS_CODEMEM_VMA) && (vma < SCARTS_CODEMEM_VMA + SCARTS_CODEMEM_SIZE * SCARTS_INSN_SIZE))
51
  {
52
    *read_fptr = &scarts_codemem_read;
53
    *write_fptr = &scarts_codemem_write;
54
 
55
    /* The PC counts in bytes, whereas instructions
56
     * are stored in chunks of SCARTS_INSN_SIZE bytes. */
57
    *addr = (vma - SCARTS_CODEMEM_VMA) / SCARTS_INSN_SIZE;
58
    return SCARTS_CODEMEM;
59
  }
60
  else
61
    return SCARTS_NOMEM;
62
}
63
 
64
enum scarts_mem_type
65
scarts_datamem_vma_decode (uint32_t vma,
66
                           scarts_datamem_read_fptr_t *read_fptr,
67
                           scarts_datamem_write_fptr_t *write_fptr,
68
                           uint32_t *addr)
69
{
70
  uint32_t plugin_addr, plugin_size;
71
  scarts_plugin_t *plugin;
72
 
73
  *addr = 0;
74
  *read_fptr = NULL;
75
  *write_fptr = NULL;
76
 
77
  if ((vma >= SCARTS_DATAMEM_VMA) && (vma < SCARTS_DATAMEM_VMA + SCARTS_DATAMEM_SIZE))
78
  {
79
    *read_fptr = &scarts_datamem_read;
80
    *write_fptr = &scarts_datamem_write;
81
    *addr = vma - SCARTS_DATAMEM_VMA;
82
    return SCARTS_DATAMEM;
83
  }
84
  else
85
  {
86
    plugin = scarts_get_plugin (vma);
87
    if (plugin != NULL)
88
    {
89
      plugin->get_mem_map (&plugin_addr, &plugin_size);
90
      *read_fptr = plugin->mem_read;
91
      *write_fptr = plugin->mem_write;
92
      *addr = vma - plugin_addr;
93
      return SCARTS_PLUGIN;
94
    }
95
  }
96
 
97
  return SCARTS_NOMEM;
98
}
99
 
100
enum scarts_mem_type
101
scarts_lma_decode (uint32_t lma,
102
                   scarts_codemem_read_fptr_t *codemem_read_fptr,
103
                   scarts_codemem_write_fptr_t *codemem_write_fptr,
104
                   scarts_datamem_read_fptr_t *datamem_read_fptr,
105
                   scarts_datamem_write_fptr_t *datamem_write_fptr,
106
                   uint32_t *addr)
107
{
108
  uint32_t vma;
109
 
110
  *addr = 0;
111
  *codemem_read_fptr = NULL;
112
  *codemem_write_fptr = NULL;
113
  *datamem_read_fptr = NULL;
114
  *datamem_write_fptr = NULL;
115
 
116
  if (lma >= SCARTS_CODEMEM_LMA)
117
  {
118
    vma = lma - SCARTS_CODEMEM_LMA + SCARTS_CODEMEM_VMA;
119
    return scarts_codemem_vma_decode (vma, codemem_read_fptr, codemem_write_fptr, addr);
120
  }
121
  else
122
  {
123
    vma = lma - SCARTS_DATAMEM_LMA + SCARTS_DATAMEM_VMA;
124
    return scarts_datamem_vma_decode (vma, datamem_read_fptr, datamem_write_fptr, addr);
125
  }
126
 
127
  return SCARTS_NOMEM;
128
}
129
 

powered by: WebSVN 2.1.0

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