Beispiel #1
0
int dirtio_mmio_out(struct dirtio_desc *dio, uint32_t port,
		    uint8_t queue, uint64_t val)
{
	int ret;

	ret = sys_out(dio->id, ((port << 8) | queue)  & ~PORT_DIRTIO_IN, val);
	return ret;
}
Beispiel #2
0
static ssize_t
rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t n)
{
	ssize_t retval;
	unsigned long now, alarm;
	struct rtc_wkalrm alm;
	struct rtc_device *rtc = to_rtc_device(dev);
	char *buf_ptr;
	int adjust = 0;
	 	printk("%s \n", __func__);
	/* Only request alarms that trigger in the future.  Disable them
	 * by writing another time, e.g. 0 meaning Jan 1 1970 UTC.
	 */
	retval = rtc_read_time(rtc, &alm.time);
	sys_out("retval is %d \n", retval);
	if (retval < 0)
		return retval;
	rtc_tm_to_time(&alm.time, &now);

	buf_ptr = (char *)buf;
	if (*buf_ptr == '+') {
		buf_ptr++;
		adjust = 1;
	}
	alarm = simple_strtoul(buf_ptr, NULL, 0);
	if (adjust) {
		alarm += now;
	}
	if (alarm > now) {
		/* Avoid accidentally clobbering active alarms; we can't
		 * entirely prevent that here, without even the minimal
		 * locking from the /dev/rtcN api.
		 */
		retval = rtc_read_alarm(rtc, &alm);
		if (retval < 0)
			return retval;
		if (alm.enabled)
			return -EBUSY;

		alm.enabled = 1;
	} else {
		alm.enabled = 0;

		/* Provide a valid future alarm time.  Linux isn't EFI,
		 * this time won't be ignored when disabling the alarm.
		 */
		alarm = now + 300;
	}
	rtc_time_to_tm(alarm, &alm.time);

	retval = rtc_set_alarm(rtc, &alm);
	printk("set_alarm retval: %d\n",retval);
	return (retval < 0) ? retval : n;
}
Beispiel #3
0
int dirtio_mmio_outw(struct dirtio_desc *dio, uint32_t port,
		     uint8_t queue, uint64_t val)
{
	int ret;
	unsigned fil;
	uintptr_t irq;
	uintptr_t udata;

	ret = sys_out(dio->id, ((port << 8) | queue)  & ~PORT_DIRTIO_IN, val);
	if (ret)
		return ret;
	drex_kqueue_wait(dio->kq, &fil, &irq, &udata, 0);
	return 0;
}
Beispiel #4
0
int dirtio_mmio_inw(struct dirtio_desc *dio, uint32_t port,
		    uint8_t queue, uint64_t *val)
{
	int ret;
	unsigned fil;
	uintptr_t irq;
	uintptr_t udata;

	ret = sys_out(dio->id, PORT_DIRTIO_IN | (port << 8) | queue, 0);
	if (ret)
		return ret;
	drex_kqueue_wait(dio->kq, &fil, &irq, &udata, 0);
	*val = dio->hdr->ioval;
	return 0;
}