sw_main_cmn.c revision f6e214c7418f43af38bd8c3a557e3d0a1d311cfa
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Code shared by software-diagnosis and software-response modules.
* The fmd module linkage info for the two modules lives in swde_main.c
* (for software-diagnosis) and swrp_main.c (for software-response).
*/
/*
* Each subsidiary that is hosted is assigned a unique subsidiary id. These
* macros convert between the id of a subsidiary and the index used in keeping
* track of subsidiaries. Outside of this file these ids should remain
* opaque.
*/
static struct {
} sw_stats = {
{ "sw_recv_total", FMD_TYPE_UINT64,
"total events received" },
{ "sw_recv_match", FMD_TYPE_UINT64,
"events matching some subsidiary" },
{ "sw_recv_callback", FMD_TYPE_UINT64,
"callbacks to all subsidiaries" },
};
/*
* ========================== Event Receipt =================================
*
* matching subscription and callback for the first match from each.
* via their registered dispatch table, including things like list.repaired.
*/
void
{
struct sw_modspecific *msinfo;
int calls = 0;
int mod;
/*
* For each sub module that has a matching class pattern call the
* registered callback for that sub DE. Only one match per sub module
* is allowed (the first match in its table, others are not checked).
*/
break;
}
}
calls++;
}
}
if (calls)
}
/*
* ========================== Timers ========================================
*
* A subsidiary can install a timer; it must pass an additional argument
* identifying itself so that we can hand off to the appropriate
* swsub_timeout function in the fmdo_timeout entry point when the timer fires.
*/
{
struct sw_modspecific *msinfo;
const struct sw_subinfo **subinfo;
const struct sw_subinfo *sip;
/*
* Look for a slot. Module entry points are single-threaded
* in nature, but if someone installs a timer from a door
* service function we're contended.
*/
break;
}
}
if (chosen == -1)
return (timerid);
}
/*
* Look for a timer installed by a given subsidiary matching timerid.
*/
static int
{
int slot;
(who == -1 ||
return (slot);
}
return (-1);
}
void
{
struct sw_modspecific *msinfo;
const struct sw_subinfo **subinfo;
const struct sw_subinfo *sip;
int slot;
}
/*
* The fmdo_timeout entry point.
*/
void
{
struct sw_modspecific *msinfo;
const struct sw_subinfo **subinfo;
const struct sw_subinfo *sip;
int slot;
}
/*
* ========================== sw_subinfo access =============================
*/
enum sw_casetype
{
struct sw_modspecific *msinfo;
const struct sw_subinfo **subinfo;
const struct sw_subinfo *sip;
who);
return (sip->swsub_casetype);
}
/*
* Given a case type lookup the struct sw_subinfo for the subsidiary
* that opens cases of that type.
*/
static const struct sw_subinfo *
{
struct sw_modspecific *msinfo;
const struct sw_subinfo **subinfo;
const struct sw_subinfo *sip;
int i;
for (i = 0; i < SW_SUB_MAX; i++) {
return (sip);
}
return (NULL);
}
/*
* Find the case close function for the given case type; can be NULL.
*/
{
const struct sw_subinfo *sip;
"%d not found\n", type);
return (sip->swsub_case_close);
}
/*
* Find the case verify function for the given case type; can be NULL.
*/
{
const struct sw_subinfo *sip;
"%d not found\n", type);
return (sip->swsub_case_verify);
}
/*
* ========================== Initialization ================================
*
* The two modules - software-diagnosis and software-response - call
* sw_fmd_init from their _fmd_init entry points.
*/
static void
{
int i;
return; /* subsidiary failed init */
/* check that the nelem'th entry is the NULL termination */
"terminated\n", who);
/* now validate the entries; we allow NULL handlers */
for (i = 0; i < nelem - 1; i++) {
"%d has a NULL pattern or function\n", who, i);
}
}
int
{
struct sw_modspecific *msinfo;
int i;
return (0);
return (0);
}
for (i = 0; i < SW_TIMER_MAX; i++)
/*
* Initialize subsidiaries. Each must make any subscription
* requests it needs and return a pointer to a NULL-terminated
* callback dispatch table and an indication of the number of
* entries in that table including the NULL termination entry.
*/
for (i = 0; i < SW_SUB_MAX; i++) {
char dbgbuf[80];
int nelem = -1;
int initrslt;
break;
"subsidiary %d (id 0x%lx) '%s'",
switch (initrslt) {
case SW_SUB_INIT_SUCCESS:
"table 0x%p and nelem %d\n",
msinfo);
break;
dbgbuf);
msinfo);
break;
case SW_SUB_INIT_FAIL_ERROR:
"because of an error\n", dbgbuf);
msinfo);
break;
default:
break;
}
}
return (1);
}
void
{
const struct sw_subinfo **subinfo;
struct sw_modspecific *msinfo;
int i;
for (i = 0; i < SW_TIMER_MAX; i++) {
continue;
}
for (i = 0; i < msinfo->swms_dispcnt; i++) {
continue; /* swsub_init did not succeed */
}
SW_SUB_MAX * sizeof (struct sw_disp *));
}