hartmannathan commented on code in PR #6478:
URL: https://github.com/apache/incubator-nuttx/pull/6478#discussion_r915013451


##########
arch/arm64/src/common/arm64_arch_timer.c:
##########
@@ -0,0 +1,245 @@
+/****************************************************************************
+ * arch/arm64/src/common/arm64_arch_timer.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 <debug.h>
+#include <assert.h>
+
+#include <nuttx/arch.h>
+#include <arch/irq.h>
+#include <arch/chip/chip.h>
+#include <nuttx/spinlock.h>
+
+#include "arm64_arch.h"
+#include "arm64_internal.h"
+#include "arm64_gic.h"
+#include "arm64_arch_timer.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+#define MIN_DELAY  (1000)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static uint64_t     last_cycle;
+static uint64_t     cycle_per_tick;
+static uint32_t     arch_timer_rate;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static inline void arm64_arch_timer_set_compare(uint64_t value)
+{
+  write_sysreg(value, cntv_cval_el0);
+}
+
+static inline void arm64_arch_timer_enable(unsigned char enable)
+{
+  uint64_t value;
+
+  value = read_sysreg(cntv_ctl_el0);
+
+  if (enable)
+    {
+      value |= CNTV_CTL_ENABLE_BIT;
+    }
+  else
+    {
+      value &= ~CNTV_CTL_ENABLE_BIT;
+    }
+
+  write_sysreg(value, cntv_ctl_el0);
+}
+
+static inline void arm64_arch_timer_set_irq_mask(bool mask)
+{
+  uint64_t value;
+
+  value = read_sysreg(cntv_ctl_el0);
+
+  if (mask)
+    {
+      value |= CNTV_CTL_IMASK_BIT;
+    }
+  else
+    {
+      value &= ~CNTV_CTL_IMASK_BIT;
+    }
+
+  write_sysreg(value, cntv_ctl_el0);
+}
+
+static inline uint64_t arm64_arch_timer_count(void)
+{
+  return read_sysreg(cntvct_el0);
+}
+
+static inline uint32_t arm64_arch_timer_get_cntfrq(void)
+{
+  return read_sysreg(cntfrq_el0);
+}
+
+#ifdef CONFIG_SCHED_TICKLESS
+static void arm64_arch_timer_compare_isr(int irq, uint64_t *regs, void *arg)

Review Comment:
   Should be:
   
   `static int arm64_arch_timer_compare_isr(int irq, void *context, void *arg)`
   
   At top of function, add:
   
   `regs = (uint64_t) context;`
   
   At end of function, add:
   
   `return OK;`
   
   (Edit: Remove FAR. Not needed for arm64.)



##########
arch/arm64/src/common/arm64_arch_timer.c:
##########
@@ -0,0 +1,245 @@
+/****************************************************************************
+ * arch/arm64/src/common/arm64_arch_timer.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 <debug.h>
+#include <assert.h>
+
+#include <nuttx/arch.h>
+#include <arch/irq.h>
+#include <arch/chip/chip.h>
+#include <nuttx/spinlock.h>
+
+#include "arm64_arch.h"
+#include "arm64_internal.h"
+#include "arm64_gic.h"
+#include "arm64_arch_timer.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+#define MIN_DELAY  (1000)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static uint64_t     last_cycle;
+static uint64_t     cycle_per_tick;
+static uint32_t     arch_timer_rate;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static inline void arm64_arch_timer_set_compare(uint64_t value)
+{
+  write_sysreg(value, cntv_cval_el0);
+}
+
+static inline void arm64_arch_timer_enable(unsigned char enable)
+{
+  uint64_t value;
+
+  value = read_sysreg(cntv_ctl_el0);
+
+  if (enable)
+    {
+      value |= CNTV_CTL_ENABLE_BIT;
+    }
+  else
+    {
+      value &= ~CNTV_CTL_ENABLE_BIT;
+    }
+
+  write_sysreg(value, cntv_ctl_el0);
+}
+
+static inline void arm64_arch_timer_set_irq_mask(bool mask)
+{
+  uint64_t value;
+
+  value = read_sysreg(cntv_ctl_el0);
+
+  if (mask)
+    {
+      value |= CNTV_CTL_IMASK_BIT;
+    }
+  else
+    {
+      value &= ~CNTV_CTL_IMASK_BIT;
+    }
+
+  write_sysreg(value, cntv_ctl_el0);
+}
+
+static inline uint64_t arm64_arch_timer_count(void)
+{
+  return read_sysreg(cntvct_el0);
+}
+
+static inline uint32_t arm64_arch_timer_get_cntfrq(void)
+{
+  return read_sysreg(cntfrq_el0);
+}
+
+#ifdef CONFIG_SCHED_TICKLESS
+static void arm64_arch_timer_compare_isr(int irq, uint64_t *regs, void *arg)

Review Comment:
   Should be:
   
   `static int arm64_arch_timer_compare_isr(int irq, void *context, void *arg)`
   
   At top of function, add:
   
   `regs = (uint64_t) context;`
   
   At end of function, add:
   
   `return OK;`
   
   (Edit: Removed FAR. Not needed for arm64.)



-- 
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

Reply via email to