Remove stale overlay testcase bits
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ovlymgr.c
1
2 /*
3 * Ovlymgr.c -- Runtime Overlay Manager for the GDB testsuite.
4 */
5
6 #include "ovlymgr.h"
7
8 /* Local functions and data: */
9
10 extern unsigned long _ovly_table[][4];
11 extern unsigned long _novlys __attribute__ ((section (".data")));
12 enum ovly_index { VMA, SIZE, LMA, MAPPED};
13
14 static void ovly_copy (unsigned long dst, unsigned long src, long size);
15
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. */
23
24 static void
25 FlushCache (void)
26 {
27 #ifdef __M32R__
28 volatile char *mspr = (char *) 0xfffffff7;
29 *mspr = 1;
30 #endif
31 }
32
33 /* _ovly_debug_event:
34 * Debuggers may set a breakpoint here, to be notified
35 * when the overlay table has been modified.
36 */
37 static void
38 _ovly_debug_event (void)
39 {
40 }
41
42 /* OverlayLoad:
43 * Copy the overlay into its runtime region,
44 * and mark the overlay as "mapped".
45 */
46
47 bool
48 OverlayLoad (unsigned long ovlyno)
49 {
50 unsigned long i;
51
52 if (ovlyno < 0 || ovlyno >= _novlys)
53 exit (-1); /* fail, bad ovly number */
54
55 if (_ovly_table[ovlyno][MAPPED])
56 return TRUE; /* this overlay already mapped -- nothing to do! */
57
58 for (i = 0; i < _novlys; i++)
59 if (i == ovlyno)
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 */
63
64 ovly_copy (_ovly_table[ovlyno][VMA],
65 _ovly_table[ovlyno][LMA],
66 _ovly_table[ovlyno][SIZE]);
67
68 FlushCache ();
69 _ovly_debug_event ();
70 return TRUE;
71 }
72
73 /* OverlayUnload:
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.
77 */
78
79 bool
80 OverlayUnload (unsigned long ovlyno)
81 {
82 if (ovlyno < 0 || ovlyno >= _novlys)
83 exit (-1); /* fail, bad ovly number */
84
85 if (!_ovly_table[ovlyno][MAPPED])
86 exit (-1); /* error, can't copy out a segment that's not "in" */
87
88 ovly_copy (_ovly_table[ovlyno][LMA],
89 _ovly_table[ovlyno][VMA],
90 _ovly_table[ovlyno][SIZE]);
91
92 _ovly_debug_event ();
93 return TRUE;
94 }
95
96 static void
97 ovly_copy (unsigned long dst, unsigned long src, long size)
98 {
99 memcpy ((void *) dst, (void *) src, size);
100 }
This page took 0.030293 seconds and 4 git commands to generate.