Lines Matching refs:iobuf
63 BHND_NVRAM_IOPS_DEFN(iobuf) in BHND_NVRAM_IOPS_DEFN() argument
87 struct bhnd_nvram_iobuf *iobuf; in BHND_NVRAM_IOPS_DEFN() local
96 if (SIZE_MAX - sizeof(*iobuf) < capacity) { in BHND_NVRAM_IOPS_DEFN()
98 iosz = sizeof(*iobuf); in BHND_NVRAM_IOPS_DEFN()
101 iosz = sizeof(*iobuf) + capacity; in BHND_NVRAM_IOPS_DEFN()
105 iobuf = bhnd_nv_malloc(iosz); in BHND_NVRAM_IOPS_DEFN()
106 if (iobuf == NULL) in BHND_NVRAM_IOPS_DEFN()
109 iobuf->io.iops = &bhnd_nvram_iobuf_ops; in BHND_NVRAM_IOPS_DEFN()
110 iobuf->buf = NULL; in BHND_NVRAM_IOPS_DEFN()
111 iobuf->size = size; in BHND_NVRAM_IOPS_DEFN()
112 iobuf->capacity = capacity; in BHND_NVRAM_IOPS_DEFN()
117 iobuf->buf = &iobuf->data; in BHND_NVRAM_IOPS_DEFN()
119 iobuf->buf = bhnd_nv_malloc(iobuf->capacity); in BHND_NVRAM_IOPS_DEFN()
121 if (iobuf->buf == NULL) { in BHND_NVRAM_IOPS_DEFN()
122 bhnd_nv_free(iobuf); in BHND_NVRAM_IOPS_DEFN()
126 return (&iobuf->io); in BHND_NVRAM_IOPS_DEFN()
145 struct bhnd_nvram_iobuf *iobuf; in bhnd_nvram_iobuf_new() local
152 iobuf = (struct bhnd_nvram_iobuf *)io; in bhnd_nvram_iobuf_new()
153 memcpy(iobuf->buf, buffer, iobuf->size); in bhnd_nvram_iobuf_new()
198 struct bhnd_nvram_iobuf *iobuf; in bhnd_nvram_iobuf_copy_range() local
210 iobuf = (struct bhnd_nvram_iobuf *)io; in bhnd_nvram_iobuf_copy_range()
211 if ((error = bhnd_nvram_io_read(src, offset, iobuf->buf, size))) { in bhnd_nvram_iobuf_copy_range()
212 bhnd_nvram_io_free(&iobuf->io); in bhnd_nvram_iobuf_copy_range()
222 struct bhnd_nvram_iobuf *iobuf = (struct bhnd_nvram_iobuf *)io; in bhnd_nvram_iobuf_free() local
225 if (iobuf->buf != &iobuf->data) in bhnd_nvram_iobuf_free()
226 bhnd_nv_free(iobuf->buf); in bhnd_nvram_iobuf_free()
228 bhnd_nv_free(iobuf); in bhnd_nvram_iobuf_free()
234 struct bhnd_nvram_iobuf *iobuf = (struct bhnd_nvram_iobuf *)io; in bhnd_nvram_iobuf_getsize() local
235 return (iobuf->size); in bhnd_nvram_iobuf_getsize()
241 struct bhnd_nvram_iobuf *iobuf = (struct bhnd_nvram_iobuf *)io; in bhnd_nvram_iobuf_setsize() local
244 if (size > iobuf->capacity) in bhnd_nvram_iobuf_setsize()
247 iobuf->size = size; in bhnd_nvram_iobuf_setsize()
253 bhnd_nvram_iobuf_ptr(struct bhnd_nvram_iobuf *iobuf, size_t offset, void **ptr, in bhnd_nvram_iobuf_ptr() argument
259 if (offset > iobuf->size) in bhnd_nvram_iobuf_ptr()
262 avail = iobuf->size - offset; in bhnd_nvram_iobuf_ptr()
268 *ptr = ((uint8_t *)iobuf->buf) + offset; in bhnd_nvram_iobuf_ptr()
279 struct bhnd_nvram_iobuf *iobuf; in bhnd_nvram_iobuf_read_ptr() local
283 iobuf = (struct bhnd_nvram_iobuf *) io; in bhnd_nvram_iobuf_read_ptr()
286 error = bhnd_nvram_iobuf_ptr(iobuf, offset, &ioptr, nbytes, navail); in bhnd_nvram_iobuf_read_ptr()
299 struct bhnd_nvram_iobuf *iobuf; in bhnd_nvram_iobuf_write_ptr() local
301 iobuf = (struct bhnd_nvram_iobuf *) io; in bhnd_nvram_iobuf_write_ptr()
304 return (bhnd_nvram_iobuf_ptr(iobuf, offset, ptr, nbytes, navail)); in bhnd_nvram_iobuf_write_ptr()