summaryrefslogtreecommitdiffstats
path: root/src/occ/gpe/gpe_macros.h
blob: 9a34f98a00d0346206fed0c7aca24dd7f41edcc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/occ/gpe/gpe_macros.h $                                    */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2011,2014                        */
/* [+] Google Inc.                                                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

#ifndef _GPE_MACROS_H
#define _GPE_MACROS_H

//--------------------------------------------------------------------
// Macro Specification:
//
// Name: _saveffdc
//
// Description:  Save FFDC into error structure
//
//     struct {
//         uint64_t rc;          // This should be read as 63:32=addr, 31:0=rc
//         uint64_t ffdc;        // Whatever GPE program puts in for FFDC data
//     } PoreGpeErrorStruct;
//
//               - Copy D0 into PoreGpeErrorStruct->ffdc
//               - Copy \gpe_id into PoreGpeErrorStruct->rc[63:32]
//               - Copy \rc into PoreGpeErrorStruct->rc[31:0]
//
// Inputs:       \gpe_id - Unique GPE program number to identify what prog failed
//               \rc - Unique GPE error code that will indicate failure
//               ETR         - Assumed to be set to base address of
//                             passed argument structure
//
// End Macro Specification
//--------------------------------------------------------------------
.macro _saveffdc, gpe_id, rc

    // Make sure passed Structure Pointer is loaded into A1
    mr      A1, ETR

    // Save address to send back (upper word of D1)
    srdi    D1, D1, 32
    // TODO: Simcs does not support SPRG0 yet, so use 24 bit CTR for now
    //mr      SPRG0, D1
    mr      CTR, D1

    // Check if rc was already saved...
    ld      D1, 0, A1
    andi    D1, D1, 0xFFFFFFFF00000000
    branz   D1, 1f

    // Save D0 into FFDC of error structure
    std     D0, 8, A1
    ld      D0, 8, A1

    // Save address to send back... (truncated to 24 bits)
    mr      D0, CTR
    // Save GPE progam ID
    li      D1, \gpe_id
    sldi    D1, D1, 16
    // and return code
    ori     D1, D1, \rc
    sldi    D1, D1, 32
    // combine GPE program/RC with address
    or      D0, D0, D1

    // Save data into error structure
    std     D0, 0, A1
    ld      D0, 8, A1
    ld      D0, 0, A1

1:
.endm


//--------------------------------------------------------------------
// Macro Specification:
//
// Name: _getscom
//
// Description:  Get a SCOM based on passed in Address, put it in D0
//
// Inputs:       SCOM Address
//
// Outputs:      D0 - Result of SCOM
//
// End Macro Specification
//--------------------------------------------------------------------
.macro _getscom, address

    lpcs    P0, \address
    ld      D0, \address, P0
.endm

//--------------------------------------------------------------------
// Macro Specification:
//
// Name: _putscom
//
// Description:  Store data into SCOM based on passed in Address
//
// Inputs:       SCOM Address, Data
//
// Outputs:      None
//
// End Macro Specification
//--------------------------------------------------------------------
.macro _putscom, address, data
    lpcs    P0, \address
    li      D0, \data
    std     D0, \address, P0
.endm

//--------------------------------------------------------------------
// Macro Specification:
//
// Name: _putscom_d0
//
// Description:  Store D0 into SCOM based on passed in Address
//
// Inputs:       SCOM Address
//
// Outputs:      None
//
// End Macro Specification
//--------------------------------------------------------------------
.macro _putscom_d0, address
    lpcs    P0, \address
    std     D0, \address, P0
.endm

#define TOD_VALUE_REG 0x00040020

// Constant for use in wait statments: waits (5 * MICROSECONDS)
#define MICROSECONDS 600

#endif  //_GPE_MACROS_H
OpenPOWER on IntegriCloud