~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/um/kernel/time.c

Version: ~ [ linux-6.1-rc7 ] ~ [ linux-6.0.10 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.80 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.156 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.225 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.267 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.300 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.334 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3  * Licensed under the GPL
  4  */
  5 
  6 #include <linux/clockchips.h>
  7 #include <linux/init.h>
  8 #include <linux/interrupt.h>
  9 #include <linux/jiffies.h>
 10 #include <linux/threads.h>
 11 #include <asm/irq.h>
 12 #include <asm/param.h>
 13 #include <kern_util.h>
 14 #include <os.h>
 15 
 16 void timer_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
 17 {
 18         unsigned long flags;
 19 
 20         local_irq_save(flags);
 21         do_IRQ(TIMER_IRQ, regs);
 22         local_irq_restore(flags);
 23 }
 24 
 25 static void itimer_set_mode(enum clock_event_mode mode,
 26                             struct clock_event_device *evt)
 27 {
 28         switch (mode) {
 29         case CLOCK_EVT_MODE_PERIODIC:
 30                 set_interval();
 31                 break;
 32 
 33         case CLOCK_EVT_MODE_SHUTDOWN:
 34         case CLOCK_EVT_MODE_UNUSED:
 35         case CLOCK_EVT_MODE_ONESHOT:
 36                 disable_timer();
 37                 break;
 38 
 39         case CLOCK_EVT_MODE_RESUME:
 40                 break;
 41         }
 42 }
 43 
 44 static int itimer_next_event(unsigned long delta,
 45                              struct clock_event_device *evt)
 46 {
 47         return timer_one_shot(delta + 1);
 48 }
 49 
 50 static struct clock_event_device itimer_clockevent = {
 51         .name           = "itimer",
 52         .rating         = 250,
 53         .cpumask        = cpu_all_mask,
 54         .features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
 55         .set_mode       = itimer_set_mode,
 56         .set_next_event = itimer_next_event,
 57         .shift          = 32,
 58         .irq            = 0,
 59 };
 60 
 61 static irqreturn_t um_timer(int irq, void *dev)
 62 {
 63         (*itimer_clockevent.event_handler)(&itimer_clockevent);
 64 
 65         return IRQ_HANDLED;
 66 }
 67 
 68 static cycle_t itimer_read(struct clocksource *cs)
 69 {
 70         return os_nsecs() / 1000;
 71 }
 72 
 73 static struct clocksource itimer_clocksource = {
 74         .name           = "itimer",
 75         .rating         = 300,
 76         .read           = itimer_read,
 77         .mask           = CLOCKSOURCE_MASK(64),
 78         .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 79 };
 80 
 81 static void __init setup_itimer(void)
 82 {
 83         int err;
 84 
 85         err = request_irq(TIMER_IRQ, um_timer, 0, "timer", NULL);
 86         if (err != 0)
 87                 printk(KERN_ERR "register_timer : request_irq failed - "
 88                        "errno = %d\n", -err);
 89 
 90         itimer_clockevent.mult = div_sc(HZ, NSEC_PER_SEC, 32);
 91         itimer_clockevent.max_delta_ns =
 92                 clockevent_delta2ns(60 * HZ, &itimer_clockevent);
 93         itimer_clockevent.min_delta_ns =
 94                 clockevent_delta2ns(1, &itimer_clockevent);
 95         err = clocksource_register_hz(&itimer_clocksource, USEC_PER_SEC);
 96         if (err) {
 97                 printk(KERN_ERR "clocksource_register_hz returned %d\n", err);
 98                 return;
 99         }
100         clockevents_register_device(&itimer_clockevent);
101 }
102 
103 void read_persistent_clock(struct timespec *ts)
104 {
105         long long nsecs = os_nsecs();
106 
107         set_normalized_timespec(ts, nsecs / NSEC_PER_SEC,
108                                 nsecs % NSEC_PER_SEC);
109 }
110 
111 void __init time_init(void)
112 {
113         timer_init();
114         late_time_init = setup_itimer;
115 }
116 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp