3 * Ovlymgr.c -- Runtime Overlay Manager for the GDB testsuite.
8 /* Local functions and data: */
10 extern unsigned long _ovly_table
[][4];
11 extern unsigned long _novlys
__attribute__ ((section (".data")));
12 enum ovly_index
{ VMA
, SIZE
, LMA
, MAPPED
};
14 static void ovly_copy (unsigned long dst
, unsigned long src
, long size
);
16 /* Flush the data and instruction caches at address START for SIZE bytes.
17 Support for each new port must be added here. */
18 /* FIXME: Might be better to have a standard libgloss function that
19 ports provide that we can then use. Use libgloss instead of newlib
20 since libgloss is the one intended to handle low level system issues.
21 I would suggest something like _flush_cache to avoid the user's namespace
22 but not be completely obscure as other things may need this facility. */
28 volatile char *mspr
= (char *) 0xfffffff7;
34 * Debuggers may set a breakpoint here, to be notified
35 * when the overlay table has been modified.
38 _ovly_debug_event (void)
43 * Copy the overlay into its runtime region,
44 * and mark the overlay as "mapped".
48 OverlayLoad (unsigned long ovlyno
)
52 if (ovlyno
< 0 || ovlyno
>= _novlys
)
53 exit (-1); /* fail, bad ovly number */
55 if (_ovly_table
[ovlyno
][MAPPED
])
56 return TRUE
; /* this overlay already mapped -- nothing to do! */
58 for (i
= 0; i
< _novlys
; i
++)
60 _ovly_table
[i
][MAPPED
] = 1; /* this one now mapped */
61 else if (_ovly_table
[i
][VMA
] == _ovly_table
[ovlyno
][VMA
])
62 _ovly_table
[i
][MAPPED
] = 0; /* this one now un-mapped */
64 ovly_copy (_ovly_table
[ovlyno
][VMA
],
65 _ovly_table
[ovlyno
][LMA
],
66 _ovly_table
[ovlyno
][SIZE
]);
74 * Copy the overlay back into its "load" region.
75 * Does NOT mark overlay as "unmapped", therefore may be called
76 * more than once for the same mapped overlay.
80 OverlayUnload (unsigned long ovlyno
)
82 if (ovlyno
< 0 || ovlyno
>= _novlys
)
83 exit (-1); /* fail, bad ovly number */
85 if (!_ovly_table
[ovlyno
][MAPPED
])
86 exit (-1); /* error, can't copy out a segment that's not "in" */
88 ovly_copy (_ovly_table
[ovlyno
][LMA
],
89 _ovly_table
[ovlyno
][VMA
],
90 _ovly_table
[ovlyno
][SIZE
]);
97 #define IMAP0 (*(short *)(0xff00))
98 #define IMAP1 (*(short *)(0xff02))
99 #define DMAP (*(short *)(0xff04))
102 D10VTranslate (unsigned long logical
,
104 unsigned long **addr
)
106 unsigned long physical
;
110 /* to access data, we use the following mapping
111 0x00xxxxxx: Logical data address segment (DMAP translated memory)
112 0x01xxxxxx: Logical instruction address segment (IMAP translated memory)
113 0x10xxxxxx: Physical data memory segment (On-chip data memory)
114 0x11xxxxxx: Physical instruction memory segment (On-chip insn memory)
115 0x12xxxxxx: Phisical unified memory segment (Unified memory)
118 /* Addresses must be correctly aligned */
119 if (logical
& (sizeof (**addr
) - 1))
122 /* If the address is in one of the two logical address spaces, it is
123 first translated into a physical address */
124 seg
= (logical
>> 24);
125 off
= (logical
& 0xffffffL
);
128 case 0x00: /* in logical data address segment */
130 physical
= (0x10L
<< 24) + off
;
132 /* Logical address out side of on-chip segment, not
136 case 0x01: /* in logical instruction address segment */
141 else if (off
<= 0x3ffffL
)
144 /* Logical address outside of IMAP[01] segment, not
149 /* Instruction memory */
150 physical
= (0x11L
<< 24) | off
;
155 physical
= ((map
& 0x7fL
) << 17) + (off
& 0x1ffffL
);
156 if (physical
> 0xffffffL
)
157 /* Address outside of unified address segment */
159 physical
|= (0x12L
<< 24);
169 exit (-1); /* error */
172 seg
= (physical
>> 24);
173 off
= (physical
& 0xffffffL
);
176 case 0x10: /* dst is a 15 bit offset into the on-chip memory */
178 *addr
= (long *) (0x0000 + ((short)off
& 0x7fff));
180 case 0x11: /* dst is an 18-bit offset into the on-chip
181 instruction memory */
182 *dmap
= 0x1000L
| ((off
& 0x3ffffL
) >> 14);
183 *addr
= (long *) (0x8000 + ((short)off
& 0x3fff));
185 case 0x12: /* dst is a 24-bit offset into unified memory */
187 *addr
= (long *) (0x8000 + ((short)off
& 0x3fff));
190 exit (-1); /* error */
193 #endif /* __D10V__ */
196 ovly_copy (unsigned long dst
, unsigned long src
, long size
)
199 unsigned long *s
, *d
, tmp
;
200 short dmap_src
, dmap_dst
;
203 /* all section sizes should by multiples of 4 bytes */
206 D10VTranslate (src
, &dmap_src
, &s
);
207 D10VTranslate (dst
, &dmap_dst
, &d
);
211 /* NB: Transfer 4 byte (long) quantites, problems occure
212 when only two bytes are transfered */
219 size
-= sizeof (tmp
);
222 if ((src
& 0x3fff) == 0)
223 D10VTranslate (src
, &dmap_src
, &s
);
224 if ((dst
& 0x3fff) == 0)
225 D10VTranslate (dst
, &dmap_dst
, &d
);
229 memcpy ((void *) dst
, (void *) src
, size
);
This page took 0.034948 seconds and 4 git commands to generate.