2016-11-08 23:36:50 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014-2016 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-11-08 23:36:50 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Private kernel definitions
|
|
|
|
*
|
|
|
|
* This file contains private kernel structures definitions and various
|
|
|
|
* other definitions for the ARCv2 processor architecture.
|
|
|
|
*
|
|
|
|
* This file is also included by assembly language files which must #define
|
|
|
|
* _ASMLANGUAGE before including this header file. Note that kernel
|
|
|
|
* assembly source files obtains structure offset values via "absolute
|
|
|
|
* symbols" in the offsets.o module.
|
|
|
|
*/
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_DATA_H_
|
|
|
|
#define ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_DATA_H_
|
2016-11-08 23:36:50 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <toolchain.h>
|
2017-06-17 23:30:47 +08:00
|
|
|
#include <linker/sections.h>
|
2016-11-08 23:36:50 +08:00
|
|
|
#include <arch/cpu.h>
|
|
|
|
#include <vector_table.h>
|
2017-04-05 04:19:13 +08:00
|
|
|
#include <kernel_arch_thread.h>
|
2016-11-08 23:36:50 +08:00
|
|
|
|
|
|
|
#ifndef _ASMLANGUAGE
|
|
|
|
#include <kernel.h>
|
2018-01-31 12:41:47 +08:00
|
|
|
#include <kernel_internal.h>
|
Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-19 23:32:08 +08:00
|
|
|
#include <zephyr/types.h>
|
2016-11-08 23:36:50 +08:00
|
|
|
#include <misc/util.h>
|
|
|
|
#include <misc/dlist.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _ASMLANGUAGE
|
2017-11-29 17:24:09 +08:00
|
|
|
#ifdef CONFIG_ARC_HAS_SECURE
|
|
|
|
struct _irq_stack_frame {
|
|
|
|
u32_t lp_end;
|
|
|
|
u32_t lp_start;
|
|
|
|
u32_t lp_count;
|
|
|
|
#ifdef CONFIG_CODE_DENSITY
|
|
|
|
/*
|
|
|
|
* Currently unsupported. This is where those registers are
|
|
|
|
* automatically pushed on the stack by the CPU when taking a regular
|
|
|
|
* IRQ.
|
|
|
|
*/
|
|
|
|
u32_t ei_base;
|
|
|
|
u32_t ldi_base;
|
|
|
|
u32_t jli_base;
|
|
|
|
#endif
|
|
|
|
u32_t r0;
|
|
|
|
u32_t r1;
|
|
|
|
u32_t r2;
|
|
|
|
u32_t r3;
|
|
|
|
u32_t r4;
|
|
|
|
u32_t r5;
|
|
|
|
u32_t r6;
|
|
|
|
u32_t r7;
|
|
|
|
u32_t r8;
|
|
|
|
u32_t r9;
|
|
|
|
u32_t r10;
|
|
|
|
u32_t r11;
|
|
|
|
u32_t r12;
|
|
|
|
u32_t r13;
|
|
|
|
u32_t blink;
|
|
|
|
u32_t pc;
|
|
|
|
u32_t sec_stat;
|
|
|
|
u32_t status32;
|
|
|
|
};
|
|
|
|
#else
|
2016-11-08 23:36:50 +08:00
|
|
|
struct _irq_stack_frame {
|
2017-04-21 02:30:33 +08:00
|
|
|
u32_t r0;
|
|
|
|
u32_t r1;
|
|
|
|
u32_t r2;
|
|
|
|
u32_t r3;
|
|
|
|
u32_t r4;
|
|
|
|
u32_t r5;
|
|
|
|
u32_t r6;
|
|
|
|
u32_t r7;
|
|
|
|
u32_t r8;
|
|
|
|
u32_t r9;
|
|
|
|
u32_t r10;
|
|
|
|
u32_t r11;
|
|
|
|
u32_t r12;
|
|
|
|
u32_t r13;
|
|
|
|
u32_t blink;
|
|
|
|
u32_t lp_end;
|
|
|
|
u32_t lp_start;
|
|
|
|
u32_t lp_count;
|
2016-11-08 23:36:50 +08:00
|
|
|
#ifdef CONFIG_CODE_DENSITY
|
|
|
|
/*
|
|
|
|
* Currently unsupported. This is where those registers are
|
|
|
|
* automatically pushed on the stack by the CPU when taking a regular
|
|
|
|
* IRQ.
|
|
|
|
*/
|
2017-04-21 02:30:33 +08:00
|
|
|
u32_t ei_base;
|
|
|
|
u32_t ldi_base;
|
|
|
|
u32_t jli_base;
|
2016-11-08 23:36:50 +08:00
|
|
|
#endif
|
2017-04-21 02:30:33 +08:00
|
|
|
u32_t pc;
|
|
|
|
u32_t status32;
|
2016-11-08 23:36:50 +08:00
|
|
|
};
|
2017-11-29 17:24:09 +08:00
|
|
|
#endif
|
2016-11-08 23:36:50 +08:00
|
|
|
|
|
|
|
typedef struct _irq_stack_frame _isf_t;
|
|
|
|
|
boards: Update arc em_starterkit support from 2.2 to 2.3
Here are the main changes:
* board: Update EMSK onboard resources such as Button, Switch and LEDs
+ update soc.h for em7d, em9d, em11d
+ update board.h for em_starterkit board
* arc: Add floating point support and code density support
+ add kconfig configuration
+ add compiler options
+ add register definitions, marcos, assembly codes
+ fixes in existing codes and configurations.
* arc: Update detailed board configurations for cores of emsk 2.3
* script: Provide arc_debugger.sh for debugging em_starterkit board
+ make BOARD=em_starterkit debug
This will start openocd server for emsk, and arc gdb will connect
to this debug server, user can run `continue` command if user just
want to run the application, or other commands if debugging needed.
+ make BOARD=em_starterkit debugserver
This will start an openocd debugger server for emsk, and user can
connect to this debugserver using arc gdb and do what they want to.
+ make BOARD=em_starterkit flash
This will download the zephyr application elf file to emsk,
and run it.
Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-05-17 15:18:51 +08:00
|
|
|
|
|
|
|
|
2016-11-08 23:36:50 +08:00
|
|
|
/* callee-saved registers pushed on the stack, not in k_thread */
|
|
|
|
struct _callee_saved_stack {
|
2017-04-21 02:30:33 +08:00
|
|
|
u32_t r13;
|
|
|
|
u32_t r14;
|
|
|
|
u32_t r15;
|
|
|
|
u32_t r16;
|
|
|
|
u32_t r17;
|
|
|
|
u32_t r18;
|
|
|
|
u32_t r19;
|
|
|
|
u32_t r20;
|
|
|
|
u32_t r21;
|
|
|
|
u32_t r22;
|
|
|
|
u32_t r23;
|
|
|
|
u32_t r24;
|
|
|
|
u32_t r25;
|
|
|
|
u32_t r26;
|
|
|
|
u32_t fp; /* r27 */
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_USERSPACE
|
2018-02-01 16:34:47 +08:00
|
|
|
#ifdef CONFIG_ARC_HAS_SECURE
|
|
|
|
u32_t user_sp;
|
|
|
|
u32_t kernel_sp;
|
|
|
|
#else
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
u32_t user_sp;
|
2018-02-01 16:34:47 +08:00
|
|
|
#endif
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
#endif
|
2016-11-08 23:36:50 +08:00
|
|
|
/* r28 is the stack pointer and saved separately */
|
|
|
|
/* r29 is ILINK and does not need to be saved */
|
2017-04-21 02:30:33 +08:00
|
|
|
u32_t r30;
|
boards: Update arc em_starterkit support from 2.2 to 2.3
Here are the main changes:
* board: Update EMSK onboard resources such as Button, Switch and LEDs
+ update soc.h for em7d, em9d, em11d
+ update board.h for em_starterkit board
* arc: Add floating point support and code density support
+ add kconfig configuration
+ add compiler options
+ add register definitions, marcos, assembly codes
+ fixes in existing codes and configurations.
* arc: Update detailed board configurations for cores of emsk 2.3
* script: Provide arc_debugger.sh for debugging em_starterkit board
+ make BOARD=em_starterkit debug
This will start openocd server for emsk, and arc gdb will connect
to this debug server, user can run `continue` command if user just
want to run the application, or other commands if debugging needed.
+ make BOARD=em_starterkit debugserver
This will start an openocd debugger server for emsk, and user can
connect to this debugserver using arc gdb and do what they want to.
+ make BOARD=em_starterkit flash
This will download the zephyr application elf file to emsk,
and run it.
Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-05-17 15:18:51 +08:00
|
|
|
#ifdef CONFIG_FP_SHARING
|
|
|
|
u32_t r58;
|
|
|
|
u32_t r59;
|
|
|
|
u32_t fpu_status;
|
|
|
|
u32_t fpu_ctrl;
|
|
|
|
#ifdef CONFIG_FP_FPU_DA
|
|
|
|
u32_t dpfp2h;
|
|
|
|
u32_t dpfp2l;
|
|
|
|
u32_t dpfp1h;
|
|
|
|
u32_t dpfp1l;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
2016-11-08 23:36:50 +08:00
|
|
|
/*
|
|
|
|
* No need to save r31 (blink), it's either alread pushed as the pc or
|
|
|
|
* blink on an irq stack frame.
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _callee_saved_stack _callee_saved_stack_t;
|
|
|
|
|
|
|
|
struct _kernel_arch {
|
|
|
|
|
|
|
|
char *rirq_sp; /* regular IRQ stack pointer base */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIRQ stack pointer is installed once in the second bank's SP, so
|
|
|
|
* there is no need to track it in _kernel.
|
|
|
|
*/
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _kernel_arch _kernel_arch_t;
|
|
|
|
|
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
2017-04-05 04:19:13 +08:00
|
|
|
/* stacks */
|
|
|
|
|
|
|
|
#define STACK_ALIGN_SIZE 4
|
|
|
|
|
|
|
|
#define STACK_ROUND_UP(x) ROUND_UP(x, STACK_ALIGN_SIZE)
|
|
|
|
#define STACK_ROUND_DOWN(x) ROUND_DOWN(x, STACK_ALIGN_SIZE)
|
|
|
|
|
2016-11-08 23:36:50 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_DATA_H_ */
|