OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-ppc/] [byteorder.h] - Blame information for rev 1276

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
#ifndef _PPC_BYTEORDER_H
2
#define _PPC_BYTEORDER_H
3
 
4
#include <asm/types.h>
5
 
6
#ifdef __GNUC__
7
#ifdef __KERNEL__
8
 
9
extern __inline__ unsigned ld_le16(const volatile unsigned short *addr)
10
{
11
        unsigned val;
12
 
13
        __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
14
        return val;
15
}
16
 
17
extern __inline__ void st_le16(volatile unsigned short *addr, const unsigned val)
18
{
19
        __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
20
}
21
 
22
extern __inline__ unsigned ld_le32(const volatile unsigned *addr)
23
{
24
        unsigned val;
25
 
26
        __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
27
        return val;
28
}
29
 
30
extern __inline__ void st_le32(volatile unsigned *addr, const unsigned val)
31
{
32
        __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
33
}
34
 
35
extern __inline__ unsigned long long ld_le64(const volatile unsigned long long *addr)
36
{
37
        unsigned char *taddr = (unsigned char *) addr;
38
        unsigned long long val;
39
 
40
        __asm__ __volatile__ ("lwbrx %L0,0,%1" : "=r" (val) : "r" (taddr),   "m" (*addr));
41
        __asm__ __volatile__ ("lwbrx  %0,0,%1" : "=r" (val) : "r" (taddr+4), "m" (*addr), "0" (val));
42
        return val;
43
}
44
 
45
extern __inline__ void st_le64(volatile unsigned long long *addr, const unsigned long long val)
46
{
47
        unsigned char *taddr = (unsigned char *) addr;
48
 
49
        __asm__ __volatile__ ("stwbrx %L1,0,%2" : "=m" (*addr) : "r" (val), "r" (taddr));
50
        __asm__ __volatile__ ("stwbrx  %1,0,%2" : "=m" (*addr) : "r" (val), "r" (taddr+4));
51
}
52
 
53
static __inline__ __const__ __u16 ___arch__swab16(__u16 value)
54
{
55
        __u16 result;
56
 
57
        __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (value >> 8), "r" (value));
58
        return result;
59
}
60
 
61
static __inline__ __const__ __u32 ___arch__swab32(__u32 value)
62
{
63
        __u32 result;
64
 
65
        __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (value>>24), "r" (value));
66
        __asm__("rlwimi %0,%2,8,8,15"   : "=&r" (result) : "0" (result),    "r" (value));
67
        __asm__("rlwimi %0,%2,24,0,7"   : "=&r" (result) : "0" (result),    "r" (value));
68
 
69
        return result;
70
}
71
#define __arch__swab32(x) ___arch__swab32(x)
72
#define __arch__swab16(x) ___arch__swab16(x)
73
 
74
/* The same, but returns converted value from the location pointer by addr. */
75
#define __arch__swab16p(addr) ld_le16(addr)
76
#define __arch__swab32p(addr) ld_le32(addr)
77
#define __arch__swab64p(addr) ld_le64(addr)
78
 
79
/* The same, but do the conversion in situ, ie. put the value back to addr. */
80
#define __arch__swab16s(addr) st_le16(addr,*addr)
81
#define __arch__swab32s(addr) st_le32(addr,*addr)
82
#define __arch__swab64s(addr) st_le64(addr,*addr)
83
 
84
#endif /* __KERNEL__ */
85
 
86
#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
87
#  define __BYTEORDER_HAS_U64__
88
#  define __SWAB_64_THRU_32__
89
#endif
90
 
91
#endif /* __GNUC__ */
92
 
93
#include <linux/byteorder/big_endian.h>
94
 
95
#endif /* _PPC_BYTEORDER_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.