Annotation of hatari/src/uae-cpu/maccess.h, revision 1.1.1.3

1.1.1.3 ! root        1:  /*
        !             2:   * UAE - The Un*x Amiga Emulator - CPU core
        !             3:   *
        !             4:   * Big endian memory access functions.
1.1       root        5:   *
                      6:   * Copyright 1996 Bernd Schmidt
1.1.1.3 ! root        7:   *
        !             8:   * Adaptation to Hatari by Thomas Huth, Eero Tamminen
        !             9:   *
        !            10:   * This file is distributed under the GNU Public License, version 2 or at
        !            11:   * your option any later version. Read the file gpl.txt for details.
1.1       root       12:   */
                     13: 
1.1.1.2   root       14: #ifndef UAE_MACCESS_H
                     15: #define UAE_MACCESS_H
                     16: 
                     17: 
1.1.1.3 ! root       18: /* Can the actual CPU access unaligned memory? */
        !            19: #ifndef CPU_CAN_ACCESS_UNALIGNED
        !            20: # if defined(__i386__) || defined(powerpc) || defined(__mc68020__)
        !            21: #  define CPU_CAN_ACCESS_UNALIGNED 1
        !            22: # else
        !            23: #  define CPU_CAN_ACCESS_UNALIGNED 0
        !            24: # endif
        !            25: #endif
        !            26: 
        !            27: 
        !            28: /* If the CPU can access unaligned memory, use these accelerated functions: */
        !            29: #if CPU_CAN_ACCESS_UNALIGNED
        !            30: 
        !            31: #include <SDL_endian.h>
        !            32: 
        !            33: 
        !            34: static inline uae_u32 do_get_mem_long(uae_u32 *a)
1.1       root       35: {
1.1.1.3 ! root       36:        return SDL_SwapBE32(*a);
1.1       root       37: }
                     38: 
1.1.1.3 ! root       39: static inline uae_u16 do_get_mem_word(uae_u16 *a)
1.1       root       40: {
1.1.1.3 ! root       41:        return SDL_SwapBE16(*a);
1.1       root       42: }
                     43: 
1.1.1.3 ! root       44: 
        !            45: static inline void do_put_mem_long(uae_u32 *a, uae_u32 v)
1.1       root       46: {
1.1.1.3 ! root       47:        *a = SDL_SwapBE32(v);
1.1       root       48: }
                     49: 
1.1.1.3 ! root       50: static inline void do_put_mem_word(uae_u16 *a, uae_u16 v)
1.1       root       51: {
1.1.1.3 ! root       52:        *a = SDL_SwapBE16(v);
1.1       root       53: }
                     54: 
1.1.1.3 ! root       55: 
        !            56: #else  /* Cpu can not access unaligned memory: */
        !            57: 
        !            58: 
        !            59: static inline uae_u32 do_get_mem_long(uae_u32 *a)
1.1       root       60: {
1.1.1.3 ! root       61:        uae_u8 *b = (uae_u8 *)a;
        !            62: 
        !            63:        return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
1.1       root       64: }
                     65: 
1.1.1.3 ! root       66: static inline uae_u16 do_get_mem_word(uae_u16 *a)
1.1       root       67: {
1.1.1.3 ! root       68:        uae_u8 *b = (uae_u8 *)a;
        !            69: 
        !            70:        return (b[0] << 8) | b[1];
1.1       root       71: }
                     72: 
                     73: 
1.1.1.3 ! root       74: static inline void do_put_mem_long(uae_u32 *a, uae_u32 v)
        !            75: {
        !            76:        uae_u8 *b = (uae_u8 *)a;
        !            77: 
        !            78:        b[0] = v >> 24;
        !            79:        b[1] = v >> 16;    
        !            80:        b[2] = v >> 8;
        !            81:        b[3] = v;
        !            82: }
        !            83: 
        !            84: static inline void do_put_mem_word(uae_u16 *a, uae_u16 v)
        !            85: {
        !            86:        uae_u8 *b = (uae_u8 *)a;
        !            87: 
        !            88:        b[0] = v >> 8;
        !            89:        b[1] = v;
        !            90: }
        !            91: 
        !            92: 
        !            93: #endif  /* CPU_CAN_ACCESS_UNALIGNED */
        !            94: 
        !            95: 
        !            96: /* These are same for all architectures: */
        !            97: 
        !            98: static inline uae_u8 do_get_mem_byte(uae_u8 *a)
        !            99: {
        !           100:        return *a;
        !           101: }
        !           102: 
        !           103: static inline void do_put_mem_byte(uae_u8 *a, uae_u8 v)
        !           104: {
        !           105:        *a = v;
        !           106: }
1.1       root      107: 
1.1.1.2   root      108: 
                    109: #endif /* UAE_MACCESS_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.