1f9412d9fSurnenfeld /* 2f9412d9fSurnenfeld * Copyright 2021-2022, Oliver Ruiz Dorantes. All rights reserved. 3f9412d9fSurnenfeld * Distributed under the terms of the MIT License. 4f9412d9fSurnenfeld */ 5f9412d9fSurnenfeld #include <boot/platform.h> 6f9412d9fSurnenfeld #include <boot/stage2.h> 7f9412d9fSurnenfeld 8f9412d9fSurnenfeld #include "aarch64.h" 9f9412d9fSurnenfeld 10f9412d9fSurnenfeld 11f9412d9fSurnenfeld void arch_cache_disable()12f9412d9fSurnenfeldarch_cache_disable() 13f9412d9fSurnenfeld { 14f9412d9fSurnenfeld if (arch_mmu_cache_enabled()) { 15f9412d9fSurnenfeld uint64 sctlr = _arch_mmu_get_sctlr(); 16*b983396cSOwen Anderson sctlr &= ~(SCTLR_M | SCTLR_C | SCTLR_I); 17f9412d9fSurnenfeld _arch_mmu_set_sctlr(sctlr); 18f9412d9fSurnenfeld 19f9412d9fSurnenfeld _arch_cache_clean_poc(); 20f9412d9fSurnenfeld _arch_mmu_invalidate_tlb_all(arch_exception_level()); 21f9412d9fSurnenfeld } 22f9412d9fSurnenfeld } 23f9412d9fSurnenfeld 24f9412d9fSurnenfeld 25f9412d9fSurnenfeld void arch_cache_enable()26f9412d9fSurnenfeldarch_cache_enable() 27f9412d9fSurnenfeld { 28f9412d9fSurnenfeld if (!arch_mmu_cache_enabled()) { 29f9412d9fSurnenfeld uint64 sctlr = _arch_mmu_get_sctlr(); 30*b983396cSOwen Anderson sctlr |= (SCTLR_M | SCTLR_C | SCTLR_I); 31f9412d9fSurnenfeld _arch_mmu_set_sctlr(sctlr); 32f9412d9fSurnenfeld } 33f9412d9fSurnenfeld } 34