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     *  Field Unit
30     *
31     * (verify exceptions caused by the imprope use of Field Unit type objects)
32     */
33    Name (Z097, 0x61)
34    OperationRegion (RG01, SystemMemory, 0x0100, 0x0100)
35    Field (RG01, ByteAcc, NoLock, Preserve)
36    {
37        FU00,   31,
38        FU01,   65
39    }
40
41    Name (II70, 0xABCD1234)
42    Name (BI00, Buffer (0x09)
43    {
44        /* 0000 */  0xA4, 0xA5, 0xA6, 0xA7, 0xB8, 0xB9, 0xBA, 0xBB,  // ........
45        /* 0008 */  0xBC                                             // .
46    })
47    /* Expected exceptions: */
48    /* */
49    /* 47 - AE_AML_OPERAND_TYPE */
50    /* See notes to m4b1 and m4b3 */
51    /* */
52    Method (M4B5, 0, Serialized)
53    {
54        Field (RG01, ByteAcc, NoLock, Preserve)
55        {
56            Offset (0x0C),
57            FU02,   31,
58            FU03,   65
59        }
60
61        /* Local Named Object */
62
63        Method (M000, 1, Serialized)
64        {
65            Field (RG01, ByteAcc, NoLock, Preserve)
66            {
67                Offset (0x18),
68                FU02,   31,
69                FU03,   65
70            }
71
72            FU02 = II70 /* \II70 */
73            FU03 = BI00 /* \BI00 */
74            /* Like Integer behaviour */
75
76            If (Y083)
77            {
78                Local1 = DerefOf (FU02)
79                CH06 (Arg0, 0x00, 0x2F)
80            }
81
82            Store (FU02 [0x00], Local1)
83            CH06 (Arg0, 0x01, 0x2F)
84            /* Like Buffer behaviour */
85
86            If (Y083)
87            {
88                Local1 = DerefOf (FU03)
89                CH06 (Arg0, 0x02, 0x2F)
90            }
91
92            Store (FU03 [0x00], Local1)
93            If (Y900)
94            {
95                CH03 (__METHOD__, Z097, __LINE__, 0x00, 0x00)
96            }
97            Else
98            {
99                CH04 (__METHOD__, 0x00, 0x55, Z094, __LINE__, 0x00, 0x00) /* AE_INDEX_TO_NOT_ATTACHED */
100            }
101        }
102
103        /* Global Named Object */
104
105        Method (M001, 1, NotSerialized)
106        {
107            FU00 = II70 /* \II70 */
108            FU01 = BI00 /* \BI00 */
109            /* Like Integer behaviour */
110
111            If (Y083)
112            {
113                Local1 = DerefOf (FU00)
114                CH06 (Arg0, 0x03, 0x2F)
115            }
116
117            Store (FU00 [0x00], Local1)
118            CH06 (Arg0, 0x04, 0x2F)
119            /* Like Buffer behaviour */
120
121            If (Y083)
122            {
123                Local1 = DerefOf (FU01)
124                CH06 (Arg0, 0x05, 0x2F)
125            }
126
127            Store (FU01 [0x00], Local1)
128            If (Y900)
129            {
130                CH03 (__METHOD__, Z097, __LINE__, 0x00, 0x00)
131            }
132            Else
133            {
134                CH04 (__METHOD__, 0x00, 0x55, Z094, __LINE__, 0x00, 0x00) /* AE_INDEX_TO_NOT_ATTACHED */
135            }
136        }
137
138        /* Reference to Object */
139
140        Method (M002, 3, NotSerialized)
141        {
142            Debug = Arg0
143            Debug = Arg1
144            Local0 = ObjectType (Arg1)
145            If ((Local0 != 0x05))
146            {
147                ERR (Arg0, Z097, __LINE__, 0x00, 0x00, Local0, 0x05)
148                Return (0x01)
149            }
150
151            Local1 = DerefOf (Arg1)
152            CH03 (__METHOD__, Z097, __LINE__, 0x00, 0x00)
153            Local1 = DerefOf (DerefOf (Arg1))
154            CH06 (Arg0, 0x07, 0x2F)
155            Store (DerefOf (Arg1) [0x00], Local1)
156            If (Arg2)
157            {
158                /* Like Buffer behaviour */
159
160                If (Y900)
161                {
162                    CH03 (__METHOD__, Z097, __LINE__, 0x00, 0x00)
163                }
164                Else
165                {
166                    CH04 (__METHOD__, 0x00, 0x55, Z097, __LINE__, 0x00, 0x00) /* AE_INDEX_TO_NOT_ATTACHED */
167                }
168            }
169            Else
170            {
171                /* Like Integer behaviour */
172
173                CH06 (Arg0, 0x08, 0x2F)
174            }
175
176            Local1 = Match (DerefOf (Arg1), MTR, 0x00, MTR, 0x00, 0x00)
177            CH06 (Arg0, 0x09, 0x2F)
178            Return (0x00)
179        }
180
181        /* Reference to Object as Result of Method invocation */
182
183        Method (M003, 1, Serialized)
184        {
185            Field (RG01, ByteAcc, NoLock, Preserve)
186            {
187                Offset (0x18),
188                FU02,   31,
189                FU03,   65
190            }
191
192            Name (I000, 0x00) /* Label to check m000 invocations */
193            Method (M000, 2, NotSerialized)
194            {
195                I000 = Arg0
196                If ((Arg1 == 0x00))
197                {
198                    Local0 = RefOf (FU00)
199                }
200                ElseIf ((Arg1 == 0x01))
201                {
202                    Local0 = RefOf (FU01)
203                }
204                ElseIf ((Arg1 == 0x02))
205                {
206                    Local0 = RefOf (FU02)
207                }
208                ElseIf ((Arg1 == 0x03))
209                {
210                    Local0 = RefOf (FU03)
211                }
212
213                Return (Local0)
214            }
215
216            Method (CH00, 2, NotSerialized)
217            {
218                If ((I000 != Arg1))
219                {
220                    ERR (Arg0, Z097, __LINE__, 0x00, 0x00, I000, Arg1)
221                }
222            }
223
224            Name (LPN0, 0x04)
225            Name (LPC0, 0x00)
226            FU00 = II70 /* \II70 */
227            FU01 = BI00 /* \BI00 */
228            FU02 = II70 /* \II70 */
229            FU03 = BI00 /* \BI00 */
230            While (LPN0)
231            {
232                Local0 = (0x03 * LPC0) /* \M4B5.M003.LPC0 */
233                I000 = 0x00
234                Local1 = DerefOf (M000 (0x01, LPC0))
235                CH03 (__METHOD__, Z097, __LINE__, 0x00, 0x00)
236                CH00 (Arg0, 0x01)
237                Local1 = DerefOf (DerefOf (M000 (0x02, LPC0)))
238                CH06 (Arg0, (0x0B + Local0), 0x2F)
239                CH00 (Arg0, 0x02)
240                Store (DerefOf (M000 (0x03, LPC0)) [0x00], Local1)
241                If ((LPC0 % 0x02))
242                {
243                    /* Like Buffer behaviour */
244
245                    If (Y900)
246                    {
247                        CH03 (__METHOD__, Z097, __LINE__, 0x00, 0x00)
248                    }
249                    Else
250                    {
251                        CH04 (__METHOD__, 0x00, 0x55, Z097, __LINE__, 0x00, 0x00) /* AE_INDEX_TO_NOT_ATTACHED */
252                    }
253                }
254                Else
255                {
256                    /* Like Integer behaviour */
257
258                    CH06 (Arg0, (0x0C + Local0), 0x2F)
259                }
260
261                CH00 (Arg0, 0x03)
262                Local1 = Match (DerefOf (M000 (0x04, LPC0)), MTR, 0x00, MTR, 0x00, 0x00)
263                CH06 (Arg0, (0x0D + Local0), 0x2F)
264                CH00 (Arg0, 0x04)
265                LPN0--
266                LPC0++
267            }
268        }
269
270        CH03 (__METHOD__, Z097, __LINE__, 0x00, 0x00)
271        /* Local Named Object */
272
273        M000 (__METHOD__)
274        /* Global Named Object */
275
276        M001 (__METHOD__)
277        /* Reference to Local Named Object */
278
279        FU02 = II70 /* \II70 */
280        FU03 = BI00 /* \BI00 */
281        M002 (Concatenate (__METHOD__, "-m002-RefLocNameI"), RefOf (FU02), 0x00)
282        Local0 = RefOf (FU02)
283        M002 (Concatenate (__METHOD__, "-m002-RefLocName2I"), Local0, 0x00)
284        CondRefOf (FU02, Local0)
285        M002 (Concatenate (__METHOD__, "-m002-CondRefLocNameI"), Local0, 0x00)
286        M002 (Concatenate (__METHOD__, "-m002-RefLocNameB"), RefOf (FU03), 0x01)
287        Local0 = RefOf (FU03)
288        M002 (Concatenate (__METHOD__, "-m002-RefLocName2B"), Local0, 0x01)
289        CondRefOf (FU03, Local0)
290        M002 (Concatenate (__METHOD__, "-m002-CondRefLocNameB"), Local0, 0x01)
291        FU00 = II70 /* \II70 */
292        FU01 = BI00 /* \BI00 */
293        M002 (Concatenate (__METHOD__, "-m002-RefGlobNameI"), RefOf (FU00), 0x00)
294        Local0 = RefOf (FU00)
295        M002 (Concatenate (__METHOD__, "-m002-RefGlobName2I"), Local0, 0x00)
296        CondRefOf (FU00, Local0)
297        M002 (Concatenate (__METHOD__, "-m002-CondRefGlobNameI"), Local0, 0x00)
298        M002 (Concatenate (__METHOD__, "-m002-RefGlobNameB"), RefOf (FU01), 0x01)
299        Local0 = RefOf (FU01)
300        M002 (Concatenate (__METHOD__, "-m002-RefGlobName2B"), Local0, 0x01)
301        CondRefOf (FU01, Local0)
302        M002 (Concatenate (__METHOD__, "-m002-CondRefGlobNameB"), Local0, 0x01)
303        /* Reference to Object as Result of Method invocation */
304
305        M003 (__METHOD__)
306    }
307