RTEMS 7.0-rc1
Loading...
Searching...
No Matches
grlib-tn-0018.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2020 Cobham Gaisler AB
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37/* NOTE: the lda should be on offset 0x18 */
38#if defined(__FIX_LEON3FT_TN0018)
39
40/* LEON3 Cache controller register accessed via ASI 2 */
41#define ASI_CTRL 0x02
42#define CCTRL_IP_BIT 15
43#define CCTRL_ICS 0x3
44
45/*
46 * l3: (out) original cctrl
47 * l4: (out) original cctrl with ics=0
48 * NOTE: This macro modifies psr.icc.
49 */
50.macro TN0018_WAIT_IFLUSH out1 out2
511:
52 ! wait for pending iflush to complete
53 lda [%g0] ASI_CTRL, \out1
54 srl \out1, CCTRL_IP_BIT, \out2
55 andcc \out2, 1, %g0
56 bne 1b
57 andn \out1, CCTRL_ICS, \out2
58.endm
59
60.macro TN0018_WRITE_PSR src
61 wr \src, %psr
62.endm
63
64/* Prevent following jmp;rett sequence from "re-executing" due to cached RETT or source
65 * registers (l1 and l2) containing bit faults triggering ECC.
66 *
67 * l3: (in) original cctrl
68 * l4: (in) original cctrl with ics=0
69 * NOTE: This macro MUST be immediately followed by the "jmp;rett" pair.
70 */
71.macro TN0018_FIX in1 in2
72 .align 0x20 ! align the sta for performance
73 sta \in2, [%g0] ASI_CTRL ! disable icache
74 nop ! delay for sta to have effect on rett
75 or %l1, %l1, %l1 ! delay + catch rf parity error on l1
76 or %l2, %l2, %l2 ! delay + catch rf parity error on l2
77 sta \in1, [%g0] ASI_CTRL ! re-enable icache after rett
78 nop ! delay ensures insn after gets cached
79.endm
80
81#else
82
83.macro TN0018_WAIT_IFLUSH out1 out2
84.endm
85
86.macro TN0018_WRITE_PSR src
87.endm
88
89.macro TN0018_FIX in1 in2
90.endm
91
92#endif
93
#define nop()
Definition: sparc.h:281