dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / hal / hald / solaris / devinfo_pci.c
blobb9c670aa7c202e3340ae19a0c668eb559c43ca3b
1 /***************************************************************************
3 * devinfo_pci.c : PCI devices
5 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
6 * Use is subject to license terms.
8 * Licensed under the Academic Free License version 2.1
10 **************************************************************************/
12 #pragma ident "%Z%%M% %I% %E% SMI"
14 #ifdef HAVE_CONFIG_H
15 # include <config.h>
16 #endif
18 #include <stdio.h>
19 #include <string.h>
20 #include <libdevinfo.h>
22 #include "../osspec.h"
23 #include "../logger.h"
24 #include "../hald.h"
25 #include "../hald_dbus.h"
26 #include "../device_info.h"
27 #include "../util.h"
28 #include "../ids.h"
29 #include "devinfo_pci.h"
31 HalDevice *devinfo_pci_add (HalDevice *parent, di_node_t node, char *devfs_path, char *device_type);
33 DevinfoDevHandler devinfo_pci_handler = {
34 devinfo_pci_add,
35 NULL,
36 NULL,
37 NULL,
38 NULL,
39 NULL
42 HalDevice *devinfo_pci_add (HalDevice *parent, di_node_t node, char *devfs_path, char *device_type)
44 HalDevice *d;
45 char *s;
46 int *i;
47 int vid, pid, svid, spid;
49 if ((device_type == NULL) ||
50 ((strcmp (device_type, "pci") != 0) &&
51 (strcmp (device_type, "pci-ide") != 0))) {
52 if (parent == NULL) {
53 return (NULL);
54 } else {
55 s = (char *)hal_device_property_get_string (parent, "info.subsystem");
56 if ((s == NULL) || (strcmp (s, "pci") != 0)) {
57 return (NULL);
62 d = hal_device_new ();
63 devinfo_set_default_properties (d, parent, node, devfs_path);
65 hal_device_property_set_string (d, "info.subsystem", "pci");
67 vid = pid = svid = spid = 0;
68 if (di_prop_lookup_ints (DDI_DEV_T_ANY, node, "vendor-id", &i) > 0) {
69 vid = i[0];
71 if (di_prop_lookup_ints (DDI_DEV_T_ANY, node, "device-id", &i) > 0) {
72 pid = i[0];
74 if (di_prop_lookup_ints (DDI_DEV_T_ANY, node, "subsystem-vendor-id", &i) > 0) {
75 svid = i[0];
77 if (di_prop_lookup_ints (DDI_DEV_T_ANY, node, "subsystem-id", &i) > 0) {
78 spid = i[0];
80 hal_device_property_set_int (d, "pci.vendor_id", vid);
81 hal_device_property_set_int (d, "pci.product_id", pid);
82 hal_device_property_set_int (d, "pci.subsys_vendor_id", svid);
83 hal_device_property_set_int (d, "pci.subsys_product_id", spid);
86 char *vendor_name;
87 char *product_name;
88 char *subsys_vendor_name;
89 char *subsys_product_name;
91 ids_find_pci (hal_device_property_get_int (d, "pci.vendor_id"),
92 hal_device_property_get_int (d, "pci.product_id"),
93 hal_device_property_get_int (d, "pci.subsys_vendor_id"),
94 hal_device_property_get_int (d, "pci.subsys_product_id"),
95 &vendor_name, &product_name, &subsys_vendor_name,
96 &subsys_product_name);
98 if (vendor_name != NULL) {
99 hal_device_property_set_string (d, "pci.vendor", vendor_name);
100 hal_device_property_set_string (d, "info.vendor", vendor_name);
103 if (product_name != NULL) {
104 hal_device_property_set_string (d, "pci.product", product_name);
105 hal_device_property_set_string (d, "info.product", product_name);
108 if (subsys_vendor_name != NULL) {
109 hal_device_property_set_string (d, "pci.subsys_vendor",
110 subsys_vendor_name);
113 if (subsys_product_name != NULL) {
114 hal_device_property_set_string (d, "pci.subsys_product", subsys_product_name);
118 devinfo_add_enqueue (d, devfs_path, &devinfo_pci_handler);
120 return (d);