X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=qemu%2Froms%2FSLOF%2Fboard-js2x%2Frtas%2Frtas_pci.c;fp=qemu%2Froms%2FSLOF%2Fboard-js2x%2Frtas%2Frtas_pci.c;h=55dbf53364ead0a03abb98b0f3a6ea41772a1200;hb=e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb;hp=0000000000000000000000000000000000000000;hpb=9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00;p=kvmfornfv.git diff --git a/qemu/roms/SLOF/board-js2x/rtas/rtas_pci.c b/qemu/roms/SLOF/board-js2x/rtas/rtas_pci.c new file mode 100644 index 000000000..55dbf5336 --- /dev/null +++ b/qemu/roms/SLOF/board-js2x/rtas/rtas_pci.c @@ -0,0 +1,116 @@ +/****************************************************************************** + * Copyright (c) 2004, 2008 IBM Corporation + * All rights reserved. + * This program and the accompanying materials + * are made available under the terms of the BSD License + * which accompanies this distribution, and is available at + * http://www.opensource.org/licenses/bsd-license.php + * + * Contributors: + * IBM Corporation - initial implementation + *****************************************************************************/ +#include +#include +#include +#include "rtas_board.h" + +void +rtas_ibm_read_pci_config (rtas_args_t *rtas_args) +{ + int retVal = 0; + uint64_t addr = ((uint64_t) rtas_args->args[1]) << 32; // high 32 bits of PHB UID + addr |= (rtas_args->args[2] & 0xFFFFFFFF); // low 32 bits of PHB UID + addr |= (rtas_args->args[0] & 0x00FFFFFF); // bus, devfn, offset + unsigned int size = rtas_args->args[3]; + + /* Check for bus != 0 on PCI/PCI-X (PHB UID = 0xf2000000) */ + if (((addr & 0xf2000000) == 0xf2000000) && (addr & 0xff0000)) + addr += 0x1000000; + + if (size == 1) + rtas_args->args[5] = load8_ci(addr); + else if (size == 2) + rtas_args->args[5] = bswap16_load(addr); + else if (size == 4) + rtas_args->args[5] = bswap32_load(addr); + else + retVal = -3; /* Bad arguments */ + + rtas_args->args[4] = retVal; +} + +void +rtas_ibm_write_pci_config (rtas_args_t *rtas_args) +{ + int retVal = 0; + uint64_t addr = ((uint64_t) rtas_args->args[1]) << 32; // high 32 bits of PHB UID + addr |= (rtas_args->args[2] & 0xFFFFFFFF); // low 32 bits of PHB UID + addr |= (rtas_args->args[0] & 0x00FFFFFF); // bus, devfn, offset + unsigned int size = rtas_args->args[3]; + + addr |= 0xf2000000; + + /* Check for bus != 0 on PCI/PCI-X (PHB UID = 0xf2000000) */ + if (((addr & 0xf2000000) == 0xf2000000) && (addr & 0xff0000)) + addr += 0x1000000; + + if (size == 1) + store8_ci(addr, rtas_args->args[4]); + else if (size == 2) + bswap16_store(addr, rtas_args->args[4]); + else if (size == 4) + bswap32_store(addr, rtas_args->args[4]); + else + retVal = -3; /* Bad arguments */ + + rtas_args->args[5] = retVal; +} + +void +rtas_read_pci_config (rtas_args_t *rtas_args) +{ + int retVal = 0; + unsigned long addr = rtas_args->args[0]; + unsigned int size = rtas_args->args[1]; + addr |= 0xf2000000; + + /* Check for bus != 0 */ + if (addr & 0xff0000) + addr += 0x1000000; + + if (size == 1) + rtas_args->args[3] = load8_ci(addr); + else if (size == 2) + rtas_args->args[3] = bswap16_load(addr); + else if (size == 4) + rtas_args->args[3] = bswap32_load(addr); + else + retVal = -3; /* Bad arguments */ + + rtas_args->args[2] = retVal; +} + +void +rtas_write_pci_config (rtas_args_t *rtas_args) +{ + int retVal = 0; + unsigned long addr = rtas_args->args[0]; + unsigned int size = rtas_args->args[1]; + + addr |= 0xf2000000; + + /* Check for bus != 0 */ + if (addr & 0xff0000) + addr += 0x1000000; + + if (size == 1) + store8_ci(addr, rtas_args->args[2]); + else if (size == 2) + bswap16_store(addr, rtas_args->args[2]); + else if (size == 4) + bswap32_store(addr, rtas_args->args[2]); + else + retVal = -3; /* Bad arguments */ + + rtas_args->args[3] = retVal; +}