From b4922dc3b1cc2514e28175dcc0d888922d6cd92c Mon Sep 17 00:00:00 2001 From: Amaan Cheval Date: Fri, 7 Sep 2018 18:59:11 +0530 Subject: [PATCH] cpu: Port cpl_changed to Rust We leave the JS version too, since it's used by several other JS functions that we aren't porting yet. --- src/browser/starter.js | 1 - src/rust/cpu2/cpu.rs | 5 +++++ src/rust/cpu2/instructions_0f.rs | 2 -- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/browser/starter.js b/src/browser/starter.js index ff684f97..3e97f778 100644 --- a/src/browser/starter.js +++ b/src/browser/starter.js @@ -213,7 +213,6 @@ function V86Starter(options) "verw": function() { return cpu.verw.apply(cpu, arguments); }, "verr": function() { return cpu.verr.apply(cpu, arguments); }, - "cpl_changed": function() { return cpu.cpl_changed.apply(cpu, arguments); }, "set_cr0": function() { return cpu.set_cr0.apply(cpu, arguments); }, "update_cs_size": function() { return cpu.update_cs_size.apply(cpu, arguments); }, "cpuid": function() { return cpu.cpuid.apply(cpu, arguments); }, diff --git a/src/rust/cpu2/cpu.rs b/src/rust/cpu2/cpu.rs index a259bc11..12c8717c 100644 --- a/src/rust/cpu2/cpu.rs +++ b/src/rust/cpu2/cpu.rs @@ -892,6 +892,11 @@ pub unsafe fn get_seg(mut segment: i32) -> i32 { return *segment_offsets.offset(segment as isize); } +pub unsafe fn cpl_changed() { + *last_virt_eip = -1; + *last_virt_esp = -1; +} + pub unsafe fn test_privileges_for_io(port: i32, size: i32) -> bool { if *protected_mode && (*cpl > getiopl() as u8 || (*flags & FLAG_VM != 0)) { if !*tss_size_32 { diff --git a/src/rust/cpu2/instructions_0f.rs b/src/rust/cpu2/instructions_0f.rs index 23611364..25342084 100644 --- a/src/rust/cpu2/instructions_0f.rs +++ b/src/rust/cpu2/instructions_0f.rs @@ -21,8 +21,6 @@ extern "C" { #[no_mangle] fn cpuid(); #[no_mangle] - fn cpl_changed(); - #[no_mangle] fn update_cs_size(cs_size: bool); #[no_mangle] fn set_cr0(cr0: i32);