Path: blob/master/arch/s390/kernel/relocate_kernel.S
10817 views
/*1* arch/s390/kernel/relocate_kernel.S2*3* (C) Copyright IBM Corp. 20054*5* Author(s): Rolf Adelsberger,6* Heiko Carstens <[email protected]>7*8*/910/*11* moves the new kernel to its destination...12* %r2 = pointer to first kimage_entry_t13* %r3 = start address - where to jump to after the job is done...14*15* %r5 will be used as temp. storage16* %r6 holds the destination address17* %r7 = PAGE_SIZE18* %r8 holds the source address19* %r9 = PAGE_SIZE20* %r10 is a page mask21*/2223.text24.globl relocate_kernel25relocate_kernel:26basr %r13,0 # base address27.base:28stnsm sys_msk-.base(%r13),0xfb # disable DAT29stctl %c0,%c15,ctlregs-.base(%r13)30stm %r0,%r15,gprregs-.base(%r13)31la %r1,load_psw-.base(%r13)32mvc 0(8,%r0),0(%r1)33la %r0,.back-.base(%r13)34st %r0,4(%r0)35oi 4(%r0),0x8036mvc 0x68(8,%r0),0(%r1)37la %r0,.back_pgm-.base(%r13)38st %r0,0x6c(%r0)39oi 0x6c(%r0),0x8040lhi %r0,041diag %r0,%r0,0x30842.back:43basr %r13,044.back_base:45oi have_diag308-.back_base(%r13),0x0146lctl %c0,%c15,ctlregs-.back_base(%r13)47lm %r0,%r15,gprregs-.back_base(%r13)48j .start_reloc49.back_pgm:50lm %r0,%r15,gprregs-.base(%r13)51.start_reloc:52lhi %r10,-1 # preparing the mask53sll %r10,12 # shift it such that it becomes 0xf00054.top:55lhi %r7,4096 # load PAGE_SIZE in r756lhi %r9,4096 # load PAGE_SIZE in r957l %r5,0(%r2) # read another word for indirection page58ahi %r2,4 # increment pointer59tml %r5,0x1 # is it a destination page?60je .indir_check # NO, goto "indir_check"61lr %r6,%r5 # r6 = r562nr %r6,%r10 # mask it out and...63j .top # ...next iteration64.indir_check:65tml %r5,0x2 # is it a indirection page?66je .done_test # NO, goto "done_test"67nr %r5,%r10 # YES, mask out,68lr %r2,%r5 # move it into the right register,69j .top # and read next...70.done_test:71tml %r5,0x4 # is it the done indicator?72je .source_test # NO! Well, then it should be the source indicator...73j .done # ok, lets finish it here...74.source_test:75tml %r5,0x8 # it should be a source indicator...76je .top # NO, ignore it...77lr %r8,%r5 # r8 = r578nr %r8,%r10 # masking790: mvcle %r6,%r8,0x0 # copy PAGE_SIZE bytes from r8 to r6 - pad with 080jo 0b81j .top82.done:83sr %r0,%r0 # clear register r084la %r4,load_psw-.base(%r13) # load psw-address into the register85o %r3,4(%r4) # or load address into psw86st %r3,4(%r4)87mvc 0(8,%r0),0(%r4) # copy psw to absolute address 088tm have_diag308-.base(%r13),0x0189jno .no_diag30890diag %r0,%r0,0x30891.no_diag308:92sr %r1,%r1 # clear %r193sr %r2,%r2 # clear %r294sigp %r1,%r2,0x12 # set cpuid to zero95lpsw 0 # hopefully start new kernel...9697.align 898load_psw:99.long 0x00080000,0x80000000100sys_msk:101.quad 0102ctlregs:103.rept 16104.long 0105.endr106gprregs:107.rept 16108.long 0109.endr110have_diag308:111.byte 0112.align 8113relocate_kernel_end:114.globl relocate_kernel_len115relocate_kernel_len:116.quad relocate_kernel_end - relocate_kernel117118119