cosmetic changes, minor code optimization

This commit is contained in:
Stefan Lankes 2011-04-18 15:10:24 +02:00
parent 47f37e3b00
commit 68281c8ad0
3 changed files with 11 additions and 9 deletions

View file

@ -68,9 +68,6 @@ int arch_fork(task_t* task)
memcpy(task_state_segments+id, task_state_segments+curr_task->id, sizeof(tss_t));
memcpy(kstacks[id], kstacks[curr_task->id], KERNEL_STACK_SIZE);
task_state_segments[id].cr3 = (uint32_t) (virt_to_phys((size_t)task->pgd));
task_state_segments[id].eflags = read_eflags();
// the parent task will enable the IF flag
task_state_segments[id].eflags |= (1 << 9);
task_state_segments[id].esp0 = (uint32_t) kstacks[id] + KERNEL_STACK_SIZE - sizeof(size_t);
asm volatile("mov %%esp, %0" : "=r"(task_state_segments[id].esp));
@ -91,6 +88,9 @@ int arch_fork(task_t* task)
asm volatile ("pop %0" : "=r"(task_state_segments[id].ecx));
asm volatile ("pop %0" : "=r"(task_state_segments[id].eax));
// store current EFLAGS and set IF flag
// => the parent task will enable the interrupt handling
task_state_segments[id].eflags = read_eflags() | (1 << 9);
// This will be the entry point for the new task.
task_state_segments[id].eip = read_eip();

View file

@ -226,9 +226,11 @@ void irq_handler(struct state *s)
* Find out if we have a custom handler to run for this
* IRQ and then finally, run it
*/
handler = irq_routines[s->int_no];
if (handler)
handler(s);
if (BUILTIN_EXPECT(s->int_no < MAX_HANDLERS, 1)) {
handler = irq_routines[s->int_no];
if (handler)
handler(s);
} else kprintf("Invalid interrupt number %d\n", s->int_no);
/*
* If the IDT entry that was invoked was greater-than-or-equal to 48,

View file

@ -49,12 +49,12 @@ uint32_t detect_cpu_frequency(void)
while((ticks = get_clock_tick()) - old == 0)
HALT;
rmb();
mb();
start = rdtsc();
/* wait a second to determine the frequency */
while(get_clock_tick() - ticks < TIMER_FREQ)
HALT;
rmb();
mb();
end = rdtsc();
diff = end > start ? end - start : start - end;
@ -78,7 +78,7 @@ void udelay(uint32_t usecs)
uint64_t deadline = get_cpu_frequency() * usecs;
do {
rmb();
mb();
end = rdtsc();
diff = end > start ? end - start : start - end;
} while(diff < deadline);