Added stubs for mips support

This commit is contained in:
Pierre Pronchery 2011-06-08 01:13:47 +00:00
parent 7edc2f2b6a
commit fe28af3bed
11 changed files with 243 additions and 7 deletions

View File

@ -57,6 +57,7 @@ dist:
$(PACKAGE)-$(VERSION)/src/arch/i586.c \
$(PACKAGE)-$(VERSION)/src/arch/i686.c \
$(PACKAGE)-$(VERSION)/src/arch/java.c \
$(PACKAGE)-$(VERSION)/src/arch/mips.c \
$(PACKAGE)-$(VERSION)/src/arch/sparc.c \
$(PACKAGE)-$(VERSION)/src/arch/sparc64.c \
$(PACKAGE)-$(VERSION)/src/arch/Makefile \
@ -72,6 +73,9 @@ dist:
$(PACKAGE)-$(VERSION)/src/arch/i586.ins \
$(PACKAGE)-$(VERSION)/src/arch/i686.ins \
$(PACKAGE)-$(VERSION)/src/arch/i686.reg \
$(PACKAGE)-$(VERSION)/src/arch/mips.h \
$(PACKAGE)-$(VERSION)/src/arch/mips.ins \
$(PACKAGE)-$(VERSION)/src/arch/mips.reg \
$(PACKAGE)-$(VERSION)/src/arch/null.ins \
$(PACKAGE)-$(VERSION)/src/arch/sparc.h \
$(PACKAGE)-$(VERSION)/src/arch/sparc.ins \
@ -91,6 +95,7 @@ dist:
$(PACKAGE)-$(VERSION)/test/i486.S \
$(PACKAGE)-$(VERSION)/test/i586.S \
$(PACKAGE)-$(VERSION)/test/i686.S \
$(PACKAGE)-$(VERSION)/test/mips.S \
$(PACKAGE)-$(VERSION)/test/java.S \
$(PACKAGE)-$(VERSION)/test/sparc.S \
$(PACKAGE)-$(VERSION)/test/sparc64.S \

View File

@ -1,4 +1,4 @@
TARGETS = amd64.so dalvik.so i386.so i386_real.so i486.so i586.so i686.so java.so sparc.so sparc64.so
TARGETS = amd64.so dalvik.so i386.so i386_real.so i486.so i586.so i686.so java.so mips.so sparc.so sparc64.so
PREFIX = /usr/local
DESTDIR =
LIBDIR = $(PREFIX)/lib
@ -74,6 +74,13 @@ java_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
java.so: $(java_OBJS)
$(LD) -o java.so $(java_OBJS) $(java_LDFLAGS)
mips_OBJS = mips.o
mips_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
mips_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
mips.so: $(mips_OBJS)
$(LD) -o mips.so $(mips_OBJS) $(mips_LDFLAGS)
sparc_OBJS = sparc.o
sparc_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
sparc_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
@ -112,6 +119,9 @@ i686.o: i686.c common.ins null.ins i386.h i386.ins i386.reg i486.ins i686.ins i6
java.o: java.c common.ins null.ins
$(CC) $(java_CFLAGS) -c java.c
mips.o: mips.c common.ins null.ins mips.h mips.ins mips.reg
$(CC) $(mips_CFLAGS) -c mips.c
sparc.o: sparc.c common.ins null.ins sparc.h sparc.ins sparc.reg
$(CC) $(sparc_CFLAGS) -c sparc.c
@ -119,7 +129,7 @@ sparc64.o: sparc64.c common.ins null.ins sparc.h sparc.ins sparc.reg
$(CC) $(sparc64_CFLAGS) -c sparc64.c
clean:
$(RM) -- $(amd64_OBJS) $(dalvik_OBJS) $(i386_OBJS) $(i386_real_OBJS) $(i486_OBJS) $(i586_OBJS) $(i686_OBJS) $(java_OBJS) $(sparc_OBJS) $(sparc64_OBJS)
$(RM) -- $(amd64_OBJS) $(dalvik_OBJS) $(i386_OBJS) $(i386_real_OBJS) $(i486_OBJS) $(i586_OBJS) $(i686_OBJS) $(java_OBJS) $(mips_OBJS) $(sparc_OBJS) $(sparc64_OBJS)
distclean: clean
$(RM) -- $(TARGETS)
@ -142,6 +152,8 @@ install: $(TARGETS)
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
$(INSTALL) -m 0644 -- java.so $(DESTDIR)$(LIBDIR)/asm/arch/java.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
$(INSTALL) -m 0644 -- mips.so $(DESTDIR)$(LIBDIR)/asm/arch/mips.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
$(INSTALL) -m 0644 -- sparc.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/asm/arch
$(INSTALL) -m 0644 -- sparc64.so $(DESTDIR)$(LIBDIR)/asm/arch/sparc64.so
@ -155,6 +167,7 @@ uninstall:
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/i586.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/i686.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/java.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/mips.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc.so
$(RM) -- $(DESTDIR)$(LIBDIR)/asm/arch/sparc64.so

59
src/arch/mips.c Normal file
View File

@ -0,0 +1,59 @@
/* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */
/* 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
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stddef.h>
#include "Asm.h"
/* mips */
/* private */
/* variables */
static ArchDescription _mips_description = { "elf", ARCH_ENDIAN_BIG, 32, 32 };
#define REG(name, size, id) { "" # name, size, id },
static ArchRegister _mips_registers[] =
{
#include "mips.reg"
{ NULL, 0, 0 }
};
#undef REG
static ArchInstruction _mips_instructions[] =
{
#include "mips.ins"
#include "common.ins"
#include "null.ins"
};
/* functions */
/* plug-in */
#include "mips.h"
/* protected */
/* variables */
ArchPlugin arch_plugin =
{
NULL,
"mips",
&_mips_description,
_mips_registers,
_mips_instructions,
_mips_write,
NULL
};

44
src/arch/mips.h Normal file
View File

@ -0,0 +1,44 @@
/* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel as */
/* 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
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stddef.h>
/* mips */
/* private */
/* prototypes */
/* plug-in */
static int _mips_write(ArchPlugin * plugin, ArchInstruction * instruction,
ArchInstructionCall * call);
/* functions */
/* plug-in */
/* mips_write */
static int _mips_write(ArchPlugin * plugin, ArchInstruction * instruction,
ArchInstructionCall * call)
{
ArchPluginHelper * helper = plugin->helper;
uint32_t opcode = instruction->opcode;
/* FIXME really implement */
opcode = _htob32(opcode);
if(helper->write(helper->arch, &opcode, sizeof(opcode))
!= sizeof(opcode))
return -1;
return 0;
}

26
src/arch/mips.ins Normal file
View File

@ -0,0 +1,26 @@
/* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */
/* 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
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* generic */
/* registers */
/* opcodes */
#define OPNOP AO_IMMEDIATE(0, 32, 0)
/* instructions */
{ "nop", 0x00000000, OPNOP, AOT_NONE, AOT_NONE, AOT_NONE },

64
src/arch/mips.reg Normal file
View File

@ -0,0 +1,64 @@
REG(r0, 32, 0x00)
REG(r1, 32, 0x01)
REG(r2, 32, 0x02)
REG(r3, 32, 0x03)
REG(r4, 32, 0x04)
REG(r5, 32, 0x05)
REG(r6, 32, 0x06)
REG(r7, 32, 0x07)
REG(r8, 32, 0x08)
REG(r9, 32, 0x09)
REG(r10, 32, 0x0a)
REG(r11, 32, 0x0b)
REG(r12, 32, 0x0c)
REG(r13, 32, 0x0d)
REG(r14, 32, 0x0e)
REG(r15, 32, 0x0f)
REG(r16, 32, 0x10)
REG(r17, 32, 0x11)
REG(r18, 32, 0x12)
REG(r19, 32, 0x13)
REG(r20, 32, 0x14)
REG(r21, 32, 0x15)
REG(r22, 32, 0x16)
REG(r23, 32, 0x17)
REG(r24, 32, 0x18)
REG(r25, 32, 0x19)
REG(r26, 32, 0x1a)
REG(r27, 32, 0x1b)
REG(r28, 32, 0x1c)
REG(r29, 32, 0x1d)
REG(r30, 32, 0x1e)
REG(r31, 32, 0x1f)
REG(f0, 32, 0x31)
REG(f1, 32, 0x32)
REG(f2, 32, 0x33)
REG(f3, 32, 0x34)
REG(f4, 32, 0x35)
REG(f5, 32, 0x36)
REG(f6, 32, 0x37)
REG(f7, 32, 0x38)
REG(f8, 32, 0x39)
REG(f9, 32, 0x3a)
REG(f10, 32, 0x3b)
REG(f11, 32, 0x3c)
REG(f12, 32, 0x3d)
REG(f13, 32, 0x3e)
REG(f14, 32, 0x3f)
REG(f15, 32, 0x40)
REG(f16, 32, 0x41)
REG(f17, 32, 0x42)
REG(f18, 32, 0x43)
REG(f19, 32, 0x44)
REG(f20, 32, 0x45)
REG(f21, 32, 0x46)
REG(f22, 32, 0x47)
REG(f23, 32, 0x48)
REG(f24, 32, 0x49)
REG(f25, 32, 0x4a)
REG(f26, 32, 0x4b)
REG(f27, 32, 0x4c)
REG(f28, 32, 0x4d)
REG(f29, 32, 0x4e)
REG(f30, 32, 0x4f)
REG(f31, 32, 0x50)

View File

@ -1,8 +1,8 @@
targets=amd64,dalvik,i386,i386_real,i486,i586,i686,java,sparc,sparc64
targets=amd64,dalvik,i386,i386_real,i486,i586,i686,java,mips,sparc,sparc64
cppflags_force=-I ../../include
cflags_force=-W `pkg-config --cflags libSystem`
cflags=-Wall -g -O2 -fPIC -pedantic
dist=Makefile,amd64.ins,amd64.reg,common.ins,dalvik.ins,dalvik.reg,i386.h,i386.ins,i386.reg,i486.ins,i586.ins,i686.ins,i686.reg,null.ins,sparc.h,sparc.ins,sparc.reg
dist=Makefile,amd64.ins,amd64.reg,common.ins,dalvik.ins,dalvik.reg,i386.h,i386.ins,i386.reg,i486.ins,i586.ins,i686.ins,i686.reg,mips.h,mips.ins,mips.reg,null.ins,sparc.h,sparc.ins,sparc.reg
[amd64]
type=plugin
@ -68,6 +68,14 @@ install=$(LIBDIR)/asm/arch
[java.c]
depends=common.ins,null.ins
[mips]
type=plugin
sources=mips.c
install=$(LIBDIR)/asm/arch
[mips.c]
depends=common.ins,null.ins,mips.h,mips.ins,mips.reg
[sparc]
type=plugin
sources=sparc.c

View File

@ -100,6 +100,7 @@ static ElfArch elf_arch[] =
{ "i486", EM_386, ELFCLASS32, ELFDATA2LSB },
{ "i586", EM_386, ELFCLASS32, ELFDATA2LSB },
{ "i686", EM_386, ELFCLASS32, ELFDATA2LSB },
{ "mips", EM_MIPS, ELFCLASS32, ELFDATA2MSB },
{ "sparc", EM_SPARC, ELFCLASS32, ELFDATA2MSB },
{ "sparc64", EM_SPARCV9, ELFCLASS64, ELFDATA2MSB },
{ NULL, '\0', '\0', '\0' }

View File

@ -1,4 +1,4 @@
TARGETS = amd64.o dalvik.o i386.o i386_real.o i486.o i586.o i686.o java.o sparc.o sparc64.o
TARGETS = amd64.o dalvik.o i386.o i386_real.o i486.o i586.o i686.o mips.o java.o sparc.o sparc64.o
PREFIX = /usr/local
DESTDIR =
BINDIR = $(PREFIX)/bin
@ -33,6 +33,9 @@ i586.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a i586
i686.o_OBJS = i686.o
i686.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a i686
mips.o_OBJS = mips.o
mips.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a mips
java.o_OBJS = java.o
java.o_ASFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(ASFLAGS) -a java -f flat
@ -63,6 +66,9 @@ i586.o: i586.S ../src/asm
i686.o: i686.S ../src/asm
$(AS) $(i686.o_ASFLAGS) -o i686.o i686.S
mips.o: mips.S ../src/asm
$(AS) $(mips.o_ASFLAGS) -o mips.o mips.S
java.o: java.S ../src/asm
$(AS) $(java.o_ASFLAGS) -o java.o java.S
@ -73,7 +79,7 @@ sparc64.o: sparc64.S ../src/asm
$(AS) $(sparc64.o_ASFLAGS) -o sparc64.o sparc64.S
clean:
$(RM) -- $(amd64.o_OBJS) $(dalvik.o_OBJS) $(i386.o_OBJS) $(i386_real.o_OBJS) $(i486.o_OBJS) $(i586.o_OBJS) $(i686.o_OBJS) $(java.o_OBJS) $(sparc.o_OBJS) $(sparc64.o_OBJS)
$(RM) -- $(amd64.o_OBJS) $(dalvik.o_OBJS) $(i386.o_OBJS) $(i386_real.o_OBJS) $(i486.o_OBJS) $(i586.o_OBJS) $(i686.o_OBJS) $(mips.o_OBJS) $(java.o_OBJS) $(sparc.o_OBJS) $(sparc64.o_OBJS)
distclean: clean
$(RM) -- $(TARGETS)

2
test/mips.S Normal file
View File

@ -0,0 +1,2 @@
.text
nop

View File

@ -1,4 +1,4 @@
targets=amd64.o,dalvik.o,i386.o,i386_real.o,i486.o,i586.o,i686.o,java.o,sparc.o,sparc64.o
targets=amd64.o,dalvik.o,i386.o,i386_real.o,i486.o,i586.o,i686.o,mips.o,java.o,sparc.o,sparc64.o
as=../src/asm-static
dist=Makefile
@ -66,6 +66,14 @@ sources=java.S
asflags=-a java -f flat
depends=../src/asm
[mips.o]
type=object
sources=mips.S
[mips.S]
asflags=-a mips
depends=../src/asm
[sparc.o]
type=object
sources=sparc.S