13f50425cSMichal Simek/* 23f50425cSMichal Simek * Miscellaneous low-level MMU functions. 33f50425cSMichal Simek * 43f50425cSMichal Simek * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> 53f50425cSMichal Simek * Copyright (C) 2008-2009 PetaLogix 63f50425cSMichal Simek * Copyright (C) 2007 Xilinx, Inc. All rights reserved. 73f50425cSMichal Simek * 83f50425cSMichal Simek * Derived from arch/ppc/kernel/misc.S 93f50425cSMichal Simek * 103f50425cSMichal Simek * This file is subject to the terms and conditions of the GNU General 113f50425cSMichal Simek * Public License. See the file COPYING in the main directory of this 123f50425cSMichal Simek * archive for more details. 133f50425cSMichal Simek */ 143f50425cSMichal Simek 153f50425cSMichal Simek#include <linux/linkage.h> 163f50425cSMichal Simek#include <linux/sys.h> 173f50425cSMichal Simek#include <asm/unistd.h> 183f50425cSMichal Simek#include <linux/errno.h> 193f50425cSMichal Simek#include <asm/mmu.h> 203f50425cSMichal Simek#include <asm/page.h> 213f50425cSMichal Simek 223f50425cSMichal Simek .text 233f50425cSMichal Simek/* 243f50425cSMichal Simek * Flush MMU TLB 253f50425cSMichal Simek * 263f50425cSMichal Simek * We avoid flushing the pinned 0, 1 and possibly 2 entries. 273f50425cSMichal Simek */ 283f50425cSMichal Simek.globl _tlbia; 2913851966SMichal Simek.type _tlbia, @function 303f50425cSMichal Simek.align 4; 313f50425cSMichal Simek_tlbia: 320691c97dSMichal Simek addik r12, r0, MICROBLAZE_TLB_SIZE - 1 /* flush all entries (63 - 3) */ 333f50425cSMichal Simek /* isync */ 343f50425cSMichal Simek_tlbia_1: 353f50425cSMichal Simek mts rtlbx, r12 363f50425cSMichal Simek nop 373f50425cSMichal Simek mts rtlbhi, r0 /* flush: ensure V is clear */ 383f50425cSMichal Simek nop 393f50425cSMichal Simek addik r11, r12, -2 403f50425cSMichal Simek bneid r11, _tlbia_1 /* loop for all entries */ 413f50425cSMichal Simek addik r12, r12, -1 423f50425cSMichal Simek /* sync */ 433f50425cSMichal Simek rtsd r15, 8 443f50425cSMichal Simek nop 4513851966SMichal Simek .size _tlbia, . - _tlbia 463f50425cSMichal Simek 473f50425cSMichal Simek/* 483f50425cSMichal Simek * Flush MMU TLB for a particular address (in r5) 493f50425cSMichal Simek */ 503f50425cSMichal Simek.globl _tlbie; 5113851966SMichal Simek.type _tlbie, @function 523f50425cSMichal Simek.align 4; 533f50425cSMichal Simek_tlbie: 543f50425cSMichal Simek mts rtlbsx, r5 /* look up the address in TLB */ 553f50425cSMichal Simek nop 563f50425cSMichal Simek mfs r12, rtlbx /* Retrieve index */ 573f50425cSMichal Simek nop 583f50425cSMichal Simek blti r12, _tlbie_1 /* Check if found */ 593f50425cSMichal Simek mts rtlbhi, r0 /* flush: ensure V is clear */ 603f50425cSMichal Simek nop 613f50425cSMichal Simek_tlbie_1: 623f50425cSMichal Simek rtsd r15, 8 633f50425cSMichal Simek nop 643f50425cSMichal Simek 6513851966SMichal Simek .size _tlbie, . - _tlbie 6613851966SMichal Simek 673f50425cSMichal Simek/* 683f50425cSMichal Simek * Allocate TLB entry for early console 693f50425cSMichal Simek */ 703f50425cSMichal Simek.globl early_console_reg_tlb_alloc; 7113851966SMichal Simek.type early_console_reg_tlb_alloc, @function 723f50425cSMichal Simek.align 4; 733f50425cSMichal Simekearly_console_reg_tlb_alloc: 743f50425cSMichal Simek /* 753f50425cSMichal Simek * Load a TLB entry for the UART, so that microblaze_progress() can use 763f50425cSMichal Simek * the UARTs nice and early. We use a 4k real==virtual mapping. 773f50425cSMichal Simek */ 780691c97dSMichal Simek ori r4, r0, MICROBLAZE_TLB_SIZE - 1 79af58ed85SMichal Simek mts rtlbx, r4 /* TLB slot 63 */ 803f50425cSMichal Simek 813f50425cSMichal Simek or r4,r5,r0 823f50425cSMichal Simek andi r4,r4,0xfffff000 833f50425cSMichal Simek ori r4,r4,(TLB_WR|TLB_I|TLB_M|TLB_G) 843f50425cSMichal Simek 853f50425cSMichal Simek andi r5,r5,0xfffff000 863f50425cSMichal Simek ori r5,r5,(TLB_VALID | TLB_PAGESZ(PAGESZ_4K)) 873f50425cSMichal Simek 883f50425cSMichal Simek mts rtlblo,r4 /* Load the data portion of the entry */ 893f50425cSMichal Simek nop 903f50425cSMichal Simek mts rtlbhi,r5 /* Load the tag portion of the entry */ 913f50425cSMichal Simek nop 923f50425cSMichal Simek rtsd r15, 8 933f50425cSMichal Simek nop 943f50425cSMichal Simek 9513851966SMichal Simek .size early_console_reg_tlb_alloc, . - early_console_reg_tlb_alloc 96