1 /* 2 ** Copyright 2001, Travis Geiselbrecht. All rights reserved. 3 ** Distributed under the terms of the NewOS License. 4 */ 5 6 7 #include <boot/stage2.h> 8 #include <kernel.h> 9 #include <debug.h> 10 11 #include <timer.h> 12 #include <arch/timer.h> 13 14 15 static bigtime_t sTickRate; 16 17 18 void arch_timer_set_hardware_timer(bigtime_t timeout)19arch_timer_set_hardware_timer(bigtime_t timeout) 20 { 21 bigtime_t new_val_64; 22 23 if(timeout < 1000) 24 timeout = 1000; 25 26 new_val_64 = (timeout * sTickRate) / 1000000; 27 28 asm("mtdec %0" :: "r"((uint32)new_val_64)); 29 } 30 31 32 void arch_timer_clear_hardware_timer()33arch_timer_clear_hardware_timer() 34 { 35 asm("mtdec %0" :: "r"(0x7fffffff)); 36 } 37 38 39 int arch_init_timer(kernel_args * ka)40arch_init_timer(kernel_args *ka) 41 { 42 sTickRate = ka->arch_args.time_base_frequency; 43 44 return 0; 45 } 46 47