qinwei2004 commented on code in PR #6478: URL: https://github.com/apache/incubator-nuttx/pull/6478#discussion_r920723985
########## arch/arm64/src/common/arm64_mmu.c: ########## @@ -0,0 +1,619 @@ +/*************************************************************************** + * arch/arm64/src/common/arm64_mmu.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ***************************************************************************/ + +/*************************************************************************** + * Included Files + ***************************************************************************/ + +#include <nuttx/config.h> +#include <stdint.h> +#include <debug.h> +#include <assert.h> + +#include <nuttx/arch.h> +#include <arch/irq.h> +#include <arch/chip/chip.h> + +#include "arm64_arch.h" +#include "arm64_internal.h" +#include "arm64_fatal.h" +#include "arm64_mmu.h" + +/*************************************************************************** + * Pre-processor Definitions + ***************************************************************************/ + +/* MMU debug option + * #define CONFIG_MMU_ASSERT 1 + * #define CONFIG_MMU_DEBUG 1 + * #define CONFIG_MMU_DUMP_PTE 1 + */ + +#ifdef CONFIG_MMU_DEBUG + +#define L0_SPACE "" +#define L1_SPACE " " +#define L2_SPACE " " +#define L3_SPACE " " +#define XLAT_TABLE_LEVEL_SPACE(level) \ + (((level) == 0) ? L0_SPACE : \ + ((level) == 1) ? L1_SPACE : \ + ((level) == 2) ? L2_SPACE : L3_SPACE) +#endif + +#ifdef CONFIG_MMU_ASSERT +#define __MMU_ASSERT(__cond, fmt, ...) \ + do { \ + if (!(__cond)){ \ + trace_printf(fmt, ## __VA_ARGS__); \ + PANIC(); \ + } \ + } while (false) +#else +#define __MMU_ASSERT(test, fmt, ...) +#endif + +/* We support only 4kB translation granule */ + +#define PAGE_SIZE_SHIFT 12U +#define PAGE_SIZE (1U << PAGE_SIZE_SHIFT) Review Comment: i perfer to keep, it's not a bit operation actually and a little weird to change to BIT defined -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org