diff --git a/CMOS.js b/CMOS.js index 99a2187..c2714a1 100644 --- a/CMOS.js +++ b/CMOS.js @@ -1,5 +1,8 @@ /* -Fabrix - An annotated version of the original JSLinux which is Copyright (c) 2011 Fabrice Bellard + JSLinux-deobfuscated - An annotated version of the original JSLinux. + + Original is Copyright (c) 2011-2012 Fabrice Bellard + Redistribution or commercial use is prohibited without the author's permission. Clock Emulator */ @@ -30,7 +33,7 @@ CMOS.prototype.ioport_write = function(mem8_loc, data) { // the high order bit is used to indicate NMI masking // low order bits are used to address CMOS // the index written here is used on an ioread 0x71 - this.cmos_index = data & 0x7f; + this.cmos_index = data & 0x7f; } }; CMOS.prototype.ioport_read = function(mem8_loc) { diff --git a/KBD.js b/KBD.js index a0357dd..9ace74f 100644 --- a/KBD.js +++ b/KBD.js @@ -1,5 +1,8 @@ /* -Fabrix - An annotated version of the original JSLinux which is Copyright (c) 2011 Fabrice Bellard +JSLinux-deobfuscated - An annotated version of the original JSLinux. + +Original is Copyright (c) 2011-2012 Fabrice Bellard +Redistribution or commercial use is prohibited without the author's permission. Keyboard Device Emulator */ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..16588ed --- /dev/null +++ b/LICENSE @@ -0,0 +1,4 @@ +This is a derivative work of JSLinux and is posted here with permission of the author. + +JSLinux is Copyright (c) 2011-2013 Fabrice Bellard +Redistribution or commercial use is prohibited without the author's permission. diff --git a/PCEmulator.js b/PCEmulator.js index 5308a61..3525d59 100644 --- a/PCEmulator.js +++ b/PCEmulator.js @@ -1,5 +1,8 @@ /* -Fabrix - An annotated version of the original JSLinux which is Copyright (c) 2011 Fabrice Bellard +JSLinux-deobfuscated - An annotated version of the original JSLinux. + +Original is Copyright (c) 2011-2012 Fabrice Bellard +Redistribution or commercial use is prohibited without the author's permission. Main PC Emulator Routine */ diff --git a/PIC.js b/PIC.js index 97315b9..5280400 100644 --- a/PIC.js +++ b/PIC.js @@ -1,5 +1,8 @@ /* -Fabrix - An annotated version of the original JSLinux which is Copyright (c) 2011 Fabrice Bellard +JSLinux-deobfuscated - An annotated version of the original JSLinux. + +Original is Copyright (c) 2011-2012 Fabrice Bellard +Redistribution or commercial use is prohibited without the author's permission. 8259 PIC (Programmable Interrupt Controller) Emulation Code */ diff --git a/PIT.js b/PIT.js index 438e593..2d936c7 100644 --- a/PIT.js +++ b/PIT.js @@ -1,7 +1,10 @@ /* -Fabrix - An annotated version of the original JSLinux which is Copyright (c) 2011 Fabrice Bellard +JSLinux-deobfuscated - An annotated version of the original JSLinux. -PIT Emulator +Original is Copyright (c) 2011-2012 Fabrice Bellard +Redistribution or commercial use is prohibited without the author's permission. + +8254 Programmble Interrupt Timer Emulator */ function PIT(PC, ah, bh) { var s, i; diff --git a/Serial.js b/Serial.js index 7a7274d..de4e3eb 100644 --- a/Serial.js +++ b/Serial.js @@ -1,5 +1,8 @@ /* -Fabrix - An annotated version of the original JSLinux which is Copyright (c) 2011 Fabrice Bellard +JSLinux-deobfuscated - An annotated version of the original JSLinux. + +Original is Copyright (c) 2011-2012 Fabrice Bellard +Redistribution or commercial use is prohibited without the author's permission. Serial Controller Emulator */ diff --git a/clipboard.js b/clipboard.js index 15ddd1c..26967de 100644 --- a/clipboard.js +++ b/clipboard.js @@ -1,5 +1,8 @@ /* -Fabrix - An annotated version of the original JSLinux which is Copyright (c) 2011 Fabrice Bellard +JSLinux-deobfuscated - An annotated version of the original JSLinux. + +Original is Copyright (c) 2011-2012 Fabrice Bellard +Redistribution or commercial use is prohibited without the author's permission. Clipboard Device */ diff --git a/cpux86-ta.js b/cpux86-ta.js index 6c9e16b..972b3e0 100644 --- a/cpux86-ta.js +++ b/cpux86-ta.js @@ -1,8 +1,11 @@ /* -Fabrix - An annotated version of the original JSLinux Copyright (c) 2011 Fabrice Bellard -================================================================================================== +JSLinux-deobfuscated - An annotated version of the original JSLinux. + +Original is Copyright (c) 2011-2012 Fabrice Bellard +Redistribution or commercial use is prohibited without the author's permission. A x86 CPU (circa 486 sans FPU) Emulator +====================================================================== Useful references: ====================================================================== @@ -4824,7 +4827,7 @@ CPU_X86.prototype.exec_internal = function(N_cycles, interrupt) { var z; z = segment_isnt_accessible(selector, is_verw); _src = get_conditional_flags(); - + // clear eflags.zf if selector is accessible and (readable (for VERR) or writable (for VERW)) if (z) _src |= 0x0040; diff --git a/readme.md b/readme.md index e48e243..4fb8230 100644 --- a/readme.md +++ b/readme.md @@ -3,17 +3,14 @@ De-obfuscated JSLinux I wanted to understand how the amazing [JsLinux][1] worked. -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. - -I hand de-obfuscated the codebase (primarily the core cpu-emulation -routines and a bit of the rest as well) while studying it over a few -days' time. +However the original was passed through a minifier and was completely incomprehensible in that form. (Mr Bellard's standards for the code that he open sources is very high.) I couldn't wait for the proper release of the opus, so in a fit of mania I hand de-obfuscated the codebase (primarily the core cpu-emulation +routines and a bit of the rest as well) while studying it over a few days' time. In the off-chance someone else might be interested in this code as a basis for further weird in-browser x86 hacking I'm posting this -redacted version of the code here. +redacted version of the code here, with permission of Mr. Bellard. -There is a much more complete, ground-up project to build a 386-style emulator in javascript called [jslm32][3]. +Note that there is a much more readable, ground-up project to build an open-source 386-style emulator in javascript called [jslm32][3]. ### Status It's still a dense code base, it's an emulator of a rather @@ -22,6 +19,8 @@ near so incomprehensible as the original. Nearly all of the global variables and function names have been named somewhat sensibly. Many comments have been added. +It seems to run identically to the original. + The core opcode execution loop has been autocommented to indicate what instruction operation the opcode refers to. @@ -31,10 +30,9 @@ One mystery is, why does CPUID(1) return 8 << 8 in EBX? EBX[15:8] is now used to I highly recommend, by the way, the excellent [JSShaper][2] 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/aesthetic reinterpretation of the original -JSLinux code Copyright (c) 2011 Fabrice Bellard. It seems to run -identically to the original. +### License + +This is a pedagogical/aesthetic derivative of the original JSLinux code Copyright (c) 2011-2013 Fabrice Bellard. It is posted here with permission of the original author subject to his original constraints : Redistribution or commercial use is prohibited without the (original) author's permission. ### References Some other helpful references for understanding what's going on: