Coder Social home page Coder Social logo

kingjbbrooks / dax86 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ykskb/dax86

0.0 1.0 0.0 354 KB

xv6-runnable x86 Emulator

Home Page: https://yohei.codes/post/dax86/

License: MIT License

Makefile 5.60% C 77.04% Shell 0.77% Assembly 15.45% Dockerfile 0.05% C++ 1.09%

dax86's Introduction

dax86

x86 (i386) Emulator in C

Why:

  • I wanted to trace how an OS runs on CPUs at archtecture / instruction level.

What:

  • Runs vanilla xv6 (memfs) image from boot.
  • Each instruction is manually implemented and executed sequentially without binary translation or OoOE.
  • Representation of logic is prioritized over the performance. Codes have bunch of comments covering the instructions and the hardware mechanism as well.

Done:

  • Instructions required for running xv6
  • Real mode
  • Protected mode
  • Paging
  • MP configuration
  • Software/Hardware interrupts
  • Device emulation (disk, keyboard, APIC timer, local APIC, IO APIC, UART etc)

To do:

  • FPU-related instructions
  • Exception
  • Virtual 8086 mode
  • TLB

System requirements:

  • Memory: 512MB
  • CPU: scheduler loop will occupy CPU resource. nice command, cgroups or docker resource setting might help here.
Build dax86
make
Run
# basic use
./dax86 [binary_file]

# run xv6 (ctrl + c to stop)
./dax86 xv6memfs.img

# verbose run (prints each op)
./dax86 [binary_file] -v
Setup Environment using Docker

Though dax86 can be built for different targets and run, there's a docker image in case Debian's build-essential package is preferred to the build environment of your host. Mini Debian Jessie is used for the base image.

The command below will build image, run a container with the image and execute shell in interactive mode.

make create-docker

To clean created container and image, run the command below.

make clean-docker
Test
# test all
./test.sh

# test specific one in tests/exec directory
./test.sh [test_name]

# directory test binary (stops at EIP: 0x0)
./dax86 test [binary_file]
Commands to Analyze Test Cases
  • Disassemble Binary
# 32 bit all the way 
ndisasm -b 32 [binary_file]

# 32 bit after 0xFF bytes of real mode instructions
ndisasm -b 32 [binary_file] -k 0,0xFF
  • View Binary
# hex
xxd [bin_file]

# bin
xxd -b [binary_file]

Referenced these publications with many thanks:

dax86's People

Contributors

ykskb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.