Skip to content
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

rewrite startup code in C++ #9

Merged
merged 7 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ see the following list for a list of available configuration options and their d
- [Boot Mode Configuration](./docs/config_options/BOOT_MODE.md)
- [Linker Script Options](./docs/config_options/LINKER_SCRIPT.md)
- [Custom Build Flags](./docs/config_options/BUILD_FLAGS.md)
- [Custom Interrupt Management](./docs/config_options/CUSTOM_INTERRUPT_MANAGEMENT.md)


## C APIs

the DDL framework adds some C apis to the standard DDL, the documentation for these can be found in the following files:

- [Heap and Stack APIs](./docs/STACK_AND_HEAP_APIS.md)


## Files and Patches
Expand Down
6 changes: 6 additions & 0 deletions cores/ddl/library/src/hc32f460_interrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
/*******************************************************************************
* Function implementation - global ('extern') and local ('static')
******************************************************************************/
#if !DDL_INTERRUPTS_CUSTOM_HANDLER_MANAGEMENT
func_ptr_t IrqHandler[IRQ_NUM_MAX] = {NULL};

/**
Expand Down Expand Up @@ -137,6 +138,7 @@ en_result_t enIrqResign(IRQn_Type enIRQn)
}
return enRet;
}
#endif // !DDL_INTERRUPTS_CUSTOM_HANDLER_MANAGEMENT

/**
*******************************************************************************
Expand Down Expand Up @@ -298,6 +300,8 @@ en_result_t enIntDisable(uint32_t u32Int)
return Ok;
}

#if !DDL_INTERRUPTS_CUSTOM_HANDLER_MANAGEMENT

/**
*******************************************************************************
** \brief NMI IRQ handler
Expand Down Expand Up @@ -2052,6 +2056,8 @@ __WEAK void IRQ127_Handler(void)
}
}

#endif // !DDL_INTERRUPTS_CUSTOM_HANDLER_MANAGEMENT

#if (DDL_INTERRUPTS_SHARE_ENABLE == DDL_ON)
/**
*******************************************************************************
Expand Down
6 changes: 6 additions & 0 deletions cores/ddl/startup/checks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "startup.h"

// check expected size of vector table
static_assert(sizeof(irq_vector_t) == 4, "irq_vector_t must be 4 bytes");
static_assert(sizeof(uint32_t *) == 4, "uint32_t must be 4 bytes");
static_assert(sizeof(vector_table) == (16 + 144) * 4, "vector_table does not match expected size");
167 changes: 167 additions & 0 deletions cores/ddl/startup/interrupts.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#include "interrupts.h"
#include "startup.h"

void __default_handler()
{
__on_default_handler();
while (true)
;
}

#define IRQ_HANDLER_ATTRS __attribute__((weak, alias("__default_handler")))

IRQ_HANDLER_ATTRS void Reset_Handler(void);
IRQ_HANDLER_ATTRS void NMI_Handler(void);
IRQ_HANDLER_ATTRS void HardFault_Handler(void);
IRQ_HANDLER_ATTRS void MemManage_Handler(void);
IRQ_HANDLER_ATTRS void BusFault_Handler(void);
IRQ_HANDLER_ATTRS void UsageFault_Handler(void);
IRQ_HANDLER_ATTRS void SVC_Handler(void);
IRQ_HANDLER_ATTRS void DebugMon_Handler(void);
IRQ_HANDLER_ATTRS void PendSV_Handler(void);
IRQ_HANDLER_ATTRS void SysTick_Handler(void);

IRQ_HANDLER_ATTRS void IRQ000_Handler(void);
IRQ_HANDLER_ATTRS void IRQ001_Handler(void);
IRQ_HANDLER_ATTRS void IRQ002_Handler(void);
IRQ_HANDLER_ATTRS void IRQ003_Handler(void);
IRQ_HANDLER_ATTRS void IRQ004_Handler(void);
IRQ_HANDLER_ATTRS void IRQ005_Handler(void);
IRQ_HANDLER_ATTRS void IRQ006_Handler(void);
IRQ_HANDLER_ATTRS void IRQ007_Handler(void);
IRQ_HANDLER_ATTRS void IRQ008_Handler(void);
IRQ_HANDLER_ATTRS void IRQ009_Handler(void);
IRQ_HANDLER_ATTRS void IRQ010_Handler(void);
IRQ_HANDLER_ATTRS void IRQ011_Handler(void);
IRQ_HANDLER_ATTRS void IRQ012_Handler(void);
IRQ_HANDLER_ATTRS void IRQ013_Handler(void);
IRQ_HANDLER_ATTRS void IRQ014_Handler(void);
IRQ_HANDLER_ATTRS void IRQ015_Handler(void);
IRQ_HANDLER_ATTRS void IRQ016_Handler(void);
IRQ_HANDLER_ATTRS void IRQ017_Handler(void);
IRQ_HANDLER_ATTRS void IRQ018_Handler(void);
IRQ_HANDLER_ATTRS void IRQ019_Handler(void);
IRQ_HANDLER_ATTRS void IRQ020_Handler(void);
IRQ_HANDLER_ATTRS void IRQ021_Handler(void);
IRQ_HANDLER_ATTRS void IRQ022_Handler(void);
IRQ_HANDLER_ATTRS void IRQ023_Handler(void);
IRQ_HANDLER_ATTRS void IRQ024_Handler(void);
IRQ_HANDLER_ATTRS void IRQ025_Handler(void);
IRQ_HANDLER_ATTRS void IRQ026_Handler(void);
IRQ_HANDLER_ATTRS void IRQ027_Handler(void);
IRQ_HANDLER_ATTRS void IRQ028_Handler(void);
IRQ_HANDLER_ATTRS void IRQ029_Handler(void);
IRQ_HANDLER_ATTRS void IRQ030_Handler(void);
IRQ_HANDLER_ATTRS void IRQ031_Handler(void);
IRQ_HANDLER_ATTRS void IRQ032_Handler(void);
IRQ_HANDLER_ATTRS void IRQ033_Handler(void);
IRQ_HANDLER_ATTRS void IRQ034_Handler(void);
IRQ_HANDLER_ATTRS void IRQ035_Handler(void);
IRQ_HANDLER_ATTRS void IRQ036_Handler(void);
IRQ_HANDLER_ATTRS void IRQ037_Handler(void);
IRQ_HANDLER_ATTRS void IRQ038_Handler(void);
IRQ_HANDLER_ATTRS void IRQ039_Handler(void);
IRQ_HANDLER_ATTRS void IRQ040_Handler(void);
IRQ_HANDLER_ATTRS void IRQ041_Handler(void);
IRQ_HANDLER_ATTRS void IRQ042_Handler(void);
IRQ_HANDLER_ATTRS void IRQ043_Handler(void);
IRQ_HANDLER_ATTRS void IRQ044_Handler(void);
IRQ_HANDLER_ATTRS void IRQ045_Handler(void);
IRQ_HANDLER_ATTRS void IRQ046_Handler(void);
IRQ_HANDLER_ATTRS void IRQ047_Handler(void);
IRQ_HANDLER_ATTRS void IRQ048_Handler(void);
IRQ_HANDLER_ATTRS void IRQ049_Handler(void);
IRQ_HANDLER_ATTRS void IRQ050_Handler(void);
IRQ_HANDLER_ATTRS void IRQ051_Handler(void);
IRQ_HANDLER_ATTRS void IRQ052_Handler(void);
IRQ_HANDLER_ATTRS void IRQ053_Handler(void);
IRQ_HANDLER_ATTRS void IRQ054_Handler(void);
IRQ_HANDLER_ATTRS void IRQ055_Handler(void);
IRQ_HANDLER_ATTRS void IRQ056_Handler(void);
IRQ_HANDLER_ATTRS void IRQ057_Handler(void);
IRQ_HANDLER_ATTRS void IRQ058_Handler(void);
IRQ_HANDLER_ATTRS void IRQ059_Handler(void);
IRQ_HANDLER_ATTRS void IRQ060_Handler(void);
IRQ_HANDLER_ATTRS void IRQ061_Handler(void);
IRQ_HANDLER_ATTRS void IRQ062_Handler(void);
IRQ_HANDLER_ATTRS void IRQ063_Handler(void);
IRQ_HANDLER_ATTRS void IRQ064_Handler(void);
IRQ_HANDLER_ATTRS void IRQ065_Handler(void);
IRQ_HANDLER_ATTRS void IRQ066_Handler(void);
IRQ_HANDLER_ATTRS void IRQ067_Handler(void);
IRQ_HANDLER_ATTRS void IRQ068_Handler(void);
IRQ_HANDLER_ATTRS void IRQ069_Handler(void);
IRQ_HANDLER_ATTRS void IRQ070_Handler(void);
IRQ_HANDLER_ATTRS void IRQ071_Handler(void);
IRQ_HANDLER_ATTRS void IRQ072_Handler(void);
IRQ_HANDLER_ATTRS void IRQ073_Handler(void);
IRQ_HANDLER_ATTRS void IRQ074_Handler(void);
IRQ_HANDLER_ATTRS void IRQ075_Handler(void);
IRQ_HANDLER_ATTRS void IRQ076_Handler(void);
IRQ_HANDLER_ATTRS void IRQ077_Handler(void);
IRQ_HANDLER_ATTRS void IRQ078_Handler(void);
IRQ_HANDLER_ATTRS void IRQ079_Handler(void);
IRQ_HANDLER_ATTRS void IRQ080_Handler(void);
IRQ_HANDLER_ATTRS void IRQ081_Handler(void);
IRQ_HANDLER_ATTRS void IRQ082_Handler(void);
IRQ_HANDLER_ATTRS void IRQ083_Handler(void);
IRQ_HANDLER_ATTRS void IRQ084_Handler(void);
IRQ_HANDLER_ATTRS void IRQ085_Handler(void);
IRQ_HANDLER_ATTRS void IRQ086_Handler(void);
IRQ_HANDLER_ATTRS void IRQ087_Handler(void);
IRQ_HANDLER_ATTRS void IRQ088_Handler(void);
IRQ_HANDLER_ATTRS void IRQ089_Handler(void);
IRQ_HANDLER_ATTRS void IRQ090_Handler(void);
IRQ_HANDLER_ATTRS void IRQ091_Handler(void);
IRQ_HANDLER_ATTRS void IRQ092_Handler(void);
IRQ_HANDLER_ATTRS void IRQ093_Handler(void);
IRQ_HANDLER_ATTRS void IRQ094_Handler(void);
IRQ_HANDLER_ATTRS void IRQ095_Handler(void);
IRQ_HANDLER_ATTRS void IRQ096_Handler(void);
IRQ_HANDLER_ATTRS void IRQ097_Handler(void);
IRQ_HANDLER_ATTRS void IRQ098_Handler(void);
IRQ_HANDLER_ATTRS void IRQ099_Handler(void);
IRQ_HANDLER_ATTRS void IRQ100_Handler(void);
IRQ_HANDLER_ATTRS void IRQ101_Handler(void);
IRQ_HANDLER_ATTRS void IRQ102_Handler(void);
IRQ_HANDLER_ATTRS void IRQ103_Handler(void);
IRQ_HANDLER_ATTRS void IRQ104_Handler(void);
IRQ_HANDLER_ATTRS void IRQ105_Handler(void);
IRQ_HANDLER_ATTRS void IRQ106_Handler(void);
IRQ_HANDLER_ATTRS void IRQ107_Handler(void);
IRQ_HANDLER_ATTRS void IRQ108_Handler(void);
IRQ_HANDLER_ATTRS void IRQ109_Handler(void);
IRQ_HANDLER_ATTRS void IRQ110_Handler(void);
IRQ_HANDLER_ATTRS void IRQ111_Handler(void);
IRQ_HANDLER_ATTRS void IRQ112_Handler(void);
IRQ_HANDLER_ATTRS void IRQ113_Handler(void);
IRQ_HANDLER_ATTRS void IRQ114_Handler(void);
IRQ_HANDLER_ATTRS void IRQ115_Handler(void);
IRQ_HANDLER_ATTRS void IRQ116_Handler(void);
IRQ_HANDLER_ATTRS void IRQ117_Handler(void);
IRQ_HANDLER_ATTRS void IRQ118_Handler(void);
IRQ_HANDLER_ATTRS void IRQ119_Handler(void);
IRQ_HANDLER_ATTRS void IRQ120_Handler(void);
IRQ_HANDLER_ATTRS void IRQ121_Handler(void);
IRQ_HANDLER_ATTRS void IRQ122_Handler(void);
IRQ_HANDLER_ATTRS void IRQ123_Handler(void);
IRQ_HANDLER_ATTRS void IRQ124_Handler(void);
IRQ_HANDLER_ATTRS void IRQ125_Handler(void);
IRQ_HANDLER_ATTRS void IRQ126_Handler(void);
IRQ_HANDLER_ATTRS void IRQ127_Handler(void);
IRQ_HANDLER_ATTRS void IRQ128_Handler(void);
IRQ_HANDLER_ATTRS void IRQ129_Handler(void);
IRQ_HANDLER_ATTRS void IRQ130_Handler(void);
IRQ_HANDLER_ATTRS void IRQ131_Handler(void);
IRQ_HANDLER_ATTRS void IRQ132_Handler(void);
IRQ_HANDLER_ATTRS void IRQ133_Handler(void);
IRQ_HANDLER_ATTRS void IRQ134_Handler(void);
IRQ_HANDLER_ATTRS void IRQ135_Handler(void);
IRQ_HANDLER_ATTRS void IRQ136_Handler(void);
IRQ_HANDLER_ATTRS void IRQ137_Handler(void);
IRQ_HANDLER_ATTRS void IRQ138_Handler(void);
IRQ_HANDLER_ATTRS void IRQ139_Handler(void);
IRQ_HANDLER_ATTRS void IRQ140_Handler(void);
IRQ_HANDLER_ATTRS void IRQ141_Handler(void);
IRQ_HANDLER_ATTRS void IRQ142_Handler(void);
IRQ_HANDLER_ATTRS void IRQ143_Handler(void);
169 changes: 169 additions & 0 deletions cores/ddl/startup/interrupts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#ifndef __STARTUP_INTERRUPTS_H__
#define __STARTUP_INTERRUPTS_H__

#ifdef __cplusplus
extern "C"
{
#endif
extern void __default_handler();

extern void Reset_Handler(void);
extern void NMI_Handler(void);
extern void HardFault_Handler(void);
extern void MemManage_Handler(void);
extern void BusFault_Handler(void);
extern void UsageFault_Handler(void);
extern void SVC_Handler(void);
extern void DebugMon_Handler(void);
extern void PendSV_Handler(void);
extern void SysTick_Handler(void);

extern void IRQ000_Handler(void);
extern void IRQ001_Handler(void);
extern void IRQ002_Handler(void);
extern void IRQ003_Handler(void);
extern void IRQ004_Handler(void);
extern void IRQ005_Handler(void);
extern void IRQ006_Handler(void);
extern void IRQ007_Handler(void);
extern void IRQ008_Handler(void);
extern void IRQ009_Handler(void);
extern void IRQ010_Handler(void);
extern void IRQ011_Handler(void);
extern void IRQ012_Handler(void);
extern void IRQ013_Handler(void);
extern void IRQ014_Handler(void);
extern void IRQ015_Handler(void);
extern void IRQ016_Handler(void);
extern void IRQ017_Handler(void);
extern void IRQ018_Handler(void);
extern void IRQ019_Handler(void);
extern void IRQ020_Handler(void);
extern void IRQ021_Handler(void);
extern void IRQ022_Handler(void);
extern void IRQ023_Handler(void);
extern void IRQ024_Handler(void);
extern void IRQ025_Handler(void);
extern void IRQ026_Handler(void);
extern void IRQ027_Handler(void);
extern void IRQ028_Handler(void);
extern void IRQ029_Handler(void);
extern void IRQ030_Handler(void);
extern void IRQ031_Handler(void);
extern void IRQ032_Handler(void);
extern void IRQ033_Handler(void);
extern void IRQ034_Handler(void);
extern void IRQ035_Handler(void);
extern void IRQ036_Handler(void);
extern void IRQ037_Handler(void);
extern void IRQ038_Handler(void);
extern void IRQ039_Handler(void);
extern void IRQ040_Handler(void);
extern void IRQ041_Handler(void);
extern void IRQ042_Handler(void);
extern void IRQ043_Handler(void);
extern void IRQ044_Handler(void);
extern void IRQ045_Handler(void);
extern void IRQ046_Handler(void);
extern void IRQ047_Handler(void);
extern void IRQ048_Handler(void);
extern void IRQ049_Handler(void);
extern void IRQ050_Handler(void);
extern void IRQ051_Handler(void);
extern void IRQ052_Handler(void);
extern void IRQ053_Handler(void);
extern void IRQ054_Handler(void);
extern void IRQ055_Handler(void);
extern void IRQ056_Handler(void);
extern void IRQ057_Handler(void);
extern void IRQ058_Handler(void);
extern void IRQ059_Handler(void);
extern void IRQ060_Handler(void);
extern void IRQ061_Handler(void);
extern void IRQ062_Handler(void);
extern void IRQ063_Handler(void);
extern void IRQ064_Handler(void);
extern void IRQ065_Handler(void);
extern void IRQ066_Handler(void);
extern void IRQ067_Handler(void);
extern void IRQ068_Handler(void);
extern void IRQ069_Handler(void);
extern void IRQ070_Handler(void);
extern void IRQ071_Handler(void);
extern void IRQ072_Handler(void);
extern void IRQ073_Handler(void);
extern void IRQ074_Handler(void);
extern void IRQ075_Handler(void);
extern void IRQ076_Handler(void);
extern void IRQ077_Handler(void);
extern void IRQ078_Handler(void);
extern void IRQ079_Handler(void);
extern void IRQ080_Handler(void);
extern void IRQ081_Handler(void);
extern void IRQ082_Handler(void);
extern void IRQ083_Handler(void);
extern void IRQ084_Handler(void);
extern void IRQ085_Handler(void);
extern void IRQ086_Handler(void);
extern void IRQ087_Handler(void);
extern void IRQ088_Handler(void);
extern void IRQ089_Handler(void);
extern void IRQ090_Handler(void);
extern void IRQ091_Handler(void);
extern void IRQ092_Handler(void);
extern void IRQ093_Handler(void);
extern void IRQ094_Handler(void);
extern void IRQ095_Handler(void);
extern void IRQ096_Handler(void);
extern void IRQ097_Handler(void);
extern void IRQ098_Handler(void);
extern void IRQ099_Handler(void);
extern void IRQ100_Handler(void);
extern void IRQ101_Handler(void);
extern void IRQ102_Handler(void);
extern void IRQ103_Handler(void);
extern void IRQ104_Handler(void);
extern void IRQ105_Handler(void);
extern void IRQ106_Handler(void);
extern void IRQ107_Handler(void);
extern void IRQ108_Handler(void);
extern void IRQ109_Handler(void);
extern void IRQ110_Handler(void);
extern void IRQ111_Handler(void);
extern void IRQ112_Handler(void);
extern void IRQ113_Handler(void);
extern void IRQ114_Handler(void);
extern void IRQ115_Handler(void);
extern void IRQ116_Handler(void);
extern void IRQ117_Handler(void);
extern void IRQ118_Handler(void);
extern void IRQ119_Handler(void);
extern void IRQ120_Handler(void);
extern void IRQ121_Handler(void);
extern void IRQ122_Handler(void);
extern void IRQ123_Handler(void);
extern void IRQ124_Handler(void);
extern void IRQ125_Handler(void);
extern void IRQ126_Handler(void);
extern void IRQ127_Handler(void);
extern void IRQ128_Handler(void);
extern void IRQ129_Handler(void);
extern void IRQ130_Handler(void);
extern void IRQ131_Handler(void);
extern void IRQ132_Handler(void);
extern void IRQ133_Handler(void);
extern void IRQ134_Handler(void);
extern void IRQ135_Handler(void);
extern void IRQ136_Handler(void);
extern void IRQ137_Handler(void);
extern void IRQ138_Handler(void);
extern void IRQ139_Handler(void);
extern void IRQ140_Handler(void);
extern void IRQ141_Handler(void);
extern void IRQ142_Handler(void);
extern void IRQ143_Handler(void);

#ifdef __cplusplus
}
#endif
#endif // __STARTUP_INTERRUPTS_H__
Loading