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 128:
30     *
31     * SUMMARY: Copying the RefOf reference to Named object spoils that reference
32     */
33    Method (MF17, 0, Serialized)
34    {
35        Name (I000, 0x1234)
36        CopyObject (RefOf (I000), Local0)
37        Debug = Local0
38        Local1 = DerefOf (Local0)
39        Debug = Local1
40        If ((Local1 != 0x1234))
41        {
42            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, 0x1234)
43        }
44    }
45
46    Method (MF18, 0, Serialized)
47    {
48        Name (REF0, 0x00)
49        Name (I000, 0x1234)
50        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
51        CopyObject (RefOf (I000), REF0) /* \MF18.REF0 */
52        Debug = "Before printing ref0"
53        Debug = REF0 /* \MF18.REF0 */
54        Debug = "Before DerefOf"
55        Local1 = DerefOf (REF0)
56        Debug = "Before printing Local1"
57        Debug = Local1
58        Debug = "Before LNotEqual"
59        If ((Local1 != 0x1234))
60        {
61            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, 0x1234)
62        }
63
64        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
65    }
66
67    Method (MF9E, 0, Serialized)
68    {
69        Name (I000, 0xABBC0000)
70        Name (II00, 0xABBC0000)
71        Name (B000, Buffer (0x08)
72        {
73             0x01, 0x02, 0x03, 0x04, 0x95, 0x06, 0x07, 0x08   // ........
74        })
75        Name (BB00, Buffer (0x08)
76        {
77             0x01, 0x02, 0x03, 0x04, 0x95, 0x06, 0x07, 0x08   // ........
78        })
79        Name (S000, "String")
80        Name (SS00, "String")
81        Name (P000, Package (0x04)
82        {
83            0x01,
84            0x02,
85            0x03,
86            0x04
87        })
88        Name (REF0, 0x00)
89        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
90        CopyObject (RefOf (I000), REF0) /* \MF9E.REF0 */
91        MF88 (DerefOf (REF0), C009, II00, 0x01, 0x02, 0x01)
92        CopyObject (RefOf (B000), REF0) /* \MF9E.REF0 */
93        MF88 (DerefOf (REF0), C00B, BB00, 0x03, 0x04, 0x01)
94        CopyObject (RefOf (S000), REF0) /* \MF9E.REF0 */
95        MF88 (DerefOf (REF0), C00A, SS00, 0x03, 0x04, 0x01)
96        CopyObject (RefOf (P000), REF0) /* \MF9E.REF0 */
97        MF88 (DerefOf (REF0), C00C, SS00, 0x05, 0x06, 0x00)
98        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
99    }
100
101    Method (MF9F, 0, Serialized)
102    {
103        Name (REF0, 0x00)
104        Event (E000)
105        Mutex (MX00, 0x00)
106        Device (D000)
107        {
108            Name (I900, 0xABCD0017)
109        }
110
111        ThermalZone (TZ00)
112        {
113        }
114
115        Processor (PR00, 0x00, 0xFFFFFFFF, 0x00){}
116        OperationRegion (R000, SystemMemory, 0x0100, 0x0100)
117        PowerResource (PW00, 0x01, 0x0000)
118        {
119            Method (MMMM, 0, NotSerialized)
120            {
121                Return (0x00)
122            }
123        }
124
125        /* Checkings */
126
127        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
128        CopyObject (RefOf (E000), REF0) /* \MF9F.REF0 */
129        MF88 (DerefOf (REF0), C00F, 0x00, 0x27, 0x28, 0x00)
130        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
131        CopyObject (RefOf (MX00), REF0) /* \MF9F.REF0 */
132        MF88 (DerefOf (REF0), C011, 0x00, 0x2A, 0x2B, 0x00)
133        If (Y511)
134        {
135            CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
136            CopyObject (RefOf (D000), REF0) /* \MF9F.REF0 */
137            MF88 (DerefOf (REF0), C00E, 0x00, 0x2D, 0x2E, 0x00)
138        }
139
140        If (Y508)
141        {
142            CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
143            CopyObject (RefOf (TZ00), REF0) /* \MF9F.REF0 */
144            MF88 (DerefOf (REF0), C015, 0x00, 0x30, 0x31, 0x00)
145        }
146
147        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
148        CopyObject (RefOf (PR00), REF0) /* \MF9F.REF0 */
149        MF88 (DerefOf (REF0), C014, 0x00, 0x33, 0x34, 0x00)
150        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
151        CopyObject (RefOf (R000), REF0) /* \MF9F.REF0 */
152        MF88 (DerefOf (REF0), C012, 0x00, 0x36, 0x37, 0x00)
153        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
154        CopyObject (RefOf (PW00), REF0) /* \MF9F.REF0 */
155        MF88 (DerefOf (REF0), C013, 0x00, 0x39, 0x3A, 0x00)
156    }
157