xref: /illumos-gate/usr/src/cmd/hal/hald/solaris/devinfo.c (revision 506aa7c6)
118c2aff7Sartem /***************************************************************************
218c2aff7Sartem  *
318c2aff7Sartem  * devinfo.c : main file for libdevinfo-based device enumeration
418c2aff7Sartem  *
5*506aa7c6SGarrett D'Amore  * Copyright 2013 Garrett D'Amore <garrett@damore.org>
63f7d54a6SGarrett D'Amore  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
718c2aff7Sartem  *
818c2aff7Sartem  * Licensed under the Academic Free License version 2.1
918c2aff7Sartem  *
1018c2aff7Sartem  **************************************************************************/
1118c2aff7Sartem 
1200687e57Sartem #ifdef HAVE_CONFIG_H
1300687e57Sartem #  include <config.h>
1400687e57Sartem #endif
1500687e57Sartem 
1618c2aff7Sartem #include <stdio.h>
1718c2aff7Sartem #include <string.h>
1818c2aff7Sartem #include <libdevinfo.h>
1918c2aff7Sartem 
2018c2aff7Sartem #include "../osspec.h"
2118c2aff7Sartem #include "../logger.h"
2218c2aff7Sartem #include "../hald.h"
2318c2aff7Sartem #include "../hald_dbus.h"
2418c2aff7Sartem #include "../device_info.h"
2518c2aff7Sartem #include "../util.h"
2618c2aff7Sartem #include "../hald_runner.h"
2718c2aff7Sartem #include "osspec_solaris.h"
2818c2aff7Sartem #include "hotplug.h"
2918c2aff7Sartem #include "devinfo.h"
3018c2aff7Sartem #include "devinfo_pci.h"
3118c2aff7Sartem #include "devinfo_storage.h"
3218c2aff7Sartem #include "devinfo_ieee1394.h"
3318c2aff7Sartem #include "devinfo_usb.h"
3418c2aff7Sartem #include "devinfo_misc.h"
357b840e52Sphitran #include "devinfo_acpi.h"
36a9da3307Snp #include "devinfo_cpu.h"
3718c2aff7Sartem 
3818c2aff7Sartem void devinfo_add_subtree(HalDevice *parent, di_node_t node, gboolean is_root);
3918c2aff7Sartem HalDevice *devinfo_add_node(HalDevice *parent, di_node_t node);
4018c2aff7Sartem 
4118c2aff7Sartem void
devinfo_add(HalDevice * parent,gchar * path)4218c2aff7Sartem devinfo_add(HalDevice *parent, gchar *path)
4318c2aff7Sartem {
4418c2aff7Sartem 	di_node_t	root;
4518c2aff7Sartem 
4618c2aff7Sartem 	if (strcmp (path, "/") == 0) {
4718c2aff7Sartem 		if ((root = di_init(path, DINFOCACHE)) == DI_NODE_NIL) {
4818c2aff7Sartem 			HAL_INFO (("di_init() failed %d", errno));
4918c2aff7Sartem 			return;
5018c2aff7Sartem 		}
5118c2aff7Sartem 	} else {
5218c2aff7Sartem 		if ((root = di_init(path, DINFOCPYALL)) == DI_NODE_NIL) {
5318c2aff7Sartem 			HAL_INFO (("di_init() failed %d", errno));
5418c2aff7Sartem 			return;
55