Ejemplo n.º 1
0
int
pmsprobe(device_t parent, cfdata_t match, void *aux)
{
	struct pckbport_attach_args *pa = aux;
	u_char cmd[1], resp[2];
	int res;

	if (pa->pa_slot != PCKBPORT_AUX_SLOT)
		return 0;

	/* Flush any garbage. */
	pckbport_flush(pa->pa_tag, pa->pa_slot);

	/* reset the device */
	cmd[0] = PMS_RESET;
	res = pckbport_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 2, resp, 1);
	if (res) {
		aprint_debug("pmsprobe: reset error %d\n", res);
		return 0;
	}
	if (resp[0] != PMS_RSTDONE) {
		printf("pmsprobe: reset response 0x%x\n", resp[0]);
		return 0;
	}

	/* get type number (0 = mouse) */
	if (resp[1] != 0) {
		aprint_debug("pmsprobe: type 0x%x\n", resp[1]);
		return 0;
	}

	return 10;
}
Ejemplo n.º 2
0
int
pckbd_set_xtscancode(pckbport_tag_t kbctag, pckbport_slot_t kbcslot,
    struct pckbd_internal *id)
{
	int xt, res = 0;
	u_char cmd[2];

	/*
	 * Some keyboard/8042 combinations do not seem to work if the keyboard
	 * is set to table 1; in fact, it would appear that some keyboards just
	 * ignore the command altogether.  So by default, we use the AT scan
	 * codes and have the 8042 translate them.  Unfortunately, this is
	 * known to not work on some PS/2 machines.  We try desperately to deal
	 * with this by checking the (lack of a) translate bit in the 8042 and
	 * attempting to set the keyboard to XT mode.  If this all fails, well,
	 * tough luck.  If the PCKBC_CANT_TRANSLATE pckbc flag was set, we
	 * enable software translation.
	 *
	 * XXX It would perhaps be a better choice to just use AT scan codes
	 * and not bother with this.
	 */
	xt = pckbport_xt_translation(kbctag, kbcslot, 1);
	if (xt == 1) {
		/* The 8042 is translating for us; use AT codes. */
		cmd[0] = KBC_SETTABLE;
		cmd[1] = 2;
		res = pckbport_poll_cmd(kbctag, kbcslot, cmd, 2, 0, 0, 0);
		if (res) {
			u_char cmdb[1];
			aprint_debug("pckbd: error setting scanset 2\n");
			/*
			 * XXX at least one keyboard is reported to lock up
			 * if a "set table" is attempted, thus the "reset".
			 * XXX ignore errors, scanset 2 should be
			 * default anyway.
			 */
			cmdb[0] = KBC_RESET;
			(void)pckbport_poll_cmd(kbctag, kbcslot, cmdb, 1, 1, 0, 1);
			pckbport_flush(kbctag, kbcslot);
			res = 0;
		}
		if (id != NULL)
			id->t_translating = 1;
	} else if (xt == -1) {
		/* Software translation required */
		if (id != NULL)
			id->t_translating = 0;
	} else {
		/* Stupid 8042; set keyboard to XT codes. */
		cmd[0] = KBC_SETTABLE;
		cmd[1] = 1;
		res = pckbport_poll_cmd(kbctag, kbcslot, cmd, 2, 0, 0, 0);
		if (res)
			aprint_debug("pckbd: error setting scanset 1\n");
		if (id != NULL)
			id->t_translating = 1;
	}
	return res;
}
Ejemplo n.º 3
0
static int
pci_io_find(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t type,
    bus_addr_t *basep, bus_size_t *sizep, int *flagsp)
{
	pcireg_t address, mask;
	int s;

	if (reg < PCI_MAPREG_START ||
#if 0
	    /*
	     * Can't do this check; some devices have mapping registers
	     * way out in left field.
	     */
	    reg >= PCI_MAPREG_END ||
#endif
	    (reg & 3))
		panic("pci_io_find: bad request");

	/*
	 * Section 6.2.5.1, `Address Maps', tells us that:
	 *
	 * 1) The builtin software should have already mapped the device in a
	 * reasonable way.
	 *
	 * 2) A device which wants 2^n bytes of memory will hardwire the bottom
	 * n bits of the address to 0.  As recommended, we write all 1s and see
	 * what we get back.
	 */
	s = splhigh();
	address = pci_conf_read(pc, tag, reg);
	pci_conf_write(pc, tag, reg, 0xffffffff);
	mask = pci_conf_read(pc, tag, reg);
	pci_conf_write(pc, tag, reg, address);
	splx(s);

	if (PCI_MAPREG_TYPE(address) != PCI_MAPREG_TYPE_IO) {
		aprint_debug("pci_io_find: expected type i/o, found mem\n");
		return (1);
	}

	if (PCI_MAPREG_IO_SIZE(mask) == 0) {
		aprint_debug("pci_io_find: void region\n");
		return (1);
	}

	if (basep != 0)
		*basep = PCI_MAPREG_IO_ADDR(address);
	if (sizep != 0)
		*sizep = PCI_MAPREG_IO_SIZE(mask);
	if (flagsp != 0)
		*flagsp = 0;

	return (0);
}
Ejemplo n.º 4
0
static int
pciaddr_do_resource_allocate(pci_chipset_tag_t pc, pcitag_t tag,
    int mapreg, void *ctx, int type, bus_addr_t *addr, bus_size_t size)
{
 	struct pciaddr *pciaddrmap = (struct pciaddr *)ctx;
	bus_addr_t start;
	int error;
 	struct extent *ex;

	if (*addr != 0) /* no need to allocate */
		return 0;

 	ex = (type == PCI_MAPREG_TYPE_MEM ?
 	      pciaddrmap->extent_mem : pciaddrmap->extent_port);

	/* XXX Don't allocate if device is AGP device to avoid conflict. */
	if (device_is_agp(pc, tag))
		return 0;

	start = (type == PCI_MAPREG_TYPE_MEM ?
		 pciaddrmap->mem_alloc_start : pciaddrmap->port_alloc_start);

	if (start < ex->ex_start || start + size - 1 >= ex->ex_end) {
		aprint_debug("No available resources. fixup failed\n");
		return 1;
	}
	error = extent_alloc_subregion(ex, start, ex->ex_end, size,
				       size, 0,
				       EX_FAST|EX_NOWAIT|EX_MALLOCOK,
				       (u_long *)addr);
	if (error) {
		aprint_debug("No available resources. fixup failed\n");
		return 1;
	}

	/* write new address to PCI device configuration header */
	pci_conf_write(pc, tag, mapreg, *addr);
	/* check */
	aprint_debug("pci_addr_fixup: ");
	pciaddr_print_devid(pc, tag);
	if (pciaddr_ioaddr(pci_conf_read(pc, tag, mapreg)) != *addr) {
		pci_conf_write(pc, tag, mapreg, 0); /* clear */
		aprint_error("fixup failed. (new address=%#x)\n", (unsigned)*addr);
		return 1;
	}
	aprint_debug("new address 0x%08x\n", (unsigned)*addr);

	return 0;
}
Ejemplo n.º 5
0
/*
 * Close SCI
 */
static ACPI_STATUS
sci_close(struct valz_acpi_softc *sc)
{
	ACPI_STATUS rv;
	uint32_t result;

	rv = valz_acpi_hci_set(sc, SCI_CLOSE, 0, 0, &result);
	if (ACPI_FAILURE(rv)) {
		aprint_error("SCI: ACPI set error\n");
	} else {
		switch (result) {
		case SCI_OPENCLOSE_OK:
			aprint_debug("Closing SCI\n");
			break;
		case SCI_NOT_OPEN:
			aprint_error("SCI is not opened\n");
			break;
		case SCI_NOT_SUPPORTED:
			aprint_error("SCI is not supported\n");
			break;
		case SCI_NOT_PRESENT:
			aprint_error("SCI is not present\n");
			break;
		default:
			aprint_error("SCI: undefined behavior\n");
			break;
		}
	}

	return rv;
}
Ejemplo n.º 6
0
/*
 * valz_acpi_event:
 *
 *	Check hotkey event and do it, if event occur.
 */
static void
valz_acpi_event(void *arg)
{
	struct valz_acpi_softc *sc = arg;
	ACPI_STATUS rv;
	uint32_t value, result;

	for (;;) {
		rv = valz_acpi_hci_get(sc, HCI_GET, HCI_SYSTEM_EVENT_FIFO,
			&value, &result);
		if (ACPI_SUCCESS(rv) && result == 0) {
			switch (value) {
			case FN_F9_PRESS:
				valz_acpi_touchpad_toggle(sc);
				break;
			case FN_TAB_PRESS:
				valz_acpi_lcd_backlight_toggle(sc);
				break;

			default:
				/* Many unused buttons */
				aprint_debug("Pressed: 0x%x\n", value);
				break;
			}
		}
		if (ACPI_FAILURE(rv) || result == HCI_NOT_SUPPORTED ||
			result == HCI_FIFO_EMPTY)
			break;
	}
}
Ejemplo n.º 7
0
/*
 * Remove inactive table from device. Routines which work's with inactive tables
 * doesn't need to synchronise with dmstrategy. They can synchronise themselves with mutex?.
 *
 */
int
dm_table_clear_ioctl(prop_dictionary_t dm_dict)
{
	dm_dev_t *dmv;
	const char *name, *uuid;
	uint32_t flags, minor;

	dmv = NULL;
	name = NULL;
	uuid = NULL;
	flags = 0;
	minor = 0;

	prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
	prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
	prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
	prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);

	aprint_debug("Clearing inactive table from device: %s--%s\n",
	    name, uuid);

	if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
		DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
		return ENOENT;
	}
	/* Select unused table */
	dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE);

	atomic_clear_int(&dmv->flags, DM_INACTIVE_PRESENT_FLAG);

	dm_dev_unbusy(dmv);

	return 0;
}
Ejemplo n.º 8
0
static bool
pckbd_resume(device_t dv, const pmf_qual_t *qual)
{
	struct pckbd_softc *sc = device_private(dv);
	u_char cmd[1], resp[1];
	int res;

	/* XXX jmcneill reset the keyboard */
	pckbport_flush(sc->id->t_kbctag, sc->id->t_kbcslot);

	cmd[0] = KBC_RESET;
	res = pckbport_poll_cmd(sc->id->t_kbctag,
	    sc->id->t_kbcslot, cmd, 1, 1, resp, 1);
	if (res)
		aprint_debug("pckbdprobe: reset error %d\n", res);
	if (resp[0] != KBR_RSTDONE)
		printf("pckbdprobe: reset response 0x%x\n",
		    resp[0]);

	pckbport_flush(sc->id->t_kbctag, sc->id->t_kbcslot);

	pckbd_enable(sc, 1);

	return true;
}
Ejemplo n.º 9
0
/*
 * Destroy all table data. This function can run when there are no
 * readers on table lists.
 */
int
dm_table_destroy(dm_table_head_t * head, uint8_t table_id)
{
	dm_table_t *tbl;
	dm_table_entry_t *table_en;
	uint8_t id;

	lockmgr(&head->table_mtx, LK_EXCLUSIVE);

	aprint_debug("dm_Table_destroy called with %d--%d\n", table_id, head->io_cnt);

	if (table_id == DM_TABLE_ACTIVE)
		id = head->cur_active_table;
	else
		id = 1 - head->cur_active_table;

	tbl = &head->tables[id];

	while (!SLIST_EMPTY(tbl)) {	/* List Deletion. */
		table_en = SLIST_FIRST(tbl);
		/*
		 * Remove target specific config data. After successfull
		 * call table_en->target_config must be set to NULL.
		 */
		table_en->target->destroy(table_en);

		SLIST_REMOVE_HEAD(tbl, next);

		kfree(table_en, M_DM);
	}

	lockmgr(&head->table_mtx, LK_RELEASE);

	return 0;
}
Ejemplo n.º 10
0
int
bi_print(void *aux, const char *name)
{
	struct bi_attach_args *ba = aux;
	const struct bi_list *bl;
	u_int16_t nr;

	nr = bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0);
	for (bl = &bi_list[0]; bl->bl_nr; bl++)
		if (bl->bl_nr == nr)
			break;

	if (name) {
		if (bl->bl_nr == 0)
			aprint_normal("unknown device 0x%x", nr);
		else
			aprint_normal(bl->bl_name);
		aprint_normal(" at %s", name);
	}
	aprint_normal(" node %d", ba->ba_nodenr);
	if (bl->bl_havedriver & DT_VEC)
		aprint_normal(" vec %o", ba->ba_ivec & 511);
#ifdef DEBUG
	if (bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR) &&
	    bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR))
		aprint_debug(" [sadr %x eadr %x]",
		    bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR),
		    bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR));
#endif
	if (bl->bl_havedriver & DT_QUIET)
		aprint_normal("\n");
	return bl->bl_havedriver & DT_QUIET ? QUIET :
	    bl->bl_havedriver & DT_HAVDRV ? UNCONF : UNSUPP;
}
Ejemplo n.º 11
0
/*
 * Translate command sent from libdevmapper to func.
 */
static int
dm_cmd_to_fun(prop_dictionary_t dm_dict) {
	int i, r;
	prop_string_t command;
	
	r = 0;

	if ((command = prop_dictionary_get(dm_dict, DM_IOCTL_COMMAND)) == NULL)
		return EINVAL;

	for(i = 0; cmd_fn[i].cmd != NULL; i++)
		if (prop_string_equals_cstring(command, cmd_fn[i].cmd))
			break;

	if (!cmd_fn[i].allowed && 
	    (r = kauth_authorize_system(kauth_cred_get(),
	    KAUTH_SYSTEM_DEVMAPPER, 0, NULL, NULL, NULL)) != 0)
		return r;

	if (cmd_fn[i].cmd == NULL)
		return EINVAL;

	aprint_debug("ioctl %s called\n", cmd_fn[i].cmd);
	r = cmd_fn[i].fn(dm_dict);

	return r;
}
Ejemplo n.º 12
0
static int
dmclose(dev_t dev, int flags, int mode, struct lwp *l)
{

	aprint_debug("dm close routine called %" PRIu32 "\n", minor(dev));
	return 0;
}
Ejemplo n.º 13
0
/* Call apropriate ioctl handler function. */
static int
dm_ioctl_switch(u_long cmd)
{

	switch(cmd) {

	case NETBSD_DM_IOCTL:
		aprint_debug("dm NetBSD_DM_IOCTL called\n");
		break;
	default:
		 aprint_debug("dm unknown ioctl called\n");
		 return ENOTTY;
		 break; /* NOT REACHED */
	}

	 return 0;
}
Ejemplo n.º 14
0
void
pchbattach(struct device *parent, struct device *self, void *aux)
{
	struct pci_attach_args *pa = aux;
	char devinfo[256];
#if NAGP > 0
	struct agpbus_attach_args apa;
#endif
	volatile unsigned char *python;
	uint32_t v;
	
	aprint_normal("\n");

	/*
	 * All we do is print out a description.  Eventually, we
	 * might want to add code that does something that's
	 * possibly chipset-specific.
	 */

	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
	aprint_normal("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
	    PCI_REVISION(pa->pa_class));

	switch (PCI_VENDOR(pa->pa_id)) {
	case PCI_VENDOR_IBM:
		switch (PCI_PRODUCT(pa->pa_id)) {
		case PCI_PRODUCT_IBM_82660:
			ibm82660_print(pa, self);
			break;
		case PCI_PRODUCT_IBM_PYTHON:
			python = mapiodev(0xfeff6000, 0x60);
			v = 0x88b78e01; /* taken from linux */
			out32rb(python+0x30, v);
			v = in32rb(python+0x30);
			aprint_debug("Reset python reg 30 to 0x%x\n", v);
			break;
		}
		break;
	case PCI_VENDOR_MOT:
		switch (PCI_PRODUCT(pa->pa_id)) {
		case PCI_PRODUCT_MOT_MPC105:
			mpc105_print(pa, self);
			break;
		case PCI_PRODUCT_MOT_MPC106:
			mpc106_print(pa, self);
			break;
		}
		break;
	}

#if NAGP > 0
	if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP,
			       NULL, NULL) != 0) {
		apa.apa_pci_args = *pa;
		config_found_ia(self, "agpbus", &apa, agpbusprint);
	}
#endif /* NAGP */
}
Ejemplo n.º 15
0
/*
 * Get list of physical devices for active table.
 * Get dev_t from pdev vnode and insert it into cmd_array.
 *
 * XXX. This function is called from lvm2tools to get information
 *      about physical devices, too e.g. during vgcreate.
 */
int
dm_table_deps_ioctl(prop_dictionary_t dm_dict)
{
	dm_dev_t *dmv;
	dm_table_t *tbl;
	dm_table_entry_t *table_en;

	prop_array_t cmd_array;
	const char *name, *uuid;
	uint32_t flags, minor;

	int table_type;

	name = NULL;
	uuid = NULL;
	dmv = NULL;
	flags = 0;

	prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
	prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
	prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
	prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);

	/* create array for dev_t's */
	cmd_array = prop_array_create();

	if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
		DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
		return ENOENT;
	}
	prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
	prop_dictionary_set_cstring(dm_dict, DM_IOCTL_NAME, dmv->name);
	prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);

	aprint_debug("Getting table deps for device: %s\n", dmv->name);

	/*
	 * if DM_QUERY_INACTIVE_TABLE_FLAG is passed we need to query
	 * INACTIVE TABLE
	 */
	if (flags & DM_QUERY_INACTIVE_TABLE_FLAG)
		table_type = DM_TABLE_INACTIVE;
	else
		table_type = DM_TABLE_ACTIVE;

	tbl = dm_table_get_entry(&dmv->table_head, table_type);

	SLIST_FOREACH(table_en, tbl, next)
	    table_en->target->deps(table_en, cmd_array);

	dm_table_release(&dmv->table_head, table_type);
	dm_dev_unbusy(dmv);

	prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, cmd_array);
	prop_object_release(cmd_array);

	return 0;
}
Ejemplo n.º 16
0
static int
systm_aprint_debug(lua_State *L)
{
	const char *s;

	s = lua_tostring(L, -1);
	if (s)
		aprint_debug("%s", s);
	return 0;
}
Ejemplo n.º 17
0
void
pciaddr_print_devid(pci_chipset_tag_t pc, pcitag_t tag)
{
	int bus, device, function;
	pcireg_t id;

	id = pci_conf_read(pc, tag, PCI_ID_REG);
	pci_decompose_tag(pc, tag, &bus, &device, &function);
	aprint_debug("%03d:%02d:%d 0x%04x 0x%04x ", bus, device, function,
	       PCI_VENDOR(id), PCI_PRODUCT(id));
}
Ejemplo n.º 18
0
void
ssp_init(void)
{
	int s;

	aprint_debug("Initializing SSP: ");
	/*
	 * We initialize ssp here carefully:
	 *	1. after we got some entropy
	 *	2. without calling a function
	 */
	size_t i;
	long guard[__arraycount(__stack_chk_guard)];

	cprng_fast(guard, sizeof(guard));
	s = splhigh();
	for (i = 0; i < __arraycount(guard); i++)
		__stack_chk_guard[i] = guard[i];
	splx(s);
	for (i = 0; i < __arraycount(guard); i++)
		aprint_debug("%lx ", guard[i]);
	aprint_debug("\n");
}
Ejemplo n.º 19
0
/*
 * these are both bad jokes
 */
int
pckbdprobe(device_t parent, cfdata_t cf, void *aux)
{
	struct pckbport_attach_args *pa = aux;
	int res;
	u_char cmd[1], resp[1];

	/*
	 * XXX There are rumours that a keyboard can be connected
	 * to the aux port as well. For me, this didn't work.
	 * For further experiments, allow it if explicitly
	 * wired in the config file.
	 */
	if ((pa->pa_slot != PCKBPORT_KBD_SLOT) &&
	    (cf->cf_loc[PCKBPORTCF_SLOT] == PCKBPORTCF_SLOT_DEFAULT))
		return 0;

	/* Flush any garbage. */
	pckbport_flush(pa->pa_tag, pa->pa_slot);

	/* Reset the keyboard. */
	cmd[0] = KBC_RESET;
	res = pckbport_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 1, resp, 1);
	if (res) {
		aprint_debug("pckbdprobe: reset error %d\n", res);
		/*
		 * There is probably no keyboard connected.
		 * Let the probe succeed if the keyboard is used
		 * as console input - it can be connected later.
		 */
		return pckbd_is_console(pa->pa_tag, pa->pa_slot) ? 1 : 0;
	}
	if (resp[0] != KBR_RSTDONE) {
		printf("pckbdprobe: reset response 0x%x\n", resp[0]);
		return 0;
	}

	/*
	 * Some keyboards seem to leave a second ack byte after the reset.
	 * This is kind of stupid, but we account for them anyway by just
	 * flushing the buffer.
	 */
	pckbport_flush(pa->pa_tag, pa->pa_slot);

	if (pckbd_set_xtscancode(pa->pa_tag, pa->pa_slot, NULL))
		return 0;

	return 2;
}
Ejemplo n.º 20
0
/*
 * Dynamically set the start address for rbus.  This must be called
 * before rbus is initialized.  The start address should be determined
 * by the amount of installed memory.  Generally 1 GB has been found
 * to be a good value, but it fails on some Thinkpads (e.g. 2645-4AU),
 * for which 0.5 GB is a good value.  It also fails on (at least)
 * Thinkpads with 2GB of RAM, for which 2 GB is a good value.
 *
 * Thus, a general strategy of setting rbus_min_start to the amount of
 * memory seems in order.  However, the actually amount of memory is
 * generally slightly more than the amount found, e.g. 1014MB vs 1024,
 * or 2046 vs 2048.
 */
void
rbus_min_start_hint(psize_t ram)
{
#ifdef RBUS_MIN_START_FORCED
	aprint_debug("rbus: rbus_min_start from config at %#0" PRIxPADDR "\n",
	    rbus_min_start);
#else
        if (ram <= 192*1024*1024UL) {
		/*
		 * <= 192 MB, so try 0.5 GB.  This will work on
		 * Thinkpad 600E (2645-4AU), which fails at 1GB, and
		 * on some other older machines that may have trouble
		 * with addresses needing more than 20 bits.
		 */
		rbus_min_start = 512 * 1024 * 1024UL;
	}

	if (ram >= 1024*1024*1024UL) {
		/*
		 * > 1GB, so try 2 GB.
		 */
		rbus_min_start =  2 * 1024 * 1024 * 1024UL;
	}

	/* XXX Not tested in > 2 GB case. */
	if (ram > 2 * 1024*1024*1024UL) {
		/*
		 * > 2 GB, so try 3 GB.
		 */
		rbus_min_start =  3 * 1024 * 1024 * 1024UL;
	}

	aprint_debug("rbus: rbus_min_start set to %#0" PRIxPADDR "\n",
	   rbus_min_start);
#endif
}
Ejemplo n.º 21
0
int
pckbd_enable(void *v, int on)
{
	struct pckbd_softc *sc = v;
	int res;
	u_char cmd[1];

	if (on) {
		if (sc->sc_enabled) {
			aprint_debug("pckbd_enable: bad enable\n");
			return EBUSY;
		}

		pckbport_slot_enable(sc->id->t_kbctag, sc->id->t_kbcslot, 1);

		cmd[0] = KBC_ENABLE;
		res = pckbport_poll_cmd(sc->id->t_kbctag, sc->id->t_kbcslot,
					cmd, 1, 0, NULL, 0);
		if (res) {
			printf("pckbd_enable: command error\n");
			return (res);
		}

		res = pckbd_set_xtscancode(sc->id->t_kbctag,
					   sc->id->t_kbcslot, sc->id);
		if (res)
			return res;

		sc->sc_enabled = 1;
	} else {
		if (sc->id->t_isconsole)
			return EBUSY;

		cmd[0] = KBC_DISABLE;
		res = pckbport_enqueue_cmd(sc->id->t_kbctag, sc->id->t_kbcslot,
					cmd, 1, 0, 1, 0);
		if (res) {
			printf("pckbd_disable: command error\n");
			return res;
		}

		pckbport_slot_enable(sc->id->t_kbctag, sc->id->t_kbcslot, 0);

		sc->sc_enabled = 0;
	}

	return 0;
}
Ejemplo n.º 22
0
/*
 * Allocate target specific config data, and link them to table.
 * This function is called only when, flags is not READONLY and
 * therefore we can add things to pdev list. This should not a
 * problem because this routine is called only from dm_table_load_ioctl.
 * @argv[0] is name,
 * @argv[1] is physical data offset.
 */
static int
dm_target_linear_init(dm_dev_t * dmv, void **target_config, char *params)
{
	dm_target_linear_config_t *tlc;
	dm_pdev_t *dmp;

	char **ap, *argv[3];

	if (params == NULL)
		return EINVAL;

	/*
	 * Parse a string, containing tokens delimited by white space,
	 * into an argument vector
	 */
	for (ap = argv; ap < &argv[2] &&
	    (*ap = strsep(&params, " \t")) != NULL;) {
		if (**ap != '\0')
			ap++;
	}

	aprint_debug("Linear target init function called %s--%s!!\n",
	    argv[0], argv[1]);

	/* XXX: temp hack */
	if (argv[0] == NULL)
		return EINVAL;

	/* Insert dmp to global pdev list */
	if ((dmp = dm_pdev_insert(argv[0])) == NULL)
		return ENOENT;

	if ((tlc = kmalloc(sizeof(dm_target_linear_config_t), M_DMLINEAR, M_WAITOK))
	    == NULL)
		return ENOMEM;

	tlc->pdev = dmp;
	tlc->offset = 0;	/* default settings */

	/* Check user input if it is not leave offset as 0. */
	tlc->offset = atoi64(argv[1]);

	*target_config = tlc;

	dmv->dev_type = DM_LINEAR_DEV;

	return 0;
}
Ejemplo n.º 23
0
void
child_return(void *arg)
{
	lwp_t *l = arg;
	register_t rval[2];
	struct pcb *pcb = lwp_getpcb(l);
	ucontext_t *ucp = &pcb->pcb_userret_ucp;

	/* return value zero */
	rval[0] = 0;
	rval[1] = 0;
	md_syscall_set_returnargs(l, ucp, 0, rval);

	aprint_debug("child return! lwp %p\n", l);
	userret(l);
	ktrsysret(SYS_fork, 0, 0);
}
Ejemplo n.º 24
0
static int
dmioctl(struct dev_ioctl_args *ap)
{
	cdev_t dev = ap->a_head.a_dev;
	u_long cmd = ap->a_cmd;
	void *data = ap->a_data;

	int r, err;
	prop_dictionary_t dm_dict_in;

	err = r = 0;

	aprint_debug("dmioctl called\n");

	KKASSERT(data != NULL);

	if (( r = disk_ioctl_switch(dev, cmd, data)) == ENOTTY) {
		struct plistref *pref = (struct plistref *) data;

		/* Check if we were called with NETBSD_DM_IOCTL ioctl
		   otherwise quit. */
		if ((r = dm_ioctl_switch(cmd)) != 0)
			return r;

		if((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in)) != 0)
			return r;

		if ((r = dm_check_version(dm_dict_in)) != 0)
			goto cleanup_exit;

		/* run ioctl routine */
		if ((err = dm_cmd_to_fun(dm_dict_in)) != 0)
			goto cleanup_exit;

cleanup_exit:
		r = prop_dictionary_copyout_ioctl(pref, cmd, dm_dict_in);
		prop_object_release(dm_dict_in);
	}

	/*
	 * Return the error of the actual command if one one has
	 * happened. Otherwise return 'r' which indicates errors
	 * that occurred during helper operations.
	 */
	return (err != 0)?err:r;
}
Ejemplo n.º 25
0
int
wbsio_probe(device_t parent, cfdata_t match, void *aux)
{
	struct isa_attach_args *ia = aux;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	uint8_t reg;

	/* Must supply an address */
	if (ia->ia_nio < 1)
		return 0;

	if (ISA_DIRECT_CONFIG(ia))
		return 0;

	if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
		return 0;

	/* Match by device ID */
	iot = ia->ia_iot;
	if (bus_space_map(iot, ia->ia_io[0].ir_addr, WBSIO_IOSIZE, 0, &ioh))
		return 0;
	wbsio_conf_enable(iot, ioh);
	reg = wbsio_conf_read(iot, ioh, WBSIO_ID);
	aprint_debug("wbsio_probe: id 0x%02x\n", reg);
	wbsio_conf_disable(iot, ioh);
	bus_space_unmap(iot, ioh, WBSIO_IOSIZE);
	switch (reg) {
	case WBSIO_ID_W83627HF:
	case WBSIO_ID_W83627THF:
	case WBSIO_ID_W83627EHF:
	case WBSIO_ID_W83627DHG:
	case WBSIO_ID_W83637HF:
	case WBSIO_ID_W83697HF:
	case WBSIO_ID_NCT6776F:
		ia->ia_nio = 1;
		ia->ia_io[0].ir_size = WBSIO_IOSIZE;
		ia->ia_niomem = 0;
		ia->ia_nirq = 0;
		ia->ia_ndrq = 0;
		return 1;
	}

	return 0;
}
Ejemplo n.º 26
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;
}
Ejemplo n.º 27
0
int
gpioiic_match(device_t parent, cfdata_t cf, void *aux)
{
	struct gpio_attach_args *ga = aux;

	if (strcmp(ga->ga_dvname, cf->cf_name))
		return 0;

	if (ga->ga_offset == -1)
		return 0;

	/* Check that we have enough pins */
	if (gpio_npins(ga->ga_mask) != GPIOIIC_NPINS) {
		aprint_debug("%s: invalid pin mask 0x%02x\n", cf->cf_name,
		    ga->ga_mask);
		return 0;
	}
	return 1;
}
Ejemplo n.º 28
0
static int
dmclose(struct dev_close_args *ap)
{
	cdev_t dev = ap->a_head.a_dev;
	dm_dev_t *dmv;

	/* Shortcut for the control device */
	if (minor(dev) == 0)
		return 0;

	if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
		return ENXIO;

	dmv->is_open = 0;
	dm_dev_unbusy(dmv);

	aprint_debug("dm close routine called %" PRIu32 "\n",
	    minor(ap->a_head.a_dev));
	return 0;
}
Ejemplo n.º 29
0
int
gpiopwm_match(device_t parent, cfdata_t cf,
    void *aux)
{
	struct gpio_attach_args *ga = aux;

	if (strcmp(ga->ga_dvname, cf->cf_name))
		return 0;

	if (ga->ga_offset == -1)
		return 0;

	/* Check number of pins, must be 1 */
	if (gpio_npins(ga->ga_mask) != GPIOPWM_NPINS) {
		aprint_debug("%s: invalid pin mask 0x%02x\n", cf->cf_name,
		    ga->ga_mask);
		return 0;
	}
	return 1;
}
Ejemplo n.º 30
0
void
ath_cardbus_setup(struct ath_cardbus_softc *csc)
{
	cardbus_devfunc_t ct = csc->sc_ct;
	cardbus_chipset_tag_t cc = ct->ct_cc;
	cardbus_function_tag_t cf = ct->ct_cf;
	int rc;
	pcireg_t reg;

	if ((rc = cardbus_set_powerstate(ct, csc->sc_tag, PCI_PWR_D0)) != 0)
		aprint_debug("%s: cardbus_set_powerstate %d\n", __func__, rc);

	/* Program the BAR. */
	cardbus_conf_write(cc, cf, csc->sc_tag, ATH_PCI_MMBA, csc->sc_bar_val);

	/* Enable the appropriate bits in the PCI CSR. */
	reg = cardbus_conf_read(cc, cf, csc->sc_tag,
	    PCI_COMMAND_STATUS_REG);
	reg |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_MEM_ENABLE;
	cardbus_conf_write(cc, cf, csc->sc_tag, PCI_COMMAND_STATUS_REG, reg);
}