Skip to content

Commit

Permalink
Use at least 64mb of memory if initrd is used
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Aug 27, 2024
1 parent 3c07e3c commit 2be07a1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,16 +702,17 @@ CPU.prototype.reset_memory = function()
this.mem8.fill(0);
};

/** @export */
CPU.prototype.create_memory = function(size)
CPU.prototype.create_memory = function(size, minimum_size)
{
if(size < 1024 * 1024)
if(size < minimum_size)
{
size = 1024 * 1024;
size = minimum_size;
dbg_log("Rounding memory size up to " + size, LOG_CPU);
}
else if((size | 0) < 0)
{
size = Math.pow(2, 31) - MMAP_BLOCK_SIZE;
dbg_log("Rounding memory size down to " + size, LOG_CPU);
}

size = ((size - 1) | (MMAP_BLOCK_SIZE - 1)) + 1 | 0;
Expand All @@ -730,8 +731,10 @@ CPU.prototype.create_memory = function(size)

CPU.prototype.init = function(settings, device_bus)
{
this.create_memory(typeof settings.memory_size === "number" ?
settings.memory_size : 1024 * 1024 * 64);
this.create_memory(
settings.memory_size || 64 * 1024 * 1024,
settings.initrd ? 64 * 1024 * 1024 : 1024 * 1024,
);

if(settings.disable_jit)
{
Expand Down

0 comments on commit 2be07a1

Please sign in to comment.