summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2009-09-21 03:37:45 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2009-09-21 03:37:45 +0200
commit14d90c9e1171655b864316c9c4aa34033fdd3a45 (patch)
tree3c297e80f774b4a6452331ff840fe6c415875e11
parent8c9c24358cca81cdb15462cb74afc5f173966c79 (diff)
Very first bit towards a Mips/PSX disassembler
-rw-r--r--Cpu/Makefile16
-rw-r--r--Cpu/cpu-mips.cpp0
-rw-r--r--Cpu/cpu.cpp0
-rw-r--r--Database/database-types.h1
-rw-r--r--Database/database.h6
-rw-r--r--Database/internals/database-internal.cpp8
-rw-r--r--Database/internals/database-internal.h4
-rw-r--r--Database/internals/database-segment.h1
-rw-r--r--Loader/loader-psyq.cpp20
-rw-r--r--Makefile2
10 files changed, 52 insertions, 6 deletions
diff --git a/Cpu/Makefile b/Cpu/Makefile
new file mode 100644
index 0000000..87835d6
--- /dev/null
+++ b/Cpu/Makefile
@@ -0,0 +1,16 @@
+TARGET = Cpu.a
+
+SRCS = \
+cpu.cpp \
+cpu-mips.cpp \
+
+SPATH =
+
+CPPFLAGS = -I. -I../Database -I../Database/internals
+
+include ../Makefile.cfg
+
+$(TARGET): $(OBJS)
+ $(AR) $@ $^
+
+-include $(DEPS)
diff --git a/Cpu/cpu-mips.cpp b/Cpu/cpu-mips.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Cpu/cpu-mips.cpp
diff --git a/Cpu/cpu.cpp b/Cpu/cpu.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Cpu/cpu.cpp
diff --git a/Database/database-types.h b/Database/database-types.h
index 49db9b8..8ea61e6 100644
--- a/Database/database-types.h
+++ b/Database/database-types.h
@@ -40,6 +40,7 @@ typedef union {
static inline Uint32 SEGID(absolute_ptr ptr) { return ptr.segment_id; }
static inline Uint32 SEGOFFSET(absolute_ptr ptr) { return ptr.ptr; }
+static inline absolute_ptr ABSPTR(Uint32 id, Uint32 ptr) { absolute_ptr r; r.segment_id = id; r.ptr = ptr; return r; }
/** A function description.
*/
diff --git a/Database/database.h b/Database/database.h
index be46598..222573d 100644
--- a/Database/database.h
+++ b/Database/database.h
@@ -22,6 +22,12 @@ class Database : public Base {
return 0;
}
Uint32 GetNextSegId() { return currentId++; }
+ Segment * CreateSegment(Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size = 0, const Byte * data = 0) {
+ DatabaseCell * r = new DatabaseCell(this, cpu, cpu_base, origin, size, extra_size, data);
+ return r->getSegment();
+ }
+ void Serialize(Handle * out);
+ void Deserialize(Handle *in);
private:
DatabaseCell * start, * end;
Uint32 currentId;
diff --git a/Database/internals/database-internal.cpp b/Database/internals/database-internal.cpp
index e564c01..ce54f44 100644
--- a/Database/internals/database-internal.cpp
+++ b/Database/internals/database-internal.cpp
@@ -1,14 +1,16 @@
#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;
+DatabaseCell::DatabaseCell(Database * parent, Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size, const Byte * data) : cpu(cpu), next(0), parent(parent) {
+ prev = parent->getEnd();
+ if (prev)
+ prev->next = this;
parent->setEnd(this);
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);
+ segment = new Segment(size, cpu_base, parent->GetNextSegId(), extra_size, data);
}
}
diff --git a/Database/internals/database-internal.h b/Database/internals/database-internal.h
index 173eb62..4616d8c 100644
--- a/Database/internals/database-internal.h
+++ b/Database/internals/database-internal.h
@@ -17,9 +17,9 @@ class DatabaseCell : public Base {
public:
/** The constructor of a DatabaseCell. Note that if you specify the origin parameter,
* it'll create a sub-segment based on the first one. Note also that this doesn't support
- * the patching system, yet.
+ * the patching system, yet. data and origin are mutually exclusive.
*/
- DatabaseCell(Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size, DatabaseCell * prev, Database * parent);
+ DatabaseCell(Database * parent, Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size = 0, const Byte * data = 0);
~DatabaseCell();
Uint32 getId() { return segment->getId(); }
void LoadMemory(Handle * src) { segment->LoadMemory(src); }
diff --git a/Database/internals/database-segment.h b/Database/internals/database-segment.h
index f01ac38..dc4d157 100644
--- a/Database/internals/database-segment.h
+++ b/Database/internals/database-segment.h
@@ -44,6 +44,7 @@ class Segment : public Base {
* @return the memory block of the segment.
*/
const Byte * getPristineMemory() { return plainmemory; }
+ const memory_tags_t * getMemoryTags() { return tags; }
void Patch(Uint32 ptr, Byte val);
void Restore(Uint32 ptr);
bool IsPatched(Uint32 ptr);
diff --git a/Loader/loader-psyq.cpp b/Loader/loader-psyq.cpp
new file mode 100644
index 0000000..d6d8876
--- /dev/null
+++ b/Loader/loader-psyq.cpp
@@ -0,0 +1,20 @@
+#include "database.h"
+
+union psyq_header_t {
+ struct {
+ Uint8 id[8];
+ Uint32 text, data, pc0, gp0, t_addr, t_size;
+ Uint32 d_addr, d_size, b_addr, b_size, s_addr, s_size;
+ Uint32 sp, fp, gp, ra, s0;
+ };
+ Uint8 raw[0x800];
+};
+
+class loader_psyq : public Base {
+ public:
+ static void load(Handle * input, Database * database) {
+ psyq_header_t head;
+
+ input->read(&head, sizeof(head));
+ }
+};
diff --git a/Makefile b/Makefile
index 52af23e..b7e3e1e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-DIRS=externals Utils Engine Lua Loader Database
+DIRS=externals Database Cpu Engine Lua Loader Utils
all: $(DIRS)