start.S revision 302408
1217044Snwhitehorn/*- 2217044Snwhitehorn * Copyright (c) 2013-2014 Robert N. M. Watson 3217044Snwhitehorn * All rights reserved. 4217044Snwhitehorn * 5217044Snwhitehorn * This software was developed by SRI International and the University of 6217044Snwhitehorn * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 7217044Snwhitehorn * ("CTSRD"), as part of the DARPA CRASH research programme. 8217044Snwhitehorn * 9217044Snwhitehorn * Redistribution and use in source and binary forms, with or without 10217044Snwhitehorn * modification, are permitted provided that the following conditions 11217044Snwhitehorn * are met: 12217044Snwhitehorn * 1. Redistributions of source code must retain the above copyright 13217044Snwhitehorn * notice, this list of conditions and the following disclaimer. 14217044Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright 15217044Snwhitehorn * notice, this list of conditions and the following disclaimer in the 16217044Snwhitehorn * documentation and/or other materials provided with the distribution. 17217044Snwhitehorn * 18217044Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19217044Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20217044Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21217044Snwhitehorn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22217044Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23217044Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24217044Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25217044Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26217044Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27217044Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28217044Snwhitehorn * SUCH DAMAGE. 29217044Snwhitehorn * 30217044Snwhitehorn * $FreeBSD: stable/11/sys/boot/mips/beri/boot2/start.S 262197 2014-02-18 23:18:32Z rwatson $ 31217044Snwhitehorn */ 32217044Snwhitehorn 33217044Snwhitehorn.set mips64 34217044Snwhitehorn.set noreorder 35217044Snwhitehorn.set nobopt 36217044Snwhitehorn.set noat 37217044Snwhitehorn 38217044Snwhitehorn/* 39217044Snwhitehorn * Save arguments from the BERI firmware for use in C-land, and jump into 40217044Snwhitehorn * main. Assume that registers/stack/etc are sufficiently initialised to get 41217044Snwhitehorn * going. Notice that we use only temporaries while relocating, as we want to 42217044Snwhitehorn * retain argument registers to pass in to main(). 43217044Snwhitehorn * 44217044Snwhitehorn * Note slightly surprising structure: boot2 is linked for a specific address, 45217044Snwhitehorn * but we may start running the code somewhere else (e.g., in DRAM as inserted 46217044Snwhitehorn * with JTAG, or in flash). The starting assembly is therefore PIC, but the 47217044Snwhitehorn * main body of the code is not PIC. 48217044Snwhitehorn */ 49217044Snwhitehorn 50217044Snwhitehorn 51217044Snwhitehorn .text 52217044Snwhitehorn .global start 53217044Snwhitehorn .ent start 54217044Snwhitehornstart: 55217044Snwhitehorn 56217044Snwhitehorn /* 57217044Snwhitehorn * Zero BSS. Run from cached memory as this will speed up 58217044Snwhitehorn * code execution noticeably. Assuming 64-bit alignment of 59217044Snwhitehorn * everything here. 60217044Snwhitehorn */ 61217044Snwhitehorn dla $t0, __bss_start 62217044Snwhitehorn dla $t1, __bss_end 63217044Snwhitehorn 64217044Snwhitehornbss_loop: 65217044Snwhitehorn beq $t0, $t1, bss_done 66217044Snwhitehorn nop 67217044Snwhitehorn sd $zero, 0($t0) 68217044Snwhitehorn daddiu $t0, 8 69217044Snwhitehorn b bss_loop 70217044Snwhitehorn nop 71217044Snwhitehorn 72217044Snwhitehornbss_done: 73217044Snwhitehorn jal main 74217044Snwhitehorn nop 75217044Snwhitehorn 76217044Snwhitehorn /* 77217044Snwhitehorn * Ideally we wouldn't get here, but just in case. 78217044Snwhitehorn */ 79217044Snwhitehornloop: 80217044Snwhitehorn b loop 81217044Snwhitehorn nop 82217044Snwhitehorn .end start 83217044Snwhitehorn