📄 head.s
字号:
/* * Here is where the ball gets rolling as far as the kernel is concerned. * When control is transferred to _start, the bootload has already * loaded us to the correct address. All that's left to do here is * to set up the kernel's global pointer and jump to the kernel * entry point. * * Copyright (C) 1998-2001, 2003, 2005 Hewlett-Packard Co * David Mosberger-Tang <davidm@hpl.hp.com> * Stephane Eranian <eranian@hpl.hp.com> * Copyright (C) 1999 VA Linux Systems * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> * Copyright (C) 1999 Intel Corp. * Copyright (C) 1999 Asit Mallick <Asit.K.Mallick@intel.com> * Copyright (C) 1999 Don Dugger <Don.Dugger@intel.com> * Copyright (C) 2002 Fenghua Yu <fenghua.yu@intel.com> * -Optimize __ia64_save_fpu() and __ia64_load_fpu() for Itanium 2. * Copyright (C) 2004 Ashok Raj <ashok.raj@intel.com> * Support for CPU Hotplug */#include <linux/config.h>#include <asm/asmmacro.h>#include <asm/fpu.h>#include <asm/kregs.h>#include <asm/mmu_context.h>#include <asm/asm-offsets.h>#include <asm/pal.h>#include <asm/pgtable.h>#include <asm/processor.h>#include <asm/ptrace.h>#include <asm/system.h>#include <asm/mca_asm.h>#ifdef CONFIG_HOTPLUG_CPU#define SAL_PSR_BITS_TO_SET \ (IA64_PSR_AC | IA64_PSR_BN | IA64_PSR_MFH | IA64_PSR_MFL)#define SAVE_FROM_REG(src, ptr, dest) \ mov dest=src;; \ st8 [ptr]=dest,0x08#define RESTORE_REG(reg, ptr, _tmp) \ ld8 _tmp=[ptr],0x08;; \ mov reg=_tmp#define SAVE_BREAK_REGS(ptr, _idx, _breg, _dest)\ mov ar.lc=IA64_NUM_DBG_REGS-1;; \ mov _idx=0;; \1: \ SAVE_FROM_REG(_breg[_idx], ptr, _dest);; \ add _idx=1,_idx;; \ br.cloop.sptk.many 1b#define RESTORE_BREAK_REGS(ptr, _idx, _breg, _tmp, _lbl)\ mov ar.lc=IA64_NUM_DBG_REGS-1;; \ mov _idx=0;; \_lbl: RESTORE_REG(_breg[_idx], ptr, _tmp);; \ add _idx=1, _idx;; \ br.cloop.sptk.many _lbl#define SAVE_ONE_RR(num, _reg, _tmp) \ movl _tmp=(num<<61);; \ mov _reg=rr[_tmp]#define SAVE_REGION_REGS(_tmp, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7) \ SAVE_ONE_RR(0,_r0, _tmp);; \ SAVE_ONE_RR(1,_r1, _tmp);; \ SAVE_ONE_RR(2,_r2, _tmp);; \ SAVE_ONE_RR(3,_r3, _tmp);; \ SAVE_ONE_RR(4,_r4, _tmp);; \ SAVE_ONE_RR(5,_r5, _tmp);; \ SAVE_ONE_RR(6,_r6, _tmp);; \ SAVE_ONE_RR(7,_r7, _tmp);;#define STORE_REGION_REGS(ptr, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7) \ st8 [ptr]=_r0, 8;; \ st8 [ptr]=_r1, 8;; \ st8 [ptr]=_r2, 8;; \ st8 [ptr]=_r3, 8;; \ st8 [ptr]=_r4, 8;; \ st8 [ptr]=_r5, 8;; \ st8 [ptr]=_r6, 8;; \ st8 [ptr]=_r7, 8;;#define RESTORE_REGION_REGS(ptr, _idx1, _idx2, _tmp) \ mov ar.lc=0x08-1;; \ movl _idx1=0x00;; \RestRR: \ dep.z _idx2=_idx1,61,3;; \ ld8 _tmp=[ptr],8;; \ mov rr[_idx2]=_tmp;; \ srlz.d;; \ add _idx1=1,_idx1;; \ br.cloop.sptk.few RestRR#define SET_AREA_FOR_BOOTING_CPU(reg1, reg2) \ movl reg1=sal_state_for_booting_cpu;; \ ld8 reg2=[reg1];;/* * Adjust region registers saved before starting to save * break regs and rest of the states that need to be preserved. */#define SAL_TO_OS_BOOT_HANDOFF_STATE_SAVE(_reg1,_reg2,_pred) \ SAVE_FROM_REG(b0,_reg1,_reg2);; \ SAVE_FROM_REG(b1,_reg1,_reg2);; \ SAVE_FROM_REG(b2,_reg1,_reg2);; \ SAVE_FROM_REG(b3,_reg1,_reg2);; \ SAVE_FROM_REG(b4,_reg1,_reg2);; \ SAVE_FROM_REG(b5,_reg1,_reg2);; \ st8 [_reg1]=r1,0x08;; \ st8 [_reg1]=r12,0x08;; \ st8 [_reg1]=r13,0x08;; \ SAVE_FROM_REG(ar.fpsr,_reg1,_reg2);; \ SAVE_FROM_REG(ar.pfs,_reg1,_reg2);; \ SAVE_FROM_REG(ar.rnat,_reg1,_reg2);; \ SAVE_FROM_REG(ar.unat,_reg1,_reg2);; \ SAVE_FROM_REG(ar.bspstore,_reg1,_reg2);; \ SAVE_FROM_REG(cr.dcr,_reg1,_reg2);; \ SAVE_FROM_REG(cr.iva,_reg1,_reg2);; \ SAVE_FROM_REG(cr.pta,_reg1,_reg2);; \ SAVE_FROM_REG(cr.itv,_reg1,_reg2);; \ SAVE_FROM_REG(cr.pmv,_reg1,_reg2);; \ SAVE_FROM_REG(cr.cmcv,_reg1,_reg2);; \ SAVE_FROM_REG(cr.lrr0,_reg1,_reg2);; \ SAVE_FROM_REG(cr.lrr1,_reg1,_reg2);; \ st8 [_reg1]=r4,0x08;; \ st8 [_reg1]=r5,0x08;; \ st8 [_reg1]=r6,0x08;; \ st8 [_reg1]=r7,0x08;; \ st8 [_reg1]=_pred,0x08;; \ SAVE_FROM_REG(ar.lc, _reg1, _reg2);; \ stf.spill.nta [_reg1]=f2,16;; \ stf.spill.nta [_reg1]=f3,16;; \ stf.spill.nta [_reg1]=f4,16;; \ stf.spill.nta [_reg1]=f5,16;; \ stf.spill.nta [_reg1]=f16,16;; \ stf.spill.nta [_reg1]=f17,16;; \ stf.spill.nta [_reg1]=f18,16;; \ stf.spill.nta [_reg1]=f19,16;; \ stf.spill.nta [_reg1]=f20,16;; \ stf.spill.nta [_reg1]=f21,16;; \ stf.spill.nta [_reg1]=f22,16;; \ stf.spill.nta [_reg1]=f23,16;; \ stf.spill.nta [_reg1]=f24,16;; \ stf.spill.nta [_reg1]=f25,16;; \ stf.spill.nta [_reg1]=f26,16;; \ stf.spill.nta [_reg1]=f27,16;; \ stf.spill.nta [_reg1]=f28,16;; \ stf.spill.nta [_reg1]=f29,16;; \ stf.spill.nta [_reg1]=f30,16;; \ stf.spill.nta [_reg1]=f31,16;;#else#define SET_AREA_FOR_BOOTING_CPU(a1, a2)#define SAL_TO_OS_BOOT_HANDOFF_STATE_SAVE(a1,a2, a3)#define SAVE_REGION_REGS(_tmp, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7)#define STORE_REGION_REGS(ptr, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7)#endif#define SET_ONE_RR(num, pgsize, _tmp1, _tmp2, vhpt) \ movl _tmp1=(num << 61);; \ mov _tmp2=((ia64_rid(IA64_REGION_ID_KERNEL, (num<<61)) << 8) | (pgsize << 2) | vhpt);; \ mov rr[_tmp1]=_tmp2 .section __special_page_section,"ax" .global empty_zero_pageempty_zero_page: .skip PAGE_SIZE .global swapper_pg_dirswapper_pg_dir: .skip PAGE_SIZE .rodatahalt_msg: stringz "Halting kernel\n" .text .global start_ap /* * Start the kernel. When the bootloader passes control to _start(), r28 * points to the address of the boot parameter area. Execution reaches * here in physical mode. */GLOBAL_ENTRY(_start)start_ap: .prologue .save rp, r0 // terminate unwind chain with a NULL rp .body rsm psr.i | psr.ic ;; srlz.i ;; /* * Save the region registers, predicate before they get clobbered */ SAVE_REGION_REGS(r2, r8,r9,r10,r11,r12,r13,r14,r15); mov r25=pr;; /* * Initialize kernel region registers: * rr[0]: VHPT enabled, page size = PAGE_SHIFT * rr[1]: VHPT enabled, page size = PAGE_SHIFT * rr[2]: VHPT enabled, page size = PAGE_SHIFT * rr[3]: VHPT enabled, page size = PAGE_SHIFT * rr[4]: VHPT enabled, page size = PAGE_SHIFT * rr[5]: VHPT enabled, page size = PAGE_SHIFT * rr[6]: VHPT disabled, page size = IA64_GRANULE_SHIFT * rr[7]: VHPT disabled, page size = IA64_GRANULE_SHIFT * We initialize all of them to prevent inadvertently assuming * something about the state of address translation early in boot. */ SET_ONE_RR(0, PAGE_SHIFT, r2, r16, 1);; SET_ONE_RR(1, PAGE_SHIFT, r2, r16, 1);; SET_ONE_RR(2, PAGE_SHIFT, r2, r16, 1);; SET_ONE_RR(3, PAGE_SHIFT, r2, r16, 1);; SET_ONE_RR(4, PAGE_SHIFT, r2, r16, 1);; SET_ONE_RR(5, PAGE_SHIFT, r2, r16, 1);; SET_ONE_RR(6, IA64_GRANULE_SHIFT, r2, r16, 0);; SET_ONE_RR(7, IA64_GRANULE_SHIFT, r2, r16, 0);; /* * Now pin mappings into the TLB for kernel text and data */ mov r18=KERNEL_TR_PAGE_SHIFT<<2 movl r17=KERNEL_START ;; mov cr.itir=r18 mov cr.ifa=r17 mov r16=IA64_TR_KERNEL mov r3=ip movl r18=PAGE_KERNEL ;; dep r2=0,r3,0,KERNEL_TR_PAGE_SHIFT ;; or r18=r2,r18 ;; srlz.i ;; itr.i itr[r16]=r18 ;; itr.d dtr[r16]=r18 ;; srlz.i /* * Switch into virtual mode: */ movl r16=(IA64_PSR_IT|IA64_PSR_IC|IA64_PSR_DT|IA64_PSR_RT|IA64_PSR_DFH|IA64_PSR_BN \ |IA64_PSR_DI) ;; mov cr.ipsr=r16 movl r17=1f ;; mov cr.iip=r17 mov cr.ifs=r0 ;; rfi ;;1: // now we are in virtual mode SET_AREA_FOR_BOOTING_CPU(r2, r16); STORE_REGION_REGS(r16, r8,r9,r10,r11,r12,r13,r14,r15); SAL_TO_OS_BOOT_HANDOFF_STATE_SAVE(r16,r17,r25) ;; // set IVT entry point---can't access I/O ports without it movl r3=ia64_ivt ;; mov cr.iva=r3 movl r2=FPSR_DEFAULT ;; srlz.i movl gp=__gp mov ar.fpsr=r2 ;;#define isAP p2 // are we an Application Processor?#define isBP p3 // are we the Bootstrap Processor?#ifdef CONFIG_SMP /* * Find the init_task for the currently booting CPU. At poweron, and in * UP mode, task_for_booting_cpu is NULL. */ movl r3=task_for_booting_cpu ;; ld8 r3=[r3] movl r2=init_task ;; cmp.eq isBP,isAP=r3,r0 ;;(isAP) mov r2=r3#else movl r2=init_task cmp.eq isBP,isAP=r0,r0#endif ;; tpa r3=r2 // r3 == phys addr of task struct mov r16=-1(isBP) br.cond.dpnt .load_current // BP stack is on region 5 --- no need to map it // load mapping for stack (virtaddr in r2, physaddr in r3) rsm psr.ic movl r17=PAGE_KERNEL ;; srlz.d dep r18=0,r3,0,12 ;; or r18=r17,r18 dep r2=-1,r3,61,3 // IMVA of task ;; mov r17=rr[r2] shr.u r16=r3,IA64_GRANULE_SHIFT ;; dep r17=0,r17,8,24 ;; mov cr.itir=r17 mov cr.ifa=r2 mov r19=IA64_TR_CURRENT_STACK ;; itr.d dtr[r19]=r18 ;; ssm psr.ic srlz.d ;;.load_current: // load the "current" pointer (r13) and ar.k6 with the current task mov IA64_KR(CURRENT)=r2 // virtual address mov IA64_KR(CURRENT_STACK)=r16 mov r13=r2 /* * Reserve space at the top of the stack for "struct pt_regs". Kernel * threads don't store interesting values in that structure, but the space * still needs to be there because time-critical stuff such as the context * switching can be implemented more efficiently (for example, __switch_to() * always sets the psr.dfh bit of the task it is switching to). */ addl r12=IA64_STK_OFFSET-IA64_PT_REGS_SIZE-16,r2 addl r2=IA64_RBS_OFFSET,r2 // initialize the RSE mov ar.rsc=0 // place RSE in enforced lazy mode ;; loadrs // clear the dirty partition ;; mov ar.bspstore=r2 // establish the new RSE stack ;; mov ar.rsc=0x3 // place RSE in eager mode(isBP) dep r28=-1,r28,61,3 // make address virtual(isBP) movl r2=ia64_boot_param ;;(isBP) st8 [r2]=r28 // save the address of the boot param area passed by the bootloader#ifdef CONFIG_SMP(isAP) br.call.sptk.many rp=start_secondary.ret0:(isAP) br.cond.sptk self#endif // This is executed by the bootstrap processor (bsp) only:#ifdef CONFIG_IA64_FW_EMU // initialize PAL & SAL emulator: br.call.sptk.many rp=sys_fw_init.ret1:#endif br.call.sptk.many rp=start_kernel.ret2: addl r3=@ltoff(halt_msg),gp ;; alloc r2=ar.pfs,8,0,2,0 ;; ld8 out0=[r3] br.call.sptk.many b0=console_printself: hint @pause br.sptk.many self // endless loopEND(_start)GLOBAL_ENTRY(ia64_save_debug_regs) alloc r16=ar.pfs,1,0,0,0 mov r20=ar.lc // preserve ar.lc mov ar.lc=IA64_NUM_DBG_REGS-1 mov r18=0 add r19=IA64_NUM_DBG_REGS*8,in0 ;;1: mov r16=dbr[r18]#ifdef CONFIG_ITANIUM ;; srlz.d#endif mov r17=ibr[r18] add r18=1,r18 ;; st8.nta [in0]=r16,8 st8.nta [r19]=r17,8 br.cloop.sptk.many 1b ;; mov ar.lc=r20 // restore ar.lc br.ret.sptk.many rpEND(ia64_save_debug_regs)GLOBAL_ENTRY(ia64_load_debug_regs) alloc r16=ar.pfs,1,0,0,0 lfetch.nta [in0] mov r20=ar.lc // preserve ar.lc add r19=IA64_NUM_DBG_REGS*8,in0 mov ar.lc=IA64_NUM_DBG_REGS-1 mov r18=-1 ;;1: ld8.nta r16=[in0],8 ld8.nta r17=[r19],8 add r18=1,r18 ;; mov dbr[r18]=r16#ifdef CONFIG_ITANIUM ;; srlz.d // Errata 132 (NoFix status)#endif mov ibr[r18]=r17 br.cloop.sptk.many 1b ;; mov ar.lc=r20 // restore ar.lc br.ret.sptk.many rpEND(ia64_load_debug_regs)GLOBAL_ENTRY(__ia64_save_fpu) alloc r2=ar.pfs,1,4,0,0 adds loc0=96*16-16,in0 adds loc1=96*16-16-128,in0 ;; stf.spill.nta [loc0]=f127,-256 stf.spill.nta [loc1]=f119,-256 ;; stf.spill.nta [loc0]=f111,-256 stf.spill.nta [loc1]=f103,-256 ;; stf.spill.nta [loc0]=f95,-256 stf.spill.nta [loc1]=f87,-256 ;; stf.spill.nta [loc0]=f79,-256 stf.spill.nta [loc1]=f71,-256 ;; stf.spill.nta [loc0]=f63,-256 stf.spill.nta [loc1]=f55,-256 adds loc2=96*16-32,in0 ;; stf.spill.nta [loc0]=f47,-256 stf.spill.nta [loc1]=f39,-256 adds loc3=96*16-32-128,in0 ;; stf.spill.nta [loc2]=f126,-256 stf.spill.nta [loc3]=f118,-256 ;; stf.spill.nta [loc2]=f110,-256 stf.spill.nta [loc3]=f102,-256 ;; stf.spill.nta [loc2]=f94,-256 stf.spill.nta [loc3]=f86,-256 ;; stf.spill.nta [loc2]=f78,-256 stf.spill.nta [loc3]=f70,-256 ;; stf.spill.nta [loc2]=f62,-256 stf.spill.nta [loc3]=f54,-256 adds loc0=96*16-48,in0 ;; stf.spill.nta [loc2]=f46,-256 stf.spill.nta [loc3]=f38,-256 adds loc1=96*16-48-128,in0 ;; stf.spill.nta [loc0]=f125,-256 stf.spill.nta [loc1]=f117,-256 ;; stf.spill.nta [loc0]=f109,-256 stf.spill.nta [loc1]=f101,-256 ;; stf.spill.nta [loc0]=f93,-256 stf.spill.nta [loc1]=f85,-256 ;; stf.spill.nta [loc0]=f77,-256 stf.spill.nta [loc1]=f69,-256 ;; stf.spill.nta [loc0]=f61,-256 stf.spill.nta [loc1]=f53,-256 adds loc2=96*16-64,in0 ;; stf.spill.nta [loc0]=f45,-256 stf.spill.nta [loc1]=f37,-256 adds loc3=96*16-64-128,in0 ;; stf.spill.nta [loc2]=f124,-256 stf.spill.nta [loc3]=f116,-256 ;; stf.spill.nta [loc2]=f108,-256 stf.spill.nta [loc3]=f100,-256 ;; stf.spill.nta [loc2]=f92,-256 stf.spill.nta [loc3]=f84,-256 ;; stf.spill.nta [loc2]=f76,-256 stf.spill.nta [loc3]=f68,-256 ;; stf.spill.nta [loc2]=f60,-256 stf.spill.nta [loc3]=f52,-256 adds loc0=96*16-80,in0 ;; stf.spill.nta [loc2]=f44,-256 stf.spill.nta [loc3]=f36,-256 adds loc1=96*16-80-128,in0 ;; stf.spill.nta [loc0]=f123,-256 stf.spill.nta [loc1]=f115,-256 ;; stf.spill.nta [loc0]=f107,-256 stf.spill.nta [loc1]=f99,-256 ;; stf.spill.nta [loc0]=f91,-256 stf.spill.nta [loc1]=f83,-256 ;; stf.spill.nta [loc0]=f75,-256 stf.spill.nta [loc1]=f67,-256 ;; stf.spill.nta [loc0]=f59,-256 stf.spill.nta [loc1]=f51,-256 adds loc2=96*16-96,in0 ;; stf.spill.nta [loc0]=f43,-256 stf.spill.nta [loc1]=f35,-256 adds loc3=96*16-96-128,in0 ;; stf.spill.nta [loc2]=f122,-256 stf.spill.nta [loc3]=f114,-256 ;; stf.spill.nta [loc2]=f106,-256 stf.spill.nta [loc3]=f98,-256 ;; stf.spill.nta [loc2]=f90,-256 stf.spill.nta [loc3]=f82,-256 ;; stf.spill.nta [loc2]=f74,-256 stf.spill.nta [loc3]=f66,-256 ;; stf.spill.nta [loc2]=f58,-256 stf.spill.nta [loc3]=f50,-256 adds loc0=96*16-112,in0 ;; stf.spill.nta [loc2]=f42,-256 stf.spill.nta [loc3]=f34,-256 adds loc1=96*16-112-128,in0 ;; stf.spill.nta [loc0]=f121,-256 stf.spill.nta [loc1]=f113,-256 ;; stf.spill.nta [loc0]=f105,-256 stf.spill.nta [loc1]=f97,-256 ;; stf.spill.nta [loc0]=f89,-256 stf.spill.nta [loc1]=f81,-256 ;; stf.spill.nta [loc0]=f73,-256 stf.spill.nta [loc1]=f65,-256 ;; stf.spill.nta [loc0]=f57,-256 stf.spill.nta [loc1]=f49,-256 adds loc2=96*16-128,in0 ;; stf.spill.nta [loc0]=f41,-256 stf.spill.nta [loc1]=f33,-256 adds loc3=96*16-128-128,in0 ;; stf.spill.nta [loc2]=f120,-256 stf.spill.nta [loc3]=f112,-256 ;; stf.spill.nta [loc2]=f104,-256 stf.spill.nta [loc3]=f96,-256 ;; stf.spill.nta [loc2]=f88,-256 stf.spill.nta [loc3]=f80,-256 ;; stf.spill.nta [loc2]=f72,-256 stf.spill.nta [loc3]=f64,-256 ;; stf.spill.nta [loc2]=f56,-256 stf.spill.nta [loc3]=f48,-256 ;; stf.spill.nta [loc2]=f40 stf.spill.nta [loc3]=f32 br.ret.sptk.many rpEND(__ia64_save_fpu)GLOBAL_ENTRY(__ia64_load_fpu) alloc r2=ar.pfs,1,2,0,0 adds r3=128,in0 adds r14=256,in0 adds r15=384,in0 mov loc0=512 mov loc1=-1024+16 ;; ldf.fill.nta f32=[in0],loc0 ldf.fill.nta f40=[ r3],loc0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -