arch/um/drivers/rtc_user.c

Source file repositories/reference/linux-study-clean/arch/um/drivers/rtc_user.c

File Facts

System
Linux kernel
Corpus path
arch/um/drivers/rtc_user.c
Extension
.c
Size
1512 bytes
Lines
82
Domain
Architecture Layer
Bucket
arch/um
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if (uml_rtc_irq_fds[0] < 0) {
			err = -errno;
			goto fail;
		}

		/* apparently timerfd won't send SIGIO, use workaround */
		sigio_broken();
		err = add_sigio_fd(uml_rtc_irq_fds[0]);
		if (err < 0) {
			close(uml_rtc_irq_fds[0]);
			goto fail;
		}
	}

	return uml_rtc_irq_fds[0];
fail:
	uml_rtc_stop(timetravel);
	return err;
}

int uml_rtc_enable_alarm(unsigned long long delta_seconds)
{
	struct itimerspec it = {
		.it_value = {
			.tv_sec = delta_seconds,
		},
	};

	if (timerfd_settime(uml_rtc_irq_fds[0], 0, &it, NULL))
		return -errno;
	return 0;
}

void uml_rtc_disable_alarm(void)
{
	uml_rtc_enable_alarm(0);
}

void uml_rtc_stop(bool timetravel)
{
	if (timetravel)
		os_close_file(uml_rtc_irq_fds[1]);
	else
		ignore_sigio_fd(uml_rtc_irq_fds[0]);
	os_close_file(uml_rtc_irq_fds[0]);
}

Annotation

Implementation Notes