fix bug in APIC code
=> before we enable the interrupts, we map the APIC registers
This commit is contained in:
parent
82e6604a2c
commit
85768e6f58
3 changed files with 35 additions and 19 deletions
|
@ -197,6 +197,7 @@ int has_apic(void);
|
|||
int apic_is_enabled(void);
|
||||
int ioapic_inton(uint8_t irq, uint8_t apicid);
|
||||
int ioapic_intoff(uint8_t irq, uint8_t apicid);
|
||||
int map_apic(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -391,21 +391,9 @@ static int lapic_reset(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* detects the timer frequency of the APIC and restart
|
||||
* the APIC timer with the correct period
|
||||
*/
|
||||
int apic_calibration(void)
|
||||
int map_apic(void)
|
||||
{
|
||||
uint8_t i;
|
||||
uint32_t flags;
|
||||
#ifndef CONFIG_ROCKCREEK
|
||||
uint64_t ticks, old;
|
||||
uint32_t diff;
|
||||
#else
|
||||
uint64_t start, end, ticks;
|
||||
uint32_t diff;
|
||||
#endif
|
||||
uint32_t i;
|
||||
|
||||
if (!has_apic())
|
||||
return -ENXIO;
|
||||
|
@ -423,11 +411,33 @@ int apic_calibration(void)
|
|||
|
||||
// map all processor entries
|
||||
for(i=0; i<MAX_CORES; i++) {
|
||||
if (apic_processors[i] && (old != (((size_t)apic_processors[i]) & 0xFFFFF000)))
|
||||
if (apic_processors[i] && (old != (((size_t)apic_processors[i]) & 0xFFFFF000)))
|
||||
old = map_region(((size_t) apic_processors[i]) & 0xFFFFF000, ((size_t) apic_processors[i]) & 0xFFFFF000, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* detects the timer frequency of the APIC and restart
|
||||
* the APIC timer with the correct period
|
||||
*/
|
||||
int apic_calibration(void)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t flags;
|
||||
#ifndef CONFIG_ROCKCREEK
|
||||
uint64_t ticks, old;
|
||||
uint32_t diff;
|
||||
#else
|
||||
uint64_t start, end, ticks;
|
||||
uint32_t diff;
|
||||
#endif
|
||||
|
||||
if (!has_apic())
|
||||
return -ENXIO;
|
||||
|
||||
#ifndef CONFIG_ROCKCREEK
|
||||
old = get_clock_tick();
|
||||
|
||||
|
@ -671,27 +681,28 @@ static void apic_err_handler(struct state *s)
|
|||
int apic_init(void)
|
||||
{
|
||||
int ret;
|
||||
uint8_t i;
|
||||
|
||||
ret = apic_probe();
|
||||
if (!ret)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
// set APIC error handler
|
||||
irq_install_handler(126, apic_err_handler);
|
||||
|
||||
#if 0
|
||||
// initialize local apic
|
||||
ret = lapic_reset();
|
||||
if (!ret)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (ioapic) {
|
||||
// enable timer interrupt
|
||||
ioapic_inton(0, apic_processors[boot_processor]->id);
|
||||
// now lets turn everything else off
|
||||
for(i=1; i<24; i++)
|
||||
for(uint32_t i=1; i<24; i++)
|
||||
ioapic_intoff(i, apic_processors[boot_processor]->id);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <metalsvm/errno.h>
|
||||
#include <asm/irq.h>
|
||||
#include <asm/multiboot.h>
|
||||
#include <asm/apic.h>
|
||||
#ifdef CONFIG_ROCKCREEK
|
||||
#include <asm/RCCE_lib.h>
|
||||
#include <asm/SCC_API.h>
|
||||
|
@ -760,6 +761,9 @@ int arch_paging_init(void)
|
|||
*/
|
||||
register_task(per_core(current_task));
|
||||
|
||||
// APIC registers into the kernel address space
|
||||
map_apic();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue