1    /*
2     * Some or all of this work - Copyright (c) 2006 - 2021, Intel Corp.
3     * All rights reserved.
4     *
5     * Redistribution and use in source and binary forms, with or without modification,
6     * are permitted provided that the following conditions are met:
7     *
8     * Redistributions of source code must retain the above copyright notice,
9     * this list of conditions and the following disclaimer.
10     * Redistributions in binary form must reproduce the above copyright notice,
11     * this list of conditions and the following disclaimer in the documentation
12     * and/or other materials provided with the distribution.
13     * Neither the name of Intel Corporation nor the names of its contributors
14     * may be used to endorse or promote products derived from this software
15     * without specific prior written permission.
16     *
17     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20     * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23     * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25     * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27     */
28    /*
29     * Bug 294:
30     *
31     * SUMMARY: _ERR method can not be evaluated when AE_OWNER_ID_LIMIT is emitted
32     */
33    Device (D294)
34    {
35        Name (BUF0, Buffer (0x34)
36        {
37            /* 0000 */  0x53, 0x53, 0x44, 0x54, 0x34, 0x00, 0x00, 0x00,  // SSDT4...
38            /* 0008 */  0x02, 0xEB, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x00,  // ..Intel.
39            /* 0010 */  0x4D, 0x61, 0x6E, 0x79, 0x00, 0x00, 0x00, 0x00,  // Many....
40            /* 0018 */  0x01, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C,  // ....INTL
41            /* 0020 */  0x08, 0x12, 0x06, 0x20, 0x14, 0x0F, 0x5C, 0x53,  // ... ..\S
42            /* 0028 */  0x53, 0x30, 0x30, 0x00, 0xA4, 0x0D, 0x5C, 0x53,  // S00...\S
43            /* 0030 */  0x53, 0x30, 0x30, 0x00                           // S00.
44        })
45        Name (BUF1, Buffer (0x5F)
46        {
47            /* 0000 */  0x53, 0x53, 0x44, 0x54, 0x5F, 0x00, 0x00, 0x00,  // SSDT_...
48            /* 0008 */  0x02, 0x33, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x00,  // .3Intel.
49            /* 0010 */  0x4D, 0x61, 0x6E, 0x79, 0x00, 0x00, 0x00, 0x00,  // Many....
50            /* 0018 */  0x01, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C,  // ....INTL
51            /* 0020 */  0x15, 0x12, 0x06, 0x20, 0x10, 0x1F, 0x5C, 0x00,  // ... ..\.
52            /* 0028 */  0x08, 0x4E, 0x41, 0x42, 0x53, 0x0D, 0x61, 0x62,  // .NABS.ab
53            /* 0030 */  0x73, 0x6F, 0x6C, 0x75, 0x74, 0x65, 0x20, 0x6C,  // solute l
54            /* 0038 */  0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20,  // ocation
55            /* 0040 */  0x6F, 0x62, 0x6A, 0x00, 0x08, 0x4E, 0x43, 0x52,  // obj..NCR
56            /* 0048 */  0x52, 0x0D, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6E,  // R.curren
57            /* 0050 */  0x74, 0x20, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x69,  // t locati
58            /* 0058 */  0x6F, 0x6E, 0x20, 0x6F, 0x62, 0x6A, 0x00         // on obj.
59        })
60        OperationRegion (IST1, SystemMemory, 0x0100, 0x5F)
61        Field (IST1, ByteAcc, NoLock, Preserve)
62        {
63            RFU1,   760
64        }
65
66        Name (BUF3, Buffer (0x011F)
67        {
68            /* 0000 */  0x53, 0x53, 0x44, 0x54, 0x1F, 0x01, 0x00, 0x00,  // SSDT....
69            /* 0008 */  0x02, 0x58, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x00,  // .XIntel.
70            /* 0010 */  0x4D, 0x61, 0x6E, 0x79, 0x00, 0x00, 0x00, 0x00,  // Many....
71            /* 0018 */  0x01, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C,  // ....INTL
72            /* 0020 */  0x15, 0x12, 0x06, 0x20, 0x5B, 0x82, 0x49, 0x0F,  // ... [.I.
73            /* 0028 */  0x41, 0x55, 0x58, 0x44, 0x08, 0x49, 0x4E, 0x54,  // AUXD.INT
74            /* 0030 */  0x30, 0x0E, 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA,  // 0..2Tv..
75            /* 0038 */  0xDC, 0xFE, 0x08, 0x53, 0x54, 0x52, 0x30, 0x0D,  // ...STR0.
76            /* 0040 */  0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x20, 0x73,  // source s
77            /* 0048 */  0x74, 0x72, 0x69, 0x6E, 0x67, 0x30, 0x00, 0x08,  // tring0..
78            /* 0050 */  0x42, 0x55, 0x46, 0x30, 0x11, 0x0C, 0x0A, 0x09,  // BUF0....
79            /* 0058 */  0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,  // ........
80            /* 0060 */  0x01, 0x08, 0x50, 0x41, 0x43, 0x30, 0x12, 0x27,  // ..PAC0.'
81            /* 0068 */  0x03, 0x0E, 0x1F, 0x32, 0x54, 0x76, 0x98, 0xBA,  // ...2Tv..
82            /* 0070 */  0xDC, 0xFE, 0x0D, 0x74, 0x65, 0x73, 0x74, 0x20,  // ...test
83            /* 0078 */  0x70, 0x61, 0x63, 0x6B, 0x61, 0x67, 0x65, 0x30,  // package0
84            /* 0080 */  0x00, 0x11, 0x0C, 0x0A, 0x09, 0x13, 0x12, 0x11,  // ........
85            /* 0088 */  0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x5B, 0x81,  // ......[.
86            /* 0090 */  0x0B, 0x4F, 0x50, 0x52, 0x30, 0x01, 0x46, 0x4C,  // .OPR0.FL
87            /* 0098 */  0x55, 0x30, 0x20, 0x5B, 0x82, 0x10, 0x44, 0x45,  // U0 [..DE
88            /* 00A0 */  0x56, 0x30, 0x08, 0x53, 0x30, 0x30, 0x30, 0x0D,  // V0.S000.
89            /* 00A8 */  0x44, 0x45, 0x56, 0x30, 0x00, 0x5B, 0x02, 0x45,  // DEV0.[.E
90            /* 00B0 */  0x56, 0x45, 0x30, 0x14, 0x09, 0x4D, 0x4D, 0x4D,  // VE0..MMM
91            /* 00B8 */  0x30, 0x00, 0xA4, 0x0A, 0x00, 0x5B, 0x01, 0x4D,  // 0....[.M
92            /* 00C0 */  0x54, 0x58, 0x30, 0x00, 0x5B, 0x80, 0x4F, 0x50,  // TX0.[.OP
93            /* 00C8 */  0x52, 0x30, 0x00, 0x0C, 0x21, 0x43, 0x65, 0x07,  // R0..!Ce.
94            /* 00D0 */  0x0A, 0x98, 0x5B, 0x84, 0x13, 0x50, 0x57, 0x52,  // ..[..PWR
95            /* 00D8 */  0x30, 0x00, 0x00, 0x00, 0x08, 0x53, 0x30, 0x30,  // 0....S00
96            /* 00E0 */  0x30, 0x0D, 0x50, 0x57, 0x52, 0x30, 0x00, 0x5B,  // 0.PWR0.[
97            /* 00E8 */  0x83, 0x16, 0x43, 0x50, 0x55, 0x30, 0x00, 0xFF,  // ..CPU0..
98            /* 00F0 */  0xFF, 0xFF, 0xFF, 0x00, 0x08, 0x53, 0x30, 0x30,  // .....S00
99            /* 00F8 */  0x30, 0x0D, 0x43, 0x50, 0x55, 0x30, 0x00, 0x5B,  // 0.CPU0.[
100            /* 0100 */  0x85, 0x10, 0x54, 0x5A, 0x4E, 0x30, 0x08, 0x53,  // ..TZN0.S
101            /* 0108 */  0x30, 0x30, 0x30, 0x0D, 0x54, 0x5A, 0x4E, 0x30,  // 000.TZN0
102            /* 0110 */  0x00, 0x5B, 0x13, 0x42, 0x55, 0x46, 0x30, 0x0A,  // .[.BUF0.
103            /* 0118 */  0x00, 0x0A, 0x45, 0x42, 0x46, 0x4C, 0x30         // ..EBFL0
104        })
105        OperationRegion (IST3, SystemMemory, 0x0400, 0x011F)
106        Field (IST3, ByteAcc, NoLock, Preserve)
107        {
108            RFU3,   2296
109        }
110
111        Name (SNML, "0123456789ABCDEF")
112        Name (NNML, 0x10) /* <= sizeof (SNML) */
113        /* Take into account AE_OWNER_ID_LIMIT */
114
115        Name (HI0M, 0x0100) /* <= (NNML * NNML) */
116        Name (HI0N, 0x00)
117        Name (INIF, 0x00)
118        Method (_ERR, 3, NotSerialized)
119        {
120            Debug = "_ERR exception handler"
121            Return (0x00)
122        }
123
124        Method (CHSM, 2, Serialized)
125        {
126            Name (LPN0, 0x00)
127            Name (LPC0, 0x00)
128            Local0 = 0x00 /* sum */
129            LPN0 = Arg1
130            LPC0 = 0x00
131            While (LPN0)
132            {
133                Local1 = DerefOf (Arg0 [LPC0])
134                Local0 += Local1
135                Local0 %= 0x0100
136                LPN0--
137                LPC0++
138            }
139
140            Local0 = (0x00 - Local0)
141            Local0 %= 0x0100
142            Debug = "checksum"
143            Debug = Local0
144            Return (Local0)
145        }
146
147        /* Initializes multiple Tables Load test */
148
149        Method (INIT, 0, NotSerialized)
150        {
151            Local0 = SizeOf (SNML)
152            If ((NNML > Local0))
153            {
154                Debug = Concatenate ("INIT: test error, check NNML <= Sizeof(SNML):", ToDecimalString (Local0))
155                Return (0x01)
156            }
157
158            Local0 *= Local0
159            If ((HI0M > Local0))
160            {
161                Debug = Concatenate ("INIT: test error, check HI0M <= 0x", Local0)
162                Return (0x01)
163            }
164
165            Return (0x00)
166        }
167
168        /* Prepares and Loads the next Table of multiple Tables Load test */
169
170        Method (LD, 0, Serialized)
171        {
172            If ((HI0N >= HI0M))
173            {
174                Debug = "LD: too many tables loaded"
175                Return (0x01)
176            }
177
178            Local2 = (HI0N * 0x30)
179            OperationRegion (IST0, SystemMemory, Local2, 0x34)
180            Field (IST0, ByteAcc, NoLock, Preserve)
181            {
182                RFU0,   416
183            }
184
185            Field (IST0, ByteAcc, NoLock, Preserve)
186            {
187                SIG,    32,
188                LENG,   32,
189                REV,    8,
190                SUM,    8,
191                OID,    48,
192                OTID,   64,
193                OREV,   32,
194                CID,    32,
195                CREV,   32,
196                Offset (0x27),
197                SSNM,   32,
198                Offset (0x2F),
199                SSRT,   32
200            }
201
202            RFU0 = BUF0 /* \D294.BUF0 */
203            /* Modify Revision field of SSDT */
204
205            Store ((CREV + 0x01), CREV) /* \D294.LD__.CREV */
206            /* Modify SSNM Object Name */
207
208            Divide (HI0N, NNML, Local0, Local1)
209            Local1 = DerefOf (SNML [Local1])
210            Local1 <<= 0x10
211            Local0 = DerefOf (SNML [Local0])
212            Local0 <<= 0x18
213            Local0 += Local1
214            Local0 += 0x5353
215            SSNM = Local0
216            Debug = SSNM /* \D294.LD__.SSNM */
217            /* Modify SSNM Method Return String */
218
219            SSRT = Local0
220            /* Recalculate and save CheckSum */
221
222            Local0 = RFU0 /* \D294.LD__.RFU0 */
223            Store ((SUM + CHSM (Local0, SizeOf (Local0))), SUM) /* \D294.LD__.SUM_ */
224            Load (RFU0, Local3)
225            HI0N++
226            Debug = "LD: SSDT Loaded"
227            Return (0x00)
228        }
229
230        Method (TST0, 0, Serialized)
231        {
232            Name (MAXT, 0xFA)
233            Name (DDB1, 0x00)
234            Name (DDB3, 0x00)
235            If (INIT ())
236            {
237                ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, 0x00, 0x00)
238                Return (0x01)
239            }
240
241            RFU1 = BUF1 /* \D294.BUF1 */
242            RFU3 = BUF3 /* \D294.BUF3 */
243            Local0 = MAXT /* \D294.TST0.MAXT */
244            While (Local0)
245            {
246                /*			Store(HI0N, Debug) */
247
248                If (LD ())
249                {
250                    ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local0, HI0N)
251                    Return (0x01)
252                }
253
254                Local0--
255            }
256
257            /* Methods can not be called after the following Load */
258            /* (OWNER_ID is exhausted) */
259            Load (RFU1, DDB1) /* \D294.TST0.DDB1 */
260            Debug = "SSDT1 Loaded"
261            /* The following Load should cause AE_OWNER_ID_LIMIT */
262
263            Load (RFU3, DDB3) /* \D294.TST0.DDB3 */
264            CH04 (__METHOD__, 0x00, 0xFF, 0x00, __LINE__, 0x00, 0x00)
265            Return (0x00)
266        }
267    }
268
269    Method (M294, 0, NotSerialized)
270    {
271        \D294.TST0 ()
272    }
273