Path: blob/master/arch/s390/kernel/relocate_kernel64.S
10819 views
/*1* arch/s390/kernel/relocate_kernel64.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*21* 0xf000 is a page_mask22*/2324.text25.globl relocate_kernel26relocate_kernel:27basr %r13,0 # base address28.base:29stnsm sys_msk-.base(%r13),0xfb # disable DAT30stctg %c0,%c15,ctlregs-.base(%r13)31stmg %r0,%r15,gprregs-.base(%r13)32lghi %r0,333sllg %r0,%r0,3134stg %r0,0x1d0(%r0)35la %r0,.back_pgm-.base(%r13)36stg %r0,0x1d8(%r0)37la %r1,load_psw-.base(%r13)38mvc 0(8,%r0),0(%r1)39la %r0,.back-.base(%r13)40st %r0,4(%r0)41oi 4(%r0),0x8042lghi %r0,043diag %r0,%r0,0x30844.back:45lhi %r1,1 # mode 1 = esame46sigp %r1,%r0,0x12 # switch to esame mode47sam64 # switch to 64 bit addressing mode48basr %r13,049.back_base:50oi have_diag308-.back_base(%r13),0x0151lctlg %c0,%c15,ctlregs-.back_base(%r13)52lmg %r0,%r15,gprregs-.back_base(%r13)53j .top54.back_pgm:55lmg %r0,%r15,gprregs-.base(%r13)56.top:57lghi %r7,4096 # load PAGE_SIZE in r758lghi %r9,4096 # load PAGE_SIZE in r959lg %r5,0(%r2) # read another word for indirection page60aghi %r2,8 # increment pointer61tml %r5,0x1 # is it a destination page?62je .indir_check # NO, goto "indir_check"63lgr %r6,%r5 # r6 = r564nill %r6,0xf000 # mask it out and...65j .top # ...next iteration66.indir_check:67tml %r5,0x2 # is it a indirection page?68je .done_test # NO, goto "done_test"69nill %r5,0xf000 # YES, mask out,70lgr %r2,%r5 # move it into the right register,71j .top # and read next...72.done_test:73tml %r5,0x4 # is it the done indicator?74je .source_test # NO! Well, then it should be the source indicator...75j .done # ok, lets finish it here...76.source_test:77tml %r5,0x8 # it should be a source indicator...78je .top # NO, ignore it...79lgr %r8,%r5 # r8 = r580nill %r8,0xf000 # masking810: mvcle %r6,%r8,0x0 # copy PAGE_SIZE bytes from r8 to r6 - pad with 082jo 0b83j .top84.done:85sgr %r0,%r0 # clear register r086la %r4,load_psw-.base(%r13) # load psw-address into the register87o %r3,4(%r4) # or load address into psw88st %r3,4(%r4)89mvc 0(8,%r0),0(%r4) # copy psw to absolute address 090tm have_diag308-.base(%r13),0x0191jno .no_diag30892diag %r0,%r0,0x30893.no_diag308:94sam31 # 31 bit mode95sr %r1,%r1 # erase register r196sr %r2,%r2 # erase register r297sigp %r1,%r2,0x12 # set cpuid to zero98lpsw 0 # hopefully start new kernel...99100.align 8101load_psw:102.long 0x00080000,0x80000000103sys_msk:104.quad 0105ctlregs:106.rept 16107.quad 0108.endr109gprregs:110.rept 16111.quad 0112.endr113have_diag308:114.byte 0115.align 8116relocate_kernel_end:117.globl relocate_kernel_len118relocate_kernel_len:119.quad relocate_kernel_end - relocate_kernel120121122