···11-ifeq ($(CONFIG_HOST_2G_2G), y)22-START_ADDR = 0x8000000033-else44-START_ADDR = 0xc000000055-endif66-ARCH_CFLAGS = -U__powerpc__ -D__UM_PPC__77-88-# The arch is ppc, but the elf32 name is powerpc99-ELF_SUBARCH = powerpc
-65
arch/um/sys-ppc/Makefile
···11-OBJ = built-in.o22-33-.S.o:44- $(CC) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o55-66-OBJS = ptrace.o sigcontext.o checksum.o miscthings.o misc.o \77- ptrace_user.o sysrq.o88-99-asflags-y := -DCONFIG_PPC32 -I. -I$(srctree)/arch/ppc/kernel1010-1111-all: $(OBJ)1212-1313-$(OBJ): $(OBJS)1414- rm -f $@1515- $(LD) $(LINKFLAGS) --start-group $^ --end-group -o $@1616-1717-ptrace_user.o: ptrace_user.c1818- $(CC) -D__KERNEL__ $(USER_CFLAGS) $(ccflags-y) -c -o $@ $<1919-2020-sigcontext.o: sigcontext.c2121- $(CC) $(USER_CFLAGS) $(ccflags-y) -c -o $@ $<2222-2323-checksum.S:2424- rm -f $@2525- ln -s $(srctree)/arch/ppc/lib/$@ $@2626-2727-mk_defs.c:2828- rm -f $@2929- ln -s $(srctree)/arch/ppc/kernel/$@ $@3030-3131-ppc_defs.head:3232- rm -f $@3333- ln -s $(srctree)/arch/ppc/kernel/$@ $@3434-3535-ppc_defs.h: mk_defs.c ppc_defs.head \3636- $(srctree)/include/asm-ppc/mmu.h \3737- $(srctree)/include/asm-ppc/processor.h \3838- $(srctree)/include/asm-ppc/pgtable.h \3939- $(srctree)/include/asm-ppc/ptrace.h4040-# $(CC) $(CFLAGS) -S mk_defs.c4141- cp ppc_defs.head ppc_defs.h4242-# for bk, this way we can write to the file even if it's not checked out4343- echo '#define THREAD 608' >> ppc_defs.h4444- echo '#define PT_REGS 8' >> ppc_defs.h4545- echo '#define CLONE_VM 256' >> ppc_defs.h4646-# chmod u+w ppc_defs.h4747-# grep '^#define' mk_defs.s >> ppc_defs.h4848-# rm mk_defs.s4949-5050-# the asm link is horrible, and breaks the other targets. This is also5151-# not going to work with parallel makes.5252-5353-checksum.o: checksum.S5454- rm -f asm5555- ln -s $(srctree)/include/asm-ppc asm5656- $(CC) $(asflags-y) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o5757- rm -f asm5858-5959-misc.o: misc.S ppc_defs.h6060- rm -f asm6161- ln -s $(srctree)/include/asm-ppc asm6262- $(CC) $(asflags-y) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o6363- rm -f asm6464-6565-clean-files := $(OBJS) ppc_defs.h checksum.S mk_defs.c
-8
arch/um/sys-ppc/asm/archparam.h
···11-#ifndef __UM_ARCHPARAM_PPC_H22-#define __UM_ARCHPARAM_PPC_H33-44-/********* Bits for asm-um/string.h **********/55-66-#define __HAVE_ARCH_STRRCHR77-88-#endif
-51
arch/um/sys-ppc/asm/elf.h
···11-#ifndef __UM_ELF_PPC_H22-#define __UM_ELF_PPC_H33-44-55-extern long elf_aux_hwcap;66-#define ELF_HWCAP (elf_aux_hwcap)77-88-#define SET_PERSONALITY(ex) do ; while(0)99-1010-#define ELF_EXEC_PAGESIZE 40961111-1212-#define elf_check_arch(x) (1)1313-1414-#ifdef CONFIG_64BIT1515-#define ELF_CLASS ELFCLASS641616-#else1717-#define ELF_CLASS ELFCLASS321818-#endif1919-2020-#define R_386_NONE 02121-#define R_386_32 12222-#define R_386_PC32 22323-#define R_386_GOT32 32424-#define R_386_PLT32 42525-#define R_386_COPY 52626-#define R_386_GLOB_DAT 62727-#define R_386_JMP_SLOT 72828-#define R_386_RELATIVE 82929-#define R_386_GOTOFF 93030-#define R_386_GOTPC 103131-#define R_386_NUM 113232-3333-#define ELF_PLATFORM (0)3434-3535-#define ELF_ET_DYN_BASE (0x08000000)3636-3737-/* the following stolen from asm-ppc/elf.h */3838-#define ELF_NGREG 48 /* includes nip, msr, lr, etc. */3939-#define ELF_NFPREG 33 /* includes fpscr */4040-/* General registers */4141-typedef unsigned long elf_greg_t;4242-typedef elf_greg_t elf_gregset_t[ELF_NGREG];4343-4444-/* Floating point registers */4545-typedef double elf_fpreg_t;4646-typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];4747-4848-#define ELF_DATA ELFDATA2MSB4949-#define ELF_ARCH EM_PPC5050-5151-#endif
···11-/*22- * This file contains miscellaneous low-level functions.33- * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)44- *55- * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)66- * and Paul Mackerras.77- *88- * A couple of functions stolen from arch/ppc/kernel/misc.S for UML99- * by Chris Emerson.1010- *1111- * This program is free software; you can redistribute it and/or1212- * modify it under the terms of the GNU General Public License1313- * as published by the Free Software Foundation; either version1414- * 2 of the License, or (at your option) any later version.1515- *1616- */1717-1818-#include <asm/processor.h>1919-#include "ppc_asm.h"2020-2121-#if defined(CONFIG_4xx) || defined(CONFIG_8xx)2222-#define CACHE_LINE_SIZE 162323-#define LG_CACHE_LINE_SIZE 42424-#define MAX_COPY_PREFETCH 12525-#else2626-#define CACHE_LINE_SIZE 322727-#define LG_CACHE_LINE_SIZE 52828-#define MAX_COPY_PREFETCH 42929-#endif /* CONFIG_4xx || CONFIG_8xx */3030-3131- .text3232-3333-/*3434- * Clear a page using the dcbz instruction, which doesn't cause any3535- * memory traffic (except to write out any cache lines which get3636- * displaced). This only works on cacheable memory.3737- */3838-_GLOBAL(clear_page)3939- li r0,4096/CACHE_LINE_SIZE4040- mtctr r04141-#ifdef CONFIG_8xx4242- li r4, 04343-1: stw r4, 0(r3)4444- stw r4, 4(r3)4545- stw r4, 8(r3)4646- stw r4, 12(r3)4747-#else4848-1: dcbz 0,r34949-#endif5050- addi r3,r3,CACHE_LINE_SIZE5151- bdnz 1b5252- blr5353-5454-/*5555- * Copy a whole page. We use the dcbz instruction on the destination5656- * to reduce memory traffic (it eliminates the unnecessary reads of5757- * the destination into cache). This requires that the destination5858- * is cacheable.5959- */6060-#define COPY_16_BYTES \6161- lwz r6,4(r4); \6262- lwz r7,8(r4); \6363- lwz r8,12(r4); \6464- lwzu r9,16(r4); \6565- stw r6,4(r3); \6666- stw r7,8(r3); \6767- stw r8,12(r3); \6868- stwu r9,16(r3)6969-7070-_GLOBAL(copy_page)7171- addi r3,r3,-47272- addi r4,r4,-47373- li r5,47474-7575-#ifndef CONFIG_8xx7676-#if MAX_COPY_PREFETCH > 17777- li r0,MAX_COPY_PREFETCH7878- li r11,47979- mtctr r08080-11: dcbt r11,r48181- addi r11,r11,CACHE_LINE_SIZE8282- bdnz 11b8383-#else /* MAX_COPY_PREFETCH == 1 */8484- dcbt r5,r48585- li r11,CACHE_LINE_SIZE+48686-#endif /* MAX_COPY_PREFETCH */8787-#endif /* CONFIG_8xx */8888-8989- li r0,4096/CACHE_LINE_SIZE9090- mtctr r09191-1:9292-#ifndef CONFIG_8xx9393- dcbt r11,r49494- dcbz r5,r39595-#endif9696- COPY_16_BYTES9797-#if CACHE_LINE_SIZE >= 329898- COPY_16_BYTES9999-#if CACHE_LINE_SIZE >= 64100100- COPY_16_BYTES101101- COPY_16_BYTES102102-#if CACHE_LINE_SIZE >= 128103103- COPY_16_BYTES104104- COPY_16_BYTES105105- COPY_16_BYTES106106- COPY_16_BYTES107107-#endif108108-#endif109109-#endif110110- bdnz 1b111111- blr
-42
arch/um/sys-ppc/miscthings.c
···11-#include <linux/threads.h>22-#include <linux/stddef.h> // for NULL33-#include <linux/elf.h> // for AT_NULL44-55-/* The following function nicked from arch/ppc/kernel/process.c and66- * adapted slightly */77-/*88- * XXX ld.so expects the auxiliary table to start on99- * a 16-byte boundary, so we have to find it and1010- * move it up. :-(1111- */1212-void shove_aux_table(unsigned long sp)1313-{1414- int argc;1515- char *p;1616- unsigned long e;1717- unsigned long aux_start, offset;1818-1919- argc = *(int *)sp;2020- sp += sizeof(int) + (argc + 1) * sizeof(char *);2121- /* skip over the environment pointers */2222- do {2323- p = *(char **)sp;2424- sp += sizeof(char *);2525- } while (p != NULL);2626- aux_start = sp;2727- /* skip to the end of the auxiliary table */2828- do {2929- e = *(unsigned long *)sp;3030- sp += 2 * sizeof(unsigned long);3131- } while (e != AT_NULL);3232- offset = ((aux_start + 15) & ~15) - aux_start;3333- if (offset != 0) {3434- do {3535- sp -= sizeof(unsigned long);3636- e = *(unsigned long *)sp;3737- *(unsigned long *)(sp + offset) = e;3838- } while (sp > aux_start);3939- }4040-}4141-/* END stuff taken from arch/ppc/kernel/process.c */4242-
-58
arch/um/sys-ppc/ptrace.c
···11-#include <linux/sched.h>22-#include "asm/ptrace.h"33-44-int putreg(struct task_struct *child, unsigned long regno, 55- unsigned long value)66-{77- child->thread.process_regs.regs[regno >> 2] = value;88- return 0;99-}1010-1111-int poke_user(struct task_struct *child, long addr, long data)1212-{1313- if ((addr & 3) || addr < 0)1414- return -EIO;1515-1616- if (addr < MAX_REG_OFFSET)1717- return putreg(child, addr, data);1818-1919- else if((addr >= offsetof(struct user, u_debugreg[0])) &&2020- (addr <= offsetof(struct user, u_debugreg[7]))){2121- addr -= offsetof(struct user, u_debugreg[0]);2222- addr = addr >> 2;2323- if((addr == 4) || (addr == 5)) return -EIO;2424- child->thread.arch.debugregs[addr] = data;2525- return 0;2626- }2727- return -EIO;2828-}2929-3030-unsigned long getreg(struct task_struct *child, unsigned long regno)3131-{3232- unsigned long retval = ~0UL;3333-3434- retval &= child->thread.process_regs.regs[regno >> 2];3535- return retval;3636-}3737-3838-int peek_user(struct task_struct *child, long addr, long data)3939-{4040- /* read the word at location addr in the USER area. */4141- unsigned long tmp;4242-4343- if ((addr & 3) || addr < 0)4444- return -EIO;4545-4646- tmp = 0; /* Default return condition */4747- if(addr < MAX_REG_OFFSET){4848- tmp = getreg(child, addr);4949- }5050- else if((addr >= offsetof(struct user, u_debugreg[0])) &&5151- (addr <= offsetof(struct user, u_debugreg[7]))){5252- addr -= offsetof(struct user, u_debugreg[0]);5353- addr = addr >> 2;5454- tmp = child->thread.arch.debugregs[addr];5555- }5656- return put_user(tmp, (unsigned long *) data);5757-}5858-
-29
arch/um/sys-ppc/ptrace_user.c
···11-#include <errno.h>22-#include <asm/ptrace.h>33-#include <sysdep/ptrace.h>44-55-int ptrace_getregs(long pid, unsigned long *regs_out)66-{77- int i;88- for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {99- errno = 0;1010- regs_out->regs[i] = ptrace(PTRACE_PEEKUSR, pid, i*4, 0);1111- if (errno) {1212- return -errno;1313- }1414- }1515- return 0;1616-}1717-1818-int ptrace_setregs(long pid, unsigned long *regs_in)1919-{2020- int i;2121- for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {2222- if (i != 34 /* FIXME: PT_ORIG_R3 */ && i <= PT_MQ) {2323- if (ptrace(PTRACE_POKEUSR, pid, i*4, regs_in->regs[i]) < 0) {2424- return -errno;2525- }2626- }2727- }2828- return 0;2929-}
-93
arch/um/sys-ppc/shared/sysdep/ptrace.h
···11-/* 22- * Licensed under the GPL33- */44-55-#ifndef __SYS_PTRACE_PPC_H66-#define __SYS_PTRACE_PPC_H77-88-#include <linux/types.h>99-1010-/* the following taken from <asm-ppc/ptrace.h> */1111-1212-#ifdef CONFIG_PPC641313-#define PPC_REG unsigned long /*long*/1414-#else1515-#define PPC_REG unsigned long1616-#endif1717-struct sys_pt_regs_s {1818- PPC_REG gpr[32];1919- PPC_REG nip;2020- PPC_REG msr;2121- PPC_REG orig_gpr3; /* Used for restarting system calls */2222- PPC_REG ctr;2323- PPC_REG link;2424- PPC_REG xer;2525- PPC_REG ccr;2626- PPC_REG mq; /* 601 only (not used at present) */2727- /* Used on APUS to hold IPL value. */2828- PPC_REG trap; /* Reason for being here */2929- PPC_REG dar; /* Fault registers */3030- PPC_REG dsisr;3131- PPC_REG result; /* Result of a system call */3232-};3333-3434-#define NUM_REGS (sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG))3535-3636-struct sys_pt_regs {3737- PPC_REG regs[sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG)];3838-};3939-4040-#define UM_MAX_REG (PT_FPR0)4141-#define UM_MAX_REG_OFFSET (UM_MAX_REG * sizeof(PPC_REG))4242-4343-#define EMPTY_REGS { { [ 0 ... NUM_REGS - 1] = 0 } }4444-4545-#define UM_REG(r, n) ((r)->regs[n])4646-4747-#define UM_SYSCALL_RET(r) UM_REG(r, PT_R3)4848-#define UM_SP(r) UM_REG(r, PT_R1)4949-#define UM_IP(r) UM_REG(r, PT_NIP)5050-#define UM_ELF_ZERO(r) UM_REG(r, PT_FPSCR)5151-#define UM_SYSCALL_NR(r) UM_REG(r, PT_R0)5252-#define UM_SYSCALL_ARG1(r) UM_REG(r, PT_ORIG_R3)5353-#define UM_SYSCALL_ARG2(r) UM_REG(r, PT_R4)5454-#define UM_SYSCALL_ARG3(r) UM_REG(r, PT_R5)5555-#define UM_SYSCALL_ARG4(r) UM_REG(r, PT_R6)5656-#define UM_SYSCALL_ARG5(r) UM_REG(r, PT_R7)5757-#define UM_SYSCALL_ARG6(r) UM_REG(r, PT_R8)5858-5959-#define UM_SYSCALL_NR_OFFSET (PT_R0 * sizeof(PPC_REG))6060-#define UM_SYSCALL_RET_OFFSET (PT_R3 * sizeof(PPC_REG))6161-#define UM_SYSCALL_ARG1_OFFSET (PT_R3 * sizeof(PPC_REG))6262-#define UM_SYSCALL_ARG2_OFFSET (PT_R4 * sizeof(PPC_REG))6363-#define UM_SYSCALL_ARG3_OFFSET (PT_R5 * sizeof(PPC_REG))6464-#define UM_SYSCALL_ARG4_OFFSET (PT_R6 * sizeof(PPC_REG))6565-#define UM_SYSCALL_ARG5_OFFSET (PT_R7 * sizeof(PPC_REG))6666-#define UM_SYSCALL_ARG6_OFFSET (PT_R8 * sizeof(PPC_REG))6767-#define UM_SP_OFFSET (PT_R1 * sizeof(PPC_REG))6868-#define UM_IP_OFFSET (PT_NIP * sizeof(PPC_REG))6969-#define UM_ELF_ZERO_OFFSET (PT_R3 * sizeof(PPC_REG))7070-7171-#define UM_SET_SYSCALL_RETURN(_regs, result) \7272-do { \7373- if (result < 0) { \7474- (_regs)->regs[PT_CCR] |= 0x10000000; \7575- UM_SYSCALL_RET((_regs)) = -result; \7676- } else { \7777- UM_SYSCALL_RET((_regs)) = result; \7878- } \7979-} while(0)8080-8181-extern void shove_aux_table(unsigned long sp);8282-#define UM_FIX_EXEC_STACK(sp) shove_aux_table(sp);8383-8484-/* These aren't actually defined. The undefs are just to make sure8585- * everyone's clear on the concept.8686- */8787-#undef UML_HAVE_GETREGS8888-#undef UML_HAVE_GETFPREGS8989-#undef UML_HAVE_SETREGS9090-#undef UML_HAVE_SETFPREGS9191-9292-#endif9393-
···11-/*22- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)33- * Licensed under the GPL44- */55-66-#ifndef __SYSDEP_PPC_SKAS_PTRACE_H77-#define __SYSDEP_PPC_SKAS_PTRACE_H88-99-struct ptrace_faultinfo {1010- int is_write;1111- unsigned long addr;1212-};1313-1414-struct ptrace_ldt {1515- int func;1616- void *ptr;1717- unsigned long bytecount;1818-};1919-2020-#define PTRACE_LDT 542121-2222-#endif
-43
arch/um/sys-ppc/shared/sysdep/syscalls.h
···11-/* 22- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)33- * Licensed under the GPL44- */55-66-typedef long syscall_handler_t(unsigned long arg1, unsigned long arg2,77- unsigned long arg3, unsigned long arg4,88- unsigned long arg5, unsigned long arg6);99-1010-#define EXECUTE_SYSCALL(syscall, regs) \1111- (*sys_call_table[syscall])(UM_SYSCALL_ARG1(®s), \1212- UM_SYSCALL_ARG2(®s), \1313- UM_SYSCALL_ARG3(®s), \1414- UM_SYSCALL_ARG4(®s), \1515- UM_SYSCALL_ARG5(®s), \1616- UM_SYSCALL_ARG6(®s))1717-1818-extern syscall_handler_t sys_mincore;1919-extern syscall_handler_t sys_madvise;2020-2121-/* old_mmap needs the correct prototype since syscall_kern.c includes2222- * this file.2323- */2424-int old_mmap(unsigned long addr, unsigned long len,2525- unsigned long prot, unsigned long flags,2626- unsigned long fd, unsigned long offset);2727-2828-#define ARCH_SYSCALLS \2929- [ __NR_modify_ldt ] = sys_ni_syscall, \3030- [ __NR_pciconfig_read ] = sys_ni_syscall, \3131- [ __NR_pciconfig_write ] = sys_ni_syscall, \3232- [ __NR_pciconfig_iobase ] = sys_ni_syscall, \3333- [ __NR_pivot_root ] = sys_ni_syscall, \3434- [ __NR_multiplexer ] = sys_ni_syscall, \3535- [ __NR_mmap ] = old_mmap, \3636- [ __NR_madvise ] = sys_madvise, \3737- [ __NR_mincore ] = sys_mincore, \3838- [ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \3939- [ __NR_utimes ] = (syscall_handler_t *) sys_utimes, \4040- [ __NR_fadvise64 ] = (syscall_handler_t *) sys_fadvise64,4141-4242-#define LAST_ARCH_SYSCALL __NR_fadvise644343-