]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/POWERMAC/dbdma.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
27 #include <platforms.h>
29 #include <ppc/proc_reg.h> /* For isync */
30 #include <mach_debug.h>
31 #include <kern/assert.h>
32 #include <kern/cpu_number.h>
34 #include <mach/mach_types.h>
36 #include <pexpert/ppc/powermac.h>
37 #include <ppc/io_map_entries.h>
38 #include <pexpert/ppc/dbdma.h>
41 static int dbdma_alloc_index
= 0;
42 dbdma_command_t
*dbdma_alloc_commands
= NULL
;
45 dbdma_start(dbdma_regmap_t
*dmap
, dbdma_command_t
*commands
)
47 unsigned long addr
= kvtophys((vm_offset_t
) commands
);
50 panic("dbdma_start command structure not 16-byte aligned");
52 dmap
->d_intselect
= 0xff; /* Endian magic - clear out interrupts */
53 DBDMA_ST4_ENDIAN(&dmap
->d_control
,
54 DBDMA_CLEAR_CNTRL( (DBDMA_CNTRL_ACTIVE
|
62 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & DBDMA_CNTRL_ACTIVE
)
65 dmap
->d_cmdptrhi
= 0; eieio();/* 64-bit not yet */
66 DBDMA_ST4_ENDIAN(&dmap
->d_cmdptrlo
, addr
); eieio();
68 DBDMA_ST4_ENDIAN(&dmap
->d_control
, DBDMA_SET_CNTRL(DBDMA_CNTRL_RUN
));
74 dbdma_stop(dbdma_regmap_t
*dmap
)
76 DBDMA_ST4_ENDIAN(&dmap
->d_control
, DBDMA_CLEAR_CNTRL(DBDMA_CNTRL_RUN
) |
77 DBDMA_SET_CNTRL(DBDMA_CNTRL_FLUSH
)); eieio();
79 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & (DBDMA_CNTRL_ACTIVE
|DBDMA_CNTRL_FLUSH
))
84 dbdma_flush(dbdma_regmap_t
*dmap
)
86 DBDMA_ST4_ENDIAN(&dmap
->d_control
,DBDMA_SET_CNTRL(DBDMA_CNTRL_FLUSH
));
89 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & (DBDMA_CNTRL_FLUSH
))
94 dbdma_reset(dbdma_regmap_t
*dmap
)
96 DBDMA_ST4_ENDIAN(&dmap
->d_control
,
97 DBDMA_CLEAR_CNTRL( (DBDMA_CNTRL_ACTIVE
|
105 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & DBDMA_CNTRL_RUN
)
110 dbdma_continue(dbdma_regmap_t
*dmap
)
112 DBDMA_ST4_ENDIAN(&dmap
->d_control
, DBDMA_SET_CNTRL(DBDMA_CNTRL_RUN
|DBDMA_CNTRL_WAKE
) | DBDMA_CLEAR_CNTRL(DBDMA_CNTRL_PAUSE
|DBDMA_CNTRL_DEAD
));
117 dbdma_pause(dbdma_regmap_t
*dmap
)
119 DBDMA_ST4_ENDIAN(&dmap
->d_control
,DBDMA_SET_CNTRL(DBDMA_CNTRL_PAUSE
));
122 while (DBDMA_LD4_ENDIAN(&dmap
->d_status
) & DBDMA_CNTRL_ACTIVE
)
127 dbdma_alloc(int count
)
129 dbdma_command_t
*dbdmap
;
132 * For now, we assume that dbdma_alloc() is called only when
133 * the system is bootstrapping, i.e. before the other CPUs
135 * If that's not the case, we need to protect the global
138 assert(cpu_number() == master_cpu
);
140 if (dbdma_alloc_index
== 0)
141 dbdma_alloc_commands
= (dbdma_command_t
*) io_map(0, PAGE_SIZE
);
142 if ((dbdma_alloc_index
+count
) >= PAGE_SIZE
/ sizeof(dbdma_command_t
))
143 panic("Too many dbdma command structures!");
145 dbdmap
= &dbdma_alloc_commands
[dbdma_alloc_index
];
146 dbdma_alloc_index
+= count
;