freepdes[nfreepdes++] = pde;
}
-PRIVATE int oxpcie_mapping_index = -1;
+PRIVATE int oxpcie_mapping_index = -1,
+ lapic_mapping_index = -1,
+ ioapic_first_index = -1,
+ ioapic_last_index = -1;
PUBLIC int arch_phys_map(const int index,
phys_bytes *addr,
if(first) {
#ifdef USE_APIC
if(lapic_addr)
- freeidx++;
- if (ioapic_enabled)
+ lapic_mapping_index = freeidx++;
+ if (ioapic_enabled) {
+ int i;
+ ioapic_first_index = freeidx;
+ assert(nioapics > 0);
freeidx += nioapics;
+ ioapic_last_index = freeidx-1;
+ }
#endif
#ifdef CONFIG_OXPCIE
if(ser_var[0] != '0' || ser_var[1] != 'x') {
printf("oxpcie address in hex please\n");
} else {
+ printf("oxpcie address is %s\n", ser_var);
oxpcie_mapping_index = freeidx++;
}
}
#ifdef USE_APIC
/* map the local APIC if enabled */
- if (index == 0) {
+ if (index == lapic_mapping_index) {
if (!lapic_addr)
return EINVAL;
*addr = vir2phys(lapic_addr);
{
#ifdef USE_APIC
/* if local APIC is enabled */
- if (index == 0 && lapic_addr) {
+ if (index == lapic_mapping_index && lapic_addr) {
lapic_addr_vaddr = addr;
return OK;
}
- else if (ioapic_enabled && index <= nioapics) {
- io_apic[index - 1].vaddr = addr;
+ else if (ioapic_enabled && index >= ioapic_first_index &&
+ index <= ioapic_last_index) {
+ io_apic[index - ioapic_first_index].vaddr = addr;
return OK;
}
#endif