2 * (c) 2010 Technische Universität Dresden
3 * This file is part of TUD:OS and distributed under the terms of the
4 * GNU General Public License 2.
5 * Please see the COPYING-GPL-2 file for details.
7 #include <l4/sys/compiler.h>
8 #include <l4/sigma0/sigma0.h>
20 #if defined(ARCH_amd64) || defined(ARCH_x86)
22 #include <l4/util/port_io.h>
23 #define DEBUG_OSL_PORT_IO 0
25 * Platform and hardware-independent I/O interfaces
29 ACPI_IO_ADDRESS address,
33 if(0 && DEBUG_OSL_PORT_IO)
34 printf("IN: adr=0x%x, width=%i\n", address, width);
42 if (res_get_ioport(address, 0) < 0)
43 return AE_BAD_PARAMETER;
44 *value = l4util_in8((l4_uint16_t)address);
47 if (res_get_ioport(address, 1) < 0)
48 return AE_BAD_PARAMETER;
49 *value = l4util_in16((l4_uint16_t)address);
52 if (res_get_ioport(address, 2) < 0)
53 return AE_BAD_PARAMETER;
54 *value = l4util_in32((l4_uint16_t)address);
57 return AE_BAD_PARAMETER;
60 printf("\tport(0x%x)=>0x%x\n",address,*value);
66 ACPI_IO_ADDRESS address,
71 printf("\tport(0x%x)<=0x%x\n",address,value);
79 if (res_get_ioport(address, 0) < 0)
80 return AE_BAD_PARAMETER;
81 l4util_out8((l4_uint8_t)value,(l4_uint16_t)address);
84 if (res_get_ioport(address, 1) < 0)
85 return AE_BAD_PARAMETER;
86 l4util_out16((l4_uint16_t)value,(l4_uint16_t)address);
89 if (res_get_ioport(address, 2) < 0)
90 return AE_BAD_PARAMETER;
91 l4util_out32((l4_uint32_t)value,(l4_uint32_t)address);
94 return AE_BAD_PARAMETER;
102 ACPI_IO_ADDRESS /*address*/,
111 ACPI_IO_ADDRESS /*address*/,
121 ACPI_PHYSICAL_ADDRESS where,
124 void *virt = (void*)res_map_iomem(where, length);
126 printf("%s(%x, %x) = %lx\n", __func__, where, length, (unsigned long)virt);
133 void *logical_address,
136 (void)logical_address;
138 // l4io_release_iomem((l4_addr_t)logical_address, size);
144 /******************************************************************************
146 * FUNCTION: AcpiOsReadPciConfiguration
148 * PARAMETERS: PciId Seg/Bus/Dev
149 * Register Device Register
150 * Value Buffer where value is placed
151 * Width Number of bits
155 * DESCRIPTION: Read data from PCI configuration space
157 *****************************************************************************/
161 pci_conf_addr(l4_uint32_t bus, l4_uint32_t dev, l4_uint32_t fn, l4_uint32_t reg)
162 { return 0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3); }
165 AcpiOsReadPciConfiguration (
171 //printf("%s: ...\n", __func__);
172 Pci_root_bridge *rb = pci_root_bridge(PciId->Segment);
174 return AE_BAD_PARAMETER;
176 int r = rb->cfg_read(PciId->Bus, (PciId->Device << 16) | PciId->Function,
177 Register, (l4_uint32_t *)Value, Hw::Pci::cfg_w_to_o(Width));
180 return AE_BAD_PARAMETER;
186 /******************************************************************************
188 * FUNCTION: AcpiOsWritePciConfiguration
190 * PARAMETERS: PciId Seg/Bus/Dev
191 * Register Device Register
192 * Value Value to be written
193 * Width Number of bits
197 * DESCRIPTION: Write data to PCI configuration space
199 *****************************************************************************/
202 AcpiOsWritePciConfiguration (
208 //printf("%s: ...\n", __func__);
209 Pci_root_bridge *rb = pci_root_bridge(PciId->Segment);
211 return AE_BAD_PARAMETER;
213 int r = rb->cfg_write(PciId->Bus, (PciId->Device << 16) | PciId->Function,
214 Register, Value, Hw::Pci::cfg_w_to_o(Width));
217 return AE_BAD_PARAMETER;