| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dvma.c,v 1.42 2013/09/06 17:43:19 tsutsui Exp $ */ | | 1 | /* $NetBSD: dvma.c,v 1.43 2013/11/07 02:37:56 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1996 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Gordon W. Ross and Jeremy Cooper. | | 8 | * by Gordon W. Ross and Jeremy Cooper. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -59,27 +59,27 @@ | | | @@ -59,27 +59,27 @@ |
59 | * a specially reserved section of the CPU's virtual address space, 16 | | 59 | * a specially reserved section of the CPU's virtual address space, 16 |
60 | * Megabytes in size. Whenever a DVMA buffer is allocated, the allocation | | 60 | * Megabytes in size. Whenever a DVMA buffer is allocated, the allocation |
61 | * code will enter in a mapping both in the MC68030 MMU page tables and the | | 61 | * code will enter in a mapping both in the MC68030 MMU page tables and the |
62 | * I/O mapper. | | 62 | * I/O mapper. |
63 | * | | 63 | * |
64 | * The address returned by the allocation routine is a virtual address that | | 64 | * The address returned by the allocation routine is a virtual address that |
65 | * the requesting driver must use to access the buffer. It is up to the | | 65 | * the requesting driver must use to access the buffer. It is up to the |
66 | * device driver to convert this virtual address into the appropriate slave | | 66 | * device driver to convert this virtual address into the appropriate slave |
67 | * address that its device should issue to access the buffer. (There will be | | 67 | * address that its device should issue to access the buffer. (There will be |
68 | * routines that assist the driver in doing so.) | | 68 | * routines that assist the driver in doing so.) |
69 | */ | | 69 | */ |
70 | | | 70 | |
71 | #include <sys/cdefs.h> | | 71 | #include <sys/cdefs.h> |
72 | __KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.42 2013/09/06 17:43:19 tsutsui Exp $"); | | 72 | __KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.43 2013/11/07 02:37:56 christos Exp $"); |
73 | | | 73 | |
74 | #include <sys/param.h> | | 74 | #include <sys/param.h> |
75 | #include <sys/systm.h> | | 75 | #include <sys/systm.h> |
76 | #include <sys/device.h> | | 76 | #include <sys/device.h> |
77 | #include <sys/proc.h> | | 77 | #include <sys/proc.h> |
78 | #include <sys/malloc.h> | | 78 | #include <sys/malloc.h> |
79 | #include <sys/extent.h> | | 79 | #include <sys/extent.h> |
80 | #include <sys/buf.h> | | 80 | #include <sys/buf.h> |
81 | #include <sys/vnode.h> | | 81 | #include <sys/vnode.h> |
82 | #include <sys/core.h> | | 82 | #include <sys/core.h> |
83 | #include <sys/exec.h> | | 83 | #include <sys/exec.h> |
84 | | | 84 | |
85 | #include <uvm/uvm_extern.h> | | 85 | #include <uvm/uvm_extern.h> |
| @@ -156,27 +156,27 @@ dvma_kvtopa(void *kva, int bustype) | | | @@ -156,27 +156,27 @@ dvma_kvtopa(void *kva, int bustype) |
156 | | | 156 | |
157 | /* | | 157 | /* |
158 | * Map a range [va, va+len] of wired virtual addresses in the given map | | 158 | * Map a range [va, va+len] of wired virtual addresses in the given map |
159 | * to a kernel address in DVMA space. | | 159 | * to a kernel address in DVMA space. |
160 | */ | | 160 | */ |
161 | void * | | 161 | void * |
162 | dvma_mapin(void *kmem_va, int len, int canwait) | | 162 | dvma_mapin(void *kmem_va, int len, int canwait) |
163 | { | | 163 | { |
164 | void *dvma_addr; | | 164 | void *dvma_addr; |
165 | vaddr_t kva, tva; | | 165 | vaddr_t kva, tva; |
166 | int npf, s, error; | | 166 | int npf, s, error; |
167 | paddr_t pa; | | 167 | paddr_t pa; |
168 | long off; | | 168 | long off; |
169 | bool rv; | | 169 | bool rv __debugused; |
170 | | | 170 | |
171 | kva = (vaddr_t)kmem_va; | | 171 | kva = (vaddr_t)kmem_va; |
172 | #ifdef DIAGNOSTIC | | 172 | #ifdef DIAGNOSTIC |
173 | /* | | 173 | /* |
174 | * Addresses below VM_MIN_KERNEL_ADDRESS are not part of the kernel | | 174 | * Addresses below VM_MIN_KERNEL_ADDRESS are not part of the kernel |
175 | * map and should not participate in DVMA. | | 175 | * map and should not participate in DVMA. |
176 | */ | | 176 | */ |
177 | if (kva < VM_MIN_KERNEL_ADDRESS) | | 177 | if (kva < VM_MIN_KERNEL_ADDRESS) |
178 | panic("dvma_mapin: bad kva"); | | 178 | panic("dvma_mapin: bad kva"); |
179 | #endif | | 179 | #endif |
180 | | | 180 | |
181 | /* | | 181 | /* |
182 | * Calculate the offset of the data buffer from a page boundary. | | 182 | * Calculate the offset of the data buffer from a page boundary. |
| @@ -294,27 +294,27 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bu | | | @@ -294,27 +294,27 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bu |
294 | { | | 294 | { |
295 | | | 295 | |
296 | panic("_bus_dmamap_load_raw(): not implemented yet."); | | 296 | panic("_bus_dmamap_load_raw(): not implemented yet."); |
297 | } | | 297 | } |
298 | | | 298 | |
299 | int | | 299 | int |
300 | _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, | | 300 | _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, |
301 | bus_size_t buflen, struct proc *p, int flags) | | 301 | bus_size_t buflen, struct proc *p, int flags) |
302 | { | | 302 | { |
303 | vaddr_t kva, dva; | | 303 | vaddr_t kva, dva; |
304 | vsize_t off, sgsize; | | 304 | vsize_t off, sgsize; |
305 | paddr_t pa; | | 305 | paddr_t pa; |
306 | pmap_t pmap; | | 306 | pmap_t pmap; |
307 | int error, rv, s; | | 307 | int error, rv __diagused, s; |
308 | | | 308 | |
309 | /* | | 309 | /* |
310 | * Make sure that on error condition we return "no valid mappings". | | 310 | * Make sure that on error condition we return "no valid mappings". |
311 | */ | | 311 | */ |
312 | map->dm_nsegs = 0; | | 312 | map->dm_nsegs = 0; |
313 | map->dm_mapsize = 0; | | 313 | map->dm_mapsize = 0; |
314 | | | 314 | |
315 | if (buflen > map->_dm_size) | | 315 | if (buflen > map->_dm_size) |
316 | return EINVAL; | | 316 | return EINVAL; |
317 | | | 317 | |
318 | kva = (vaddr_t)buf; | | 318 | kva = (vaddr_t)buf; |
319 | off = kva & PGOFSET; | | 319 | off = kva & PGOFSET; |
320 | sgsize = round_page(off + buflen); | | 320 | sgsize = round_page(off + buflen); |
| @@ -359,27 +359,27 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dm | | | @@ -359,27 +359,27 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dm |
359 | | | 359 | |
360 | map->dm_nsegs = 1; | | 360 | map->dm_nsegs = 1; |
361 | map->dm_mapsize = map->dm_segs[0].ds_len; | | 361 | map->dm_mapsize = map->dm_segs[0].ds_len; |
362 | | | 362 | |
363 | return 0; | | 363 | return 0; |
364 | } | | 364 | } |
365 | | | 365 | |
366 | void | | 366 | void |
367 | _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) | | 367 | _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) |
368 | { | | 368 | { |
369 | bus_dma_segment_t *segs; | | 369 | bus_dma_segment_t *segs; |
370 | vaddr_t dva; | | 370 | vaddr_t dva; |
371 | vsize_t sgsize; | | 371 | vsize_t sgsize; |
372 | int error, s; | | 372 | int error __diagused, s; |
373 | | | 373 | |
374 | #ifdef DIAGNOSTIC | | 374 | #ifdef DIAGNOSTIC |
375 | if (map->dm_nsegs != 1) | | 375 | if (map->dm_nsegs != 1) |
376 | panic("%s: invalid nsegs = %d", __func__, map->dm_nsegs); | | 376 | panic("%s: invalid nsegs = %d", __func__, map->dm_nsegs); |
377 | #endif | | 377 | #endif |
378 | | | 378 | |
379 | segs = map->dm_segs; | | 379 | segs = map->dm_segs; |
380 | dva = segs[0]._ds_va & ~PGOFSET; | | 380 | dva = segs[0]._ds_va & ~PGOFSET; |
381 | sgsize = segs[0]._ds_sgsize; | | 381 | sgsize = segs[0]._ds_sgsize; |
382 | | | 382 | |
383 | /* Unmap the DVMA addresses. */ | | 383 | /* Unmap the DVMA addresses. */ |
384 | iommu_remove((dva & IOMMU_VA_MASK), sgsize); | | 384 | iommu_remove((dva & IOMMU_VA_MASK), sgsize); |
385 | pmap_kremove(dva, sgsize); | | 385 | pmap_kremove(dva, sgsize); |