locore.S revision 85718
184996Srobert/* 284996Srobert * Initial implementation: 384996Srobert * Copyright (c) 2001 Robert Drehmel 484996Srobert * All rights reserved. 584996Srobert * 684996Srobert * As long as the above copyright statement and this notice remain 784996Srobert * unchanged, you can do what ever you want with this file. 884996Srobert * 984996Srobert * $FreeBSD: head/sys/boot/sparc64/loader/locore.S 85718 2001-10-30 06:27:34Z jake $ 1084996Srobert */ 1184996Srobert#include <machine/asi.h> 1285718Sjake#include <machine/asm.h> 1384996Srobert#include <machine/pstate.h> 1484996Srobert#include <machine/param.h> 1584996Srobert 1685718Sjake#define SPOFF 2047 1785718Sjake#define STACK_SIZE (2 * PAGE_SIZE) 1884996Srobert 1985718SjakeENTRY(_start) 2084996Srobert /* limit interrupts */ 2184996Srobert wrpr %g0, 13, %pil 2284996Srobert 2384996Srobert /* 2484996Srobert * PSTATE: privileged, interrupts enabled, floating point 2584996Srobert * unit enabled 2684996Srobert */ 2784996Srobert wrpr %g0, PSTATE_PRIV|PSTATE_IE|PSTATE_PEF, %pstate 2885718Sjake wr %g0, 0x4, %fprs 2984996Srobert 3085718Sjake setx stack + STACK_SIZE - SPOFF, %l7, %l6 3185718Sjake mov %l6, %sp 3284996Srobert call main 3385718Sjake mov %o4, %o0 3485718Sjake illtrap 3584996Srobert 3684996Srobert/* 3784996Srobert * %o0 input VA constant 3884996Srobert * %o1 current iTLB offset 3984996Srobert * %o2 current iTLB TTE tag 4084996Srobert */ 4185718SjakeENTRY(itlb_va_to_pa) 4284996Srobert clr %o1 4384996Srobert0: ldxa [%o1] ASI_ITLB_TAG_READ_REG, %o2 4484996Srobert cmp %o2, %o0 4584996Srobert bne,a %xcc, 1f 4684996Srobert nop 4784996Srobert /* return PA of matching entry */ 4884996Srobert ldxa [%o1] ASI_ITLB_DATA_ACCESS_REG, %o0 4984996Srobert sllx %o0, 23, %o0 5084996Srobert srlx %o0, PAGE_SHIFT+23, %o0 5184996Srobert sllx %o0, PAGE_SHIFT, %o0 5284996Srobert retl 5384996Srobert mov %o0, %o1 5484996Srobert1: cmp %o1, 63<<3 5584996Srobert blu %xcc, 0b 5684996Srobert add %o1, 8, %o1 5784996Srobert clr %o0 5884996Srobert retl 5984996Srobert not %o0 6084996Srobert 6185718SjakeENTRY(dtlb_va_to_pa) 6284996Srobert clr %o1 6384996Srobert0: ldxa [%o1] ASI_DTLB_TAG_READ_REG, %o2 6484996Srobert cmp %o2, %o0 6584996Srobert bne,a %xcc, 1f 6684996Srobert nop 6784996Srobert /* return PA of matching entry */ 6884996Srobert ldxa [%o1] ASI_DTLB_DATA_ACCESS_REG, %o0 6984996Srobert sllx %o0, 23, %o0 7084996Srobert srlx %o0, PAGE_SHIFT+23, %o0 7184996Srobert sllx %o0, PAGE_SHIFT, %o0 7284996Srobert retl 7384996Srobert mov %o0, %o1 7484996Srobert1: cmp %o1, 63<<3 7584996Srobert blu %xcc, 0b 7684996Srobert add %o1, 8, %o1 7784996Srobert clr %o0 7884996Srobert retl 7984996Srobert not %o0 8084996Srobert 8184996Srobert/* 8284996Srobert * %o0 = slot number 8384996Srobert * %o1 = pa 8484996Srobert * %o2 = va 8584996Srobert * %o3 = flags 8684996Srobert */ 8785718SjakeENTRY(itlb_enter) 8884996Srobert sllx %o0, 3, %o0 8984996Srobert or %o1, %o3, %o1 9085718Sjake mov AA_IMMU_TAR, %o3 9184996Srobert stxa %o2, [%o3] ASI_IMMU 9284996Srobert membar #Sync 9384996Srobert stxa %o1, [%o0] ASI_ITLB_DATA_ACCESS_REG 9484996Srobert retl 9584996Srobert nop 9684996Srobert 9785718SjakeENTRY(dtlb_enter) 9884996Srobert sllx %o0, 3, %o0 9984996Srobert or %o1, %o3, %o1 10085718Sjake mov AA_DMMU_TAR, %o3 10184996Srobert stxa %o2, [%o3] ASI_DMMU 10284996Srobert membar #Sync 10384996Srobert stxa %o1, [%o0] ASI_DTLB_DATA_ACCESS_REG 10484996Srobert retl 10584996Srobert nop 10684996Srobert 10785718Sjake .comm stack, STACK_SIZE, 32 108