Permalink
Browse files

upload 0.4.015a: create bochx, the bridge connects bochs and nxvm

  • Loading branch information...
cshaxu committed May 7, 2014
1 parent 1104986 commit 7585a287bfaab81fb0fb93a1b518bd258b8c0f64
Showing with 886 additions and 609 deletions.
  1. +15 −8 .gitignore
  2. +45 −0 NEWS
  3. +81 −1 README
  4. +14 −2 README.md
  5. +15 −0 TODO
  6. BIN bin/{nxvm_0_4_0152_win32_x64_vs2012.exe → legacy/nxvm_0_4_0152_x64_vs2012.exe}
  7. BIN bin/{nxvm_0_3_014f_win32_arm_vs2012.exe → nxvm_0_3_014f_arm_vs2012.exe}
  8. BIN bin/nxvm_0_4_015a_x64_vs2012.exe
  9. +37 −0 bochx/README
  10. +1 −1 {doc/_test → bochx}/bochs-2.6/bochs.h
  11. +1 −1 {doc/_test → bochx}/bochs-2.6/config.cc
  12. +6 −6 {doc/_test → bochx}/bochs-2.6/cpu/cpu.cc
  13. +2 −2 {doc/_test → bochx}/bochs-2.6/cpu/paging.cc
  14. +448 −0 bochx/bochsapi.cc
  15. +45 −0 bochx/bochsapi.h
  16. +27 −0 bochx/makefile
  17. +57 −0 bochx/nxvmapi.c
  18. +0 −385 doc/_test/vcpuapi.cc
  19. +0 −30 doc/_test/vcpuapi.h
  20. +71 −0 doc/code/debug/vm8086_trace.txt
  21. 0 doc/{_save → code/deprecated}/i386_ref/vcpu.c
  22. 0 doc/{_save → code/deprecated}/i386_ref/vcpu.h
  23. 0 doc/{_save → code/deprecated}/i386_ref/vcpuins.c
  24. 0 doc/{_save → code/deprecated}/i386_ref/vcpuins.h
  25. 0 doc/{_save → code/deprecated}/makefile
  26. 0 doc/{_save → code/deprecated}/mm.cmd
  27. 0 doc/{_save → code/deprecated}/vcpuins_i8086.c
  28. 0 doc/{_todo → code/todo}/vbios.c
  29. 0 doc/{_todo → code/todo}/vbios.h
  30. 0 doc/{_todo → code/todo}/vkbc.c
  31. 0 doc/{_todo → code/todo}/vkbc.h
  32. 0 doc/{_todo → code/todo}/vkeyb.c
  33. 0 doc/{_todo → code/todo}/vkeyb.h
  34. BIN doc/{ → design}/design_chs_0_3_014f.pdf
  35. +2 −1 doc/{ → help}/astyle.txt
  36. 0 doc/{ → help}/automake.txt
  37. +17 −17 src/device/qdx/qdx.c
  38. +2 −155 src/main.c
View
@@ -1,3 +1,10 @@
# Bochs project files
/bochx/bochs-2.6/
!/bochx/bochs-2.6/bochs.h
!/bochx/bochs-2.6/config.cc
!/bochx/bochs-2.6/cpu/cpu.cc
!/bochx/bochs-2.6/cpu/paging.cc
# Object files
*.o
@@ -12,26 +19,26 @@
*.dylib
# Executables
# *.exe
*.out
*.app
/nxvm
bochx/bochx
# AutoMake Directories
/autom4te.cache
.deps
# Automake directories
/autom4te.cache/
.deps/
.dirstamp
# AutoMake Makefiles
/nxvm
# Automake makefiles
/config.h.in~
/Makefile
/config.h
/config.status
/config.log
/stamp-h1
# Astyle Trash
# Astyle trash
*.orig
# Mac OS X Trash
# Mac OS X trash
.DS_Store
View
45 NEWS
@@ -0,0 +1,45 @@
NXVM in the year 2012
01/01-02/05 built debugger
02/06-02/12 built i8086 cpu
02/06-02/12 built pic
03/02-04/01 built cmos
03/03-04/01 built pit, dma
03/07-03/18 built fdc, fdd
NXVM in the year 2013
03/03-04/01 built pit, cont
03/17-03/21 built pic, cont
03/25-03/28 built dma, cont
04/03-04/06 built fdd, cont
04/07-04/11 built kbc, qdkeyb
04/14-05/05 debugged i8086 cpu
04/21-05/23 updated debugger
05/24-07/31 built 80386 cpu
08/06-08/09 built dasm32
08/10-08/15 built aasm32
NXVM in the year 2014
04/24-present format/refactor entire code base
Milestones
0x45 Console, 8086 CPU, Debug, Aasm, Dasm
0x82 Basic Devices (QD Devices)
0x90 Win32 Application
0xbc Win32 Console
0xbf Linux Console
0xca New BIOS System
0xcc New Console Commands
0xdf Rebuilt Aasm/Dasm/Debug System
0xf2 Clean CPUINS; Hard Disk Installed
0xf5 i386 Build Begin
010d Bitmap Font Implemented
0118 i386 Milestone 1 (32-bit ins)
0128 i386 Milestone 2 (MMU)
012e Bochs Tester Constructed
013a Built Dasm 32
0140 Built Trace System
0143 Built Debug 32
0144 Built Aasm 32
014c Rebuilt vmachine.ch
0153 Refactored Architecture
0154 Built AutoMake System
View
82 README
@@ -1 +1,81 @@
For NXVM introduction, please see README.md.
Project Phases
1. Read documents and list all necessary functionality
2. Code the functions
3. Add comment for each I/O function, check logic
4. Create test functions and corresponding test case
5. Perform unit tests
6. Read official document and PC.PDF, then check logic
Modules:
0- Version and Settings
main.c
global.h
1- Console
console.ch
2- Debugger
debug.ch
3- Assembler and Disassembler for Intel 80386
xasm32/aasm32.ch
xasm32/dasm32.ch
4- Machine Controller
machine.ch
5- Platform Related Module - Human-Computer Interface
a- Platform Selector
platform/platform.ch
b- Linux Platform Module
platform/linux.ch
c- Win32 Platform Module
platform/win32.ch
.- Win32 Console Module
platform/win32con.ch
platform/w32cdisp.ch
:- Win32 Window Module
platform/win32app.ch
platform/w32adisp.ch
6- Virtual Machine Devices
a- Type Definitions
device/vglobal.h
b- Device Thread Controller
device/device.ch
c- Device Registry
device/vmachine.ch
d- Input/Output Ports
device/vport.ch
e- BIOS
device/vbios.ch
f- Random Accessing Memory
device/vram.ch
g- Center Processing Unit (Intel 8086+)
device/vcpu.ch
device/vcpuins.ch
h- Programmable Interrupt Controller (8259)
device/vpic.ch
NOTE: fully tested, except for OCW2, ICW4(AEOI)
i- Programmable Internal Timer (8254)
device/vpit.ch
NOTE: not fully implemented (read-back command); not fully tested
j- Direct Memory Accessing Controller (8237)
device/vdma.ch
k- Floppy Drive Controller (8272)
device/vfdc.ch
device/vfdd.ch
l- Hard Disk Driver
device/vhdc.ch
device/vhdd.ch
qdx/qddisk.ch
NOTE: Quick And Dirty
m- Keyboard Controller
device/vkbc.ch
qdx/qdkeyb.ch
NOTE: Quick And Dirty
n- Video Adapter
device/vvadp.ch
qdx/qdcga.ch
NOTE: Quick And Dirty
o- CMOS
device/vcmos.ch
z- additional
serial: vseri.c, vseri.h
parallel: vpara.c, vpara.h
printer: vprinter.c, vprinter.h
cdrom: vcdrom.c, vcdrom.h
View
@@ -6,7 +6,7 @@ Author: Xu Ha (cshaxu@gmail.com)
Introduction
------------
This project includes an integrated implementation of a light-weight x86 PC emulator, which is written in 37,000 lines of C codes and a few Assembly codes.
This project includes an integrated implementation of a light-weight x86 PC emulator, which is written in 40,000 lines of C codes and a few Assembly codes.
It emulated a PC machine which serves as a software container. The emulator has an Intel 80386 CPU and all other necessary devices, such as RAM, DMA, PIC, Floppy, Hard Drive, Keyboard, Display and so on.
@@ -58,7 +58,7 @@ Compiling
The compiling options are defined in `src/global.h`, to specify 32/64 bit compilation. It also has a macro to specify the platform WIN32/LINUX. In most cases, user doesn't need to change anything there.
### Windows
IDE is MS Visual Studio 2008 or higher.
For Visual Studio 2008 or higher:
Create an empty Win32 Console project and add all `.c` and `.h` files from the folders:
- src
- src/device
@@ -68,6 +68,18 @@ Create an empty Win32 Console project and add all `.c` and `.h` files from the f
- src/xasm32
For MinGW:
1. In `global.h`, replace `#ifdef _WIN32` with `#ifdef _WIN32_DISABLED`.
2. Install MinGW.
3. Download PDCurses 3.4 (pdc34dllw.zip, Win32 DLL for console w/ Unicode) from Sourceforge.com.
4. Add files to %MINGW_HOME%:
- pdcurses.lib -> %MINGW_HOME%/lib/ncurses.lib
- cursors.h -> %MINGW_HOME%/include/cursors.h
- panels.h -> %MINGW_HOME%/include/panels.h
- pdcures.dll -> %MINGW_HOME%/bin/pdcures.dll
5. Run `mingw32-make`.
### Linux
1. Install `ncurses` and `pthread` if they do not exist.
2. Change directory to NXVM project folder.
View
15 TODO
@@ -0,0 +1,15 @@
TODO - Coding Conventions
1- rename variables
2- repair flags
3- replace constants
@debug.c, aasm32.c, dasm32.c
@vcpu.ch, vcpuins.ch
@qdcga.ch, qddisk.ch, qdkeyb.ch
TODO - Implementation and Improvement
1- Debug CPU: Cannot enter Virtual 8086 Mode.
See "ntrace.txt".
Refer to Bochs BIOS implementations.
2- Build Exception Handler
3- Build VGA Graphics Mode
4- Build BIOS Service Routine System
Binary file not shown.
View
@@ -0,0 +1,37 @@
BOCHX: BOCHs - nXvm Connector that helps NXVM CPU Verification
1- Test if Bochx is compatible with current NXVM:
a- In bochsapi.cc, set BOCHSAPI_BOCHS to False.
b- Make binary with the makefile in this folder.
c- Resolve any compilation warnings and/or errors.
2- Test NXVM CPU by connecting with Bochs:
a- In bochsapi.cc, set BOCHSAPI_BOCHS to True.
b- In bochsapi.h, set BOCHSAPI_BOCHS_BIOS to correct bochs path.
c- Extract bochs-2.6 project files to folder bochs-2.6/.
Do NOT replace existing Bochs source files in this folder.
The existing Bochs source files are modified to fit Bochx.
bochs-2.6/bochs.h
bochs-2.6/config.cc
bochs-2.6/cpu/cpu.cc
bochs-2.6/cpu/paging.cc
d- Add Bochx files to Bochs project:
bochsapi.cc
bochsapi.h
nxvmapi.c
e- Add NXVM files to Bochs project:
../src/utils.h
../src/global.h
../src/device/device.h
../src/device/vcpu.c
../src/device/vcpu.h
../src/device/vcpuins.c
../src/device/vcpuins.h
../src/device/vglobal.h
../src/device/vpic.h
../src/device/vram.h
../src/device/vport.h
f- In bochsapi.cc, set BOCHSAPI_LINEAR_START to the linear address,
from which the cpu status comparison starts.
g- In bochsapi.cc, set BOCHSAPI_LINEAR_END to the linear address,
at which the CPU status comparison stops.
@@ -29,7 +29,7 @@
# define BX_BOCHS_H 1
#include "config.h" /* generated by configure script from config.h.in */
#include "d:/libraryw/scripts/nekolib/nxvm/src/vmachine/vcpuapi.h"
#include "../bochsapi.h"
#ifndef __QNXNTO__
extern "C" {
@@ -1750,7 +1750,7 @@ static const char *get_builtin_variable(const char *varname)
if (!strcmp(varname, "BXSHARE")) {
#ifdef WIN32
if (1) {
strcpy(data, "d:/bochs-2.6/bios");
strcpy(data, BOCHSAPI_BOCHS_BIOS);
return data;
} else {
wsprintf(keyname, "Software\\Bochs %s", VER_STRING);
@@ -83,7 +83,7 @@ void BX_CPU_C::cpu_loop(void)
BX_CPU_THIS_PTR speculative_rsp = 0;
BX_CPU_THIS_PTR EXT = 0;
vcpuapiInit();
bochsApiInit();
while (1) {
@@ -92,7 +92,7 @@ void BX_CPU_C::cpu_loop(void)
if (BX_CPU_THIS_PTR async_event) {
if (handleAsyncEvent()) {
// If request to return to caller ASAP.
vcpuapiFinal();
bochsApiFinal();
return;
}
}
@@ -129,13 +129,13 @@ void BX_CPU_C::cpu_loop(void)
// want to allow changing of the instruction inside instrumentation callback
BX_INSTR_BEFORE_EXECUTION(BX_CPU_ID, i);
vcpuapiExecBefore();
bochsApiExecBefore();
RIP += i->ilen();
BX_CPU_CALL_METHOD(i->execute, (i)); // might iterate repeat instruction
BX_CPU_THIS_PTR prev_rip = RIP; // commit new RIP
vcpuapiExecAfter();
bochsApiExecAfter();
BX_INSTR_AFTER_EXECUTION(BX_CPU_ID, i);
BX_CPU_THIS_PTR icount++;
@@ -144,7 +144,7 @@ void BX_CPU_C::cpu_loop(void)
// note instructions generating exceptions never reach this point
#if BX_DEBUGGER || BX_GDBSTUB
if (dbg_instruction_epilog()) {vcpuapiFinal();return;}
if (dbg_instruction_epilog()) {bochsApiFinal();return;}
#endif
if (BX_CPU_THIS_PTR async_event) break;
@@ -162,7 +162,7 @@ void BX_CPU_C::cpu_loop(void)
} // while (1)
vcpuapiFinal();
bochsApiFinal();
}
@@ -1849,7 +1849,7 @@ void BX_CPU_C::access_write_linear(bx_address laddr, unsigned len, unsigned curr
{
Bit32u pageOffset = PAGE_OFFSET(laddr);
vcpuapiMemRec(laddr, (t_vaddrcc)data, (t_nubit8)len, 1);
bochsApiRecordRam(laddr, (t_vaddrcc) data, (t_nubit8) len, 1);
/* check for reference across multiple pages */
if ((pageOffset + len) <= 4096) {
@@ -1973,7 +1973,7 @@ void BX_CPU_C::access_read_linear(bx_address laddr, unsigned len, unsigned curr_
hwbreakpoint_match(laddr2, BX_CPU_THIS_PTR address_xlation.len2, xlate_rw);
#endif
}
vcpuapiMemRec(laddr, (t_vaddrcc)data, (t_nubit8)len, 0);
bochsApiRecordRam(laddr, (t_vaddrcc) data, (t_nubit8) len, 0);
}
void BX_CPU_C::access_write_physical(bx_phy_address paddr, unsigned len, void *data)
Oops, something went wrong.

0 comments on commit 7585a28

Please sign in to comment.