Creation of Cybook 2416 (actually Gen4) repository
This commit is contained in:
69
arch/um/sys-ppc/Makefile
Normal file
69
arch/um/sys-ppc/Makefile
Normal file
@@ -0,0 +1,69 @@
|
||||
OBJ = built-in.o
|
||||
|
||||
.S.o:
|
||||
$(CC) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
|
||||
|
||||
OBJS = ptrace.o sigcontext.o semaphore.o checksum.o miscthings.o misc.o \
|
||||
ptrace_user.o sysrq.o
|
||||
|
||||
EXTRA_AFLAGS := -DCONFIG_PPC32 -I. -I$(TOPDIR)/arch/ppc/kernel
|
||||
|
||||
all: $(OBJ)
|
||||
|
||||
$(OBJ): $(OBJS)
|
||||
rm -f $@
|
||||
$(LD) $(LINKFLAGS) --start-group $^ --end-group -o $@
|
||||
|
||||
ptrace_user.o: ptrace_user.c
|
||||
$(CC) -D__KERNEL__ $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
sigcontext.o: sigcontext.c
|
||||
$(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
semaphore.c:
|
||||
rm -f $@
|
||||
ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
|
||||
|
||||
checksum.S:
|
||||
rm -f $@
|
||||
ln -s $(TOPDIR)/arch/ppc/lib/$@ $@
|
||||
|
||||
mk_defs.c:
|
||||
rm -f $@
|
||||
ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
|
||||
|
||||
ppc_defs.head:
|
||||
rm -f $@
|
||||
ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
|
||||
|
||||
ppc_defs.h: mk_defs.c ppc_defs.head \
|
||||
$(TOPDIR)/include/asm-ppc/mmu.h \
|
||||
$(TOPDIR)/include/asm-ppc/processor.h \
|
||||
$(TOPDIR)/include/asm-ppc/pgtable.h \
|
||||
$(TOPDIR)/include/asm-ppc/ptrace.h
|
||||
# $(CC) $(CFLAGS) -S mk_defs.c
|
||||
cp ppc_defs.head ppc_defs.h
|
||||
# for bk, this way we can write to the file even if it's not checked out
|
||||
echo '#define THREAD 608' >> ppc_defs.h
|
||||
echo '#define PT_REGS 8' >> ppc_defs.h
|
||||
echo '#define CLONE_VM 256' >> ppc_defs.h
|
||||
# chmod u+w ppc_defs.h
|
||||
# grep '^#define' mk_defs.s >> ppc_defs.h
|
||||
# rm mk_defs.s
|
||||
|
||||
# the asm link is horrible, and breaks the other targets. This is also
|
||||
# not going to work with parallel makes.
|
||||
|
||||
checksum.o: checksum.S
|
||||
rm -f asm
|
||||
ln -s $(TOPDIR)/include/asm-ppc asm
|
||||
$(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
|
||||
rm -f asm
|
||||
|
||||
misc.o: misc.S ppc_defs.h
|
||||
rm -f asm
|
||||
ln -s $(TOPDIR)/include/asm-ppc asm
|
||||
$(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
|
||||
rm -f asm
|
||||
|
||||
clean-files := $(OBJS) ppc_defs.h checksum.S semaphore.c mk_defs.c
|
||||
111
arch/um/sys-ppc/misc.S
Normal file
111
arch/um/sys-ppc/misc.S
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* This file contains miscellaneous low-level functions.
|
||||
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
|
||||
*
|
||||
* Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
|
||||
* and Paul Mackerras.
|
||||
*
|
||||
* A couple of functions stolen from arch/ppc/kernel/misc.S for UML
|
||||
* by Chris Emerson.
|
||||
*
|
||||
* 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; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <asm/processor.h>
|
||||
#include "ppc_asm.h"
|
||||
|
||||
#if defined(CONFIG_4xx) || defined(CONFIG_8xx)
|
||||
#define CACHE_LINE_SIZE 16
|
||||
#define LG_CACHE_LINE_SIZE 4
|
||||
#define MAX_COPY_PREFETCH 1
|
||||
#else
|
||||
#define CACHE_LINE_SIZE 32
|
||||
#define LG_CACHE_LINE_SIZE 5
|
||||
#define MAX_COPY_PREFETCH 4
|
||||
#endif /* CONFIG_4xx || CONFIG_8xx */
|
||||
|
||||
.text
|
||||
|
||||
/*
|
||||
* Clear a page using the dcbz instruction, which doesn't cause any
|
||||
* memory traffic (except to write out any cache lines which get
|
||||
* displaced). This only works on cacheable memory.
|
||||
*/
|
||||
_GLOBAL(clear_page)
|
||||
li r0,4096/CACHE_LINE_SIZE
|
||||
mtctr r0
|
||||
#ifdef CONFIG_8xx
|
||||
li r4, 0
|
||||
1: stw r4, 0(r3)
|
||||
stw r4, 4(r3)
|
||||
stw r4, 8(r3)
|
||||
stw r4, 12(r3)
|
||||
#else
|
||||
1: dcbz 0,r3
|
||||
#endif
|
||||
addi r3,r3,CACHE_LINE_SIZE
|
||||
bdnz 1b
|
||||
blr
|
||||
|
||||
/*
|
||||
* Copy a whole page. We use the dcbz instruction on the destination
|
||||
* to reduce memory traffic (it eliminates the unnecessary reads of
|
||||
* the destination into cache). This requires that the destination
|
||||
* is cacheable.
|
||||
*/
|
||||
#define COPY_16_BYTES \
|
||||
lwz r6,4(r4); \
|
||||
lwz r7,8(r4); \
|
||||
lwz r8,12(r4); \
|
||||
lwzu r9,16(r4); \
|
||||
stw r6,4(r3); \
|
||||
stw r7,8(r3); \
|
||||
stw r8,12(r3); \
|
||||
stwu r9,16(r3)
|
||||
|
||||
_GLOBAL(copy_page)
|
||||
addi r3,r3,-4
|
||||
addi r4,r4,-4
|
||||
li r5,4
|
||||
|
||||
#ifndef CONFIG_8xx
|
||||
#if MAX_COPY_PREFETCH > 1
|
||||
li r0,MAX_COPY_PREFETCH
|
||||
li r11,4
|
||||
mtctr r0
|
||||
11: dcbt r11,r4
|
||||
addi r11,r11,CACHE_LINE_SIZE
|
||||
bdnz 11b
|
||||
#else /* MAX_COPY_PREFETCH == 1 */
|
||||
dcbt r5,r4
|
||||
li r11,CACHE_LINE_SIZE+4
|
||||
#endif /* MAX_COPY_PREFETCH */
|
||||
#endif /* CONFIG_8xx */
|
||||
|
||||
li r0,4096/CACHE_LINE_SIZE
|
||||
mtctr r0
|
||||
1:
|
||||
#ifndef CONFIG_8xx
|
||||
dcbt r11,r4
|
||||
dcbz r5,r3
|
||||
#endif
|
||||
COPY_16_BYTES
|
||||
#if CACHE_LINE_SIZE >= 32
|
||||
COPY_16_BYTES
|
||||
#if CACHE_LINE_SIZE >= 64
|
||||
COPY_16_BYTES
|
||||
COPY_16_BYTES
|
||||
#if CACHE_LINE_SIZE >= 128
|
||||
COPY_16_BYTES
|
||||
COPY_16_BYTES
|
||||
COPY_16_BYTES
|
||||
COPY_16_BYTES
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
bdnz 1b
|
||||
blr
|
||||
53
arch/um/sys-ppc/miscthings.c
Normal file
53
arch/um/sys-ppc/miscthings.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "linux/threads.h"
|
||||
#include "linux/stddef.h" // for NULL
|
||||
#include "linux/elf.h" // for AT_NULL
|
||||
|
||||
/* The following function nicked from arch/ppc/kernel/process.c and
|
||||
* adapted slightly */
|
||||
/*
|
||||
* XXX ld.so expects the auxiliary table to start on
|
||||
* a 16-byte boundary, so we have to find it and
|
||||
* move it up. :-(
|
||||
*/
|
||||
void shove_aux_table(unsigned long sp)
|
||||
{
|
||||
int argc;
|
||||
char *p;
|
||||
unsigned long e;
|
||||
unsigned long aux_start, offset;
|
||||
|
||||
argc = *(int *)sp;
|
||||
sp += sizeof(int) + (argc + 1) * sizeof(char *);
|
||||
/* skip over the environment pointers */
|
||||
do {
|
||||
p = *(char **)sp;
|
||||
sp += sizeof(char *);
|
||||
} while (p != NULL);
|
||||
aux_start = sp;
|
||||
/* skip to the end of the auxiliary table */
|
||||
do {
|
||||
e = *(unsigned long *)sp;
|
||||
sp += 2 * sizeof(unsigned long);
|
||||
} while (e != AT_NULL);
|
||||
offset = ((aux_start + 15) & ~15) - aux_start;
|
||||
if (offset != 0) {
|
||||
do {
|
||||
sp -= sizeof(unsigned long);
|
||||
e = *(unsigned long *)sp;
|
||||
*(unsigned long *)(sp + offset) = e;
|
||||
} while (sp > aux_start);
|
||||
}
|
||||
}
|
||||
/* END stuff taken from arch/ppc/kernel/process.c */
|
||||
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
68
arch/um/sys-ppc/ptrace.c
Normal file
68
arch/um/sys-ppc/ptrace.c
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "linux/sched.h"
|
||||
#include "asm/ptrace.h"
|
||||
|
||||
int putreg(struct task_struct *child, unsigned long regno,
|
||||
unsigned long value)
|
||||
{
|
||||
child->thread.process_regs.regs[regno >> 2] = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int poke_user(struct task_struct *child, long addr, long data)
|
||||
{
|
||||
if ((addr & 3) || addr < 0)
|
||||
return -EIO;
|
||||
|
||||
if (addr < MAX_REG_OFFSET)
|
||||
return putreg(child, addr, data);
|
||||
|
||||
else if((addr >= offsetof(struct user, u_debugreg[0])) &&
|
||||
(addr <= offsetof(struct user, u_debugreg[7]))){
|
||||
addr -= offsetof(struct user, u_debugreg[0]);
|
||||
addr = addr >> 2;
|
||||
if((addr == 4) || (addr == 5)) return -EIO;
|
||||
child->thread.arch.debugregs[addr] = data;
|
||||
return 0;
|
||||
}
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
unsigned long getreg(struct task_struct *child, unsigned long regno)
|
||||
{
|
||||
unsigned long retval = ~0UL;
|
||||
|
||||
retval &= child->thread.process_regs.regs[regno >> 2];
|
||||
return retval;
|
||||
}
|
||||
|
||||
int peek_user(struct task_struct *child, long addr, long data)
|
||||
{
|
||||
/* read the word at location addr in the USER area. */
|
||||
unsigned long tmp;
|
||||
|
||||
if ((addr & 3) || addr < 0)
|
||||
return -EIO;
|
||||
|
||||
tmp = 0; /* Default return condition */
|
||||
if(addr < MAX_REG_OFFSET){
|
||||
tmp = getreg(child, addr);
|
||||
}
|
||||
else if((addr >= offsetof(struct user, u_debugreg[0])) &&
|
||||
(addr <= offsetof(struct user, u_debugreg[7]))){
|
||||
addr -= offsetof(struct user, u_debugreg[0]);
|
||||
addr = addr >> 2;
|
||||
tmp = child->thread.arch.debugregs[addr];
|
||||
}
|
||||
return put_user(tmp, (unsigned long *) data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
39
arch/um/sys-ppc/ptrace_user.c
Normal file
39
arch/um/sys-ppc/ptrace_user.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <errno.h>
|
||||
#include <asm/ptrace.h>
|
||||
#include "sysdep/ptrace.h"
|
||||
|
||||
int ptrace_getregs(long pid, unsigned long *regs_out)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
|
||||
errno = 0;
|
||||
regs_out->regs[i] = ptrace(PTRACE_PEEKUSR, pid, i*4, 0);
|
||||
if (errno) {
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ptrace_setregs(long pid, unsigned long *regs_in)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
|
||||
if (i != 34 /* FIXME: PT_ORIG_R3 */ && i <= PT_MQ) {
|
||||
if (ptrace(PTRACE_POKEUSR, pid, i*4, regs_in->regs[i]) < 0) {
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
15
arch/um/sys-ppc/sigcontext.c
Normal file
15
arch/um/sys-ppc/sigcontext.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "asm/ptrace.h"
|
||||
#include "asm/sigcontext.h"
|
||||
#include "sysdep/ptrace.h"
|
||||
#include "user_util.h"
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
31
arch/um/sys-ppc/sysrq.c
Normal file
31
arch/um/sys-ppc/sysrq.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#include "linux/kernel.h"
|
||||
#include "linux/smp.h"
|
||||
#include "asm/ptrace.h"
|
||||
#include "sysrq.h"
|
||||
|
||||
void show_regs(struct pt_regs_subarch *regs)
|
||||
{
|
||||
printk("\n");
|
||||
printk("show_regs(): insert regs here.\n");
|
||||
#if 0
|
||||
printk("\n");
|
||||
printk("EIP: %04x:[<%08lx>] CPU: %d",0xffff & regs->xcs, regs->eip,
|
||||
smp_processor_id());
|
||||
if (regs->xcs & 3)
|
||||
printk(" ESP: %04x:%08lx",0xffff & regs->xss, regs->esp);
|
||||
printk(" EFLAGS: %08lx\n", regs->eflags);
|
||||
printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
|
||||
regs->eax, regs->ebx, regs->ecx, regs->edx);
|
||||
printk("ESI: %08lx EDI: %08lx EBP: %08lx",
|
||||
regs->esi, regs->edi, regs->ebp);
|
||||
printk(" DS: %04x ES: %04x\n",
|
||||
0xffff & regs->xds, 0xffff & regs->xes);
|
||||
#endif
|
||||
|
||||
show_trace(current, ®s->gpr[1]);
|
||||
}
|
||||
Reference in New Issue
Block a user