Delete more JavaScript

This commit is contained in:
Fabian 2018-01-27 20:00:42 -06:00
parent f07a2a37ba
commit fcfcc76034
8 changed files with 142 additions and 2823 deletions

View file

@ -89,7 +89,7 @@ CC_FLAGS=\
-s WASM=1 \
-s SIDE_MODULE=1
CORE_FILES=const.js config.js io.js main.js lib.js coverage.js fpu.js ide.js pci.js floppy.js \
CORE_FILES=const.js config.js io.js main.js lib.js coverage.js ide.js pci.js floppy.js \
memory.js dma.js pit.js vga.js ps2.js pic.js rtc.js uart.js hpet.js acpi.js apic.js ioapic.js \
state.js ne2k.js virtio.js bus.js log.js \
cpu.js debug.js \

View file

@ -6,7 +6,7 @@
var CORE_FILES =
"const.js config.js log.js lib.js coverage.js cpu.js debug.js codegen.js " +
"io.js main.js ide.js fpu.js pci.js floppy.js " +
"io.js main.js ide.js pci.js floppy.js " +
"memory.js dma.js pit.js vga.js ps2.js pic.js rtc.js uart.js acpi.js apic.js ioapic.js hpet.js " +
"ne2k.js state.js virtio.js bus.js elf.js";

View file

@ -187,8 +187,6 @@ function V86Starter(options)
"_popa16": function() { return cpu.popa16.apply(cpu, arguments); },
"_popa32": function() { return cpu.popa32.apply(cpu, arguments); },
"_arpl": function() { return cpu.arpl.apply(cpu, arguments); },
"_getiopl": function() { return cpu.getiopl.apply(cpu, arguments); },
"_vm86_mode": function() { return cpu.vm86_mode.apply(cpu, arguments); },
"_bswap": function() { return cpu.bswap.apply(cpu, arguments); },
@ -212,11 +210,11 @@ function V86Starter(options)
"_lss32": function() { return cpu.lss32.apply(cpu, arguments); },
"_enter16": function() { return cpu.enter16.apply(cpu, arguments); },
"_enter32": function() { return cpu.enter32.apply(cpu, arguments); },
"_update_eflags": function() { return cpu.update_eflags.apply(cpu, arguments); },
"_loop": function() { return cpu.loop.apply(cpu, arguments); },
"_loope": function() { return cpu.loope.apply(cpu, arguments); },
"_loopne": function() { return cpu.loopne.apply(cpu, arguments); },
"_jcxz": function() { return cpu.jcxz.apply(cpu, arguments); },
"_test_privileges_for_io": function() { return cpu.test_privileges_for_io.apply(cpu, arguments); },
"_convert_f64_to_i32": function(f) {

1197
src/cpu.js

File diff suppressed because it is too large Load diff

1655
src/fpu.js

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,8 @@
#include "js_imports.h"
#include "cpu.h"
extern void call_indirect(int32_t index);
struct code_cache jit_cache_arr[WASM_TABLE_SIZE] = {{0, 0, {0}, 0, 0, 0}};
uint32_t jit_jump = 0;
@ -49,6 +51,58 @@ int32_t get_eflags()
!!getzf() << 6 | !!getsf() << 7 | !!getof() << 11;
}
int32_t getiopl(void)
{
return *flags >> 12 & 3;
}
bool vm86_mode(void)
{
return (*flags & FLAG_VM) == FLAG_VM;
}
/*
* Update the flags register depending on iopl and cpl
*/
void update_eflags(int32_t new_flags)
{
int32_t dont_update = FLAG_RF | FLAG_VM | FLAG_VIP | FLAG_VIF;
int32_t clear = ~FLAG_VIP & ~FLAG_VIF & FLAGS_MASK;
if(*flags & FLAG_VM)
{
// other case needs to be handled in popf or iret
dbg_assert(getiopl() == 3);
dont_update |= FLAG_IOPL;
// don't clear vip or vif
clear |= FLAG_VIP | FLAG_VIF;
}
else
{
if(!*protected_mode) dbg_assert(*cpl == 0);
if(*cpl)
{
// cpl > 0
// cannot update iopl
dont_update |= FLAG_IOPL;
if(*cpl > getiopl())
{
// cpl > iopl
// cannot update interrupt flag
dont_update |= FLAG_INTERRUPT;
}
}
}
*flags = (new_flags ^ ((*flags ^ new_flags) & dont_update)) & clear | FLAGS_DEFAULT;
*flags_changed = 0;
}
void trigger_pagefault(bool write, bool user, bool present)
{
if(LOG_PAGE_FAULTS)
@ -266,7 +320,7 @@ int32_t translate_address_read(int32_t address)
}
else
{
return do_page_translation(address, 0, *cpl == 3) | address & 0xFFF;
return do_page_translation(address, false, *cpl == 3) | address & 0xFFF;
}
}
@ -281,7 +335,37 @@ int32_t translate_address_write(int32_t address)
}
else
{
return do_page_translation(address, 1, *cpl == 3) | address & 0xFFF;
return do_page_translation(address, true, *cpl == 3) | address & 0xFFF;
}
}
int32_t translate_address_system_read(int32_t address)
{
if(!*paging) return address;
int32_t base = (uint32_t)address >> 12;
if(tlb_info[base] & TLB_SYSTEM_READ)
{
return tlb_data[base] ^ address;
}
else
{
return do_page_translation(address, false, false) | address & 0xFFF;
}
}
int32_t translate_address_system_write(int32_t address)
{
if(!*paging) return address;
int32_t base = (uint32_t)address >> 12;
if(tlb_info[base] & TLB_SYSTEM_WRITE)
{
return tlb_data[base] ^ address;
}
else
{
return do_page_translation(address, true, false) | address & 0xFFF;
}
}
@ -720,6 +804,18 @@ void trigger_nm()
raise_exception(7);
}
void trigger_np(int32_t code)
{
*instruction_pointer = *previous_ip;
raise_exception_with_code(11, code);
}
void trigger_ss(int32_t code)
{
*instruction_pointer = *previous_ip;
raise_exception_with_code(12, code);
}
void trigger_gp(int32_t code)
{
*instruction_pointer = *previous_ip;

View file

@ -134,3 +134,5 @@ void set_ecx_asize(int32_t value);
void add_reg_asize(int32_t reg, int32_t value);
int32_t decr_ecx_asize(void);
uint64_t read_tsc(void);
bool vm86_mode(void);
int32_t getiopl(void);

View file

@ -13,7 +13,6 @@ extern bool has_rand_int(void);
extern int32_t arpl(int32_t, int32_t);
extern int32_t bswap(int32_t);
extern int32_t get_rand_int(void);
extern int32_t getiopl(void);
extern int32_t int_log2(int32_t);
extern int32_t lar(int32_t, int32_t);
extern int32_t loop(int32_t);
@ -53,7 +52,6 @@ extern void unimplemented_sse(void);
extern void update_cs_size(int32_t);
extern void update_eflags(int32_t);
extern void switch_seg(int32_t, int32_t);
extern bool vm86_mode(void);
extern void lss16(int32_t, int32_t, int32_t);
extern void lss32(int32_t, int32_t, int32_t);
extern void test_privileges_for_io(int32_t, int32_t);
@ -64,7 +62,6 @@ extern void io_port_write8(int32_t, int32_t);
extern void io_port_write16(int32_t, int32_t);
extern void io_port_write32(int32_t, int32_t);
extern int32_t convert_f64_to_i32(double_t);
extern void call_indirect(int32_t index);
extern void jit_clear_func(int32_t index);
extern void call_interrupt_vector(int32_t interrupt_nr, bool is_software_int, bool has_error_code, int32_t error_code);
extern void throw_cpu_exception(void);