Make the ram(2) allocation failed fatals more user friendly
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#define HAVE_STDARG_H
|
#define HAVE_STDARG_H
|
||||||
#include <86box/86box.h>
|
#include <86box/86box.h>
|
||||||
|
#include <86box/version.h>
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "x86_ops.h"
|
#include "x86_ops.h"
|
||||||
#include "x86.h"
|
#include "x86.h"
|
||||||
@@ -2520,26 +2521,29 @@ mem_reset(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (mem_size > 2097152)
|
if (mem_size > 2097152)
|
||||||
fatal("Attempting to use more than 2 GB of guest RAM\n");
|
fatal("Attempting to use more than 2 GB of emulated RAM\n");
|
||||||
|
|
||||||
#if (!(defined __amd64__ || defined _M_X64))
|
#if (!(defined __amd64__ || defined _M_X64))
|
||||||
if (mem_size > 1048576) {
|
if (mem_size > 1048576) {
|
||||||
ram = (uint8_t *)malloc(1 << 30); /* allocate and clear the RAM block of the first 1 GB */
|
ram = (uint8_t *)malloc(1 << 30); /* allocate and clear the RAM block of the first 1 GB */
|
||||||
if (ram == NULL) {
|
if (ram == NULL) {
|
||||||
fatal("X86 > 1 GB: Failed to malloc() ram\n");
|
fatal("Failed to allocate primary RAM block. Make sure you have enough RAM available.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(ram, 0x00, (1 << 30));
|
memset(ram, 0x00, (1 << 30));
|
||||||
ram2 = (uint8_t *)malloc(m - (1 << 30)); /* allocate and clear the RAM block above 1 GB */
|
ram2 = (uint8_t *)malloc(m - (1 << 30)); /* allocate and clear the RAM block above 1 GB */
|
||||||
if (ram2 == NULL) {
|
if (ram2 == NULL) {
|
||||||
fatal("X86 > 1 GB: Failed to malloc() ram2\n");
|
if (config_changed == 2)
|
||||||
|
fatal(EMU_NAME " must be restarted for the memory amount change to be applied.\n");
|
||||||
|
else
|
||||||
|
fatal("Failed to allocate secondary RAM block. Make sure you have enough RAM available.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(ram2, 0x00, m - (1 << 30));
|
memset(ram2, 0x00, m - (1 << 30));
|
||||||
} else {
|
} else {
|
||||||
ram = (uint8_t *)malloc(m); /* allocate and clear the RAM block */
|
ram = (uint8_t *)malloc(m); /* allocate and clear the RAM block */
|
||||||
if (ram == NULL) {
|
if (ram == NULL) {
|
||||||
fatal("X86 <= 1 GB: Failed to malloc() ram\n");
|
fatal("Failed to allocate RAM block. Make sure you have enough RAM available.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(ram, 0x00, m);
|
memset(ram, 0x00, m);
|
||||||
@@ -2547,7 +2551,7 @@ mem_reset(void)
|
|||||||
#else
|
#else
|
||||||
ram = (uint8_t *)malloc(m); /* allocate and clear the RAM block */
|
ram = (uint8_t *)malloc(m); /* allocate and clear the RAM block */
|
||||||
if (ram == NULL) {
|
if (ram == NULL) {
|
||||||
fatal("X64: Failed to malloc() ram\n");
|
fatal("Failed to allocate RAM block. Make sure you have enough RAM available.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(ram, 0x00, m);
|
memset(ram, 0x00, m);
|
||||||
|
@@ -622,7 +622,7 @@ win_settings_save(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Mark configuration as changed. */
|
/* Mark configuration as changed. */
|
||||||
config_changed = 1;
|
config_changed = 2;
|
||||||
|
|
||||||
pc_reset_hard_init();
|
pc_reset_hard_init();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user