JSLinux rewritten to be human readable, hand deobfuscated and annotated.
Go to file
Anselm Levskaya bcaaf741b9 cleaning old comments out 2011-12-21 21:34:05 -08:00
refactoring_hacks cleaning old comments out 2011-12-21 21:34:05 -08:00
CMOS.js Split massive emulator code into logical parts. 2011-12-20 21:34:38 -08:00
KBD.js Split massive emulator code into logical parts. 2011-12-20 21:34:38 -08:00
PCEmulator.js Split massive emulator code into logical parts. 2011-12-20 21:34:38 -08:00
PIC.js Split massive emulator code into logical parts. 2011-12-20 21:34:38 -08:00
PIT.js Split massive emulator code into logical parts. 2011-12-20 21:34:38 -08:00
Serial.js Split massive emulator code into logical parts. 2011-12-20 21:34:38 -08:00
clipboard.js Split massive emulator code into logical parts. 2011-12-20 21:34:38 -08:00
cpux86-ta.js cleaning old comments out 2011-12-21 21:34:05 -08:00
cpux86-ta.original.js added the actual original cpu code for reference 2011-12-21 01:08:54 -08:00
index.html Split massive emulator code into logical parts. 2011-12-20 21:34:38 -08:00
jslinux.js moved files 2011-12-16 21:38:46 -08:00
linuxstart-20110820.tar.gz more notes 2011-12-17 04:22:50 -08:00
linuxstart.bin moved files 2011-12-16 21:38:46 -08:00
readme.md autoannotated the opcodes 2011-12-21 21:04:44 -08:00
root.bin moved files 2011-12-16 21:38:46 -08:00
term.js moved files 2011-12-16 21:38:46 -08:00
vmlinux-2.6.20.bin moved files 2011-12-16 21:38:46 -08:00

readme.md

Fabrix - (De-obfuscated) JSLinux

I wanted to understand how the amazing JsLinux worked. However, Mr Bellard seems to have applied a decidedly french proclivity towards obfuscatory algorithmic prose, replete with two-letter variable names and the like... ;) I have no idea if he passed it through a minifier or if the code was generated algorithmically from stuff in the QEMU codebase. In any case, it's hard to follow the action as presented originally, let alone extend it to do new tricks.

So in order to better understand the code, I started transforming all the symbols and commenting it up, which isn't all that hard a thing to do given that it's been built to imitate a very well-specified piece of hardware.

In the tiny off-chance someone else might be interested I'm posting this "cheat sheet" version of the code here.

Status

It's still absolutely ungainly, but not nearly so ungainly as the original. About a third to a half of the variables/function names have been redescribed. The names are basically long comments and will ultimately need to be redone once the whole is understood.

The core opcode execution loop has been autocommented to indicate what instruction operation the opcode refers to.

I highly recommend, by the way, the excellent JSShaper library for transforming large javascript code bases. The hacks I made from it are in this repo: a little symbol-name-transformer node.js script and an emacs function for doing this in live buffers.

Caveat Coder

This is a pedagogical reinterpretation of the original JSLinux code Copyright (c) 2011 Fabrice Bellard.

There's no alteration in the algorithmic content. I do check that that it still runs, but I won't guarantee anything else.

References

Some other helpful references for understanding what's going on:

http://ref.x86asm.net/coder32.html#xC4 http://en.wikibooks.org/wiki/X86_Assembly/X86_Architecture http://en.wikipedia.org/wiki/X86 http://en.wikipedia.org/wiki/Control_register http://en.wikipedia.org/wiki/X86_assembly_language http://en.wikipedia.org/wiki/Translation_lookaside_buffer http://en.wikibooks.org/wiki/Serial_Programming/8250_UART_Programming