Commit 188d857911636fa43628eb8a7beeab4702636317
1 parent
9bc9d1c7
limited 8 bit support - removed unaligned memory accesses in VGA (initial patch …
…by Johannes Schindelin) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1116 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
35 additions
and
10 deletions
bswap.h
| @@ -133,6 +133,9 @@ CPU_CONVERT(le, 64, uint64_t) | @@ -133,6 +133,9 @@ CPU_CONVERT(le, 64, uint64_t) | ||
| 133 | #define le16_to_cpupu(p) le16_to_cpup(p) | 133 | #define le16_to_cpupu(p) le16_to_cpup(p) |
| 134 | #define le32_to_cpupu(p) le32_to_cpup(p) | 134 | #define le32_to_cpupu(p) le32_to_cpup(p) |
| 135 | 135 | ||
| 136 | +#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v) | ||
| 137 | +#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v) | ||
| 138 | + | ||
| 136 | #else | 139 | #else |
| 137 | 140 | ||
| 138 | static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) | 141 | static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) |
| @@ -165,6 +168,30 @@ static inline uint32_t le32_to_cpupu(const uint32_t *p) | @@ -165,6 +168,30 @@ static inline uint32_t le32_to_cpupu(const uint32_t *p) | ||
| 165 | return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24); | 168 | return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24); |
| 166 | } | 169 | } |
| 167 | 170 | ||
| 171 | +static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) | ||
| 172 | +{ | ||
| 173 | + uint8_t *p1 = (uint8_t *)p; | ||
| 174 | + | ||
| 175 | + p1[0] = v >> 8; | ||
| 176 | + p1[1] = v; | ||
| 177 | +} | ||
| 178 | + | ||
| 179 | +static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) | ||
| 180 | +{ | ||
| 181 | + uint8_t *p1 = (uint8_t *)p; | ||
| 182 | + | ||
| 183 | + p1[0] = v >> 24; | ||
| 184 | + p1[1] = v >> 16; | ||
| 185 | + p1[2] = v >> 8; | ||
| 186 | + p1[3] = v; | ||
| 187 | +} | ||
| 188 | + | ||
| 189 | +#endif | ||
| 190 | + | ||
| 191 | +#ifdef WORDS_BIGENDIAN | ||
| 192 | +#define cpu_to_32wu cpu_to_be32wu | ||
| 193 | +#else | ||
| 194 | +#define cpu_to_32wu cpu_to_le32wu | ||
| 168 | #endif | 195 | #endif |
| 169 | 196 | ||
| 170 | #undef le_bswap | 197 | #undef le_bswap |
hw/vga.c
| @@ -824,8 +824,7 @@ typedef void vga_draw_line_func(VGAState *s1, uint8_t *d, | @@ -824,8 +824,7 @@ typedef void vga_draw_line_func(VGAState *s1, uint8_t *d, | ||
| 824 | 824 | ||
| 825 | static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b) | 825 | static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b) |
| 826 | { | 826 | { |
| 827 | - /* XXX: TODO */ | ||
| 828 | - return 0; | 827 | + return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6); |
| 829 | } | 828 | } |
| 830 | 829 | ||
| 831 | static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b) | 830 | static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b) |
hw/vga_template.h
| @@ -44,7 +44,7 @@ static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d, | @@ -44,7 +44,7 @@ static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d, | ||
| 44 | { | 44 | { |
| 45 | #if BPP == 1 | 45 | #if BPP == 1 |
| 46 | ((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol; | 46 | ((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol; |
| 47 | - ((uint32_t *)d)[3] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; | 47 | + ((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; |
| 48 | #elif BPP == 2 | 48 | #elif BPP == 2 |
| 49 | ((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol; | 49 | ((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol; |
| 50 | ((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol; | 50 | ((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol; |
| @@ -106,22 +106,21 @@ static void glue(vga_draw_glyph9_, DEPTH)(uint8_t *d, int linesize, | @@ -106,22 +106,21 @@ static void glue(vga_draw_glyph9_, DEPTH)(uint8_t *d, int linesize, | ||
| 106 | xorcol = bgcol ^ fgcol; | 106 | xorcol = bgcol ^ fgcol; |
| 107 | do { | 107 | do { |
| 108 | font_data = font_ptr[0]; | 108 | font_data = font_ptr[0]; |
| 109 | - /* XXX: unaligned accesses are done */ | ||
| 110 | #if BPP == 1 | 109 | #if BPP == 1 |
| 111 | - ((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol; | 110 | + cpu_to_32wu((uint32_t *)d, (dmask16[(font_data >> 4)] & xorcol) ^ bgcol); |
| 112 | v = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; | 111 | v = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; |
| 113 | - ((uint32_t *)d)[3] = v; | 112 | + cpu_to_32wu(((uint32_t *)d)+1, v); |
| 114 | if (dup9) | 113 | if (dup9) |
| 115 | ((uint8_t *)d)[8] = v >> (24 * (1 - BIG)); | 114 | ((uint8_t *)d)[8] = v >> (24 * (1 - BIG)); |
| 116 | else | 115 | else |
| 117 | ((uint8_t *)d)[8] = bgcol; | 116 | ((uint8_t *)d)[8] = bgcol; |
| 118 | 117 | ||
| 119 | #elif BPP == 2 | 118 | #elif BPP == 2 |
| 120 | - ((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol; | ||
| 121 | - ((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol; | ||
| 122 | - ((uint32_t *)d)[2] = (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol; | 119 | + cpu_to_32wu(((uint32_t *)d)+0, (dmask4[(font_data >> 6)] & xorcol) ^ bgcol); |
| 120 | + cpu_to_32wu(((uint32_t *)d)+1, (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol); | ||
| 121 | + cpu_to_32wu(((uint32_t *)d)+2, (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol); | ||
| 123 | v = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol; | 122 | v = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol; |
| 124 | - ((uint32_t *)d)[3] = v; | 123 | + cpu_to_32wu(((uint32_t *)d)+3, v); |
| 125 | if (dup9) | 124 | if (dup9) |
| 126 | ((uint16_t *)d)[8] = v >> (16 * (1 - BIG)); | 125 | ((uint16_t *)d)[8] = v >> (16 * (1 - BIG)); |
| 127 | else | 126 | else |