pcjs/modules/pcjs/lib
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2014-12-23 16:20:07 -08:00
..
.jshintrc Cleaned up debugger message handling 2014-11-30 12:56:59 -08:00
bus.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
chipset.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
computer.js Updated comments 2014-12-13 11:20:22 -08:00
cpu.js Comment cleanup 2014-12-17 14:47:14 -08:00
debugger.js Updated comments 2014-12-13 11:20:22 -08:00
defines.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
disk.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
fdc.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
hdc.js Updated comments 2014-12-13 11:20:22 -08:00
interrupts.js Starting work on v1.16.4: fixed command-line (Node) version of PCjs 2014-12-11 20:28:29 -08:00
keyboard.js Fixed a problem with the right SHIFT key, and with webkit browsers when pressing/releasing both SHIFT keys together 2014-12-15 17:23:10 -08:00
memory.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
messages.js Starting work on v1.16.4: fixed command-line (Node) version of PCjs 2014-12-11 20:28:29 -08:00
mouse.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
nodebugger.js Removed some dead code 2014-12-12 09:20:02 -08:00
panel.js Updated comments 2014-12-13 11:20:22 -08:00
ram.js Updated comments 2014-12-13 11:20:22 -08:00
README.md Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:20:07 -08:00
rom.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
serialport.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
state.js Enhanced INT return handling, and reorganized some disks. 2014-12-13 10:09:13 -08:00
video.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
x86.js Starting work on v1.16.4: fixed command-line (Node) version of PCjs 2014-12-11 20:28:29 -08:00
x86cpu.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
x86grps.js Enhanced INT return handling, and reorganized some disks. 2014-12-13 10:09:13 -08:00
x86help.js Enhanced INT return handling, and reorganized some disks. 2014-12-13 10:09:13 -08:00
x86mods.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
x86op0f.js Starting work on v1.16.4: fixed command-line (Node) version of PCjs 2014-12-11 20:28:29 -08:00
x86opxx.js Groundwork laid for upcoming BACKTRACK support 2014-12-23 16:02:41 -08:00
x86seg.js Starting work on v1.16.4: fixed command-line (Node) version of PCjs 2014-12-11 20:28:29 -08:00

PCjs Sources

Structure

All the code for PCjs is contained in the following JavaScript files, which roughly divide the functionality into major PC components, aka "devices". However, not every file implements a device, and "component" is an overloaded term, since Component is also the name of the shared base class used for most PCjs devices (see component.js). So it's best to refer to these files generically as "modules", and more specifically as "device modules" whenever they implement a specific device (or set of devices, in the case of ChipSet).

Examples of non-device modules include UI modules like panel.js and debugger.js, and sub-modules like x86opxx.js, x86mods.js and x86help.js that separate the CPU functionality of x86.js into more manageable pieces.

These modules should always be loaded or compiled in the order listed by the pcJSFiles property in package.json, which includes all the necessary shared modules as well. At the time of this writing, the order is:

Some of the modules can be reordered or even omitted (eg, debugger.js or embed.js), but you should observe the following:

  • component.js must be listed before any module that extends Component
  • panel.js should be loaded early to initialize the Control Panel (if any) as soon as possible
  • computer.js should be the last device module, as it supervises and notifies all the other device modules

To minimize ordering requirements, the init() handlers and constructors of all modules should avoid referencing other modules. Device modules should define an initBus() notification handler, which the Computer will call after it has created/initialized the Bus object.

Features

[List of major existing features goes here]

BackTrack Support

The next major feature to be implemented is referred to as BackTrack Support, or simply BackTracks. When BackTracks are enabled, every memory location (at the byte level) and every general-purpose byte register may have an optional link back to its source. These links are called BackTrack indexes.

All the code that a virtual machine initially executes enters the machine either via ROM or disk sectors, and as that code executes, the machine is loading data into registers from memory locations and/or I/O ports and writing the results to other memory locations and/or I/O ports. BackTracks keep track of that data flow, allowing us to examine the history of any piece of data at any time, down to the byte level; while this feature could be extended to the bit level, it would make the feature dramatically more expensive, both in terms of size and speed.

A BackTrack index is encoded as a 32-bit value with three parts:

  • 15-bit BackTrack object index
  • 9-bit source object offset (0-511)
  • 6-bit generation number (1-63)

This represents a total of 30 bits, with 2 bits reserved.

Let's look at one of the last things a ROM does during boot: load a disk sector into RAM. It will be up to the disk controller (or DMA controller if one is used) to create a BackTrack object representing the sector that was read, adding that object to the global BackTrack object array, and then associating the corresponding BackTrack index with the first byte of RAM where the sector was loaded. Subsequent bytes of RAM containing the rest of the sector will refer to the same BackTrack object, using BackTrack indexes containing offsets 1-511.