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     * Memory24() Memory Resource Descriptor Macro
32     */
33    Name (P40E, Package (0x03)
34    {
35        ResourceTemplate ()
36        {
37            Memory24 (ReadOnly,
38                0xF0F1,             // Range Minimum
39                0xF2F3,             // Range Maximum
40                0xF4F5,             // Alignment
41                0xF6F7,             // Length
42                )
43        },
44
45        ResourceTemplate ()
46        {
47            Memory24 (ReadWrite,
48                0xF0F1,             // Range Minimum
49                0xF2F3,             // Range Maximum
50                0xF4F5,             // Alignment
51                0xF6F7,             // Length
52                )
53        },
54
55        ResourceTemplate ()
56        {
57            Memory24 (ReadWrite,
58                0x0000,             // Range Minimum
59                0x0000,             // Range Maximum
60                0x0000,             // Alignment
61                0x0000,             // Length
62                )
63        }
64    })
65    /*
66     ACPI Specification, Revision 3.0, September 2, 2004
67     6.4.3.1   24-Bit Memory Range Descriptor
68     24-Bit Memory Range Descriptor layout:
69     Byte 0 (Tag Bits): Value = 10000001B (0x81) (Type = 1, Large item name = 0x1)
70     Byte 1 (Length, bits[7:0]): Value = 00001001B (9)
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     Address bits[15:8] of the minimum base memory address
79     for which the card may be configured.
80     Byte 5 (Range minimum base address, _MIN, bits[15:8]):
81     Address bits[23:16] of the minimum base memory address
82     for which the card may be configured
83     Byte 6 (Range maximum base address, _MAX, bits[7:0]):
84     Address bits[15:8] of the maximum base memory address
85     for which the card may be configured.
86     Byte 7 (Range maximum base address, _MAX, bits[15:8]):
87     Address bits[23:16] of the maximum base memory address
88     for which the card may be configured
89     Byte 8 (Base alignment, _ALN, bits[7:0]):
90     This field contains the lower eight bits of the base alignment.
91     The base alignment provides the increment for the minimum base
92     address. (0x0000 = 64 KB)
93     Byte 9 (Base alignment, _ALN, bits[15:8]):
94     This field contains the upper eight bits of the base alignment.
95     Byte 10 (Range length, _LEN, bits[7:0]):
96     This field contains the lower eight bits of the memory range length.
97     The range length provides the length of the memory range in 256 byte blocks.
98     Byte 11 (Range length, _LEN, bits[15:8]):
99     This field contains the upper eight bits of the memory range length.
100     */
101    Name (P40F, Package (0x03)
102    {
103        ResourceTemplate ()
104        {
105            Memory24 (ReadOnly,
106                0xF0F1,             // Range Minimum
107                0xF2F3,             // Range Maximum
108                0xF4F5,             // Alignment
109                0xF6F7,             // Length
110                )
111        },
112
113        ResourceTemplate ()
114        {
115            Memory24 (ReadWrite,
116                0xF0F1,             // Range Minimum
117                0xF2F3,             // Range Maximum
118                0xF4F5,             // Alignment
119                0xF6F7,             // Length
120                )
121        },
122
123        ResourceTemplate ()
124        {
125            Memory24 (ReadWrite,
126                0x0000,             // Range Minimum
127                0x0000,             // Range Maximum
128                0x0000,             // Alignment
129                0x0000,             // Length
130                )
131        }
132    })
133    Method (RT08, 0, Serialized)
134    {
135        /* Emit test header, set the filename */
136
137        THDR (__METHOD__, "Memory24 Resource Descriptor Macro", "memory24.asl")
138        /* Main test case for packages above */
139
140        M330 (__METHOD__, 0x03, "p40e", P40E, P40F)
141        /* Check resource descriptor tag offsets */
142
143        Local0 = ResourceTemplate ()
144            {
145                Memory24 (ReadOnly,
146                    0xF0F1,             // Range Minimum
147                    0xF2F3,             // Range Maximum
148                    0xF4F5,             // Alignment
149                    0xF6F7,             // Length
150                    )
151                Memory24 (ReadOnly,
152                    0xF0F1,             // Range Minimum
153                    0xF2F3,             // Range Maximum
154                    0xF4F5,             // Alignment
155                    0xF6F7,             // Length
156                    )
157            }
158        M331 (__METHOD__, 0x01, 0x18, 0x18, 0x78, 0x78, "_RW")
159        M331 (__METHOD__, 0x02, 0x20, 0x20, 0x80, 0x80, "_MIN")
160        M331 (__METHOD__, 0x03, 0x30, 0x30, 0x90, 0x90, "_MAX")
161        M331 (__METHOD__, 0x04, 0x40, 0x40, 0xA0, 0xA0, "_ALN")
162        M331 (__METHOD__, 0x05, 0x50, 0x50, 0xB0, 0xB0, "_LEN")
163    }
164