Skip to content

Commit

Permalink
Increase page fault queue size
Browse files Browse the repository at this point in the history
  • Loading branch information
schellingb committed Apr 26, 2022
1 parent 850e31b commit 2dcba68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/cpu/paging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ struct PF_Entry {
Bitu mpl;
};

#ifdef C_DBP_LIBRETRO
// Increased to survive longer in Windows 9x
#define PF_QUEUESIZE 384
#else
#define PF_QUEUESIZE 16
#endif
static struct {
Bitu used;
PF_Entry entries[PF_QUEUESIZE];
Expand Down Expand Up @@ -145,6 +150,7 @@ void PAGING_PageFault(PhysPt lin_addr,Bitu page_addr,Bitu faultcode) {
old_cpudecoder=cpudecoder;
cpudecoder=&PageFaultCore;
paging.cr2=lin_addr;
DBP_ASSERT(pf_queue.used < PF_QUEUESIZE);
PF_Entry * entry=&pf_queue.entries[pf_queue.used++];
LOG(LOG_PAGING,LOG_NORMAL)("PageFault at %X type [%x] queue %d",lin_addr,faultcode,pf_queue.used);
// LOG_MSG("EAX:%04X ECX:%04X EDX:%04X EBX:%04X",reg_eax,reg_ecx,reg_edx,reg_ebx);
Expand Down Expand Up @@ -910,7 +916,13 @@ void DBPSerialize_Paging(DBPArchive& ar)
ar.SerializeSparse(paging.links.entries, sizeof(paging.links.entries));
ar.SerializeArray(paging.firstmb);
ar.Serialize(paging.enabled);
ar.Serialize(pf_queue);
if (ar.version <= 3)
ar.SerializeBytes(&pf_queue, sizeof(pf_queue) - sizeof(pf_queue.entries) + sizeof(pf_queue.entries[0]) * 16);
else
{
ar.Serialize(pf_queue.used);
ar.SerializeBytes(&pf_queue.entries, pf_queue.used * sizeof(pf_queue.entries[0]));
}

if (ar.mode == DBPArchive::MODE_LOAD)
PAGING_InitTLB();
Expand Down
6 changes: 3 additions & 3 deletions src/dbp_serialize.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Bernhard Schelling
* Copyright (C) 2020-2022 Bernhard Schelling
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -269,14 +269,14 @@ void DBPSerialize_All(DBPArchive& ar, bool dos_running, bool game_running)
Bit64s from = __rdtsc();
#endif

ar.version = 3;
ar.version = 4;
if (ar.mode != DBPArchive::MODE_ZERO)
{
Bit32u magic = 0xD05B5747;
Bit8u invalid_state = (dos_running ? 0 : 1) | (game_running ? 0 : 2);
ar << magic << ar.version << invalid_state;
if (magic != 0xD05B5747) { ar.had_error = DBPArchive::ERR_LAYOUT; return; }
if (ar.version < 1 || ar.version > 3) { DBP_ASSERT(false); ar.had_error = DBPArchive::ERR_VERSION; return; }
if (ar.version < 1 || ar.version > 4) { DBP_ASSERT(false); ar.had_error = DBPArchive::ERR_VERSION; return; }
if (ar.mode == DBPArchive::MODE_LOAD || ar.mode == DBPArchive::MODE_SAVE)
{
if (!dos_running || (invalid_state & 1)) { ar.had_error = DBPArchive::ERR_DOSNOTRUNNING; return; }
Expand Down

0 comments on commit 2dcba68

Please sign in to comment.