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)
272 u_int num;
275 for (p = strings, num = 0; p < strings + len; p += strlen(p) + 1) {
278 num++;
281 return (num);
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)
308 strings[len - 1] = '\0';
310 /* Count the strings. */
311 *num = extract_strings(strings, /*dest*/NULL, len);
314 ret = malloc(*num * sizeof(char *) + len, M_XENSTORE, M_WAITOK);
315 memcpy(&ret[*num], strings, len);
316 free(strings, M_XENSTORE);
319 strings = (char *)&ret[*num];
320 (void)extract_strings(strings, /*dest*/ret, len);
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);
409 *len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(prod);
410 if ((XENSTORE_RING_SIZE - (prod - cons)) < *len)
411 *len = XENSTORE_RING_SIZE - (prod - cons);
431 *len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(cons);
432 if ((prod - cons) < *len)
433 *len = prod - cons;
465 cons = xen_store->req_cons;
466 prod = xen_store->req_prod;
467 if ((prod - cons) == XENSTORE_RING_SIZE) {
492 xen_store->req_cons = xen_store->req_prod = 0;
496 dst = xs_get_output_chunk(cons, prod, xen_store->req, &avail);
502 len -= avail;
511 xen_store->req_prod += avail;
553 cons = xen_store->rsp_cons;
554 prod = xen_store->rsp_prod;
578 xen_store->rsp_cons = xen_store->rsp_prod = 0;
582 src = xs_get_input_chunk(cons, prod, xen_store->rsp, &avail);
594 len -= avail;
602 xen_store->rsp_cons += avail;
614 /*----------------------- Received Message Processing ------------------------*/
632 error = xs_read_store(&msg->hdr, sizeof(msg->hdr));
638 body = malloc(msg->hdr.len + 1, M_XENSTORE, M_WAITOK);
639 error = xs_read_store(body, msg->hdr.len);
645 body[msg->hdr.len] = '\0';
647 *type = msg->hdr.type;
648 if (msg->hdr.type == XS_WATCH_EVENT) {
649 msg->u.watch.vec = split(body, msg->hdr.len,
650 &msg->u.watch.vec_size);
653 msg->u.watch.handle = find_watch(
654 msg->u.watch.vec[XS_WATCH_TOKEN]);
656 if (msg->u.watch.handle != NULL &&
657 (!msg->u.watch.handle->max_pending ||
658 msg->u.watch.handle->pending <
659 msg->u.watch.handle->max_pending)) {
660 msg->u.watch.handle->pending++;
666 free(msg->u.watch.vec, M_XENSTORE);
671 msg->u.reply.body = body;
701 /*---------------- XenStore Message Request/Reply Processing -----------------*/
711 * \note Unknown error strings are converted to EINVAL.
757 *type = msg->hdr.type;
759 *len = msg->hdr.len;
760 body = msg->u.reply.body;
768 * Pass-thru interface for XenStore access by userland processes
790 if ((error = xs_write_store(msg, sizeof(*msg) + msg->len)) == 0)
791 error = xs_read_reply(&msg->type, &msg->len, result);
798 * Send a message with an optionally muti-part body to the XenStore service.
896 /*------------------------- XenStore Watch Support ---------------------------*/
985 msg->u.watch.handle->pending--;
996 if (msg->u.watch.handle->callback != NULL)
997 msg->u.watch.handle->callback(
998 msg->u.watch.handle,
999 (const char **)msg->u.watch.vec,
1000 msg->u.watch.vec_size);
1001 free(msg->u.watch.vec, M_XENSTORE);
1009 /*----------- XenStore Configuration, Initialization, and Control ------------*/
1021 if (xen_store->rsp_prod != xen_store->rsp_cons) {
1024 xen_store->rsp_cons, xen_store->rsp_prod);
1025 xen_store->rsp_cons = xen_store->rsp_prod;
1041 /*------------------ Private Device Attachment Functions --------------------*/
1097 /* Allow us to get device_t from softc and vice-versa. */
1150 xs.xenwatch_pid = p->p_pid;
1206 xs_watch(watch->node, token);
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)
1275 char *strings;
1281 (void **)&strings);
1286 *result = split(strings, len, num);
1470 t->id = strtoul(id_str, NULL, 0);
1580 watch->pending = 0;
1588 error = xs_watch(watch->node, token);
1620 error = xs_unwatch(watch->node, token);
1623 watch->node, error);
1628 if (msg->u.watch.handle != watch)
1631 free(msg->u.watch.vec, M_XENSTORE);
1636 /* Flush any currently-executing callback, unless we are it. :-) */
1637 if (curproc->p_pid != xs.xenwatch_pid) {