1
2 /******************************************************************************
3 *
4 * Module Name: hwvalid - I/O request validation
5 *
6 *****************************************************************************/
7
8 /*
9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
132 static ACPI_STATUS
133 AcpiHwValidateIoRequest (
134 ACPI_IO_ADDRESS Address,
135 UINT32 BitWidth)
136 {
137 UINT32 i;
138 UINT32 ByteWidth;
139 ACPI_IO_ADDRESS LastAddress;
140 const ACPI_PORT_INFO *PortInfo;
141
142
143 ACPI_FUNCTION_TRACE (HwValidateIoRequest);
144
145
146 /* Supported widths are 8/16/32 */
147
148 if ((BitWidth != 8) &&
149 (BitWidth != 16) &&
150 (BitWidth != 32))
151 {
152 return (AE_BAD_PARAMETER);
153 }
154
155 PortInfo = AcpiProtectedPorts;
156 ByteWidth = ACPI_DIV_8 (BitWidth);
157 LastAddress = Address + ByteWidth - 1;
158
159 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %p LastAddress %p Length %X",
160 ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, LastAddress),
161 ByteWidth));
162
163 /* Maximum 16-bit address in I/O space */
164
165 if (LastAddress > ACPI_UINT16_MAX)
166 {
167 ACPI_ERROR ((AE_INFO,
168 "Illegal I/O port address/length above 64K: %p/0x%X",
169 ACPI_CAST_PTR (void, Address), ByteWidth));
170 return_ACPI_STATUS (AE_LIMIT);
171 }
345 * This provides Windows compatibility.
346 */
347 for (i = 0; i < Width; i += 8)
348 {
349 /* Validate and write one byte */
350
351 if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
352 {
353 Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8);
354 if (ACPI_FAILURE (Status))
355 {
356 return (Status);
357 }
358 }
359
360 Address++;
361 }
362
363 return (AE_OK);
364 }
365
366
|
1 /******************************************************************************
2 *
3 * Module Name: hwvalid - I/O request validation
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
131 static ACPI_STATUS
132 AcpiHwValidateIoRequest (
133 ACPI_IO_ADDRESS Address,
134 UINT32 BitWidth)
135 {
136 UINT32 i;
137 UINT32 ByteWidth;
138 ACPI_IO_ADDRESS LastAddress;
139 const ACPI_PORT_INFO *PortInfo;
140
141
142 ACPI_FUNCTION_TRACE (HwValidateIoRequest);
143
144
145 /* Supported widths are 8/16/32 */
146
147 if ((BitWidth != 8) &&
148 (BitWidth != 16) &&
149 (BitWidth != 32))
150 {
151 ACPI_ERROR ((AE_INFO,
152 "Bad BitWidth parameter: %8.8X", BitWidth));
153 return (AE_BAD_PARAMETER);
154 }
155
156 PortInfo = AcpiProtectedPorts;
157 ByteWidth = ACPI_DIV_8 (BitWidth);
158 LastAddress = Address + ByteWidth - 1;
159
160 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %p LastAddress %p Length %X",
161 ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, LastAddress),
162 ByteWidth));
163
164 /* Maximum 16-bit address in I/O space */
165
166 if (LastAddress > ACPI_UINT16_MAX)
167 {
168 ACPI_ERROR ((AE_INFO,
169 "Illegal I/O port address/length above 64K: %p/0x%X",
170 ACPI_CAST_PTR (void, Address), ByteWidth));
171 return_ACPI_STATUS (AE_LIMIT);
172 }
346 * This provides Windows compatibility.
347 */
348 for (i = 0; i < Width; i += 8)
349 {
350 /* Validate and write one byte */
351
352 if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
353 {
354 Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8);
355 if (ACPI_FAILURE (Status))
356 {
357 return (Status);
358 }
359 }
360
361 Address++;
362 }
363
364 return (AE_OK);
365 }
|