4.104.114.84.95
Line | |
---|
1 | /* |
---|
2 | * COPYRIGHT (c) 1998 by Radstone Technology |
---|
3 | * |
---|
4 | * |
---|
5 | * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY |
---|
6 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE |
---|
7 | * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK |
---|
8 | * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU. |
---|
9 | * |
---|
10 | * You are hereby granted permission to use, copy, modify, and distribute |
---|
11 | * this file, provided that this notice, plus the above copyright notice |
---|
12 | * and disclaimer, appears in all copies. Radstone Technology will provide |
---|
13 | * no support for this code. |
---|
14 | * |
---|
15 | */ |
---|
16 | |
---|
17 | #include <rtems.h> |
---|
18 | |
---|
19 | /* |
---|
20 | * JRS - February 20, 1998 |
---|
21 | * |
---|
22 | * There is a swap32 in each port. So this should be removed. |
---|
23 | * |
---|
24 | * Adding a swap16 to the port would be useful. |
---|
25 | * |
---|
26 | * The end of all this would be to remove this file. |
---|
27 | */ |
---|
28 | |
---|
29 | inline unsigned int Swap32( |
---|
30 | uint32_t ulValue |
---|
31 | ) |
---|
32 | { |
---|
33 | uint32_t ulSwapped; |
---|
34 | |
---|
35 | asm volatile( |
---|
36 | "rlwimi %0,%1,8,24,31;" |
---|
37 | "rlwimi %0,%1,24,16,23;" |
---|
38 | "rlwimi %0,%1,8,8,15;" |
---|
39 | "rlwimi %0,%1,24,0,7;" : |
---|
40 | |
---|
41 | "=&r" ((ulSwapped)) : |
---|
42 | "r" ((ulValue)) |
---|
43 | ); |
---|
44 | |
---|
45 | return( ulSwapped ); |
---|
46 | } |
---|
47 | |
---|
48 | inline unsigned int Swap16( |
---|
49 | uint16_t usValue |
---|
50 | ) |
---|
51 | { |
---|
52 | uint16_t usSwapped; |
---|
53 | |
---|
54 | asm volatile( |
---|
55 | "rlwimi %0,%1,24,24,31;" |
---|
56 | "rlwimi %0,%1,8,16,23;" : |
---|
57 | |
---|
58 | "=&r" ((usSwapped)) : |
---|
59 | "r" ((usValue)) |
---|
60 | ); |
---|
61 | |
---|
62 | return( usSwapped ); |
---|
63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.