Esempio n. 1
0
/* Creates the FRU nodes for the DIMMs on a particular CPU Module */
static int
do_dimms_init(picl_nodehdl_t rooth, int slot, int module)
{
	picl_nodehdl_t		dimmsloth;
	picl_nodehdl_t		dimmmodh;
	picl_nodehdl_t		tmph;
	int			i, c, l, err;

	for (i = 0; i < DIMMS_PER_MOD; i++) {
		/* Create the node for the memory slot */
		err = ptree_create_node("dimm-slot", "location",
		    &dimmsloth);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_slot_prop(dimmsloth, i);
		if (err != PICL_SUCCESS)
			return (err);

		c = ((slot * DIMMS_PER_SLOT) +
		    (module * DIMMS_PER_MOD) + i) + CPU0_DIMM0;

		l = c - (DIMMS_PER_SLOT * slot);

		err = add_label_prop(dimmsloth, location_label[l]);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, dimmsloth);
		if (err != PICL_SUCCESS)
			return (err);

		/* If the memory module exists, create a node for it */
		if (ptree_get_node_by_path(platform_frupath[c], &tmph) ==
		    PICL_SUCCESS) {
			err = ptree_create_node("dimm-module", "fru",
			    &dimmmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(dimmmodh, tmph, SEEPROM_SOURCE);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_void_fda_prop(dimmmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = ptree_add_node(dimmsloth, dimmmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(tmph, dimmmodh, FRU_PARENT);
			if (err != PICL_SUCCESS)
				return (err);
		}
	}
	return (PICL_SUCCESS);
}
Esempio n. 2
0
/* Initializes the FRU nodes for the memory modules */
static int
do_mem_init(picl_nodehdl_t rooth)
{
	picl_nodehdl_t		memsloth;
	picl_nodehdl_t		memmodh;
	picl_nodehdl_t		tmph;
	int			i, err, slotnum;

	for (i = DIMM0; i <= DIMM7; i++) {
		/* Create the node for the memory slot */
		err = ptree_create_node("mem-slot", "location", &memsloth);
		if (err != PICL_SUCCESS)
			return (err);

		slotnum = i - DIMM0;
		err = add_slot_prop(memsloth, slotnum);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_label_prop(memsloth, location_label[i]);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, memsloth);
		if (err != PICL_SUCCESS)
			return (err);

		/* If the memory exists, create a node for it */
		if (ptree_get_node_by_path(platform_frupath[i], &tmph) ==
		    PICL_SUCCESS) {
			err = ptree_create_node("mem-module", "fru", &memmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(memmodh, tmph, SEEPROM_SOURCE);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_void_fda_prop(memmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = ptree_add_node(memsloth, memmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(tmph, memmodh, FRU_PARENT);
			if (err != PICL_SUCCESS)
				return (err);
		}
	}
	return (PICL_SUCCESS);
}
Esempio n. 3
0
/* Initializes the FRU nodes for the CPU modules */
static int
do_cpus_init(picl_nodehdl_t rooth)
{
	picl_nodehdl_t		cpusloth;
	picl_nodehdl_t		cpumodh;
	picl_nodehdl_t		tmph;
	int			i, err;

	for (i = CPU0; i <= CPU1; i++) {
		/* Create the node for the CPU slot */
		err = ptree_create_node("cpu-slot", "location", &cpusloth);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_slot_prop(cpusloth, i);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_label_prop(cpusloth, location_label[i]);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, cpusloth);
		if (err != PICL_SUCCESS)
			return (err);

		/* If the CPU module exists, create a node for it */
		if (ptree_get_node_by_path(platform_frupath[i], &tmph) ==
		    PICL_SUCCESS) {
			err = ptree_create_node("cpu-module", "fru", &cpumodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(cpumodh, tmph, SEEPROM_SOURCE);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_void_fda_prop(cpumodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = ptree_add_node(cpusloth, cpumodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(tmph, cpumodh, FRU_PARENT);
			if (err != PICL_SUCCESS)
				return (err);
		}
	}
	return (PICL_SUCCESS);
}
Esempio n. 4
0
/* ------------------------------------------------------------------------- */
struct service_t*
service_create(struct plugin_t* plugin,
               const char* directory,
               const service_func exec,
               struct type_info_t* type_info)
{
    struct service_t* service;
    struct ptree_t* node;

    assert(plugin);
    assert(plugin->game);
    assert(directory);
    assert(exec);
    assert(type_info);

    /* allocate and initialise service object */
    if(!(service = (struct service_t*)MALLOC(sizeof(struct service_t))))
        OUT_OF_MEMORY("service_create()", NULL);
    memset(service, 0, sizeof(struct service_t));

    /* if anything fails, break */
    for(;;)
    {
        service->plugin = plugin;
        service->exec = exec;
        service->type_info = type_info;

        /* plugin object keeps track of all created services */
        if(!unordered_vector_push(&plugin->services, &service))
            break;

        /* copy directory */
        if(!(service->directory = malloc_string(directory)))
            break;

        /* create node in game's service directory - want to do this last
         * because ptree_remove_node uses malloc() */
        if(!(node = ptree_add_node(&plugin->game->services, directory, service)))
            break;

        /* NOTE: don't MALLOC() past this point ----------------------- */

        /* set the node's free function to service_free() to make deleting
         * nodes easier */
        ptree_set_free_func(node, (ptree_free_func)service_free);

        /* success! */
        return service;
    }

    /* something went wrong, clean up everything */

    /* remove from plugin's list of services */
    unordered_vector_erase_element(&plugin->services, &service);

    if(service->directory)
        free_string(service->directory);

    return NULL;
}
Esempio n. 5
0
/* Creates the FRU nodes for the CPU Module and associated DIMMs */
static int
do_cpu_module_init(picl_nodehdl_t rooth, int slot)
{
	picl_nodehdl_t		cpumodh;
	int			i, c, err;

	for (i = 0; i <= 1; i++) {
		err = ptree_create_node("cpu-module", "location",
		    &cpumodh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_slot_prop(cpumodh, i);
		if (err != PICL_SUCCESS)
			return (err);

		c = CPU0_DIMM0 + DIMMS_PER_SLOT + i;

		err = add_label_prop(cpumodh, location_label[c]);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, cpumodh);
		if (err != PICL_SUCCESS)
			return (err);

		/* Create the nodes for the memory (if they exist) */
		err = do_dimms_init(cpumodh, slot, i);
		if (err != PICL_SUCCESS)
			return (err);
	}
	return (PICL_SUCCESS);
}
Esempio n. 6
0
/* Initializes the FRU node for the RSC card */
static int
do_rscboard_init(picl_nodehdl_t rooth)
{
	picl_nodehdl_t		rscbrdh;
	picl_nodehdl_t		tmph;
	int			err;

	/* Create the node for the RSC board (if it exists) */
	if (ptree_get_node_by_path(platform_frupath[RSC], &tmph) ==
	    PICL_SUCCESS) {
		err = ptree_create_node("rsc-board", "fru", &rscbrdh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(rscbrdh, tmph, SEEPROM_SOURCE);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_void_fda_prop(rscbrdh);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, rscbrdh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(tmph, rscbrdh, FRU_PARENT);
		if (err != PICL_SUCCESS)
			return (err);
	}
	return (PICL_SUCCESS);
}
Esempio n. 7
0
/* Initializes the FRU nodes for the FCAL backplane */
static int
do_fcal_init(picl_nodehdl_t rooth)
{
	picl_nodehdl_t		fcalbrdh;
	picl_nodehdl_t		tmph;
	int			err;

	/* Create the node for the FCAL backplane (if it exists) */
	if (ptree_get_node_by_path(platform_frupath[FCAL], &tmph) ==
	    PICL_SUCCESS) {
		err = ptree_create_node("fcal-backplane", "fru", &fcalbrdh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(fcalbrdh, tmph, SEEPROM_SOURCE);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_void_fda_prop(fcalbrdh);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, fcalbrdh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(tmph, fcalbrdh, FRU_PARENT);
		if (err != PICL_SUCCESS)
			return (err);
	}
	return (PICL_SUCCESS);
}
Esempio n. 8
0
/* Initialize the FRU node for the system board */
static int
do_sysboard_init(picl_nodehdl_t rooth, picl_nodehdl_t *childh)
{
	picl_nodehdl_t		tmph;
	int			err;

	/* Create the node for the system board */
	if (ptree_get_node_by_path(platform_frupath[SYSBRD], &tmph) ==
	    PICL_SUCCESS) {
		err = ptree_create_node("system-board", "fru", childh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(*childh, tmph, SEEPROM_SOURCE);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_void_fda_prop(*childh);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, *childh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(tmph, *childh, FRU_PARENT);
		if (err != PICL_SUCCESS)
			return (err);

	}
	return (PICL_SUCCESS);
}
Esempio n. 9
0
/* ------------------------------------------------------------------------- */
struct event_t*
event_create(struct plugin_t* plugin,
             const char* directory,
             struct type_info_t* type_info)
{
    struct ptree_t* node;
    struct event_t* event;

    assert(plugin);
    assert(plugin->game);
    assert(directory);

    /* allocate and initialise event object */
    if(!(event = (struct event_t*)MALLOC(sizeof(struct event_t))))
        OUT_OF_MEMORY("event_create()", NULL);
    memset(event, 0, sizeof(struct event_t));

    for(;;)
    {
        event->plugin = plugin;
        event->type_info = type_info;
        unordered_vector_init_vector(&event->listeners, sizeof(struct event_listener_t));

        /* copy directory */
        if(!(event->directory = malloc_string(directory)))
            break;

        /* plugin object keeps track of all created events */
        if(!unordered_vector_push(&plugin->events, &event))
            break;

        /* create node in game's event directory and add event - do this last
         * because ptree_remove_node() uses malloc() */
        if(!(node = ptree_add_node(&plugin->game->events, directory, event)))
            break;

        /* NOTE: don't MALLOC() past this point ----------------------- */

        /* set the node's free function to event_free() to make deleting
         * nodes easier */
        ptree_set_free_func(node, (ptree_free_func)event_free);

        /* success! */
        return event;
    }

    /* something went wrong, clean up */
    if(event->directory)
        free_string(event->directory);

    return NULL;
}
Esempio n. 10
0
/* Hotplug routine used to add a new CPU Mem Module (with associated DIMMs) */
static int
add_cpu_module(int slotnum)
{
	picl_nodehdl_t		cpumemsloth;
	picl_nodehdl_t		cpumemmodh;
	picl_nodehdl_t		tmph;
	int			i, err;

	/* Find the node for the given CPU Memory module slot */
	if (ptree_get_node_by_path(frutree_cpu_module[slotnum],
	    &cpumemsloth) == PICL_SUCCESS) {

		i = slotnum + CPUMOD0;

		/* Make sure it's in /platform and create the frutree nodes */
		if (ptree_get_node_by_path(platform_frupath[i], &tmph) ==
		    PICL_SUCCESS) {
			err = ptree_create_node("cpu-mem-module", "fru",
			    &cpumemmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(cpumemmodh, tmph, SEEPROM_SOURCE);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_void_fda_prop(cpumemmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = ptree_add_node(cpumemsloth, cpumemmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(tmph, cpumemmodh, FRU_PARENT);
			if (err != PICL_SUCCESS)
				return (err);
		}

		err = do_cpu_module_init(cpumemmodh, slotnum);
		if (err != PICL_SUCCESS)
			return (err);
	}
	return (PICL_SUCCESS);
}
Esempio n. 11
0
/* Hotplug routine used to add a new power supply */
static int
add_power_supply(int slotnum)
{
	picl_nodehdl_t		powersloth;
	picl_nodehdl_t		powermodh;
	picl_nodehdl_t		tmph;
	int			i, err;

	/* Find the node for the given power supply slot */
	if (ptree_get_node_by_path(frutree_power_supply[slotnum],
	    &powersloth) == PICL_SUCCESS) {

		i = slotnum + PS0;

		/* Make sure it's in /platform and create the frutree node */
		if (ptree_get_node_by_path(platform_frupath[i], &tmph) ==
		    PICL_SUCCESS) {
			err = ptree_create_node("power-supply", "fru",
			    &powermodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(powermodh, tmph, SEEPROM_SOURCE);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_void_fda_prop(powermodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = ptree_add_node(powersloth, powermodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(tmph, powermodh, FRU_PARENT);
			if (err != PICL_SUCCESS)
				return (err);

			/* Post picl-fru-added event */
			post_frudr_event(PICL_FRU_ADDED, NULL, powermodh);
		}
	}
	return (PICL_SUCCESS);
}
Esempio n. 12
0
/* Initializes the FRU nodes for the motherboard and CPU Memory modules */
static int
do_motherboard_init(picl_nodehdl_t rooth)
{
	picl_nodehdl_t		sysboardh;
	picl_nodehdl_t		cpumemsloth;
	picl_nodehdl_t		cpumemmodh;
	picl_nodehdl_t		tmph;
	int			i, err, slotnum;

	/* Create the node for the system board (if it exists) */
	if (ptree_get_node_by_path(platform_frupath[SYSBRD], &tmph) ==
	    PICL_SUCCESS) {
		err = ptree_create_node("system-board", "fru",
		    &sysboardh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(sysboardh, tmph, SEEPROM_SOURCE);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_void_fda_prop(sysboardh);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, sysboardh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(tmph, sysboardh, FRU_PARENT);
		if (err != PICL_SUCCESS)
			return (err);

		for (i = CPUMOD0; i <= CPUMOD3; i++) {
			/* Create the node for the CPU Memory slot */
			err = ptree_create_node("cpu-mem-slot", "location",
			    &cpumemsloth);
			if (err != PICL_SUCCESS)
				return (err);

			slotnum = i - CPUMOD0;
			err = add_slot_prop(cpumemsloth, slotnum);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_label_prop(cpumemsloth, location_label[i]);
			if (err != PICL_SUCCESS)
				return (err);

			err = ptree_add_node(sysboardh, cpumemsloth);
			if (err != PICL_SUCCESS)
				return (err);

			/* If CPU Mem module exists, create a node for it */
			if (ptree_get_node_by_path(platform_frupath[i],
			    &tmph) == PICL_SUCCESS) {
				err = ptree_create_node("cpu-mem-module",
				    "fru", &cpumemmodh);
				if (err != PICL_SUCCESS)
					return (err);

				err = add_ref_prop(cpumemmodh, tmph,
				    SEEPROM_SOURCE);
				if (err != PICL_SUCCESS)
					return (err);

				err = add_void_fda_prop(cpumemmodh);
				if (err != PICL_SUCCESS)
					return (err);

				err = ptree_add_node(cpumemsloth, cpumemmodh);
				if (err != PICL_SUCCESS)
					return (err);

				err = add_ref_prop(tmph, cpumemmodh,
				    FRU_PARENT);
				if (err != PICL_SUCCESS)
					return (err);

				err = do_cpu_module_init(cpumemmodh, slotnum);
				if (err != PICL_SUCCESS)
					return (err);
			}
		}
	}
	return (PICL_SUCCESS);
}
Esempio n. 13
0
/* Initializes the FRU nodes for the PDB and the power supplies */
static int
do_power_supplies_init(picl_nodehdl_t rooth)
{
	picl_nodehdl_t		powerbrdh;
	picl_nodehdl_t		powersloth;
	picl_nodehdl_t		powermodh;
	picl_nodehdl_t		tmph;
	int			i, err, slotnum;

	/* Create the node for the PDB (if it exists) */
	if (ptree_get_node_by_path(platform_frupath[PDB], &tmph) ==
	    PICL_SUCCESS) {
		err = ptree_create_node("power-dist-board", "fru", &powerbrdh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(powerbrdh, tmph, SEEPROM_SOURCE);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_void_fda_prop(powerbrdh);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, powerbrdh);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(tmph, powerbrdh, FRU_PARENT);
		if (err != PICL_SUCCESS)
			return (err);

		for (i = PS0; i <= PS2; i++) {
			/* Create the node for the power supply slot */
			err = ptree_create_node("power-supply-slot",
			    "location", &powersloth);
			if (err != PICL_SUCCESS)
				return (err);

			slotnum = i - PS0;
			err = add_slot_prop(powersloth, slotnum);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_label_prop(powersloth, location_label[i]);
			if (err != PICL_SUCCESS)
				return (err);

			err = ptree_add_node(powerbrdh, powersloth);
			if (err != PICL_SUCCESS)
				return (err);

			/* If the PS exists, create a node for it */
			if (ptree_get_node_by_path(platform_frupath[i],
			    &tmph) == PICL_SUCCESS) {
				err = ptree_create_node("power-supply",
				    "fru", &powermodh);
				if (err != PICL_SUCCESS)
					return (err);

				err = add_ref_prop(powermodh, tmph,
				    SEEPROM_SOURCE);
				if (err != PICL_SUCCESS)
					return (err);

				err = add_void_fda_prop(powermodh);
				if (err != PICL_SUCCESS)
					return (err);

				err = ptree_add_node(powersloth, powermodh);
				if (err != PICL_SUCCESS)
					return (err);

				err = add_ref_prop(tmph, powermodh, FRU_PARENT);
				if (err != PICL_SUCCESS)
					return (err);
			}
		}
	}
	return (PICL_SUCCESS);
}
Esempio n. 14
0
/* Initializes the FRU nodes for the FCAL backplanes and GBIC card */
static int
do_fcal_init(picl_nodehdl_t rooth)
{
	picl_nodehdl_t		fcalsloth;
	picl_nodehdl_t		fcalmodh;
	picl_nodehdl_t		fcalgbich;
	picl_nodehdl_t		tmph;
	int			i, err, slotnum;

	for (i = FCAL0; i <= FCAL1; i++) {
		/* Create the node for the FCAL backplane slot */
		err = ptree_create_node("fcal-backplane-slot",
		    "location", &fcalsloth);
		if (err != PICL_SUCCESS)
			return (err);

		slotnum = i - FCAL0;
		err = add_slot_prop(fcalsloth, slotnum);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_label_prop(fcalsloth, location_label[i]);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, fcalsloth);
		if (err != PICL_SUCCESS)
			return (err);

		/* If the FCAL backplane exists, create a node for it */
		if (ptree_get_node_by_path(platform_frupath[i], &tmph) ==
		    PICL_SUCCESS) {
			err = ptree_create_node("fcal-backplane", "fru",
			    &fcalmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(fcalmodh, tmph, SEEPROM_SOURCE);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_void_fda_prop(fcalmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = ptree_add_node(fcalsloth, fcalmodh);
			if (err != PICL_SUCCESS)
				return (err);

			err = add_ref_prop(tmph, fcalmodh, FRU_PARENT);
			if (err != PICL_SUCCESS)
				return (err);
		}
	}

	/* If the FCAL GBIC board exists, create a node for it */
	if (ptree_get_node_by_path(platform_frupath[FCALGBIC], &tmph) ==
	    PICL_SUCCESS) {
		err = ptree_create_node("fcal-gbic-board", "fru",
		    &fcalgbich);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(fcalgbich, tmph, SEEPROM_SOURCE);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_void_fda_prop(fcalgbich);
		if (err != PICL_SUCCESS)
			return (err);

		err = ptree_add_node(rooth, fcalgbich);
		if (err != PICL_SUCCESS)
			return (err);

		err = add_ref_prop(tmph, fcalgbich, FRU_PARENT);
		if (err != PICL_SUCCESS)
			return (err);
	}
	return (PICL_SUCCESS);
}