RTEMS  5.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
byteorder.h
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
21 extern "C" {
22 #endif
23 
24 static 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 
32 static 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 
37 static 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 
45 static 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 */
register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__("g6")
The pointer to the current per-CPU control is available via register g6.