|
|
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>
1.1.1.2 ! root 15: #include "rtas_board.h"
1.1 root 16:
1.1.1.2 ! root 17: void
! 18: rtas_ibm_read_pci_config (rtas_args_t *rtas_args)
! 19: {
1.1 root 20: int retVal = 0;
21: uint64_t addr = ((uint64_t) rtas_args->args[1]) << 32; // high 32 bits of PHB UID
22: addr |= (rtas_args->args[2] & 0xFFFFFFFF); // low 32 bits of PHB UID
23: addr |= (rtas_args->args[0] & 0x00FFFFFF); // bus, devfn, offset
24: unsigned int size = rtas_args->args[3];
25:
26: /* Check for bus != 0 on PCI/PCI-X (PHB UID = 0xf2000000) */
27: if (((addr & 0xf2000000) == 0xf2000000) && (addr & 0xff0000))
28: addr += 0x1000000;
29:
30: if (size == 1)
31: rtas_args->args[5] = load8_ci(addr);
32: else if (size == 2)
33: rtas_args->args[5] = bswap16_load(addr);
34: else if (size == 4)
35: rtas_args->args[5] = bswap32_load(addr);
36: else
37: retVal = -3; /* Bad arguments */
38:
1.1.1.2 ! root 39: rtas_args->args[4] = retVal;
1.1 root 40: }
41:
1.1.1.2 ! root 42: void
! 43: rtas_ibm_write_pci_config (rtas_args_t *rtas_args)
! 44: {
1.1 root 45: int retVal = 0;
46: uint64_t addr = ((uint64_t) rtas_args->args[1]) << 32; // high 32 bits of PHB UID
47: addr |= (rtas_args->args[2] & 0xFFFFFFFF); // low 32 bits of PHB UID
48: addr |= (rtas_args->args[0] & 0x00FFFFFF); // bus, devfn, offset
49: unsigned int size = rtas_args->args[3];
50:
51: addr |= 0xf2000000;
52:
53: /* Check for bus != 0 on PCI/PCI-X (PHB UID = 0xf2000000) */
54: if (((addr & 0xf2000000) == 0xf2000000) && (addr & 0xff0000))
55: addr += 0x1000000;
56:
57: if (size == 1)
58: store8_ci(addr, rtas_args->args[4]);
59: else if (size == 2)
60: bswap16_store(addr, rtas_args->args[4]);
61: else if (size == 4)
62: bswap32_store(addr, rtas_args->args[4]);
63: else
64: retVal = -3; /* Bad arguments */
65:
1.1.1.2 ! root 66: rtas_args->args[5] = retVal;
1.1 root 67: }
68:
1.1.1.2 ! root 69: void
! 70: rtas_read_pci_config (rtas_args_t *rtas_args)
! 71: {
1.1 root 72: int retVal = 0;
73: unsigned long addr = rtas_args->args[0];
74: unsigned int size = rtas_args->args[1];
75: addr |= 0xf2000000;
76:
77: /* Check for bus != 0 */
78: if (addr & 0xff0000)
79: addr += 0x1000000;
80:
81: if (size == 1)
82: rtas_args->args[3] = load8_ci(addr);
83: else if (size == 2)
84: rtas_args->args[3] = bswap16_load(addr);
85: else if (size == 4)
86: rtas_args->args[3] = bswap32_load(addr);
87: else
88: retVal = -3; /* Bad arguments */
89:
1.1.1.2 ! root 90: rtas_args->args[2] = retVal;
1.1 root 91: }
92:
1.1.1.2 ! root 93: void
! 94: rtas_write_pci_config (rtas_args_t *rtas_args)
! 95: {
1.1 root 96: int retVal = 0;
97: unsigned long addr = rtas_args->args[0];
98: unsigned int size = rtas_args->args[1];
99:
100: addr |= 0xf2000000;
101:
102: /* Check for bus != 0 */
103: if (addr & 0xff0000)
104: addr += 0x1000000;
105:
106: if (size == 1)
107: store8_ci(addr, rtas_args->args[2]);
108: else if (size == 2)
109: bswap16_store(addr, rtas_args->args[2]);
110: else if (size == 4)
111: bswap32_store(addr, rtas_args->args[2]);
112: else
113: retVal = -3; /* Bad arguments */
114:
1.1.1.2 ! root 115: rtas_args->args[3] = retVal;
1.1 root 116: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.