Code refactor for ARM bsp MMU initialization
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed Jul 8 13:34:50 UTC 2015
On 08/07/15 15:10, Rohini Kulkarni wrote:
>
>
> On Wed, Jul 8, 2015 at 6:29 PM, Sebastian Huber
> <sebastian.huber at embedded-brains.de
> <mailto:sebastian.huber at embedded-brains.de>> wrote:
>
> Hello Rohini,
>
> please use git format-patch to generate the patches.
>
> Actually,that is what I have used. I pasted the patch here from the
> resulting file.
Better use git send-email, or send the file as is since this will
preserve the commit message and author.
>
>
> On 08/07/15 14:44, Rohini Kulkarni wrote:
>
> +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstartmmu.c
> @@ -0,0 +1,30 @@
> +#define ARM_CP15_TEXT_SECTION BSP_START_TEXT_SECTION
> +
> +#include <bsp/start.h>
> +#include <bsp/arm-cp15-start.h>
> +#include <bsp/linker-symbols.h>
> +#include <libcpu/arm-cp15.h>
> +#include <bsp/mm.h>
> +#include <bsp.h>
> +
> +uint32_t bsp_initial_mmu_ctrl_set;
> +uint32_t bsp_initial_mmu_ctrl_clear;
> +uint32_t domain_set;
> +
> +void raspberrypi_setup_mmu_and_cache(void)
> +{
> +#if (BSP_IS_RPI2 == 1)
> + /* Enable SMP in auxiliary control */
> + uint32_t actlr = arm_cp15_get_auxiliary_control();
> + actlr |= ARM_CORTEX_A9_ACTL_SMP;
> + arm_cp15_set_auxiliary_control(actlr);
> + bsp_initial_mmu_ctrl_clear = ARM_CP15_CTRL_A;
> + bsp_initial_mmu_ctrl_set = ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z;
> +#else
> + bsp_initial_mmu_ctrl_clear = 0;
> + bsp_initial_mmu_ctrl_set = ARM_CP15_CTRL_AFE |
> ARM_CP15_CTRL_S | ARM_CP15_CTRL_XP;
> +#endif
> + domain_set = ARM_MMU_DEFAULT_CLIENT_DOMAIN;
> +
> + bsp_memory_management_initialize();
> +}
>
>
> Is there a reason, why you use global variables instead of
> function parameters?
>
> I have set them as extern in mm.h and are directly used in mminit.c
> instead of being passed to bsp_memory_management_initialize. They will
> be set by the bsp the source is being compiled for.
You should avoid global variables and functions in general. I don't see
a necessity for them here.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the devel
mailing list