net: Use NULL to signal lack of promisc/multicast
[akaros.git] / kern / arch / riscv / time.c
index 637643c..c03b80e 100644 (file)
@@ -1,17 +1,16 @@
 #include <arch/time.h>
 #include <ros/common.h>
-#include <arch/trap.h>
+#include <trap.h>
 #include <arch/arch.h>
 #include <stdio.h>
 #include <assert.h>
-
-system_timing_t system_timing = {0};
+#include <ros/procinfo.h>
 
 void
 timer_init(void)
 {
-       system_timing.tsc_freq = TSC_HZ;
-       cprintf("TSC Frequency: %llu\n", system_timing.tsc_freq);
+       __proc_global_info.tsc_freq = TSC_HZ;
+       cprintf("TSC Frequency: %llu\n", __proc_global_info.tsc_freq);
 }
 
 void
@@ -23,32 +22,32 @@ set_core_timer(uint32_t usec, bool periodic)
 
        if (usec)
        {
-         uint32_t clocks =  (uint64_t)usec*TSC_HZ/1000000;
+               uint32_t clocks =  (uint64_t)usec*TSC_HZ/1000000;
 
-         int8_t irq_state = 0;
-         disable_irqsave(&irq_state);
+               int8_t irq_state = 0;
+               disable_irqsave(&irq_state);
 
-         mtpcr(PCR_COUNT, 0);
-         mtpcr(PCR_COMPARE, clocks);
-         mtpcr(PCR_SR, mfpcr(PCR_SR) | (1 << (TIMER_IRQ+SR_IM_SHIFT)));
+               mtpcr(PCR_COUNT, 0);
+               mtpcr(PCR_COMPARE, clocks);
+               mtpcr(PCR_SR, mfpcr(PCR_SR) | (1 << (IRQ_TIMER+SR_IM_SHIFT)));
 
-         enable_irqsave(&irq_state);
+               enable_irqsave(&irq_state);
        }
        else
        {
-         mtpcr(PCR_SR, mfpcr(PCR_SR) & ~(1 << (TIMER_IRQ+SR_IM_SHIFT)));
+               mtpcr(PCR_SR, mfpcr(PCR_SR) & ~(1 << (IRQ_TIMER+SR_IM_SHIFT)));
        }
 }
 
 void
 udelay(uint64_t usec)
 {
-       if (system_timing.tsc_freq != 0)
+       if (__proc_global_info.tsc_freq != 0)
        {
                uint64_t start, end, now;
-        
+
                start = read_tsc();
-               end = start + (system_timing.tsc_freq * usec) / 1000000;
+               end = start + (__proc_global_info.tsc_freq * usec) / 1000000;
 
                do
                {
@@ -58,3 +57,8 @@ udelay(uint64_t usec)
        }
        else panic("udelay() was called before timer_init(), moron!");
 }
+
+uint64_t read_persistent_clock(void)
+{
+       return 1242129600 * 1000000000UL; /* nanwan's birthday */
+}