source: rtems/cpukit/score/cpu/hppa1.1/rtems/score/hppa.h @ 14b5387

4.104.114.84.95
Last change on this file since 14b5387 was 14b5387, checked in by Joel Sherrill <joel.sherrill@…>, on 09/25/00 at 18:58:50

2000-09-25 Joel Sherrill <joel@…>

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