Skip to content

Commit 3c5fdd6

Browse files
authored
Merge pull request #19 from smaeul/patch/big-endian-host
Fix the build on big-endian hosts and a related cleanup
2 parents e3a5af0 + bcfb572 commit 3c5fdd6

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

cpu/common/elf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#endif
77

88
#ifdef WORDS_BIGENDIAN
9-
#define ELF_SHORT_H
10-
#define ELF_LONG_H
9+
#define ELF_SHORT_H(ps) ((unsigned short)(ps))
10+
#define ELF_LONG_H(ps) ((unsigned long)(ps))
1111
#else
1212
/* Load a short int from the following tables with big-endian formats */
1313
#define ELF_SHORT_H(ps) ((((unsigned short)(ps) >> 8) & 0xff) |\

debug/rsp-server.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,8 @@ reg2hex (unsigned long int val,
11901190

11911191
for (n = 0; n < 8; n++)
11921192
{
1193-
#ifdef WORDSBIGENDIAN
1194-
int nyb_shift = n * 4;
1193+
#ifdef WORDS_BIGENDIAN
1194+
int nyb_shift = (n ^ 1) * 4;
11951195
#else
11961196
int nyb_shift = 28 - (n * 4);
11971197
#endif
@@ -1221,8 +1221,8 @@ hex2reg (char *buf)
12211221

12221222
for (n = 0; n < 8; n++)
12231223
{
1224-
#ifdef WORDSBIGENDIAN
1225-
int nyb_shift = n * 4;
1224+
#ifdef WORDS_BIGENDIAN
1225+
int nyb_shift = (n ^ 1) * 4;
12261226
#else
12271227
int nyb_shift = 28 - (n * 4);
12281228
#endif

peripheral/memory.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ simmem_read8 (oraddr_t addr, void *dat)
9090
#ifdef WORDS_BIGENDIAN
9191
return *(uint8_t *) (dat + addr);
9292
#else
93-
return *(uint8_t *) (dat + ((addr & ~ADDR_C (3)) | (3 - (addr & 3))));
93+
return *(uint8_t *) (dat + (addr ^ 3));
9494
#endif
9595
}
9696

@@ -116,7 +116,7 @@ simmem_write8 (oraddr_t addr, uint8_t value, void *dat)
116116
#ifdef WORDS_BIGENDIAN
117117
*(uint8_t *) (dat + addr) = value;
118118
#else
119-
*(uint8_t *) (dat + ((addr & ~ADDR_C (3)) | (3 - (addr & 3)))) = value;
119+
*(uint8_t *) (dat + (addr ^ 3)) = value;
120120
#endif
121121
}
122122

peripheral/vga.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,12 @@ vga_read32 (oraddr_t addr, void *dat)
177177

178178
/* This code will only work on little endian machines */
179179
#ifdef __BIG_ENDIAN__
180-
#warning Image dump not supported on big endian machines
181180

182181
static int
183-
vga_dump_image (char *filename, struct vga_start *vga)
182+
vga_dump_image (char *filename, struct vga_state *vga)
184183
{
184+
fprintf (stderr, "Image dump not supported on big endian machines\n");
185+
185186
return 1;
186187
}
187188

0 commit comments

Comments
 (0)