Mercurial > ecos-v3_0-branch
annotate packages/hal/h8300/h8300h/current/src/h8300h_stub.c @ 2729:74dbf4c3f2e1 after-copyright-change-20090129
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
| author | jlarmour |
|---|---|
| date | Thu, 29 Jan 2009 17:47:46 +0000 |
| parents | bbd1a5ee1075 |
| children |
| rev | line source |
|---|---|
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
1 //======================================================================== |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
2 // |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
3 // h8300h_stub.c |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
4 // |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
5 // Helper functions for H8/300H stub |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
6 // |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
7 //======================================================================== |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
16 // version. |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
17 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
21 // for more details. |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
33 // General Public License v2. |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1571
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
39 //======================================================================== |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
40 //#####DESCRIPTIONBEGIN#### |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
41 // |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
42 // Author(s): Yoshinori Sato |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
43 // Contributors: Yoshinori Sato |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
44 // Date: 2002-05-03 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
45 // Purpose: |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
46 // Description: Helper functions for H8/300H stub |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
47 // Usage: |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
48 // |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
49 //####DESCRIPTIONEND#### |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
50 // |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
51 //======================================================================== |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
52 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
53 #include <stddef.h> |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
54 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
55 #include <pkgconf/hal.h> |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
56 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
57 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
58 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
59 #include <cyg/hal/hal_stub.h> |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
60 #include <cyg/hal/hal_arch.h> |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
61 #include <cyg/hal/hal_intr.h> |
| 1571 | 62 #include <cyg/hal/hal_diag.h> |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
63 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
64 #ifdef CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
65 #include <cyg/hal/dbg-threads-api.h> // dbg_currthread_id |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
66 #endif |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
67 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
68 /*--------------------------------------------------------------------*/ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
69 /* Given a trap value TRAP, return the corresponding signal. */ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
70 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
71 int __computeSignal (unsigned int trap_number) |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
72 { |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
73 switch (trap_number) { |
| 1571 | 74 case CYGNUM_HAL_VECTOR_TRAP3: |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
75 return SIGTRAP; |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
76 default: |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
77 return SIGINT; |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
78 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
79 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
80 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
81 /*--------------------------------------------------------------------*/ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
82 /* Return the trap number corresponding to the last-taken trap. */ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
83 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
84 int __get_trap_number (void) |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
85 { |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
86 extern int CYG_LABEL_NAME(_intvector); |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
87 // The vector is not not part of the GDB register set so get it |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
88 // directly from the save context. |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
89 return CYG_LABEL_NAME(_intvector); |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
90 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
91 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
92 /*--------------------------------------------------------------------*/ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
93 /* Set the currently-saved pc register value to PC. This also updates NPC |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
94 as needed. */ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
95 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
96 void set_pc (target_register_t pc) |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
97 { |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
98 put_register (PC, pc); |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
99 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
100 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
101 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
102 /*---------------------------------------------------------------------- |
| 1571 | 103 * Single-step support. |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
104 */ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
105 |
| 1571 | 106 typedef struct { |
| 107 unsigned short *addr; | |
| 108 unsigned short inst; | |
| 109 } breakinfo; | |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
110 |
| 1571 | 111 static breakinfo InstBuffer = {(unsigned short *)-1,0}; |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
112 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
113 /* Clear any single-step breakpoint(s) that may have been set. */ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
114 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
115 void __clear_single_step (void) |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
116 { |
| 1571 | 117 if ((long)InstBuffer.addr != -1L) { |
| 118 *InstBuffer.addr = InstBuffer.inst; | |
| 119 InstBuffer.addr = (unsigned short *)-1; | |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
120 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
121 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
122 |
| 1571 | 123 /* calculate next pc */ |
| 124 | |
| 125 enum jump_type{none,aabs,aind,ret,reg,relb,relw}; | |
| 126 | |
| 127 /* opcode decode table define | |
| 128 ptn: opcode pattern | |
| 129 msk: opcode bitmask | |
| 130 len: instruction length (<0 next table index) | |
| 131 jmp: jump operation mode */ | |
| 132 | |
| 133 struct optable { | |
| 134 unsigned char pattern; | |
| 135 unsigned char mask; | |
| 136 signed char length; | |
| 137 char type; | |
| 138 } __attribute__((aligned(1),packed)); | |
| 139 | |
| 140 #define OPTABLE(ptn,msk,len,jmp) {ptn,msk,len,jmp} | |
| 141 | |
| 142 const static struct optable optable_0[] = { | |
| 143 OPTABLE(0x00,0xff, 1,none), /* 0x00 */ | |
| 144 OPTABLE(0x01,0xff,-1,none), /* 0x01 */ | |
| 145 OPTABLE(0x02,0xfe, 1,none), /* 0x02-0x03 */ | |
| 146 OPTABLE(0x04,0xee, 1,none), /* 0x04-0x05/0x14-0x15 */ | |
| 147 OPTABLE(0x06,0xfe, 1,none), /* 0x06-0x07 */ | |
| 148 OPTABLE(0x08,0xea, 1,none), /* 0x08-0x09/0x0c-0x0d/0x18-0x19/0x1c-0x1d */ | |
| 149 OPTABLE(0x0a,0xee, 1,none), /* 0x0a-0x0b/0x1a-0x1b */ | |
| 150 OPTABLE(0x0e,0xee, 1,none), /* 0x0e-0x0f/0x1e-0x1f */ | |
| 151 OPTABLE(0x10,0xfc, 1,none), /* 0x10-0x13 */ | |
| 152 OPTABLE(0x16,0xfe, 1,none), /* 0x16-0x17 */ | |
| 153 OPTABLE(0x20,0xe0, 1,none), /* 0x20-0x3f */ | |
| 154 OPTABLE(0x40,0xf0, 1,relb), /* 0x40-0x4f */ | |
| 155 OPTABLE(0x50,0xfc, 1,none), /* 0x50-0x53 */ | |
| 156 OPTABLE(0x54,0xfd, 1,ret ), /* 0x54/0x56 */ | |
| 157 OPTABLE(0x55,0xff, 1,relb), /* 0x55 */ | |
| 158 OPTABLE(0x57,0xff, 1,none), /* 0x57 */ | |
| 159 OPTABLE(0x58,0xfb, 2,relw), /* 0x58/0x5c */ | |
| 160 OPTABLE(0x59,0xfb, 1,reg ), /* 0x59/0x5b */ | |
| 161 OPTABLE(0x5a,0xfb, 2,aabs), /* 0x5a/0x5e */ | |
| 162 OPTABLE(0x5b,0xfb, 2,aind), /* 0x5b/0x5f */ | |
| 163 OPTABLE(0x60,0xe8, 1,none), /* 0x60-0x67/0x70-0x77 */ | |
| 164 OPTABLE(0x68,0xfa, 1,none), /* 0x68-0x69/0x6c-0x6d */ | |
| 165 OPTABLE(0x6a,0xfe,-2,none), /* 0x6a-0x6b */ | |
| 166 OPTABLE(0x6e,0xfe, 2,none), /* 0x6e-0x6f */ | |
| 167 OPTABLE(0x78,0xff, 4,none), /* 0x78 */ | |
| 168 OPTABLE(0x79,0xff, 2,none), /* 0x79 */ | |
| 169 OPTABLE(0x7a,0xff, 3,none), /* 0x7a */ | |
| 170 OPTABLE(0x7b,0xff, 2,none), /* 0x7b */ | |
| 171 OPTABLE(0x7c,0xfc, 2,none), /* 0x7c-0x7f */ | |
| 172 OPTABLE(0x80,0x80, 1,none), /* 0x80-0xff */ | |
| 173 }; | |
| 174 | |
| 175 const static struct optable optable_1[] = { | |
| 176 OPTABLE(0x00,0xff,-3,none), /* 0x0100 */ | |
| 177 OPTABLE(0x40,0xf0,-3,none), /* 0x0140-0x14f */ | |
| 178 OPTABLE(0x80,0xf0, 1,none), /* 0x0180-0x018f */ | |
| 179 OPTABLE(0xc0,0xc0, 2,none), /* 0x01c0-0x01ff */ | |
| 180 }; | |
| 181 | |
| 182 const static struct optable optable_2[] = { | |
| 183 OPTABLE(0x00,0x20, 2,none), /* 0x6a0?/0x6a8?/0x6b0?/0x6b8? */ | |
| 184 OPTABLE(0x20,0x20, 3,none), /* 0x6a2?/0x6aa?/0x6b2?/0x6ba? */ | |
| 185 }; | |
| 186 | |
| 187 const static struct optable optable_3[] = { | |
| 188 OPTABLE(0x69,0xfb, 2,none), /* 0x010069/0x01006d/014069/0x01406d */ | |
| 189 OPTABLE(0x6b,0xff,-4,none), /* 0x01006b/0x01406b */ | |
| 190 OPTABLE(0x6f,0xff, 3,none), /* 0x01006f/0x01406f */ | |
| 191 OPTABLE(0x78,0xff, 5,none), /* 0x010078/0x014078 */ | |
| 192 }; | |
| 193 | |
| 194 const static struct optable optable_4[] = { | |
| 195 OPTABLE(0x00,0x78, 3,none), /* 0x0100690?/0x01006d0?/0140690/0x01406d0?/0x0100698?/0x01006d8?/0140698?/0x01406d8? */ | |
| 196 OPTABLE(0x20,0x78, 4,none), /* 0x0100692?/0x01006d2?/0140692/0x01406d2?/0x010069a?/0x01006da?/014069a?/0x01406da? */ | |
| 197 }; | |
| 198 | |
| 199 const static struct { | |
| 200 const struct optable *op; | |
| 201 int length; | |
| 202 } optables[] = { | |
| 203 {optable_0,sizeof(optable_0)/sizeof(struct optable)}, | |
| 204 {optable_1,sizeof(optable_1)/sizeof(struct optable)}, | |
| 205 {optable_2,sizeof(optable_2)/sizeof(struct optable)}, | |
| 206 {optable_3,sizeof(optable_3)/sizeof(struct optable)}, | |
| 207 {optable_4,sizeof(optable_4)/sizeof(struct optable)}, | |
| 208 }; | |
| 209 | |
| 210 const static unsigned char condmask[] = { | |
| 211 0x00,0x40,0x01,0x04,0x02,0x08,0x10,0x20 | |
| 212 }; | |
| 213 | |
| 214 static int isbranch(int reson) | |
| 215 { | |
| 216 unsigned char cond = get_register(CCR); | |
| 217 /* encode complex conditions */ | |
| 218 /* B4: N^V | |
| 219 B5: Z|(N^V) | |
| 220 B6: C|Z */ | |
| 221 __asm__("bld #3,%w0\n\t" | |
| 222 "bxor #1,%w0\n\t" | |
| 223 "bst #4,%w0\n\t" | |
| 224 "bor #2,%w0\n\t" | |
| 225 "bst #5,%w0\n\t" | |
| 226 "bld #2,%w0\n\t" | |
| 227 "bor #0,%w0\n\t" | |
| 228 "bst #6,%w0\n\t" | |
| 229 :"=&r"(cond):"g"(cond):"cc"); | |
| 230 cond &= condmask[reson >> 1]; | |
| 231 if (!(reson & 1)) | |
| 232 return cond == 0; | |
| 233 else | |
| 234 return cond != 0; | |
| 235 } | |
| 236 | |
| 237 static unsigned short *getnextpc(unsigned short *pc) | |
| 238 { | |
| 239 const struct optable *op; | |
| 240 unsigned char *fetch_p; | |
| 241 unsigned char inst; | |
| 242 unsigned long addr; | |
| 243 unsigned long *sp; | |
| 244 int op_len; | |
| 245 op = optables[0].op; | |
| 246 op_len = optables[0].length; | |
| 247 fetch_p = (unsigned char *)pc; | |
| 248 inst = *fetch_p++; | |
| 249 do { | |
| 250 if ((inst & op->mask) == op->pattern) { | |
| 251 if (op->length < 0) { | |
| 252 op = optables[-op->length].op; | |
| 253 op_len = optables[-op->length].length + 1; | |
| 254 inst = *fetch_p++; | |
| 255 } else { | |
| 256 switch (op->type) { | |
| 257 case none: | |
| 258 return pc + op->length; | |
| 259 case aabs: | |
| 260 addr = *(unsigned long *)pc; | |
| 261 return (unsigned short *)(addr & 0x00ffffff); | |
| 262 case aind: | |
| 263 addr = *pc & 0xff; | |
| 264 return (unsigned short *)(*(unsigned long *)addr); | |
| 265 case ret: | |
| 266 sp = (unsigned long *)get_register(SP); | |
| 267 return (unsigned short *)(*(sp+3) & 0x00ffffff); | |
| 268 case reg: | |
| 269 addr = get_register((*pc >> 4) & 0x07); | |
| 270 return (unsigned short *)addr; | |
| 271 case relb: | |
| 272 if ((inst = 0x55) || isbranch(inst & 0x0f)) | |
| 273 (unsigned char *)pc += (signed char)(*fetch_p); | |
| 274 return pc+1; /* skip myself */ | |
| 275 case relw: | |
| 276 if ((inst = 0x5c) || isbranch((*fetch_p & 0xf0) >> 4)) | |
| 277 (unsigned char *)pc += (signed short)(*(pc+1)); | |
| 278 return pc+2; /* skip myself */ | |
| 279 } | |
| 280 } | |
| 281 } else | |
| 282 op++; | |
| 283 } while(--op_len > 0); | |
| 284 return NULL; | |
| 285 } | |
| 286 | |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
287 /* Set breakpoint(s) to simulate a single step from the current PC. */ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
288 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
289 void __single_step (void) |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
290 { |
| 1571 | 291 unsigned short *nextpc; |
| 292 nextpc = getnextpc((unsigned short *)get_register(PC)); | |
| 293 InstBuffer.addr = nextpc; | |
| 294 InstBuffer.inst = *nextpc; | |
| 295 *nextpc = HAL_BREAKINST; | |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
296 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
297 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
298 void __install_breakpoints (void) |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
299 { |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
300 /* NOP since single-step HW exceptions are used instead of |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
301 breakpoints. */ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
302 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
303 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
304 void __clear_breakpoints (void) |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
305 { |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
306 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
307 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
308 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
309 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
310 /* If the breakpoint we hit is in the breakpoint() instruction, return a |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
311 non-zero value. */ |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
312 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
313 externC void CYG_LABEL_NAME(breakinst)(void); |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
314 int |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
315 __is_breakpoint_function () |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
316 { |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
317 return get_register (PC) == (target_register_t)&CYG_LABEL_NAME(breakinst); |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
318 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
319 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
320 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
321 /* Skip the current instruction. */ |
| 1571 | 322 /* only TRAPA instruction */ |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
323 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
324 void __skipinst (void) |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
325 { |
| 1571 | 326 put_register (PC, get_register(PC) + 2); |
|
1281
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
327 } |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
328 |
|
f58b62f3c85d
Apply Yoshinori Sato's H8/300 patches plus a few of my own.
nickg
parents:
diff
changeset
|
329 #endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
