]> git.saurik.com Git - apple/xnu.git/blame - pexpert/pexpert/ppc/dbdma.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / pexpert / pexpert / ppc / dbdma.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
d7e50217 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
d7e50217
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
d7e50217
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * @OSF_COPYRIGHT@
27 */
28
29#ifndef _PEXPERT_PPC_DBDMA_H_
30#define _PEXPERT_PPC_DBDMA_H_
31
32#ifndef ASSEMBLER
33
34#define DBDMA_CMD_OUT_MORE 0
35#define DBDMA_CMD_OUT_LAST 1
36#define DBDMA_CMD_IN_MORE 2
37#define DBDMA_CMD_IN_LAST 3
38#define DBDMA_CMD_STORE_QUAD 4
39#define DBDMA_CMD_LOAD_QUAD 5
40#define DBDMA_CMD_NOP 6
41#define DBDMA_CMD_STOP 7
42
43/* Keys */
44
45#define DBDMA_KEY_STREAM0 0
46#define DBDMA_KEY_STREAM1 1
47#define DBDMA_KEY_STREAM2 2
48#define DBDMA_KEY_STREAM3 3
49
50/* value 4 is reserved */
51#define DBDMA_KEY_REGS 5
52#define DBDMA_KEY_SYSTEM 6
53#define DBDMA_KEY_DEVICE 7
54
55#define DBDMA_INT_NEVER 0
56#define DBDMA_INT_IF_TRUE 1
57#define DBDMA_INT_IF_FALSE 2
58#define DBDMA_INT_ALWAYS 3
59
60#define DBDMA_BRANCH_NEVER 0
61#define DBDMA_BRANCH_IF_TRUE 1
62#define DBDMA_BRANCH_IF_FALSE 2
63#define DBDMA_BRANCH_ALWAYS 3
64
65#define DBDMA_WAIT_NEVER 0
66#define DBDMA_WAIT_IF_TRUE 1
67#define DBDMA_WAIT_IF_FALSE 2
68#define DBDMA_WAIT_ALWAYS 3
69
70/* Control register values (in little endian) */
71
72#define DBDMA_STATUS_MASK 0x000000ff /* Status Mask */
73#define DBDMA_CNTRL_BRANCH 0x00000100
74 /* 0x200 reserved */
75#define DBDMA_CNTRL_ACTIVE 0x00000400
76#define DBDMA_CNTRL_DEAD 0x00000800
77#define DBDMA_CNTRL_WAKE 0x00001000
78#define DBDMA_CNTRL_FLUSH 0x00002000
79#define DBDMA_CNTRL_PAUSE 0x00004000
80#define DBDMA_CNTRL_RUN 0x00008000
81
82#define DBDMA_SET_CNTRL(x) ( ((x) | (x) << 16) )
83#define DBDMA_CLEAR_CNTRL(x) ( (x) << 16)
84
85#define POWERMAC_IO(a) (a)
86#define DBDMA_REGMAP(channel) \
87 (dbdma_regmap_t *)((v_u_char *) POWERMAC_IO(PCI_DMA_BASE_PHYS) \
88 + (channel << 8))
89
90
91/* powermac_dbdma_channels hold the physical channel numbers for
92 * each dbdma device
93 */
94
95
96/* This struct is layout in little endian format */
97
98struct dbdma_command {
99 unsigned long d_cmd_count;
100 unsigned long d_address;
101 unsigned long d_cmddep;
102 unsigned long d_status_resid;
103};
104
105typedef struct dbdma_command dbdma_command_t;
106
107#define DBDMA_BUILD(d, cmd, key, count, address, interrupt, wait, branch) {\
108 DBDMA_ST4_ENDIAN(&d->d_address, address); \
109 (d)->d_status_resid = 0; \
110 (d)->d_cmddep = 0; \
111 DBDMA_ST4_ENDIAN(&d->d_cmd_count, \
112 ((cmd) << 28) | ((key) << 24) |\
113 ((interrupt) << 20) |\
114 ((branch) << 18) | ((wait) << 16) | \
115 (count)); \
116 }
117
118static __inline__ void
119dbdma_st4_endian(volatile unsigned long *a, unsigned long x)
120{
121 __asm__ volatile
122 ("stwbrx %0,0,%1" : : "r" (x), "r" (a) : "memory");
123
124 return;
125}
126
127static __inline__ unsigned long
128dbdma_ld4_endian(volatile unsigned long *a)
129{
130 unsigned long swap;
131
132 __asm__ volatile
133 ("lwbrx %0,0,%1" : "=r" (swap) : "r" (a));
134
135 return swap;
136}
137
138#define DBDMA_LD4_ENDIAN(a) dbdma_ld4_endian(a)
139#define DBDMA_ST4_ENDIAN(a, x) dbdma_st4_endian(a, x)
140
141/*
142 * DBDMA Channel layout
143 *
144 * NOTE - This structure is in little-endian format.
145 */
146
147struct dbdma_regmap {
148 unsigned long d_control; /* Control Register */
149 unsigned long d_status; /* DBDMA Status Register */
150 unsigned long d_cmdptrhi; /* MSB of command pointer (not used yet) */
151 unsigned long d_cmdptrlo; /* LSB of command pointer */
152 unsigned long d_intselect; /* Interrupt Select */
153 unsigned long d_branch; /* Branch selection */
154 unsigned long d_wait; /* Wait selection */
155 unsigned long d_transmode; /* Transfer modes */
156 unsigned long d_dataptrhi; /* MSB of Data Pointer */
157 unsigned long d_dataptrlo; /* LSB of Data Pointer */
158 unsigned long d_reserved; /* Reserved for the moment */
159 unsigned long d_branchptrhi; /* MSB of Branch Pointer */
160 unsigned long d_branchptrlo; /* LSB of Branch Pointer */
161 /* The remaining fields are undefinied and unimplemented */
162};
163
164typedef volatile struct dbdma_regmap dbdma_regmap_t;
165
166/* DBDMA routines */
167
168void dbdma_start(dbdma_regmap_t *channel, dbdma_command_t *commands);
169void dbdma_stop(dbdma_regmap_t *channel);
170void dbdma_flush(dbdma_regmap_t *channel);
171void dbdma_reset(dbdma_regmap_t *channel);
172void dbdma_continue(dbdma_regmap_t *channel);
173void dbdma_pause(dbdma_regmap_t *channel);
174
175dbdma_command_t *dbdma_alloc(int); /* Allocate command structures */
176
177#endif /* ASSEMBLER */
178
179#endif /* _PEXPERT_PPC_DBDMA_H_ */