]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/boot/arc/lib/elf_freebsd.c
merge fix for boot-time hang on centos' xen
[FreeBSD/FreeBSD.git] / sys / boot / arc / lib / elf_freebsd.c
1 /* $NetBSD: loadfile.c,v 1.10 1998/06/25 06:45:46 ross Exp $ */
2
3 /*-
4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9  * NASA Ames Research Center.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *      This product includes software developed by the NetBSD
22  *      Foundation, Inc. and its contributors.
23  * 4. Neither the name of The NetBSD Foundation nor the names of its
24  *    contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39 /*
40  * Copyright (c) 1992, 1993
41  *      The Regents of the University of California.  All rights reserved.
42  *
43  * This code is derived from software contributed to Berkeley by
44  * Ralph Campbell.
45  *
46  * Redistribution and use in source and binary forms, with or without
47  * modification, are permitted provided that the following conditions
48  * are met:
49  * 1. Redistributions of source code must retain the above copyright
50  *    notice, this list of conditions and the following disclaimer.
51  * 2. Redistributions in binary form must reproduce the above copyright
52  *    notice, this list of conditions and the following disclaimer in the
53  *    documentation and/or other materials provided with the distribution.
54  * 4. Neither the name of the University nor the names of its contributors
55  *    may be used to endorse or promote products derived from this software
56  *    without specific prior written permission.
57  *
58  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68  * SUCH DAMAGE.
69  *
70  *      @(#)boot.c      8.1 (Berkeley) 6/10/93
71  */
72
73 #include <sys/cdefs.h>
74 __FBSDID("$FreeBSD$");
75
76 #include <stand.h>
77 #include <string.h>
78
79 #include <sys/param.h>
80 #include <sys/linker.h>
81 #include <machine/elf.h>
82 #include <machine/prom.h>
83 #include <machine/rpb.h>
84 #include <machine/bootinfo.h>
85
86 #include "bootstrap.h"
87
88 #define _KERNEL
89
90 static int      elf64_exec(struct preloaded_file *amp);
91 int             bi_load(struct bootinfo_v1 *, vm_offset_t *,
92                         struct preloaded_file *);
93
94 struct file_format alpha_elf = { elf64_loadfile, elf64_exec };
95
96 vm_offset_t ffp_save, ptbr_save;
97
98 static int
99 elf64_exec(struct preloaded_file *fp)
100 {
101 #if 0
102     static struct bootinfo_v1   bootinfo_v1;
103     struct file_metadata        *md;
104     Elf_Ehdr                    *hdr;
105     int                         err;
106
107     if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
108         return(EFTYPE);                 /* XXX actually EFUCKUP */
109     hdr = (Elf_Ehdr *)&(md->md_data);
110
111     /* XXX ffp_save does not appear to be used in the kernel.. */
112     bzero(&bootinfo_v1, sizeof(bootinfo_v1));
113     err = bi_load(&bootinfo_v1, &ffp_save, fp);
114     if (err)
115         return(err);
116
117     /*
118      * Fill in the bootinfo for the kernel.
119      */
120     strncpy(bootinfo_v1.booted_kernel, fp->f_name,
121             sizeof(bootinfo_v1.booted_kernel));
122     prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo_v1.boot_flags,
123                 sizeof(bootinfo_v1.boot_flags));
124     bootinfo_v1.hwrpb = (void *)HWRPB_ADDR;
125     bootinfo_v1.hwrpbsize = ((struct rpb *)HWRPB_ADDR)->rpb_size;
126     bootinfo_v1.cngetc = NULL;
127     bootinfo_v1.cnputc = NULL;
128     bootinfo_v1.cnpollc = NULL;
129
130     printf("Entering %s at 0x%lx...\n", fp->f_name, hdr->e_entry);
131     exit(0);
132     closeall();
133     alpha_pal_imb();
134     (*(void (*)())hdr->e_entry)(ffp_save, ptbr_save,
135                                BOOTINFO_MAGIC, &bootinfo_v1, 1, 0);
136 #endif
137 }
138
139
140