Commit 38084663 authored by Pete Zaitcev's avatar Pete Zaitcev Committed by David S. Miller

[sparc] Use Kai's way to make asm_offsets.h

parent a82891c4
# $Id: Makefile,v 1.49 2001/07/27 09:42:22 davem Exp $
#
# sparc/Makefile
#
# Makefile for the architecture dependent flags and dependencies on the
......@@ -47,16 +47,24 @@ image: vmlinux
$(MAKE) -C arch/sparc/boot image
archclean:
rm -f arch/sparc/kernel/include
rm -f $(TOPDIR)/vmlinux.aout
-$(MAKE) -C arch/sparc/boot clean
archmrproper:
rm -f $(TOPDIR)/include/asm-sparc/asm_offsets.h
prepare: check_asm
prepare: include/asm-$(ARCH)/asm_offsets.h
arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \
include/config/MARKER
include/asm-$(ARCH)/asm_offsets.h.tmp: arch/$(ARCH)/kernel/asm-offsets.s
@$(generate-asm-offsets.h) < $< > $@
check_asm: include/linux/version.h include/asm include/config/MARKER
$(MAKE) -C arch/sparc/kernel check_asm
include/asm-$(ARCH)/asm_offsets.h: include/asm-$(ARCH)/asm_offsets.h.tmp
@echo -n ' Generating $@'
@$(update-if-changed)
tftpboot.img:
$(MAKE) -C arch/sparc/boot tftpboot.img
......@@ -28,95 +28,3 @@ obj-y += sys_sunos.o sunos_ioctl.o
endif
include $(TOPDIR)/Rules.make
HPATH := $(objtree)/include
check_asm: FORCE
@if [ ! -r $(HPATH)/asm/asm_offsets.h ] ; then \
touch $(HPATH)/asm/asm_offsets.h ; \
fi
@echo "/* Automatically generated. Do not edit. */" > asm_offsets.h
@echo "#ifndef __ASM_OFFSETS_H__" >> asm_offsets.h
@echo "#define __ASM_OFFSETS_H__" >> asm_offsets.h
@echo "" >> asm_offsets.h
@echo "#include <linux/config.h>" >> asm_offsets.h
@echo "" >> asm_offsets.h
@echo "#ifndef CONFIG_SMP" >> asm_offsets.h
@echo "" >> asm_offsets.h
@echo "#include <linux/config.h>" > tmp.c
@echo "#undef CONFIG_SMP" >> tmp.c
@echo "#include <linux/sched.h>" >> tmp.c
$(CPP) $(CPPFLAGS) tmp.c -o tmp.i
@echo "/* Automatically generated. Do not edit. */" > check_asm_data.c
@echo "#include <linux/config.h>" >> check_asm_data.c
@echo "#undef CONFIG_SMP" >> check_asm_data.c
@echo "#include <linux/sched.h>" >> check_asm_data.c
@echo "unsigned int check_asm_data[] = {" >> check_asm_data.c
$(SH) ./check_asm.sh -data task tmp.i check_asm_data.c
$(SH) ./check_asm.sh -data mm tmp.i check_asm_data.c
$(SH) ./check_asm.sh -data thread tmp.i check_asm_data.c
@echo '};' >> check_asm_data.c
$(CC) $(CFLAGS) -S -o check_asm_data.s check_asm_data.c
@echo "/* Automatically generated. Do not edit. */" > check_asm.c
@echo 'extern int printf(const char *fmt, ...);' >>check_asm.c
@echo "unsigned int check_asm_data[] = {" >> check_asm.c
$(SH) ./check_asm.sh -ints check_asm_data.s check_asm.c
@echo "};" >> check_asm.c
@echo 'int main(void) {' >> check_asm.c
@echo 'int i = 0;' >> check_asm.c
$(SH) ./check_asm.sh -printf task tmp.i check_asm.c
$(SH) ./check_asm.sh -printf mm tmp.i check_asm.c
$(SH) ./check_asm.sh -printf thread tmp.i check_asm.c
@echo 'return 0; }' >> check_asm.c
@rm -f tmp.[ci] check_asm_data.[cs]
$(HOSTCC) -o check_asm check_asm.c
./check_asm >> asm_offsets.h
@rm -f check_asm check_asm.c
@echo "" >> asm_offsets.h
@echo "#else /* CONFIG_SMP */" >> asm_offsets.h
@echo "" >> asm_offsets.h
@echo "#include <linux/config.h>" > tmp.c
@echo "#undef CONFIG_SMP" >> tmp.c
@echo "#define CONFIG_SMP 1" >> tmp.c
@echo "#include <linux/sched.h>" >> tmp.c
$(CPP) $(CPPFLAGS) tmp.c -o tmp.i
@echo "/* Automatically generated. Do not edit. */" > check_asm_data.c
@echo "#include <linux/config.h>" >> check_asm_data.c
@echo "#undef CONFIG_SMP" >> check_asm_data.c
@echo "#define CONFIG_SMP 1" >> check_asm_data.c
@echo "#include <linux/sched.h>" >> check_asm_data.c
@echo "unsigned int check_asm_data[] = {" >> check_asm_data.c
$(SH) ./check_asm.sh -data task tmp.i check_asm_data.c
$(SH) ./check_asm.sh -data mm tmp.i check_asm_data.c
$(SH) ./check_asm.sh -data thread tmp.i check_asm_data.c
@echo '};' >> check_asm_data.c
$(CC) $(CFLAGS) -S -o check_asm_data.s check_asm_data.c
@echo "/* Automatically generated. Do not edit. */" > check_asm.c
@echo 'extern int printf(const char *fmt, ...);' >>check_asm.c
@echo "unsigned int check_asm_data[] = {" >> check_asm.c
$(SH) ./check_asm.sh -ints check_asm_data.s check_asm.c
@echo "};" >> check_asm.c
@echo 'int main(void) {' >> check_asm.c
@echo 'int i = 0;' >> check_asm.c
$(SH) ./check_asm.sh -printf task tmp.i check_asm.c
$(SH) ./check_asm.sh -printf mm tmp.i check_asm.c
$(SH) ./check_asm.sh -printf thread tmp.i check_asm.c
@echo 'return 0; }' >> check_asm.c
@rm -f tmp.[ci] check_asm_data.[cs]
$(HOSTCC) -o check_asm check_asm.c
./check_asm >> asm_offsets.h
@rm -f check_asm check_asm.c
@echo "" >> asm_offsets.h
@echo "#endif /* CONFIG_SMP */" >> asm_offsets.h
@echo "" >> asm_offsets.h
@echo "#endif /* __ASM_OFFSETS_H__ */" >> asm_offsets.h
@if test -r $(HPATH)/asm/asm_offsets.h; then \
if cmp -s asm_offsets.h $(HPATH)/asm/asm_offsets.h; then \
echo $(HPATH)/asm/asm_offsets.h is unchanged; \
rm -f asm_offsets.h; \
else \
mv -f asm_offsets.h $(HPATH)/asm/asm_offsets.h; \
fi; \
else \
mv -f asm_offsets.h $(HPATH)/asm/asm_offsets.h; \
fi
/*
* This program is used to generate definitions needed by
* assembly language modules.
*
* We use the technique used in the OSF Mach kernel code:
* generate asm statements containing #defines,
* compile this file to assembler, and then extract the
* #defines from the assembly-language output.
*
* On sparc, thread_info data is static and TI_XXX offsets are computed by hand.
*/
#include <linux/config.h>
#include <linux/sched.h>
// #include <linux/mm.h>
#define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
#define BLANK() asm volatile("\n->" : : )
int foo(void)
{
DEFINE(AOFF_task_thread, offsetof(struct task_struct, thread));
DEFINE(AOFF_task_ptrace, offsetof(struct task_struct, ptrace));
DEFINE(AOFF_task_blocked, offsetof(struct task_struct, blocked));
BLANK();
/* XXX This is the stuff for sclow.S, kill it. */
DEFINE(AOFF_task_pid, offsetof(struct task_struct, pid));
DEFINE(AOFF_task_uid, offsetof(struct task_struct, uid));
DEFINE(AOFF_task_gid, offsetof(struct task_struct, gid));
DEFINE(AOFF_task_euid, offsetof(struct task_struct, euid));
DEFINE(AOFF_task_egid, offsetof(struct task_struct, egid));
/* DEFINE(THREAD_INFO, offsetof(struct task_struct, thread_info)); */
DEFINE(ASIZ_task_uid, sizeof(current->uid));
DEFINE(ASIZ_task_gid, sizeof(current->gid));
DEFINE(ASIZ_task_euid, sizeof(current->euid));
DEFINE(ASIZ_task_egid, sizeof(current->egid));
BLANK();
DEFINE(AOFF_thread_fork_kpsr,
offsetof(struct thread_struct, fork_kpsr));
BLANK();
DEFINE(AOFF_thread_w_saved, offsetof(struct thread_struct, w_saved));
DEFINE(AOFF_thread_rwbuf_stkptrs,
offsetof(struct thread_struct, rwbuf_stkptrs));
DEFINE(AOFF_thread_reg_window,
offsetof(struct thread_struct, reg_window));
BLANK();
DEFINE(AOFF_mm_context, offsetof(struct mm_struct, context));
/* DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28); */
return 0;
}
#!/bin/sh
case $1 in
-printf)
sed -n -e '/^#/d;/struct[ ]*'$2'_struct[ ]*{/,/};/p' < $3 | sed '/struct[ ]*'$2'_struct[ ]*{/d;/:[0-9]*[ ]*;/d;/^[ ]*$/d;/};/d;s/^[ ]*//;s/volatile[ ]*//;s/\(unsigned\|signed\|struct\)[ ]*//;s/\(\[\|__attribute__\).*;[ ]*$//;s/(\*//;s/)(.*)//;s/;[ ]*$//;s/^[^ ]*[ ]*//;s/,/\
/g' | sed 's/^[ *]*//;s/[ ]*$//;s/^.*$/printf ("#define AOFF_'$2'_\0 0x%08x\\n", check_asm_data[i++]); printf("#define ASIZ_'$2'_\0 0x%08x\\n", check_asm_data[i++]);/' >> $4
echo "printf (\"#define ASIZ_$2\\t0x%08x\\n\", check_asm_data[i++]);" >> $4
;;
-data)
sed -n -e '/^#/d;/struct[ ]*'$2'_struct[ ]*{/,/};/p' < $3 | sed '/struct[ ]*'$2'_struct[ ]*{/d;/:[0-9]*[ ]*;/d;/^[ ]*$/d;/};/d;s/^[ ]*//;s/volatile[ ]*//;s/\(unsigned\|signed\|struct\)[ ]*//;s/\(\[\|__attribute__\).*;[ ]*$//;s/(\*//;s/)(.*)//;s/;[ ]*$//;s/^[^ ]*[ ]*//;s/,/\
/g' | sed 's/^[ *]*//;s/[ ]*$//;s/^.*$/ ((char *)\&((struct '$2'_struct *)0)->\0) - ((char *)((struct '$2'_struct *)0)), sizeof(((struct '$2'_struct *)0)->\0),/' >> $4
echo " sizeof(struct $2_struct)," >> $4
;;
-ints)
sed -n -e '/check_asm_data:/,/\.size/p' <$2 | sed -e 's/check_asm_data://' -e 's/\.size.*//' -e 's/\.ident.*//' -e 's/\.global.*//' -e 's/\.long[ ]\([0-9]*\)/\1,/' >>$3 ;;
*)
exit 1
;;
esac
exit 0
......@@ -17,6 +17,7 @@
#include <asm/kgdb.h>
#include <asm/contregs.h>
#include <asm/ptrace.h>
#include <asm/asm_offsets.h>
#include <asm/psr.h>
#include <asm/cprefix.h>
#include <asm/vaddrs.h>
......
......@@ -12,6 +12,7 @@
#include <asm/page.h>
#include <asm/psr.h>
#include <asm/ptrace.h>
#include <asm/asm_offsets.h>
#include <asm/winmacro.h>
#include <asm/asmmacro.h>
#include <asm/thread_info.h>
......
......@@ -7,6 +7,7 @@
#include <asm/cprefix.h>
#include <asm/page.h>
#include <asm/ptrace.h>
#include <asm/asm_offsets.h>
#include <asm/psr.h>
#include <asm/asi.h>
#include <asm/smp.h>
......
......@@ -36,18 +36,6 @@
LABEL(sunosnop):
CC_AND_RETT
#if 0
/* Not SMP safe */
.globl LABEL(sunosgetpid)
LABEL(sunosgetpid):
LOAD_CURRENT(l4, l5)
ld [%l4 + TI_TASK], %l4
ld [%l4 + AOFF_task_pid], %i0
ld [%l4 + AOFF_task_p_opptr], %l5
ld [%l5 + AOFF_task_pid], %i1
CC_AND_RETT
#endif
#if (ASIZ_task_uid == 2 && ASIZ_task_euid == 2)
.globl LABEL(sunosgetuid)
LABEL(sunosgetuid):
......
......@@ -8,6 +8,7 @@
#include <asm/contregs.h>
#include <asm/page.h>
#include <asm/ptrace.h>
#include <asm/asm_offsets.h>
#include <asm/psr.h>
#include <asm/smp.h>
#include <asm/asi.h>
......
......@@ -8,6 +8,7 @@
#include <asm/contregs.h>
#include <asm/page.h>
#include <asm/ptrace.h>
#include <asm/asm_offsets.h>
#include <asm/psr.h>
#include <asm/smp.h>
#include <asm/asi.h>
......
......@@ -73,7 +73,12 @@ extern void show_regs(struct pt_regs *);
#define REGWIN_SZ 0x40
#endif
#include <asm/asm_offsets.h>
/*
* The asm_offsets.h is a generated file, so we cannot include it.
* It may be OK for glibc headers, but it's utterly pointless for C code.
* The assembly code using those offsets has to include it explicitly.
*/
/* #include <asm/asm_offsets.h> */
/* These are for pt_regs. */
#define PT_PSR 0x0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment