Skip to content

Commit

Permalink
Small improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Jan 10, 2014
1 parent 51c5009 commit d89af6d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 38 deletions.
27 changes: 23 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ How to build, run and embed?
- If you want a compressed and fast (ie, with debug code removed) version, you
need Closure Compiler.
Set the path to `compiler.jar` in the Makefile and run `make v86_all.js`.
- ROM and disk images are loaded via AJAX, so if you want to try out `index.html`
- ROM and disk images are loaded via XHR, so if you want to try out `index.html`
locally, make sure to serve it from a local webserver.
- For more details on how to customize the behaviour and interface, see [docs/adapters.md](docs/adapters.md).

Expand All @@ -54,13 +54,32 @@ there might be some actual uses.
If you build something interesting, let me know. However, keep in mind that the project
is not very stable at the moment.

Compatibility
-

Here's an overview of the operating systems supported in v86:

- Linux works pretty well. Graphical boots fails in many versions, but you
mostly get a shell. The mouse is never detected automatically.
- Damn Small Linux (2.4 Kernel): Run with `lowram` and choose PS2 mouse in
xsetup. Takes circa 10 minutes to boot.
- Tinycore, Nanolinux (3.0 kernel): `udev` and `X` fail, but you get a
terminal.
- FreeDOS and Windows 1.01 run pretty good. A few applications cause the OS to
freeze. Some BIOS problems.
- KolibriOS works.
- Haiku boots after 30 minutes. r1alpha4 immediately reboots, the newest version
compiled from source works.




How can I contribute?
-

- Someone who could work on hardware devices, such as a modem or the AT
controller. I'll write an overview for that at a later point, if people are
interested.
- Someone who could work on new hardware devices, such as a modem. I'll write
an overview for that at a later point, if people are interested. Also, help
on the interface would be appreciated.
- Donate. Since Bitcoin is the new cool thing, here's my address:
`14KBXSoewGzbQY8VoznJ5MZXGxoia8RxC9`

Expand Down
9 changes: 4 additions & 5 deletions src/const.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/** @define {boolean} */
var DEBUG = true;

Expand Down Expand Up @@ -30,7 +29,7 @@ var



/** @const */ LOG_LEVEL = LOG_ALL & ~LOG_DMA & ~LOG_PS2 & ~LOG_DISK & ~LOG_PIT;
/** @const */ LOG_LEVEL = LOG_ALL & ~LOG_DMA & ~LOG_DISK & ~LOG_PIT;
///** @const */ LOG_LEVEL = LOG_OTHER | LOG_PS2;
///** @const */ LOG_LEVEL = 0;

Expand All @@ -47,7 +46,7 @@ var
ENABLE_HPET = false,

/** @const */
ENABLE_ACPI = false;
ENABLE_ACPI = true;

var

Expand Down Expand Up @@ -146,8 +145,8 @@ PSE_ENABLED = 128,



/** @const */ LOOP_COUNTER = 4001,
/** @const */ TIME_PER_FRAME = 20;
/** @const */ LOOP_COUNTER = 11001,
/** @const */ TIME_PER_FRAME = 33;


var
Expand Down
41 changes: 28 additions & 13 deletions src/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ function IDEDevice(dev, buffer, is_cd, nr)
{
this.ata_port = 0x1F0;
this.irq = 14;

this.pci_id = 0x1E << 3;
}
else
{
this.ata_port = 0x1F0;
this.irq = 15;
this.irq = 14;

this.pci_id = 0x1F << 3;
}

// alternate status, starting at 3f4/374
Expand All @@ -40,23 +44,35 @@ function IDEDevice(dev, buffer, is_cd, nr)
this.buffer = buffer;
this.is_atapi = is_cd;

this.sector_count = me.buffer.byteLength / this.sector_size;

if(is_cd)
if(buffer)
{
this.head_count = 1;
this.sectors_per_track = 0;
this.sector_count = me.buffer.byteLength / this.sector_size;

if(is_cd)
{
this.head_count = 1;
this.sectors_per_track = 0;
}
else
{
this.head_count = 1;
this.sectors_per_track = 63;
}

this.cylinder_count = me.buffer.byteLength /
this.head_count / (this.sectors_per_track + 1) / this.sector_size;

dbg_assert(this.cylinder_count === (this.cylinder_count | 0));
}
else
{
this.head_count = 1;
this.sectors_per_track = 63;
}
this.sector_count = 0;

this.cylinder_count = me.buffer.byteLength /
this.head_count / (this.sectors_per_track + 1) / this.sector_size;
this.head_count = 0;
this.sectors_per_track = 0;

dbg_assert(this.cylinder_count === (this.cylinder_count | 0));
this.cylinder_count = 0;
}

this.stats = {
sectors_read: 0,
Expand All @@ -76,7 +92,6 @@ function IDEDevice(dev, buffer, is_cd, nr)
}
}

this.pci_id = 0x1F << 3;
this.pci_space = [
0x86, 0x80, 0x20, 0x3a, 0x05, 0x00, 0xa0, 0x02, 0x00, 0x8f, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
this.ata_port & 0xFF | 1, this.ata_port >> 8, 0x00, 0x00,
Expand Down
10 changes: 5 additions & 5 deletions src/misc_instr.macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function getcf()
{
if(flags_changed & 1)
{
return !!((last_op1 ^ (last_op1 ^ last_op2) & (last_op2 ^ last_add_result)) & last_op_size);
return +!!((last_op1 ^ (last_op1 ^ last_op2) & (last_op2 ^ last_add_result)) & last_op_size);
}
else
{
Expand Down Expand Up @@ -247,7 +247,7 @@ function pusha16()

// make sure we don't get a pagefault after having
// pushed several registers already
translate_address_write(temp - 15);
translate_address_write(get_seg(reg_ss) + temp - 15);

push16(reg16[reg_ax]);
push16(reg16[reg_cx]);
Expand All @@ -263,7 +263,7 @@ function pusha32()
{
var temp = reg32s[reg_esp];

translate_address_write(temp - 31);
translate_address_write(get_seg(reg_ss) + temp - 31);

push32(reg32s[reg_eax]);
push32(reg32s[reg_ecx]);
Expand All @@ -277,7 +277,7 @@ function pusha32()

function popa16()
{
translate_address_read(stack_reg[reg_vsp] + 15);
translate_address_read(get_seg(reg_ss) + stack_reg[reg_vsp] + 15);

reg16[reg_di] = pop16();
reg16[reg_si] = pop16();
Expand All @@ -291,7 +291,7 @@ function popa16()

function popa32()
{
translate_address_read(stack_reg[reg_vsp] + 31);
translate_address_read(get_seg(reg_ss) + stack_reg[reg_vsp] + 31);

reg32[reg_edi] = pop32s();
reg32[reg_esi] = pop32s();
Expand Down
12 changes: 3 additions & 9 deletions src/modrm.macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var modrm_table16 = Array(0xC0),
modrm_table16[n] = function() { return offset | 0; };


#define getsib(mod)\
sib_table[read_imm8()](mod)

entry16(0, ds, reg16[reg_bx] + reg16[reg_si])
entry16(1, ds, reg16[reg_bx] + reg16[reg_di])
entry16(2, ss, reg16[reg_bp] + reg16[reg_si])
Expand Down Expand Up @@ -140,15 +143,6 @@ modrm_resolve32 = function(modrm_byte)
return modrm_table32[modrm_byte]();
}

/**
* @param {boolean} mod
* @return {number}
*/
function getsib(mod)
{
return sib_table[read_imm8()](mod);
}

#undef ds
#undef ss

Expand Down
4 changes: 2 additions & 2 deletions src/pci.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function PCI(dev)

if(space)
{
(new Uint8Array(space.buffer))[addr | byte_pos] = byte;
//(new Uint8Array(space.buffer))[addr | byte_pos] = byte;

if(byte_pos === 3 && addr >= 0x10 && addr < 0x28)
{
Expand All @@ -189,7 +189,7 @@ function PCI(dev)
if(bar)
{
dbg_assert(!(bar.size & bar.size - 1));
space[addr >> 2] = value & ~(bar.size - 1) | 3;
//space[addr >> 2] = value & ~(bar.size - 1) | 3;
}
else
{
Expand Down

0 comments on commit d89af6d

Please sign in to comment.