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

4.104.115
Last change on this file since e08dbc5 was e08dbc5, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 11/03/09 at 18:45:04

various PowerPC code maintenance

  • Property mode set to 100644
File size: 1.3 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 __cplusplus
23extern "C" {
24#endif
25
26#ifdef __GNUC__
27
28extern __inline__ unsigned ld_le16(volatile uint16_t *addr)
29{
30        unsigned val;
31
32        __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
33        return val;
34}
35
36extern __inline__ void st_le16(volatile uint16_t *addr, unsigned val)
37{
38        __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
39}
40
41extern __inline__ unsigned ld_le32(volatile uint32_t *addr)
42{
43        unsigned val;
44
45        __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
46        return val;
47}
48
49extern __inline__ void st_le32(volatile uint32_t *addr, unsigned val)
50{
51        __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
52}
53
54#endif /* __GNUC__ */
55
56#ifdef __cplusplus
57}
58#endif
59
60#endif /* _LIBCPU_BYTEORDER_H */
Note: See TracBrowser for help on using the repository browser.