Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/cam_periph.c
Show First 20 Lines • Show All 930 Lines • ▼ Show 20 Lines | cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo, | ||||
* XXX KDM should I use P_NOSWAP instead? | * XXX KDM should I use P_NOSWAP instead? | ||||
*/ | */ | ||||
PHOLD(curproc); | PHOLD(curproc); | ||||
for (i = 0; i < numbufs; i++) { | for (i = 0; i < numbufs; i++) { | ||||
/* | /* | ||||
* Get the buffer. | * Get the buffer. | ||||
*/ | */ | ||||
mapinfo->bp[i] = getpbuf(NULL); | mapinfo->bp[i] = uma_zalloc(pbuf_zone, M_WAITOK); | ||||
/* put our pointer in the data slot */ | /* put our pointer in the data slot */ | ||||
mapinfo->bp[i]->b_data = *data_ptrs[i]; | mapinfo->bp[i]->b_data = *data_ptrs[i]; | ||||
/* save the user's data address */ | /* save the user's data address */ | ||||
mapinfo->bp[i]->b_caller1 = *data_ptrs[i]; | mapinfo->bp[i]->b_caller1 = *data_ptrs[i]; | ||||
/* set the transfer length, we know it's < MAXPHYS */ | /* set the transfer length, we know it's < MAXPHYS */ | ||||
Show All 9 Lines | for (i = 0; i < numbufs; i++) { | ||||
* vmapbuf() can still fail due to a smaller file mapped | * vmapbuf() can still fail due to a smaller file mapped | ||||
* into a larger area of VM, or if userland races against | * into a larger area of VM, or if userland races against | ||||
* vmapbuf() after the useracc() check. | * vmapbuf() after the useracc() check. | ||||
*/ | */ | ||||
if (vmapbuf(mapinfo->bp[i], 1) < 0) { | if (vmapbuf(mapinfo->bp[i], 1) < 0) { | ||||
for (j = 0; j < i; ++j) { | for (j = 0; j < i; ++j) { | ||||
*data_ptrs[j] = mapinfo->bp[j]->b_caller1; | *data_ptrs[j] = mapinfo->bp[j]->b_caller1; | ||||
vunmapbuf(mapinfo->bp[j]); | vunmapbuf(mapinfo->bp[j]); | ||||
relpbuf(mapinfo->bp[j], NULL); | uma_zfree(pbuf_zone, mapinfo->bp[j]); | ||||
} | } | ||||
relpbuf(mapinfo->bp[i], NULL); | uma_zfree(pbuf_zone, mapinfo->bp[i]); | ||||
PRELE(curproc); | PRELE(curproc); | ||||
return(EACCES); | return(EACCES); | ||||
} | } | ||||
/* set our pointer to the new mapped area */ | /* set our pointer to the new mapped area */ | ||||
*data_ptrs[i] = mapinfo->bp[i]->b_data; | *data_ptrs[i] = mapinfo->bp[i]->b_data; | ||||
mapinfo->num_bufs_used++; | mapinfo->num_bufs_used++; | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | cam_periph_unmapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) | ||||
for (i = 0; i < numbufs; i++) { | for (i = 0; i < numbufs; i++) { | ||||
/* Set the user's pointer back to the original value */ | /* Set the user's pointer back to the original value */ | ||||
*data_ptrs[i] = mapinfo->bp[i]->b_caller1; | *data_ptrs[i] = mapinfo->bp[i]->b_caller1; | ||||
/* unmap the buffer */ | /* unmap the buffer */ | ||||
vunmapbuf(mapinfo->bp[i]); | vunmapbuf(mapinfo->bp[i]); | ||||
/* release the buffer */ | /* release the buffer */ | ||||
relpbuf(mapinfo->bp[i], NULL); | uma_zfree(pbuf_zone, mapinfo->bp[i]); | ||||
} | } | ||||
/* allow ourselves to be swapped once again */ | /* allow ourselves to be swapped once again */ | ||||
PRELE(curproc); | PRELE(curproc); | ||||
} | } | ||||
int | int | ||||
cam_periph_ioctl(struct cam_periph *periph, u_long cmd, caddr_t addr, | cam_periph_ioctl(struct cam_periph *periph, u_long cmd, caddr_t addr, | ||||
▲ Show 20 Lines • Show All 1,045 Lines • Show Last 20 Lines |