Lines Matching +full:string +full:- +full:array +full:- +full:property
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org>.
58 /* The 'name' property is considered mandatory. */
59 if ((OF_getprop_alloc(node, "name", (void **)&obd->obd_name)) == -1)
61 OF_getprop_alloc(node, "compatible", (void **)&obd->obd_compat);
62 OF_getprop_alloc(node, "device_type", (void **)&obd->obd_type);
63 OF_getprop_alloc(node, "model", (void **)&obd->obd_model);
64 OF_getprop_alloc(node, "status", (void **)&obd->obd_status);
65 obd->obd_node = node;
75 if (obd->obd_compat != NULL)
76 free(obd->obd_compat, M_OFWPROP);
77 if (obd->obd_model != NULL)
78 free(obd->obd_model, M_OFWPROP);
79 if (obd->obd_name != NULL)
80 free(obd->obd_name, M_OFWPROP);
81 if (obd->obd_type != NULL)
82 free(obd->obd_type, M_OFWPROP);
83 if (obd->obd_status != NULL)
84 free(obd->obd_status, M_OFWPROP);
129 return (obd->obd_compat);
140 return (obd->obd_model);
151 return (obd->obd_name);
161 return ((phandle_t)-1);
162 return (obd->obd_node);
173 return (obd->obd_type);
185 return (obd->obd_status);
236 /* Slide to the next sub-string. */
239 len -= l;
274 if ((node = ofw_bus_get_node(dev)) == -1)
308 for (; compat->ocd_str != NULL; ++compat) {
309 if (ofw_bus_is_compatible(dev, compat->ocd_str))
321 if ((node = ofw_bus_get_node(dev)) == -1)
333 if (OF_getencprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1)
335 ii->opi_addrc = addrc * sizeof(pcell_t);
337 ii->opi_imapsz = OF_getencprop_alloc(node, "interrupt-map",
338 (void **)&ii->opi_imap);
339 if (ii->opi_imapsz > 0) {
340 msksz = OF_getencprop_alloc(node, "interrupt-map-mask",
341 (void **)&ii->opi_imapmsk);
346 if (msksz != -1 && msksz != ii->opi_addrc + intrsz)
347 panic("ofw_bus_setup_iinfo: bad interrupt-map-mask "
348 "property!");
360 if (ii->opi_imapsz <= 0)
362 KASSERT(regsz >= ii->opi_addrc,
364 regsz, ii->opi_addrc));
365 if (node != -1) {
368 panic("ofw_bus_lookup_imap: cannot get reg property");
370 return (ofw_bus_search_intrmap(pintr, pintrsz, reg, ii->opi_addrc,
371 ii->opi_imap, ii->opi_imapsz, ii->opi_imapmsk, maskbuf, mintr,
376 * Map an interrupt using the firmware reg, interrupt-map and
377 * interrupt-map-mask properties.
378 * The interrupt property to be mapped must be of size intrsz, and pointed to
379 * by intr. The regs property of the node for which the mapping is done must
380 * be passed as regs. This property is an array of register specifications;
382 * physsz. Only the first element of the property is used.
384 * imapmsk is a pointer to the interrupt-map-mask property, which must have
425 * CHRP-derived OF bindings, including ePAPR-compliant FDTs,
429 "#address-cells", &paddrsz, sizeof(paddrsz)) == -1)
435 "#interrupt-cells", &pintrsz, sizeof(pintrsz)) == -1)
452 i -= tsz;
467 len = OF_getencprop_alloc_multi(node, "msi-map", sizeof(*map),
472 OF_getencprop(node, "msi-parent", msi_parent,
482 OF_getencprop(node, "msi-map-mask", &mask, sizeof(mask));
498 *msi_rid = masked_rid - rid_base + msi_base;
517 len = OF_getencprop_alloc_multi(node, "iommu-map", sizeof(*map),
524 OF_getencprop(node, "iommu-map-mask", &mask, sizeof(mask));
540 *iommu_rid = masked_rid - rid_base + iommu_base;
564 if (ret == -1)
569 nreg = (ret == -1) ? 0 : ret;
573 device_printf(dev, "Malformed reg property on <%s>\n",
588 /* Skip the dummy reg property of glue devices like ssm(4). */
591 phys, phys + size - 1, size);
613 rl, "assigned-addresses"));
625 if (OF_searchencprop(node, "interrupt-parent", &iparent,
626 sizeof(iparent)) == -1) {
629 if (OF_hasprop(iparent, "interrupt-controller"))
651 device_printf(dev, "No interrupt-parent found, "
657 "#interrupt-cells", &icells, sizeof(icells)) == -1) {
658 device_printf(dev, "Missing #interrupt-cells "
659 "property, assuming <1>\n");
663 device_printf(dev, "Invalid #interrupt-cells property "
669 nintr = OF_getencprop_alloc_multi(node, "interrupts-extended",
681 "#interrupt-cells", &icells, sizeof(icells)) == -1) {
682 device_printf(dev, "Missing #interrupt-cells "
683 "property\n");
688 device_printf(dev, "Invalid #interrupt-cells "
689 "property value <%d>\n", icells);
717 device_printf(dev, "No interrupt-parent found, "
723 "#interrupt-cells", &icells, sizeof(icells)) == -1) {
724 device_printf(dev, "Missing #interrupt-cells "
725 "property, assuming <1>\n");
729 device_printf(dev, "Invalid #interrupt-cells property "
735 nintr = OF_getencprop_alloc_multi(node, "interrupts-extended",
747 "#interrupt-cells", &icells, sizeof(icells)) == -1) {
748 device_printf(dev, "Missing #interrupt-cells "
749 "property\n");
754 device_printf(dev, "Invalid #interrupt-cells "
755 "property value <%d>\n", icells);
783 if (ret == -1)
803 * matching 'compatible' property.
834 if (node == -1)
858 * Parse property that contain list of xrefs and values
861 * node - consumers device node
862 * list_name - name of parsed list - "clocks"
863 * cells_name - name of size property - "#clock-cells"
864 * idx - the index of the requested list entry, or, if -1, an indication
867 * producer - handle of producer
868 * ncells - number of cells in result or the number of items in the list when
869 * idx == -1.
870 * cells - array of decoded cells
887 rv = (idx == -1) ? 0 : ENOENT;
891 cells_name, &pcells, sizeof(pcells)) == -1) {
892 printf("Missing %s property\n", cells_name);
898 printf("Invalid %s property value <%d>\n", cells_name,
916 if (idx == -1 && rv == 0)
922 * Parse property that contain list of xrefs and values
925 * node - consumers device node
926 * list_name - name of parsed list - "clocks"
927 * cells_name - name of size property - "#clock-cells"
928 * idx - the index of the requested list entry (>= 0)
930 * producer - handle of producer
931 * ncells - number of cells in result
932 * cells - array of decoded cells
948 * Parse property that contain list of xrefs and values
952 * node - consumers device node
953 * list_name - name of parsed list - "clocks"
954 * cells_name - name of size property - "#clock-cells"
956 * count - number of items in list
964 -1, NULL, count, NULL));
968 * Find index of string in string list property (case sensitive).
998 * Create zero terminated array of strings from string list property.
1005 const char **array;
1018 array = malloc((cnt + 1) * sizeof(char *) + nelems, M_OFWPROP,
1021 /* Get address of first string. */
1022 tptr = (char *)(array + cnt + 1);
1028 /* Fill string pointers. */
1031 array[cnt] = tptr;
1035 array[cnt] = NULL;
1036 *out_array = array;