1 /* $FreeBSD: src/sys/boot/arc/lib/elf_freebsd.c,v 1.2 1999/08/28 00:39:38 peter Exp $ */
2 /* $DragonFly: src/sys/boot/arc/lib/Attic/elf_freebsd.c,v 1.2 2003/06/17 04:28:16 dillon Exp $ */
3 /* $NetBSD: loadfile.c,v 1.10 1998/06/25 06:45:46 ross Exp $ */
6 * Copyright (c) 1997 The NetBSD Foundation, Inc.
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
11 * NASA Ames Research Center.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the NetBSD
24 * Foundation, Inc. and its contributors.
25 * 4. Neither the name of The NetBSD Foundation nor the names of its
26 * contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
30 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
31 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
33 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
43 * Copyright (c) 1992, 1993
44 * The Regents of the University of California. All rights reserved.
46 * This code is derived from software contributed to Berkeley by
49 * Redistribution and use in source and binary forms, with or without
50 * modification, are permitted provided that the following conditions
52 * 1. Redistributions of source code must retain the above copyright
53 * notice, this list of conditions and the following disclaimer.
54 * 2. Redistributions in binary form must reproduce the above copyright
55 * notice, this list of conditions and the following disclaimer in the
56 * documentation and/or other materials provided with the distribution.
57 * 3. All advertising materials mentioning features or use of this software
58 * must display the following acknowledgement:
59 * This product includes software developed by the University of
60 * California, Berkeley and its contributors.
61 * 4. Neither the name of the University nor the names of its contributors
62 * may be used to endorse or promote products derived from this software
63 * without specific prior written permission.
65 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
66 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
67 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
68 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
69 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
70 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
71 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
72 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
73 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
74 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
77 * @(#)boot.c 8.1 (Berkeley) 6/10/93
83 #include <sys/param.h>
84 #include <sys/linker.h>
85 #include <machine/elf.h>
86 #include <machine/prom.h>
87 #include <machine/rpb.h>
88 #include <machine/bootinfo.h>
90 #include "bootstrap.h"
94 static int elf_exec(struct loaded_module *amp);
95 int bi_load(struct bootinfo_v1 *, vm_offset_t *,
96 struct loaded_module *);
98 struct module_format alpha_elf = { elf_loadmodule, elf_exec };
100 vm_offset_t ffp_save, ptbr_save;
103 elf_exec(struct loaded_module *mp)
106 static struct bootinfo_v1 bootinfo_v1;
107 struct module_metadata *md;
111 if ((md = mod_findmetadata(mp, MODINFOMD_ELFHDR)) == NULL)
112 return(EFTYPE); /* XXX actually EFUCKUP */
113 hdr = (Elf_Ehdr *)&(md->md_data);
115 /* XXX ffp_save does not appear to be used in the kernel.. */
116 bzero(&bootinfo_v1, sizeof(bootinfo_v1));
117 err = bi_load(&bootinfo_v1, &ffp_save, mp);
122 * Fill in the bootinfo for the kernel.
124 strncpy(bootinfo_v1.booted_kernel, mp->m_name,
125 sizeof(bootinfo_v1.booted_kernel));
126 prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo_v1.boot_flags,
127 sizeof(bootinfo_v1.boot_flags));
128 bootinfo_v1.hwrpb = (void *)HWRPB_ADDR;
129 bootinfo_v1.hwrpbsize = ((struct rpb *)HWRPB_ADDR)->rpb_size;
130 bootinfo_v1.cngetc = NULL;
131 bootinfo_v1.cnputc = NULL;
132 bootinfo_v1.cnpollc = NULL;
134 printf("Entering %s at 0x%lx...\n", mp->m_name, hdr->e_entry);
138 (*(void (*)())hdr->e_entry)(ffp_save, ptbr_save,
139 BOOTINFO_MAGIC, &bootinfo_v1, 1, 0);