URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [mips64orion/] [p4000/] [startup/] [idttlb.S] - Rev 1765
Compare with Previous | Blame | View Log
/*Based upon IDT provided code with the following release:This source code has been made available to you by IDT on an AS-ISbasis. Anyone receiving this source is licensed under IDT copyrightsto use it in any way he or she deems fit, including copying it,modifying it, compiling it, and redistributing it either with orwithout modifications. No license under IDT patents or patentapplications is to be implied by the copyright license.Any user of this software should understand that IDT cannot providetechnical support for this software and will not be responsible forany consequences resulting from the use of this software.Any person who transfers this source code or any derivative work mustinclude the IDT copyright notice, this paragraph, and the preceedingtwo paragraphs in the transferred software.COPYRIGHT IDT CORPORATION 1996LICENSED MATERIAL - PROGRAM PROPERTY OF IDTidttlb.S,v 1.2 1999/03/31 23:21:19 joel Exp*//*** idttlb.s - fetch the registers associated with and the contents** of the tlb.***//* 950308: Ketan patched a few tlb functions that would not have worked.*/#include <iregdef.h>#include <idtcpu.h>#include <idtmon.h>.text#if defined(CPU_R3000)/*** ret_tlblo -- returns the 'entrylo' contents for the TLB** 'c' callable - as ret_tlblo(index) - where index is the** tlb entry to return the lo value for - if called from assembly** language then index should be in register a0.*/FRAME(ret_tlblo,sp,0,ra).set noreordermfc0 t0,C0_SR # save srnopand t0,~SR_PE # dont inadvertantly clear PEmtc0 zero,C0_SR # clear interruptsmfc0 t1,C0_TLBHI # save pidsll a0,TLBINX_INXSHIFT # position indexmtc0 a0,C0_INX # write to index registernoptlbr # put tlb entry in entrylo and hinopmfc0 v0,C0_TLBLO # get the requested entry lomtc0 t1,C0_TLBHI # restore pidmtc0 t0,C0_SR # restore status registerj ranop.set reorderENDFRAME(ret_tlblo)#endif#if defined(CPU_R4000)/*** ret_tlblo[01] -- returns the 'entrylo' contents for the TLB** 'c' callable - as ret_tlblo(index) - where index is the** tlb entry to return the lo value for - if called from assembly** language then index should be in register a0.*/FRAME(ret_tlblo0,sp,0,ra)mfc0 t0,C0_SR # save srmtc0 zero,C0_SR # clear interruptsmfc0 t1,C0_TLBHI # save pidmtc0 a0,C0_INX # write to index register.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordertlbr # put tlb entry in entrylo and hi.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordermfc0 v0,C0_TLBLO0 # get the requested entry lomtc0 t1,C0_TLBHI # restore pidmtc0 t0,C0_SR # restore status registerj raENDFRAME(ret_tlblo0)FRAME(ret_tlblo1,sp,0,ra)mfc0 t0,C0_SR # save srmtc0 zero,C0_SR # clear interruptsmfc0 t1,C0_TLBHI # save pidmtc0 a0,C0_INX # write to index register.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordertlbr # put tlb entry in entrylo and hi.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordermfc0 v0,C0_TLBLO1 # get the requested entry lomtc0 t1,C0_TLBHI # restore pidmtc0 t0,C0_SR # restore status registerj raENDFRAME(ret_tlblo1)/*** ret_pagemask(index) -- return pagemask contents of tlb entry "index"*/FRAME(ret_pagemask,sp,0,ra)mfc0 t0,C0_SR # save srmtc0 zero,C0_SR # disable interruptsmfc0 t1,C0_TLBHI # save current pidmtc0 a0,C0_INX # drop it in C0 register.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordertlbr # read entry to entry hi/lo.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordermfc0 v0,C0_PAGEMASK # to return valuemtc0 t1,C0_TLBHI # restore current pidmtc0 t0,C0_SR # restore srj raENDFRAME(ret_pagemask)/*** ret_tlbwired(void) -- return wired register*/FRAME(ret_tlbwired,sp,0,ra)mfc0 v0,C0_WIREDj raENDFRAME(ret_tlbwired)#endif/*** ret_tlbhi -- return the tlb entry high content for tlb entry** index*/FRAME(ret_tlbhi,sp,0,ra)#if defined(CPU_R3000).set noreordermfc0 t0,C0_SR # save srnopand t0,~SR_PEmtc0 zero,C0_SR # disable interruptsmfc0 t1,C0_TLBHI # save current pidsll a0,TLBINX_INXSHIFT # position indexmtc0 a0,C0_INX # drop it in C0 registernoptlbr # read entry to entry hi/lonopmfc0 v0,C0_TLBHI # to return valuemtc0 t1,C0_TLBHI # restore current pidmtc0 t0,C0_SR # restore srj ranop.set reorder#endif#if defined(CPU_R4000)mfc0 t0,C0_SR # save srmtc0 zero,C0_SR # disable interruptsmfc0 t1,C0_TLBHI # save current pidmtc0 a0,C0_INX # drop it in C0 register.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordertlbr # read entry to entry hi/lo0/lo1/mask.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordermfc0 v0,C0_TLBHI # to return valuemtc0 t1,C0_TLBHI # restore current pidmtc0 t0,C0_SR # restore srj ra#endifENDFRAME(ret_tlbhi)/*** ret_tlbpid() -- return tlb pid contained in the current entry hi*/FRAME(ret_tlbpid,sp,0,ra)#if defined(CPU_R3000).set noreordermfc0 v0,C0_TLBHI # fetch tlb highnopand v0,TLBHI_PIDMASK # isolate and positionsrl v0,TLBHI_PIDSHIFTj ranop.set reorder#endif#if defined(CPU_R4000)mfc0 v0,C0_TLBHI # to return valuenopand v0,TLBHI_PIDMASKj ra#endifENDFRAME(ret_tlbpid)/*** tlbprobe(address, pid) -- probe the tlb to see if address is currently** mapped** a0 = vpn - virtual page numbers are 0=0 1=0x1000, 2=0x2000...** virtual page numbers for the r3000 are in** entry hi bits 31-12** a1 = pid - this is a process id ranging from 0 to 63** this process id is shifted left 6 bits and or'ed into** the entry hi register** returns an index value (0-63) if successful -1 -f not*/FRAME(tlbprobe,sp,0,ra)#if defined(CPU_R3000).set noreordermfc0 t0,C0_SR /* fetch status reg */and a0,TLBHI_VPNMASK /* isolate just the vpn */and t0,~SR_PE /* don't inadvertantly clear pe */mtc0 zero,C0_SRmfc0 t1,C0_TLBHIsll a1,TLBHI_PIDSHIFT /* possition the pid */and a1,TLBHI_PIDMASKor a0,a1 /* build entry hi value */mtc0 a0,C0_TLBHInoptlbp /* do the probe */nopmfc0 v1,C0_INXli v0,-1bltz v1,1fnopsra v0,v1,TLBINX_INXSHIFT /* get index positioned for return */1:mtc0 t1,C0_TLBHI /* restore tlb hi */mtc0 t0,C0_SR /* restore the status reg */j ranop.set reorder#endif#if defined(CPU_R4000)mfc0 t0,C0_SR # save srmtc0 zero,C0_SR # disable interruptsmfc0 t1,C0_TLBHI # save current pidand a0,TLBHI_VPN2MASK # construct tlbhi for probeand a1,TLBHI_PIDMASKor a0,a1mtc0 a0,C0_TLBHI.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordertlbp # probe entry to entry hi/lo0/lo1/mask.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordermfc0 v1,C0_INXli v0,-1bltz v1,1fmove v0,v11: mtc0 t1,C0_TLBHI # restore current pidmtc0 t0,C0_SR # restore srj ra#endifENDFRAME(tlbprobe)/*** resettlb(index) Invalidate the TLB entry specified by index*/FRAME(resettlb,sp,0,ra)#if defined(CPU_R3000).set noreordermfc0 t0,C0_TLBHI # fetch the current himfc0 v0,C0_SR # fetch the status reg.li t2,K0BASE&TLBHI_VPNMASKand v0,~SR_PE # dont inadvertantly clear PEmtc0 zero,C0_SRmtc0 t2,C0_TLBHI # set up tlbhimtc0 zero,C0_TLBLOsll a0,TLBINX_INXSHIFTmtc0 a0,C0_INXnoptlbwi # do actual invalidatenopmtc0 t0,C0_TLBHImtc0 v0,C0_SRj ranop.set reorder#endif#if defined(CPU_R4000)li t2,K0BASE&TLBHI_VPN2MASKmfc0 t0,C0_TLBHI # save current TLBHImfc0 v0,C0_SR # save SR and disable interruptsmtc0 zero,C0_SRmtc0 t2,C0_TLBHI # invalidate entrymtc0 zero,C0_TLBLO0mtc0 zero,C0_TLBLO1mtc0 a0,C0_INX.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordertlbwi.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordermtc0 t0,C0_TLBHImtc0 v0,C0_SRj ra#endifENDFRAME(resettlb)#if defined(CPU_R3000)/*** Setup TLB entry**** map_tlb(index, tlbhi, phypage)** a0 = TLB entry index** a1 = virtual page number and PID** a2 = physical page*/FRAME(map_tlb,sp,0,ra).set noreordersll a0,TLBINX_INXSHIFTmfc0 v0,C0_SR # fetch the current statusmfc0 a3,C0_TLBHI # save the current hiand v0,~SR_PE # dont inadvertantly clear paritymtc0 zero,C0_SRmtc0 a1,C0_TLBHI # set the hi entrymtc0 a2,C0_TLBLO # set the lo entrymtc0 a0,C0_INX # load the indexnoptlbwi # put the hi/lo in tlb entry indexednopmtc0 a3,C0_TLBHI # put back the tlb hi regmtc0 v0,C0_SR # restore the status registerj ranop.set reorderENDFRAME(map_tlb)#endif#if defined(CPU_R4000)/*** Setup R4000 TLB entry**** map_tlb4000(mask_index, tlbhi, pte_even, pte_odd)** a0 = TLB entry index and page mask** a1 = virtual page number and PID** a2 = pte -- contents of even pte** a3 = pte -- contents of odd pte*/FRAME(map_tlb4000,sp,0,ra)and t2,a0,TLBPGMASK_MASKand a0,TLBINX_INXMASKmfc0 t1,C0_TLBHI # save current TLBPIDmfc0 v0,C0_SR # save SR and disable interruptsmtc0 zero,C0_SRmtc0 t2,C0_PAGEMASK # setmtc0 a1,C0_TLBHI # set VPN and TLBPIDmtc0 a2,C0_TLBLO0 # set PPN and access bitsmtc0 a3,C0_TLBLO1 # set PPN and access bitsmtc0 a0,C0_INX # set INDEX to wired entry.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordertlbwi # drop it in.set noreordernop; nop; nop; nop; nop; nop; nop; nop.set reordermtc0 t1,C0_TLBHI # restore TLBPIDmtc0 v0,C0_SR # restore SRj raENDFRAME(map_tlb4000)#endif/*** Set current TLBPID. This assumes PID is positioned correctly in reg.** a0.*/FRAME(set_tlbpid,sp,0,ra).set noreordermtc0 a0,C0_TLBHIj ranop.set reorderENDFRAME(set_tlbpid)
