00001 /* define for src/arch/x86/rtc.cpp */ 00002 00003 #ifndef _CORE_ARCH_X86_RTC_HPP 00004 #define _CORE_ARCH_X86_RTC_HPP 00005 00006 //necessary includes 00007 #include "src/arch/x86/except_c.hpp" 00008 #include "src/common/blist.hpp" 00009 00010 const char DEF_RTC_IRQ = 0x08; /*this is the rtc's irq*/ 00011 const char DEF_RTC_BASE = 0x70; /*this the base port for the MC 146818*/ 00012 const char DEF_RTC_ST_B = 0x0b; /*adress for Status B*/ 00013 const char DEF_RTC_ST_C = 0x0c; /*adress for Status C*/ 00014 const char DEF_RTC_PERIODIC = 0x40; /*bit to enable periodic interrupts*/ 00015 const char DEF_RTC_NO_PERIODIC = 0xBF; /*mask used to disable rtc*/ 00016 const char DEF_RTC_PERIOD_INT = 0x40; /*bit in status c informing the interrupt was the periodic one*/ 00017 00018 const uint32 RTC_NOT_ONE_SHOT = 0; /*repeat handler infinitive*/ 00019 const uint32 RTC_ONE_SHOT = 1; /*one-shot handler*/ 00020 00021 const uint32 DEF_SECOND = 1024; /*how many rtc ticks make a second*/ 00022 typedef int (*RTC_proc) (int,int) ; //a proc to be called 00023 typedef int rtc_handle; //a handle to a proc 00024 00025 namespace Arch { 00026 namespace x86 { 00027 namespace RTC { 00028 00029 00030 void init(); //initialise tha ziom 00031 void done(); //destruct 00032 00033 void enable_rtc(); //enable 00034 void disable_rtc(); //disable 00035 00036 /*each function to be done.*/ 00037 struct rtc_list 00038 { 00039 RTC_proc proc; 00040 uint64 boom; // if equal to up_time then run 00041 uint64 ticks_def; 00042 bool one_shot; /*if 1, deletes handler after first call; if 0, calls it each ticks_def ticks*/ 00043 int arg1,arg2; /*argument for handler*/ 00044 }; 00045 00046 extern blist_t rtc_funcs; 00047 00048 rtc_handle add_proc(RTC_proc proc, uint32 ticks_def, bool one_shot, int arg1, int arg2); 00049 int rtccompar(const void *a, const void *b); 00050 int del_proc(rtc_handle handle); 00051 00052 // 00053 // extern rtc_list *rtc_procs; 00054 // extern uint32 rtc_id; 00056 extern uint64 volatile up_time; 00057 // extern uint32 volatile rtc_times; /*how many ticks have passed since last we serviced the handlers*/ 00058 extern class IPC::Lock::lock_t rtc_lock; 00059 // 00060 // uint32 add_rtc_proc(uint32 ticks_def, uint32 (*proc)(), uint32 one_shot); 00061 // uint32 add_rtc_proc(uint32 ticks_def, uint32 (*proc)(), uint32 one_shot, uint32 arg); 00062 // uint32 del_rtc_proc(uint32 ptr); 00063 00064 uint8 ack_rtc(); /*acknowledge the rtc and return status byte c*/ 00065 int rtc_handler(struct Interr::except2_t *code); 00066 00067 // void try_handlers(); /*runs all handlers supposed to run*/ 00068 void tdelay(uint32 ticks); 00069 00070 00071 }; /*namespace RTC*/ 00072 }; /*namespace x86*/ 00073 }; /*namespace Arch*/ 00074 00075 #endif