summaryrefslogtreecommitdiffstats
path: root/src/occ/gpe/pore_test_error.pS
blob: 344bdcb900678adb399d41fbcc2399225f245511 (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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# *****************************************************************************
# @file pore_test_error.S
# @brief A Quick Test Program for PORE Model
# Delays for X (passed in) uS before halting PORE-GPE 
# program.  Always sets an error

# *****************************************************************************
#
#       @page ChangeLogs Change Logs
#       @section pore_test_error.S PORE_TEST_ERROR.S
#       @verbatim
#
#   Flag    Def/Fea    Userid    Date        Description
#   ------- ---------- --------  ----------  ----------------------------------
#   @rc003             rickylie  02/03/2012  Verify & Clean Up OCC Headers & Comments
#
#  @endverbatim
#
# *****************************************************************************


// Input:
//     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;
//
//     struct {
//         PoreGpeErrorStruct error;
//         uint32_t pore_delay;
//     } PoreSimpleArgs;
//
//
//

        //////////////////////////////////////////////////////////////////////
        // Includes
        //////////////////////////////////////////////////////////////////////
        .nolist
#include "pgp.h"
#include "pgas.h"
        .list

        //////////////////////////////////////////////////////////////////////
        // Define Address Space
        //////////////////////////////////////////////////////////////////////
        .oci

        //////////////////////////////////////////////////////////////////////
        // Define Symbols
        //////////////////////////////////////////////////////////////////////
#define TOD_VALUE_REG                 0x00040020
#define SPIPSS_REGISTER_BASE          0x00020000
#define SPIPSS_ADC_CTRL_REG0          (SPIPSS_REGISTER_BASE + 0x00) 
#define SPIPSS_ADC_CTRL_REG1          (SPIPSS_REGISTER_BASE + 0x01) 
#define SPIPSS_ADC_CTRL_REG2          (SPIPSS_REGISTER_BASE + 0x02) 
#define SPIPSS_ADC_STATUS_REG         (SPIPSS_REGISTER_BASE + 0x03)
#define SPIPSS_ADC_COMMAND_REG        (SPIPSS_REGISTER_BASE + 0x04)
#define SPIPSS_ADC_WDATA_REG          (SPIPSS_REGISTER_BASE + 0x10) 
#define SPIPSS_ADC_RDATA_REG0         (SPIPSS_REGISTER_BASE + 0x20) 
#define SPIPSS_ADC_RDATA_REG1         (SPIPSS_REGISTER_BASE + 0x21) 
#define SPIPSS_ADC_RDATA_REG2         (SPIPSS_REGISTER_BASE + 0x22) 
#define SPIPSS_ADC_RDATA_REG3         (SPIPSS_REGISTER_BASE + 0x23) 
#define SPIPSS_P2S_CTRL_REG0          (SPIPSS_REGISTER_BASE + 0x40)
#define SPIPSS_P2S_CTRL_REG1          (SPIPSS_REGISTER_BASE + 0x41)
#define SPIPSS_P2S_CTRL_REG2          (SPIPSS_REGISTER_BASE + 0x42)
#define SPIPSS_P2S_STATUS_REG         (SPIPSS_REGISTER_BASE + 0x43)
#define SPIPSS_P2S_COMMAND_REG        (SPIPSS_REGISTER_BASE + 0x44)
#define SPIPSS_P2S_WDATA_REG          (SPIPSS_REGISTER_BASE + 0x50)
#define SPIPSS_P2S_RDATA_REG          (SPIPSS_REGISTER_BASE + 0x60)


        .set    GPE_PROG_ID, 100
        .set    GPE_ERROR_CODE, 0xAA55AA55
        .set    GPE_ERROR_RC, 0xBEEFCAFE

        //////////////////////////////////////////////////////////////////////
        // Define Structures
        //////////////////////////////////////////////////////////////////////
        
        // Declare the offsets of the struct that will be passed to the 
        // GPE program via the ETR register
        //
        // struct PoreSimpleArgs =
        // {
        .struct     0
RETURN_CODE:
        .struct RETURN_CODE + 8
FFDC:
        .struct FFDC + 8
PORE_DELAY:
        // };
        
        //////////////////////////////////////////////////////////////////////
        // Begin Program
        //////////////////////////////////////////////////////////////////////

        .text

        //--------------------------------------------------------------------
        // Macro Specification:
        // 
        // Name: _saveffdc
        //
        // Description:  Save off RC, FFDC & Address when there is an error 
        //               in a GPE program.
        //               
        //               - Copy D0 into PoreGpeErrorStruct->ffdc
        //               - Copy D1[63:32] into PoreGpeErrorStruct->rc[63:32]
        //               - Copy \error_code into PoreGpeErrorStruct->rc[31:0]
        //
        // Inputs:       \error_code - Unique GPE error code that will
        //                             indicate the failure mode of the GPE
        //                             program.
        //               D0          - Set to FFDC data that will be copied to
        //                             PoreGpeErrorStruct->ffdc
        //               D1          - Bits[63:32] set to address that will be
        //                             copied to PoreGpeErrorStruct->rc[63:32]
        //               ETR         - Assumed to be set to base address of 
        //                             passed argument structure
        //
        // End Macro Specification
        //--------------------------------------------------------------------
        .macro _saveffdc, error_code

        // Make sure passed Structure Pointer is loaded into A1
        mr      A1, ETR
        
        // First save off D0 into FFDC
        std     D0, FFDC, A1  

        // Then save off SPRG0 into the lower 32 bits of D0
        // TODO:  SPRG0 doesn't work in Simics....switching to D1 for now
        mr      D0, D1

        // Save off the address of the start of the GPE program into the 
        // upper 32 bits of D0
        li      D1, \error_code
        sldi    D1, D1, 32
        or      D0, D0, D1

        // Save register off into code_addr 
        std     D0, RETURN_CODE, A1

        .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:  Get a SCOM based on passed in Address, put it in D0
        //
        // Inputs:       SCOM Address, Data
        //
        // Outputs:      None
        //
        // End Macro Specification
        //--------------------------------------------------------------------
	.macro _putscom, address, data

	lpcs	P0, \address
        li      D0, \data
        std     D0, \address, P0

	.endm


        //--------------------------------------------------------------------
        // PORE-GPE Routine Specification:
        //
        // Name: pore_test_error
        // 
        // Description:  Delays for X (passed in) uS before halting PORE-GPE
        //               routine.  Always sets the ffdc to indicate an error
        //               with a RC of 0xDEADBEEF
        //
        // Inputs:       PoreSimpleArgs - FFDC & uS to delay.
        //
        // Outputs:      None (except FFDC on failure)
        //
        // End PORE-GPE Routine Specification
        //--------------------------------------------------------------------
        .global pore_test_error
pore_test_error:
        // Copy passed Structure Pointer into A1
        mr      A1, ETR

        // Read pore_delay parameter into D0 
        ld      D0, PORE_DELAY, A1
        
        // Shift Right so that we only use the upper 32 bits
        // (not passed in as 64 bit value)
        srdi    D0, D0, 32
        
        // Copy pore_delay into CTR so that we can loop
        mr      CTR, D0

        // Set D0 to a value for some fake operation we are testing out
        li      D0, GPE_ERROR_CODE
        li      D1, GPE_ERROR_CODE

        trap
delay_loop:
        waits    600
        nop
        loop    delay_loop
        trap

        //bra     done
error:
        _getscom TOD_VALUE_REG

        _saveffdc 0xDEADBEEF

done:
        


        halt				// End of pore_test

        //////////////////////////////////////////////////////////////////////
        // End of Program
        //////////////////////////////////////////////////////////////////////

OpenPOWER on IntegriCloud