source: rtems/c/src/exec/score/cpu/hppa1.1/hppa.h @ 2ff1d549

4.104.114.84.95
Last change on this file since 2ff1d549 was 254b4450, checked in by Joel Sherrill <joel.sherrill@…>, on 04/01/97 at 23:07:52

This set of changes is the build of what was required to convert to
GNU autoconf. This is the first large step in allowing an RTEMS
user to perform a one-tree build (per crossgcc FAQ) including RTEMS
in the build process. With this change RTEMS is configured in
built in the same style as the GNU tools, yet retains the basic
structure of its traditional Makefiles (ala Tony Bennett).
Jiri Gaisler (jgais@…) deserves (and received)
a big thank you for doing this.

There are still issues to be resolved but as of this commit, all target
which can be built on a linux host have been using a modified version
of the source Jiri submitted. This source was merged and most targets
built in the tree before this commit.

There are some issues which remain to be resolved but they are primarily
related to host OS dependencies, script issues, the use of gawk
for hack_specs, and the dependence on gcc snapshots. These will
be resolved.

  • Property mode set to 100644
File size: 29.8 KB
Line 
1/*
2 *  Description:
3 *             
4 * Definitions for HP PA Risc
5 * ref: PA RISC 1.1 Architecture and Instruction Set Reference Manual
6 *     
7 *  COPYRIGHT (c) 1994 by Division Incorporated
8 *
9 *  To anyone who acknowledges that this file is provided "AS IS"
10 *  without any express or implied warranty:
11 *      permission to use, copy, modify, and distribute this file
12 *      for any purpose is hereby granted without fee, provided that
13 *      the above copyright notice and this notice appears in all
14 *      copies, and that the name of Division Incorporated not be
15 *      used in advertising or publicity pertaining to distribution
16 *      of the software without specific, written prior permission.
17 *      Division Incorporated makes no representations about the
18 *      suitability of this software for any purpose.
19 *
20 *
21 * Note:
22 *      This file is included by both C and assembler code ( -DASM )
23 *
24 *  $Id$
25 */
26
27#ifndef _INCLUDE_HPPA_H
28#define _INCLUDE_HPPA_H
29
30#ifdef ASM
31#include <rtems/score/targopts.h>
32#endif
33
34#if defined(__cplusplus)
35extern "C" {
36#endif
37
38/*
39 *  This section contains the information required to build
40 *  RTEMS for a particular member of the Hewlett Packard
41 *  PA-RISC family.  It does this by setting variables to
42 *  indicate which implementation dependent features are
43 *  present in a particular member of the family.
44 */
45
46#if defined(hppa7100)
47
48#define CPU_MODEL_NAME  "hppa 7100"
49
50#elif defined(hppa7200)
51
52#define CPU_MODEL_NAME  "hppa 7200"
53
54#else
55
56#error "Unsupported CPU Model"
57
58#endif
59         
60/*
61 *  Define the name of the CPU family.
62 */
63
64#if !defined(CPU_NAME)
65#define CPU_NAME "HP PA-RISC 1.1"
66#endif
67
68/*
69 * Processor Status Word (PSW) Masks
70 */
71
72
73#define HPPA_PSW_Y      0x80000000    /* Data Debug Trap Disable */
74#define HPPA_PSW_Z      0x40000000    /* Instruction Debug Trap Disable */
75#define HPPA_PSW_r2     0x20000000    /* reserved */
76#define HPPA_PSW_r3     0x10000000    /* reserved */
77#define HPPA_PSW_r4     0x08000000    /* reserved */
78#define HPPA_PSW_E      0x04000000    /* Little Endian on Memory References */
79#define HPPA_PSW_S      0x02000000    /* Secure Interval Timer */
80#define HPPA_PSW_T      0x01000000    /* Taken Branch Trap Enable */
81#define HPPA_PSW_H      0x00800000    /* Higher-Privilege Transfer Trap Enable*/
82#define HPPA_PSW_L      0x00400000    /* Lower-Privilege Transfer Trap Enable */
83#define HPPA_PSW_N      0x00200000    /* PC Queue Front Instruction Nullified */
84#define HPPA_PSW_X      0x00100000    /* Data Memory Break Disable */
85#define HPPA_PSW_B      0x00080000    /* Taken Branch in Previous Cycle */
86#define HPPA_PSW_C      0x00040000    /* Code Address Translation Enable */
87#define HPPA_PSW_V      0x00020000    /* Divide Step Correction */
88#define HPPA_PSW_M      0x00010000    /* High-Priority Machine Check Disable */
89#define HPPA_PSW_CB     0x0000ff00    /* Carry/Borrow Bits */
90#define HPPA_PSW_r24    0x00000080    /* reserved */
91#define HPPA_PSW_G      0x00000040    /* Debug trap Enable */
92#define HPPA_PSW_F      0x00000020    /* Performance monitor interrupt unmask */
93#define HPPA_PSW_R      0x00000010    /* Recovery Counter Enable */
94#define HPPA_PSW_Q      0x00000008    /* Interruption State Collection Enable */
95#define HPPA_PSW_P      0x00000004    /* Protection ID Validation Enable */
96#define HPPA_PSW_D      0x00000002    /* Data Address Translation Enable */
97#define HPPA_PSW_I      0x00000001    /* External, Power Failure, */
98                                      /*   Low-Priority Machine Check */
99                                      /*   Interruption Enable */
100
101/*
102 * HPPA traps and interrupts
103 * basic layout.  Note numbers do not denote priority
104 *
105 *      0-31    basic traps and interrupts defined by HPPA architecture
106 *      0-31    32 external interrupts
107 *     32-...   bsp defined
108 */
109
110#define HPPA_TRAP_NON_EXISTENT                     0
111/* group 1 */
112#define HPPA_TRAP_HIGH_PRIORITY_MACHINE_CHECK      1
113/* group 2 */
114#define HPPA_TRAP_POWER_FAIL                       2
115#define HPPA_TRAP_RECOVERY_COUNTER                 3
116#define HPPA_TRAP_EXTERNAL_INTERRUPT               4
117#define HPPA_TRAP_LOW_PRIORITY_MACHINE_CHECK       5
118#define HPPA_TRAP_PERFORMANCE_MONITOR             29
119/* group 3 */
120#define HPPA_TRAP_INSTRUCTION_TLB_MISS             6
121#define HPPA_TRAP_INSTRUCTION_MEMORY_PROTECTION    7
122#define HPPA_TRAP_INSTRUCTION_DEBUG               30
123#define HPPA_TRAP_ILLEGAL_INSTRUCTION              8
124#define HPPA_TRAP_BREAK_INSTRUCTION                9
125#define HPPA_TRAP_PRIVILEGED_OPERATION            10
126#define HPPA_TRAP_PRIVILEGED_REGISTER             11
127#define HPPA_TRAP_OVERFLOW                        12
128#define HPPA_TRAP_CONDITIONAL                     13
129#define HPPA_TRAP_ASSIST_EXCEPTION                14
130#define HPPA_TRAP_DATA_TLB_MISS                   15
131#define HPPA_TRAP_NON_ACCESS_INSTRUCTION_TLB_MISS 16
132#define HPPA_TRAP_NON_ACCESS_DATA_TLB_MISS        17
133#define HPPA_TRAP_DATA_MEMORY_ACCESS_RIGHTS       26
134#define HPPA_TRAP_DATA_MEMORY_PROTECTION_ID       27
135#define HPPA_TRAP_UNALIGNED_DATA_REFERENCE        28
136#define HPPA_TRAP_DATA_MEMORY_PROTECTION          18
137#define HPPA_TRAP_DATA_MEMORY_BREAK               19
138#define HPPA_TRAP_TLB_DIRTY_BIT                   20
139#define HPPA_TRAP_PAGE_REFERENCE                  21
140#define HPPA_TRAP_DATA_DEBUG                      31
141#define HPPA_TRAP_ASSIST_EMULATION                22
142/* group 4 */
143#define HPPA_TRAP_HIGHER_PRIVILEGE_TRANSFER       23
144#define HPPA_TRAP_LOWER_PRIVILEGE_TRANSFER        24
145#define HPPA_TRAP_TAKEN_BRANCH                    25
146
147#define HPPA_INTERNAL_TRAPS                       32
148
149/* External Interrupts via interrupt 4 */
150
151#define HPPA_INTERRUPT_EXTERNAL_0                  0
152#define HPPA_INTERRUPT_EXTERNAL_1                  1
153#define HPPA_INTERRUPT_EXTERNAL_2                  2
154#define HPPA_INTERRUPT_EXTERNAL_3                  3
155#define HPPA_INTERRUPT_EXTERNAL_4                  4
156#define HPPA_INTERRUPT_EXTERNAL_5                  5
157#define HPPA_INTERRUPT_EXTERNAL_6                  6
158#define HPPA_INTERRUPT_EXTERNAL_7                  7
159#define HPPA_INTERRUPT_EXTERNAL_8                  8
160#define HPPA_INTERRUPT_EXTERNAL_9                  9
161#define HPPA_INTERRUPT_EXTERNAL_10                10
162#define HPPA_INTERRUPT_EXTERNAL_11                11
163#define HPPA_INTERRUPT_EXTERNAL_12                12
164#define HPPA_INTERRUPT_EXTERNAL_13                13
165#define HPPA_INTERRUPT_EXTERNAL_14                14
166#define HPPA_INTERRUPT_EXTERNAL_15                15
167#define HPPA_INTERRUPT_EXTERNAL_16                16
168#define HPPA_INTERRUPT_EXTERNAL_17                17
169#define HPPA_INTERRUPT_EXTERNAL_18                18
170#define HPPA_INTERRUPT_EXTERNAL_19                19
171#define HPPA_INTERRUPT_EXTERNAL_20                20
172#define HPPA_INTERRUPT_EXTERNAL_21                21
173#define HPPA_INTERRUPT_EXTERNAL_22                22
174#define HPPA_INTERRUPT_EXTERNAL_23                23
175#define HPPA_INTERRUPT_EXTERNAL_24                24
176#define HPPA_INTERRUPT_EXTERNAL_25                25
177#define HPPA_INTERRUPT_EXTERNAL_26                26
178#define HPPA_INTERRUPT_EXTERNAL_27                27
179#define HPPA_INTERRUPT_EXTERNAL_28                28
180#define HPPA_INTERRUPT_EXTERNAL_29                29
181#define HPPA_INTERRUPT_EXTERNAL_30                30
182#define HPPA_INTERRUPT_EXTERNAL_31                31
183
184#define HPPA_INTERRUPT_EXTERNAL_INTERVAL_TIMER    HPPA_INTERRUPT_EXTERNAL_0
185#define HPPA_EXTERNAL_INTERRUPTS                  32
186
187/* BSP defined interrupts begin here */
188
189#define HPPA_INTERRUPT_MAX  32
190
191/*
192 * Cache characteristics
193 */
194 
195#define HPPA_CACHELINE_SIZE     32
196#define HPPA_CACHELINE_MASK     (HPPA_CACHELINE_SIZE - 1)
197
198/*
199 * page size characteristics
200 */
201
202#define HPPA_PAGE_SIZE          4096
203#define HPPA_PAGE_MASK          (0xfffff000)
204
205
206/*
207 * TLB characteristics
208 *
209 * Flags and Access Control layout for using TLB protection insertion
210 *
211 *                      1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
212 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
213 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
214 * |?|?|T|D|B|type |PL1|Pl2|U|           access id               |?|
215 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
216 *
217 */
218
219/*
220 * Access rights (type + PL1 + PL2)
221 */
222#define HPPA_PROT_R    0x00c00000   /* Read Only, no Write, no Execute */
223#define HPPA_PROT_RW   0x01c00000   /* Read & Write Only, no Execute */
224#define HPPA_PROT_RX   0x02c00000   /* Read & Execute Only, no Write */
225#define HPPA_PROT_RWX  0x03c00000   /* Read, Write, Execute */
226#define HPPA_PROT_X0   0x04c00000   /* Execute Only, Promote to Level 0 */
227#define HPPA_PROT_X1   0x05c00000   /* Execute Only, Promote to Level 1 */
228#define HPPA_PROT_X2   0x06c00000   /* Execute Only, Promote to Level 2 */
229#define HPPA_PROT_X3   0x07c00000   /* Execute Only, Promote to Level 3 */
230
231/*
232 * Floating point status register definitions
233 */
234
235#define HPPA_FPSTATUS_ENABLE_I    0x00000001    /* inexact operation */
236#define HPPA_FPSTATUS_ENABLE_U    0x00000002    /* underflow */
237#define HPPA_FPSTATUS_ENABLE_O    0x00000004    /* overflow */
238#define HPPA_FPSTATUS_ENABLE_Z    0x00000008    /* division by zero */
239#define HPPA_FPSTATUS_ENABLE_V    0x00000010    /* invalid operation */
240#define HPPA_FPSTATUS_D           0x00000020    /* denormalize as zero */
241#define HPPA_FPSTATUS_T           0x00000040    /* delayed trap */
242#define HPPA_FPSTATUS_RM_MASK     0x00000600    /* rounding mode */
243#define HPPA_FPSTATUS_RM_SHIFT    9
244#define HPPA_FPSTATUS_CQ_MASK     0x001FFC00    /* compare queue */
245#define HPPA_FPSTATUS_CQ_SHIFT    13
246#define HPPA_FPSTATUS_C           0x04000000    /* most recent ompare bit */
247#define HPPA_FPSTATUS_FLAG_I      0x08000000    /* inexact */
248#define HPPA_FPSTATUS_FLAG_U      0x10000000    /* underflow */
249#define HPPA_FPSTATUS_FLAG_O      0x20000000    /* overflow */
250#define HPPA_FPSTATUS_FLAG_Z      0x40000000    /* division by zero */
251#define HPPA_FPSTATUS_FLAG_V      0x80000000    /* invalid operation */
252
253
254/*
255 * Inline macros for misc. interesting opcodes
256 */
257
258/* generate a global label */
259#define HPPA_ASM_LABEL(label) \
260    asm(".export " label ", ! .label " label);
261
262/* Return From Interrupt                RFI */
263#define HPPA_ASM_RFI()                  asm volatile ("rfi")
264
265/* Set System Mask                      SSM i,t */
266#define HPPA_ASM_SSM(i,gr)              asm volatile ("ssm %1, %0" \
267                                                      : "=r" (gr)   \
268                                                      : "i"  (i))
269/* Reset System Mask                    RSM i,t */
270#define HPPA_ASM_RSM(i,gr)              asm volatile ("rsm %1, %0" \
271                                                      : "=r" (gr)   \
272                                                      : "i"  (i))
273/* Move To System Mask                  MTSM r */
274#define HPPA_ASM_MTSM(gr)               asm volatile ("mtsm %0" \
275                                                      : : "r" (gr))
276
277/* Load Space Identifier                LDSID (s,b),t */
278#define HPPA_ASM_LDSID(sr,grb,grt)      asm volatile ("ldsid (%1,%2),%0" \
279                                                      : "=r" (grt)  \
280                                                      : "i"  (sr), \
281                                                        "r"  (grb))
282
283/*
284 * Gcc extended asm doesn't really allow for treatment of space registers
285 * as "registers", so we have to use "i" format.
286 * Unfortunately this means that the "=" constraint is not available.
287 */
288
289/* Move To Space Register               MTSP r,sr */
290#define HPPA_ASM_MTSP(gr,sr)            asm volatile ("mtsp %1,%0" \
291                                                      : : "i"  (sr),  \
292                                                          "r"  (gr))
293
294/* Move From Space Register             MFSP sr,t */
295#define HPPA_ASM_MFSP(sr,gr)            asm volatile ("mfsp %1,%0" \
296                                                      : "=r" (gr)  \
297                                                      : "i"  (sr))
298
299/* Move To Control register             MTCTL r,t */
300#define HPPA_ASM_MTCTL(gr,cr)           asm volatile ("mtctl %1,%0" \
301                                                      : : "i" (cr), \
302                                                          "r" (gr))
303
304/* Move From Control register           MFCTL r,t */
305#define HPPA_ASM_MFCTL(cr,gr)           asm volatile ("mfctl %1,%0" \
306                                                      : "=r" (gr) \
307                                                      : "i" (cr))
308
309/* Synchronize caches                   SYNC */
310#define HPPA_ASM_SYNC()                 asm volatile ("sync")
311
312/* Probe Read Access                    PROBER (s,b),r,t */
313#define HPPA_ASM_PROBER(sr,groff,gracc,grt) \
314                                        asm volatile ("prober (%1,%2),%3,%0" \
315                                                      : "=r" (grt) \
316                                                      : "i"  (sr), \
317                                                        "r"  (groff), \
318                                                        "r"  (gracc))
319
320/* Probe Read Access Immediate          PROBERI (s,b),i,t*/
321#define HPPA_ASM_PROBERI(sr,groff,iacc,grt) \
322                                        asm volatile ("proberi (%1,%2),%3,%0" \
323                                                      : "=r" (grt) \
324                                                      : "i"  (sr), \
325                                                        "r"  (groff), \
326                                                        "i"  (iacc))
327
328/* Probe Write Access                   PROBEW (s,b),r,t */
329#define HPPA_ASM_PROBEW(sr,groff,gracc,grt) \
330                                        asm volatile ("probew (%1,%2),%3,%0" \
331                                                      : "=r" (grt) \
332                                                      : "i"  (sr), \
333                                                        "r"  (groff), \
334                                                        "r"  (gracc))
335
336/* Probe Write Access Immediate         PROBEWI (s,b),i,t */
337#define HPPA_ASM_PROBEWI(sr,groff,iacc,grt) \
338                                        asm volatile ("probewi (%1,%2),%3,%0" \
339                                                      : "=r" (grt) \
340                                                      : "i"  (sr), \
341                                                        "r"  (groff), \
342                                                        "i"  (iacc))
343
344/* Load Physical Address                LPA x(s,b),t */
345#define HPPA_ASM_LPA(sr,grb,grt)        asm volatile ("lpa %%r0(%1,%2),%0" \
346                                                      : "=r" (grt) \
347                                                      : "i"  (sr), \
348                                                        "r"  (grb))
349
350/* Load Coherence Index                 LCI x(s,b),t */
351/* AKA: Load Hash Address               LHA x(s,b),t */
352#define HPPA_ASM_LCI(grx,sr,grb,grt)    asm volatile ("lha %1(%2,%3),%0" \
353                                                      : "=r" (grt) \
354                                                      : "r"  (grx),\
355                                                        "i"  (sr), \
356                                                        "r"  (grb))
357#define HPPA_ASM_LHA(grx,sr,grb,grt)    HPPA_ASM_LCI(grx,sr,grb,grt)
358
359/* Purge Data Tlb                       PDTLB  x(s,b) */
360#define HPPA_ASM_PDTLB(grx,sr,grb)      asm volatile ("pdtlb %0(%1,%2)" \
361                                                      : : "r"  (grx), \
362                                                          "i"  (sr),  \
363                                                          "r"  (grb))
364
365/* Purge Instruction Tlb                PITLB  x(s,b) */
366#define HPPA_ASM_PITLB(grx,sr,grb)      asm volatile ("pitlb %0(%1,%2)" \
367                                                      : : "r"  (grx), \
368                                                          "i"  (sr),  \
369                                                          "r"  (grb))
370
371/* Purge Data Tlb Entry                 PDTLBE  x(s,b) */
372#define HPPA_ASM_PDTLBE(grx,sr,grb)     asm volatile ("pdtlbe %0(%1,%2)" \
373                                                      : : "r"  (grx), \
374                                                          "i"  (sr),  \
375                                                          "r"  (grb))
376
377/* Purge Instruction Tlb Entry          PITLBE  x(s,b) */
378#define HPPA_ASM_PITLBE(grx,sr,grb)     asm volatile ("pitlbe %0(%1,%2)" \
379                                                      : : "r"  (grx), \
380                                                          "i"  (sr),  \
381                                                          "r"  (grb))
382
383
384/* Insert Data TLB Address              IDTLBA r,(s,b) */
385#define HPPA_ASM_IDTLBA(gr,sr,grb)      asm volatile ("idtlba %0,(%1,%2)" \
386                                                      : : "r"  (gr),  \
387                                                          "i"  (sr),  \
388                                                          "r"  (grb))
389
390/* Insert Instruction TLB Address       IITLBA r,(s,b) */
391#define HPPA_ASM_IITLBA(gr,sr,grb)      asm volatile ("iitlba %0,(%1,%2)" \
392                                                      : : "r"  (gr),  \
393                                                          "i"  (sr),  \
394                                                          "r"  (grb))
395
396/* Insert Data TLB Protection           IDTLBP r,(s,b) */
397#define HPPA_ASM_IDTLBP(gr,sr,grb)      asm volatile ("idtlbp %0,(%1,%2)" \
398                                                      : : "r"  (gr),  \
399                                                          "i"  (sr),  \
400                                                          "r"  (grb))
401
402/* Insert Instruction TLB Protection    IITLBP r,(s,b) */
403#define HPPA_ASM_IITLBP(gr,sr,grb)      asm volatile ("iitlbp %0,(%1,%2)" \
404                                                      : : "r"  (gr),  \
405                                                          "i"  (sr),  \
406                                                          "r"  (grb))
407
408/* Purge Data Cache                     PDC x(s,b) */
409#define HPPA_ASM_PDC(grx,sr,grb)        asm volatile ("pdc %0(%1,%2)" \
410                                                      : : "r"  (grx), \
411                                                          "i"  (sr),  \
412                                                          "r"  (grb))
413
414/* Flush Data Cache                     FDC x(s,b) */
415#define HPPA_ASM_FDC(grx,sr,grb)        asm volatile ("fdc %0(%1,%2)" \
416                                                      : : "r"  (grx), \
417                                                          "i"  (sr),  \
418                                                          "r"  (grb))
419
420/* Flush Instruction Cache              FDC x(s,b) */
421#define HPPA_ASM_FIC(grx,sr,grb)        asm volatile ("fic %0(%1,%2)" \
422                                                      : : "r"  (grx), \
423                                                          "i"  (sr),  \
424                                                          "r"  (grb))
425
426/* Flush Data Cache Entry               FDCE x(s,b) */
427#define HPPA_ASM_FDCE(grx,sr,grb)       asm volatile ("fdce %0(%1,%2)" \
428                                                      : : "r"  (grx), \
429                                                          "i"  (sr),  \
430                                                          "r"  (grb))
431
432/* Flush Instruction Cache Entry        FICE x(s,b) */
433#define HPPA_ASM_FICE(grx,sr,grb)       asm volatile ("fice %0(%1,%2)" \
434                                                      : : "r"  (grx), \
435                                                          "i"  (sr),  \
436                                                          "r"  (grb))
437
438/* Break                                BREAK i5,i13 */
439#define HPPA_ASM_BREAK(i5,i13)          asm volatile ("break %0,%1" \
440                                                      : : "i" (i5), \
441                                                          "i" (i13))
442
443/* Load and Clear Word Short            LDCWS d(s,b),t */
444#define HPPA_ASM_LDCWS(i,sr,grb,grt)    asm volatile ("ldcws %1(%2,%3),%0" \
445                                                      : "=r" (grt) \
446                                                      : "i"  (i),  \
447                                                        "i"  (sr), \
448                                                        "r"  (grb))
449
450/* Load and Clear Word Indexed          LDCWX x(s,b),t */
451#define HPPA_ASM_LDCWX(grx,sr,grb,grt)  asm volatile ("ldcwx %1(%2,%3),%0" \
452                                                      : "=r" (grt)  \
453                                                      : "r"  (grx), \
454                                                        "i"  (sr),  \
455                                                        "r"  (grb))
456
457/* Load Word Absolute Short             LDWAS d(b),t */
458/* NOTE: "short" here means "short displacement"     */
459#define HPPA_ASM_LDWAS(disp,grbase,gr)  asm volatile("ldwas %1(%2),%0" \
460                                                     : "=r" (gr)    \
461                                                     : "i"  (disp), \
462                                                       "r"  (grbase))
463
464/* Store Word Absolute Short            STWAS r,d(b) */
465/* NOTE: "short" here means "short displacement"     */
466#define HPPA_ASM_STWAS(gr,disp,grbase)  asm volatile("stwas %0,%1(%2)" \
467                                                     : : "r" (gr),   \
468                                                         "i" (disp), \
469                                                         "r" (grbase))
470
471/*
472 * Swap bytes
473 * REFERENCE:  PA72000 TRM -- Appendix C
474 */
475#define HPPA_ASM_SWAPBYTES(value, swapped)  asm volatile( \
476    " shd    %1,%1,16,%0  \n\
477      dep    %0,15,8,%0   \n\
478      shd    %1,%0,8,%0"    \
479    : "=r" (swapped)        \
480    : "r" (value)           \
481  )
482
483
484/* 72000 Diagnose instructions follow
485 * These macros assume gas knows about these instructions.
486 * gas2.2.u1 did not.
487 * I added them to my copy and installed it locally.
488 *
489 * There are *very* special requirements for these guys
490 *   ref: TRM 6.1.3 Programming Constraints
491 *
492 * The macros below handle the following rules
493 *
494 *   Except for WIT, WDT, WDD, WIDO, WIDE, all DIAGNOSE must be doubled.
495 *   Must never be nullified (hence the leading nop)
496 *   NOP must preced every RDD,RDT,WDD,WDT,RDTLB
497 *   Instruction preceeding GR_SHDW must not set any of the GR's saved
498 *
499 * The macros do *NOT* deal with the following problems
500 *   doubled DIAGNOSE instructions must not straddle a page boundary
501 *       if code translation enabled.  (since 2nd could trap on ITLB)
502 *   If you care about DHIT and DPE bits of DR0, then
503 *       No store instruction in the 2 insn window before RDD
504 */
505
506
507/* Move To CPU/DIAG register            MTCPU r,t */
508#define HPPA_ASM_MTCPU(gr,dr)           asm volatile (" nop \n"          \
509                                                      " mtcpu %1,%0 \n"  \
510                                                      " mtcpu %1,%0"     \
511                                                      : : "i" (dr), \
512                                                          "r" (gr))
513
514/* Move From CPU/DIAG register          MFCPU r,t */
515#define HPPA_ASM_MFCPU(dr,gr)           asm volatile (" nop \n"          \
516                                                      " mfcpu %1,%0\n"   \
517                                                      " mfcpu %1,%0"     \
518                                                      : "=r" (gr) \
519                                                      : "i" (dr))
520
521/* Transfer of Control Enable           TOC_EN */
522#define HPPA_ASM_TOC_EN()               asm volatile (" tocen \n" \
523                                                      " tocen")
524
525/* Transfer of Control Disable          TOC_DIS */
526#define HPPA_ASM_TOC_DIS()              asm volatile (" tocdis \n" \
527                                                      " tocdis")
528
529/* Shadow Registers to General Register SHDW_GR */
530#define HPPA_ASM_SHDW_GR()              asm volatile (" shdwgr \n" \
531                                                      " shdwgr"    \
532                                                ::: "r1" "r8" "r9" "r16" \
533                                                    "r17" "r24" "r25")
534
535/* General Registers to Shadow Register GR_SHDW */
536#define HPPA_ASM_GR_SHDW()              asm volatile (" nop \n" \
537                                                      " grshdw \n" \
538                                                      " grshdw")
539
540/*
541 * Definitions of special registers for use by the above macros.
542 */
543
544/* Hardware Space Registers */
545#define HPPA_SR0     0
546#define HPPA_SR1     1
547#define HPPA_SR2     2
548#define HPPA_SR3     3
549#define HPPA_SR4     4
550#define HPPA_SR5     5
551#define HPPA_SR6     6
552#define HPPA_SR7     7
553
554/* Hardware Control Registers */
555#define HPPA_CR0     0
556#define HPPA_RCTR    0               /* Recovery Counter Register */
557
558#define HPPA_CR8     8               /* Protection ID 1 */
559#define HPPA_PIDR1   8
560
561#define HPPA_CR9     9               /* Protection ID 2 */
562#define HPPA_PIDR2   9
563
564#define HPPA_CR10    10
565#define HPPA_CCR     10              /* Coprocessor Confiquration Register */
566
567#define HPPA_CR11    11
568#define HPPA_SAR     11              /* Shift Amount Register */
569
570#define HPPA_CR12    12
571#define HPPA_PIDR3   12              /* Protection ID 3 */
572
573#define HPPA_CR13    13
574#define HPPA_PIDR4   13              /* Protection ID 4 */
575
576#define HPPA_CR14    14
577#define HPPA_IVA     14              /* Interrupt Vector Address */
578
579#define HPPA_CR15    15
580#define HPPA_EIEM    15              /* External Interrupt Enable Mask */
581
582#define HPPA_CR16    16
583#define HPPA_ITMR    16              /* Interval Timer */
584
585#define HPPA_CR17    17
586#define HPPA_PCSQ    17              /* Program Counter Space queue */
587
588#define HPPA_CR18    18
589#define HPPA_PCOQ    18              /* Program Counter Offset queue */
590
591#define HPPA_CR19    19
592#define HPPA_IIR     19              /* Interruption Instruction Register */
593
594#define HPPA_CR20    20
595#define HPPA_ISR     20              /* Interruption Space Register */
596
597#define HPPA_CR21    21
598#define HPPA_IOR     21              /* Interruption Offset Register */
599
600#define HPPA_CR22    22
601#define HPPA_IPSW    22              /* Interrpution Processor Status Word */
602
603#define HPPA_CR23    23
604#define HPPA_EIRR    23              /* External Interrupt Request */
605
606#define HPPA_CR24    24
607#define HPPA_PPDA    24              /* Physcial Page Directory Address */
608#define HPPA_TR0     24              /* Temporary register 0 */
609
610#define HPPA_CR25    25
611#define HPPA_HTA     25              /* Hash Table Address */
612#define HPPA_TR1     25              /* Temporary register 1 */
613
614#define HPPA_CR26    26
615#define HPPA_TR2     26              /* Temporary register 2 */
616
617#define HPPA_CR27    27
618#define HPPA_TR3     27              /* Temporary register 3 */
619
620#define HPPA_CR28    28
621#define HPPA_TR4     28              /* Temporary register 4 */
622
623#define HPPA_CR29    29
624#define HPPA_TR5     29              /* Temporary register 5 */
625
626#define HPPA_CR30    30
627#define HPPA_TR6     30              /* Temporary register 6 */
628
629#define HPPA_CR31    31
630#define HPPA_CPUID   31              /* MP identifier */
631
632/*
633 * Diagnose registers
634 */
635
636#define HPPA_DR0      0
637#define HPPA_DR1      1
638#define HPPA_DR8      8
639#define HPPA_DR24    24
640#define HPPA_DR25    25
641
642/*
643 * Tear apart a break instruction to find its type.
644 */
645#define HPPA_BREAK5(x)          ((x) & 0x1F)
646#define HPPA_BREAK13(x)         (((x) >> 13) & 0x1FFF)
647
648/* assemble a break instruction */
649#define HPPA_BREAK(i5,i13)      (((i5) & 0x1F) | (((i13) & 0x1FFF) << 13))
650
651
652/*
653 * this won't work in ASM or non-GNU compilers
654 */
655
656#if !defined(ASM) && defined(__GNUC__)
657
658/*
659 * static inline utility functions to get at control registers
660 */
661
662#define EMIT_GET_CONTROL(name, reg)            \
663static __inline__ unsigned int                 \
664get_ ## name (void)                            \
665{                                              \
666    unsigned int value;                        \
667    HPPA_ASM_MFCTL(reg, value);                \
668    return value;                              \
669}
670
671#define EMIT_SET_CONTROL(name, reg)            \
672static __inline__ void                         \
673set_ ## name (unsigned int new_value)          \
674{                                              \
675    HPPA_ASM_MTCTL(new_value, reg);            \
676}
677
678#define EMIT_CONTROLS(name, reg)               \
679    EMIT_GET_CONTROL(name, reg)                \
680    EMIT_SET_CONTROL(name, reg)
681
682EMIT_CONTROLS(recovery, HPPA_RCTR);          /* CR0  */
683EMIT_CONTROLS(pid1, HPPA_PIDR1);             /* CR8  */
684EMIT_CONTROLS(pid2, HPPA_PIDR2);             /* CR9  */
685EMIT_CONTROLS(ccr, HPPA_CCR);                /* CR10; CCR and SCR share CR10 */
686EMIT_CONTROLS(scr, HPPA_CCR);                /* CR10; CCR and SCR share CR10 */
687EMIT_CONTROLS(sar, HPPA_SAR);                /* CR11 */
688EMIT_CONTROLS(pid3, HPPA_PIDR3);             /* CR12 */
689EMIT_CONTROLS(pid4, HPPA_PIDR4);             /* CR13 */
690EMIT_CONTROLS(iva, HPPA_IVA);                /* CR14 */
691EMIT_CONTROLS(eiem, HPPA_EIEM);              /* CR15 */
692EMIT_CONTROLS(itimer, HPPA_ITMR);            /* CR16 */
693EMIT_CONTROLS(pcsq, HPPA_PCSQ);              /* CR17 */
694EMIT_CONTROLS(pcoq, HPPA_PCOQ);              /* CR18 */
695EMIT_CONTROLS(iir, HPPA_IIR);                /* CR19 */
696EMIT_CONTROLS(isr, HPPA_ISR);                /* CR20 */
697EMIT_CONTROLS(ior, HPPA_IOR);                /* CR21 */
698EMIT_CONTROLS(ipsw, HPPA_IPSW);              /* CR22 */
699EMIT_CONTROLS(eirr, HPPA_EIRR);              /* CR23 */
700EMIT_CONTROLS(tr0, HPPA_TR0);                /* CR24 */
701EMIT_CONTROLS(tr1, HPPA_TR1);                /* CR25 */
702EMIT_CONTROLS(tr2, HPPA_TR2);                /* CR26 */
703EMIT_CONTROLS(tr3, HPPA_TR3);                /* CR27 */
704EMIT_CONTROLS(tr4, HPPA_TR4);                /* CR28 */
705EMIT_CONTROLS(tr5, HPPA_TR5);                /* CR29 */
706EMIT_CONTROLS(tr6, HPPA_TR6);                /* CR30 */
707EMIT_CONTROLS(tr7, HPPA_CR31);               /* CR31 */
708
709#endif /* ASM and GNU */
710
711/*
712 * If and How to invoke the debugger (a ROM debugger generally)
713 */
714#define CPU_INVOKE_DEBUGGER \
715    do { \
716        HPPA_ASM_BREAK(1,1); \
717    } while (0)
718
719#ifdef __cplusplus
720}
721#endif
722
723#endif /* ! _INCLUDE_HPPA_H */
724
Note: See TracBrowser for help on using the repository browser.