source: rtems/c/src/lib/libcpu/powerpc/shared/include/byteorder.h @ b472166d

4.104.114.95
Last change on this file since b472166d was b472166d, checked in by Till Straumann <strauman@…>, on 11/14/07 at 00:36:59

2007-11-13 Till Straumann <strauman@…>

  • shared/include/byteorder.h: fixed wrong pointer-type of ld_le32() (uint16_t* -> uint32_t*).
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 * byteorder.h
3 *
4 *        This file contains inline implementation of function to
5 *          deal with endian conversion.
6 *
7 * It is a stripped down version of linux ppc file...
8 *
9 * Copyright (C) 1999  Eric Valette (valette@crf.canon.fr)
10 *                     Canon Centre Recherche France.
11 *
12 *  The license and distribution terms for this file may be
13 *  found in found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#ifndef _LIBCPU_BYTEORDER_H
20#define _LIBCPU_BYTEORDER_H
21
22#ifdef __GNUC__
23
24extern __inline__ unsigned ld_le16(volatile uint16_t *addr)
25{
26        unsigned val;
27
28        __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
29        return val;
30}
31
32extern __inline__ void st_le16(volatile uint16_t *addr, unsigned val)
33{
34        __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
35}
36
37extern __inline__ unsigned ld_le32(volatile uint32_t *addr)
38{
39        unsigned val;
40
41        __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
42        return val;
43}
44
45extern __inline__ void st_le32(volatile uint32_t *addr, unsigned val)
46{
47        __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
48}
49
50#endif /* __GNUC__ */
51
52#endif /* _LIBCPU_BYTEORDER_H */
Note: See TracBrowser for help on using the repository browser.