Annotation of sys/arch/armish/stand/boot/exec.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: exec.c,v 1.3 2006/07/30 21:38:12 drahn Exp $ */
2:
3: /*
4: * Copyright (c) 2006 Mark Kettenis
5: *
6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: */
18:
19: #include <sys/param.h>
20:
21: #include <lib/libsa/loadfile.h>
22:
23: #ifdef BOOT_ELF
24: #include <sys/exec_elf.h>
25: #endif
26:
27: #include <sys/reboot.h>
28: #include <stand/boot/cmd.h>
29: #include <machine/bootconfig.h>
30:
31: typedef void (*startfuncp)(void) __attribute__ ((noreturn));
32:
33: void
34: run_loadfile(u_long *marks, int howto)
35: {
36: #ifdef BOOT_ELF
37: Elf_Ehdr *elf = (Elf_Ehdr *)marks[MARK_SYM];
38: Elf_Shdr *shp = (Elf_Shdr *)(marks[MARK_SYM] + elf->e_shoff);
39: u_long esym = marks[MARK_END];
40: char *cp;
41: int i;
42:
43: /*
44: * Tell locore.S where the symbol table ends by setting
45: * 'esym', which should be the first word in the .data
46: * section.
47: */
48: for (i = 0; i < elf->e_shnum; i++) {
49: /* XXX Assume .data is the first writable segment. */
50: if (shp[i].sh_flags & SHF_WRITE) {
51: /* XXX We have to store the virtual address. */
52: esym |= shp[i].sh_addr & 0xff000000;
53: *(u_long *)(shp[i].sh_addr & 0x00ffffff) = esym;
54: break;
55: }
56: }
57: #endif
58: cp = (char *)0x00200000 - MAX_BOOT_STRING - 1;
59:
60: #define BOOT_STRING_MAGIC 0x4f425344
61:
62: *(int *)cp = BOOT_STRING_MAGIC;
63:
64: cp += sizeof(int);
65: snprintf(cp, MAX_BOOT_STRING, "%s:%s -", cmd.bootdev, cmd.image);
66:
67: while (*cp != '\0')
68: cp++;
69: if (howto & RB_ASKNAME)
70: *cp++ = 'a';
71: if (howto & RB_CONFIG)
72: *cp++ = 'c';
73: if (howto & RB_KDB)
74: *cp++ = 'd';
75: if (howto & RB_SINGLE)
76: *cp++ = 's';
77:
78: *cp = '\0';
79:
80: (*(startfuncp)(marks[MARK_ENTRY]))();
81:
82: /* NOTREACHED */
83: }
CVSweb