예제 #1
0
파일: freemtap.c 프로젝트: sp193/ps2sdk
void update_slot_numbers_thread()
{
	while(1)
	{
		u32 resbits, port;
		s32 slots;

		WaitEventFlag(event_flag, EF_UPDATE_SLOTS | EF_EXIT_THREAD, 0x11, &resbits);

		if((resbits & EF_EXIT_THREAD) == 1)
		{
			SetEventFlag(event_flag, 0x4);
			ExitThread();
		}

		for(port=0; port < 4; port++)
		{
			if(state_open[port] == 1)
			{
				if(state_getcon[port] == 0)
					slots = get_slot_number(port, 10);
				else
					slots = get_slot_number(port, 0);

				if(slots < 0)
				{
					state_slots[port] = 1;
					state_getcon[port] = 0;
				}
				else
				{
					state_slots[port] = slots;
					state_getcon[port] = 1;
				}
			}
		}


	}
}
예제 #2
0
파일: freemtap.c 프로젝트: sp193/ps2sdk
s32 mtapGetSlotNumber(u32 port)
{
	s32 res;

	if(port > 4) return -1;

	if(state_open[port] == 0) return 1;

	res = get_slot_number(port, 10);

	if(res >= 0)
		return res;
	else
		return 1;
}
예제 #3
0
파일: pccardq.c 프로젝트: coyizumi/cs111
int
main(int ac, char **av)
{
    char           *path = NULL;
    int             so = -1;
    int             nslot;
    int             i;

    if (proc_arg(ac, av) < 0)
	goto out;
    if ((so = connect_to_pccardd(&path)) < 0)
	goto out;
    if ((nslot = get_slot_number(so)) < 0)
	goto out;
    if (slot_map == 0) {
	printf("%d\n", nslot);
    } else {
	for (i = 0; i < nslot; i++) {
	    if ((slot_map & (1 << i))) {
		char           *manuf;
		char           *version;
		char           *device;
		int             state;

		if (get_slot_info(so, i, &manuf, &version, &device,
				  &state) < 0)
		    goto out;
		if (manuf == NULL || version == NULL || device == NULL)
		    goto out;
		printf("%d~%s~%s~%s~%s\n",
		       i, manuf, version, device, strstate(state));
		free(manuf);
		free(version);
		free(device);
	    }
	}
    }
  out:
    if (path) {
	unlink(path);
	free(path);
    }
    if (so >= 0)
	close(so);
    exit(0);
}
예제 #4
0
파일: freemtap.c 프로젝트: sp193/ps2sdk
s32 mtapPortOpen(u32 port)
{
	if(port < 4)
	{
		state_open[port] = 1;

		s32 res = get_slot_number(port, 10);

		if(res < 0)
		{
			state_getcon[port] = 0;
			state_slots[port] = 1;
			return res;
		}
		else
		{
			state_getcon[port] = 1;
			state_slots[port] = res;
			return 1;
		}
	}

	return 0;
}
예제 #5
0
/* ARGSUSED */
static int
montoya_pci_callback(picl_nodehdl_t pcih, void *args)
{
    int		err = PICL_SUCCESS;
    picl_nodehdl_t	nodeh;
    char		path[MAXSTRLEN];
    char		parent_path[MAXSTRLEN];
    char		piclclass[PICL_CLASSNAMELEN_MAX];
    char		name[MAXSTRLEN];
    char		model[MAXSTRLEN];
    char		*compatible;
    char		binding_name[MAXSTRLEN];
    struct io_card	pci_card;
    int32_t		instance;

    err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, parent_path,
                                   sizeof (parent_path));
    if (err != PICL_SUCCESS) {
        return (err);
    }

    /* Walk through the children */

    err = picl_get_propval_by_name(pcih, PICL_PROP_CHILD, &nodeh,
                                   sizeof (picl_nodehdl_t));

    while (err == PICL_SUCCESS) {
        err = picl_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
                                       piclclass, sizeof (piclclass));
        if (err !=  PICL_SUCCESS)
            return (err);

        if (strcmp(piclclass, PCIEX) == 0) {
            err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER,
                                           &nodeh, sizeof (picl_nodehdl_t));
            continue;
        }

        if (strcmp(piclclass, PICL_CLASS_PCI) == 0) {
            err = picl_get_propval_by_name(nodeh, PICL_PROP_CHILD,
                                           &nodeh, sizeof (picl_nodehdl_t));
            continue;
        }

        err = picl_get_propval_by_name(nodeh, PICL_PROP_DEVFS_PATH,
                                       path, sizeof (path));
        if (err != PICL_SUCCESS) {
            return (err);
        }

        (void) strlcpy(pci_card.notes, path, sizeof (pci_card.notes));

        get_bus_type(parent_path, &pci_card);

        get_slot_number(parent_path, &pci_card);

        err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME, &name,
                                       sizeof (name));
        if (err == PICL_PROPNOTFOUND)
            (void) strcpy(name, "");
        else if (err != PICL_SUCCESS)
            return (err);

        /* Figure NAC name */
        if ((strcmp(name, NETWORK) == 0 ||
                strcmp(name, ETHERNET) == 0) &&
                (strcmp(pci_card.slot_str, MOTHERBOARD) == 0)) {
            instance = montoya_get_network_instance(path);

            (void) snprintf(pci_card.status,
                            sizeof (pci_card.status), "%s/%s%d", MOTHERBOARD,
                            "NET", instance);
        } else {
            if (pci_card.slot != -1) {
                (void) snprintf(pci_card.status,
                                sizeof (pci_card.status), "%s/%s%d",
                                IOBOARD, pci_card.bus_type, pci_card.slot);
            } else {
                (void) snprintf(pci_card.status,
                                sizeof (pci_card.status),
                                "%s/%s", MOTHERBOARD, pci_card.bus_type);
            }
        }

        /*
         * Get the name of this card. If binding_name is found,
         * name will be <nodename>-<binding_name>
         */

        err = picl_get_propval_by_name(nodeh, PICL_PROP_BINDING_NAME,
                                       &binding_name, sizeof (binding_name));
        if (err == PICL_PROPNOTFOUND) {
            /*
             * if compatible prop is found, name will be
             * <nodename>-<compatible>
             */
            err = montoya_get_first_compatible_value(nodeh,
                    &compatible);
            if (err == PICL_SUCCESS) {
                (void) strlcat(name, "-", MAXSTRLEN);
                (void) strlcat(name, compatible, MAXSTRLEN);
                free(compatible);
            } else if (err != PICL_PROPNOTFOUND) {
                return (err);
            }
        } else if (err != PICL_SUCCESS) {
            return (err);
        } else if (strcmp(name, binding_name) != 0) {
            (void) strlcat(name, "-", MAXSTRLEN);
            (void) strlcat(name, binding_name, MAXSTRLEN);
        }

        (void) strlcpy(pci_card.name, name, sizeof (pci_card.name));

        /* Get the model of this card */

        err = picl_get_propval_by_name(nodeh, OBP_PROP_MODEL,
                                       &model, sizeof (model));
        if (err == PICL_PROPNOTFOUND)
            (void) strcpy(model, "");
        else if (err != PICL_SUCCESS)
            return (err);
        (void) strlcpy(pci_card.model, model, sizeof (pci_card.model));

        /* Print NAC name */
        log_printf("%-11s", pci_card.status);
        /* Print IO Type */
        log_printf("%6s", pci_card.bus_type);
        /* Print Slot # */
        log_printf("%5s", pci_card.slot_str);
        /* Print Parent Path */
        log_printf("%46.45s", pci_card.notes);
        /* Printf Card Name */
        if (strlen(pci_card.name) > 24)
            log_printf("%25.24s+", pci_card.name);
        else
            log_printf("%26s", pci_card.name);
        /* Print Card Model */
        if (strlen(pci_card.model) > 10)
            log_printf("%10.9s+", pci_card.model);
        else
            log_printf("%10s", pci_card.model);
        log_printf("\n");

        err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER, &nodeh,
                                       sizeof (picl_nodehdl_t));

    }

    return (PICL_WALK_CONTINUE);
}
예제 #6
0
fc::time_point_sec get_slot_start_time( const fc::time_point_sec timestamp )
{
   return get_slot_start_time( get_slot_number( timestamp ) );
}