This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / asm-powerpc / systemsim.h
1 /*********************************************************
2  *
3  * Copyright (C) 2001, 2005 IBM
4  * 
5  * Filename     : systemsim.h
6  *
7  * Originator   : Patrick Bohrer and Charles Lefurgy
8  * Modified By  : Eric Van Hensbegren <ericvh@gmail.com>
9  *
10  * Purpose      : 
11  *
12  *   This file is compiled with programs that are run under the 
13  *   PowerPC Full System simulator.  For example, stand-alone programs 
14  *   or operating systems.  The programs call the callthru wrapper 
15  *   functions which use an illegal PowerPC instruction to signal the 
16  *   simulator to emulate special support.
17  *
18  *********************************************************/
19
20 #ifndef _SYSTEMSIM_CONFIG_H_
21 #define _SYSTEMSIM_CONFIG_H_
22
23 /* The functions callthru0 to callthru5 setup up the arguments for the
24  * simulator callthru and then use the callthru instruction.  Note that
25  * 0-5 specify the number of arguments after the command */
26
27 /* Note: Arguments are cast as void* to prevent casting by the
28    compiler.  This way, you can pass pointers, integers, etc. in
29    machine register and have the simulator interpret what the
30    register is supposed to be.  To help with typing errors when using
31    callthrus, we provide wrapper functions for each callthru.  The
32    wrappers cast all arguments to void*.  Unfortunately, this results
33    in a lot of compiler warnings that I do not know how to remove.  If
34    you modify this code, be aware that we are trying to pick a type
35    that is the size of the registers (32-bit or 64-bit) and that is
36    why are choosing to cast to a void* (it should be the size of a
37    machine register) */
38
39 static inline int callthru0(int command)
40 {
41         register int c asm("r3") = command;
42         asm volatile (".long 0x000eaeb0":"=r" (c):"r"(c));
43         return (c);
44 }
45 static inline int callthru1(int command, unsigned long arg1)
46 {
47         register int c asm("r3") = command;
48         register unsigned long a1 asm("r4") = arg1;
49         asm volatile (".long 0x000eaeb0":"=r" (c):"r"(c), "r"(a1));
50         return (c);
51 }
52 static inline int callthru2(int command, unsigned long arg1, unsigned long arg2)
53 {
54         register int c asm("r3") = command;
55         register unsigned long a1 asm("r4") = arg1;
56         register unsigned long a2 asm("r5") = arg2;
57         asm volatile (".long 0x000eaeb0":"=r" (c):"r"(c), "r"(a1), "r"(a2));
58         return (c);
59 }
60 static inline int callthru3(int command, unsigned long arg1, unsigned long arg2,
61                             unsigned long arg3)
62 {
63         register int c asm("r3") = command;
64         register unsigned long a1 asm("r4") = arg1;
65         register unsigned long a2 asm("r5") = arg2;
66         register unsigned long a3 asm("r6") = arg3;
67         asm volatile (".long 0x000eaeb0":"=r" (c):"r"(c), "r"(a1), "r"(a2),
68                       "r"(a3));
69         return (c);
70 }
71 static inline int callthru4(int command, unsigned long arg1, unsigned long arg2,
72                             unsigned long arg3, unsigned long arg4)
73 {
74         register int c asm("r3") = command;
75         register unsigned long a1 asm("r4") = arg1;
76         register unsigned long a2 asm("r5") = arg2;
77         register unsigned long a3 asm("r6") = arg3;
78         register unsigned long a4 asm("r7") = arg4;
79         asm volatile (".long 0x000eaeb0":"=r" (c):"r"(c), "r"(a1), "r"(a2),
80                       "r"(a3), "r"(a4));
81         return (c);
82 }
83 static inline int callthru5(int command, unsigned long arg1, unsigned long arg2,
84                             unsigned long arg3, unsigned long arg4,
85                             unsigned long arg5)
86 {
87         register int c asm("r3") = command;
88         register unsigned long a1 asm("r4") = arg1;
89         register unsigned long a2 asm("r5") = arg2;
90         register unsigned long a3 asm("r6") = arg3;
91         register unsigned long a4 asm("r7") = arg4;
92         register unsigned long a5 asm("r8") = arg5;
93         asm volatile (".long 0x000eaeb0":"=r" (c):"r"(c), "r"(a1), "r"(a2),
94                       "r"(a3), "r"(a4), "r"(a5));
95         return (c);
96 }
97 static inline int callthru6(int command, unsigned long arg1, unsigned long arg2,
98                             unsigned long arg3, unsigned long arg4,
99                             unsigned long arg5, unsigned long arg6)
100 {
101         register int c asm("r3") = command;
102         register unsigned long a1 asm("r4") = arg1;
103         register unsigned long a2 asm("r5") = arg2;
104         register unsigned long a3 asm("r6") = arg3;
105         register unsigned long a4 asm("r7") = arg4;
106         register unsigned long a5 asm("r8") = arg5;
107         register unsigned long a6 asm("r9") = arg6;
108         asm volatile (".long 0x000eaeb0":"=r" (c):"r"(c), "r"(a1), "r"(a2),
109                       "r"(a3), "r"(a4), "r"(a5), "r"(a6));
110         return (c);
111 }
112 static inline int callthru7(int command, unsigned long arg1, unsigned long arg2,
113                             unsigned long arg3, unsigned long arg4,
114                             unsigned long arg5, unsigned long arg6,
115                             unsigned long arg7)
116 {
117         register int c asm("r3") = command;
118         register unsigned long a1 asm("r4") = arg1;
119         register unsigned long a2 asm("r5") = arg2;
120         register unsigned long a3 asm("r6") = arg3;
121         register unsigned long a4 asm("r7") = arg4;
122         register unsigned long a5 asm("r8") = arg5;
123         register unsigned long a6 asm("r9") = arg6;
124         register unsigned long a7 asm("r10") = arg7;
125         asm volatile (".long 0x000eaeb0":"=r" (c):"r"(c), "r"(a1), "r"(a2),
126                       "r"(a3), "r"(a4), "r"(a5), "r"(a6), "r"(a7));
127         return (c);
128 }
129
130 #endif/* _SYSTEMSIM_CONFIG_H_ */