xref: /titanic_44/usr/src/cmd/hal/hald/solaris/devinfo_ieee1394.c (revision 18c2aff776a775d34a4c9893a4c72e0434d68e36)
1 /***************************************************************************
2  *
3  * devinfo_ieee1394.c : IEEE 1394/FireWire devices
4  *
5  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
6  * Use is subject to license terms.
7  *
8  * Licensed under the Academic Free License version 2.1
9  *
10  **************************************************************************/
11 
12 #include <stdio.h>
13 #include <string.h>
14 #include <libdevinfo.h>
15 #include <sys/types.h>
16 #include <sys/mkdev.h>
17 #include <sys/stat.h>
18 
19 #include "../osspec.h"
20 #include "../logger.h"
21 #include "../hald.h"
22 #include "../hald_dbus.h"
23 #include "../device_info.h"
24 #include "../util.h"
25 #include "../ids.h"
26 #include "hotplug.h"
27 #include "devinfo.h"
28 #include "devinfo_ieee1394.h"
29 
30 HalDevice *devinfo_ieee1394_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type);
31 static HalDevice *devinfo_scsa1394_add(HalDevice *d, di_node_t node, gchar *devfs_path);
32 
33 DevinfoDevHandler devinfo_ieee1394_handler = {
34         devinfo_ieee1394_add,
35 	NULL,
36 	NULL,
37 	NULL,
38 	NULL,
39         NULL
40 };
41 
42 HalDevice *
43 devinfo_ieee1394_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type)
44 {
45 	HalDevice *d = NULL;
46 	char	*compat;
47 	char	*driver_name;
48 
49 	/*
50 	 * we distinguish 1394 devices by compatible name
51 	 * starting with 'firewire'
52 	 */
53 	if ((di_compatible_names (node, &compat) < 1) ||
54 	    (strncmp (compat, "firewire", sizeof ("firewire") - 1) != 0)) {
55 		return (NULL);
56 	}
57 
58 	if ((driver_name = di_driver_name (node)) == NULL) {
59 		return (NULL);
60 	}
61 
62 	if (strcmp (driver_name, "scsa1394") == 0) {
63 		d = devinfo_scsa1394_add (parent, node, devfs_path);
64 	}
65 
66 	return (d);
67 }
68 
69 static HalDevice *
70 devinfo_scsa1394_add(HalDevice *parent, di_node_t node, gchar *devfs_path)
71 {
72 	HalDevice *d = NULL;
73 
74 	d = hal_device_new ();
75 
76 	devinfo_set_default_properties (d, parent, node, devfs_path);
77 	hal_device_property_set_string (d, "info.bus", "ieee1394");
78 	hal_device_property_set_string (d, "info.product", "FireWire SBP-2 device");
79 
80 	devinfo_add_enqueue (d, devfs_path, &devinfo_ieee1394_handler);
81 
82 	return (d);
83 }
84 
85