* arch/arm64/src/common/arm64_internal.h
*
* 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.
*
****************************************************************************/
#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_INTERNAL_H
#define __ARCH_ARM64_SRC_COMMON_ARM64_INTERNAL_H
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <nuttx/compiler.h>
# include <nuttx/arch.h>
# include <nuttx/tls.h>
# include <sys/types.h>
# include <stdint.h>
# include <syscall.h>
#endif
#include "arm64_arch.h"
* Pre-processor Definitions
****************************************************************************/
* and no other console device is specified, then a serial console is
* assumed.
*/
#ifndef CONFIG_DEV_CONSOLE
# undef USE_SERIALDRIVER
# undef USE_EARLYSERIALINIT
#else
# if defined(CONFIG_LWL_CONSOLE)
# undef USE_SERIALDRIVER
# undef USE_EARLYSERIALINIT
# elif defined(CONFIG_CONSOLE_SYSLOG)
# undef USE_SERIALDRIVER
# undef USE_EARLYSERIALINIT
# elif defined(CONFIG_SERIAL_RTT_CONSOLE)
# undef USE_SERIALDRIVER
# undef USE_EARLYSERIALINIT
# elif defined(CONFIG_RPMSG_UART_CONSOLE)
# undef USE_SERIALDRIVER
# undef USE_EARLYSERIALINIT
# else
# define USE_SERIALDRIVER 1
# define USE_EARLYSERIALINIT 1
# endif
#endif
* still be needed. Let's assume that if the upper half serial driver is
* built, then the lower half will also be needed. There is no need for
* the early serial initialization in this case.
*/
#if !defined(USE_SERIALDRIVER) && defined(CONFIG_STANDARD_SERIAL)
# define USE_SERIALDRIVER 1
#endif
#ifndef CONFIG_ARCH_INTERRUPTSTACK
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
* logic.
*/
#define STACK_COLOR 0xdeadbeef
#define HEAP_COLOR 'h'
#ifndef CONFIG_UP
# define STACK_WORDS (CONFIG_IDLETHREAD_STACKSIZE >> 2)
#endif
#define arm64_fullcontextrestore() \
do \
{ \
sys_call0(SYS_restore_context); \
} \
while (1)
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
typedef void (*up_vector_t)(void);
#endif
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#define INIT_STACK_DEFINE(sym, size) \
char locate_data(".initstack") \
aligned_data(STACK_ALIGNMENT) sym[size]
#define INIT_STACK_ARRAY_DEFINE(sym, n, size) \
char locate_data(".initstack") \
aligned_data(STACK_ALIGNMENT) sym[n][size]
#define INIT_STACK_DEFINE_EXTERN(sym, size) \
EXTERN char sym[size]
#define INIT_STACK_ARRAY_DEFINE_EXTERN(sym, n, size) \
EXTERN char sym[n][size]
#define STACK_PTR_TO_FRAME(type, ptr) \
(type *)STACKFRAME_ALIGN_DOWN((uintptr_t)(ptr) - sizeof(type))
#define INTSTACK_SIZE (CONFIG_ARCH_INTERRUPTSTACK & ~STACKFRAME_ALIGN_MASK)
#ifdef CONFIG_ARM64_DECODEFIQ
INIT_STACK_ARRAY_DEFINE_EXTERN(g_interrupt_fiq_stack, CONFIG_NCPUS,
INTSTACK_SIZE);
#endif
INIT_STACK_ARRAY_DEFINE_EXTERN(g_cpu_idlestackalloc, CONFIG_NCPUS,
CONFIG_IDLETHREAD_STACKSIZE);
INIT_STACK_ARRAY_DEFINE_EXTERN(g_interrupt_stack, CONFIG_NCPUS,
INTSTACK_SIZE);
* This is the first address in DRAM after the loaded
* program + bss + idle stack. The end of the heap is
* CONFIG_RAM_END
*/
#if CONFIG_ARCH_INTERRUPTSTACK > 3
EXTERN uint8_t g_intstackalloc[];
EXTERN uint8_t g_intstacktop[];
#else
# error CONFIG_ARCH_INTERRUPTSTACK must be defined (4096 at least) at arm64
#endif
*
* Memory layout for Nuttx at arm64 for FLAT Build
*
* +-------------------------+ <- RAM BASE
* | |
* |<<<<<<<<<<<<<<<<<<<<<<<<<| <- LOAD_BASE
* | text(code) section |
* | vector table |
* +-------------------------+-- page align(4096)
* | rodata section |
* +-------------------------+-- page align(4096)
* | data/bss section |
* +-------------------------+-- page align(4096)
* | initstack section |
* +-------------------------+-- page align(4096)
* | heap alloc area |
* | |
* | |
* | |
* +-------------------------+
*
* Note:
* 1. initstack is for idle_thread and interrupt stack,
* it has dedicated stack for IRQ handler in arm64
* 2. Every section with different memory attribute,
* please check mmu_nxrt_regions at arm64_mmu.c
*
* please check dramboot.ld at specified platform for more detail
*/
EXTERN uint8_t _stext[];
EXTERN uint8_t _etext[];
EXTERN uint8_t _sztext[];
EXTERN uint8_t _srodata[];
EXTERN uint8_t _erodata[];
EXTERN uint8_t _szrodata[];
EXTERN const uint8_t _eronly[];
EXTERN uint8_t _sdata[];
EXTERN uint8_t _edata[];
EXTERN uint8_t _sbss[];
EXTERN uint8_t _ebss[];
EXTERN uint8_t _szdata[];
EXTERN uint8_t _e_initstack[];
EXTERN uint8_t g_idle_topstack[];
#ifdef CONFIG_PERCPU_SECTION
EXTERN uint8_t _ldata_percpu[];
EXTERN uint8_t _sdata_percpu[];
EXTERN uint8_t _edata_percpu[];
EXTERN uint8_t _sbss_percpu[];
EXTERN uint8_t _ebss_percpu[];
EXTERN uint8_t _percpu_size[];
#endif
# define _START_TEXT _stext
# define _END_TEXT _etext
# define _START_BSS _sbss
# define _END_BSS _ebss
# define _DATA_INIT _eronly
# define _START_DATA _sdata
# define _END_DATA _edata
* Inline Functions
****************************************************************************/
* Public Function Prototypes
****************************************************************************/
void arm64_new_task(struct tcb_s *tak_new);
#ifdef CONFIG_BUILD_KERNEL
void arm64_jump_to_user(uint64_t entry, uint64_t x0, uint64_t x1,
uint64_t sp_el0, uint64_t *regs) noreturn_function;
#elif defined(CONFIG_BUILD_PROTECTED)
void arm64_jump_to_user(uint64_t startup, uint64_t entry, uint64_t x0,
uint64_t x1, uint64_t sp_el0,
uint64_t *regs) noreturn_function;
#endif
void arm64_chip_boot(void);
int arm64_psci_init(const char *method);
void __start(void);
void arm64_secondary_start(void);
void arm64_sigdeliver(void);
#ifdef CONFIG_PM
void arm64_pminitialize(void);
#else
# define arm64_pminitialize()
#endif
* (but should be back-ported to the ARM7 and ARM9 families).
*/
uint64_t *arm64_doirq(int irq, uint64_t *regs);
#ifdef CONFIG_LEGACY_PAGING
void arm64_pginitialize(void);
#else
# define arm64_pginitialize()
#endif
uint64_t *arm64_syscall(uint64_t *regs);
void arm64_lowputc(char ch);
#ifdef USE_SERIALDRIVER
* Name: arm64_serialinit
*
* Description:
* Register serial console and serial ports. This assumes
* that arm64_earlyserialinit was called previously.
*
****************************************************************************/
void arm64_serialinit(void);
#endif
#ifdef USE_EARLYSERIALINIT
* Name: arm64_earlyserialinit
*
* Description:
* Performs the low level UART initialization early in debug so that the
* serial console will be available during bootup. This must be called
* before arm64_serialinit.
*
* Note:
* This function assumes that low level hardware configuration
* including all clocking and pin configuration -- was performed
* earlier in the boot sequence(eg bootloader).
*
****************************************************************************/
void arm64_earlyserialinit(void);
#endif
#ifdef CONFIG_ARCH_DMA
void weak_function arm64_dma_initialize(void);
#endif
#if CONFIG_MM_REGIONS > 1
void arm64_addregion(void);
#else
# define arm64_addregion()
#endif
* implementations, or chip/xyx_ethernet.c for chip-specific Ethernet
* implementations, or common/arm_etherstub.c for a corner case where the
* network is enabled yet there is no Ethernet driver to be initialized.
*
* Use of common/arm_etherstub.c is deprecated. The preferred mechanism is
* to use CONFIG_NETDEV_LATEINIT=y to suppress the call to
* arm_netinitialize() in up_initialize(). Then this stub would not be
* needed.
*/
#if defined(CONFIG_NET) && !defined(CONFIG_NETDEV_LATEINIT)
void arm64_netinitialize(void);
#else
# define arm64_netinitialize()
#endif
#ifdef CONFIG_USBDEV
void arm64_usbinitialize(void);
void arm64_usbuninitialize(void);
#else
# define arm64_usbinitialize()
# define arm64_usbuninitialize()
#endif
#ifdef CONFIG_STACK_COLORATION
size_t arm64_stack_check(void *stackbase, size_t nbytes);
void arm64_stack_color(void *stackbase, size_t nbytes);
#endif
#ifdef CONFIG_ARCH_HAVE_DEBUG
void arm64_enable_dbgmonitor(void);
#endif
* Name: arm64_color_intstack
*
* Description:
* Set the interrupt stack to a value so that later we can determine how
* much stack space was used by interrupt handling logic
*
****************************************************************************/
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
static inline_function void arm64_color_intstack(void)
{
arm64_stack_color((void *)up_get_intstackbase(this_cpu()),
INTSTACK_SIZE);
}
#else
# define arm64_color_intstack()
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif
#endif