Lines Matching +full:num +full:- +full:strings
4 * Low-level kernel interface to the XenStore.
52 #include <xen/xen-os.h>
85 * guest either via the xen_start_info structure for a fully para-
116 /*-------------------------- Private Data Structures ------------------------*/
218 * The HVM guest pseudo-physical frame number. This is Xen's mapping
240 * Xenstore is a user-space process that usually runs in Dom0,
254 /*-------------------------------- Global Data ------------------------------*/
257 /*------------------------- Private Utility Functions -----------------------*/
261 * strings in a buffer.
263 * \param strings A pointer to a contiguous buffer of NUL terminated strings.
264 * \param dest An array to store pointers to each string found in strings.
265 * \param len The length of the buffer pointed to by strings.
267 * \return A count of the number of strings found.
270 extract_strings(const char *strings, const char **dest, u_int len) in extract_strings() argument
272 u_int num; in extract_strings() local
275 for (p = strings, num = 0; p < strings + len; p += strlen(p) + 1) { in extract_strings()
278 num++; in extract_strings()
281 return (num); in extract_strings()
286 * strings into an array of pointers to strings.
292 * The storage addressed by strings is free'd prior to split returning.
294 * \param strings A pointer to a contiguous buffer of NUL terminated strings.
295 * \param len The length of the buffer pointed to by strings.
296 * \param num The number of strings found and returned in the strings
299 * \return An array of pointers to the strings found in the input buffer.
302 split(char *strings, u_int len, u_int *num) in split() argument
308 strings[len - 1] = '\0'; in split()
310 /* Count the strings. */ in split()
311 *num = extract_strings(strings, /*dest*/NULL, len); in split()
314 ret = malloc(*num * sizeof(char *) + len, M_XENSTORE, M_WAITOK); in split()
315 memcpy(&ret[*num], strings, len); in split()
316 free(strings, M_XENSTORE); in split()
319 strings = (char *)&ret[*num]; in split()
320 (void)extract_strings(strings, /*dest*/ret, len); in split()
325 /*------------------------- Public Utility Functions -------------------------*/
326 /*------- API comments for these methods can be found in xenstorevar.h -------*/
343 /*-------------------- Low Level Communication Management --------------------*/
390 return ((prod - cons) <= XENSTORE_RING_SIZE); in xs_check_indexes()
409 *len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(prod); in xs_get_output_chunk()
410 if ((XENSTORE_RING_SIZE - (prod - cons)) < *len) in xs_get_output_chunk()
411 *len = XENSTORE_RING_SIZE - (prod - cons); in xs_get_output_chunk()
431 *len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(cons); in xs_get_input_chunk()
432 if ((prod - cons) < *len) in xs_get_input_chunk()
433 *len = prod - cons; in xs_get_input_chunk()
465 cons = xen_store->req_cons; in xs_write_store()
466 prod = xen_store->req_prod; in xs_write_store()
467 if ((prod - cons) == XENSTORE_RING_SIZE) { in xs_write_store()
492 xen_store->req_cons = xen_store->req_prod = 0; in xs_write_store()
496 dst = xs_get_output_chunk(cons, prod, xen_store->req, &avail); in xs_write_store()
502 len -= avail; in xs_write_store()
511 xen_store->req_prod += avail; in xs_write_store()
553 cons = xen_store->rsp_cons; in xs_read_store()
554 prod = xen_store->rsp_prod; in xs_read_store()
578 xen_store->rsp_cons = xen_store->rsp_prod = 0; in xs_read_store()
582 src = xs_get_input_chunk(cons, prod, xen_store->rsp, &avail); in xs_read_store()
594 len -= avail; in xs_read_store()
602 xen_store->rsp_cons += avail; in xs_read_store()
614 /*----------------------- Received Message Processing ------------------------*/
632 error = xs_read_store(&msg->hdr, sizeof(msg->hdr)); in xs_process_msg()
638 body = malloc(msg->hdr.len + 1, M_XENSTORE, M_WAITOK); in xs_process_msg()
639 error = xs_read_store(body, msg->hdr.len); in xs_process_msg()
645 body[msg->hdr.len] = '\0'; in xs_process_msg()
647 *type = msg->hdr.type; in xs_process_msg()
648 if (msg->hdr.type == XS_WATCH_EVENT) { in xs_process_msg()
649 msg->u.watch.vec = split(body, msg->hdr.len, in xs_process_msg()
650 &msg->u.watch.vec_size); in xs_process_msg()
653 msg->u.watch.handle = find_watch( in xs_process_msg()
654 msg->u.watch.vec[XS_WATCH_TOKEN]); in xs_process_msg()
656 if (msg->u.watch.handle != NULL && in xs_process_msg()
657 (!msg->u.watch.handle->max_pending || in xs_process_msg()
658 msg->u.watch.handle->pending < in xs_process_msg()
659 msg->u.watch.handle->max_pending)) { in xs_process_msg()
660 msg->u.watch.handle->pending++; in xs_process_msg()
666 free(msg->u.watch.vec, M_XENSTORE); in xs_process_msg()
671 msg->u.reply.body = body; in xs_process_msg()
701 /*---------------- XenStore Message Request/Reply Processing -----------------*/
711 * \note Unknown error strings are converted to EINVAL.
757 *type = msg->hdr.type; in xs_read_reply()
759 *len = msg->hdr.len; in xs_read_reply()
760 body = msg->u.reply.body; in xs_read_reply()
768 * Pass-thru interface for XenStore access by userland processes
790 if ((error = xs_write_store(msg, sizeof(*msg) + msg->len)) == 0) in xs_dev_request_and_reply()
791 error = xs_read_reply(&msg->type, &msg->len, result); in xs_dev_request_and_reply()
798 * Send a message with an optionally muti-part body to the XenStore service.
896 /*------------------------- XenStore Watch Support ---------------------------*/
985 msg->u.watch.handle->pending--; in xenwatch_thread()
996 if (msg->u.watch.handle->callback != NULL) in xenwatch_thread()
997 msg->u.watch.handle->callback( in xenwatch_thread()
998 msg->u.watch.handle, in xenwatch_thread()
999 (const char **)msg->u.watch.vec, in xenwatch_thread()
1000 msg->u.watch.vec_size); in xenwatch_thread()
1001 free(msg->u.watch.vec, M_XENSTORE); in xenwatch_thread()
1009 /*----------- XenStore Configuration, Initialization, and Control ------------*/
1021 if (xen_store->rsp_prod != xen_store->rsp_cons) { in xs_init_comms()
1024 xen_store->rsp_cons, xen_store->rsp_prod); in xs_init_comms()
1025 xen_store->rsp_cons = xen_store->rsp_prod; in xs_init_comms()
1041 /*------------------ Private Device Attachment Functions --------------------*/
1097 /* Allow us to get device_t from softc and vice-versa. */ in xs_attach()
1150 xs.xenwatch_pid = p->p_pid; in xs_attach()
1206 xs_watch(watch->node, token); in xs_resume()
1215 /*-------------------- Private Device Attachment Data -----------------------*/
1240 /*------------------------------- Sysctl Data --------------------------------*/
1247 /*-------------------------------- Public API --------------------------------*/
1248 /*------- API comments for these methods can be found in xenstorevar.h -------*/
1272 u_int *num, const char ***result) in xs_directory() argument
1275 char *strings; in xs_directory() local
1281 (void **)&strings); in xs_directory()
1286 *result = split(strings, len, num); in xs_directory()
1470 t->id = strtoul(id_str, NULL, 0); in xs_transaction_start()
1580 watch->pending = 0; in xs_register_watch()
1588 error = xs_watch(watch->node, token); in xs_register_watch()
1620 error = xs_unwatch(watch->node, token); in xs_unregister_watch()
1623 watch->node, error); in xs_unregister_watch()
1628 if (msg->u.watch.handle != watch) in xs_unregister_watch()
1631 free(msg->u.watch.vec, M_XENSTORE); in xs_unregister_watch()
1636 /* Flush any currently-executing callback, unless we are it. :-) */ in xs_unregister_watch()
1637 if (curproc->p_pid != xs.xenwatch_pid) { in xs_unregister_watch()