GithubHelp home page GithubHelp logo

nepx / halfix Goto Github PK

View Code? Open in Web Editor NEW
635.0 20.0 81.0 2.34 MB

x86 PC emulator that runs both natively and in the browser, via WebAssembly

Home Page: https://nepx.github.io/halfix-demo/

License: GNU General Public License v3.0

C 91.43% C++ 0.32% HTML 1.61% JavaScript 6.64%
emulator x86 emscripten pc-emulator c99 webassembly pentium cpu-emulator x86-emulator javascript

halfix's People

Contributors

mthiim avatar nepx avatar pgodwin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

halfix's Issues

x86-64 and some upgrade?

yeah i know it'll be hard to do, but a 64-bit pentium 4 upgrade would be very nice
i think 386/486 emulator is really good for low-end hosts, so you might think about adding it in the browser, nepx :)
and about video card, i think i would be great to add a 3dfx voodoo 3 or 5 or cga (low-end) or even nvidia geforce 256 i think ;)
also, network and sounds :)

Options handling

Hi,
I'm quite impressed with what you've done with this project. But I ran into a problem, as I wanted to have a play with the "native" version (on a Linux system). I initially failed to get the '-c' option to work for me.

First up, I believe that the "long" options typically work with a double dash (e.g. '--help'), and the "short" alias with a single dash (e.g. '-h'), which is not what the help text actually shows. This might be addressed via a small change to 'src/main.c':

@@ -51 +51 @@ static void generic_help(const struct op
-        int linelength = sprintf(line, " -%s", o->name);
+        int linelength = sprintf(line, " --%s", o->name);
@@ -53 +53 @@ static void generic_help(const struct op
-            linelength += sprintf(line + linelength, " --%s", o->alias);
+            linelength += sprintf(line + linelength, " -%s", o->alias);

Secondly, the "custom config file" parameter does not get parsed correctly, which I managed to solve for myself (in the same source file) via:

@@ -88 +88 @@ int main(int argc, char** argv)
-                    if (!(data = argv[i++])) {
+                    if (!(data = argv[++i])) {

Cheers,
Martin

Native build on osx has missing color channels?

Ex: This happens for at least win2k and win98 when using a native build. The emscripten build has correct rendering with the same images. It seems like the initial blue channel background persists?
Screen Shot 2020-12-26 at 9 53 23 AM

Alpine Linux as docker host with inbound/outbound networking

We’d love to provide commercial support for this project especially if we can get inbound/outbound networking working as well as being able to get docker working inside a lightweight host distribution like Alpine Linux.

Sorry to open an issue over this, but I couldn’t find your contact information anywhere. Please shoot me an email at matthew at clutch dot io if you are interested. Either way, this is such a cool project that opens up many great possibilities!

Regression testing?

It would be nice to have some instruction regression tests to be sure that the implementation would be consistent with real x86.

Can't increase ram? (192mb limit on browser)

I get an error when I try to run Windows XP on the browser when I increase the ram.
Is there any way to make ram reach 1GB for example?
Thanks in advance, this is an amazing project

Initialize FPU by default

Even though real operating systems will initialize FPU during their boot process (by issuing finit instruction), it would be more convenient for libcpu user if the FPU was already initialized.

Failing to compile

remy@DESKTOP-O6A3FTL:/mnt/c/Users/Matt/halfix$ node makefile.js emscripten release
[
  '-lSDL',
  '-lSDLmain',
  '-lm',
  '-lz',
  '-s',
  'NO_FILESYSTEM=1',
  '-s',
  'TOTAL_MEMORY=256MB',
  '',
  '-s',
  'WASM=0'
]
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/pc.c -c -o build/objs/94-pc-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/util.c -c -o build/objs/94-util-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/state.c -c -o build/objs/94-state-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/io.c -c -o build/objs/94-io-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/display.c -c -o build/objs/94-display-1b228.o -Iincludeemcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/drive.c -c -o build/objs/94-drive-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/emscripten/emscripten.c -c -o build/objs/14h-emscripten-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/ini.c -c -o build/objs/94-ini-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/host/net-none.c -c -o build/objs/mt-net-none-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/access.c -c -o build/objs/jj-access-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/trace.c -c -o build/objs/jj-trace-1b228.o -Iincludeemcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/seg.c -c -o build/objs/jj-seg-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/cpu.c -c -o build/objs/jj-cpu-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/mmu.c -c -o build/objs/jj-mmu-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/ops/ctrlflow.c -c -o build/objs/u8-ctrlflow-1b228.o -Iinclude
src/emscripten/emscripten.c:29:5: error: expected expression
    EM_ASM_({
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/smc.c -c -o build/objs/jj-smc-1b228.o -Iinclude
    ^
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/decoder.c -c -o build/objs/jj-decoder-1b228.o -Iinclude
/usr/share/emscripten/system/include/emscripten/emscripten.h:97:71:emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/eflags.c -c -o build/objs/jj-eflags-1b228.o -Iinclude
 noteemcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/prot.c -c -o build/objs/jj-prot-1b228.o -Iinclude
: expanded emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/opcodes.c -c -o build/objs/jj-opcodes-1b228.o -Iinclude
from macro 'EM_ASM_'
#define EM_ASM_(code, ...) emscripten_asm_const_int(#code, __VA_ARGS__)
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/ops/arith.c -c -o build/objs/u8-arith-1b228.o -Iinclude
                                                                      ^
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/ops/io.c -c -o build/objs/u8-io-1b228.o -Iinclude
1 error generatedemcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/ops/string.c -c -o build/objs/u8-string-1b228.o -Iinclude
.
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/ops/stack.c -c -o build/objs/u8-stack-1b228.o -Iinclude
ERROR    root: compiler frontend failed to generate LLVM bitcode, halting
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/ops/misc.c -c -o build/objs/u8-misc-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/ops/bit.c -c -o build/objs/u8-bit-1b228.o -Iincludeemcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/softfloat.c -c -o build/objs/jj-softfloat-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/fpu.c -c -o build/objs/jj-fpu-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/cpu/ops/simd.c -c -o build/objs/u8-simd-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/dma.c -c -o build/objs/xx-dma-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/cmos.c -c -o build/objs/xx-cmos-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/pit.c -c -o build/objs/xx-pit-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/pic.c -c -o build/objs/xx-pic-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/kbd.c -c -o build/objs/xx-kbd-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/vga.c -c -o build/objs/xx-vga-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/ide.c -c -o build/objs/xx-ide-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/pci.c -c -o build/objs/xx-pci-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/apic.c -c -o build/objs/xx-apic-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/ioapic.c -c -o build/objs/xx-ioapic-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/fdc.c -c -o build/objs/xx-fdc-1b228.o -Iinclude
emcc -Wall -Wextra -Werror -std=gnu99 -DEMSCRIPTEN_BUILD -O3 src/hardware/acpi.c -c -o build/objs/xx-acpi-1b228.o -Iinclude
Failed to compile: src/emscripten/emscripten.c
40/41 compiled successfully!
src/emscripten/emscripten.c

Any help would be greatly appreciated. Anything as simple as "it's on my end" or "it's on your end"

Thanks

Another corner case shift issue

The following snippet

stc
mov $0x00, %al
rcr $0x20, %al

sets al to 0x8, while 0 is expected, as x86 masks the shift count with 0x1f before the rotate.

Disk Image documentation update

Firstly, thanks for creating this project. I'm impressed with the compatibility so far, especially with OS/2 working out of the box - this seems to be quite a feet!

Just a note that https://github.com/nepx/halfix/wiki/Disk-Images#modifying-disk-images is out of date

To enable write, set the ALLOW_READWRITE macro in src/drive.c to 1. This will allow changes to all disk images to be written back to the disk.

TODO: make this a run-time option.

Should be:

To enable write, set writeback=1 in your configuration. This will allow changes to all disk images to be written back to the disk.

Thanks again!

Problems building

I'm getting error below when trying to build. I'm using a fresh installed node.js (12.9.0) and EMSDK on Ubuntu 20.04 AMD64. Seems to be a syntax error in emulator-files.json. I've created PR: #13


Running:
node makefile.js emscripten

Yields:

undefined:389
}
^
SyntaxError: Unexpected token } in JSON at position 9852
    at JSON.parse (<anonymous>)
    at load_json (/home/martin/halfix/makefile.js:21:17)
    at Object.<anonymous> (/home/martin/halfix/makefile.js:27:16)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (intern

out of memory

I've installed Windows 98 SE (OEM) on halfix and it works good (with splitted/normal image).
But when I'm running in browser:
image
Host: Windows 10 x64 Pro
Browser: Google Chrome
Memory: 16GB

lib/drive-filereader.js is missing

Wanted to try the emscripten build of halfix.

Looks like there's a file that's missing from git:

<script src="lib/drive-filereader.js"></script>

The file is not in the repo, I assume its also where dynCall_vii would be implemented, as it ends up being undefined.

Dedicated website

Great job on this project, it's nice to see another x86 emulator which can target the web. It's written very nicely too, so props to you!

I think it would be great to see a dedicated website for this so that people can easily try it out. I guess some more work might need to be done on save states?

Windows XP not working in halfix-demo

On Halfix for Windows:
HalfFix
In Browser, before loading screen VM resets:
Browser

  • Host: Windows 10 x64
  • Guest: Windows XP SP3 RUS
  • Memory: 200MB (on first screenshot - 512), Video Memory - 16MB
  • Image
  • Run In Browser Link

On Windows works with .img/splitted image.
In browser in Safe Mode not works

mobile rendering

happy new year!

the in browser emu

tested: nt, react

has no text-input stream
aka

i can not aplay any text, like the login

but mouse works fine

used now opera on Android 10

What does `BIG_ENDIAN` do in fpu.h

I'm not sure what does ifdef with a BIG_ENDIAN does. Is it an attemt to support arbitrary endianness hosts? Well, if it is, then it does not work. Even if standard C had something like that, at my perfectly little endian x86_64 system it is defined somewhere in depths of glibc...

Windows 8 BSOD

Windows 8 doesn't boot. It BSODs (or rather GSODs -- gray screen of death) right after the Windows logo disappears.

Screenshot from 2020-01-01 17-57-54

It's because of a Kernel Data Inpage Error, which, according to this source indicates that Windows 8 couldn't read from the pagefile.

I think it's a hardware issue, specifically pertaining to how hard disk information is read/written. It's not a IDE DMA issue -- I created a Windows 8 disk image that uses the READ/WRITE MULTIPLE command, and it still BSODs this way.

Multi-sector reads/writes to the disk image haven't been extensively tested. I think there's a subtle bug where cross-block writes don't work properly. The only operating system that uses them is OS/2 (which works fine).

It's possible that the BSOD is due to a cross-block bug. Windows XP had trouble booting in the Emscripten version because single sector reads at the end of the block were corrupting the next one. OS/2 sometimes has trouble booting on my Android phone because of multi-block reads.

More investigation is required.

Exploring halfix with emulation of web browsers

This is more a question / inquiry about using halfix.

I've just released an updated version of https://oldweb.today (https://github.com/oldweb-today/oldweb-today), which runs several browsers in JS-based emulators to run old browsers, connected to web archives.
The system connects to a custom network stack, also running in the browser.
Currently, I'm using v86 and basilisk emulators, and it would be neat to also add halfix, eventually.

I'd in trying out Halfix, if it can support more recent browsers, especially ones that can run Flash, probably a later version of Firefox. So far, I haven't been able to get it to load a Win98 image, though it did load WinXP.
To make this performant, would also need to have save state / load state working..

I'm curious what combinations of browsers have been tested and do work well..

Wrong CF value for corner-case shift

Assembly snippet:

mov $0x88, %al
sar $0x09, %al

Set CF on real hardware (and as per intel manual), but your emulator resets it.

Screenshot_20200706_152154

I haven't dug deep into the flags logic for this, so I'm not sure how to fix this problem.

System is deadlocked on memory -- Tinycore Linux 11 in browser (WASM)

Hi!

First of all, thank you for really amazing project!

Trying to boot TinyCore Linux 11 (http://tinycorelinux.net/) in browser (WASM)

and get System is deadlocked on memory error (see attached screenshot).

tc11_fail

Compiled with node makefile.js emscripten release --enable-wasm
Emscripten info: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.39.9, clang version 11.0.0 MacOS

Run in Chrome 80 via serve npm package (via http://localhost:5000/?cda=tc11os)

I think the system is out of memory -- how can I increase available RAM for OS (e.g. via browser address line parameters?)?

Thank you!

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.