git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Decoupling Architectural-specific Code (#35)
[lunaix-os.git]
/
lunaix-os
/
includes
/
lunaix
/
timer.h
diff --git
a/lunaix-os/includes/lunaix/timer.h
b/lunaix-os/includes/lunaix/timer.h
index 567b8d24d70e72462ad1ee941c20c1c26e2ed25e..08718adc474a1d8147476b739bb35be9b92d8fc4 100644
(file)
--- a/
lunaix-os/includes/lunaix/timer.h
+++ b/
lunaix-os/includes/lunaix/timer.h
@@
-2,61
+2,73
@@
#define __LUNAIX_TIMER_H
#include <lunaix/ds/llist.h>
#define __LUNAIX_TIMER_H
#include <lunaix/ds/llist.h>
-#include <stdint.h>
+#include <lunaix/time.h>
+#include <lunaix/hart_state.h>
-#define SYS_TIMER_FREQUENCY_HZ
2048
+#define SYS_TIMER_FREQUENCY_HZ
1000
-#define TIMER_MODE_PERIODIC
0x1
+#define TIMER_MODE_PERIODIC 0x1
-typedef uint32_t ticks_t;
-
-struct lx_timer_context {
- struct lx_timer *active_timers;
+struct lx_timer_context
+{
+ struct lx_timer* active_timers;
/**
/**
- * @brief
APIC timer
base frequency (ticks per seconds)
- *
+ * @brief
timer hardware
base frequency (ticks per seconds)
+ *
*/
ticks_t base_frequency;
/**
* @brief Desired system running frequency
*/
ticks_t base_frequency;
/**
* @brief Desired system running frequency
- *
+ *
*/
*/
-
uint32
_t running_frequency;
+
ticks
_t running_frequency;
/**
* @brief Ticks per hertz
/**
* @brief Ticks per hertz
- *
+ *
*/
ticks_t tphz;
};
*/
ticks_t tphz;
};
-struct lx_timer {
+struct timer_init_param
+{
+ struct lx_timer_context* context;
+ void* timer_update_isr;
+};
+
+struct lx_timer
+{
struct llist_header link;
ticks_t deadline;
ticks_t counter;
void* payload;
void (*callback)(void*);
struct llist_header link;
ticks_t deadline;
ticks_t counter;
void* payload;
void (*callback)(void*);
- u
int
8_t flags;
+ u8_t flags;
};
};
-
/**
* @brief Initialize the system timer that runs at specified frequency
/**
* @brief Initialize the system timer that runs at specified frequency
- *
+ *
* @param frequency The frequency that timer should run in Hz.
*/
void
* @param frequency The frequency that timer should run in Hz.
*/
void
-timer_init(
uint32_t frequency
);
+timer_init();
struct lx_timer*
struct lx_timer*
-timer_run_second(uint32_t second, void (*callback)(void*), void* payload, uint8_t flags);
+timer_run_second(u32_t second,
+ void (*callback)(void*),
+ void* payload,
+ u8_t flags);
struct lx_timer*
struct lx_timer*
-timer_run_ms(uint32_t millisecond, void (*callback)(void*), void* payload, uint8_t flags);
+timer_run_ms(u32_t millisecond,
+ void (*callback)(void*),
+ void* payload,
+ u8_t flags);
struct lx_timer*
struct lx_timer*
-timer_run(ticks_t ticks, void (*callback)(void*), void* payload, u
int
8_t flags);
+timer_run(ticks_t ticks, void (*callback)(void*), void* payload, u8_t flags);
-struct lx_timer_context*
+struct lx_timer_context*
timer_context();
#endif /* __LUNAIX_TIMER_H */
timer_context();
#endif /* __LUNAIX_TIMER_H */