~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/SLOF/board-js2x/rtas/rtas_pci.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include "rtas_board.h"
 
16
 
 
17
void
 
18
rtas_ibm_read_pci_config (rtas_args_t *rtas_args)
 
19
{
 
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
 
 
39
        rtas_args->args[4] = retVal;
 
40
}
 
41
 
 
42
void
 
43
rtas_ibm_write_pci_config (rtas_args_t *rtas_args)
 
44
{
 
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
 
 
66
        rtas_args->args[5] = retVal;
 
67
}
 
68
 
 
69
void
 
70
rtas_read_pci_config (rtas_args_t *rtas_args)
 
71
{
 
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
 
 
90
        rtas_args->args[2] = retVal;
 
91
}
 
92
 
 
93
void
 
94
rtas_write_pci_config (rtas_args_t *rtas_args)
 
95
{
 
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
 
 
115
        rtas_args->args[3] = retVal;
 
116
}