Subversion Repositories HelenOS

Rev

Rev 4418 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4418 Rev 4438
Line 82... Line 82...
82
    u2p_bases[1] = 0x1ca00000000;  
82
    u2p_bases[1] = 0x1ca00000000;  
83
}
83
}
84
 
84
 
85
uint8_t pci_conf_read_8(pci_dev_t *dev, int reg)
85
uint8_t pci_conf_read_8(pci_dev_t *dev, int reg)
86
{
86
{
87
    uint8_t res;
87
    uint8_t res;   
88
    futex_down(&pci_conf_futex);
-
 
89
    psycho_conf_read(dev, reg, &res, sizeof(uint8_t)); 
88
    psycho_conf_read(dev, reg, &res, sizeof(uint8_t)); 
90
    futex_up(&pci_conf_futex);
-
 
91
    return res;
89
    return res;
92
}
90
}
93
 
91
 
94
uint16_t pci_conf_read_16(pci_dev_t *dev, int reg)
92
uint16_t pci_conf_read_16(pci_dev_t *dev, int reg)
95
{
93
{
96
    uint16_t res;
94
    uint16_t res;
97
    futex_down(&pci_conf_futex);
-
 
98
    psycho_conf_read(dev, reg, (uint8_t *)(&res), sizeof(uint16_t));   
95
    psycho_conf_read(dev, reg, (uint8_t *)(&res), sizeof(uint16_t));   
99
    futex_up(&pci_conf_futex);
-
 
100
    return res;
96
    return res;
101
}
97
}
102
 
98
 
103
uint32_t pci_conf_read_32(pci_dev_t *dev, int reg)
99
uint32_t pci_conf_read_32(pci_dev_t *dev, int reg)
104
{
100
{
105
    uint32_t res;
101
    uint32_t res;
106
    futex_down(&pci_conf_futex);
-
 
107
    psycho_conf_read(dev, reg, (uint8_t *)(&res), sizeof(uint32_t));   
102
    psycho_conf_read(dev, reg, (uint8_t *)(&res), sizeof(uint32_t));       
108
    futex_up(&pci_conf_futex);
-
 
109
    return res;
103
    return res;
110
}
104
}
111
 
105
 
112
static inline uint16_t invert_endianness_16(uint16_t x)
106
static inline uint16_t invert_endianness_16(uint16_t x)
113
{
107
{
Line 119... Line 113...
119
    return ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | (x >> 24);
113
    return ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | (x >> 24);
120
}
114
}
121
 
115
 
122
static void psycho_conf_read(pci_dev_t *d, int reg, uint8_t *buf, int len)
116
static void psycho_conf_read(pci_dev_t *d, int reg, uint8_t *buf, int len)
123
{  
117
{  
-
 
118
    futex_down(&pci_conf_futex);
124
    switch (len) {
119
    switch (len) {
125
        case 1:
120
        case 1:
126
            buf[0] = pio_read_8(psycho_conf_addr(d, reg));
121
            buf[0] = pio_read_8(psycho_conf_addr(d, reg));
127
            break;
122
            break;
128
        case 2:
123
        case 2:
129
            *((uint16_t *)buf) = invert_endianness_16(pio_read_16(psycho_conf_addr(d, reg)));
124
            *((uint16_t *)buf) = invert_endianness_16(pio_read_16(psycho_conf_addr(d, reg)));
130
            break;
125
            break;
131
        case 4:
126
        case 4:
132
            *((uint32_t *)buf) = invert_endianness_32(pio_read_32(psycho_conf_addr(d, reg)));
127
            *((uint32_t *)buf) = invert_endianness_32(pio_read_32(psycho_conf_addr(d, reg)));
133
            break;
128
            break;
134
    }  
129
    }
-
 
130
    futex_up(&pci_conf_futex);
135
}
131
}
136
 
132
 
137
static void psycho_conf_write(pci_dev_t *d, int reg, uint8_t *buf, int len)
133
static void psycho_conf_write(pci_dev_t *d, int reg, uint8_t *buf, int len)
138
{  
134
{  
-
 
135
    futex_down(&pci_conf_futex);
139
    switch (len) {
136
    switch (len) {
140
        case 1:
137
        case 1:
141
            pio_write_8(psycho_conf_addr(d, reg), buf[0]);
138
            pio_write_8(psycho_conf_addr(d, reg), buf[0]);
142
            break;
139
            break;
143
        case 2:
140
        case 2:
Line 145... Line 142...
145
            break;
142
            break;
146
        case 4:
143
        case 4:
147
            pio_write_32(psycho_conf_addr(d, reg), invert_endianness_32(*((uint32_t *)buf)));
144
            pio_write_32(psycho_conf_addr(d, reg), invert_endianness_32(*((uint32_t *)buf)));
148
            break;
145
            break;
149
    }
146
    }
-
 
147
    futex_up(&pci_conf_futex);
150
}
148
}
151
 
149
 
152
/* pci bus structure initialization */
150
/* pci bus structure initialization */
153
void pci_init_bus_data(pci_bus_t *bus, pci_bus_t *parent)
151
void pci_init_bus_data(pci_bus_t *bus, pci_bus_t *parent)
154
{
152
{