pkarashchenko commented on a change in pull request #5040:
URL: https://github.com/apache/incubator-nuttx/pull/5040#discussion_r772449525



##########
File path: arch/risc-v/src/mpfs/mpfs_opensbi.c
##########
@@ -0,0 +1,523 @@
+/****************************************************************************
+ * arch/risc-v/src/mpfs/mpfs_opensbi.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 <assert.h>
+#include <errno.h>
+#include <stdint.h>
+#include <riscv_internal.h>
+#include <riscv_arch.h>
+
+#include <hardware/mpfs_plic.h>
+#include <hardware/mpfs_memorymap.h>
+#include <hardware/mpfs_clint.h>
+#include <hardware/mpfs_sysreg.h>
+
+/* OpenSBI will also define NULL. Undefine NULL in order to avoid warning:
+ * 'warning: "NULL" redefined'
+ */
+
+#ifdef NULL
+  #undef NULL
+#endif
+
+#include <sbi/sbi_types.h>
+#include <sbi/riscv_atomic.h>
+#include <sbi/riscv_asm.h>
+#include <sbi/riscv_io.h>
+#include <sbi/riscv_encoding.h>
+#include <sbi/sbi_hart.h>
+#include <sbi/sbi_console.h>
+#include <sbi/sbi_platform.h>
+#include <sbi/sbi_domain.h>
+#include <sbi/sbi_timer.h>
+#include <sbi/sbi_init.h>
+#include <sbi/sbi_scratch.h>
+#include <sbi_utils/irqchip/plic.h>
+#include <sbi_utils/ipi/aclint_mswi.h>
+#include <sbi_utils/timer/aclint_mtimer.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MPFS_SYS_CLK               1000000000
+#define MPFS_MAX_NUM_HARTS         5
+#define MPFS_HART_COUNT            5
+
+#define MPFS_ACLINT_MSWI_ADDR      MPFS_CLINT_MSIP0
+#define MPFS_ACLINT_MTIMER_ADDR    MPFS_CLINT_MTIMECMP0
+
+#define MPFS_PMP_DEFAULT_ADDR      0xfffffffff
+#define MPFS_PMP_DEFAULT_PERM      0x000000009f
+
+static bool mpfs_console_ready     = false;
+
+#define UBOOT_LOAD_ADDR            0x80200000  /* We expect u-boot here */
+
+/* The following define is not accessible with assember.  Make sure it's in
+ * sync with the assembler usage in mpfs_opensbi_utils.S.
+ */
+
+#if SBI_PLATFORM_DEFAULT_HART_STACK_SIZE != 8192
+# error "Fix define in file mpfs_opensbi_utils.S"
+#endif
+
+#define MPFS_SYSREG_SOFT_RESET_CR     (MPFS_SYSREG_BASE + \
+                                       MPFS_SYSREG_SOFT_RESET_CR_OFFSET)
+#define MPFS_SYSREG_SUBBLK_CLOCK_CR   (MPFS_SYSREG_BASE + \
+                                       MPFS_SYSREG_SUBBLK_CLOCK_CR_OFFSET)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sbi_scratch_holder_s
+{
+  union
+    {
+      struct sbi_scratch scratch;
+      unsigned long buffer[SBI_SCRATCH_SIZE / __SIZEOF_POINTER__];

Review comment:
       is it reasonable to use `sizeof(void *)` or `sizeof(uintptr_t)` instead 
of `__SIZEOF_POINTER__`? Als what if `SBI_SCRATCH_SIZE` is not multiple of 
pointer size? Are we sure that `unsigned long` can hold pointer value? Maybe 
reasonable to switch to `uintptr_t`?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to