1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte * CDDL HEADER START
3fcf3ce44SJohn Forte *
4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte *
8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte * and limitations under the License.
12fcf3ce44SJohn Forte *
13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte *
19fcf3ce44SJohn Forte * CDDL HEADER END
20fcf3ce44SJohn Forte */
21fcf3ce44SJohn Forte /*
22*ab43d050SJiri Svoboda * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
23fcf3ce44SJohn Forte */
24fcf3ce44SJohn Forte
25fcf3ce44SJohn Forte
26fcf3ce44SJohn Forte #include <sys/stat.h>
27fcf3ce44SJohn Forte #include <fcntl.h>
28fcf3ce44SJohn Forte #include <errno.h>
29fcf3ce44SJohn Forte
30fcf3ce44SJohn Forte #include "mp_utils.h"
31fcf3ce44SJohn Forte
32fcf3ce44SJohn Forte
33fcf3ce44SJohn Forte /*
34fcf3ce44SJohn Forte * Global Variables
35fcf3ce44SJohn Forte */
36fcf3ce44SJohn Forte
37fcf3ce44SJohn Forte MP_UINT32 g_pluginOwnerID = 0;
38fcf3ce44SJohn Forte int g_scsi_vhci_fd = -1;
39fcf3ce44SJohn Forte
40fcf3ce44SJohn Forte PROPERTY_CALLBACK_NODE g_Property_Callback_List[MP_OBJECT_TYPE_MAX + 1];
41fcf3ce44SJohn Forte VISIBILITY_CALLBACK_NODE g_Visibility_Callback_List[MP_OBJECT_TYPE_MAX + 1];
42fcf3ce44SJohn Forte
43fcf3ce44SJohn Forte sysevent_handle_t *g_SysEventHandle = NULL;
44fcf3ce44SJohn Forte
45fcf3ce44SJohn Forte pthread_mutex_t g_visa_mutex = PTHREAD_MUTEX_INITIALIZER;
46fcf3ce44SJohn Forte pthread_mutex_t g_prop_mutex = PTHREAD_MUTEX_INITIALIZER;
47fcf3ce44SJohn Forte
48fcf3ce44SJohn Forte /*
49fcf3ce44SJohn Forte * Called by the common layer to request the plugin to initialize
50fcf3ce44SJohn Forte * itself.
51fcf3ce44SJohn Forte */
52fcf3ce44SJohn Forte
53fcf3ce44SJohn Forte MP_STATUS
Initialize(MP_UINT32 pluginOwnerID)54fcf3ce44SJohn Forte Initialize(MP_UINT32 pluginOwnerID)
55fcf3ce44SJohn Forte {
56fcf3ce44SJohn Forte log(LOG_INFO, "Initialize()", " - enter");
57fcf3ce44SJohn Forte
58fcf3ce44SJohn Forte
59fcf3ce44SJohn Forte (void) memset(&g_Property_Callback_List, 0,
60*ab43d050SJiri Svoboda sizeof (PROPERTY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1));
61fcf3ce44SJohn Forte
62fcf3ce44SJohn Forte (void) memset(&g_Visibility_Callback_List, 0,
63*ab43d050SJiri Svoboda sizeof (VISIBILITY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1));
64fcf3ce44SJohn Forte
65fcf3ce44SJohn Forte /* Attempt to open the driver that this plugin will make request of. */
66fcf3ce44SJohn Forte g_scsi_vhci_fd = open("/devices/scsi_vhci:devctl",
67fcf3ce44SJohn Forte O_NDELAY | O_RDONLY);
68fcf3ce44SJohn Forte
69fcf3ce44SJohn Forte if (g_scsi_vhci_fd < 0) {
70fcf3ce44SJohn Forte log(LOG_INFO, "Initialize()",
71fcf3ce44SJohn Forte " - failed to open driver. error is : %s",
72fcf3ce44SJohn Forte strerror(errno));
73fcf3ce44SJohn Forte log(LOG_INFO, "Initialize()", " - error exit");
74*ab43d050SJiri Svoboda return (MP_STATUS_FAILED);
75fcf3ce44SJohn Forte }
76fcf3ce44SJohn Forte
77fcf3ce44SJohn Forte g_pluginOwnerID = pluginOwnerID;
78fcf3ce44SJohn Forte
79fcf3ce44SJohn Forte log(LOG_INFO, "Initialize()", " - exit");
80fcf3ce44SJohn Forte
81*ab43d050SJiri Svoboda return (MP_STATUS_SUCCESS);
82fcf3ce44SJohn Forte }
83