mirror of
https://github.com/copy/v86.git
synced 2025-12-31 04:23:15 +00:00
fix: correct field indices for restoring old state images with apic
This commit is contained in:
parent
2f65f9d6d1
commit
7c4cbd0b04
2 changed files with 14 additions and 10 deletions
18
src/cpu.js
18
src/cpu.js
|
|
@ -822,15 +822,15 @@ CPU.prototype.set_state_apic = function(state)
|
||||||
apic[2] = state[2]; // timer_divider_shift
|
apic[2] = state[2]; // timer_divider_shift
|
||||||
apic[3] = state[3]; // timer_initial_count
|
apic[3] = state[3]; // timer_initial_count
|
||||||
apic[4] = state[4]; // timer_current_count
|
apic[4] = state[4]; // timer_current_count
|
||||||
// skip next_tick (in js: state[4]; in rust: apic[5] and apic[6])
|
// skip next_tick (in js: state[4]; in rust: apic[6] and apic[7])
|
||||||
apic[7] = state[6]; // lvt_timer
|
apic[8] = state[6]; // lvt_timer
|
||||||
apic[8] = state[7]; // lvt_perf_counter
|
apic[9] = state[7]; // lvt_perf_counter
|
||||||
apic[9] = state[8]; // lvt_int0
|
apic[10] = state[8]; // lvt_int0
|
||||||
apic[10] = state[9]; // lvt_int1
|
apic[11] = state[9]; // lvt_int1
|
||||||
apic[11] = state[10]; // lvt_error
|
apic[12] = state[10]; // lvt_error
|
||||||
apic[12] = state[11]; // tpr
|
apic[13] = state[11]; // tpr
|
||||||
apic[13] = state[12]; // icr0
|
apic[14] = state[12]; // icr0
|
||||||
apic[14] = state[13]; // icr1
|
apic[15] = state[13]; // icr1
|
||||||
apic.set(state[15], 16); // irr
|
apic.set(state[15], 16); // irr
|
||||||
apic.set(state[15], 24); // isr
|
apic.set(state[15], 24); // isr
|
||||||
apic.set(state[16], 32); // tmr
|
apic.set(state[16], 32); // tmr
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,11 @@ const IOAPIC_DELIVERY_FIXED: u8 = 0;
|
||||||
const APIC_STRUCT_SIZE: usize = 4 * 46;
|
const APIC_STRUCT_SIZE: usize = 4 * 46;
|
||||||
|
|
||||||
// Note: JavaScript (cpu.get_state_apic) depens on this layout
|
// Note: JavaScript (cpu.get_state_apic) depens on this layout
|
||||||
|
const _: () = assert!(std::mem::offset_of!(Apic, timer_last_tick) == 6 * 4);
|
||||||
|
const _: () = assert!(std::mem::offset_of!(Apic, lvt_timer) == 8 * 4);
|
||||||
|
const _: () = assert!(std::mem::offset_of!(Apic, lvt_perf_counter) == 9 * 4);
|
||||||
const _: () = assert!(std::mem::offset_of!(Apic, icr0) == 14 * 4);
|
const _: () = assert!(std::mem::offset_of!(Apic, icr0) == 14 * 4);
|
||||||
|
const _: () = assert!(std::mem::offset_of!(Apic, icr1) == 15 * 4);
|
||||||
const _: () = assert!(std::mem::offset_of!(Apic, irr) == 16 * 4);
|
const _: () = assert!(std::mem::offset_of!(Apic, irr) == 16 * 4);
|
||||||
const _: () = assert!(std::mem::offset_of!(Apic, isr) == 24 * 4);
|
const _: () = assert!(std::mem::offset_of!(Apic, isr) == 24 * 4);
|
||||||
const _: () = assert!(std::mem::offset_of!(Apic, tmr) == 32 * 4);
|
const _: () = assert!(std::mem::offset_of!(Apic, tmr) == 32 * 4);
|
||||||
|
|
@ -552,7 +556,7 @@ fn deliver(apic: &mut Apic, vector: u8, mode: u8, is_level: bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if vector < 0x10 || vector == 0xFF {
|
if vector < 0x10 || vector == 0xFF {
|
||||||
dbg_assert!(false, "TODO: Invalid vector");
|
dbg_assert!(false, "TODO: Invalid vector: {:x}", vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
if register_get_bit(&apic.irr, vector) {
|
if register_get_bit(&apic.irr, vector) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue