Date: Mon, 6 Jun 2005 04:36:18 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 78070 for review Message-ID: <200506060436.j564aItM024092@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=78070 Change 78070 by marcel@marcel_nfs on 2005/06/06 04:35:55 Submit a bunch of changes I have for a while now. This definitely doesn't compile. Includes changes by prior integrations. Affected files ... .. //depot/projects/ia64/sys/boot/ia64/ski/Makefile#3 edit .. //depot/projects/ia64/sys/boot/ia64/ski/elf_freebsd.c#2 edit .. //depot/projects/ia64/sys/ia64/ia64/efi.c#8 edit .. //depot/projects/ia64/sys/ia64/ia64/machdep.c#115 edit .. //depot/projects/ia64/sys/ia64/include/bootinfo.h#10 edit Differences ... ==== //depot/projects/ia64/sys/boot/ia64/ski/Makefile#3 (text+ko) ==== @@ -10,6 +10,7 @@ skiconsole.c skifs.c ssc.c start.S time.c vers.c CFLAGS+= -DLOADER +CFLAGS+= -I${.OBJDIR} CFLAGS+= -I${.CURDIR} CFLAGS+= -I${.CURDIR}/../../.. CFLAGS+= -I${.CURDIR}/../../efi/include @@ -43,4 +44,8 @@ FILES= ${PROG}.help +CLEANFILES+= machine +beforedepend: + ln -s ${.CURDIR}/../../../ia64/include ${.OBJDIR}/machine + .include <bsd.prog.mk> ==== //depot/projects/ia64/sys/boot/ia64/ski/elf_freebsd.c#2 (text+ko) ==== @@ -36,7 +36,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/boot/ia64/ski/elf_freebsd.c,v 1.11 2004/09/24 03:53:50 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/boot/ia64/ski/elf_freebsd.c,v 1.12 2005/01/05 22:16:58 imp Exp $"); #include <stand.h> #include <string.h> @@ -86,9 +86,9 @@ #include "bootstrap.h" #include "libski.h" -#define _KERNEL +extern uint64_t *pgtbl; -static int elf64_exec(struct preloaded_file *amp); +static int elf64_exec(struct preloaded_file *amp); struct file_format ia64_elf = { elf64_loadfile, elf64_exec }; @@ -170,33 +170,56 @@ bzero(bi, sizeof(struct bootinfo)); bi_load(bi, fp); - /* - * Region 6 is direct mapped UC and region 7 is direct mapped - * WC. The details of this is controlled by the Alt {I,D}TLB - * handlers. Here we just make sure that they have the largest - * possible page size to minimise TLB usage. - */ - ia64_set_rr(IA64_RR_BASE(6), (6 << 8) | (28 << 2)); - ia64_set_rr(IA64_RR_BASE(7), (7 << 8) | (28 << 2)); + if (pgtbl == NULL) { + /* + * Region 6 is direct mapped UC and region 7 is direct mapped + * WC. The details of this is controlled by the Alt {I,D}TLB + * handlers. Here we just make sure that they have the largest + * possible page size to minimise TLB usage. + */ + ia64_set_rr(IA64_RR_BASE(6), (6 << 8) | (28 << 2)); + ia64_set_rr(IA64_RR_BASE(7), (7 << 8) | (28 << 2)); + + bzero(&pte, sizeof(pte)); + pte.pte_p = 1; + pte.pte_ma = PTE_MA_WB; + pte.pte_a = 1; + pte.pte_d = 1; + pte.pte_pl = PTE_PL_KERN; + pte.pte_ar = PTE_AR_RWX; + pte.pte_ppn = 0; + + __asm __volatile("mov cr.ifa=%0" :: "r"(IA64_RR_BASE(7))); + __asm __volatile("mov cr.itir=%0" :: "r"(28 << 2)); + __asm __volatile("srlz.i;;"); + __asm __volatile("itr.i itr[%0]=%1;;" + :: "r"(0), "r"(*(u_int64_t*)&pte)); + __asm __volatile("srlz.i;;"); + __asm __volatile("itr.d dtr[%0]=%1;;" + :: "r"(0), "r"(*(u_int64_t*)&pte)); + __asm __volatile("srlz.i;;"); + } else { + ia64_set_rr(IA64_RR_BASE(5), (5 << 8) | (20 << 2) | 1); - bzero(&pte, sizeof(pte)); - pte.pte_p = 1; - pte.pte_ma = PTE_MA_WB; - pte.pte_a = 1; - pte.pte_d = 1; - pte.pte_pl = PTE_PL_KERN; - pte.pte_ar = PTE_AR_RWX; - pte.pte_ppn = 0; + bzero(&pte, sizeof(pte)); + pte.pte_p = 1; + pte.pte_ma = PTE_MA_WB; + pte.pte_a = 1; + pte.pte_d = 1; + pte.pte_pl = PTE_PL_KERN; + pte.pte_ar = PTE_AR_RWX; + pte.pte_ppn = pgtbl[0] >> 12; - __asm __volatile("mov cr.ifa=%0" :: "r"(IA64_RR_BASE(7))); - __asm __volatile("mov cr.itir=%0" :: "r"(28 << 2)); - __asm __volatile("srlz.i;;"); - __asm __volatile("itr.i itr[%0]=%1;;" + __asm __volatile("mov cr.ifa=%0" :: "r"(IA64_KERNELBASE)); + __asm __volatile("mov cr.itir=%0" :: "r"(20 << 2)); + __asm __volatile("srlz.i;;"); + __asm __volatile("itr.i itr[%0]=%1;;" :: "r"(0), "r"(*(u_int64_t*)&pte)); - __asm __volatile("srlz.i;;"); - __asm __volatile("itr.d dtr[%0]=%1;;" + __asm __volatile("srlz.i;;"); + __asm __volatile("itr.d dtr[%0]=%1;;" :: "r"(0), "r"(*(u_int64_t*)&pte)); - __asm __volatile("srlz.i;;"); + __asm __volatile("srlz.i;;"); + } enter_kernel(fp->f_name, hdr->e_entry, bi); } ==== //depot/projects/ia64/sys/ia64/ia64/efi.c#8 (text+ko) ==== @@ -90,8 +90,8 @@ md = efi_md_next(md); } status = ia64_call_efi_physical((uint64_t)efi_runtime->rt_setvirtual, - bootinfo.bi_memmap_size, bootinfo.bi_memdesc_size, - bootinfo.bi_memdesc_version, bootinfo.bi_memmap, 0); + ia64_bi_lookup(BI_TAG_MM_SIZE), ia64_bi_lookup(BI_TAG_MMD_SIZE), + ia64_bi_lookup(BI_TAG_MMD_VERS), ia64_bi_lookup(BI_TAG_MM_ADDR), 0); return ((status < 0) ? EFAULT : 0); } @@ -123,10 +123,12 @@ struct efi_md * efi_md_first(void) { + uint64_t pa; - if (bootinfo.bi_memmap == 0) + pa = ia64_bi_lookup(BI_TAG_MM_ADDR); + if (pa == 0) return (NULL); - return ((struct efi_md *)IA64_PHYS_TO_RR7(bootinfo.bi_memmap)); + return ((struct efi_md *)IA64_PHYS_TO_RR7(pa)); } struct efi_md * @@ -134,9 +136,9 @@ { uint64_t plim; - plim = IA64_PHYS_TO_RR7(bootinfo.bi_memmap + bootinfo.bi_memmap_size); - md = (struct efi_md *)((uintptr_t)md + bootinfo.bi_memdesc_size); - return ((md >= (struct efi_md *)plim) ? NULL : md); + plim = ia64_bi_lookup(BI_TAG_MM_ADDR) + ia64_bi_lookup(BI_TAG_MM_SIZE); + md = (struct efi_md *)((uintptr_t)md + ia64_bi_lookup(BI_TAG_MMD_SIZE)); + return ((md >= (struct efi_md *)IA64_PHYS_TO_RR7(plim)) ? NULL : md); } void ==== //depot/projects/ia64/sys/ia64/ia64/machdep.c#115 (text+ko) ==== @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/ia64/ia64/machdep.c,v 1.193 2004/12/08 05:46:54 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/ia64/ia64/machdep.c,v 1.199 2005/04/04 21:53:54 jhb Exp $"); #include "opt_compat.h" #include "opt_ddb.h" @@ -34,63 +34,70 @@ #include "opt_msgbuf.h" #include <sys/param.h> +#include <sys/proc.h> #include <sys/systm.h> +#include <sys/bio.h> +#include <sys/buf.h> +#include <sys/bus.h> +#include <sys/cons.h> +#include <sys/cpu.h> #include <sys/eventhandler.h> +#include <sys/exec.h> +#include <sys/imgact.h> #include <sys/kdb.h> -#include <sys/sysproto.h> -#include <sys/signalvar.h> -#include <sys/imgact.h> #include <sys/kernel.h> -#include <sys/proc.h> +#include <sys/linker.h> #include <sys/lock.h> -#include <sys/pcpu.h> #include <sys/malloc.h> -#include <sys/reboot.h> -#include <sys/bio.h> -#include <sys/buf.h> #include <sys/mbuf.h> -#include <sys/vmmeter.h> #include <sys/msgbuf.h> -#include <sys/exec.h> +#include <sys/pcpu.h> +#include <sys/ptrace.h> +#include <sys/random.h> +#include <sys/reboot.h> +#include <sys/signalvar.h> +#include <sys/syscall.h> #include <sys/sysctl.h> +#include <sys/sysproto.h> +#include <sys/ucontext.h> #include <sys/uio.h> -#include <sys/linker.h> -#include <sys/random.h> -#include <sys/cons.h> #include <sys/uuid.h> -#include <sys/syscall.h> +#include <sys/vmmeter.h> +#include <sys/vnode.h> + +#include <ddb/ddb.h> + #include <net/netisr.h> + #include <vm/vm.h> +#include <vm/vm_extern.h> #include <vm/vm_kern.h> #include <vm/vm_page.h> #include <vm/vm_map.h> -#include <vm/vm_extern.h> #include <vm/vm_object.h> #include <vm/vm_pager.h> -#include <sys/ptrace.h> + +#include <machine/bootinfo.h> #include <machine/clock.h> #include <machine/cpu.h> -#include <machine/md_var.h> -#include <machine/reg.h> +#include <machine/efi.h> +#include <machine/elf.h> #include <machine/fpu.h> #include <machine/mca.h> +#include <machine/md_var.h> +#include <machine/mutex.h> #include <machine/pal.h> +#include <machine/pcb.h> +#include <machine/reg.h> #include <machine/sal.h> +#include <machine/sigframe.h> #ifdef SMP #include <machine/smp.h> #endif -#include <machine/bootinfo.h> -#include <machine/mutex.h> +#include <machine/unwind.h> #include <machine/vmparam.h> -#include <machine/elf.h> -#include <ddb/ddb.h> -#include <sys/vnode.h> -#include <sys/ucontext.h> -#include <machine/sigframe.h> -#include <machine/efi.h> -#include <machine/unwind.h> + #include <i386/include/specialreg.h> -#include <machine/pcb.h> u_int64_t processor_frequency; u_int64_t bus_frequency; @@ -98,7 +105,7 @@ int cold = 1; u_int64_t pa_bootinfo; -struct bootinfo bootinfo; +struct bi_tagval *bootinfo; struct pcpu early_pcpu; extern char kstack[]; @@ -136,6 +143,7 @@ struct msgbuf *msgbufp=0; long Maxmem = 0; +long realmem = 0; vm_offset_t phys_avail[100]; @@ -239,6 +247,7 @@ #endif printf("real memory = %ld (%ld MB)\n", ia64_ptob(Maxmem), ia64_ptob(Maxmem) / 1048576); + realmem = ia64_ptob(Maxmem); /* * Display any holes after the first chunk of extended memory. @@ -287,6 +296,17 @@ efi_reset_system(); } +/* Get current clock frequency for the given cpu id. */ +int +cpu_est_clockrate(int cpu_id, uint64_t *rate) +{ + + if (pcpu_find(cpu_id) == NULL || rate == NULL) + return (EINVAL); + *rate = processor_frequency; + return (0); +} + void cpu_halt() { @@ -381,6 +401,30 @@ } void +spinlock_enter(void) +{ + struct thread *td; + + td = curthread; + if (td->td_md.md_spinlock_count == 0) + td->td_md.md_saved_intr = intr_disable(); + td->td_md.md_spinlock_count++; + critical_enter(); +} + +void +spinlock_exit(void) +{ + struct thread *td; + + td = curthread; + critical_exit(); + td->td_md.md_spinlock_count--; + if (td->td_md.md_spinlock_count == 0) + intr_restore(td->td_md.md_saved_intr); +} + +void map_pal_code(void) { pt_entry_t pte; @@ -471,15 +515,28 @@ } } +uint64_t +ia64_bi_lookup(uint64_t tag) +{ + struct bi_tagval *bi; + + bi = bootinfo; + if (bi == NULL) + return (0); + while (bi->tag != 0 && bi->tag != tag) + bi = (bi->tag == BI_TAG_BI_REDIR) ? (void *)bi->val : bi + 1; + return (bi->val); +} + void ia64_init(void) { - int phys_avail_cnt; vm_offset_t kernstart, kernend; vm_offset_t kernstartpfn, kernendpfn, pfn0, pfn1; char *p; struct efi_md *md; - int metadata_missing; + uint64_t val; + int phys_avail_cnt; /* NO OUTPUT ALLOWED UNTIL FURTHER NOTICE */ @@ -495,15 +552,13 @@ */ /* - * pa_bootinfo is the physical address of the bootinfo block as - * passed to us by the loader and set in locore.s. + * pa_bootinfo is the physical address of the first (tag,val) + * pair. This must have the magic tag and value. */ - bootinfo = *(struct bootinfo *)(IA64_PHYS_TO_RR7(pa_bootinfo)); - - if (bootinfo.bi_magic != BOOTINFO_MAGIC || bootinfo.bi_version != 1) { - bzero(&bootinfo, sizeof(bootinfo)); - bootinfo.bi_kernend = (vm_offset_t) round_page(_end); - } + bootinfo = (struct bi_tagval *)(IA64_PHYS_TO_RR7(pa_bootinfo)); + if (bootinfo->tag != BI_TAG_BI_MAGIC || + bootinfo->val != BI_VAL_BI_MAGIC) + bootinfo = NULL; /* * Look for the I/O ports first - we need them for console @@ -520,22 +575,12 @@ } } - metadata_missing = 0; - if (bootinfo.bi_modulep) - preload_metadata = (caddr_t)bootinfo.bi_modulep; - else - metadata_missing = 1; - if (envmode == 1) - kern_envp = static_env; - else - kern_envp = (caddr_t)bootinfo.bi_envp; + boothowto = ia64_bi_lookup(BI_TAG_BOOTHOW); + kern_envp = (envmode != 1) ? (void *)ia64_bi_lookup(BI_TAG_ENVIRON) : + static_env; + preload_metadata = (void *)ia64_bi_lookup(BI_TAG_PRELOAD); /* - * Look at arguments passed to us and compute boothowto. - */ - boothowto = bootinfo.bi_boothowto; - - /* * Catch case of boot_verbose set in environment. */ if ((p = getenv("boot_verbose")) != NULL) { @@ -570,7 +615,7 @@ * Wire things up so we can call the firmware. */ map_pal_code(); - efi_boot_minimal(bootinfo.bi_systab); + efi_boot_minimal(ia64_bi_lookup(BI_TAG_SYSTABLE)); ia64_sal_init(); calculate_frequencies(); @@ -579,21 +624,26 @@ */ kernstart = trunc_page(kernel_text); #ifdef DDB - ksym_start = bootinfo.bi_symtab; - ksym_end = bootinfo.bi_esymtab; - kernend = (vm_offset_t)round_page(ksym_end); + ksym_start = ia64_bi_lookup(BI_TAG_SSYMTAB); + ksym_end = ia64_bi_lookup(BI_TAG_ESYMTAB); + kernend = (ksym_end != 0) ? (vm_offset_t)round_page(ksym_end) : + (vm_offset_t)round_page(_end); #else kernend = (vm_offset_t)round_page(_end); #endif /* But if the bootstrap tells us otherwise, believe it! */ - if (bootinfo.bi_kernend) - kernend = round_page(bootinfo.bi_kernend); - if (metadata_missing) + val = ia64_bi_lookup(BI_TAG_KERNEND); + if (val != 0) + kernend = round_page(val); + + if (preload_metadata == NULL) printf("WARNING: loader(8) metadata is missing!\n"); /* Get FPSWA interface */ - fpswa_iface = (struct fpswa_iface *)IA64_PHYS_TO_RR7(bootinfo.bi_fpswa); + val = ia64_bi_lookup(BI_TAG_FPSWA); + if (val != 0) + fpswa_iface = (struct fpswa_iface *)IA64_PHYS_TO_RR7(val); /* Init basic tunables, including hz */ init_param1(); @@ -781,7 +831,7 @@ ia64_get_hcdp(void) { - return (bootinfo.bi_hcdp); + return (ia64_bi_lookup(BI_TAG_HCDP)); } void ==== //depot/projects/ia64/sys/ia64/include/bootinfo.h#10 (text+ko) ==== @@ -1,37 +1,41 @@ -/* $FreeBSD: src/sys/ia64/include/bootinfo.h,v 1.7 2004/11/28 04:34:17 marcel Exp $ */ -/* - * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. +/*- + * Copyright (c) 2004,2005 Marcel Moolenaar * All rights reserved. * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. + * $FreeBSD$ */ +#ifndef _MACHINE_BOOTINFO_H_ +#define _MACHINE_BOOTINFO_H_ + +#ifdef LOADER_BACKWARD_COMPATIBILITY + struct bootinfo { uint64_t bi_magic; /* BOOTINFO_MAGIC */ #define BOOTINFO_MAGIC 0xdeadbeeffeedface uint64_t bi_version; /* version 1 */ - uint64_t bi_spare[5]; /* was: name of kernel */ - uint64_t bi_pgtbl; /* PA of loader page table */ + uint64_t bi_spare[6]; /* was: name of kernel */ uint64_t bi_hcdp; /* DIG64 HCDP table */ uint64_t bi_fpswa; /* FPSWA interface */ uint64_t bi_boothowto; /* value for boothowto */ @@ -40,7 +44,7 @@ uint64_t bi_memmap_size; /* size of EFI memory map */ uint64_t bi_memdesc_size; /* sizeof EFI memory desc */ uint32_t bi_memdesc_version; /* EFI memory desc version */ - uint32_t bi_pgtblsz; /* Size of loader page table */ + uint32_t bi_spare2; uint64_t bi_symtab; /* start of kernel sym table */ uint64_t bi_esymtab; /* end of kernel sym table */ uint64_t bi_kernend; /* end of kernel space */ @@ -49,3 +53,43 @@ }; extern struct bootinfo bootinfo; + +#endif + +/* + * (tag,val) array based hand-off. + */ + +struct bi_tagval { + uint64_t tag; + uint64_t val; +}; + +/* Non-optional tags. */ +#define BI_TAG_BI_MAGIC 0x62695f6d61676963ul /* bi_magic */ +#define BI_VAL_BI_MAGIC 0x3d46726565425344ul +#define BI_TAG_BI_REDIR 0x62695f7265646972ul /* bi_redir */ + +/* Tags for MI (meta) data. */ +#define BI_TAG_BOOTHOW 0x626f6f74686f7700ul /* boothow */ +#define BI_TAG_ENVIRON 0x656e7669726f6e00ul /* environ */ +#define BI_TAG_KERNEND 0x1 +#define BI_TAG_PRELOAD 0x7072656c6f616400ul /* preload */ +#define BI_TAG_SSYMTAB 0x7373796d74616200ul /* ssymtab */ +#define BI_TAG_ESYMTAB 0x6573796d74616200ul /* esymtab */ + +/* Tags for MD (meta) data. */ +#define BI_TAG_FPSWA 0x2 +#define BI_TAG_HCDP 0x3 +#define BI_TAG_MM_ADDR 0x6d6d5f6164647200ul /* mm_addr */ +#define BI_TAG_MM_SIZE 0x6d6d5f73697a6500ul /* mm_size */ +#define BI_TAG_MMD_SIZE 0x6d6d645f73697a65ul /* mmd_size */ +#define BI_TAG_MMD_VERS 0x6d6d645f76657273ul /* mmd_vers */ +#define BI_TAG_SYSTABLE 0x4 + +#define BI_TAG_PGTBL 0x10 +#define BI_TAG_PGTBLSZ 0x11 + +uint64_t ia64_bi_lookup(uint64_t); + +#endif /* _MACHINE_BOOTINFO_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506060436.j564aItM024092>