aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-ppc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/sys-ppc
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/um/sys-ppc')
-rw-r--r--arch/um/sys-ppc/Makefile69
-rw-r--r--arch/um/sys-ppc/misc.S116
-rw-r--r--arch/um/sys-ppc/miscthings.c53
-rw-r--r--arch/um/sys-ppc/ptrace.c28
-rw-r--r--arch/um/sys-ppc/ptrace_user.c39
-rw-r--r--arch/um/sys-ppc/sigcontext.c15
-rw-r--r--arch/um/sys-ppc/sysrq.c43
7 files changed, 363 insertions, 0 deletions
diff --git a/arch/um/sys-ppc/Makefile b/arch/um/sys-ppc/Makefile
new file mode 100644
index 000000000000..af200268fddb
--- /dev/null
+++ b/arch/um/sys-ppc/Makefile
@@ -0,0 +1,69 @@
1OBJ = built-in.o
2
3.S.o:
4 $(CC) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
5
6OBJS = ptrace.o sigcontext.o semaphore.o checksum.o miscthings.o misc.o \
7 ptrace_user.o sysrq.o
8
9EXTRA_AFLAGS := -DCONFIG_PPC32 -I. -I$(TOPDIR)/arch/ppc/kernel
10
11all: $(OBJ)
12
13$(OBJ): $(OBJS)
14 rm -f $@
15 $(LD) $(LINKFLAGS) --start-group $^ --end-group -o $@
16
17ptrace_user.o: ptrace_user.c
18 $(CC) -D__KERNEL__ $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
19
20sigcontext.o: sigcontext.c
21 $(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
22
23semaphore.c:
24 rm -f $@
25 ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
26
27checksum.S:
28 rm -f $@
29 ln -s $(TOPDIR)/arch/ppc/lib/$@ $@
30
31mk_defs.c:
32 rm -f $@
33 ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
34
35ppc_defs.head:
36 rm -f $@
37 ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
38
39ppc_defs.h: mk_defs.c ppc_defs.head \
40 $(TOPDIR)/include/asm-ppc/mmu.h \
41 $(TOPDIR)/include/asm-ppc/processor.h \
42 $(TOPDIR)/include/asm-ppc/pgtable.h \
43 $(TOPDIR)/include/asm-ppc/ptrace.h
44# $(CC) $(CFLAGS) -S mk_defs.c
45 cp ppc_defs.head ppc_defs.h
46# for bk, this way we can write to the file even if it's not checked out
47 echo '#define THREAD 608' >> ppc_defs.h
48 echo '#define PT_REGS 8' >> ppc_defs.h
49 echo '#define CLONE_VM 256' >> ppc_defs.h
50# chmod u+w ppc_defs.h
51# grep '^#define' mk_defs.s >> ppc_defs.h
52# rm mk_defs.s
53
54# the asm link is horrible, and breaks the other targets. This is also
55# not going to work with parallel makes.
56
57checksum.o: checksum.S
58 rm -f asm
59 ln -s $(TOPDIR)/include/asm-ppc asm
60 $(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
61 rm -f asm
62
63misc.o: misc.S ppc_defs.h
64 rm -f asm
65 ln -s $(TOPDIR)/include/asm-ppc asm
66 $(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
67 rm -f asm
68
69clean-files := $(OBJS) ppc_defs.h checksum.S semaphore.c mk_defs.c
diff --git a/arch/um/sys-ppc/misc.S b/arch/um/sys-ppc/misc.S
new file mode 100644
index 000000000000..11b7bd768cfd
--- /dev/null
+++ b/arch/um/sys-ppc/misc.S
@@ -0,0 +1,116 @@
1/*
2 * This file contains miscellaneous low-level functions.
3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
4 *
5 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
6 * and Paul Mackerras.
7 *
8 * A couple of functions stolen from arch/ppc/kernel/misc.S for UML
9 * by Chris Emerson.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 *
16 */
17
18#include <linux/config.h>
19#include <asm/processor.h>
20#include "ppc_asm.h"
21
22#if defined(CONFIG_4xx) || defined(CONFIG_8xx)
23#define CACHE_LINE_SIZE 16
24#define LG_CACHE_LINE_SIZE 4
25#define MAX_COPY_PREFETCH 1
26#elif !defined(CONFIG_PPC64BRIDGE)
27#define CACHE_LINE_SIZE 32
28#define LG_CACHE_LINE_SIZE 5
29#define MAX_COPY_PREFETCH 4
30#else
31#define CACHE_LINE_SIZE 128
32#define LG_CACHE_LINE_SIZE 7
33#define MAX_COPY_PREFETCH 1
34#endif /* CONFIG_4xx || CONFIG_8xx */
35
36 .text
37
38/*
39 * Clear a page using the dcbz instruction, which doesn't cause any
40 * memory traffic (except to write out any cache lines which get
41 * displaced). This only works on cacheable memory.
42 */
43_GLOBAL(clear_page)
44 li r0,4096/CACHE_LINE_SIZE
45 mtctr r0
46#ifdef CONFIG_8xx
47 li r4, 0
481: stw r4, 0(r3)
49 stw r4, 4(r3)
50 stw r4, 8(r3)
51 stw r4, 12(r3)
52#else
531: dcbz 0,r3
54#endif
55 addi r3,r3,CACHE_LINE_SIZE
56 bdnz 1b
57 blr
58
59/*
60 * Copy a whole page. We use the dcbz instruction on the destination
61 * to reduce memory traffic (it eliminates the unnecessary reads of
62 * the destination into cache). This requires that the destination
63 * is cacheable.
64 */
65#define COPY_16_BYTES \
66 lwz r6,4(r4); \
67 lwz r7,8(r4); \
68 lwz r8,12(r4); \
69 lwzu r9,16(r4); \
70 stw r6,4(r3); \
71 stw r7,8(r3); \
72 stw r8,12(r3); \
73 stwu r9,16(r3)
74
75_GLOBAL(copy_page)
76 addi r3,r3,-4
77 addi r4,r4,-4
78 li r5,4
79
80#ifndef CONFIG_8xx
81#if MAX_COPY_PREFETCH > 1
82 li r0,MAX_COPY_PREFETCH
83 li r11,4
84 mtctr r0
8511: dcbt r11,r4
86 addi r11,r11,CACHE_LINE_SIZE
87 bdnz 11b
88#else /* MAX_COPY_PREFETCH == 1 */
89 dcbt r5,r4
90 li r11,CACHE_LINE_SIZE+4
91#endif /* MAX_COPY_PREFETCH */
92#endif /* CONFIG_8xx */
93
94 li r0,4096/CACHE_LINE_SIZE
95 mtctr r0
961:
97#ifndef CONFIG_8xx
98 dcbt r11,r4
99 dcbz r5,r3
100#endif
101 COPY_16_BYTES
102#if CACHE_LINE_SIZE >= 32
103 COPY_16_BYTES
104#if CACHE_LINE_SIZE >= 64
105 COPY_16_BYTES
106 COPY_16_BYTES
107#if CACHE_LINE_SIZE >= 128
108 COPY_16_BYTES
109 COPY_16_BYTES
110 COPY_16_BYTES
111 COPY_16_BYTES
112#endif
113#endif
114#endif
115 bdnz 1b
116 blr
diff --git a/arch/um/sys-ppc/miscthings.c b/arch/um/sys-ppc/miscthings.c
new file mode 100644
index 000000000000..373061c50129
--- /dev/null
+++ b/arch/um/sys-ppc/miscthings.c
@@ -0,0 +1,53 @@
1#include "linux/threads.h"
2#include "linux/stddef.h" // for NULL
3#include "linux/elf.h" // for AT_NULL
4
5/* The following function nicked from arch/ppc/kernel/process.c and
6 * adapted slightly */
7/*
8 * XXX ld.so expects the auxiliary table to start on
9 * a 16-byte boundary, so we have to find it and
10 * move it up. :-(
11 */
12void shove_aux_table(unsigned long sp)
13{
14 int argc;
15 char *p;
16 unsigned long e;
17 unsigned long aux_start, offset;
18
19 argc = *(int *)sp;
20 sp += sizeof(int) + (argc + 1) * sizeof(char *);
21 /* skip over the environment pointers */
22 do {
23 p = *(char **)sp;
24 sp += sizeof(char *);
25 } while (p != NULL);
26 aux_start = sp;
27 /* skip to the end of the auxiliary table */
28 do {
29 e = *(unsigned long *)sp;
30 sp += 2 * sizeof(unsigned long);
31 } while (e != AT_NULL);
32 offset = ((aux_start + 15) & ~15) - aux_start;
33 if (offset != 0) {
34 do {
35 sp -= sizeof(unsigned long);
36 e = *(unsigned long *)sp;
37 *(unsigned long *)(sp + offset) = e;
38 } while (sp > aux_start);
39 }
40}
41/* END stuff taken from arch/ppc/kernel/process.c */
42
43
44/*
45 * Overrides for Emacs so that we follow Linus's tabbing style.
46 * Emacs will notice this stuff at the end of the file and automatically
47 * adjust the settings for this buffer only. This must remain at the end
48 * of the file.
49 * ---------------------------------------------------------------------------
50 * Local variables:
51 * c-file-style: "linux"
52 * End:
53 */
diff --git a/arch/um/sys-ppc/ptrace.c b/arch/um/sys-ppc/ptrace.c
new file mode 100644
index 000000000000..a971366d3277
--- /dev/null
+++ b/arch/um/sys-ppc/ptrace.c
@@ -0,0 +1,28 @@
1#include "linux/sched.h"
2#include "asm/ptrace.h"
3
4int putreg(struct task_struct *child, unsigned long regno,
5 unsigned long value)
6{
7 child->thread.process_regs.regs[regno >> 2] = value;
8 return 0;
9}
10
11unsigned long getreg(struct task_struct *child, unsigned long regno)
12{
13 unsigned long retval = ~0UL;
14
15 retval &= child->thread.process_regs.regs[regno >> 2];
16 return retval;
17}
18
19/*
20 * Overrides for Emacs so that we follow Linus's tabbing style.
21 * Emacs will notice this stuff at the end of the file and automatically
22 * adjust the settings for this buffer only. This must remain at the end
23 * of the file.
24 * ---------------------------------------------------------------------------
25 * Local variables:
26 * c-file-style: "linux"
27 * End:
28 */
diff --git a/arch/um/sys-ppc/ptrace_user.c b/arch/um/sys-ppc/ptrace_user.c
new file mode 100644
index 000000000000..ff0b9c077a13
--- /dev/null
+++ b/arch/um/sys-ppc/ptrace_user.c
@@ -0,0 +1,39 @@
1#include <errno.h>
2#include <asm/ptrace.h>
3#include "sysdep/ptrace.h"
4
5int ptrace_getregs(long pid, unsigned long *regs_out)
6{
7 int i;
8 for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
9 errno = 0;
10 regs_out->regs[i] = ptrace(PTRACE_PEEKUSR, pid, i*4, 0);
11 if (errno) {
12 return -errno;
13 }
14 }
15 return 0;
16}
17
18int ptrace_setregs(long pid, unsigned long *regs_in)
19{
20 int i;
21 for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
22 if (i != 34 /* FIXME: PT_ORIG_R3 */ && i <= PT_MQ) {
23 if (ptrace(PTRACE_POKEUSR, pid, i*4, regs_in->regs[i]) < 0) {
24 return -errno;
25 }
26 }
27 }
28 return 0;
29}
30/*
31 * Overrides for Emacs so that we follow Linus's tabbing style.
32 * Emacs will notice this stuff at the end of the file and automatically
33 * adjust the settings for this buffer only. This must remain at the end
34 * of the file.
35 * ---------------------------------------------------------------------------
36 * Local variables:
37 * c-file-style: "linux"
38 * End:
39 */
diff --git a/arch/um/sys-ppc/sigcontext.c b/arch/um/sys-ppc/sigcontext.c
new file mode 100644
index 000000000000..5d430fc994af
--- /dev/null
+++ b/arch/um/sys-ppc/sigcontext.c
@@ -0,0 +1,15 @@
1#include "asm/ptrace.h"
2#include "asm/sigcontext.h"
3#include "sysdep/ptrace.h"
4#include "user_util.h"
5
6/*
7 * Overrides for Emacs so that we follow Linus's tabbing style.
8 * Emacs will notice this stuff at the end of the file and automatically
9 * adjust the settings for this buffer only. This must remain at the end
10 * of the file.
11 * ---------------------------------------------------------------------------
12 * Local variables:
13 * c-file-style: "linux"
14 * End:
15 */
diff --git a/arch/um/sys-ppc/sysrq.c b/arch/um/sys-ppc/sysrq.c
new file mode 100644
index 000000000000..82d6e9335bb6
--- /dev/null
+++ b/arch/um/sys-ppc/sysrq.c
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
3 * Licensed under the GPL
4 */
5
6#include "linux/kernel.h"
7#include "linux/smp.h"
8#include "asm/ptrace.h"
9#include "sysrq.h"
10
11void show_regs(struct pt_regs_subarch *regs)
12{
13 printk("\n");
14 printk("show_regs(): insert regs here.\n");
15#if 0
16 printk("\n");
17 printk("EIP: %04x:[<%08lx>] CPU: %d",0xffff & regs->xcs, regs->eip,
18 smp_processor_id());
19 if (regs->xcs & 3)
20 printk(" ESP: %04x:%08lx",0xffff & regs->xss, regs->esp);
21 printk(" EFLAGS: %08lx\n", regs->eflags);
22 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
23 regs->eax, regs->ebx, regs->ecx, regs->edx);
24 printk("ESI: %08lx EDI: %08lx EBP: %08lx",
25 regs->esi, regs->edi, regs->ebp);
26 printk(" DS: %04x ES: %04x\n",
27 0xffff & regs->xds, 0xffff & regs->xes);
28#endif
29
30 show_trace(&regs->gpr[1]);
31}
32
33
34/*
35 * Overrides for Emacs so that we follow Linus's tabbing style.
36 * Emacs will notice this stuff at the end of the file and automatically
37 * adjust the settings for this buffer only. This must remain at the end
38 * of the file.
39 * ---------------------------------------------------------------------------
40 * Local variables:
41 * c-file-style: "linux"
42 * End:
43 */