|
|
1.1 ! root 1: /****************************************************************************** ! 2: * Copyright (c) 2004, 2008 IBM Corporation ! 3: * All rights reserved. ! 4: * This program and the accompanying materials ! 5: * are made available under the terms of the BSD License ! 6: * which accompanies this distribution, and is available at ! 7: * http://www.opensource.org/licenses/bsd-license.php ! 8: * ! 9: * Contributors: ! 10: * IBM Corporation - initial implementation ! 11: *****************************************************************************/ ! 12: #include <stdint.h> ! 13: #include <rtas.h> ! 14: #include <hw.h> ! 15: ! 16: int ! 17: rtas_ibm_read_pci_config (rtas_args_t *rtas_args) { ! 18: int retVal = 0; ! 19: uint64_t addr = ((uint64_t) rtas_args->args[1]) << 32; // high 32 bits of PHB UID ! 20: addr |= (rtas_args->args[2] & 0xFFFFFFFF); // low 32 bits of PHB UID ! 21: addr |= (rtas_args->args[0] & 0x00FFFFFF); // bus, devfn, offset ! 22: unsigned int size = rtas_args->args[3]; ! 23: ! 24: /* Check for bus != 0 on PCI/PCI-X (PHB UID = 0xf2000000) */ ! 25: if (((addr & 0xf2000000) == 0xf2000000) && (addr & 0xff0000)) ! 26: addr += 0x1000000; ! 27: ! 28: if (size == 1) ! 29: rtas_args->args[5] = load8_ci(addr); ! 30: else if (size == 2) ! 31: rtas_args->args[5] = bswap16_load(addr); ! 32: else if (size == 4) ! 33: rtas_args->args[5] = bswap32_load(addr); ! 34: else ! 35: retVal = -3; /* Bad arguments */ ! 36: ! 37: return retVal; ! 38: } ! 39: ! 40: int ! 41: rtas_ibm_write_pci_config (rtas_args_t *rtas_args) { ! 42: int retVal = 0; ! 43: uint64_t addr = ((uint64_t) rtas_args->args[1]) << 32; // high 32 bits of PHB UID ! 44: addr |= (rtas_args->args[2] & 0xFFFFFFFF); // low 32 bits of PHB UID ! 45: addr |= (rtas_args->args[0] & 0x00FFFFFF); // bus, devfn, offset ! 46: unsigned int size = rtas_args->args[3]; ! 47: ! 48: addr |= 0xf2000000; ! 49: ! 50: /* Check for bus != 0 on PCI/PCI-X (PHB UID = 0xf2000000) */ ! 51: if (((addr & 0xf2000000) == 0xf2000000) && (addr & 0xff0000)) ! 52: addr += 0x1000000; ! 53: ! 54: if (size == 1) ! 55: store8_ci(addr, rtas_args->args[4]); ! 56: else if (size == 2) ! 57: bswap16_store(addr, rtas_args->args[4]); ! 58: else if (size == 4) ! 59: bswap32_store(addr, rtas_args->args[4]); ! 60: else ! 61: retVal = -3; /* Bad arguments */ ! 62: ! 63: return retVal; ! 64: } ! 65: ! 66: int ! 67: rtas_read_pci_config (rtas_args_t *rtas_args) { ! 68: int retVal = 0; ! 69: unsigned long addr = rtas_args->args[0]; ! 70: unsigned int size = rtas_args->args[1]; ! 71: addr |= 0xf2000000; ! 72: ! 73: /* Check for bus != 0 */ ! 74: if (addr & 0xff0000) ! 75: addr += 0x1000000; ! 76: ! 77: if (size == 1) ! 78: rtas_args->args[3] = load8_ci(addr); ! 79: else if (size == 2) ! 80: rtas_args->args[3] = bswap16_load(addr); ! 81: else if (size == 4) ! 82: rtas_args->args[3] = bswap32_load(addr); ! 83: else ! 84: retVal = -3; /* Bad arguments */ ! 85: ! 86: return retVal; ! 87: } ! 88: ! 89: int ! 90: rtas_write_pci_config (rtas_args_t *rtas_args) { ! 91: int retVal = 0; ! 92: unsigned long addr = rtas_args->args[0]; ! 93: unsigned int size = rtas_args->args[1]; ! 94: ! 95: addr |= 0xf2000000; ! 96: ! 97: /* Check for bus != 0 */ ! 98: if (addr & 0xff0000) ! 99: addr += 0x1000000; ! 100: ! 101: if (size == 1) ! 102: store8_ci(addr, rtas_args->args[2]); ! 103: else if (size == 2) ! 104: bswap16_store(addr, rtas_args->args[2]); ! 105: else if (size == 4) ! 106: bswap32_store(addr, rtas_args->args[2]); ! 107: else ! 108: retVal = -3; /* Bad arguments */ ! 109: ! 110: return retVal; ! 111: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.