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     * Resource Descriptor macros
30     *
31     * Memory32() Memory Resource Descriptor Macro
32     */
33    Name (P412, Package (0x03)
34    {
35        ResourceTemplate ()
36        {
37            Memory32 (ReadOnly,
38                0xF0F1F2F3,         // Range Minimum
39                0xF4F5F6F7,         // Range Maximum
40                0xF8F9FAFB,         // Alignment
41                0xFCFDFEFF,         // Length
42                )
43        },
44
45        ResourceTemplate ()
46        {
47            Memory32 (ReadWrite,
48                0xF0F1F2F3,         // Range Minimum
49                0xF4F5F6F7,         // Range Maximum
50                0xF8F9FAFB,         // Alignment
51                0xFCFDFEFF,         // Length
52                )
53        },
54
55        ResourceTemplate ()
56        {
57            Memory32 (ReadWrite,
58                0x00000000,         // Range Minimum
59                0x00000000,         // Range Maximum
60                0x00000000,         // Alignment
61                0x00000000,         // Length
62                )
63        }
64    })
65    /*
66     ACPI Specification, Revision 3.0, September 2, 2004
67     6.4.3.3   32-Bit Memory Range Descriptor
68     32-Bit Memory Range Descriptor layout:
69     Byte 0 (Tag Bits): Value = 10000101B (0x85) (Type = 1, Large item name = 0x5)
70     Byte 1 (Length, bits[7:0]): Value = 00010001B (17)
71     Byte 2 (Length, bits[15:8]): Value = 00000000B (0)
72     Byte 3 (Information):
73     Bit[7:1]	Ignored
74     Bit[0]		Write status, _RW
75     1	writeable (read/write)
76     0	non-writeable (read-only)
77     Byte 4 (Range minimum base address, _MIN, bits[7:0])
78     Byte 5 (Range minimum base address, _MIN, bits[15:8]
79     Byte 6 (Range minimum base address, _MIN, bits[23:16])
80     Byte 7 (Range minimum base address, _MIN, bits[31:24])
81     Byte 8 (Range maximum base address, _MAX, bits[7:0])
82     Byte 9 (Range maximum base address, _MAX, bits[15:8])
83     Byte 10 (Range maximum base address, _MAX, bits[23:16])
84     Byte 11 (Range maximum base address, _MAX, bits[31:24])
85     Byte 12 (Base alignment, _ALN bits[7:0])
86     Byte 13 (Base alignment, _ALN bits[15:8])
87     Byte 14 (Base alignment, _ALN bits[23:16])
88     Byte 15 (Base alignment, _ALN bits[31:24])
89     Byte 16 (Range length, _LEN bits[7:0])
90     Byte 17 (Range length, _LEN, bits[15:8])
91     Byte 18 (Range length, _LEN, bits[23:16])
92     Byte 19 (Range length, _LEN, bits[31:24])
93     */
94    Name (P413, Package (0x03)
95    {
96        ResourceTemplate ()
97        {
98            Memory32 (ReadOnly,
99                0xF0F1F2F3,         // Range Minimum
100                0xF4F5F6F7,         // Range Maximum
101                0xF8F9FAFB,         // Alignment
102                0xFCFDFEFF,         // Length
103                )
104        },
105
106        ResourceTemplate ()
107        {
108            Memory32 (ReadWrite,
109                0xF0F1F2F3,         // Range Minimum
110                0xF4F5F6F7,         // Range Maximum
111                0xF8F9FAFB,         // Alignment
112                0xFCFDFEFF,         // Length
113                )
114        },
115
116        ResourceTemplate ()
117        {
118            Memory32 (ReadWrite,
119                0x00000000,         // Range Minimum
120                0x00000000,         // Range Maximum
121                0x00000000,         // Alignment
122                0x00000000,         // Length
123                )
124        }
125    })
126    Method (RT0A, 0, Serialized)
127    {
128        /* Emit test header, set the filename */
129
130        THDR (__METHOD__, "Memory32 Resource Descriptor Macro", "memory32.asl")
131        /* Main test case for packages above */
132
133        M330 (__METHOD__, 0x03, "p412", P412, P413)
134        /* Check resource descriptor tag offsets */
135
136        Local0 = ResourceTemplate ()
137            {
138                Memory32 (ReadOnly,
139                    0xF0F1F2F3,         // Range Minimum
140                    0xF4F5F6F7,         // Range Maximum
141                    0xF8F9FAFB,         // Alignment
142                    0xFCFDFEFF,         // Length
143                    )
144                Memory32 (ReadOnly,
145                    0xF0F1F2F3,         // Range Minimum
146                    0xF4F5F6F7,         // Range Maximum
147                    0xF8F9FAFB,         // Alignment
148                    0xFCFDFEFF,         // Length
149                    )
150            }
151        M331 (__METHOD__, 0x01, 0x18, 0x18, 0xB8, 0xB8, "_RW")
152        M331 (__METHOD__, 0x02, 0x20, 0x20, 0xC0, 0xC0, "_MIN")
153        M331 (__METHOD__, 0x03, 0x40, 0x40, 0xE0, 0xE0, "_MAX")
154        M331 (__METHOD__, 0x04, 0x60, 0x60, 0x0100, 0x0100, "_ALN")
155        M331 (__METHOD__, 0x05, 0x80, 0x80, 0x0120, 0x0120, "_LEN")
156    }
157