* arch/arm64/src/common/arm64_doirq.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 <assert.h>
#include <sched.h>
#include <debug.h>
#include <nuttx/addrenv.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include "task/task.h"
#include "sched/sched.h"
#include "irq/irq.h"
#include "arm64_arch.h"
#include "arm64_internal.h"
#include "arm64_gic.h"
#include "arm64_fatal.h"
* Private Functions
****************************************************************************/
* Public Functions
****************************************************************************/
* Name: arm64_doirq
*
* Description:
* Receives the decoded GIC interrupt information and dispatches control
* to the attached interrupt handler.
*
****************************************************************************/
uint64_t *arm64_doirq(int irq, uint64_t * regs)
{
struct tcb_s *tcb = this_task();
DEBUGASSERT(!up_interrupt_context());
g_interrupt_context = true;
tcb->xcp.regs = regs;
nxsched_suspend_scheduler(tcb);
irq_dispatch(irq, regs);
tcb = this_task();
* current_regs will have a different value than it did on entry. If an
* interrupt level context switch has occurred, then restore the floating
* point state and the establish the correct address environment before
* returning from the interrupt.
*/
if (regs != tcb->xcp.regs)
{
struct tcb_s **running_task = &g_running_task;
#ifdef CONFIG_ARCH_ADDRENV
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
addrenv_switch(tcb);
tcb = this_task();
#endif
write_sysreg(tcb->stack_alloc_ptr, tpidr_el0);
* g_running_tasks[] is only used by assertion logic for reporting
* crashes.
*/
*running_task = tcb;
regs = tcb->xcp.regs;
}
nxsched_resume_scheduler(tcb);
g_interrupt_context = false;
* and will be marked as NULL to avoid misusage.
*/
tcb->xcp.regs = NULL;
return regs;
}
* Name: up_irqinitialize
*
* Description:
* This function is called by up_initialize() during the bring-up of the
* system. It is the responsibility of this function to but the interrupt
* subsystem into the working and ready state.
*
****************************************************************************/
void up_irqinitialize(void)
{
* called early in the initialization sequence, we expect to have exclusive
* access to the GIC.
*/
arm64_gic_initialize();
#ifndef CONFIG_SUPPRESS_INTERRUPTS
arm64_color_intstack();
up_irq_enable();
#endif
}