144961713Sgirish /*
244961713Sgirish * CDDL HEADER START
344961713Sgirish *
444961713Sgirish * The contents of this file are subject to the terms of the
544961713Sgirish * Common Development and Distribution License (the "License").
644961713Sgirish * You may not use this file except in compliance with the License.
744961713Sgirish *
844961713Sgirish * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
944961713Sgirish * or http://www.opensolaris.org/os/licensing.
1044961713Sgirish * See the License for the specific language governing permissions
1144961713Sgirish * and limitations under the License.
1244961713Sgirish *
1344961713Sgirish * When distributing Covered Code, include this CDDL HEADER in each
1444961713Sgirish * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1544961713Sgirish * If applicable, add the following below this CDDL HEADER, with the
1644961713Sgirish * fields enclosed by brackets "[]" replaced with your own identifying
1744961713Sgirish * information: Portions Copyright [yyyy] [name of copyright owner]
1844961713Sgirish *
1944961713Sgirish * CDDL HEADER END
2044961713Sgirish */
2144961713Sgirish /*
22*087113e1Smb * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2344961713Sgirish * Use is subject to license terms.
2444961713Sgirish */
2544961713Sgirish
2644961713Sgirish /*
2744961713Sgirish * Sun4v Platform specific functions.
2844961713Sgirish *
2944961713Sgirish * called when :
3044961713Sgirish * machine_type == huron
3144961713Sgirish *
3244961713Sgirish */
3344961713Sgirish
3444961713Sgirish #include <stdio.h>
3544961713Sgirish #include <stdlib.h>
3644961713Sgirish #include <unistd.h>
3744961713Sgirish #include <kstat.h>
3844961713Sgirish #include <fcntl.h>
3944961713Sgirish #include <string.h>
4044961713Sgirish #include <assert.h>
4144961713Sgirish #include <libintl.h>
4244961713Sgirish #include <note.h>
4344961713Sgirish #include <sys/systeminfo.h>
4444961713Sgirish #include <sys/openpromio.h>
4544961713Sgirish #include <sys/sysmacros.h>
4644961713Sgirish #include <picl.h>
4744961713Sgirish #include "picldefs.h"
4844961713Sgirish #include <pdevinfo.h>
4944961713Sgirish #include <display.h>
5044961713Sgirish #include <display_sun4v.h>
5144961713Sgirish #include <libprtdiag.h>
5244961713Sgirish #include "huron.h"
5344961713Sgirish
5444961713Sgirish #if !defined(TEXT_DOMAIN)
5544961713Sgirish #define TEXT_DOMAIN "SYS_TEST"
5644961713Sgirish #endif
5744961713Sgirish
5844961713Sgirish static void
huron_get_bus_type(char * path,struct io_card * card)5944961713Sgirish huron_get_bus_type(char *path, struct io_card *card)
6044961713Sgirish {
6187c478a5Szx if (strcmp(path, HURON_NIU) == 0) {
6287c478a5Szx (void) strcpy(card->bus_type, "NIU");
6344961713Sgirish } else {
6444961713Sgirish (void) strcpy(card->bus_type, "PCIE");
6544961713Sgirish }
6644961713Sgirish }
6744961713Sgirish
6844961713Sgirish void
huron_get_slot_number(char * path,struct io_card * card)6944961713Sgirish huron_get_slot_number(char *path, struct io_card *card)
7044961713Sgirish {
7144961713Sgirish if (strcmp(path, HURON_N2_XAUI0) == 0) {
7244961713Sgirish (void) strcpy(card->slot_str, "0");
7344961713Sgirish card->slot = 0;
7444961713Sgirish } else if (strcmp(path, HURON_N2_XAUI1) == 0) {
7544961713Sgirish (void) strcpy(card->slot_str, "1");
7644961713Sgirish card->slot = 1;
77b423da26Szx } else if (strncmp(path, HURON_PCIE_SLOT0,
78*087113e1Smb strlen(HURON_PCIE_SLOT0)) == 0) {
79b423da26Szx (void) strcpy(card->slot_str, "0");
80b423da26Szx card->slot = 0;
8144961713Sgirish } else if (strncmp(path, HURON_PCIE_SLOT1,
82*087113e1Smb strlen(HURON_PCIE_SLOT1)) == 0) {
8344961713Sgirish (void) strcpy(card->slot_str, "1");
8444961713Sgirish card->slot = 1;
8544961713Sgirish } else if (strncmp(path, HURON_PCIE_SLOT2,
86*087113e1Smb strlen(HURON_PCIE_SLOT2)) == 0) {
8744961713Sgirish (void) strcpy(card->slot_str, "2");
8844961713Sgirish card->slot = 2;
8944961713Sgirish } else if (strncmp(path, HURON_PCIE_SLOT3,
90*087113e1Smb strlen(HURON_PCIE_SLOT3)) == 0) {
9144961713Sgirish (void) strcpy(card->slot_str, "3");
9244961713Sgirish card->slot = 3;
9344961713Sgirish } else if (strncmp(path, HURON_PCIE_SLOT4,
94*087113e1Smb strlen(HURON_PCIE_SLOT4)) == 0) {
9544961713Sgirish (void) strcpy(card->slot_str, "4");
9644961713Sgirish card->slot = 4;
9744961713Sgirish } else if (strncmp(path, HURON_PCIE_SLOT5,
98*087113e1Smb strlen(HURON_PCIE_SLOT5)) == 0) {
9944961713Sgirish (void) strcpy(card->slot_str, "5");
10044961713Sgirish card->slot = 5;
10144961713Sgirish } else {
10244961713Sgirish (void) strcpy(card->slot_str, MOTHERBOARD);
10344961713Sgirish card->slot = NO_SLOT;
10444961713Sgirish }
10544961713Sgirish }
10644961713Sgirish
10744961713Sgirish int
huron_get_network_instance(char * path)10844961713Sgirish huron_get_network_instance(char *path)
10944961713Sgirish {
11044961713Sgirish if (strcmp(path, HURON_NETWORK_0) == 0) {
11144961713Sgirish return (0);
11244961713Sgirish } else if (strcmp(path, HURON_NETWORK_1) == 0) {
11344961713Sgirish return (1);
11444961713Sgirish } else if (strcmp(path, HURON_NETWORK_2) == 0) {
11544961713Sgirish return (2);
11644961713Sgirish } else if (strcmp(path, HURON_NETWORK_3) == 0) {
11744961713Sgirish return (3);
11844961713Sgirish } else if (strcmp(path, HURON_N2_XAUI0) == 0) {
11944961713Sgirish return (0);
12044961713Sgirish } else if (strcmp(path, HURON_N2_XAUI1) == 0) {
12144961713Sgirish return (1);
12244961713Sgirish } else {
12344961713Sgirish return (-1);
12444961713Sgirish }
12544961713Sgirish }
12644961713Sgirish /*
12744961713Sgirish * add all io devices under pci in io list
12844961713Sgirish */
12944961713Sgirish /* ARGSUSED */
13044961713Sgirish int
huron_pci_callback(picl_nodehdl_t pcih,void * args)13144961713Sgirish huron_pci_callback(picl_nodehdl_t pcih, void *args)
13244961713Sgirish {
13344961713Sgirish int err = PICL_SUCCESS;
13444961713Sgirish picl_nodehdl_t nodeh;
13544961713Sgirish char path[MAXSTRLEN];
13644961713Sgirish char parent_path[MAXSTRLEN];
13744961713Sgirish char piclclass[PICL_CLASSNAMELEN_MAX];
13844961713Sgirish char name[MAXSTRLEN];
13944961713Sgirish char model[MAXSTRLEN];
14044961713Sgirish char *compatible;
14144961713Sgirish char binding_name[MAXSTRLEN];
14244961713Sgirish struct io_card pci_card;
14344961713Sgirish int32_t instance;
14444961713Sgirish
14544961713Sgirish err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, parent_path,
14644961713Sgirish sizeof (parent_path));
14744961713Sgirish if (err != PICL_SUCCESS) {
14844961713Sgirish return (err);
14944961713Sgirish }
15044961713Sgirish
15144961713Sgirish /* Walk through the children */
15244961713Sgirish err = picl_get_propval_by_name(pcih, PICL_PROP_CHILD, &nodeh,
15344961713Sgirish sizeof (picl_nodehdl_t));
15444961713Sgirish
15544961713Sgirish while (err == PICL_SUCCESS) {
15644961713Sgirish err = picl_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
15744961713Sgirish piclclass, sizeof (piclclass));
15844961713Sgirish if (err != PICL_SUCCESS)
15944961713Sgirish return (err);
16044961713Sgirish
16144961713Sgirish if (strcmp(piclclass, "pciex") == 0) {
16244961713Sgirish err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER,
16344961713Sgirish &nodeh, sizeof (picl_nodehdl_t));
16444961713Sgirish continue;
16544961713Sgirish }
16644961713Sgirish
16787c478a5Szx if (strcmp(piclclass, "sun4v") == 0) {
16844961713Sgirish err = picl_get_propval_by_name(nodeh, PICL_PROP_CHILD,
16944961713Sgirish &nodeh, sizeof (picl_nodehdl_t));
17044961713Sgirish continue;
17144961713Sgirish }
17244961713Sgirish
17344961713Sgirish err = picl_get_propval_by_name(nodeh, PICL_PROP_DEVFS_PATH,
17444961713Sgirish path, sizeof (path));
17544961713Sgirish if (err != PICL_SUCCESS) {
17644961713Sgirish return (err);
17744961713Sgirish }
17844961713Sgirish
17944961713Sgirish (void) strlcpy(pci_card.notes, path, sizeof (pci_card.notes));
18044961713Sgirish
18144961713Sgirish huron_get_bus_type(parent_path, &pci_card);
18244961713Sgirish
18344961713Sgirish err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME, &name,
18444961713Sgirish sizeof (name));
18544961713Sgirish if (err == PICL_PROPNOTFOUND)
18644961713Sgirish (void) strcpy(name, "");
18744961713Sgirish else if (err != PICL_SUCCESS)
18844961713Sgirish return (err);
18944961713Sgirish
19087c478a5Szx if (strcmp(parent_path, HURON_NIU) == 0)
19187c478a5Szx huron_get_slot_number(path, &pci_card);
19287c478a5Szx else
19387c478a5Szx huron_get_slot_number(parent_path, &pci_card);
19444961713Sgirish
19544961713Sgirish /* Figure NAC name */
19644961713Sgirish if ((strcmp(name, NETWORK) == 0) &&
19744961713Sgirish (strcmp(pci_card.slot_str, MOTHERBOARD) == 0)) {
19844961713Sgirish instance = huron_get_network_instance(path);
19944961713Sgirish (void) snprintf(pci_card.status,
20044961713Sgirish sizeof (pci_card.status), "%s/%s%d", MOTHERBOARD,
20144961713Sgirish "NET", instance);
20244961713Sgirish } else {
20344961713Sgirish if (pci_card.slot != NO_SLOT) {
20444961713Sgirish (void) snprintf(pci_card.status,
20544961713Sgirish sizeof (pci_card.status), "%s/%s%d",
20644961713Sgirish MOTHERBOARD, pci_card.bus_type,
20744961713Sgirish pci_card.slot);
20844961713Sgirish } else {
20944961713Sgirish (void) snprintf(pci_card.status,
21044961713Sgirish sizeof (pci_card.status), "%s/%s",
21144961713Sgirish MOTHERBOARD, pci_card.bus_type);
21244961713Sgirish }
21344961713Sgirish }
21444961713Sgirish
21544961713Sgirish /*
21644961713Sgirish * Get the name of this card. Iif binding_name is found,
21744961713Sgirish * name will be <nodename>-<binding_name>
21844961713Sgirish */
21944961713Sgirish
22044961713Sgirish err = picl_get_propval_by_name(nodeh, PICL_PROP_BINDING_NAME,
22144961713Sgirish &binding_name, sizeof (binding_name));
22244961713Sgirish if (err == PICL_PROPNOTFOUND) {
22344961713Sgirish /*
22444961713Sgirish * if compatible prop is found, name will be
22544961713Sgirish * <nodename>-<compatible>
22644961713Sgirish */
22744961713Sgirish err = huron_get_first_compatible_value(nodeh,
22844961713Sgirish &compatible);
22944961713Sgirish if (err == PICL_SUCCESS) {
23044961713Sgirish (void) strlcat(name, "-", MAXSTRLEN);
23144961713Sgirish (void) strlcat(name, compatible, MAXSTRLEN);
23244961713Sgirish free(compatible);
23344961713Sgirish } else if (err != PICL_PROPNOTFOUND) {
23444961713Sgirish return (err);
23544961713Sgirish }
23644961713Sgirish } else if (err != PICL_SUCCESS) {
23744961713Sgirish return (err);
23844961713Sgirish } else if (strcmp(name, binding_name) != 0) {
23944961713Sgirish (void) strlcat(name, "-", MAXSTRLEN);
24044961713Sgirish (void) strlcat(name, binding_name, MAXSTRLEN);
24144961713Sgirish }
24244961713Sgirish
24344961713Sgirish (void) strlcpy(pci_card.name, name, sizeof (pci_card.name));
24444961713Sgirish
24544961713Sgirish /* Get the model of this card */
24644961713Sgirish
24744961713Sgirish err = picl_get_propval_by_name(nodeh, OBP_PROP_MODEL,
24844961713Sgirish &model, sizeof (model));
24944961713Sgirish if (err == PICL_PROPNOTFOUND)
25044961713Sgirish (void) strcpy(model, "");
25144961713Sgirish else if (err != PICL_SUCCESS)
25244961713Sgirish return (err);
25344961713Sgirish (void) strlcpy(pci_card.model, model, sizeof (pci_card.model));
25444961713Sgirish
25544961713Sgirish /* Print NAC name */
25644961713Sgirish log_printf("%-11s", pci_card.status);
25744961713Sgirish /* Print IO Type */
25844961713Sgirish log_printf("%6s", pci_card.bus_type);
25944961713Sgirish /* Print Slot # */
26044961713Sgirish log_printf("%5s", pci_card.slot_str);
26144961713Sgirish /* Print Parent Path */
26244961713Sgirish log_printf("%46.45s", pci_card.notes);
26344961713Sgirish /* Printf Card Name */
26444961713Sgirish if (strlen(pci_card.name) > 24)
26544961713Sgirish log_printf("%25.24s+", pci_card.name);
26644961713Sgirish else
26744961713Sgirish log_printf("%26s", pci_card.name);
26844961713Sgirish /* Print Card Model */
26944961713Sgirish if (strlen(pci_card.model) > 10)
27044961713Sgirish log_printf("%10.9s+", pci_card.model);
27144961713Sgirish else
27244961713Sgirish log_printf("%10s", pci_card.model);
27344961713Sgirish log_printf("\n");
27444961713Sgirish
27544961713Sgirish err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER, &nodeh,
27644961713Sgirish sizeof (picl_nodehdl_t));
27744961713Sgirish
27844961713Sgirish }
27944961713Sgirish
28044961713Sgirish return (PICL_WALK_CONTINUE);
28144961713Sgirish }
28244961713Sgirish
28344961713Sgirish /*
28444961713Sgirish * local functions
28544961713Sgirish */
28644961713Sgirish /*
28744961713Sgirish * add all io devices under pci in io list
28844961713Sgirish */
28944961713Sgirish /* ARGSUSED */
29044961713Sgirish int
huron_hw_rev_callback(picl_nodehdl_t pcih,void * args)29144961713Sgirish huron_hw_rev_callback(picl_nodehdl_t pcih, void *args)
29244961713Sgirish {
29344961713Sgirish int err = PICL_SUCCESS;
29444961713Sgirish char path[MAXSTRLEN] = "";
29544961713Sgirish char device_path[MAXSTRLEN];
29644961713Sgirish char NAC[MAXSTRLEN];
29744961713Sgirish char *compatible;
29844961713Sgirish int32_t revision;
29944961713Sgirish int device_found = 0;
30044961713Sgirish
30144961713Sgirish err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, path,
30244961713Sgirish sizeof (path));
30344961713Sgirish if (err != PICL_SUCCESS) {
30444961713Sgirish return (err);
30544961713Sgirish }
30644961713Sgirish
30744961713Sgirish if ((strcmp(path, HURON_NETWORK_0) == 0) ||
30844961713Sgirish (strcmp(path, HURON_NETWORK_1) == 0)) {
30944961713Sgirish device_found = 1;
31044961713Sgirish (void) snprintf(NAC, sizeof (NAC), "%s/%s%d",
311*087113e1Smb MOTHERBOARD, OPHIR, 0);
31244961713Sgirish revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
31344961713Sgirish &err);
31444961713Sgirish }
31544961713Sgirish
31644961713Sgirish if ((strcmp(path, HURON_NETWORK_2) == 0) ||
31744961713Sgirish (strcmp(path, HURON_NETWORK_3) == 0)) {
31844961713Sgirish device_found = 1;
31944961713Sgirish (void) snprintf(NAC, sizeof (NAC), "%s/%s%d", MOTHERBOARD,
320*087113e1Smb OPHIR, 1);
32144961713Sgirish revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
32244961713Sgirish &err);
32344961713Sgirish }
32444961713Sgirish
32544961713Sgirish if (strcmp(path, HURON_SWITCH_A_PATH) == 0) {
32644961713Sgirish device_found = 1;
32744961713Sgirish (void) snprintf(NAC, sizeof (NAC), "%s/%s",
328*087113e1Smb MOTHERBOARD, HURON_SWITCH_A);
32944961713Sgirish revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
33044961713Sgirish &err);
33144961713Sgirish }
33244961713Sgirish
33344961713Sgirish if (strcmp(path, HURON_SWITCH_B_PATH) == 0) {
33444961713Sgirish device_found = 1;
33544961713Sgirish (void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
336*087113e1Smb HURON_SWITCH_B);
33744961713Sgirish revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
33844961713Sgirish &err);
33944961713Sgirish }
34044961713Sgirish
34144961713Sgirish if (strcmp(path, HURON_SWITCH_C_PATH) == 0) {
34244961713Sgirish device_found = 1;
34344961713Sgirish (void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
344*087113e1Smb HURON_SWITCH_C);
34544961713Sgirish revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
34644961713Sgirish &err);
34744961713Sgirish }
34844961713Sgirish
34944961713Sgirish if (strcmp(path, HURON_LSI_PATH) == 0) {
35044961713Sgirish device_found = 1;
35144961713Sgirish (void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
35244961713Sgirish SAS_SATA_HBA);
35344961713Sgirish revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
35444961713Sgirish &err);
35544961713Sgirish }
35644961713Sgirish if (device_found == 1) {
35744961713Sgirish (void) strcpy(device_path, path);
35844961713Sgirish err = huron_get_first_compatible_value(pcih, &compatible);
35944961713Sgirish
36044961713Sgirish /* Print NAC name */
36144961713Sgirish log_printf("%-20s", NAC);
36244961713Sgirish /* Print Device Path */
36344961713Sgirish if (strlen(device_path) > 45)
36444961713Sgirish log_printf("%45.44s+", device_path);
36544961713Sgirish else
36644961713Sgirish log_printf("%46s", device_path);
36744961713Sgirish /* Print Compatible # */
368*087113e1Smb if (err == PICL_SUCCESS) {
369*087113e1Smb log_printf("%31s", compatible);
370*087113e1Smb free(compatible);
371*087113e1Smb } else
372*087113e1Smb log_printf("%31s", " ");
37344961713Sgirish /* Print Revision */
37444961713Sgirish log_printf("%6d", revision);
37544961713Sgirish log_printf("\n");
37644961713Sgirish }
37744961713Sgirish
37844961713Sgirish return (PICL_WALK_CONTINUE);
37944961713Sgirish }
38044961713Sgirish
38144961713Sgirish /*
38244961713Sgirish * return the first compatible value
38344961713Sgirish */
38444961713Sgirish int
huron_get_first_compatible_value(picl_nodehdl_t nodeh,char ** outbuf)38544961713Sgirish huron_get_first_compatible_value(picl_nodehdl_t nodeh, char **outbuf)
38644961713Sgirish {
38744961713Sgirish int err;
38844961713Sgirish picl_prophdl_t proph;
38944961713Sgirish picl_propinfo_t pinfo;
39044961713Sgirish picl_prophdl_t tblh;
39144961713Sgirish picl_prophdl_t rowproph;
39244961713Sgirish char *pval;
39344961713Sgirish
39444961713Sgirish err = picl_get_propinfo_by_name(nodeh, OBP_PROP_COMPATIBLE,
39544961713Sgirish &pinfo, &proph);
39644961713Sgirish if (err != PICL_SUCCESS)
397*087113e1Smb return (err);
39844961713Sgirish
39944961713Sgirish if (pinfo.type == PICL_PTYPE_CHARSTRING) {
40044961713Sgirish pval = malloc(pinfo.size);
40144961713Sgirish if (pval == NULL)
40244961713Sgirish return (PICL_FAILURE);
40344961713Sgirish err = picl_get_propval(proph, pval, pinfo.size);
40444961713Sgirish if (err != PICL_SUCCESS) {
40544961713Sgirish free(pval);
40644961713Sgirish return (err);
40744961713Sgirish }
40844961713Sgirish *outbuf = pval;
40944961713Sgirish return (PICL_SUCCESS);
41044961713Sgirish }
41144961713Sgirish
41244961713Sgirish if (pinfo.type != PICL_PTYPE_TABLE)
41344961713Sgirish return (PICL_FAILURE);
41444961713Sgirish
41544961713Sgirish /* get first string from table */
41644961713Sgirish err = picl_get_propval(proph, &tblh, pinfo.size);
41744961713Sgirish if (err != PICL_SUCCESS)
41844961713Sgirish return (err);
41944961713Sgirish
42044961713Sgirish err = picl_get_next_by_row(tblh, &rowproph);
42144961713Sgirish if (err != PICL_SUCCESS)
42244961713Sgirish return (err);
42344961713Sgirish
42444961713Sgirish err = picl_get_propinfo(rowproph, &pinfo);
42544961713Sgirish if (err != PICL_SUCCESS)
426*087113e1Smb return (err);
42744961713Sgirish
42844961713Sgirish pval = malloc(pinfo.size);
42944961713Sgirish if (pval == NULL)
43044961713Sgirish return (PICL_FAILURE);
43144961713Sgirish
43244961713Sgirish err = picl_get_propval(rowproph, pval, pinfo.size);
43344961713Sgirish if (err != PICL_SUCCESS) {
43444961713Sgirish free(pval);
43544961713Sgirish return (err);
43644961713Sgirish }
43744961713Sgirish
43844961713Sgirish *outbuf = pval;
43944961713Sgirish return (PICL_SUCCESS);
44044961713Sgirish }
44144961713Sgirish
44244961713Sgirish int64_t
huron_get_int_propval(picl_nodehdl_t modh,char * prop_name,int * ret)44344961713Sgirish huron_get_int_propval(picl_nodehdl_t modh, char *prop_name, int *ret)
44444961713Sgirish {
44544961713Sgirish int err;
44644961713Sgirish picl_prophdl_t proph;
44744961713Sgirish picl_propinfo_t pinfo;
44844961713Sgirish int8_t int8v;
44944961713Sgirish int16_t int16v;
45044961713Sgirish int32_t int32v;
45144961713Sgirish int64_t int64v;
45244961713Sgirish
45344961713Sgirish err = picl_get_propinfo_by_name(modh, prop_name, &pinfo, &proph);
45444961713Sgirish if (err != PICL_SUCCESS) {
45544961713Sgirish *ret = err;
45644961713Sgirish return (0);
45744961713Sgirish }
45844961713Sgirish
45944961713Sgirish /*
46044961713Sgirish * If it is not an int, uint or byte array prop, return failure
46144961713Sgirish */
46244961713Sgirish if ((pinfo.type != PICL_PTYPE_INT) &&
463*087113e1Smb (pinfo.type != PICL_PTYPE_UNSIGNED_INT) &&
464*087113e1Smb (pinfo.type != PICL_PTYPE_BYTEARRAY)) {
46544961713Sgirish *ret = PICL_FAILURE;
46644961713Sgirish return (0);
46744961713Sgirish }
46844961713Sgirish
46944961713Sgirish switch (pinfo.size) {
47044961713Sgirish case sizeof (int8_t):
47144961713Sgirish err = picl_get_propval(proph, &int8v, sizeof (int8v));
47244961713Sgirish *ret = err;
47344961713Sgirish return (int8v);
47444961713Sgirish case sizeof (int16_t):
47544961713Sgirish err = picl_get_propval(proph, &int16v, sizeof (int16v));
47644961713Sgirish *ret = err;
47744961713Sgirish return (int16v);
47844961713Sgirish case sizeof (int32_t):
47944961713Sgirish err = picl_get_propval(proph, &int32v, sizeof (int32v));
48044961713Sgirish *ret = err;
48144961713Sgirish return (int32v);
48244961713Sgirish case sizeof (int64_t):
48344961713Sgirish err = picl_get_propval(proph, &int64v, sizeof (int64v));
48444961713Sgirish *ret = err;
48544961713Sgirish return (int64v);
48644961713Sgirish default: /* not supported size */
48744961713Sgirish *ret = PICL_FAILURE;
48844961713Sgirish return (0);
48944961713Sgirish }
49044961713Sgirish }
491