| 158 | } |
| 159 | |
| 160 | int |
| 161 | sdma_alloc(void) |
| 162 | { |
| 163 | struct sdma_channel *channel; |
| 164 | struct sdma_softc *sc; |
| 165 | int found; |
| 166 | int chn; |
| 167 | int i; |
| 168 | |
| 169 | sc = sdma_sc; |
| 170 | found = 0; |
| 171 | |
| 172 | /* Channel 0 can't be used */ |
| 173 | for (i = 1; i < SDMA_N_CHANNELS; i++) { |
| 174 | channel = &sc->channel[i]; |
| 175 | if (channel->in_use == 0) { |
| 176 | channel->in_use = 1; |
| 177 | found = 1; |
| 178 | break; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | if (!found) |
| 183 | return (-1); |
| 184 | |
| 185 | chn = i; |
| 186 | |
| 187 | /* Allocate area for buffer descriptors */ |
| 188 | channel->bd = (void *)kmem_alloc_contig(PAGE_SIZE, M_ZERO, 0, ~0, |
| 189 | PAGE_SIZE, 0, VM_MEMATTR_UNCACHEABLE); |
| 190 | |
| 191 | return (chn); |
| 192 | } |
| 193 | |
| 194 | int |
| 195 | sdma_free(int chn) |
no test coverage detected