start.S revision 1.14 1 1.14 christos /* $NetBSD: start.S,v 1.14 2005/12/11 12:16:20 christos Exp $ */
2 1.12 cgd
3 1.12 cgd /*
4 1.12 cgd * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
5 1.12 cgd *
6 1.12 cgd * Redistribution and use in source and binary forms, with or without
7 1.12 cgd * modification, are permitted provided that the following conditions
8 1.12 cgd * are met:
9 1.12 cgd * 1. Redistributions of source code must retain the above copyright
10 1.12 cgd * notice, this list of conditions and the following disclaimer.
11 1.12 cgd * 2. Redistributions in binary form must reproduce the above copyright
12 1.12 cgd * notice, this list of conditions and the following disclaimer in the
13 1.12 cgd * documentation and/or other materials provided with the distribution.
14 1.12 cgd * 3. All advertising materials mentioning features or use of this software
15 1.12 cgd * must display the following acknowledgement:
16 1.12 cgd * This product includes software developed by Christopher G. Demetriou
17 1.12 cgd * for the NetBSD Project.
18 1.12 cgd * 4. The name of the author may not be used to endorse or promote products
19 1.12 cgd * derived from this software without specific prior written permission
20 1.12 cgd *
21 1.12 cgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.12 cgd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.12 cgd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.12 cgd * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.12 cgd * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.12 cgd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.12 cgd * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.12 cgd * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.12 cgd * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.12 cgd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.12 cgd */
32 1.1 cgd
33 1.1 cgd /*
34 1.1 cgd * Mach Operating System
35 1.1 cgd * Copyright (c) 1992 Carnegie Mellon University
36 1.1 cgd * All Rights Reserved.
37 1.1 cgd *
38 1.1 cgd * Permission to use, copy, modify and distribute this software and its
39 1.1 cgd * documentation is hereby granted, provided that both the copyright
40 1.1 cgd * notice and this permission notice appear in all copies of the
41 1.1 cgd * software, derivative works or modified versions, and any portions
42 1.1 cgd * thereof, and that both notices appear in supporting documentation.
43 1.1 cgd *
44 1.1 cgd * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45 1.1 cgd * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
46 1.1 cgd * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
47 1.1 cgd *
48 1.1 cgd * Carnegie Mellon requests users of this software to return to
49 1.1 cgd *
50 1.1 cgd * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
51 1.1 cgd * School of Computer Science
52 1.1 cgd * Carnegie Mellon University
53 1.1 cgd * Pittsburgh PA 15213-3890
54 1.1 cgd *
55 1.1 cgd * any improvements or extensions that they make and grant Carnegie Mellon
56 1.1 cgd * the rights to redistribute these changes.
57 1.1 cgd */
58 1.1 cgd
59 1.1 cgd #include "include/asm.h"
60 1.1 cgd
61 1.1 cgd /*
62 1.1 cgd * start --
63 1.1 cgd * Entry point for boot/standalone programs.
64 1.1 cgd *
65 1.12 cgd * Unified and Primary Bootstrap arguments:
66 1.12 cgd * None.
67 1.12 cgd *
68 1.12 cgd * Secondary Bootstrap arguments:
69 1.12 cgd * a0 first free physical page
70 1.12 cgd *
71 1.12 cgd * Standalone program arguments:
72 1.1 cgd *
73 1.12 cgd * a0 first free physical page
74 1.12 cgd * a1 page table base register (PTBR)
75 1.12 cgd * a2 bootinfo magic number
76 1.12 cgd * a3 pointer to the bootinfo structure
77 1.12 cgd * a4 bootinfo version number
78 1.12 cgd *
79 1.12 cgd * All bootstrap and standalone programs leave exception and interrupt
80 1.12 cgd * handling to the firmware, and run from the firmware-provided stack.
81 1.12 cgd * To return to the firmware, these programs simply invoke the 'halt'
82 1.12 cgd * PALcode operation.
83 1.12 cgd *
84 1.12 cgd * Bootstrap programs have to clear their own BSS. Standalone programs
85 1.12 cgd * have their BSS cleared by the bootstraps.
86 1.1 cgd */
87 1.1 cgd .text
88 1.1 cgd .set noreorder /* don't reorder instructions */
89 1.1 cgd
90 1.1 cgd #define ENTRY_FRAME 32
91 1.1 cgd
92 1.1 cgd NESTED(start, 1, ENTRY_FRAME, ra, 0, 0)
93 1.1 cgd br pv,Lstartgp
94 1.1 cgd Lstartgp:
95 1.1 cgd LDGP(pv)
96 1.1 cgd
97 1.12 cgd #if defined(STANDALONE_PROGRAM)
98 1.12 cgd
99 1.12 cgd /*
100 1.12 cgd * save the arguments, invoke init_prom_calls() to set up console
101 1.12 cgd * callbacks and output, then restore the arguments.
102 1.12 cgd */
103 1.12 cgd mov a0, s0
104 1.12 cgd mov a1, s1
105 1.12 cgd mov a2, s2
106 1.12 cgd mov a3, s3
107 1.12 cgd mov a4, s4
108 1.12 cgd CALL(init_prom_calls)
109 1.12 cgd mov s0, a0
110 1.12 cgd mov s1, a1
111 1.12 cgd mov s2, a2
112 1.12 cgd mov s3, a3
113 1.12 cgd mov s4, a4
114 1.12 cgd
115 1.12 cgd #else /* defined(STANDALONE_PROGRAM) */
116 1.12 cgd
117 1.11 cgd #if !defined(PRIMARY_BOOTBLOCK) && !defined(UNIFIED_BOOTBLOCK)
118 1.1 cgd lda sp,start /* start stack below text */
119 1.1 cgd lda sp,-ENTRY_FRAME(sp)
120 1.1 cgd
121 1.5 ross or a0,zero,s0
122 1.11 cgd #endif /* !defined(PRIMARY_BOOTBLOCK) && !defined(UNIFIED_BOOTBLOCK) */
123 1.1 cgd lda a0,_edata
124 1.13 dsl xor a1,a1,a1
125 1.13 dsl lda a2,_end
126 1.13 dsl subq a2,a0,a2
127 1.13 dsl CALL(memset)
128 1.11 cgd #if !defined(PRIMARY_BOOTBLOCK) && !defined(UNIFIED_BOOTBLOCK)
129 1.5 ross or s0,zero,a0
130 1.11 cgd #endif /* !defined(PRIMARY_BOOTBLOCK) && !defined(UNIFIED_BOOTBLOCK) */
131 1.12 cgd
132 1.12 cgd #endif /* defined(STANDALONE_PROGRAM) */
133 1.5 ross
134 1.9 cgd CALL(main) /* transfer to C */
135 1.1 cgd
136 1.1 cgd XLEAF(_rtt, 0)
137 1.1 cgd XLEAF(halt, 0)
138 1.1 cgd call_pal PAL_halt /* halt if we ever return */
139 1.1 cgd END(start)
140