]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/POWERMAC/dbdma.c
8d7101b2cebd6906eb912a4f99c95de020bf53a3
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
23 * @APPLE_LICENSE_HEADER_END@
30 #include <platforms.h>
32 #include <ppc/proc_reg.h> /* For isync */
33 #include <mach_debug.h>
34 #include <kern/assert.h>
35 #include <kern/cpu_number.h>
37 #include <mach/mach_types.h>
39 #include <pexpert/ppc/powermac.h>
40 #include <ppc/io_map_entries.h>
41 #include <pexpert/ppc/dbdma.h>
44 static int dbdma_alloc_index
= 0;
45 dbdma_command_t
*dbdma_alloc_commands
= NULL
;
48 dbdma_start(dbdma_regmap_t
*dmap
, dbdma_command_t
*commands
)
50 unsigned long addr
= kvtophys((vm_offset_t
) commands
);
53 panic("dbdma_start command structure not 16-byte aligned");
55 dmap
->d_intselect
= 0xff; /* Endian magic - clear out interrupts */
56 DBDMA_ST4_ENDIAN(&dmap
->d_control
,
57 DBDMA_CLEAR_CNTRL( (DBDMA_CNTRL_ACTIVE
|
65 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & DBDMA_CNTRL_ACTIVE
)
68 dmap
->d_cmdptrhi
= 0; eieio();/* 64-bit not yet */
69 DBDMA_ST4_ENDIAN(&dmap
->d_cmdptrlo
, addr
); eieio();
71 DBDMA_ST4_ENDIAN(&dmap
->d_control
, DBDMA_SET_CNTRL(DBDMA_CNTRL_RUN
));
77 dbdma_stop(dbdma_regmap_t
*dmap
)
79 DBDMA_ST4_ENDIAN(&dmap
->d_control
, DBDMA_CLEAR_CNTRL(DBDMA_CNTRL_RUN
) |
80 DBDMA_SET_CNTRL(DBDMA_CNTRL_FLUSH
)); eieio();
82 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & (DBDMA_CNTRL_ACTIVE
|DBDMA_CNTRL_FLUSH
))
87 dbdma_flush(dbdma_regmap_t
*dmap
)
89 DBDMA_ST4_ENDIAN(&dmap
->d_control
,DBDMA_SET_CNTRL(DBDMA_CNTRL_FLUSH
));
92 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & (DBDMA_CNTRL_FLUSH
))
97 dbdma_reset(dbdma_regmap_t
*dmap
)
99 DBDMA_ST4_ENDIAN(&dmap
->d_control
,
100 DBDMA_CLEAR_CNTRL( (DBDMA_CNTRL_ACTIVE
|
108 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & DBDMA_CNTRL_RUN
)
113 dbdma_continue(dbdma_regmap_t
*dmap
)
115 DBDMA_ST4_ENDIAN(&dmap
->d_control
, DBDMA_SET_CNTRL(DBDMA_CNTRL_RUN
|DBDMA_CNTRL_WAKE
) | DBDMA_CLEAR_CNTRL(DBDMA_CNTRL_PAUSE
|DBDMA_CNTRL_DEAD
));
120 dbdma_pause(dbdma_regmap_t
*dmap
)
122 DBDMA_ST4_ENDIAN(&dmap
->d_control
,DBDMA_SET_CNTRL(DBDMA_CNTRL_PAUSE
));
125 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & DBDMA_CNTRL_ACTIVE
)
130 dbdma_alloc(int count
)
132 dbdma_command_t
*dbdmap
;
135 * For now, we assume that dbdma_alloc() is called only when
136 * the system is bootstrapping, i.e. before the other CPUs
138 * If that's not the case, we need to protect the global
141 assert(cpu_number() == master_cpu
);
143 if (dbdma_alloc_index
== 0)
144 dbdma_alloc_commands
= (dbdma_command_t
*) io_map(0, PAGE_SIZE
);
145 if ((dbdma_alloc_index
+count
) >= PAGE_SIZE
/ sizeof(dbdma_command_t
))
146 panic("Too many dbdma command structures!");
148 dbdmap
= &dbdma_alloc_commands
[dbdma_alloc_index
];
149 dbdma_alloc_index
+= count
;