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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • 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 the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#ifndef _LIBCPU_BYTEORDER_H
18#define _LIBCPU_BYTEORDER_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24static 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
32static 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
37static 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
45static 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#ifdef __cplusplus
51}
52#endif
53
54#endif /* _LIBCPU_BYTEORDER_H */
Note: See TracBrowser for help on using the repository browser.