]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* If we're being compiled as a .c file, rather than being included in |
2 | d10v_sim.h, then ENDIAN_INLINE won't be defined yet. */ | |
3 | ||
6df01ab8 MF |
4 | /* This must come before any other includes. */ |
5 | #include "defs.h" | |
6 | ||
c906108c SS |
7 | #ifndef ENDIAN_INLINE |
8 | #define NO_ENDIAN_INLINE | |
67954606 | 9 | #include "sim-main.h" |
c906108c SS |
10 | #define ENDIAN_INLINE |
11 | #endif | |
12 | ||
13 | ENDIAN_INLINE uint16 | |
11558abc | 14 | get_word (uint8 *x) |
c906108c | 15 | { |
c906108c | 16 | return ((uint16)x[0]<<8) + x[1]; |
c906108c SS |
17 | } |
18 | ||
19 | ENDIAN_INLINE uint32 | |
11558abc | 20 | get_longword (uint8 *x) |
c906108c | 21 | { |
c906108c | 22 | return ((uint32)x[0]<<24) + ((uint32)x[1]<<16) + ((uint32)x[2]<<8) + ((uint32)x[3]); |
c906108c SS |
23 | } |
24 | ||
25 | ENDIAN_INLINE int64 | |
11558abc | 26 | get_longlong (uint8 *x) |
c906108c SS |
27 | { |
28 | uint32 top = get_longword (x); | |
29 | uint32 bottom = get_longword (x+4); | |
30 | return (((int64)top)<<32) | (int64)bottom; | |
31 | } | |
32 | ||
33 | ENDIAN_INLINE void | |
11558abc | 34 | write_word (uint8 *addr, uint16 data) |
c906108c | 35 | { |
c906108c SS |
36 | addr[0] = (data >> 8) & 0xff; |
37 | addr[1] = data & 0xff; | |
c906108c SS |
38 | } |
39 | ||
40 | ENDIAN_INLINE void | |
11558abc | 41 | write_longword (uint8 *addr, uint32 data) |
c906108c | 42 | { |
c906108c SS |
43 | addr[0] = (data >> 24) & 0xff; |
44 | addr[1] = (data >> 16) & 0xff; | |
45 | addr[2] = (data >> 8) & 0xff; | |
46 | addr[3] = data & 0xff; | |
c906108c SS |
47 | } |
48 | ||
49 | ENDIAN_INLINE void | |
11558abc | 50 | write_longlong (uint8 *addr, int64 data) |
c906108c SS |
51 | { |
52 | write_longword (addr, (uint32)(data >> 32)); | |
53 | write_longword (addr+4, (uint32)data); | |
54 | } |