1 /* $NetBSD: exec_image.S,v 1.1 2001/09/27 10:14:50 minoura Exp $ */
4 * Copyright (c) 2001 Minoura Makoto.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <machine/asm.h>
31 #define LASTADDR (0x00ed0008)
37 ENTRY_NOPROFILE(exec_image)
38 || void exec_image(loaded,executed,entry,size,bootdev,boothowto)
39 || unsigned int loaded;
40 || unsigned int executed;
41 || unsigned int entry;
45 addl #4,%sp | throw away the return address
49 /* copy the trampoline to the last physical page. */
50 moval LASTADDR,%sp | tmpstack from end of physmem
51 lea %sp@(-4096),%a3 | use last phys page as tramp
53 movl #(end_trampoline-trampoline),%sp@-
56 jbsr _C_LABEL(memcpy) | memcpy() is still alive
59 jmp %a3@ | jump to tramp
61 ASENTRY_NOPROFILE(trampoline)
68 movl %d5,%sp@- | push last arg (esym)
69 movel LASTADDR,%sp@- | second arg (physsize)
70 pea %a5@ | first arg (firstpa)
72 cmpl %a4,%a5 | if (l == x)
73 beq L1 | copy not required
75 /* this may overwrite the trap vectors; disable interrupt. */
78 L0: movb %a4@+,%a5@+ | copy kern to x
83 movq #0,%d0 | reg arg (unused)
84 movq #0,%d1 | reg arg (unused)
85 movq #0,%d2 | reg arg (unused)
86 movq #0,%d3 | reg arg (unused)
87 movq #0,%d4 | reg arg (unused)
88 movq #0,%d5 | reg arg (unused)
89 | bootdev(%d6) is already set
90 | boothowto(%d7) is already set
92 moval %d0,%a1 | reg arg (unused)
93 moval %d0,%a2 | reg arg (unused)
94 moval %d0,%a3 | reg arg (unused)
95 moval %d0,%a4 | reg arg (unused)
96 moval %d0,%a5 | reg arg (unused)
97 moval %d0,%a6 | reg arg (unused)
98 movec %a1,%vbr | clear vbr
100 jsr %a0@ | here we go!