# # Copyright (C) 2005 Jakub Jermar # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # - Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # - 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. # - The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. # #include #include #include #include #include #include #include #ifdef CONFIG_SMP #include #endif .register %g2, #scratch .register %g3, #scratch .section K_TEXT_START, "ax" #define BSP_FLAG 1 /* * Here is where the kernel is passed control from the boot loader. * * The registers are expected to be in this state: * - %o0 starting address of physical memory + bootstrap processor flag * bits 63...1: physical memory starting address / 2 * bit 0: non-zero on BSP processor, zero on AP processors * - %o1 bootinfo structure address (BSP only) * - %o2 bootinfo structure size (BSP only) * * Moreover, we depend on boot having established the following environment: * - TLBs are on * - identity mapping for the kernel image */ .global kernel_image_start kernel_image_start: mov BSP_FLAG, %l0 and %o0, %l0, %l7 ! l7 <= bootstrap processor? andn %o0, %l0, %l6 ! l6 <= start of physical memory ! Get bits 40:13 of physmem_base. srlx %l6, 13, %l5 sllx %l5, 13 + (63 - 40), %l5 srlx %l5, 63 - 40, %l5 ! l5 <= physmem_base[40:13] /* * Setup basic runtime environment. */ wrpr %g0, NWINDOWS - 2, %cansave ! set maximum saveable windows wrpr %g0, 0, %canrestore ! get rid of windows we will never need again wrpr %g0, 0, %otherwin ! make sure the window state is consistent wrpr %g0, NWINDOWS - 1, %cleanwin ! prevent needless clean_window traps for kernel wrpr %g0, 0, %tl ! TL = 0, primary context register is used wrpr %g0, PSTATE_PRIV_BIT, %pstate ! Disable interrupts and disable 32-bit address masking. wrpr %g0, 0, %pil ! intialize %pil /* * Switch to kernel trap table. */ sethi %hi(trap_table), %g1 wrpr %g1, %lo(trap_table), %tba /* * Take over the DMMU by installing global locked * TTE entry identically mapping the first 4M * of memory. * * In case of DMMU, no FLUSH instructions need to be * issued. Because of that, the old DTLB contents can * be demapped pretty straightforwardly and without * causing any traps. */ wr %g0, ASI_DMMU, %asi #define SET_TLB_DEMAP_CMD(r1, context_id) \ set (TLB_DEMAP_CONTEXT<