From f90b1c310d91ccc9657697df833a3c8efec4bc53 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Wed, 3 Dec 2003 14:01:11 +0000 Subject: [PATCH] Fix correct releasing of paging links new phys_read/write functions Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1474 --- src/hardware/memory.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/hardware/memory.cpp b/src/hardware/memory.cpp index 37db0530..f9ed5a56 100644 --- a/src/hardware/memory.cpp +++ b/src/hardware/memory.cpp @@ -40,7 +40,7 @@ struct AllocBlock { }; struct LinkBlock { - Bit8u used; + Bitu used; Bit32u pages[MAX_LINKS]; }; @@ -156,6 +156,7 @@ void MEM_SetPageHandler(Bitu phys_page,Bitu pages,PageHandler * handler) { void MEM_UnlinkPages(void) { PAGING_ClearTLBEntries(memory.links.used,memory.links.pages); + memory.links.used=0; } Bitu mem_strlen(PhysPt pt) { @@ -495,6 +496,8 @@ void phys_writed(PhysPt addr,Bit32u val) { Bit32u MEM_PhysReadD(Bitu addr) { Bitu page=addr >> 12; Bitu index=(addr & 4095); + if (page>memory.pages) + E_Exit("Reading from illegal page"); HostPt block=memory.hostpts[page]; if (!block) { E_Exit("Reading from empty page"); @@ -502,6 +505,18 @@ Bit32u MEM_PhysReadD(Bitu addr) { return host_readd(block+index); } +void MEM_PhysWriteD(Bitu addr,Bit32u val) { + Bitu page=addr >> 12; + Bitu index=(addr & 4095); + if (page>memory.pages) + E_Exit("Writing from illegal page"); + HostPt block=memory.hostpts[page]; + if (!block) { + E_Exit("Writing to empty page"); + } + host_writed(block+index,val); +} + static void write_p92(Bit32u port,Bit8u val) { // Bit 0 = system reset (switch back to real mode)