-
Notifications
You must be signed in to change notification settings - Fork 2
Release: v2.0 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,6 @@ archs: | |
- name: rx | ||
path: rx | ||
full_name: Renesas RX | ||
- name: dspic | ||
path: dspic | ||
full_name: Microchip dsPIC |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
if(CONFIG_BIG_ENDIAN) | ||
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-big) | ||
else() | ||
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-little) | ||
endif() | ||
zephyr_include_directories(${XCDSC_TOOLCHAIN_PATH}/support/generic/h/) | ||
zephyr_include_directories(include) | ||
add_subdirectory(core) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) 2025, Microchip Technology Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
menu "DSPIC Options" | ||
depends on DSPIC | ||
|
||
config ARCH | ||
string | ||
default "dspic" | ||
|
||
config NUM_IRQS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can vary from SoC to SoC, in that case how do we handle this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IRQ shall only be part of SoC definitions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted, will analyse the changes needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is Kconfig file and we can have different values for this in respective SOC definictions |
||
default 287 | ||
|
||
config GEN_IRQ_START_VECTOR | ||
default 8 | ||
|
||
endmenu |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
zephyr_library() | ||
|
||
zephyr_library_sources( | ||
cpu_idle.c | ||
fatal.c | ||
irq_manage.c | ||
isr_wrapper.c | ||
prep_c.c | ||
thread.c | ||
swap.c | ||
tls.c | ||
reset0.S | ||
init.S | ||
vector_table.S | ||
reset1.S | ||
) | ||
|
||
zephyr_linker_sources(ROM_START SORT_KEY 0x04 vector_table.ld) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) 2025, Microchip Technology Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/irq.h> | ||
#include <zephyr/tracing/tracing.h> | ||
#include <zephyr/arch/cpu.h> | ||
|
||
#ifndef CONFIG_ARCH_HAS_CUSTOM_CPU_IDLE | ||
void arch_cpu_idle(void) | ||
{ | ||
} | ||
#endif | ||
|
||
#ifndef CONFIG_ARCH_HAS_CUSTOM_CPU_ATOMIC_IDLE | ||
void arch_cpu_atomic_idle(unsigned int key) | ||
{ | ||
(void)key; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldnt we use pwrsav instruction here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @harishagari |
||
} | ||
#endif | ||
|
||
FUNC_NORETURN void arch_system_halt(unsigned int reason) | ||
{ | ||
(void)reason; | ||
CODE_UNREACHABLE; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2025, Microchip Technology Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
|
||
volatile uint32_t reason, address; | ||
|
||
#define EXCEPTION_HANDLER __attribute__((interrupt, no_auto_psv, keep)) | ||
|
||
void EXCEPTION_HANDLER _ReservedTrap7(void); | ||
void __attribute__((weak)) TRAPS_halt_on_error(void); | ||
void EXCEPTION_HANDLER _BusErrorTrap(void); | ||
void EXCEPTION_HANDLER _AddressErrorTrap(void); | ||
void EXCEPTION_HANDLER _IllegalInstructionTrap(void); | ||
void EXCEPTION_HANDLER _MathErrorTrap(void); | ||
void EXCEPTION_HANDLER _StackErrorTrap(void); | ||
void EXCEPTION_HANDLER _GeneralTrap(void); | ||
void EXCEPTION_HANDLER _ReservedTrap0(void); | ||
void EXCEPTION_HANDLER _ReservedTrap7(void); | ||
|
||
void __attribute__((weak)) TRAPS_halt_on_error(void) | ||
{ | ||
} | ||
|
||
/** Bus error.**/ | ||
void EXCEPTION_HANDLER _BusErrorTrap(void) | ||
{ | ||
__asm__("nop"); | ||
__asm__("retfie"); | ||
} | ||
|
||
/** Address error.**/ | ||
void EXCEPTION_HANDLER _AddressErrorTrap(void) | ||
{ | ||
__asm__("nop"); | ||
__asm__("retfie"); | ||
} | ||
|
||
/** Illegal instruction.**/ | ||
void EXCEPTION_HANDLER _IllegalInstructionTrap(void) | ||
{ | ||
__asm__("nop"); | ||
__asm__("retfie"); | ||
} | ||
|
||
/** Math error.**/ | ||
void EXCEPTION_HANDLER _MathErrorTrap(void) | ||
{ | ||
__asm__("nop"); | ||
__asm__("retfie"); | ||
} | ||
|
||
/** Stack error.**/ | ||
void EXCEPTION_HANDLER _StackErrorTrap(void) | ||
{ | ||
__asm__("nop"); | ||
__asm__("retfie"); | ||
} | ||
|
||
/** Generic error.**/ | ||
void EXCEPTION_HANDLER _GeneralTrap(void) | ||
{ | ||
__asm__("nop"); | ||
__asm__("retfie"); | ||
} | ||
|
||
/** Reserved Trap0.**/ | ||
void EXCEPTION_HANDLER _ReservedTrap0(void) | ||
{ | ||
__asm__("nop"); | ||
__asm__("retfie"); | ||
} | ||
|
||
/** Reserved Trap7.**/ | ||
void EXCEPTION_HANDLER _ReservedTrap7(void) | ||
{ | ||
__asm__("nop"); | ||
__asm__("retfie"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2025, Microchip Technology Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
.section .init,code | ||
.global __custom_data_init | ||
.global __custom_data_init_extended | ||
|
||
.equ __custom_data_init, __custom_data_init_extended | ||
__custom_data_init_extended: | ||
|
||
.equiv FMT_CLEAR,0 | ||
.equiv FMT_COPY2,1 | ||
.equiv FMT_COPY3,2 | ||
.equiv FMT_CALL, 3 | ||
.equiv FMT_DUO_COPY3,0x1F | ||
|
||
#define DINIT w0 | ||
#define TLSOFFSET w1 | ||
#define TBLOFFSET w9 | ||
#define DSTOFFSET w10 | ||
#define LEN w11 | ||
#define FORMAT w12 | ||
|
||
mov.l w0, TBLOFFSET | ||
bra 4f | ||
|
||
1: | ||
add.l DSTOFFSET,TLSOFFSET,DSTOFFSET | ||
mov.l [TBLOFFSET++], LEN | ||
mov.l [TBLOFFSET++], FORMAT | ||
|
||
cp.b FORMAT, #FMT_CALL | ||
bra nz, 2f | ||
call DSTOFFSET | ||
bra 4f | ||
|
||
2: | ||
cp.b FORMAT, #FMT_CLEAR | ||
bra nz, 2f | ||
9: | ||
sub.l LEN, #1, LEN | ||
repeat LEN | ||
clr.b [DSTOFFSET++] | ||
bra 4f | ||
|
||
2: | ||
cp.b FORMAT, #FMT_COPY2 | ||
bra z, 3f | ||
|
||
3: | ||
sub.l LEN, #1, LEN | ||
repeat LEN | ||
mov.b [TBLOFFSET++], [DSTOFFSET++] | ||
add.l TBLOFFSET, #3, TBLOFFSET | ||
and1.l TBLOFFSET, #0x7C, TBLOFFSET | ||
|
||
4: | ||
sub.l [TBLOFFSET++], #0, DSTOFFSET | ||
bra nz, 1b | ||
return |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2025, Microchip Technology Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <kswap.h> | ||
|
||
void z_irq_spurious(const void *unused) | ||
{ | ||
(void)unused; | ||
} | ||
|
||
void arch_irq_enable(unsigned int irq) | ||
{ | ||
(void)irq; | ||
} | ||
|
||
int arch_irq_is_enabled(unsigned int irq) | ||
{ | ||
(void)irq; | ||
return 0; | ||
} | ||
|
||
void arch_irq_disable(unsigned int irq) | ||
{ | ||
(void)irq; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright (c) 2025, Microchip Technology Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/irq.h> | ||
#include <zephyr/pm/pm.h> | ||
#include <zephyr/sw_isr_table.h> | ||
#include <kernel_arch_func.h> | ||
|
||
/* dsPIC33A interrtup exit routine. Will check if a context | ||
* switch is required. If so, z_dspic_do_swap() will be called | ||
* to affect the context switch | ||
*/ | ||
void __attribute__((naked)) z_dspic_exc_exit(void) | ||
{ | ||
} | ||
|
||
void __attribute__((interrupt, naked)) _COMMONInterrupt(void) | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright (c) 2025, Microchip Technology Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <gen_offset.h> | ||
#include <zephyr/kernel.h> | ||
#include <kernel_offsets.h> | ||
|
||
GEN_ABS_SYM_END |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2025, Microchip Technology Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <kernel_internal.h> | ||
#include <zephyr/irq.h> | ||
#include <zephyr/platform/hooks.h> | ||
#include <zephyr/arch/cache.h> | ||
|
||
void z_prep_c(void); | ||
/** | ||
* @brief Prepare to and run C code | ||
* | ||
* This routine prepares for the execution of and runs C code. | ||
*/ | ||
|
||
void z_prep_c(void) | ||
{ | ||
#if defined(CONFIG_SOC_PREP_HOOK) | ||
soc_prep_hook(); | ||
#endif | ||
z_cstart(); | ||
CODE_UNREACHABLE; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2025, Microchip Technology Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/toolchain.h> | ||
#include <zephyr/linker/sections.h> | ||
#include <zephyr/arch/cpu.h> | ||
#include <zephyr/offsets.h> | ||
|
||
;;This reset version support data initialization | ||
;;Refer reset1.S for without data initialization | ||
|
||
.section .text, code ; Use .text to avoid section attribute errors | ||
.weak __start,__user_init, __has_user_init, ___tls_crt_init | ||
.extern __custom_data_init_extended | ||
.extern __user_init | ||
|
||
__start: | ||
;; Initialize stack pointer and limit | ||
mov.l #__SP_init, w15 ; Stack pointer (W15) | ||
mov.l #__SPLIM_init, w14 ; Stack limit (W14) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W14 is stack frame pointer , SPLIM is stack pointer limit register. Do we want to initialize w14 or SPLIM here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we needed to write back the value from w14 to SPLIM. This was a mistake, will take care with next changes. |
||
|
||
;; Data initialization | ||
mov.l #__dinit_tbloffset, w0 | ||
cp0.l w0 | ||
bra eq, 1f | ||
clr w1 | ||
rcall __custom_data_init_extended | ||
1: | ||
;; Thread-local storage init (if available) | ||
mov.l #___tls_crt_init, w0 | ||
cp0.l w0 | ||
bra eq, 1f | ||
rcall ___tls_crt_init | ||
1: | ||
mov.l #__user_init,w0 | ||
cp0.l w0 ; user init functions | ||
bra eq,1f | ||
call __user_init | ||
1: | ||
;; Call the main application | ||
call _z_prep_c |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comma is not required in the copyright header.
It should be as follows:
This can be updated everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will start changing all files in coming commits. Please expect this in coming release