xref: /onnv-gate/usr/src/uts/intel/io/acpica/hardware/hwvalid.c (revision 9980:13d7f3eec672)
1*9980SDana.Myers@Sun.COM 
2*9980SDana.Myers@Sun.COM /******************************************************************************
3*9980SDana.Myers@Sun.COM  *
4*9980SDana.Myers@Sun.COM  * Module Name: hwvalid - I/O request validation
5*9980SDana.Myers@Sun.COM  *
6*9980SDana.Myers@Sun.COM  *****************************************************************************/
7*9980SDana.Myers@Sun.COM 
8*9980SDana.Myers@Sun.COM /******************************************************************************
9*9980SDana.Myers@Sun.COM  *
10*9980SDana.Myers@Sun.COM  * 1. Copyright Notice
11*9980SDana.Myers@Sun.COM  *
12*9980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
13*9980SDana.Myers@Sun.COM  * All rights reserved.
14*9980SDana.Myers@Sun.COM  *
15*9980SDana.Myers@Sun.COM  * 2. License
16*9980SDana.Myers@Sun.COM  *
17*9980SDana.Myers@Sun.COM  * 2.1. This is your license from Intel Corp. under its intellectual property
18*9980SDana.Myers@Sun.COM  * rights.  You may have additional license terms from the party that provided
19*9980SDana.Myers@Sun.COM  * you this software, covering your right to use that party's intellectual
20*9980SDana.Myers@Sun.COM  * property rights.
21*9980SDana.Myers@Sun.COM  *
22*9980SDana.Myers@Sun.COM  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23*9980SDana.Myers@Sun.COM  * copy of the source code appearing in this file ("Covered Code") an
24*9980SDana.Myers@Sun.COM  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25*9980SDana.Myers@Sun.COM  * base code distributed originally by Intel ("Original Intel Code") to copy,
26*9980SDana.Myers@Sun.COM  * make derivatives, distribute, use and display any portion of the Covered
27*9980SDana.Myers@Sun.COM  * Code in any form, with the right to sublicense such rights; and
28*9980SDana.Myers@Sun.COM  *
29*9980SDana.Myers@Sun.COM  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30*9980SDana.Myers@Sun.COM  * license (with the right to sublicense), under only those claims of Intel
31*9980SDana.Myers@Sun.COM  * patents that are infringed by the Original Intel Code, to make, use, sell,
32*9980SDana.Myers@Sun.COM  * offer to sell, and import the Covered Code and derivative works thereof
33*9980SDana.Myers@Sun.COM  * solely to the minimum extent necessary to exercise the above copyright
34*9980SDana.Myers@Sun.COM  * license, and in no event shall the patent license extend to any additions
35*9980SDana.Myers@Sun.COM  * to or modifications of the Original Intel Code.  No other license or right
36*9980SDana.Myers@Sun.COM  * is granted directly or by implication, estoppel or otherwise;
37*9980SDana.Myers@Sun.COM  *
38*9980SDana.Myers@Sun.COM  * The above copyright and patent license is granted only if the following
39*9980SDana.Myers@Sun.COM  * conditions are met:
40*9980SDana.Myers@Sun.COM  *
41*9980SDana.Myers@Sun.COM  * 3. Conditions
42*9980SDana.Myers@Sun.COM  *
43*9980SDana.Myers@Sun.COM  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44*9980SDana.Myers@Sun.COM  * Redistribution of source code of any substantial portion of the Covered
45*9980SDana.Myers@Sun.COM  * Code or modification with rights to further distribute source must include
46*9980SDana.Myers@Sun.COM  * the above Copyright Notice, the above License, this list of Conditions,
47*9980SDana.Myers@Sun.COM  * and the following Disclaimer and Export Compliance provision.  In addition,
48*9980SDana.Myers@Sun.COM  * Licensee must cause all Covered Code to which Licensee contributes to
49*9980SDana.Myers@Sun.COM  * contain a file documenting the changes Licensee made to create that Covered
50*9980SDana.Myers@Sun.COM  * Code and the date of any change.  Licensee must include in that file the
51*9980SDana.Myers@Sun.COM  * documentation of any changes made by any predecessor Licensee.  Licensee
52*9980SDana.Myers@Sun.COM  * must include a prominent statement that the modification is derived,
53*9980SDana.Myers@Sun.COM  * directly or indirectly, from Original Intel Code.
54*9980SDana.Myers@Sun.COM  *
55*9980SDana.Myers@Sun.COM  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56*9980SDana.Myers@Sun.COM  * Redistribution of source code of any substantial portion of the Covered
57*9980SDana.Myers@Sun.COM  * Code or modification without rights to further distribute source must
58*9980SDana.Myers@Sun.COM  * include the following Disclaimer and Export Compliance provision in the
59*9980SDana.Myers@Sun.COM  * documentation and/or other materials provided with distribution.  In
60*9980SDana.Myers@Sun.COM  * addition, Licensee may not authorize further sublicense of source of any
61*9980SDana.Myers@Sun.COM  * portion of the Covered Code, and must include terms to the effect that the
62*9980SDana.Myers@Sun.COM  * license from Licensee to its licensee is limited to the intellectual
63*9980SDana.Myers@Sun.COM  * property embodied in the software Licensee provides to its licensee, and
64*9980SDana.Myers@Sun.COM  * not to intellectual property embodied in modifications its licensee may
65*9980SDana.Myers@Sun.COM  * make.
66*9980SDana.Myers@Sun.COM  *
67*9980SDana.Myers@Sun.COM  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68*9980SDana.Myers@Sun.COM  * substantial portion of the Covered Code or modification must reproduce the
69*9980SDana.Myers@Sun.COM  * above Copyright Notice, and the following Disclaimer and Export Compliance
70*9980SDana.Myers@Sun.COM  * provision in the documentation and/or other materials provided with the
71*9980SDana.Myers@Sun.COM  * distribution.
72*9980SDana.Myers@Sun.COM  *
73*9980SDana.Myers@Sun.COM  * 3.4. Intel retains all right, title, and interest in and to the Original
74*9980SDana.Myers@Sun.COM  * Intel Code.
75*9980SDana.Myers@Sun.COM  *
76*9980SDana.Myers@Sun.COM  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77*9980SDana.Myers@Sun.COM  * Intel shall be used in advertising or otherwise to promote the sale, use or
78*9980SDana.Myers@Sun.COM  * other dealings in products derived from or relating to the Covered Code
79*9980SDana.Myers@Sun.COM  * without prior written authorization from Intel.
80*9980SDana.Myers@Sun.COM  *
81*9980SDana.Myers@Sun.COM  * 4. Disclaimer and Export Compliance
82*9980SDana.Myers@Sun.COM  *
83*9980SDana.Myers@Sun.COM  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84*9980SDana.Myers@Sun.COM  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85*9980SDana.Myers@Sun.COM  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86*9980SDana.Myers@Sun.COM  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87*9980SDana.Myers@Sun.COM  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88*9980SDana.Myers@Sun.COM  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89*9980SDana.Myers@Sun.COM  * PARTICULAR PURPOSE.
90*9980SDana.Myers@Sun.COM  *
91*9980SDana.Myers@Sun.COM  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92*9980SDana.Myers@Sun.COM  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93*9980SDana.Myers@Sun.COM  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94*9980SDana.Myers@Sun.COM  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95*9980SDana.Myers@Sun.COM  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96*9980SDana.Myers@Sun.COM  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97*9980SDana.Myers@Sun.COM  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98*9980SDana.Myers@Sun.COM  * LIMITED REMEDY.
99*9980SDana.Myers@Sun.COM  *
100*9980SDana.Myers@Sun.COM  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101*9980SDana.Myers@Sun.COM  * software or system incorporating such software without first obtaining any
102*9980SDana.Myers@Sun.COM  * required license or other approval from the U. S. Department of Commerce or
103*9980SDana.Myers@Sun.COM  * any other agency or department of the United States Government.  In the
104*9980SDana.Myers@Sun.COM  * event Licensee exports any such software from the United States or
105*9980SDana.Myers@Sun.COM  * re-exports any such software from a foreign destination, Licensee shall
106*9980SDana.Myers@Sun.COM  * ensure that the distribution and export/re-export of the software is in
107*9980SDana.Myers@Sun.COM  * compliance with all laws, regulations, orders, or other restrictions of the
108*9980SDana.Myers@Sun.COM  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109*9980SDana.Myers@Sun.COM  * any of its subsidiaries will export/re-export any technical data, process,
110*9980SDana.Myers@Sun.COM  * software, or service, directly or indirectly, to any country for which the
111*9980SDana.Myers@Sun.COM  * United States government or any agency thereof requires an export license,
112*9980SDana.Myers@Sun.COM  * other governmental approval, or letter of assurance, without first obtaining
113*9980SDana.Myers@Sun.COM  * such license, approval or letter.
114*9980SDana.Myers@Sun.COM  *
115*9980SDana.Myers@Sun.COM  *****************************************************************************/
116*9980SDana.Myers@Sun.COM 
117*9980SDana.Myers@Sun.COM #define __HWVALID_C__
118*9980SDana.Myers@Sun.COM 
119*9980SDana.Myers@Sun.COM #include "acpi.h"
120*9980SDana.Myers@Sun.COM #include "accommon.h"
121*9980SDana.Myers@Sun.COM 
122*9980SDana.Myers@Sun.COM #define _COMPONENT          ACPI_HARDWARE
123*9980SDana.Myers@Sun.COM         ACPI_MODULE_NAME    ("hwvalid")
124*9980SDana.Myers@Sun.COM 
125*9980SDana.Myers@Sun.COM /* Local prototypes */
126*9980SDana.Myers@Sun.COM 
127*9980SDana.Myers@Sun.COM static ACPI_STATUS
128*9980SDana.Myers@Sun.COM AcpiHwValidateIoRequest (
129*9980SDana.Myers@Sun.COM     ACPI_IO_ADDRESS         Address,
130*9980SDana.Myers@Sun.COM     UINT32                  BitWidth);
131*9980SDana.Myers@Sun.COM 
132*9980SDana.Myers@Sun.COM 
133*9980SDana.Myers@Sun.COM /*
134*9980SDana.Myers@Sun.COM  * Protected I/O ports. Some ports are always illegal, and some are
135*9980SDana.Myers@Sun.COM  * conditionally illegal. This table must remain ordered by port address.
136*9980SDana.Myers@Sun.COM  *
137*9980SDana.Myers@Sun.COM  * The table is used to implement the Microsoft port access rules that
138*9980SDana.Myers@Sun.COM  * first appeared in Windows XP. Some ports are always illegal, and some
139*9980SDana.Myers@Sun.COM  * ports are only illegal if the BIOS calls _OSI with a WinXP string or
140*9980SDana.Myers@Sun.COM  * later (meaning that the BIOS itelf is post-XP.)
141*9980SDana.Myers@Sun.COM  *
142*9980SDana.Myers@Sun.COM  * This provides ACPICA with the desired port protections and
143*9980SDana.Myers@Sun.COM  * Microsoft compatibility.
144*9980SDana.Myers@Sun.COM  *
145*9980SDana.Myers@Sun.COM  * Description of port entries:
146*9980SDana.Myers@Sun.COM  *  DMA:   DMA controller
147*9980SDana.Myers@Sun.COM  *  PIC0:  Programmable Interrupt Controller (8259A)
148*9980SDana.Myers@Sun.COM  *  PIT1:  System Timer 1
149*9980SDana.Myers@Sun.COM  *  PIT2:  System Timer 2 failsafe
150*9980SDana.Myers@Sun.COM  *  RTC:   Real-time clock
151*9980SDana.Myers@Sun.COM  *  CMOS:  Extended CMOS
152*9980SDana.Myers@Sun.COM  *  DMA1:  DMA 1 page registers
153*9980SDana.Myers@Sun.COM  *  DMA1L: DMA 1 Ch 0 low page
154*9980SDana.Myers@Sun.COM  *  DMA2:  DMA 2 page registers
155*9980SDana.Myers@Sun.COM  *  DMA2L: DMA 2 low page refresh
156*9980SDana.Myers@Sun.COM  *  ARBC:  Arbitration control
157*9980SDana.Myers@Sun.COM  *  SETUP: Reserved system board setup
158*9980SDana.Myers@Sun.COM  *  POS:   POS channel select
159*9980SDana.Myers@Sun.COM  *  PIC1:  Cascaded PIC
160*9980SDana.Myers@Sun.COM  *  IDMA:  ISA DMA
161*9980SDana.Myers@Sun.COM  *  ELCR:  PIC edge/level registers
162*9980SDana.Myers@Sun.COM  *  PCI:   PCI configuration space
163*9980SDana.Myers@Sun.COM  */
164*9980SDana.Myers@Sun.COM static const ACPI_PORT_INFO     AcpiProtectedPorts[] =
165*9980SDana.Myers@Sun.COM {
166*9980SDana.Myers@Sun.COM     {"DMA",     0x0000, 0x000F, ACPI_OSI_WIN_XP},
167*9980SDana.Myers@Sun.COM     {"PIC0",    0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL},
168*9980SDana.Myers@Sun.COM     {"PIT1",    0x0040, 0x0043, ACPI_OSI_WIN_XP},
169*9980SDana.Myers@Sun.COM     {"PIT2",    0x0048, 0x004B, ACPI_OSI_WIN_XP},
170*9980SDana.Myers@Sun.COM     {"RTC",     0x0070, 0x0071, ACPI_OSI_WIN_XP},
171*9980SDana.Myers@Sun.COM     {"CMOS",    0x0074, 0x0076, ACPI_OSI_WIN_XP},
172*9980SDana.Myers@Sun.COM     {"DMA1",    0x0081, 0x0083, ACPI_OSI_WIN_XP},
173*9980SDana.Myers@Sun.COM     {"DMA1L",   0x0087, 0x0087, ACPI_OSI_WIN_XP},
174*9980SDana.Myers@Sun.COM     {"DMA2",    0x0089, 0x008B, ACPI_OSI_WIN_XP},
175*9980SDana.Myers@Sun.COM     {"DMA2L",   0x008F, 0x008F, ACPI_OSI_WIN_XP},
176*9980SDana.Myers@Sun.COM     {"ARBC",    0x0090, 0x0091, ACPI_OSI_WIN_XP},
177*9980SDana.Myers@Sun.COM     {"SETUP",   0x0093, 0x0094, ACPI_OSI_WIN_XP},
178*9980SDana.Myers@Sun.COM     {"POS",     0x0096, 0x0097, ACPI_OSI_WIN_XP},
179*9980SDana.Myers@Sun.COM     {"PIC1",    0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL},
180*9980SDana.Myers@Sun.COM     {"IDMA",    0x00C0, 0x00DF, ACPI_OSI_WIN_XP},
181*9980SDana.Myers@Sun.COM     {"ELCR",    0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL},
182*9980SDana.Myers@Sun.COM     {"PCI",     0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP}
183*9980SDana.Myers@Sun.COM };
184*9980SDana.Myers@Sun.COM 
185*9980SDana.Myers@Sun.COM #define ACPI_PORT_INFO_ENTRIES  ACPI_ARRAY_LENGTH (AcpiProtectedPorts)
186*9980SDana.Myers@Sun.COM 
187*9980SDana.Myers@Sun.COM 
188*9980SDana.Myers@Sun.COM /******************************************************************************
189*9980SDana.Myers@Sun.COM  *
190*9980SDana.Myers@Sun.COM  * FUNCTION:    AcpiHwValidateIoRequest
191*9980SDana.Myers@Sun.COM  *
192*9980SDana.Myers@Sun.COM  * PARAMETERS:  Address             Address of I/O port/register
193*9980SDana.Myers@Sun.COM  *              BitWidth            Number of bits (8,16,32)
194*9980SDana.Myers@Sun.COM  *
195*9980SDana.Myers@Sun.COM  * RETURN:      Status
196*9980SDana.Myers@Sun.COM  *
197*9980SDana.Myers@Sun.COM  * DESCRIPTION: Validates an I/O request (address/length). Certain ports are
198*9980SDana.Myers@Sun.COM  *              always illegal and some ports are only illegal depending on
199*9980SDana.Myers@Sun.COM  *              the requests the BIOS AML code makes to the predefined
200*9980SDana.Myers@Sun.COM  *              _OSI method.
201*9980SDana.Myers@Sun.COM  *
202*9980SDana.Myers@Sun.COM  ******************************************************************************/
203*9980SDana.Myers@Sun.COM 
204*9980SDana.Myers@Sun.COM static ACPI_STATUS
AcpiHwValidateIoRequest(ACPI_IO_ADDRESS Address,UINT32 BitWidth)205*9980SDana.Myers@Sun.COM AcpiHwValidateIoRequest (
206*9980SDana.Myers@Sun.COM     ACPI_IO_ADDRESS         Address,
207*9980SDana.Myers@Sun.COM     UINT32                  BitWidth)
208*9980SDana.Myers@Sun.COM {
209*9980SDana.Myers@Sun.COM     UINT32                  i;
210*9980SDana.Myers@Sun.COM     UINT32                  ByteWidth;
211*9980SDana.Myers@Sun.COM     ACPI_IO_ADDRESS         LastAddress;
212*9980SDana.Myers@Sun.COM     const ACPI_PORT_INFO    *PortInfo;
213*9980SDana.Myers@Sun.COM 
214*9980SDana.Myers@Sun.COM 
215*9980SDana.Myers@Sun.COM     ACPI_FUNCTION_TRACE (HwValidateIoRequest);
216*9980SDana.Myers@Sun.COM 
217*9980SDana.Myers@Sun.COM 
218*9980SDana.Myers@Sun.COM     /* Supported widths are 8/16/32 */
219*9980SDana.Myers@Sun.COM 
220*9980SDana.Myers@Sun.COM     if ((BitWidth != 8) &&
221*9980SDana.Myers@Sun.COM         (BitWidth != 16) &&
222*9980SDana.Myers@Sun.COM         (BitWidth != 32))
223*9980SDana.Myers@Sun.COM     {
224*9980SDana.Myers@Sun.COM         return (AE_BAD_PARAMETER);
225*9980SDana.Myers@Sun.COM     }
226*9980SDana.Myers@Sun.COM 
227*9980SDana.Myers@Sun.COM     PortInfo = AcpiProtectedPorts;
228*9980SDana.Myers@Sun.COM     ByteWidth = ACPI_DIV_8 (BitWidth);
229*9980SDana.Myers@Sun.COM     LastAddress = Address + ByteWidth - 1;
230*9980SDana.Myers@Sun.COM 
231*9980SDana.Myers@Sun.COM     ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %p LastAddress %p Length %X",
232*9980SDana.Myers@Sun.COM         ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, LastAddress),
233*9980SDana.Myers@Sun.COM         ByteWidth));
234*9980SDana.Myers@Sun.COM 
235*9980SDana.Myers@Sun.COM     /* Maximum 16-bit address in I/O space */
236*9980SDana.Myers@Sun.COM 
237*9980SDana.Myers@Sun.COM     if (LastAddress > ACPI_UINT16_MAX)
238*9980SDana.Myers@Sun.COM     {
239*9980SDana.Myers@Sun.COM         ACPI_ERROR ((AE_INFO,
240*9980SDana.Myers@Sun.COM             "Illegal I/O port address/length above 64K: 0x%p/%X",
241*9980SDana.Myers@Sun.COM             ACPI_CAST_PTR (void, Address), ByteWidth));
242*9980SDana.Myers@Sun.COM         return_ACPI_STATUS (AE_LIMIT);
243*9980SDana.Myers@Sun.COM     }
244*9980SDana.Myers@Sun.COM 
245*9980SDana.Myers@Sun.COM     /* Exit if requested address is not within the protected port table */
246*9980SDana.Myers@Sun.COM 
247*9980SDana.Myers@Sun.COM     if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End)
248*9980SDana.Myers@Sun.COM     {
249*9980SDana.Myers@Sun.COM         return_ACPI_STATUS (AE_OK);
250*9980SDana.Myers@Sun.COM     }
251*9980SDana.Myers@Sun.COM 
252*9980SDana.Myers@Sun.COM     /* Check request against the list of protected I/O ports */
253*9980SDana.Myers@Sun.COM 
254*9980SDana.Myers@Sun.COM     for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, PortInfo++)
255*9980SDana.Myers@Sun.COM     {
256*9980SDana.Myers@Sun.COM         /*
257*9980SDana.Myers@Sun.COM          * Check if the requested address range will write to a reserved
258*9980SDana.Myers@Sun.COM          * port. Four cases to consider:
259*9980SDana.Myers@Sun.COM          *
260*9980SDana.Myers@Sun.COM          * 1) Address range is contained completely in the port address range
261*9980SDana.Myers@Sun.COM          * 2) Address range overlaps port range at the port range start
262*9980SDana.Myers@Sun.COM          * 3) Address range overlaps port range at the port range end
263*9980SDana.Myers@Sun.COM          * 4) Address range completely encompasses the port range
264*9980SDana.Myers@Sun.COM          */
265*9980SDana.Myers@Sun.COM         if ((Address <= PortInfo->End) && (LastAddress >= PortInfo->Start))
266*9980SDana.Myers@Sun.COM         {
267*9980SDana.Myers@Sun.COM             /* Port illegality may depend on the _OSI calls made by the BIOS */
268*9980SDana.Myers@Sun.COM 
269*9980SDana.Myers@Sun.COM             if (AcpiGbl_OsiData >= PortInfo->OsiDependency)
270*9980SDana.Myers@Sun.COM             {
271*9980SDana.Myers@Sun.COM                 ACPI_DEBUG_PRINT ((ACPI_DB_IO,
272*9980SDana.Myers@Sun.COM                     "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)",
273*9980SDana.Myers@Sun.COM                     ACPI_CAST_PTR (void, Address), ByteWidth, PortInfo->Name,
274*9980SDana.Myers@Sun.COM                     PortInfo->Start, PortInfo->End));
275*9980SDana.Myers@Sun.COM 
276*9980SDana.Myers@Sun.COM                 return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS);
277*9980SDana.Myers@Sun.COM             }
278*9980SDana.Myers@Sun.COM         }
279*9980SDana.Myers@Sun.COM 
280*9980SDana.Myers@Sun.COM         /* Finished if address range ends before the end of this port */
281*9980SDana.Myers@Sun.COM 
282*9980SDana.Myers@Sun.COM         if (LastAddress <= PortInfo->End)
283*9980SDana.Myers@Sun.COM         {
284*9980SDana.Myers@Sun.COM             break;
285*9980SDana.Myers@Sun.COM         }
286*9980SDana.Myers@Sun.COM     }
287*9980SDana.Myers@Sun.COM 
288*9980SDana.Myers@Sun.COM     return_ACPI_STATUS (AE_OK);
289*9980SDana.Myers@Sun.COM }
290*9980SDana.Myers@Sun.COM 
291*9980SDana.Myers@Sun.COM 
292*9980SDana.Myers@Sun.COM /******************************************************************************
293*9980SDana.Myers@Sun.COM  *
294*9980SDana.Myers@Sun.COM  * FUNCTION:    AcpiHwReadPort
295*9980SDana.Myers@Sun.COM  *
296*9980SDana.Myers@Sun.COM  * PARAMETERS:  Address             Address of I/O port/register to read
297*9980SDana.Myers@Sun.COM  *              Value               Where value is placed
298*9980SDana.Myers@Sun.COM  *              Width               Number of bits
299*9980SDana.Myers@Sun.COM  *
300*9980SDana.Myers@Sun.COM  * RETURN:      Status and value read from port
301*9980SDana.Myers@Sun.COM  *
302*9980SDana.Myers@Sun.COM  * DESCRIPTION: Read data from an I/O port or register. This is a front-end
303*9980SDana.Myers@Sun.COM  *              to AcpiOsReadPort that performs validation on both the port
304*9980SDana.Myers@Sun.COM  *              address and the length.
305*9980SDana.Myers@Sun.COM  *
306*9980SDana.Myers@Sun.COM  *****************************************************************************/
307*9980SDana.Myers@Sun.COM 
308*9980SDana.Myers@Sun.COM ACPI_STATUS
AcpiHwReadPort(ACPI_IO_ADDRESS Address,UINT32 * Value,UINT32 Width)309*9980SDana.Myers@Sun.COM AcpiHwReadPort (
310*9980SDana.Myers@Sun.COM     ACPI_IO_ADDRESS         Address,
311*9980SDana.Myers@Sun.COM     UINT32                  *Value,
312*9980SDana.Myers@Sun.COM     UINT32                  Width)
313*9980SDana.Myers@Sun.COM {
314*9980SDana.Myers@Sun.COM     ACPI_STATUS             Status;
315*9980SDana.Myers@Sun.COM     UINT32                  OneByte;
316*9980SDana.Myers@Sun.COM     UINT32                  i;
317*9980SDana.Myers@Sun.COM 
318*9980SDana.Myers@Sun.COM 
319*9980SDana.Myers@Sun.COM     /* Validate the entire request and perform the I/O */
320*9980SDana.Myers@Sun.COM 
321*9980SDana.Myers@Sun.COM     Status = AcpiHwValidateIoRequest (Address, Width);
322*9980SDana.Myers@Sun.COM     if (ACPI_SUCCESS (Status))
323*9980SDana.Myers@Sun.COM     {
324*9980SDana.Myers@Sun.COM         Status = AcpiOsReadPort (Address, Value, Width);
325*9980SDana.Myers@Sun.COM         return (Status);
326*9980SDana.Myers@Sun.COM     }
327*9980SDana.Myers@Sun.COM 
328*9980SDana.Myers@Sun.COM     if (Status != AE_AML_ILLEGAL_ADDRESS)
329*9980SDana.Myers@Sun.COM     {
330*9980SDana.Myers@Sun.COM         return (Status);
331*9980SDana.Myers@Sun.COM     }
332*9980SDana.Myers@Sun.COM 
333*9980SDana.Myers@Sun.COM     /*
334*9980SDana.Myers@Sun.COM      * There has been a protection violation within the request. Fall
335*9980SDana.Myers@Sun.COM      * back to byte granularity port I/O and ignore the failing bytes.
336*9980SDana.Myers@Sun.COM      * This provides Windows compatibility.
337*9980SDana.Myers@Sun.COM      */
338*9980SDana.Myers@Sun.COM     for (i = 0, *Value = 0; i < Width; i += 8)
339*9980SDana.Myers@Sun.COM     {
340*9980SDana.Myers@Sun.COM         /* Validate and read one byte */
341*9980SDana.Myers@Sun.COM 
342*9980SDana.Myers@Sun.COM         if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
343*9980SDana.Myers@Sun.COM         {
344*9980SDana.Myers@Sun.COM             Status = AcpiOsReadPort (Address, &OneByte, 8);
345*9980SDana.Myers@Sun.COM             if (ACPI_FAILURE (Status))
346*9980SDana.Myers@Sun.COM             {
347*9980SDana.Myers@Sun.COM                 return (Status);
348*9980SDana.Myers@Sun.COM             }
349*9980SDana.Myers@Sun.COM 
350*9980SDana.Myers@Sun.COM             *Value |= (OneByte << i);
351*9980SDana.Myers@Sun.COM         }
352*9980SDana.Myers@Sun.COM 
353*9980SDana.Myers@Sun.COM         Address++;
354*9980SDana.Myers@Sun.COM     }
355*9980SDana.Myers@Sun.COM 
356*9980SDana.Myers@Sun.COM     return (AE_OK);
357*9980SDana.Myers@Sun.COM }
358*9980SDana.Myers@Sun.COM 
359*9980SDana.Myers@Sun.COM 
360*9980SDana.Myers@Sun.COM /******************************************************************************
361*9980SDana.Myers@Sun.COM  *
362*9980SDana.Myers@Sun.COM  * FUNCTION:    AcpiHwWritePort
363*9980SDana.Myers@Sun.COM  *
364*9980SDana.Myers@Sun.COM  * PARAMETERS:  Address             Address of I/O port/register to write
365*9980SDana.Myers@Sun.COM  *              Value               Value to write
366*9980SDana.Myers@Sun.COM  *              Width               Number of bits
367*9980SDana.Myers@Sun.COM  *
368*9980SDana.Myers@Sun.COM  * RETURN:      Status
369*9980SDana.Myers@Sun.COM  *
370*9980SDana.Myers@Sun.COM  * DESCRIPTION: Write data to an I/O port or register. This is a front-end
371*9980SDana.Myers@Sun.COM  *              to AcpiOsWritePort that performs validation on both the port
372*9980SDana.Myers@Sun.COM  *              address and the length.
373*9980SDana.Myers@Sun.COM  *
374*9980SDana.Myers@Sun.COM  *****************************************************************************/
375*9980SDana.Myers@Sun.COM 
376*9980SDana.Myers@Sun.COM ACPI_STATUS
AcpiHwWritePort(ACPI_IO_ADDRESS Address,UINT32 Value,UINT32 Width)377*9980SDana.Myers@Sun.COM AcpiHwWritePort (
378*9980SDana.Myers@Sun.COM     ACPI_IO_ADDRESS         Address,
379*9980SDana.Myers@Sun.COM     UINT32                  Value,
380*9980SDana.Myers@Sun.COM     UINT32                  Width)
381*9980SDana.Myers@Sun.COM {
382*9980SDana.Myers@Sun.COM     ACPI_STATUS             Status;
383*9980SDana.Myers@Sun.COM     UINT32                  i;
384*9980SDana.Myers@Sun.COM 
385*9980SDana.Myers@Sun.COM 
386*9980SDana.Myers@Sun.COM     /* Validate the entire request and perform the I/O */
387*9980SDana.Myers@Sun.COM 
388*9980SDana.Myers@Sun.COM     Status = AcpiHwValidateIoRequest (Address, Width);
389*9980SDana.Myers@Sun.COM     if (ACPI_SUCCESS (Status))
390*9980SDana.Myers@Sun.COM     {
391*9980SDana.Myers@Sun.COM         Status = AcpiOsWritePort (Address, Value, Width);
392*9980SDana.Myers@Sun.COM         return (Status);
393*9980SDana.Myers@Sun.COM     }
394*9980SDana.Myers@Sun.COM 
395*9980SDana.Myers@Sun.COM     if (Status != AE_AML_ILLEGAL_ADDRESS)
396*9980SDana.Myers@Sun.COM     {
397*9980SDana.Myers@Sun.COM         return (Status);
398*9980SDana.Myers@Sun.COM     }
399*9980SDana.Myers@Sun.COM 
400*9980SDana.Myers@Sun.COM     /*
401*9980SDana.Myers@Sun.COM      * There has been a protection violation within the request. Fall
402*9980SDana.Myers@Sun.COM      * back to byte granularity port I/O and ignore the failing bytes.
403*9980SDana.Myers@Sun.COM      * This provides Windows compatibility.
404*9980SDana.Myers@Sun.COM      */
405*9980SDana.Myers@Sun.COM     for (i = 0; i < Width; i += 8)
406*9980SDana.Myers@Sun.COM     {
407*9980SDana.Myers@Sun.COM         /* Validate and write one byte */
408*9980SDana.Myers@Sun.COM 
409*9980SDana.Myers@Sun.COM         if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
410*9980SDana.Myers@Sun.COM         {
411*9980SDana.Myers@Sun.COM             Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8);
412*9980SDana.Myers@Sun.COM             if (ACPI_FAILURE (Status))
413*9980SDana.Myers@Sun.COM             {
414*9980SDana.Myers@Sun.COM                 return (Status);
415*9980SDana.Myers@Sun.COM             }
416*9980SDana.Myers@Sun.COM         }
417*9980SDana.Myers@Sun.COM 
418*9980SDana.Myers@Sun.COM         Address++;
419*9980SDana.Myers@Sun.COM     }
420*9980SDana.Myers@Sun.COM 
421*9980SDana.Myers@Sun.COM     return (AE_OK);
422*9980SDana.Myers@Sun.COM }
423*9980SDana.Myers@Sun.COM 
424*9980SDana.Myers@Sun.COM 
425