Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:57

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsPowerPCQorIQMMU
0007  *
0008  * @brief MMU API.
0009  */
0010 
0011 /*
0012  * Copyright (C) 2011, 2015 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifndef LIBBSP_POWERPC_QORIQ_MMU_H
0037 #define LIBBSP_POWERPC_QORIQ_MMU_H
0038 
0039 #include <stdint.h>
0040 #include <stdbool.h>
0041 
0042 #include <bspopts.h>
0043 
0044 #ifdef __cplusplus
0045 extern "C" {
0046 #endif /* __cplusplus */
0047 
0048 /**
0049  * @defgroup QorIQMMU QorIQ - MMU Support
0050  *
0051  * @ingroup RTEMSBSPsPowerPCQorIQ
0052  *
0053  * @brief MMU support.
0054  *
0055  * @{
0056  */
0057 
0058 #define QORIQ_MMU_MIN_POWER 12
0059 #define QORIQ_MMU_MAX_POWER 30
0060 #define QORIQ_MMU_POWER_STEP 2
0061 
0062 typedef struct {
0063     uintptr_t begin;
0064     uintptr_t last;
0065     uint32_t mas1;
0066     uint32_t mas2;
0067     uint32_t mas3;
0068     uint32_t mas7;
0069 } qoriq_mmu_entry;
0070 
0071 typedef struct {
0072     int count;
0073     qoriq_mmu_entry entries [QORIQ_TLB1_ENTRY_COUNT];
0074 } qoriq_mmu_context;
0075 
0076 void qoriq_mmu_context_init(qoriq_mmu_context *self);
0077 
0078 bool qoriq_mmu_add(
0079     qoriq_mmu_context *self,
0080     uintptr_t begin,
0081     uintptr_t last,
0082     uint32_t mas1,
0083     uint32_t mas2,
0084     uint32_t mas3,
0085     uint32_t mas7
0086 );
0087 
0088 void qoriq_mmu_partition(qoriq_mmu_context *self, int max_count);
0089 
0090 void qoriq_mmu_write_to_tlb1(qoriq_mmu_context *self, int first_tlb);
0091 
0092 void qoriq_mmu_change_perm(uint32_t test, uint32_t set, uint32_t clear);
0093 
0094 int qoriq_mmu_find_free_tlb1_entry(void);
0095 
0096 void qoriq_mmu_config(bool boot_processor, int first_tlb, int scratch_tlb);
0097 
0098 void qoriq_tlb1_write(
0099     int esel,
0100     uint32_t mas1,
0101     uint32_t mas2,
0102     uint32_t mas3,
0103     uint32_t mas7,
0104     uintptr_t ea,
0105     int tsize
0106 );
0107 
0108 void qoriq_mmu_adjust_and_write_to_tlb1(
0109     int tlb,
0110     uintptr_t begin,
0111     uintptr_t last,
0112     uint32_t mas1,
0113     uint32_t mas2,
0114     uint32_t mas3,
0115     uint32_t mas7
0116 );
0117 
0118 void qoriq_tlb1_invalidate(int esel);
0119 
0120 /** @} */
0121 
0122 #ifdef __cplusplus
0123 }
0124 #endif /* __cplusplus */
0125 
0126 #endif /* LIBBSP_POWERPC_QORIQ_MMU_H */