2 * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
9 #include <l4/sys/compiler.h>
10 #include <l4/sigma0/sigma0.h>
22 #if defined(ARCH_amd64) || defined(ARCH_x86)
24 #include <l4/util/port_io.h>
25 #define DEBUG_OSL_PORT_IO 0
27 * Platform and hardware-independent I/O interfaces
31 ACPI_IO_ADDRESS address,
36 d_printf(DBG_ALL, "IN: adr=0x%x, width=%i\n", address, width);
44 if (res_get_ioport(address, 0) < 0)
45 return AE_BAD_PARAMETER;
46 *value = l4util_in8((l4_uint16_t)address);
49 if (res_get_ioport(address, 1) < 0)
50 return AE_BAD_PARAMETER;
51 *value = l4util_in16((l4_uint16_t)address);
54 if (res_get_ioport(address, 2) < 0)
55 return AE_BAD_PARAMETER;
56 *value = l4util_in32((l4_uint16_t)address);
59 return AE_BAD_PARAMETER;
62 d_printf(DBG_ALL, "\tport(0x%x)=>0x%x\n",address,*value);
68 ACPI_IO_ADDRESS address,
73 d_printf(DBG_ALL, "\tport(0x%x)<=0x%x\n",address,value);
81 if (res_get_ioport(address, 0) < 0)
82 return AE_BAD_PARAMETER;
83 l4util_out8((l4_uint8_t)value,(l4_uint16_t)address);
86 if (res_get_ioport(address, 1) < 0)
87 return AE_BAD_PARAMETER;
88 l4util_out16((l4_uint16_t)value,(l4_uint16_t)address);
91 if (res_get_ioport(address, 2) < 0)
92 return AE_BAD_PARAMETER;
93 l4util_out32((l4_uint32_t)value,(l4_uint32_t)address);
96 return AE_BAD_PARAMETER;
104 ACPI_IO_ADDRESS /*address*/,
113 ACPI_IO_ADDRESS /*address*/,
123 ACPI_PHYSICAL_ADDRESS where,
126 void *virt = (void*)res_map_iomem(where, length);
128 d_printf(DBG_DEBUG, "%s(%x, %x) = %lx\n", __func__, where, length, (unsigned long)virt);
135 void *logical_address,
138 (void)logical_address;
140 // l4io_release_iomem((l4_addr_t)logical_address, size);
146 /******************************************************************************
148 * FUNCTION: AcpiOsReadPciConfiguration
150 * PARAMETERS: PciId Seg/Bus/Dev
151 * Register Device Register
152 * Value Buffer where value is placed
153 * Width Number of bits
157 * DESCRIPTION: Read data from PCI configuration space
159 *****************************************************************************/
163 pci_conf_addr(l4_uint32_t bus, l4_uint32_t dev, l4_uint32_t fn, l4_uint32_t reg)
164 { return 0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3); }
167 AcpiOsReadPciConfiguration (
173 //printf("%s: ...\n", __func__);
174 Pci_root_bridge *rb = pci_root_bridge(PciId->Segment);
176 return AE_BAD_PARAMETER;
178 int r = rb->cfg_read(PciId->Bus, (PciId->Device << 16) | PciId->Function,
179 Register, (l4_uint32_t *)Value, Hw::Pci::cfg_w_to_o(Width));
182 return AE_BAD_PARAMETER;
188 /******************************************************************************
190 * FUNCTION: AcpiOsWritePciConfiguration
192 * PARAMETERS: PciId Seg/Bus/Dev
193 * Register Device Register
194 * Value Value to be written
195 * Width Number of bits
199 * DESCRIPTION: Write data to PCI configuration space
201 *****************************************************************************/
204 AcpiOsWritePciConfiguration (
210 //printf("%s: ...\n", __func__);
211 Pci_root_bridge *rb = pci_root_bridge(PciId->Segment);
213 return AE_BAD_PARAMETER;
215 int r = rb->cfg_write(PciId->Bus, (PciId->Device << 16) | PciId->Function,
216 Register, Value, Hw::Pci::cfg_w_to_o(Width));
219 return AE_BAD_PARAMETER;