From owner-svn-src-all@FreeBSD.ORG Sun Jan 24 03:10:49 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04F5B106566C; Sun, 24 Jan 2010 03:10:49 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DD46C8FC1F; Sun, 24 Jan 2010 03:10:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0O3AmNS099776; Sun, 24 Jan 2010 03:10:48 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0O3AmVo099773; Sun, 24 Jan 2010 03:10:48 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201001240310.o0O3AmVo099773@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Sun, 24 Jan 2010 03:10:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202909 - in head/sys/mips: include mips X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jan 2010 03:10:49 -0000 Author: gonzo Date: Sun Jan 24 03:10:48 2010 New Revision: 202909 URL: http://svn.freebsd.org/changeset/base/202909 Log: - Introduce kernel_kseg0_end variable that marks first address in KSEG0 available for use. All data below this address considered to be used by kernel. Along with kernel own data it might be symbol tables prepeared by trampoline code, boot loader service data passed for further analysis by kernel, etc... By default kernel_kseg0_end points to the end of loaded kernel. - Introduce mips_postboot_fixup function. It checks for symbol information copied by ELF trampoline and passes it to KDB Modified: head/sys/mips/include/md_var.h head/sys/mips/mips/machdep.c Modified: head/sys/mips/include/md_var.h ============================================================================== --- head/sys/mips/include/md_var.h Sun Jan 24 02:59:22 2010 (r202908) +++ head/sys/mips/include/md_var.h Sun Jan 24 03:10:48 2010 (r202909) @@ -44,6 +44,7 @@ extern char sigcode[]; extern int szsigcode, szosigcode; extern vm_offset_t kstack0; +extern vm_offset_t kernel_kseg0_end; void MipsSaveCurFPState(struct thread *); void fork_trampoline(void); @@ -69,6 +70,7 @@ void cpu_identify(void); void mips_cpu_init(void); void mips_pcpu0_init(void); void mips_proc0_init(void); +void mips_postboot_fixup(void); /* Platform call-downs. */ void platform_identify(void); Modified: head/sys/mips/mips/machdep.c ============================================================================== --- head/sys/mips/mips/machdep.c Sun Jan 24 02:59:22 2010 (r202908) +++ head/sys/mips/mips/machdep.c Sun Jan 24 03:10:48 2010 (r202909) @@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -151,9 +152,18 @@ extern char MipsTLBMiss[], MipsTLBMissEn extern char MipsCache[], MipsCacheEnd[]; extern char edata[], end[]; +#ifdef DDB +extern vm_offset_t ksym_start, ksym_end; +#endif u_int32_t bootdev; struct bootinfo bootinfo; +/* + * First kseg0 address available for use. By default it's equal to &end. + * But in some cases there might be additional data placed right after + * _end by loader or ELF trampoline. + */ +vm_offset_t kernel_kseg0_end = (vm_offset_t)&end; static void cpu_startup(void *dummy) @@ -360,6 +370,29 @@ mips_vector_init(void) } /* + * Fix kernel_kseg0_end address in case trampoline placed debug sympols + * data there + */ +void +mips_postboot_fixup(void) +{ +#ifdef DDB + Elf_Size *trampoline_data = (Elf_Size*)kernel_kseg0_end; + Elf_Size symtabsize = 0; + + if (trampoline_data[0] == SYMTAB_MAGIC) { + symtabsize = trampoline_data[1]; + kernel_kseg0_end += 2 * sizeof(Elf_Size); + /* start of .symtab */ + ksym_start = kernel_kseg0_end; + kernel_kseg0_end += symtabsize; + /* end of .strtab */ + ksym_end = kernel_kseg0_end; + } +#endif +} + +/* * Many SoCs have a means to reset the core itself. Others do not, or * the method is unknown to us. For those cases, we jump to the mips * reset vector and hope for the best. This works well in practice.