From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerone Young Subject: [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes Date: Wed, 25 Jun 2008 15:39:14 -0500 Message-ID: <0818f751aba30d65eb39.1214426354@thinkpadL> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-ppc@vger.kernel.org To: kvm@vger.kernel.org Return-path: Received: from e33.co.us.ibm.com ([32.97.110.151]:57714 "EHLO e33.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751693AbYFYUlx (ORCPT ); Wed, 25 Jun 2008 16:41:53 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: 4 files changed, 124 insertions(+), 1 deletion(-) user/config-powerpc.mak | 10 ++++++- user/test/lib/powerpc/44x/map.c | 51 +++++++++++++++++++++++++++++++++++++ user/test/lib/powerpc/44x/tlbwe.S | 29 +++++++++++++++++++++ user/test/lib/powerpc/io.c | 35 +++++++++++++++++++++++++ Signed-off-by: Hollis Blanchard Signed-off-by: Jerone Young diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak --- a/user/config-powerpc.mak +++ b/user/config-powerpc.mak @@ -3,6 +3,14 @@ CFLAGS += -I $(KERNELDIR)/include # for some reaons binutils hates tlbsx unless we say we're 405 :( CFLAGS += -Wa,-mregnames,-m405 + +cflatobjs += \ + test/lib/powerpc/io.o \ + test/lib/powerpc/44x/map.o \ + test/lib/powerpc/44x/tlbwe.o + +$(libcflat): LDFLAGS += -nostdlib +$(libcflat): CFLAGS += -ffreestanding -I test/lib -I test/lib/powerpc/44x %.bin: %.o $(OBJCOPY) -O binary $^ $@ @@ -18,7 +26,7 @@ tests := $(addprefix test/powerpc/, $(testobjs)) -all: kvmtrace kvmctl $(tests) +all: kvmtrace kvmctl $(libcflat) $(tests) kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a diff --git a/user/test/lib/powerpc/44x/map.c b/user/test/lib/powerpc/44x/map.c new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/map.c @@ -0,0 +1,51 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation. + * + * 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, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2008 + * + * Authors: Hollis Blanchard + */ + +#include "libcflat.h" + +#define TLB_SIZE 64 + +extern void tlbwe(unsigned int index, + unsigned char tid, + unsigned int word0, + unsigned int word1, + unsigned int word2); + +unsigned int next_free_index; + +#define PAGE_SHIFT 12 +#define PAGE_MASK (~((1<= TLB_SIZE) + panic("TLB overflow"); + + w0 = (vaddr & PAGE_MASK) | V; + w1 = paddr & PAGE_MASK; + w2 = 0x3; + + tlbwe(next_free_index, 0, w0, w1, w2); +} diff --git a/user/test/lib/powerpc/44x/tlbwe.S b/user/test/lib/powerpc/44x/tlbwe.S new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/tlbwe.S @@ -0,0 +1,29 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation. + * + * 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, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2008 + * + * Authors: Hollis Blanchard + */ + +#define SPRN_MMUCR 0x3b2 + +/* tlbwe(uint index, uint8_t tid, uint word0, uint word1, uint word2) */ +.global tlbwe +tlbwe: + mtspr SPRN_MMUCR, r4 + tlbwe r5, r3, 0 + tlbwe r6, r3, 1 + tlbwe r7, r3, 2 + blr diff --git a/user/test/lib/powerpc/io.c b/user/test/lib/powerpc/io.c new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/io.c @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation. + * + * 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, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2008 + * + * Authors: Hollis Blanchard + */ + +#include "libcflat.h" + +#define BASE 0xf0000000 +#define _putc ((volatile char *)(BASE)) +#define _exit ((volatile char *)(BASE+1)) + +void puts(const char *s) +{ + while (*s != '\0') + *_putc = *s++; +} + +void exit(int code) +{ + *_exit = code; +}