#
#  Third stage boot loader
#    Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
#    Author(s):	Heiko Carstens (heiko.carstens@de.ibm.com)
#

# some definitions from kernel land
__LC_IPLDEV  = 0xC6C
IPL_DEVICE   = 0x10404
INITRD_START = 0x10408
INITRD_SIZE  = 0x10410
COMMAND_LINE = 0x10480

_parm_addr:				#
	.quad  0			# address of parmline
_initrd_addr:				#
	.quad  0			# address of initrd
_initrd_len:				#
	.quad  0			# length of initrd
_load_psw:				#
	.quad  0			# load psw of kernel

#
# Program execution of the third stage boot loader starts at 0x4020
#
        .globl _start
_start: basr   %r13,0                   # base register
0:	l      %r2,0xb8			# subchannel id of ipl device
	st     %r2,__LC_IPLDEV          # old ipl device storage location
	l      %r3,1f-0b(%r13)          # load address of IPL_DEVICE
	st     %r2,0(%r3)               # new ipl device storage location

	l      %r1,2f-0b(%r13)		# load address of parmfile parameter
	l      %r1,4(%r1)		# load address of parmfile
	l      %r2,3f-0b(%r13)          # load address of kernel command line
	mvc    0x0(256,%r2),0(%r1)      # move command line to 0x10480
	mvc    0x100(256,%r2),0x100(%r1)
	mvc    0x200(256,%r2),0x200(%r1)
	mvc    0x300(127,%r2),0x300(%r1)
	xc     0x37f(1,%r2),0x37f(%r2)

	l      %r1,4f-0b(%r13)		# load address of initrd parameter
	l      %r2,5f-0b(%r13)		# load address of INITRD_START
	mvc    0(8,%r2),0(%r1)		# copy INITRD_START address

	l      %r1,6f-0b(%r13)		# load address of initrd length parmeter
	l      %r2,7f-0b(%r13)		# load address of INITRD_SIZE
	mvc    0(8,%r2),0(%r1)		# copy INITRD_SIZE length

	l      %r1,8f-0b(%r13)
	lpsw   0(%r1)			# start kernel
	
1:	.long  IPL_DEVICE
2:	.long  _parm_addr
3:	.long  COMMAND_LINE
4:	.long  _initrd_addr
5:	.long  INITRD_START
6:	.long  _initrd_len
7:	.long  INITRD_SIZE
8:	.long  _load_psw
