From 1f7ca9fd3964481318bbaddfb39acc5de8c7d65d Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sun, 20 Sep 2009 23:10:31 +0200 Subject: Basic makefile structure; making the project at least compilable. --- Database/internals/database-internal.cpp | 5 +++-- Database/internals/database-internal.h | 4 ++-- Database/internals/database-references.cpp | 11 +++++++---- Database/internals/database-references.h | 18 +++++++++++------- Database/internals/database-segment.cpp | 16 ++++++++++------ Database/internals/database-segment.h | 3 ++- 6 files changed, 35 insertions(+), 22 deletions(-) (limited to 'Database/internals') diff --git a/Database/internals/database-internal.cpp b/Database/internals/database-internal.cpp index e19222a..e564c01 100644 --- a/Database/internals/database-internal.cpp +++ b/Database/internals/database-internal.cpp @@ -1,10 +1,11 @@ #include "database-internal.h" +#include "database.h" DatabaseCell::DatabaseCell(Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size, DatabaseCell * prev, Database * parent) : cpu(cpu), next(0), prev(prev), parent(parent) { prev->next = this; parent->setEnd(this); - if (origin) { - Segment * origin_seg = parent->GetSegment(SEGID(origin)); + if (origin.raw_ptr) { + Segment * origin_seg = parent->getSegment(SEGID(origin)); segment = new Segment(size, cpu_base, parent->GetNextSegId(), extra_size, origin_seg->getPristineMemory() + SEGOFFSET(origin)); } else { segment = new Segment(size, cpu_base, parent->GetNextSegId(), extra_size); diff --git a/Database/internals/database-internal.h b/Database/internals/database-internal.h index f63b40e..5ca6050 100644 --- a/Database/internals/database-internal.h +++ b/Database/internals/database-internal.h @@ -19,9 +19,9 @@ class DatabaseCell : public Base { * it'll create a sub-segment based on the first one. Note also that this doesn't support * the patching system, yet. */ - DatabaseCell(Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size, DatabaseCell * prev); + DatabaseCell(Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size, DatabaseCell * prev, Database * parent); ~DatabaseCell(); - Uint32 getID() { return segment->GetID(); } + Uint32 getID() { return segment->getId(); } void LoadMemory(Handle * src) { segment->LoadMemory(src); } Segment * getSegment() { return segment; } Cpu * getCpu() { return cpu; } diff --git a/Database/internals/database-references.cpp b/Database/internals/database-references.cpp index c138698..30841bf 100644 --- a/Database/internals/database-references.cpp +++ b/Database/internals/database-references.cpp @@ -1,12 +1,15 @@ +#include + #include "database-references.h" +#include "database.h" RefFrom::RefFrom(RefTo * refTo, SegmentRefData * data) : refTo(refTo), data(data) { - assert(refto); + assert(refTo); assert(data); next = data->getRefFrom(); prev = 0; - data->firstRefFrom = this; + data->setFirstRefFrom(this); if (next) next->prev = this; } @@ -24,7 +27,7 @@ RefTo::RefTo(absolute_ptr ptr, SegmentRefData * data, Database * database) : dat assert(database); Segment * destSeg = database->getSegment(ptr.segment_id); assert(destSeg); - refFrom = new RefFrom(this, destSeg->getSegmentRefData(ptr.ptr); + refFrom = new RefFrom(this, destSeg->getSegmentRefData(ptr.ptr)); RefTo * t = data->getRefTo(); if (t) { @@ -34,7 +37,7 @@ RefTo::RefTo(absolute_ptr ptr, SegmentRefData * data, Database * database) : dat } RefTo::~RefTo() { - data->refTo = 0; + data->setRefTo(0); delete refFrom; } diff --git a/Database/internals/database-references.h b/Database/internals/database-references.h index 278b531..6ad64bd 100644 --- a/Database/internals/database-references.h +++ b/Database/internals/database-references.h @@ -1,9 +1,10 @@ #ifndef __DATABASE_REFERENCES_H__ #define __DATABASE_REFERENCES_H__ -class SegmentData; -class RefFrom; +#include "database-segment.h" + class RefTo; +class Database; /** The reference system, where the database will be able to hold references from and to memory pointers. */ @@ -11,8 +12,8 @@ class RefTo; class RefFrom : public Base { public: RefFrom(RefTo * refTo, SegmentRefData * data); - ~RefFrom() - SegmentRefData * getRefSegData() { return refTo->getSegRefData(); } + ~RefFrom(); + SegmentRefData * getRefSegData(); SegmentRefData * getSegRefData() { return data; } RefFrom * getNext() { return next; } private: @@ -23,19 +24,22 @@ class RefFrom : public Base { class RefTo : public Base { public: - RefTo(Uint32 ptr, SegmentRefData * data); + RefTo(absolute_ptr ptr, SegmentRefData * data, Database *); ~RefTo(); - SegmentRefData * getRefSegData() { return refFrom->getSegRefData(); } + SegmentRefData * getRefSegData(); SegmentRefData * getSegRefData() { return data; } private: RefFrom * refFrom; SegmentRefData * data; }; +inline SegmentRefData * RefFrom::getRefSegData() { return refTo->getSegRefData(); } +inline SegmentRefData * RefTo::getRefSegData() { return refFrom->getSegRefData(); } + class SegmentRefData : public Base { public: SegmentRefData(Uint32 ptr, Segment * seg); - ~SegmentRefData() + ~SegmentRefData(); Uint32 getPtr() { return ptr; } Segment * getSegment() { return seg; } SegmentRefData * getSegmentRefData(Uint32 ptr) { return seg->getSegmentRefData(ptr); } diff --git a/Database/internals/database-segment.cpp b/Database/internals/database-segment.cpp index 55689f8..8ee5b4b 100644 --- a/Database/internals/database-segment.cpp +++ b/Database/internals/database-segment.cpp @@ -1,6 +1,10 @@ +#include + +#include +#include #include "database-segment.h" -Segment::Segment(Uint32 size, Uint32 id, Uint64 cpu_base, Uint32 extra_size, const Byte * data) : patches(0), plainmemory(0), size(size), extra_size(extra_size), id(id), cpu_base(cpu_base) { +Segment::Segment(Uint32 size, Uint32 id, Uint64 cpu_base, Uint32 extra_size, const Byte * data) : plainmemory(0), patches(0), size(size), extra_size(extra_size), id(id), cpu_base(cpu_base) { Uint64 fullsize = size + extra_size; assert(size); @@ -8,7 +12,7 @@ Segment::Segment(Uint32 size, Uint32 id, Uint64 cpu_base, Uint32 extra_size, con if (data) { plainmemory = (Byte *) data; loaded = true; - allocated = false + allocated = false; } else { plainmemory = Allocator::alloc(size); loaded = false; @@ -23,7 +27,7 @@ Segment::~Segment() { Allocator::free(plainmemory); if (patches) Allocator::free(patches); - if (patchesmemory) + if (patchesmap) Allocator::free(patchesmap); Allocator::free(tags); Allocator::free(refData); @@ -82,10 +86,10 @@ void Segment::LoadMemory(Handle * src) { return; } - src->Read(plainmemory, size); + src->read(plainmemory, size); } -void setTag(Uint32 ptr, memory_tags_t tag) { +void Segment::setTag(Uint32 ptr, memory_tags_t tag) { if (ptr >= (size + extra_size)) { LOG(CONSOLE, ERROR, "Out of bound setTag attempt in segment %i at %08X\n", id, ptr); return; @@ -93,7 +97,7 @@ void setTag(Uint32 ptr, memory_tags_t tag) { tags[ptr] = tag; } -memory_tags_t getTag(Uint32 ptr) { +memory_tags_t Segment::getTag(Uint32 ptr) { if (ptr >= (size + extra_size)) { memory_tags_t z = { 0, 0 }; LOG(CONSOLE, ERROR, "Out of bound getTag attempt in segment %i at %08X\n", id, ptr); diff --git a/Database/internals/database-segment.h b/Database/internals/database-segment.h index a08b149..f01ac38 100644 --- a/Database/internals/database-segment.h +++ b/Database/internals/database-segment.h @@ -1,6 +1,7 @@ #ifndef __DATABASE_SEGMENT_H__ #define __DATABASE_SEGMENT_H__ +#include #include "database-types.h" class SegmentRefData; @@ -67,6 +68,6 @@ class Segment : public Base { Uint32 size, extra_size; Uint32 id; Uint64 cpu_base; -} +}; #endif -- cgit v1.2.3