summaryrefslogtreecommitdiff
path: root/sys/arch/arc/stand/start.S
blob: 09114a91b7e7d8284cb6e1d2168571582bda054f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*	$NetBSD: start.S,v 1.1 1995/01/18 06:19:01 mellon Exp $	*/

/*
 * Copyright (c) 1992, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Ralph Campbell.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

/*
 * start.S -
 *
 *     Contains code that is the first executed at boot time.
 */

#include <machine/regdef.h>
#include <machine/cpu.h>
#include <machine/asm.h>

/*
 * Frame required for the debugger (if we have any)
 */
#define START_FRAME	((4 * 4) + 4 + 4)

	.globl	__start
__start:
	.set	noreorder
#ifdef __GP_SUPPORT__
	la      gp, _C_LABEL (_gp)
#endif
	la	sp, __start - START_FRAME		# Stack below program
	sw	zero, START_FRAME - 4(sp)	# Zero out old ra for debugger
	sw	zero, START_FRAME - 8(sp)	# Zero out old fp for debugger
	move	s0, a0				# save argc
	move	s1, a1				# save argv

	la	a0, _C_LABEL (edata)			# clear BSS
	la	a1, _C_LABEL (end)
	jal	_C_LABEL(bzero)			# bzero(edata, end - edata)
	subu	a1, a1, a0

	move	a0, s0				# restore argc
	jal	_C_LABEL(main)			# main(argc, argv)
	move	a1, s1				# restore argv

	j	_C_LABEL(Bios_Restart)		# restart...
	nop

/* dummy routine for gcc2 */
	.globl	_C_LABEL(__main)
_C_LABEL(__main):
	j	ra
	nop

#define Bios_Call(Name,Offset)	\
LEAF(Name);			\
	lw	v0,0x80001020;	\
	lw	v0,Offset(v0);	\
	jr	v0	;	\
	nop		;	\
	END(Name)

Bios_Call(Bios_Load,			0x00)
Bios_Call(Bios_Invoke,			0x04)
Bios_Call(Bios_Execute,			0x08)
Bios_Call(Bios_Halt,			0x0c)
Bios_Call(Bios_PowerDown,		0x10)
Bios_Call(Bios_Restart,			0x14)
Bios_Call(Bios_Reboot,			0x18)
Bios_Call(Bios_EnterInteractiveMode,	0x1c)
Bios_Call(Bios_Unused1,			0x20)
Bios_Call(Bios_GetPeer,			0x24)
Bios_Call(Bios_GetChild,		0x28)
Bios_Call(Bios_GetParent,		0x2c)
Bios_Call(Bios_GetConfigurationData,	0x30)
Bios_Call(Bios_AddChild,		0x34)
Bios_Call(Bios_DeleteComponent,		0x38)
Bios_Call(Bios_GetComponent,		0x3c)
Bios_Call(Bios_SaveConfiguration,	0x40)
Bios_Call(Bios_GetSystemId,		0x44)
Bios_Call(Bios_GetMemoryDescriptor,	0x48)
Bios_Call(Bios_Unused2,			0x4c)
Bios_Call(Bios_GetTime,			0x50)
Bios_Call(Bios_GetRelativeTime,		0x54)
Bios_Call(Bios_GetDirectoryEntry,	0x58)
Bios_Call(Bios_Open,			0x5c)
Bios_Call(Bios_Close,			0x60)
Bios_Call(Bios_Read,			0x64)
Bios_Call(Bios_GetReadStatus,		0x68)
Bios_Call(Bios_Write,			0x6c)
Bios_Call(Bios_Seek,			0x70)
Bios_Call(Bios_Mount,			0x74)
Bios_Call(Bios_GetEnvironmentVariable,	0x78)
Bios_Call(Bios_SetEnvironmentVariable,	0x7c)
Bios_Call(Bios_GetFileInformation,	0x80)
Bios_Call(Bios_SetFileInformation,	0x84)
Bios_Call(Bios_FlushAllCaches,		0x88)
Bios_Call(Bios_TestUnicodeCharacter,	0x8c)
Bios_Call(Bios_GetDisplayStatus,	0x90)