Copyright clean-up (part 1):
[AROS.git] / arch / ppc-all / prep / kernel / io.c
blobcea86dda2163bd3c8139af5efba052b36d408803
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/libcall.h>
7 #include <aros/asmcall.h>
9 #include <proto/exec.h>
10 #include <proto/kernel.h>
12 #include "kernel.h"
14 /*****************************************************************************
16 NAME */
18 AROS_LH1(APTR, BusToPhys,
20 /* SYNOPSIS */
21 AROS_LHA(APTR, busAddress, A0),
23 /* LOCATION */
24 APTR, KernelBase, 1, Kernel)
26 /* FUNCTION
27 This function translates Bus address (address that device sees) to
28 Physical address (address seen by CPU).
30 INPUTS
31 busAddress - Bus address as seen by device
33 RESULT
34 Physical address seen by CPU
36 *****************************************************************************/
38 AROS_LIBFUNC_INIT
40 return((APTR)((ULONG)busAddress+_BUS_BASE));
42 AROS_LIBFUNC_EXIT
48 /*****************************************************************************
50 NAME */
52 AROS_LH1(APTR, PhysToBus,
54 /* SYNOPSIS */
55 AROS_LHA(APTR, physAddress, A0),
57 /* LOCATION */
58 APTR, KernelBase, 2, Kernel)
60 /* FUNCTION
61 This function translates Physical address address (address seen by CPU)
62 to Bus address (address seen by device).
64 INPUTS
65 physAddress - Physical address as seen by CPU
67 RESULT
68 Bus address seen by device
70 *****************************************************************************/
72 AROS_LIBFUNC_INIT
74 return((APTR)((ULONG)physAddress+_BUS_BASE));
76 AROS_LIBFUNC_EXIT
80 /*****************************************************************************
82 IO access functions
84 These functions are the only allowable things used to communicate with IO
85 address space. Please note that theirs implementation is platform specific.
87 Also note, that allthough it might be possible to talk to hardware without
88 them, it doesn't have to be possible any time. It may happen, that
89 self-made IO access will end with program killed.
91 There is no description available for this functions, but there is no need
92 for any. Function names and parameters are self-explaining.
94 *****************************************************************************/
96 AROS_LH2(void, OutB,
97 AROS_LHA(UWORD, port, D0),
98 AROS_LHA(UBYTE, val, D1),
99 APTR, KernelBase, 3, Kernel)
101 AROS_LIBFUNC_INIT
103 asm volatile (
104 "stbx %0,0,%1 \n\t"
105 "sync \n\t"
107 : "r"(val), "r"(port + _IO_BASE));
109 AROS_LIBFUNC_EXIT
112 AROS_LH2(void, OutW,
113 AROS_LHA(UWORD, port, D0),
114 AROS_LHA(UWORD, val, D1),
115 APTR, KernelBase, 4, Kernel)
117 AROS_LIBFUNC_INIT
119 asm volatile (
120 "sthbrx %0,0,%1 \n\t"
121 "sync \n\t"
123 : "r"(val), "r"(port + _IO_BASE));
125 AROS_LIBFUNC_EXIT
128 AROS_LH2(void, OutL,
129 AROS_LHA(UWORD, port, D0),
130 AROS_LHA(ULONG, val, D1),
131 APTR, KernelBase, 5, Kernel)
133 AROS_LIBFUNC_INIT
135 asm volatile (
136 "stwbrx %0,0,%1 \n\t"
137 "sync \n\t"
139 : "r"(val), "r"(port + _IO_BASE));
141 AROS_LIBFUNC_EXIT
144 AROS_LH1(UBYTE, InB,
145 AROS_LHA(UWORD, port, D0),
146 APTR, KernelBase, 6, Kernel)
148 AROS_LIBFUNC_INIT
150 UBYTE ret;
152 asm volatile ("lbzx %0,0,%1\n\tisync\n\tnop"
153 :"=r"(ret)
154 :"r"(port + _IO_BASE));
156 return(ret);
158 AROS_LIBFUNC_EXIT
161 AROS_LH1(UWORD, InW,
162 AROS_LHA(UWORD, port, D0),
163 APTR, KernelBase, 7, Kernel)
165 AROS_LIBFUNC_INIT
167 UWORD ret;
169 asm volatile ("lhbrx %0,0,%1\n\tisync\n\tnop"
170 :"=r"(ret)
171 :"r"(port + _IO_BASE));
173 return(ret);
175 AROS_LIBFUNC_EXIT
178 AROS_LH1(ULONG, InL,
179 AROS_LHA(UWORD, port, D0),
180 APTR, KernelBase, 8, Kernel)
182 AROS_LIBFUNC_INIT
184 ULONG ret;
186 asm volatile ("lwbrx %0,0,%1\n\tisync\n\tnop"
187 :"=r"(ret)
188 :"r"(port + _IO_BASE));
190 return(ret);
192 AROS_LIBFUNC_EXIT