Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / boot / alpha / libalpha / start.S
1 /* 
2  * $FreeBSD: src/sys/boot/alpha/libalpha/start.S,v 1.6.2.2 2001/03/04 05:23:01 obrien Exp $ 
3  * From: $NetBSD: start.S,v 1.4 1998/03/28 00:54:15 cgd Exp $ 
4  */
5
6 /*  
7  * Mach Operating System
8  * Copyright (c) 1992 Carnegie Mellon University
9  * All Rights Reserved.
10  * 
11  * Permission to use, copy, modify and distribute this software and its
12  * documentation is hereby granted, provided that both the copyright
13  * notice and this permission notice appear in all copies of the
14  * software, derivative works or modified versions, and any portions
15  * thereof, and that both notices appear in supporting documentation.
16  * 
17  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
18  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
19  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
20  * 
21  * Carnegie Mellon requests users of this software to return to
22  * 
23  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
24  *  School of Computer Science
25  *  Carnegie Mellon University
26  *  Pittsburgh PA 15213-3890
27  * 
28  * any improvements or extensions that they make and grant Carnegie Mellon
29  * the rights to redistribute these changes.
30  */
31
32 #include <machine/asm.h>
33
34 /*
35  * start --
36  *      Entry point for boot/standalone programs.
37  *
38  * Arguments:
39  *      a0                              long (first free physical page)
40  *
41  * This is where the prom comes to.  Leaves all exception and interrupts
42  * to prom, runs off prom's stack too.  No return values.
43  */
44         .text
45         .set    noreorder               /* don't reorder instructions */
46
47 #define ENTRY_FRAME     32
48 #define STACK_SIZE      12288
49
50 NESTED(start, 1, ENTRY_FRAME, ra, 0, 0)
51         br      pv,Lstartgp
52 Lstartgp:
53         LDGP(pv)
54
55 #ifndef BOOT1
56         CALL(extend_heap)
57 #endif
58
59         lda     a0,_edata
60         lda     a1,_end
61         subq    a1,a0,a1
62         CALL(bzero)
63
64 #ifndef BOOT1
65         lda     sp,stackbase + STACK_SIZE - ENTRY_FRAME
66 #endif
67
68         CALL(main)                      /* transfer to C */
69
70 XLEAF(_rtt, 0)
71 XLEAF(halt, 0)
72         call_pal PAL_halt               /* halt if we ever return */
73 END(start)
74
75 /*
76  * Dummy routine for GCC2.
77  */
78 LEAF(__main,0)
79         RET
80 END(__main)
81
82 /*
83  * cpu_number
84  *      Return the cpu number, using the whami instruction.
85  */
86 LEAF(cpu_number, 0)
87         call_pal PAL_VMS_mfpr_whami
88         RET
89 END(cpu_number)
90
91 #ifndef BOOT1
92 BSS(stackbase, STACK_SIZE)
93 #endif