/*
 * Create a dependency from one component entry to another
 */
int mca_base_component_repository_link(const char *src_type, 
                                       const char *src_name,
                                       const char *depend_type,
                                       const char *depend_name)
{
#if OPAL_WANT_LIBLTDL
  repository_item_t *src, *depend;

  /* Look up the two components */

  src = find_component(src_type, src_name);
  if (NULL == src) {
    return OPAL_ERR_BAD_PARAM;
  }
  depend = find_component(depend_type, depend_name);
  if (NULL == depend) {
    return OPAL_ERR_BAD_PARAM;
  }

  /* Link them */

  return link_items(src, depend);
#else
    return OPAL_ERR_NOT_SUPPORTED;
#endif
}
Example #2
0
	void MultiDef::add_body_tohull()
	{
	  short rx, ry;
	  for ( ry = minry; ry <= maxry; ++ry )
	  {
		for ( rx = minrx; rx <= maxrx; ++rx )
		{
		  const MULTI_ELEM* elem = find_component( rx, ry );
		  if ( elem != NULL )
		  {
			add_to_hull( elem );

			break;
		  }
		}
		for ( rx = maxrx; rx >= minrx; --rx )
		{
		  const MULTI_ELEM* elem = find_component( rx, ry );
		  if ( elem != NULL )
		  {
			add_to_hull( elem );

			break;
		  }
		}
	  }


	  for ( rx = minrx; rx <= maxrx; ++rx )
	  {
		for ( ry = minry; ry <= maxry; ++ry )
		{
		  const MULTI_ELEM* elem = find_component( rx, ry );
		  if ( elem != NULL )
		  {
			add_to_hull( elem );
			break;
		  }
		}
		for ( ry = maxry; ry >= minry; --ry )
		{
		  const MULTI_ELEM* elem = find_component( rx, ry );
		  if ( elem != NULL )
		  {
			add_to_hull( elem );
			break;
		  }
		}
	  }
	}
Example #3
0
	void MultiDef::add_to_hull( const MULTI_ELEM* elem )
	{
	  unsigned short k = getkey( elem->x, elem->y );

	  if ( !hull2.count( k ) )
	  {
		hull.push_back( elem );
		hull2.insert( k );
	  }


	  if ( type == BOAT )
	  {
		short int_rx = elem->x, int_ry = elem->y;
		if ( ( multiid & 1 ) == 0 ) // N/S hull, so squeeze X
		{
		  if ( elem->x == minrx )
			int_rx = minrx + 1;
		  else if ( elem->x == maxrx )
			int_rx = maxrx - 1;
		}
		else
		{
		  if ( elem->y == minry )
			int_ry = minry + 1;
		  else if ( elem->y > 0 )
			int_ry = maxry - 1;
		}
		elem = find_component( int_rx, int_ry );
		if ( elem )
		  add_to_internal_hull( elem );
	  }

	}
Example #4
0
gint
gnc_forall_gui_components (const char *component_class,
                           GNCComponentHandler handler,
                           gpointer iter_data)
{
    GList *list;
    GList *node;
    gint count = 0;

    if (!handler)
        return(0);

    /* so components can be destroyed during the forall */
    list = find_component_ids_by_class (component_class);

    for (node = list; node; node = node->next)
    {
        ComponentInfo *ci = find_component (GPOINTER_TO_INT (node->data));

        if (!ci)
            continue;

        if (handler (ci->component_class, ci->component_id, ci->user_data, iter_data))
            count++;
    }

    g_list_free (list);
    return(count);
}
Example #5
0
void create_ce_statistics (
    char *ce,
    char *c,
    char *file
    )
{
    file_stat *fs;
    char *fn;
    component_stat *cs;

    fn = clean_filename (file);
    cs = find_component (component);
    if (cs) {
	fs = find_filestat (cs, fn);
	if (fs == NULL) {
	    fs = malloc (sizeof (file_stat));
	    memset (fs, 0, sizeof (file_stat));
	    fs->name = f_strdup(fn);
	    if (cs->stat == NULL) {
		cs->stat = fs;
	    } else {
		fs->next = cs->stat;
		cs->stat = fs;
	    }
	}
    }
    sscanf (ce, "%f", &fs->ce);
    sscanf (c, "%d", &fs->c);
}
Example #6
0
void register_missed_functions (
    char *file,
    int missed_functions
    )
{
    component_stat *cs;
    file_stat *fs;
    char *dot;

    dot = r_index (file, '.');
    if (dot) {
	*dot = '\0';
        dot = r_index (file, '.');
        if (dot) {
	    *dot = '\0';
	}
    }
    cs = find_component (component);
    if (cs) {
	fs = find_filestat (cs, file);
	if (fs == NULL) {
	    fs = malloc (sizeof (file_stat));
	    memset (fs, 0, sizeof (file_stat));
	    fs->name = f_strdup(file);
	    if (cs->stat == NULL) {
		cs->stat = fs;
	    } else {
		fs->next = cs->stat;
		cs->stat = fs;
	    }
	}
    }
    fs->mf = missed_functions;
}
    /**
     * Function FindRescues
     * Grab all possible RESCUE_CACHE_CANDIDATEs into a vector.
     * @param aRescuer - the working RESCUER instance.
     * @param aCandidates - the vector the will hold the candidates.
     */
    static void FindRescues( RESCUER& aRescuer, boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates )
    {
        typedef std::map<wxString, RESCUE_CACHE_CANDIDATE> candidate_map_t;
        candidate_map_t candidate_map;

        wxString part_name_suffix = aRescuer.GetPartNameSuffix();

        for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) )
        {
            wxString part_name( each_component->GetPartName() );

            LIB_PART* cache_match = find_component( part_name, aRescuer.GetLibs(), /* aCached */ true );
            LIB_PART* lib_match = aRescuer.GetLibs()->FindLibPart( part_name );

            // Test whether there is a conflict
            if( !cache_match || !lib_match )
                continue;
            if( !cache_match->PinsConflictWith( *lib_match, /* aTestNums */ true,
                    /* aTestNames */ true, /* aTestType */ true, /* aTestOrientation */ true,
                    /* aTestLength */ false ))
                continue;

            RESCUE_CACHE_CANDIDATE candidate(
                part_name, part_name + part_name_suffix,
                cache_match, lib_match );
            candidate_map[part_name] = candidate;
        }

        // Now, dump the map into aCandidates
        for( const candidate_map_t::value_type& each_pair : candidate_map )
        {
            aCandidates.push_back( new RESCUE_CACHE_CANDIDATE( each_pair.second ) );
        }
    }
Example #8
0
bool component_manager::delete_component(component *root, const std::string &path)
{
	path_element tail;
	component *c = find_component(root,path,tail);
	if (c==NULL) {
		return false;
	}
	return c->delete_child(tail);
}
/*
 * If it's in the repository, close a specified component and remove
 * it from the repository.
 */
void mca_base_component_repository_release(const mca_base_component_t *component)
{
#if OPAL_WANT_LIBLTDL
  if (initialized) {
    repository_item_t *ri = find_component(component->mca_type_name, 
                                           component->mca_component_name);
    if (NULL != ri) {
      OBJ_RELEASE(ri);
    }
  }
#endif
}
Example #10
0
static int __cpuinit xbow_probe(nasid_t nasid)
{
	lboard_t *brd;
	klxbow_t *xbow_p;
	unsigned masterwid, i;

	printk("is xbow\n");

	/*
	 * found xbow, so may have multiple bridges
	 * need to probe xbow
	 */
	brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_MIDPLANE8);
	if (!brd)
		return -ENODEV;

	xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW);
	if (!xbow_p)
		return -ENODEV;

	/*
	 * Okay, here's a xbow. Lets arbitrate and find
	 * out if we should initialize it. Set enabled
	 * hub connected at highest or lowest widget as
	 * master.
	 */
#ifdef WIDGET_A
	i = HUB_WIDGET_ID_MAX + 1;
	do {
		i--;
	} while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
		 (!XBOW_PORT_IS_ENABLED(xbow_p, i)));
#else
	i = HUB_WIDGET_ID_MIN - 1;
	do {
		i++;
	} while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
		 (!XBOW_PORT_IS_ENABLED(xbow_p, i)));
#endif

	masterwid = i;
	if (nasid != XBOW_PORT_NASID(xbow_p, i))
		return 1;

	for (i = HUB_WIDGET_ID_MIN; i <= HUB_WIDGET_ID_MAX; i++) {
		if (XBOW_PORT_IS_ENABLED(xbow_p, i) &&
		    XBOW_PORT_TYPE_IO(xbow_p, i))
			probe_one_port(nasid, i, masterwid);
	}

	return 0;
}
Example #11
0
bool component_manager::change_component(component *root, const std::string &path, const config &cfg)
{
	path_element tail;
	component *c = find_component(root,path,tail);
	if (c==NULL) {
		return false;
	}
	const config &ch = cfg.child(tail.property);
	if (!ch) {
		return false;
	}
	return c->change_child(tail,ch);
}
Example #12
0
void
gnc_gui_component_clear_watches (gint component_id)
{
    ComponentInfo *ci;

    ci = find_component (component_id);
    if (!ci)
    {
        PERR ("component not found");
        return;
    }

    clear_event_info (&ci->watch_info);
}
Example #13
0
void
gnc_gui_component_set_session (gint component_id, gpointer session)
{
    ComponentInfo *ci;

    ci = find_component (component_id);
    if (!ci)
    {
        PERR ("component not found");
        return;
    }

    ci->session = session;
}
/*
 * Bump up the refcount on a component
 */
int mca_base_component_repository_retain_component(const char *type, 
                                                   const char *name)
{
#if OPAL_WANT_LIBLTDL
    repository_item_t *ri = find_component(type, name);
    if (NULL != ri) {
        OBJ_RETAIN(ri);
        return OPAL_SUCCESS;
    }
    return OPAL_ERR_NOT_FOUND;
#else
    return OPAL_ERR_NOT_SUPPORTED;
#endif
}
Example #15
0
void
gnc_gui_component_watch_entity_type (gint component_id,
                                     QofIdTypeConst entity_type,
                                     QofEventId event_mask)
{
    ComponentInfo *ci;

    ci = find_component (component_id);
    if (!ci)
    {
        PERR ("component not found");
        return;
    }

    add_event_type (&ci->watch_info, entity_type, event_mask, FALSE);
}
Example #16
0
static ComponentInfo *
gnc_register_gui_component_internal (const char * component_class)
{
    ComponentInfo *ci;
    gint component_id;

    g_return_val_if_fail (component_class, NULL);

    /* look for a free handler id */
    component_id = next_component_id;

    /* design warning: if we ever get 2^32-1 components,
       this loop is infinite.  Instead of fixing it, we'll just
       complain when (if) we get half way there (probably never).
    */
    while (find_component (component_id))
        if (++component_id == NO_COMPONENT)
            component_id++;

    if (component_id < 0)
        PERR("Amazing! Half way to running out of component_ids.");

    /* found one, add the handler */
    ci = g_new0 (ComponentInfo, 1);

    ci->watch_info.event_masks = g_hash_table_new (g_str_hash, g_str_equal);
    ci->watch_info.entity_events = guid_hash_table_new ();

    ci->component_class = g_strdup (component_class);
    ci->component_id = component_id;
    ci->session = NULL;

    components = g_list_prepend (components, ci);

    /* update id for next registration */
    next_component_id = component_id + 1;

#if CM_DEBUG
    fprintf (stderr, "Register component %d in class %s\n",
             component_id, component_class ? component_class : "(null)");
    dump_components ();
#endif

    return ci;
}
Example #17
0
klcpu_t * nasid_slice_to_cpuinfo(nasid_t nasid, int slice)
{
	lboard_t *brd;
	klcpu_t *acpu;

	if (!(brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27)))
		return (klcpu_t *)NULL;

	if (!(acpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU)))
		return (klcpu_t *)NULL;

	do {
		if ((acpu->cpu_info.physid) == slice)
			return acpu;
	} while ((acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu,
								KLSTRUCT_CPU)));
	return (klcpu_t *)NULL;
}
Example #18
0
void
gnc_close_gui_component (gint component_id)
{
    ComponentInfo *ci;

    ci = find_component (component_id);
    if (!ci)
    {
        PERR ("component not found");
        return;
    }

    if (!ci->close_handler)
        return;

    if (ci->close_handler)
        ci->close_handler (ci->user_data);
}
Example #19
0
void
gnc_gui_component_watch_entity (gint component_id,
                                const GncGUID *entity,
                                QofEventId event_mask)
{
    ComponentInfo *ci;

    if (entity == NULL)
        return;

    ci = find_component (component_id);
    if (!ci)
    {
        PERR ("component not found");
        return;
    }

    add_event (&ci->watch_info, entity, event_mask, FALSE);
}
Example #20
0
void create_be_statistics (
    char *be,
    char *b,
    char *file
    )
{
    file_stat *fs;
    char *fn;
    component_stat *cs;

    fn = clean_filename (file);
    cs = find_component (component);
    if (cs) {
	fs = find_filestat (cs, fn);
	if (fs == NULL) {
	    fs = malloc (sizeof (file_stat));
	    memset (fs, 0, sizeof (file_stat));
	    fs->name = f_strdup(fn);
	    if (cs->stat == NULL) {
		cs->stat = fs;
	    } else {
		fs->next = cs->stat;
		cs->stat = fs;
	    }
	}
    }
    sscanf (be, "%f", &fs->be);
    sscanf (b, "%d", &fs->b);
#if 0
    if ((fs->be < 80.0) && !(fs->be == 0.0 && fs->sle == 100.0)) {
	cs->files_fail_on_limit++;
    } else {
	cs->files_pass_on_limit++;
	if (missed_functions) {
	    cs->files_fail_untouched_functions++;
	}
    }
    fs->mf = missed_functions;
#endif
}
Example #21
0
static int do_cpumask(cnodeid_t cnode, nasid_t nasid, int highest)
{
	static int tot_cpus_found = 0;
	lboard_t *brd;
	klcpu_t *acpu;
	int cpus_found = 0;
	cpuid_t cpuid;

	brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27);

	do {
		acpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU);
		while (acpu) {
			cpuid = acpu->cpu_info.virtid;
			/* cnode is not valid for completely disabled brds */
			if (get_actual_nasid(brd) == brd->brd_nasid)
				cpuid_to_compact_node[cpuid] = cnode;
			if (cpuid > highest)
				highest = cpuid;
			/* Only let it join in if it's marked enabled */
			if ((acpu->cpu_info.flags & KLINFO_ENABLE) &&
			    (tot_cpus_found != NR_CPUS)) {
				cpu_set(cpuid, phys_cpu_present_map);
				alloc_cpupda(cpuid, tot_cpus_found);
				cpus_found++;
				tot_cpus_found++;
			}
			acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu,
								KLSTRUCT_CPU);
		}
		brd = KLCF_NEXT(brd);
		if (!brd)
			break;

		brd = find_lboard(brd, KLTYPE_IP27);
	} while (brd);

	return highest;
}
Example #22
0
void
gnc_unregister_gui_component (gint component_id)
{
    ComponentInfo *ci;

    ci = find_component (component_id);
    if (!ci)
    {
        PERR ("component %d not found", component_id);
        return;
    }

#if CM_DEBUG
    fprintf (stderr, "Unregister component %d in class %s\n",
             ci->component_id,
             ci->component_class ? ci->component_class : "(null)");
#endif

    gnc_gui_component_clear_watches (component_id);

    components = g_list_remove (components, ci);

    destroy_mask_hash (ci->watch_info.event_masks);
    ci->watch_info.event_masks = NULL;

    destroy_event_hash (ci->watch_info.entity_events);
    ci->watch_info.entity_events = NULL;

    g_free (ci->component_class);
    ci->component_class = NULL;

    g_free (ci);

#if CM_DEBUG
    dump_components ();
#endif
}
Example #23
0
static av_cold int omx_encode_init(AVCodecContext *avctx)
{
    OMXCodecContext *s = avctx->priv_data;
    int ret = AVERROR_ENCODER_NOT_FOUND;
    const char *role;
    OMX_BUFFERHEADERTYPE *buffer;
    OMX_ERRORTYPE err;

#if CONFIG_OMX_RPI
    s->input_zerocopy = 1;
#endif

    s->omx_context = omx_init(avctx, s->libname, s->libprefix);
    if (!s->omx_context)
        return AVERROR_ENCODER_NOT_FOUND;

    pthread_mutex_init(&s->state_mutex, NULL);
    pthread_cond_init(&s->state_cond, NULL);
    pthread_mutex_init(&s->input_mutex, NULL);
    pthread_cond_init(&s->input_cond, NULL);
    pthread_mutex_init(&s->output_mutex, NULL);
    pthread_cond_init(&s->output_cond, NULL);
    s->mutex_cond_inited = 1;
    s->avctx = avctx;
    s->state = OMX_StateLoaded;
    s->error = OMX_ErrorNone;

    switch (avctx->codec->id) {
    case AV_CODEC_ID_MPEG4:
        role = "video_encoder.mpeg4";
        break;
    case AV_CODEC_ID_H264:
        role = "video_encoder.avc";
        break;
    default:
        return AVERROR(ENOSYS);
    }

    if ((ret = find_component(s->omx_context, avctx, role, s->component_name, sizeof(s->component_name))) < 0)
        goto fail;

    av_log(avctx, AV_LOG_INFO, "Using %s\n", s->component_name);

    if ((ret = omx_component_init(avctx, role)) < 0)
        goto fail;

    if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
        while (1) {
            buffer = get_buffer(&s->output_mutex, &s->output_cond,
                                &s->num_done_out_buffers, s->done_out_buffers, 1);
            if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) {
                if ((ret = av_reallocp(&avctx->extradata, avctx->extradata_size + buffer->nFilledLen + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) {
                    avctx->extradata_size = 0;
                    goto fail;
                }
                memcpy(avctx->extradata + avctx->extradata_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen);
                avctx->extradata_size += buffer->nFilledLen;
                memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
            }
            err = OMX_FillThisBuffer(s->handle, buffer);
            if (err != OMX_ErrorNone) {
                append_buffer(&s->output_mutex, &s->output_cond,
                              &s->num_done_out_buffers, s->done_out_buffers, buffer);
                av_log(avctx, AV_LOG_ERROR, "OMX_FillThisBuffer failed: %x\n", err);
                ret = AVERROR_UNKNOWN;
                goto fail;
            }
            if (avctx->codec->id == AV_CODEC_ID_H264) {
                // For H.264, the extradata can be returned in two separate buffers
                // (the videocore encoder on raspberry pi does this);
                // therefore check that we have got both SPS and PPS before continuing.
                int nals[32] = { 0 };
                int i;
                for (i = 0; i + 4 < avctx->extradata_size; i++) {
                     if (!avctx->extradata[i + 0] &&
                         !avctx->extradata[i + 1] &&
                         !avctx->extradata[i + 2] &&
                         avctx->extradata[i + 3] == 1) {
                         nals[avctx->extradata[i + 4] & 0x1f]++;
                     }
                }
                if (nals[H264_NAL_SPS] && nals[H264_NAL_PPS])
                    break;
            } else {
                if (avctx->extradata_size > 0)
                    break;
            }
        }
    }

    return 0;
fail:
    return ret;
}
Example #24
0
klinfo_t *find_first_component(lboard_t *brd, unsigned char struct_type)
{
	return find_component(brd, (klinfo_t *)NULL, struct_type);
}
Example #25
0
/* ARGSUSED */
static void __init
klhwg_add_node(vertex_hdl_t hwgraph_root, cnodeid_t cnode)
{
	nasid_t nasid;
	lboard_t *brd;
	klhub_t *hub;
	vertex_hdl_t node_vertex = NULL;
	char path_buffer[100];
	int rv;
	char *s;
	int board_disabled = 0;
	klcpu_t *cpu;
	vertex_hdl_t cpu_dir;

	nasid = cnodeid_to_nasid(cnode);
	brd = find_lboard_any((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
	ASSERT(brd);

	/* Generate a hardware graph path for this board. */
	board_to_path(brd, path_buffer);
	rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex);
	if (rv != GRAPH_SUCCESS) {
		printk("Node vertex creation failed.  Path == %s", path_buffer);
		return;
	}

	HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, node_vertex, NULL, "Created path for SHUB node.\n");
	hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);
	ASSERT(hub);
	if(hub->hub_info.flags & KLINFO_ENABLE)
		board_disabled = 0;
	else
		board_disabled = 1;
		
	if(!board_disabled) {
		mark_nodevertex_as_node(node_vertex, cnode);
		s = dev_to_name(node_vertex, path_buffer, sizeof(path_buffer));
		NODEPDA(cnode)->hwg_node_name =
					kmalloc(strlen(s) + 1, GFP_KERNEL);
		if (NODEPDA(cnode)->hwg_node_name <= 0) {
			printk("%s: no memory\n", __FUNCTION__);
			return;
		}
		strcpy(NODEPDA(cnode)->hwg_node_name, s);
		hubinfo_set(node_vertex, NODEPDA(cnode)->pdinfo);
		NODEPDA(cnode)->slotdesc = brd->brd_slot;
		NODEPDA(cnode)->geoid = brd->brd_geoid;
		NODEPDA(cnode)->module = module_lookup(geo_module(brd->brd_geoid));
		klhwg_add_hub(node_vertex, hub, cnode);
	}

	/*
	 * If there's at least 1 CPU, add a "cpu" directory to represent
	 * the collection of all CPUs attached to this node.
	 */
	cpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU);
	if (cpu) {
		graph_error_t rv;

		rv = hwgraph_path_add(node_vertex, EDGE_LBL_CPU, &cpu_dir);
		if (rv != GRAPH_SUCCESS) {
			printk("klhwg_add_node: Cannot create CPU directory\n");
			return;
		}
		HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, cpu_dir, NULL, "Created cpu directiry on SHUB node.\n");

	}

	while (cpu) {
		cpuid_t cpu_id;
		cpu_id = nasid_slice_to_cpuid(nasid,cpu->cpu_info.physid);
		if (cpu_online(cpu_id))
			klhwg_add_cpu(node_vertex, cnode, cpu);
		else
			klhwg_add_disabled_cpu(node_vertex, cnode, cpu, brd->brd_slot);

		cpu = (klcpu_t *)
			find_component(brd, (klinfo_t *)cpu, KLSTRUCT_CPU);
	}
}
Example #26
0
static void __init
klhwg_add_xbow(cnodeid_t cnode, nasid_t nasid)
{
	lboard_t *brd;
	klxbow_t *xbow_p;
	nasid_t hub_nasid;
	cnodeid_t hub_cnode;
	int widgetnum;
	vertex_hdl_t xbow_v, hubv;
	/*REFERENCED*/
	graph_error_t err;

	if (!(brd = find_lboard_nasid((lboard_t *)KL_CONFIG_INFO(nasid), 
			nasid, KLTYPE_IOBRICK_XBOW)))
		return;

	if (KL_CONFIG_DUPLICATE_BOARD(brd))
	    return;

	if ((xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW))
	    == NULL)
	    return;

	for (widgetnum = HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) {
		if (!XBOW_PORT_TYPE_HUB(xbow_p, widgetnum)) 
		    continue;

		hub_nasid = XBOW_PORT_NASID(xbow_p, widgetnum);
		if (hub_nasid == INVALID_NASID) {
			printk(KERN_WARNING  "hub widget %d, skipping xbow graph\n", widgetnum);
			continue;
		}

		hub_cnode = nasid_to_cnodeid(hub_nasid);

		if (hub_cnode == INVALID_CNODEID) {
			continue;
		}
			
		hubv = cnodeid_to_vertex(hub_cnode);

		err = hwgraph_path_add(hubv, EDGE_LBL_XTALK, &xbow_v);
                if (err != GRAPH_SUCCESS) {
                        if (err == GRAPH_DUP)
                                printk(KERN_WARNING  "klhwg_add_xbow: Check for "
                                        "working routers and router links!");

                        printk("klhwg_add_xbow: Failed to add "
                                "edge: vertex 0x%p to vertex 0x%p,"
                                "error %d\n",
                                (void *)hubv, (void *)xbow_v, err);
			return;
                }

		HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, xbow_v, NULL, "Created path for xtalk.\n");

		xswitch_vertex_init(xbow_v); 

		NODEPDA(hub_cnode)->xbow_vhdl = xbow_v;

		/*
		 * XXX - This won't work is we ever hook up two hubs
		 * by crosstown through a crossbow.
		 */
		if (hub_nasid != nasid) {
			NODEPDA(hub_cnode)->xbow_peer = nasid;
			NODEPDA(nasid_to_cnodeid(nasid))->xbow_peer =
				hub_nasid;
		}
	}
}
Example #27
0
/*
 * Arie's main "Loop": calculate undirparents.
 */
void calculate_undirparents( void )
{
  organism *i;
  connected_component *C0;
  child_datum *edge;
  organism *cp;
  connected_component *Cp;

  /*
   * Superfluous "goto" statement in honor of Arie's research on "goto"
   */
  goto beginning_of_calculate_undirparents;

beginning_of_calculate_undirparents:

  /*
   * Let i go from the youngest organism to the oldest.
   */
  for ( i = youngest_organism; i; i = i->prev )
  {
    /*
     * Create a component consisting only of node i,
     * having i as orphan.  Note: the function
     * create_singleton_component automatically makes
     * the single member the orphan.
     */
    C0 = create_singleton_component(i);

    /*
     * Iterate through the children of i.
     * (If i has no children, this for loop does nothing.)
     */
    for ( edge = i->first_child; edge; edge = edge->next )
    {
      cp = edge->child;
      /*
       * Find which component the child is in.
       */
      Cp = find_component(cp);

      /*
       * If i has multiple children in a component,
       * we must be careful only to "process" that component
       * once.  If we've already processed it, then its
       * orphan is i.  If so, go on to the next child of i.
       */
      if ( Cp->orphan == i )
        continue;

      /*
       * The undirparent of the component's previous orphan shall now be i.
       */
      Cp->orphan->undirparent = i;

      /*
       * Unite the components.
       */
      C0 = component_union(C0,Cp);
      C0->orphan = i;
    }
  }
}
Example #28
0
void __init pcibr_setup(cnodeid_t nid)
{
    int 			i, start, num;
    unsigned long		masterwid;
    bridge_t 		*bridge;
    volatile u64 		hubreg;
    nasid_t	 		nasid, masternasid;
    xwidget_part_num_t	partnum;
    widgetreg_t 		widget_id;
    static spinlock_t	pcibr_setup_lock = SPIN_LOCK_UNLOCKED;

    /*
     * If the master is doing this for headless node, nothing to do.
     * This is because currently we require at least one of the hubs
     * (master hub) connected to the xbow to have at least one enabled
     * cpu to receive intrs. Else we need an array bus_to_intrnasid[]
     * that bridge_startup() needs to use to target intrs. All dma is
     * routed thru the widget of the master hub. The master hub wid
     * is selectable by WIDGET_A below.
     */
    if (nid != get_compact_nodeid())
        return;
    /*
     * find what's on our local node
     */
    spin_lock(&pcibr_setup_lock);
    start = num_bridges;		/* Remember where we start from */
    nasid = COMPACT_TO_NASID_NODEID(nid);
    hubreg = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
    if (hubreg & IIO_LLP_CSR_IS_UP) {
        /* link is up */
        widget_id = *(volatile widgetreg_t *)
                    (RAW_NODE_SWIN_BASE(nasid, 0x0) + WIDGET_ID);
        partnum = XWIDGET_PART_NUM(widget_id);
        printk("Cpu %d, Nasid 0x%x, pcibr_setup(): found partnum= 0x%x",
               smp_processor_id(), nasid, partnum);
        if (partnum == BRIDGE_WIDGET_PART_NUM) {
            /*
             * found direct connected bridge so must be Origin200
             */
            printk("...is bridge\n");
            num_bridges = 1;
            bus_to_wid[0] = 0x8;
            bus_to_nid[0] = 0;
            masterwid = 0xa;
            bus_to_baddr[0] = 0xa100000000000000UL;
        } else if (partnum == XBOW_WIDGET_PART_NUM) {
            lboard_t *brd;
            klxbow_t *xbow_p;
            /*
             * found xbow, so may have multiple bridges
             * need to probe xbow
             */
            printk("...is xbow\n");

            if ((brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid),
                                   KLTYPE_MIDPLANE8)) == NULL)
                printk("argh\n");
            else
                printk("brd = 0x%lx\n", (unsigned long) brd);
            if ((xbow_p = (klxbow_t *)
                          find_component(brd, NULL, KLSTRUCT_XBOW)) == NULL)
                printk("argh\n");
            else {
                /*
                 * Okay, here's a xbow. Lets arbitrate and find
                 * out if we should initialize it. Set enabled
                 * hub connected at highest or lowest widget as
                 * master.
                 */
#ifdef WIDGET_A
                i = HUB_WIDGET_ID_MAX + 1;
                do {
                    i--;
                } while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
                         (!XBOW_PORT_IS_ENABLED(xbow_p, i)));
#else
                i = HUB_WIDGET_ID_MIN - 1;
                do {
                    i++;
                } while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
                         (!XBOW_PORT_IS_ENABLED(xbow_p, i)));
#endif
                masterwid = i;
                masternasid = XBOW_PORT_NASID(xbow_p, i);
                if (nasid == masternasid)
                    for (i=HUB_WIDGET_ID_MIN; i<=HUB_WIDGET_ID_MAX; i++) {
                        if (!XBOW_PORT_IS_ENABLED(xbow_p, i))
                            continue;
                        if (XBOW_PORT_TYPE_IO(xbow_p, i)) {
                            widget_id = *(volatile widgetreg_t *)
                                        (RAW_NODE_SWIN_BASE(nasid, i) + WIDGET_ID);
                            partnum = XWIDGET_PART_NUM(widget_id);
                            if (partnum == BRIDGE_WIDGET_PART_NUM) {
                                printk("widget 0x%x is a bridge\n", i);
                                bus_to_wid[num_bridges] = i;
                                bus_to_nid[num_bridges] = nasid;
                                bus_to_baddr[num_bridges] = ((masterwid << 60) | (1UL << 56));	/* Barrier set */
                                num_bridges++;
                            }
                        }
                    }
            }
        } else if (partnum == XXBOW_WIDGET_PART_NUM) {
            /*
             * found xbridge, assume ibrick for now
             */
            printk("...is xbridge\n");
            bus_to_wid[0] = 0xb;
            bus_to_wid[1] = 0xe;
            bus_to_wid[2] = 0xf;

            bus_to_nid[0] = 0;
            bus_to_nid[1] = 0;
            bus_to_nid[2] = 0;

            bus_to_baddr[0] = 0xa100000000000000UL;
            bus_to_baddr[1] = 0xa100000000000000UL;
            bus_to_baddr[2] = 0xa100000000000000UL;
            masterwid = 0xa;
            num_bridges = 3;
        }
    }
    num = num_bridges - start;
    spin_unlock(&pcibr_setup_lock);
    /*
         * set bridge registers
         */
    for (i = start; i < (start + num); i++) {

        DBG("pcibr_setup: bus= %d  bus_to_wid[%2d]= %d  bus_to_nid[%2d]= %d\n",
            i, i, bus_to_wid[i], i, bus_to_nid[i]);

        bus_to_cpu[i] = smp_processor_id();
        /*
         * point to this bridge
         */
        bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[i],bus_to_wid[i]);
        /*
         * Clear all pending interrupts.
         */
        bridge->b_int_rst_stat = (BRIDGE_IRR_ALL_CLR);
        /*
         * Until otherwise set up, assume all interrupts are from slot 0
         */
        bridge->b_int_device = (u32) 0x0;
        /*
         * swap pio's to pci mem and io space (big windows)
         */
        bridge->b_wid_control |= BRIDGE_CTRL_IO_SWAP;
        bridge->b_wid_control |= BRIDGE_CTRL_MEM_SWAP;

        /*
         * Hmm...  IRIX sets additional bits in the address which
         * are documented as reserved in the bridge docs.
         */
        bridge->b_int_mode = 0x0;		/* Don't clear ints */
        bridge->b_wid_int_upper = 0x8000 | (masterwid << 16);
        bridge->b_wid_int_lower = 0x01800090;	/* PI_INT_PEND_MOD off*/
        bridge->b_dir_map = (masterwid << 20);	/* DMA */
        bridge->b_int_enable = 0;

        bridge->b_wid_tflush;     /* wait until Bridge PIO complete */
    }
}
Example #29
0
void player::complete_disassemble( int item_pos, const tripoint &loc,
                                   bool from_ground, const recipe &dis )
{
    // Get the proper recipe - the one for disassembly, not assembly
    const auto dis_requirements = dis.disassembly_requirements();
    item &org_item = get_item_for_uncraft( *this, item_pos, loc, from_ground );
    bool filthy = org_item.is_filthy();
    if( org_item.is_null() ) {
        add_msg( _( "The item has vanished." ) );
        activity.set_to_null();
        return;
    }

    if( org_item.typeId() != dis.result ) {
        add_msg( _( "The item might be gone, at least it is not at the expected position anymore." ) );
        activity.set_to_null();
        return;
    }
    // Make a copy to keep its data (damage/components) even after it
    // has been removed.
    item dis_item = org_item;

    float component_success_chance = std::min( std::pow( 0.8, dis_item.damage() ), 1.0 );

    add_msg( _( "You disassemble the %s into its components." ), dis_item.tname().c_str() );
    // Remove any batteries, ammo and mods first
    remove_ammo( &dis_item, *this );
    remove_radio_mod( dis_item, *this );

    if( dis_item.count_by_charges() ) {
        // remove the charges that one would get from crafting it
        org_item.charges -= dis.create_result().charges;
    }
    // remove the item, except when it's counted by charges and still has some
    if( !org_item.count_by_charges() || org_item.charges <= 0 ) {
        if( from_ground ) {
            g->m.i_rem( loc, item_pos );
        } else {
            i_rem( item_pos );
        }
    }

    // Consume tool charges
    for( const auto &it : dis_requirements.get_tools() ) {
        consume_tools( it );
    }

    // add the components to the map
    // Player skills should determine how many components are returned

    int skill_dice = 2 + get_skill_level( dis.skill_used ) * 3;
    skill_dice += get_skill_level( dis.skill_used );

    // Sides on dice is 16 plus your current intelligence
    ///\EFFECT_INT increases success rate for disassembling items
    int skill_sides = 16 + int_cur;

    int diff_dice = dis.difficulty;
    int diff_sides = 24; // 16 + 8 (default intelligence)

    // disassembly only nets a bit of practice
    if( dis.skill_used ) {
        practice( dis.skill_used, ( dis.difficulty ) * 2, dis.difficulty );
    }

    for( const auto &altercomps : dis_requirements.get_components() ) {
        const item_comp comp = find_component( altercomps, dis_item );
        int compcount = comp.count;
        item newit( comp.type, calendar::turn );
        // Counted-by-charge items that can be disassembled individually
        // have their component count multiplied by the number of charges.
        if( dis_item.count_by_charges() && dis.has_flag( "UNCRAFT_SINGLE_CHARGE" ) ) {
            compcount *= std::min( dis_item.charges, dis.create_result().charges );
        }
        // Compress liquids and counted-by-charges items into one item,
        // they are added together on the map anyway and handle_liquid
        // should only be called once to put it all into a container at once.
        if( newit.count_by_charges() || newit.made_of( LIQUID ) ) {
            newit.charges = compcount;
            compcount = 1;
        } else if( !newit.craft_has_charges() && newit.charges > 0 ) {
            // tools that can be unloaded should be created unloaded,
            // tools that can't be unloaded will keep their default charges.
            newit.charges = 0;
        }

        for( ; compcount > 0; compcount-- ) {
            const bool comp_success = ( dice( skill_dice, skill_sides ) > dice( diff_dice,  diff_sides ) );
            if( dis.difficulty != 0 && !comp_success ) {
                add_msg( m_bad, _( "You fail to recover %s." ), newit.tname().c_str() );
                continue;
            }
            const bool dmg_success = component_success_chance > rng_float( 0, 1 );
            if( !dmg_success ) {
                // Show reason for failure (damaged item, tname contains the damage adjective)
                //~ %1s - material, %2$s - disassembled item
                add_msg( m_bad, _( "You fail to recover %1$s from the %2$s." ), newit.tname().c_str(),
                         dis_item.tname().c_str() );
                continue;
            }
            // Use item from components list, or (if not contained)
            // use newit, the default constructed.
            item act_item = newit;

            if( filthy ) {
                act_item.item_tags.insert( "FILTHY" );
            }

            for( item::t_item_vector::iterator a = dis_item.components.begin(); a != dis_item.components.end();
                 ++a ) {
                if( a->type == newit.type ) {
                    act_item = *a;
                    dis_item.components.erase( a );
                    break;
                }
            }

            int veh_part = -1;
            vehicle *veh = g->m.veh_at( pos(), veh_part );
            if( veh != nullptr ) {
                veh_part = veh->part_with_feature( veh_part, "CARGO" );
            }

            if( act_item.made_of( LIQUID ) ) {
                g->handle_all_liquid( act_item, PICKUP_RANGE );
            } else if( veh_part != -1 && veh->add_item( veh_part, act_item ) ) {
                // add_item did put the items in the vehicle, nothing further to be done
            } else {
                // TODO: For items counted by charges, add as much as we can to the vehicle, and
                // the rest on the ground (see dropping code and @vehicle::add_charges)
                g->m.add_item_or_charges( pos(), act_item );
            }
        }
    }

    if( !dis.learn_by_disassembly.empty() && !knows_recipe( &dis ) ) {
        if( can_decomp_learn( dis ) ) {
            // @todo: make this depend on intelligence
            if( one_in( 4 ) ) {
                learn_recipe( &recipe_dict[ dis.ident() ] );
                add_msg( m_good, _( "You learned a recipe from disassembling it!" ) );
            } else {
                add_msg( m_info, _( "You might be able to learn a recipe if you disassemble another." ) );
            }
        } else {
            add_msg( m_info, _( "If you had better skills, you might learn a recipe next time." ) );
        }
    }
}
Example #30
0
static void
gnc_gui_refresh_internal (gboolean force)
{
    GList *list;
    GList *node;

    if (!got_events && !force)
        return;

    gnc_suspend_gui_refresh ();

    {
        GHashTable *table;

        table = changes_backup.event_masks;
        changes_backup.event_masks = changes.event_masks;
        changes.event_masks = table;

        table = changes_backup.entity_events;
        changes_backup.entity_events = changes.entity_events;
        changes.entity_events = table;
    }

#if CM_DEBUG
    fprintf (stderr, "%srefresh!\n", force ? "forced " : "");
#endif

    list = find_component_ids_by_class (NULL);

    for (node = list; node; node = node->next)
    {
        ComponentInfo *ci = find_component (GPOINTER_TO_INT (node->data));

        if (!ci)
            continue;

        if (!ci->refresh_handler)
        {
#if CM_DEBUG
            fprintf (stderr, "no handlers for %s:%d\n", ci->component_class, ci->component_id);
#endif
            continue;
        }

        if (force)
        {
            if (ci->refresh_handler)
            {
#if CM_DEBUG
                fprintf (stderr, "calling %s:%d C handler\n", ci->component_class, ci->component_id);
#endif
                ci->refresh_handler (NULL, ci->user_data);
            }
        }
        else if (changes_match (&ci->watch_info, &changes_backup))
        {
            if (ci->refresh_handler)
            {
#if CM_DEBUG
                fprintf (stderr, "calling %s:%d C handler\n", ci->component_class, ci->component_id);
#endif
                ci->refresh_handler (changes_backup.entity_events, ci->user_data);
            }
        }
        else
        {
#if CM_DEBUG
            fprintf (stderr, "no match for %s:%d\n", ci->component_class, ci->component_id);
#endif
        }
    }

    clear_event_info (&changes_backup);
    got_events = FALSE;

    g_list_free (list);

    gnc_resume_gui_refresh ();
}