Rev 4399 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4399 | Rev 4418 | ||
---|---|---|---|
Line 107... | Line 107... | ||
107 | psycho_conf_read(dev, reg, (uint8_t *)(&res), sizeof(uint32_t)); |
107 | psycho_conf_read(dev, reg, (uint8_t *)(&res), sizeof(uint32_t)); |
108 | futex_up(&pci_conf_futex); |
108 | futex_up(&pci_conf_futex); |
109 | return res; |
109 | return res; |
110 | } |
110 | } |
111 | 111 | ||
112 | static inline uint16_t invert_endianess_16(uint16_t x) |
112 | static inline uint16_t invert_endianness_16(uint16_t x) |
113 | { |
113 | { |
114 | return (x & 0xFF) << 8 | (x >> 8); |
114 | return (x & 0xFF) << 8 | (x >> 8); |
115 | } |
115 | } |
116 | 116 | ||
117 | static inline uint32_t invert_endianess_32(uint32_t x) |
117 | static inline uint32_t invert_endianness_32(uint32_t x) |
118 | { |
118 | { |
119 | return ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | (x >> 24); |
119 | return ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | (x >> 24); |
120 | } |
120 | } |
121 | 121 | ||
122 | static void psycho_conf_read(pci_dev_t *d, int reg, uint8_t *buf, int len) |
122 | static void psycho_conf_read(pci_dev_t *d, int reg, uint8_t *buf, int len) |
Line 124... | Line 124... | ||
124 | switch (len) { |
124 | switch (len) { |
125 | case 1: |
125 | case 1: |
126 | buf[0] = pio_read_8(psycho_conf_addr(d, reg)); |
126 | buf[0] = pio_read_8(psycho_conf_addr(d, reg)); |
127 | break; |
127 | break; |
128 | case 2: |
128 | case 2: |
129 | *((uint16_t *)buf) = invert_endianess_16(pio_read_16(psycho_conf_addr(d, reg))); |
129 | *((uint16_t *)buf) = invert_endianness_16(pio_read_16(psycho_conf_addr(d, reg))); |
130 | break; |
130 | break; |
131 | case 4: |
131 | case 4: |
132 | *((uint32_t *)buf) = invert_endianess_32(pio_read_32(psycho_conf_addr(d, reg))); |
132 | *((uint32_t *)buf) = invert_endianness_32(pio_read_32(psycho_conf_addr(d, reg))); |
133 | break; |
133 | break; |
134 | } |
134 | } |
135 | } |
135 | } |
136 | 136 | ||
137 | static void psycho_conf_write(pci_dev_t *d, int reg, uint8_t *buf, int len) |
137 | static void psycho_conf_write(pci_dev_t *d, int reg, uint8_t *buf, int len) |
Line 139... | Line 139... | ||
139 | switch (len) { |
139 | switch (len) { |
140 | case 1: |
140 | case 1: |
141 | pio_write_8(psycho_conf_addr(d, reg), buf[0]); |
141 | pio_write_8(psycho_conf_addr(d, reg), buf[0]); |
142 | break; |
142 | break; |
143 | case 2: |
143 | case 2: |
144 | pio_write_16(psycho_conf_addr(d, reg), invert_endianess_16(*((uint16_t *)buf))); |
144 | pio_write_16(psycho_conf_addr(d, reg), invert_endianness_16(*((uint16_t *)buf))); |
145 | break; |
145 | break; |
146 | case 4: |
146 | case 4: |
147 | pio_write_32(psycho_conf_addr(d, reg), invert_endianess_32(*((uint32_t *)buf))); |
147 | pio_write_32(psycho_conf_addr(d, reg), invert_endianness_32(*((uint32_t *)buf))); |
148 | break; |
148 | break; |
149 | } |
149 | } |
150 | } |
150 | } |
151 | 151 | ||
152 | /* pci bus structure initialization */ |
152 | /* pci bus structure initialization */ |