-
Notifications
You must be signed in to change notification settings - Fork 4
Jnwang/enable timer interrupt #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
include/timer.h
Outdated
| #define USED 1 | ||
|
|
||
| typedef struct TIMER { | ||
| struct TIMER *next; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need the next pointer? As I understand we have a pool of those rather than a linked list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I seems like can't recall what it does mean, :-) the code is long far away ago. The next pointer is not for a link list. might be mean where is the next fired.
| unsigned int count, next; | ||
| struct TIMER *current; | ||
| struct TIMER pool[MAX_TIMER]; | ||
| }timer_zone; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually a matter of taste, but I usually stick to the occam's razor rule, - be minimalistic in the code. We don't actually need those singletons like timer_zone and timer. And declaring the timer_zone timers; in the timer.c:5 can be immediatelly like TIMER_POOL timer.
And besides, I don't remember about how it was in our convention, but usually, people use the UPPERCASE_NAMES for constants and all magics. Naming the structures are usually lower_case_names.
@wjn740 @crazyss what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. I think you are right. I don't have too much experience on this, but I'd like to improve it.
hypervisor/timer.c
Outdated
| } | ||
| t = timers.current; | ||
| for(;;) { | ||
| if (t->timeout > timers.count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make cleaner, like while(t->timeout <= timers.count) {...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me look into it. now
3a89bf8 to
7366464
Compare
| } | ||
|
|
||
|
|
||
| timer* timer_alloc(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suppose this function will add new timer, and should has following parameters?
- timeout
- func name which will be called after timeout
| unsigned int timeout, flags; | ||
| int data; | ||
| }timer; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be simple, i think following struct already can reach our goal.
timer {
struct timer *next;
void (*fun)();
long timeout;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your opinions look like a work queue.
Inital PIT controller, enable IRQ0, serial console as output.
timer.c is created for storing the code
99a0183 to
389ccb7
Compare
Enable timer interrupt.
Please take a look. @coolgw @Aleksei_Burlakov.