1/****************************************************************************** 2 * 3 * Module Name: osbarrelfishxf - Barrelfish OSL interfaces 4 * 5 *****************************************************************************/ 6 7/* 8 * Copyright (c) 2008, 2010, ETH Zurich. 9 * All rights reserved. 10 * 11 * This file is distributed under the terms in the attached LICENSE file. 12 * If you do not find this file, copies can be found by writing to: 13 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 14 */ 15 16/***************************************************************** 17 * Debug printer and its power-switch: 18 *****************************************************************/ 19 20#include "acpi_debug.h" 21 22 23/****************************************************************************** 24 * 25 * 1. Copyright Notice 26 * 27 * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. 28 * All rights reserved. 29 * 30 * 2. License 31 * 32 * 2.1. This is your license from Intel Corp. under its intellectual property 33 * rights. You may have additional license terms from the party that provided 34 * you this software, covering your right to use that party's intellectual 35 * property rights. 36 * 37 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 38 * copy of the source code appearing in this file ("Covered Code") an 39 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 40 * base code distributed originally by Intel ("Original Intel Code") to copy, 41 * make derivatives, distribute, use and display any portion of the Covered 42 * Code in any form, with the right to sublicense such rights; and 43 * 44 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 45 * license (with the right to sublicense), under only those claims of Intel 46 * patents that are infringed by the Original Intel Code, to make, use, sell, 47 * offer to sell, and import the Covered Code and derivative works thereof 48 * solely to the minimum extent necessary to exercise the above copyright 49 * license, and in no event shall the patent license extend to any additions 50 * to or modifications of the Original Intel Code. No other license or right 51 * is granted directly or by implication, estoppel or otherwise; 52 * 53 * The above copyright and patent license is granted only if the following 54 * conditions are met: 55 * 56 * 3. Conditions 57 * 58 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 59 * Redistribution of source code of any substantial portion of the Covered 60 * Code or modification with rights to further distribute source must include 61 * the above Copyright Notice, the above License, this list of Conditions, 62 * and the following Disclaimer and Export Compliance provision. In addition, 63 * Licensee must cause all Covered Code to which Licensee contributes to 64 * contain a file documenting the changes Licensee made to create that Covered 65 * Code and the date of any change. Licensee must include in that file the 66 * documentation of any changes made by any predecessor Licensee. Licensee 67 * must include a prominent statement that the modification is derived, 68 * directly or indirectly, from Original Intel Code. 69 * 70 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 71 * Redistribution of source code of any substantial portion of the Covered 72 * Code or modification without rights to further distribute source must 73 * include the following Disclaimer and Export Compliance provision in the 74 * documentation and/or other materials provided with distribution. In 75 * addition, Licensee may not authorize further sublicense of source of any 76 * portion of the Covered Code, and must include terms to the effect that the 77 * license from Licensee to its licensee is limited to the intellectual 78 * property embodied in the software Licensee provides to its licensee, and 79 * not to intellectual property embodied in modifications its licensee may 80 * make. 81 * 82 * 3.3. Redistribution of Executable. Redistribution in executable form of any 83 * substantial portion of the Covered Code or modification must reproduce the 84 * above Copyright Notice, and the following Disclaimer and Export Compliance 85 * provision in the documentation and/or other materials provided with the 86 * distribution. 87 * 88 * 3.4. Intel retains all right, title, and interest in and to the Original 89 * Intel Code. 90 * 91 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 92 * Intel shall be used in advertising or otherwise to promote the sale, use or 93 * other dealings in products derived from or relating to the Covered Code 94 * without prior written authorization from Intel. 95 * 96 * 4. Disclaimer and Export Compliance 97 * 98 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 99 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 100 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 101 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 102 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 103 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 104 * PARTICULAR PURPOSE. 105 * 106 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 107 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 108 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 109 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 110 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 111 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 112 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 113 * LIMITED REMEDY. 114 * 115 * 4.3. Licensee shall not export, either directly or indirectly, any of this 116 * software or system incorporating such software without first obtaining any 117 * required license or other approval from the U. S. Department of Commerce or 118 * any other agency or department of the United States Government. In the 119 * event Licensee exports any such software from the United States or 120 * re-exports any such software from a foreign destination, Licensee shall 121 * ensure that the distribution and export/re-export of the software is in 122 * compliance with all laws, regulations, orders, or other restrictions of the 123 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 124 * any of its subsidiaries will export/re-export any technical data, process, 125 * software, or service, directly or indirectly, to any country for which the 126 * United States government or any agency thereof requires an export license, 127 * other governmental approval, or letter of assurance, without first obtaining 128 * such license, approval or letter. 129 * 130 *****************************************************************************/ 131 132#include <stdio.h> 133#include <stdlib.h> 134#include <barrelfish/barrelfish.h> 135#include <barrelfish/dispatch.h> 136#include <barrelfish/inthandler.h> 137 138#include <acpi.h> 139#include <accommon.h> 140#include <amlcode.h> 141#include <acparser.h> 142#include <acdebug.h> 143 144#include "ioapic.h" 145#include <pci/confspace/pci_confspace.h> 146#include <pci/confspace/mackerelpci.h> 147 148#include <mm/mm.h> 149 150#define _COMPONENT ACPI_OS_SERVICES 151 ACPI_MODULE_NAME ("osbarrelfishxf") 152 153 154/****************************************************************************** 155 * 156 * FUNCTION: AcpiOsReadPort 157 * 158 * PARAMETERS: Address Address of I/O port/register to read 159 * Value Where value is placed 160 * Width Number of bits 161 * 162 * RETURN: Value read from port 163 * 164 * DESCRIPTION: Read data from an I/O port or register 165 * 166 *****************************************************************************/ 167 168ACPI_STATUS 169AcpiOsReadPort ( 170 ACPI_IO_ADDRESS Address, 171 UINT32 *Value, 172 UINT32 Width) 173{ 174 uint8_t tmp8 = 0; 175 uint16_t tmp16 = 0; 176 int r = -1; 177 178 switch (Width) 179 { 180 case 8: 181 r = iocap_in8(cap_io, Address, &tmp8); 182 if (r == 0) { 183 *Value = tmp8; 184 } 185 break; 186 187 case 16: 188 r = iocap_in16(cap_io, Address, &tmp16); 189 if (r == 0) { 190 *Value = tmp16; 191 } 192 break; 193 194 case 32: 195 r = iocap_in32(cap_io, Address, Value); 196 break; 197 } 198 199 //printf("AcpiOsReadPort(0x%lx %d) -> 0x%x\n", Address, Width, *Value); 200 201 return r == 0 ? AE_OK : AE_ERROR; 202} 203 204 205/****************************************************************************** 206 * 207 * FUNCTION: AcpiOsWritePort 208 * 209 * PARAMETERS: Address Address of I/O port/register to write 210 * Value Value to write 211 * Width Number of bits 212 * 213 * RETURN: None 214 * 215 * DESCRIPTION: Write data to an I/O port or register 216 * 217 *****************************************************************************/ 218 219ACPI_STATUS 220AcpiOsWritePort ( 221 ACPI_IO_ADDRESS Address, 222 UINT32 Value, 223 UINT32 Width) 224{ 225 int r = -1; 226 //printf("AcpiOsWritePort(0x%lx %d 0x%x)\n", Address, Width, Value); 227 228 switch (Width) 229 { 230 case 8: 231 r = iocap_out8(cap_io, Address, Value); 232 break; 233 234 case 16: 235 r = iocap_out16(cap_io, Address, Value); 236 break; 237 238 case 32: 239 r = iocap_out32(cap_io, Address, Value); 240 break; 241 } 242 243 return r == 0 ? AE_OK : AE_ERROR; 244} 245 246