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