/*
 * Status routine called to get params string.
 */
static char *
dm_target_stripe_status(void *target_config)
{
	dm_target_stripe_config_t *tsc;
	char *params;
	char *ptr;
	size_t len;
	size_t nlen;
	int n;

	tsc = target_config;

	/* caller expects use of M_DM for returned params */
	nlen = DM_MAX_PARAMS_SIZE;
	params = kmalloc(nlen, M_DM, M_WAITOK);
	ptr = params;

	ksnprintf(ptr, nlen, "%d %jd",
		  tsc->stripe_num, (intmax_t)tsc->stripe_chunksize);
	len = strlen(params);
	ptr += len;
	nlen -= len;

	for (n = 0; n < tsc->stripe_num; ++n) {
		ksnprintf(ptr, nlen, " %s %jd",
			  tsc->stripe_devs[n].pdev->name,
			  (intmax_t)tsc->stripe_devs[n].offset);
		len = strlen(ptr);
		ptr += len;
		nlen -= len;
	}

	return params;
}
Example #2
0
/* Convert a struct sockaddr from binary to ASCII */
static int
ng_ksocket_sockaddr_unparse(const struct ng_parse_type *type,
	const u_char *data, int *off, char *cbuf, int cbuflen)
{
	const struct sockaddr *sa = (const struct sockaddr *)(data + *off);
	int slen = 0;

	/* Output socket address, either in special or generic format */
	switch (sa->sa_family) {
	case PF_LOCAL:
	    {
		const int pathoff = OFFSETOF(struct sockaddr_un, sun_path);
		const struct sockaddr_un *sun = (const struct sockaddr_un *)sa;
		const int pathlen = sun->sun_len - pathoff;
		char pathbuf[SOCK_MAXADDRLEN + 1];
		char *pathtoken;

		bcopy(sun->sun_path, pathbuf, pathlen);
		if ((pathtoken = ng_encode_string(pathbuf, pathlen)) == NULL)
			return (ENOMEM);
		slen += ksnprintf(cbuf, cbuflen, "local/%s", pathtoken);
		kfree(pathtoken, M_NETGRAPH_KSOCKET);
		if (slen >= cbuflen)
			return (ERANGE);
		*off += sun->sun_len;
		return (0);
	    }

	case PF_INET:
	    {
		const struct sockaddr_in *sin = (const struct sockaddr_in *)sa;

		slen += ksnprintf(cbuf, cbuflen, "inet/%d.%d.%d.%d",
		  ((const u_char *)&sin->sin_addr)[0],
		  ((const u_char *)&sin->sin_addr)[1],
		  ((const u_char *)&sin->sin_addr)[2],
		  ((const u_char *)&sin->sin_addr)[3]);
		if (sin->sin_port != 0) {
			slen += ksnprintf(cbuf + strlen(cbuf),
			    cbuflen - strlen(cbuf), ":%d",
			    (u_int)ntohs(sin->sin_port));
		}
		if (slen >= cbuflen)
			return (ERANGE);
		*off += sizeof(*sin);
		return(0);
	    }

#if 0
	case PF_INET6:
	case PF_IPX:
#endif

	default:
		return (*ng_ksocket_generic_sockaddr_type.supertype->unparse)
		    (&ng_ksocket_generic_sockaddr_type,
		    data, off, cbuf, cbuflen);
	}
}
Example #3
0
void
ipx_printhost(struct ipx_addr *addr)
{
	u_short port;
	struct ipx_addr work = *addr;
	char *p; u_char *q;
	char *net = "", *host = "";
	char cport[10], chost[15], cnet[15];

	port = ntohs(work.x_port);

	if (ipx_nullnet(work) && ipx_nullhost(work)) {

		if (port)
			kprintf("*.%x", port);
		else
			kprintf("*.*");

		return;
	}

	if (ipx_wildnet(work))
		net = "any";
	else if (ipx_nullnet(work))
		net = "*";
	else {
		q = work.x_net.c_net;
		ksnprintf(cnet, sizeof(cnet), "%x%x%x%x",
			q[0], q[1], q[2], q[3]);
		for (p = cnet; *p == '0' && p < cnet + 8; p++)
			continue;
		net = p;
	}

	if (ipx_wildhost(work))
		host = "any";
	else if (ipx_nullhost(work))
		host = "*";
	else {
		q = work.x_host.c_host;
		ksnprintf(chost, sizeof(chost), "%x%x%x%x%x%x",
			q[0], q[1], q[2], q[3], q[4], q[5]);
		for (p = chost; *p == '0' && p < chost + 12; p++)
			continue;
		host = p;
	}

	if (port) {
		if (strcmp(host, "*") == 0) {
			host = "";
			ksnprintf(cport, sizeof(cport), "%x", port);
		} else
			ksnprintf(cport, sizeof(cport), ".%x", port);
	} else
		*cport = 0;

	kprintf("%s.%s%s", net, host, cport);
}
Example #4
0
void
it_setup_volt(struct it_softc *sc, int start, int n)
{
	int i;

	for (i = 0; i < n; ++i) {
		sc->sensors[start + i].type = SENSOR_VOLTS_DC;
	}

	ksnprintf(sc->sensors[start + 0].desc, sizeof(sc->sensors[0].desc),
	    "VCORE_A");
	ksnprintf(sc->sensors[start + 1].desc, sizeof(sc->sensors[1].desc),
	    "VCORE_B");
	ksnprintf(sc->sensors[start + 2].desc, sizeof(sc->sensors[2].desc),
	    "+3.3V");
	ksnprintf(sc->sensors[start + 3].desc, sizeof(sc->sensors[3].desc),
	    "+5V");
	ksnprintf(sc->sensors[start + 4].desc, sizeof(sc->sensors[4].desc),
	    "+12V");
	ksnprintf(sc->sensors[start + 5].desc, sizeof(sc->sensors[5].desc),
	    "Unused");
	ksnprintf(sc->sensors[start + 6].desc, sizeof(sc->sensors[6].desc),
	    "-12V");
	ksnprintf(sc->sensors[start + 7].desc, sizeof(sc->sensors[7].desc),
	    "+5VSB");
	ksnprintf(sc->sensors[start + 8].desc, sizeof(sc->sensors[8].desc),
	    "VBAT");
}
Example #5
0
int
uhub_child_pnpinfo_str(device_t cbdev, device_t child, char *buf,
    size_t buflen)
{
	struct uhub_softc *sc = device_get_softc(cbdev);
	usbd_device_handle devhub = sc->sc_hub;
	usbd_device_handle dev;
	struct usbd_interface *iface;
	char serial[128];
	int nports;
	int port;
	int i;

	crit_enter();
	nports = devhub->hub->hubdesc.bNbrPorts;
	for (port = 0; port < nports; port++) {
		dev = devhub->hub->ports[port].device;
		if (dev && dev->subdevs) {
			for (i = 0; dev->subdevs[i]; i++) {
				if (dev->subdevs[i] == child) {
					goto found_dev;
				}
			}
		}
	}
	DPRINTFN(0,("uhub_child_pnpinfo_str: device not on hub\n"));
	buf[0] = '\0';
	crit_exit();
	return (0);

found_dev:
	/* XXX can sleep */
	(void)usbd_get_string(dev, dev->ddesc.iSerialNumber, &serial[0]);
	if (dev->ifacenums == NULL) {
		ksnprintf(buf, buflen, "vendor=0x%04x product=0x%04x "
		    "devclass=0x%02x devsubclass=0x%02x "
		    "release=0x%04x sernum=\"%s\"",
		    UGETW(dev->ddesc.idVendor), UGETW(dev->ddesc.idProduct),
		    dev->ddesc.bDeviceClass, dev->ddesc.bDeviceSubClass,
		    UGETW(dev->ddesc.bcdDevice), serial);
	} else {
		iface = &dev->ifaces[dev->ifacenums[i]];
		ksnprintf(buf, buflen, "vendor=0x%04x product=0x%04x "
		    "devclass=0x%02x devsubclass=0x%02x "
		    "release=0x%04x sernum=\"%s\" "
		    "intclass=0x%02x intsubclass=0x%02x",
		    UGETW(dev->ddesc.idVendor), UGETW(dev->ddesc.idProduct),
		    dev->ddesc.bDeviceClass, dev->ddesc.bDeviceSubClass,
		    UGETW(dev->ddesc.bcdDevice), serial,
		    iface->idesc->bInterfaceClass,
		    iface->idesc->bInterfaceSubClass);
	}
	crit_exit();
	return (0);
}
Example #6
0
/*
 * Look up a linker set on an ELF system.
 */
static int
link_elf_lookup_set(linker_file_t lf, const char *name,
		    void ***startp, void ***stopp, int *countp)
{
    c_linker_sym_t  sym;
    linker_symval_t symval;
    char           *setsym;
    void          **start, **stop;
    int		    len, error = 0, count;

    len = strlen(name) + sizeof("__start_set_");	/* sizeof includes \0 */
    setsym = kmalloc(len, M_LINKER, M_WAITOK);

    /* get address of first entry */
    ksnprintf(setsym, len, "%s%s", "__start_set_", name);
    error = link_elf_lookup_symbol(lf, setsym, &sym);
    if (error)
	goto out;
    link_elf_symbol_values(lf, sym, &symval);
    if (symval.value == NULL) {
	error = ESRCH;
	goto out;
    }
    start = (void **)symval.value;

    /* get address of last entry */
    ksnprintf(setsym, len, "%s%s", "__stop_set_", name);
    error = link_elf_lookup_symbol(lf, setsym, &sym);
    if (error)
	goto out;
    link_elf_symbol_values(lf, sym, &symval);
    if (symval.value == NULL) {
	error = ESRCH;
	goto out;
    }
    stop = (void **)symval.value;

    /* and the number of entries */
    count = stop - start;

    /* and copy out */
    if (startp)
	*startp = start;
    if (stopp)
	*stopp = stop;
    if (countp)
	*countp = count;

out:
    kfree(setsym, M_LINKER);
    return error;
}
Example #7
0
/*
 * Create the OS-specific port helper thread and per-port lock.
 */
void
ahci_os_start_port(struct ahci_port *ap)
{
	char name[16];

	atomic_set_int(&ap->ap_signal, AP_SIGF_INIT | AP_SIGF_THREAD_SYNC);
	lockinit(&ap->ap_lock, "ahcipo", 0, 0);
	lockinit(&ap->ap_sim_lock, "ahcicam", 0, LK_CANRECURSE);
	lockinit(&ap->ap_sig_lock, "ahport", 0, 0);
	sysctl_ctx_init(&ap->sysctl_ctx);
	ksnprintf(name, sizeof(name), "%d", ap->ap_num);
	ap->sysctl_tree = SYSCTL_ADD_NODE(&ap->sysctl_ctx,
				SYSCTL_CHILDREN(ap->ap_sc->sysctl_tree),
				OID_AUTO, name, CTLFLAG_RD, 0, "");

	if ((ap->ap_sc->sc_cap & AHCI_REG_CAP_SALP) &&
	    (ap->ap_sc->sc_cap & (AHCI_REG_CAP_PSC | AHCI_REG_CAP_SSC))) {
		SYSCTL_ADD_PROC(&ap->sysctl_ctx,
			SYSCTL_CHILDREN(ap->sysctl_tree), OID_AUTO,
			"link_pwr_mgmt", CTLTYPE_INT | CTLFLAG_RW, ap, 0,
			ahci_sysctl_link_pwr_mgmt, "I",
			"Link power management policy "
			"(0 = disabled, 1 = medium, 2 = aggressive)");
		SYSCTL_ADD_PROC(&ap->sysctl_ctx,
			SYSCTL_CHILDREN(ap->sysctl_tree), OID_AUTO,
			"link_pwr_state", CTLTYPE_STRING | CTLFLAG_RD, ap, 0,
			ahci_sysctl_link_pwr_state, "A",
			"Link power management state");

	}

	kthread_create(ahci_port_thread, ap, &ap->ap_thread,
		       "%s", PORTNAME(ap));
}
Example #8
0
static int
acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS)
{
    struct	acpi_cpu_softc *sc;
    char	state[8];
    int		val, error, i;

    ksnprintf(state, sizeof(state), "C%d", cpu_cx_lowest + 1);
    error = sysctl_handle_string(oidp, state, sizeof(state), req);
    if (error != 0 || req->newptr == NULL)
	return (error);
    if (strlen(state) < 2 || toupper(state[0]) != 'C')
	return (EINVAL);
    val = (int) strtol(state + 1, NULL, 10) - 1;
    if (val < 0 || val > cpu_cx_count - 1)
	return (EINVAL);
    cpu_cx_lowest = val;

    /* Update the new lowest useable Cx state for all CPUs. */
    crit_enter();
    for (i = 0; i < cpu_ndevices; i++) {
	sc = device_get_softc(cpu_devices[i]);
	error = acpi_cpu_set_cx_lowest(sc, val);
	if (error) {
	    KKASSERT(i == 0);
	    break;
	}
    }
    crit_exit();

    return error;
}
Example #9
0
char *
adv_name(struct adv_softc *adv)
{
	static char name[10];

	ksnprintf(name, sizeof(name), "adv%d", adv->unit);
	return (name);
}
Example #10
0
static char *
mpt_scsi_state(int code)
{
    const struct Error_Map *status = IOC_SCSIState;
    static char buf[128];
    char *ptr = buf;
    char *end = &buf[128];
    buf[0] = '\0';
    ptr += ksnprintf(buf, sizeof buf, "(0x%08x)", code);
    while (status->Error_Code >= 0) {
        if ((status->Error_Code & code) != 0)
            ptr += ksnprintf(ptr, (size_t)(end-ptr), "%s ",
                             status->Error_String);
        status++;
    }
    return buf;
}
/**
 * drm_mode_set_name - set the name on a mode
 * @mode: name will be set in this mode
 *
 * LOCKING:
 * None.
 *
 * Set the name of @mode to a standard format.
 */
void drm_mode_set_name(struct drm_display_mode *mode)
{
	bool interlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);

	ksnprintf(mode->name, DRM_DISPLAY_MODE_LEN, "%dx%d%s",
		 mode->hdisplay, mode->vdisplay,
		 interlaced ? "i" : "");
}
Example #12
0
static int
acpi_cst_global_lowest_use_sysctl(SYSCTL_HANDLER_ARGS)
{
    char	state[8];

    ksnprintf(state, sizeof(state), "C%d", acpi_cst_cx_lowest + 1);
    return sysctl_handle_string(oidp, state, sizeof(state), req);
}
Example #13
0
static int
ioapic_abi_gsi_cpuid(int irq, int gsi)
{
	char envpath[32];
	int cpuid = -1;

	KKASSERT(gsi >= 0);

	if (irq == 0 || gsi == 0) {
		KKASSERT(irq >= 0);
		if (bootverbose) {
			kprintf("IOAPIC: irq %d, gsi %d -> cpu0 (0)\n",
			    irq, gsi);
		}
		return 0;
	}

	if (irq >= 0 && irq == acpi_sci_irqno()) {
		if (bootverbose) {
			kprintf("IOAPIC: irq %d, gsi %d -> cpu0 (sci)\n",
			    irq, gsi);
		}
		return 0;
	}

	ksnprintf(envpath, sizeof(envpath), "hw.ioapic.gsi.%d.cpu", gsi);
	kgetenv_int(envpath, &cpuid);

	if (cpuid < 0) {
		if (!ioapic_abi_gsi_balance) {
			if (irq >= 0 && bootverbose) {
				kprintf("IOAPIC: irq %d, gsi %d -> cpu0 "
				    "(fixed)\n", irq, gsi);
			}
			return 0;
		}

		cpuid = gsi % ncpus;
		if (irq >= 0 && bootverbose) {
			kprintf("IOAPIC: irq %d, gsi %d -> cpu%d (auto)\n",
			    irq, gsi, cpuid);
		}
	} else if (cpuid >= ncpus) {
		cpuid = ncpus - 1;
		if (irq >= 0 && bootverbose) {
			kprintf("IOAPIC: irq %d, gsi %d -> cpu%d (fixup)\n",
			    irq, gsi, cpuid);
		}
	} else {
		if (irq >= 0 && bootverbose) {
			kprintf("IOAPIC: irq %d, gsi %d -> cpu%d (user)\n",
			    irq, gsi, cpuid);
		}
	}
	return cpuid;
}
Example #14
0
static int
acpi_cst_lowest_use_sysctl(SYSCTL_HANDLER_ARGS)
{
    struct	 acpi_cst_softc *sc;
    char	 state[8];

    sc = (struct acpi_cst_softc *)arg1;
    ksnprintf(state, sizeof(state), "C%d", sc->cst_cx_lowest + 1);
    return sysctl_handle_string(oidp, state, sizeof(state), req);
}
Example #15
0
/*
 * Reconnect using the passed file pointer.  The caller must ref the
 * fp for us.
 */
void
hammer2_cluster_reconnect(hammer2_dev_t *hmp, struct file *fp)
{
	/*
	 * Closes old comm descriptor, kills threads, cleans up
	 * states, then installs the new descriptor and creates
	 * new threads.
	 */
	kdmsg_iocom_reconnect(&hmp->iocom, fp, "hammer2");

	/*
	 * Setup LNK_CONN fields for autoinitiated state machine.  LNK_CONN
	 * does not have to be unique.  peer_id can be used to filter incoming
	 * LNK_SPANs automatically if desired (though we still need to check).
	 * peer_label typically identifies who we are and is not a filter.
	 *
	 * Since we will be initiating multiple LNK_SPANs we cannot use
	 * AUTOTXSPAN, but we do use AUTORXSPAN so kdmsg tracks received
	 * LNK_SPANs, and we simply monitor those messages.
	 */
	bzero(&hmp->iocom.auto_lnk_conn.peer_id,
	      sizeof(hmp->iocom.auto_lnk_conn.peer_id));
	/* hmp->iocom.auto_lnk_conn.peer_id = hmp->voldata.fsid; */
	hmp->iocom.auto_lnk_conn.proto_version = DMSG_SPAN_PROTO_1;
#if 0
	hmp->iocom.auto_lnk_conn.peer_type = hmp->voldata.peer_type;
#endif
	hmp->iocom.auto_lnk_conn.peer_type = DMSG_PEER_HAMMER2;

	/*
	 * We just want to receive LNK_SPANs related to HAMMER2 matching
	 * peer_id.
	 */
	hmp->iocom.auto_lnk_conn.peer_mask = 1LLU << DMSG_PEER_HAMMER2;

#if 0
	switch (ipdata->meta.pfs_type) {
	case DMSG_PFSTYPE_CLIENT:
		hmp->iocom.auto_lnk_conn.peer_mask &=
				~(1LLU << DMSG_PFSTYPE_CLIENT);
		break;
	default:
		break;
	}
#endif

	bzero(&hmp->iocom.auto_lnk_conn.peer_label,
	      sizeof(hmp->iocom.auto_lnk_conn.peer_label));
	ksnprintf(hmp->iocom.auto_lnk_conn.peer_label,
		  sizeof(hmp->iocom.auto_lnk_conn.peer_label),
		  "%s/%s",
		  hostname, "hammer2-mount");
	kdmsg_iocom_autoinitiate(&hmp->iocom, hammer2_autodmsg);
}
Example #16
0
const char *
usbd_errstr(usbd_status err)
{
	static char buffer[5];

	if (err < USBD_ERROR_MAX) {
		return usbd_error_strs[err];
	} else {
		ksnprintf(buffer, sizeof buffer, "%d", err);
		return buffer;
	}
}
Example #17
0
static char *
mpt_ioc_event(int code)
{
    const struct Error_Map *status = IOC_Event;
    static char buf[64];
    while (status->Error_Code >= 0) {
        if (status->Error_Code == code)
            return status->Error_String;
        status++;
    }
    ksnprintf(buf, sizeof buf, "Unknown (0x%08x)", code);
    return buf;
}
Example #18
0
/*
 * Replacement for old '%z' kprintf format.
 */
void
db_format_hex(char *buf, size_t bufsiz, quad_t val, int altflag)
{
	/* Only use alternate form if val is nonzero. */
	const char *fmt = (altflag && val) ? "-%#qx" : "-%qx";

	if (val < 0)
		val = -val;
	else
		++fmt;

	ksnprintf(buf, bufsiz, fmt, val);
}
Example #19
0
static char *
mpt_ioc_status(int code)
{
    const struct Error_Map *status = IOC_Status;
    static char buf[64];
    while (status->Error_Code >= 0) {
        if (status->Error_Code == (code & MPI_IOCSTATUS_MASK))
            return status->Error_String;
        status++;
    }
    ksnprintf(buf, sizeof buf, "Unknown (0x%08x)", code);
    return buf;
}
Example #20
0
static char *
mpt_scsi_tm_type(int code)
{
    const struct Error_Map *status = IOC_SCSITMType;
    static char buf[64];
    while (status->Error_Code >= 0) {
        if (status->Error_Code == code)
            return status->Error_String;
        status++;
    }
    ksnprintf(buf, sizeof buf, "Unknown (0x%08x)", code);
    return buf;
}
Example #21
0
int
uhub_child_location_str(device_t cbdev, device_t child, char *buf,
    size_t buflen)
{
	struct uhub_softc *sc = device_get_softc(cbdev);
	usbd_device_handle devhub = sc->sc_hub;
	usbd_device_handle dev;
	int nports;
	int port;
	int i;

	crit_enter();
	nports = devhub->hub->hubdesc.bNbrPorts;
	for (port = 0; port < nports; port++) {
		dev = devhub->hub->ports[port].device;
		if (dev && dev->subdevs) {
			for (i = 0; dev->subdevs[i]; i++) {
				if (dev->subdevs[i] == child) {
					if (dev->ifacenums == NULL) {
						ksnprintf(buf, buflen,
						    "port=%i", port);
					} else {
						ksnprintf(buf, buflen,
						    "port=%i interface=%i",
						    port, dev->ifacenums[i]);
					}
					goto found_dev;
				}
			}
		}
	}
	DPRINTFN(0,("uhub_child_location_str: device not on hub\n"));
	buf[0] = '\0';
found_dev:
	crit_exit();
	return (0);
}
Example #22
0
static int
ahci_sysctl_link_pwr_state (SYSCTL_HANDLER_ARGS)
{
	struct ahci_port *ap = arg1;
	const char *state_names[] = {"unknown", "active", "partial", "slumber"};
	char buf[16];
	int state;

	state = ahci_port_link_pwr_state(ap);
	if (state < 0 || state >= NELEM(state_names))
		state = 0;

	ksnprintf(buf, sizeof(buf), "%s", state_names[state]);
	return sysctl_handle_string(oidp, buf, sizeof(buf), req);
}
Example #23
0
/*
 * readlink reads the link of `curproc' or `file'
 */
static int
procfs_readlink(struct vop_readlink_args *ap)
{
	char buf[16];		/* should be enough */
	struct proc *procp;
	struct vnode *vp = ap->a_vp;
	struct pfsnode *pfs = VTOPFS(vp);
	char *fullpath, *freepath;
	int error, len;

	switch (pfs->pfs_type) {
	case Pcurproc:
		if (pfs->pfs_fileno != PROCFS_FILENO(0, Pcurproc))
			return (EINVAL);

		len = ksnprintf(buf, sizeof(buf), "%ld", (long)curproc->p_pid);

		return (uiomove(buf, len, ap->a_uio));
	/*
	 * There _should_ be no way for an entire process to disappear
	 * from under us...
	 */
	case Pfile:
		procp = pfs_pfind(pfs->pfs_pid);
		if (procp == NULL || procp->p_ucred == NULL) {
			kprintf("procfs_readlink: pid %d disappeared\n",
			    pfs->pfs_pid);
			if (procp)
				PRELE(procp);
			return (uiomove("unknown", sizeof("unknown") - 1,
			    ap->a_uio));
		}
		error = cache_fullpath(procp, &procp->p_textnch, &fullpath, &freepath, 0);
		if (error != 0) {
			if (procp)
				PRELE(procp);
			return (uiomove("unknown", sizeof("unknown") - 1,
			    ap->a_uio));
		}
		error = uiomove(fullpath, strlen(fullpath), ap->a_uio);
		kfree(freepath, M_TEMP);
		if (procp)
			PRELE(procp);
		return (error);
	default:
		return (EINVAL);
	}
}
Example #24
0
void
lapic_timer_always(struct intrframe *frame)
{
#if 0
	globaldata_t gd = mycpu;
	int cpu = gd->gd_cpuid;
	char buf[64];
	short *gptr;
	int i;

	if (cpu <= 20) {
		gptr = (short *)0xFFFFFFFF800b8000 + 80 * cpu;
		*gptr = ((*gptr + 1) & 0x00FF) | 0x0700;
		++gptr;

		ksnprintf(buf, sizeof(buf), " %p %16s %d %16s ",
		    (void *)frame->if_rip, gd->gd_curthread->td_comm, ticks,
		    gd->gd_infomsg);
		for (i = 0; buf[i]; ++i) {
			gptr[i] = 0x0700 | (unsigned char)buf[i];
		}
	}
#if 0
	if (saveticks[gd->gd_cpuid] != ticks) {
		saveticks[gd->gd_cpuid] = ticks;
		savecounts[gd->gd_cpuid] = 0;
	}
	++savecounts[gd->gd_cpuid];
	if (savecounts[gd->gd_cpuid] > 2000 && panicstr == NULL) {
		panic("cpud %d panicing on ticks failure",
			gd->gd_cpuid);
	}
	for (i = 0; i < ncpus; ++i) {
		int delta;
		if (saveticks[i] && panicstr == NULL) {
			delta = saveticks[i] - ticks;
			if (delta < -10 || delta > 10) {
				panic("cpu %d panicing on cpu %d watchdog",
				      gd->gd_cpuid, i);
			}
		}
	}
#endif
#endif
}
Example #25
0
static void
poll_comm_init(int cpuid)
{
	struct poll_comm *comm;
	char cpuid_str[16];

	comm = kmalloc(sizeof(*comm), M_DEVBUF, M_WAITOK | M_ZERO);

	if (ifpoll_stfrac < 0)
		ifpoll_stfrac = IFPOLL_STFRAC_DEFAULT;
	if (ifpoll_txfrac < 0)
		ifpoll_txfrac = IFPOLL_TXFRAC_DEFAULT;

	comm->pollhz = ifpoll_pollhz;
	comm->poll_cpuid = cpuid;
	comm->poll_stfrac = ifpoll_stfrac;
	comm->poll_txfrac = ifpoll_txfrac;

	ksnprintf(cpuid_str, sizeof(cpuid_str), "%d", cpuid);

	sysctl_ctx_init(&comm->sysctl_ctx);
	comm->sysctl_tree = SYSCTL_ADD_NODE(&comm->sysctl_ctx,
			    SYSCTL_STATIC_CHILDREN(_net_ifpoll),
			    OID_AUTO, cpuid_str, CTLFLAG_RD, 0, "");

	SYSCTL_ADD_PROC(&comm->sysctl_ctx, SYSCTL_CHILDREN(comm->sysctl_tree),
			OID_AUTO, "pollhz", CTLTYPE_INT | CTLFLAG_RW,
			comm, 0, sysctl_pollhz,
			"I", "Device polling frequency");

	if (cpuid == 0) {
		SYSCTL_ADD_PROC(&comm->sysctl_ctx,
				SYSCTL_CHILDREN(comm->sysctl_tree),
				OID_AUTO, "status_frac",
				CTLTYPE_INT | CTLFLAG_RW,
				comm, 0, sysctl_stfrac,
				"I", "# of cycles before status is polled");
	}
	SYSCTL_ADD_PROC(&comm->sysctl_ctx, SYSCTL_CHILDREN(comm->sysctl_tree),
			OID_AUTO, "tx_frac", CTLTYPE_INT | CTLFLAG_RW,
			comm, 0, sysctl_txfrac,
			"I", "# of cycles before TX is polled");

	poll_common[cpuid] = comm;
}
Example #26
0
static int
dirfs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred)
{
	dirfs_mount_t dmp = VFS_TO_DIRFS(mp);
	struct statfs st;

	dbg(1, "called\n");

	if((statfs(dmp->dm_path, &st)) == -1)
		return errno;

	ksnprintf(st.f_mntfromname, MNAMELEN - 1, "dirfs@%s", dmp->dm_path);
	bcopy(&st, sbp, sizeof(st));
	strlcpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
	dbg(5, "iosize = %zd\n", sbp->f_iosize);

	return 0;
}
Example #27
0
/*
 * Status routine is called to get params string, which is target
 * specific. When dm_table_status_ioctl is called with flag
 * DM_STATUS_TABLE_FLAG I have to sent params string back.
 */
static char *
dm_target_linear_status(void *target_config)
{
	dm_target_linear_config_t *tlc;
	char *params;
	tlc = target_config;

	aprint_debug("Linear target status function called\n");

	/* target expects use of M_DM */
	params = kmalloc(DM_MAX_PARAMS_SIZE, M_DM, M_WAITOK);

	aprint_normal("%s %" PRIu64, tlc->pdev->name, tlc->offset);
	ksnprintf(params, DM_MAX_PARAMS_SIZE, "%s %" PRIu64,
	    tlc->pdev->name, tlc->offset);

	return params;
}
Example #28
0
/*
 * Retrieve version info.
 *
 * Load min_version, wip_version, and max_versino.  If cur_version is passed
 * as 0 then load the current version into cur_version.  Load the description
 * for cur_version into the description array.
 *
 * Returns 0 on success, EINVAL if cur_version is non-zero and set to an
 * unsupported value.
 */
static
int
hammer_ioc_get_version(hammer_transaction_t trans, hammer_inode_t ip,
		   struct hammer_ioc_version *ver)
{
	int error = 0;

	ver->min_version = HAMMER_VOL_VERSION_MIN;
	ver->wip_version = HAMMER_VOL_VERSION_WIP;
	ver->max_version = HAMMER_VOL_VERSION_MAX;
	if (ver->cur_version == 0)
		ver->cur_version = trans->hmp->version;
	switch(ver->cur_version) {
	case 1:
		ksnprintf(ver->description, sizeof(ver->description),
			 "First HAMMER release (DragonFly 2.0+)");
		break;
	case 2:
		ksnprintf(ver->description, sizeof(ver->description),
			 "New directory entry layout (DragonFly 2.3+)");
		break;
	case 3:
		ksnprintf(ver->description, sizeof(ver->description),
			 "New snapshot management (DragonFly 2.5+)");
		break;
	case 4:
		ksnprintf(ver->description, sizeof(ver->description),
			 "New undo/flush, faster flush/sync (DragonFly 2.5+)");
		break;
	case 5:
		ksnprintf(ver->description, sizeof(ver->description),
			 "Adjustments for dedup support (DragonFly 2.9+)");
		break;
	case 6:
		ksnprintf(ver->description, sizeof(ver->description),
			  "Directory Hash ALG1 (tmp/rename resistance)");
		break;
	default:
		ksnprintf(ver->description, sizeof(ver->description),
			 "Unknown");
		error = EINVAL;
		break;
	}
	return(error);
};
Example #29
0
static int
ahci_attach (device_t dev)
{
	struct ahci_softc *sc = device_get_softc(dev);
	char name[16];
	int error;

	sc->sc_ad = ahci_lookup_device(dev);
	if (sc->sc_ad == NULL)
		return(ENXIO);

	/*
	 * Some chipsets do not properly implement the AHCI spec and may
	 * require the link speed to be specifically requested.
	 */
	if (kgetenv("hint.ahci.force150"))
		AhciForceGen = 1;
	if (kgetenv("hint.ahci.force300"))
		AhciForceGen = 2;
	if (kgetenv("hint.ahci.force600"))
		AhciForceGen = 3;

	if (kgetenv("hint.ahci.nofeatures"))
		AhciNoFeatures = -1;

	if (kgetenv("hint.ahci.forcefbss"))
		sc->sc_flags |= AHCI_F_FORCE_FBSS;

	sysctl_ctx_init(&sc->sysctl_ctx);
	ksnprintf(name, sizeof(name), "%s%d",
		device_get_name(dev), device_get_unit(dev));
	sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
				SYSCTL_STATIC_CHILDREN(_hw),
				OID_AUTO, name, CTLFLAG_RD, 0, "");

	error = sc->sc_ad->ad_attach(dev);
	if (error) {
		sysctl_ctx_free(&sc->sysctl_ctx);
		sc->sysctl_tree = NULL;
	}
	return (error);
}
Example #30
0
void
ucom_set_pnpinfo_usb(struct ucom_super_softc *ssc, device_t dev)
{
	char buf[64];
	uint8_t iface_index;
	struct usb_attach_arg *uaa;

	ksnprintf(buf, sizeof(buf), "ttyname=" UCOM_TTY_PREFIX
	    "%d ttyports=%d", ssc->sc_unit, ssc->sc_subunits);

	/* Store the PNP info in the first interface for the device */
	uaa = device_get_ivars(dev);
	iface_index = uaa->info.bIfaceIndex;
    
	if (usbd_set_pnpinfo(uaa->device, iface_index, buf) != 0)
		device_printf(dev, "Could not set PNP info\n");

	/*
	 * The following information is also replicated in the PNP-info
	 * string which is registered above:
	 */
	if (ssc->sc_sysctl_ttyname == NULL) {
		/*
		ssc->sc_sysctl_ttyname = SYSCTL_ADD_STRING(NULL,
		    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
		    OID_AUTO, "ttyname", CTLFLAG_RD, ssc->sc_ttyname, 0,
		    "TTY device basename");
		*/
	}
	if (ssc->sc_sysctl_ttyports == NULL) {
		/*
		ssc->sc_sysctl_ttyports = SYSCTL_ADD_INT(NULL,
		    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
		    OID_AUTO, "ttyports", CTLFLAG_RD,
		    NULL, ssc->sc_subunits, "Number of ports");
		*/
	}
}