初始提交

This commit is contained in:
2024-09-28 14:24:04 +08:00
commit c756587541
5564 changed files with 2413077 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
# OUTPUT type
# 1 - .out
# 2 - .a
# 3 - .so
OUTPUT_TYPE = 1
OUTPUT_NAME = exception_test
SUB_DIRS =
# .h files dir
ADD_INCLUDE += $(TOPDIR)/plc/halphy/inc $(TOPDIR)/inc/compiler/gcc $(TOPDIR)/inc $(TOPDIR)/inc/io_lib $(TOPDIR)/inc/driver $(TOPDIR)/inc/uart $(TOPDIR)/inc/plc_lib $(TOPDIR)/inc/ipc $(TOPDIR)/inc/os_shim $(TOPDIR)/inc/pkt $(TOPDIR)/inc/utils $(TOPDIR)/plc/inc $(TOPDIR)/inc/cli $(TOPDIR)/cli/communicator $(TOPDIR)/inc/dbglog $(TOPDIR)/inc/ftm $(TOPDIR)/plc/halmac/inc $(TOPDIR)/plc/halmac/hw/inc/desc $(TOPDIR)/driver/inc
# predefined macro
PRE_MARCO =
OPT_FLAG = -O0
ifeq ($(gcc), arm)
ADD_INCLUDE += $(TOPDIR)/os/freertos/src/portable/ARM_CM3
else
ADD_INCLUDE += $(TOPDIR)/os/freertos/src/portable/RISCV
endif
ifeq ($(gcc),arm)
ADD_LIB = cm3
ADD_LIBDIR = $(TOPDIR)/startup/cm3
else
ifeq ($(target), kunlun2)
ADD_LIB = riscv
ADD_LIBDIR =$(TOPDIR)/startup/riscv2
ADD_INCLUDE += $(TOPDIR)/driver/src/hw2/inc
else
ADD_LIB = riscv
ADD_LIBDIR =$(TOPDIR)/startup/riscv
ADD_INCLUDE += $(TOPDIR)/driver/src/hw/inc
endif
endif
# lib dir
ADD_LIBDIR += $(TOPDIR)/plc $(TOPDIR)/driver $(TOPDIR)/common $(TOPDIR)/os
# lib need to ld together
ADD_LIB += os plc driver common
#####################################################
ifdef TOPDIR
include $(TOPDIR)/build/makefile.cfg
else
include $(CURDIR)/build/makefile.cfg
TOPDIR = $(CURDIR)
export TOPDIR
endif
dump:
$(OBJDUMP) -D -S -l $(OUTPUT_FULL_NAME) > $(OUTPUT_FULL_NAME).dump
# display the obj files and output name
debug:
@echo TOPDIR=$(TOPDIR)
@echo OUTPUT_LIB=$(OUTPUT_FULL_NAME)
@echo DEPS=$(DEPS)
@echo OBJECTS=$(OBJECTS)
@echo SRCS=$(SRCS)
@echo OBJECTS folder=$(foreach dirname, $(SUB_DIRS), $(addprefix $(BIN_DIR)/, $(dirname)))
@echo output_name=$(OUTPUT_FULL_NAME)

View File

@@ -0,0 +1,192 @@
/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
/* os shim includes */
#include "os_types.h"
#include "os_task.h"
#include "os_utils.h"
/* common includes */
#include "iot_io.h"
#include "iot_bitops.h"
#include "iot_config.h"
/* driver includes */
#include "iot_clock.h"
#include "iot_uart.h"
/* cli includes */
#include "iot_uart_h.h"
/* debug includes*/
#include "dbg_io.h"
extern int platform_init();
os_task_h test_init_handle;
void addr_invalid()
{
volatile uint32_t *reg = (volatile uint32_t *) 0x620000c0;
*reg &= ~0x2;
iot_printf("reg: %08x\n", *reg);
int *buf = (int *)0xffe0000;
//*buf = 0xaabbccdd;
iot_printf("align test a: %08x\r\n", *(buf));
}
void misalign_access()
{
uint32_t addr = 0x1003ffd1;
iot_printf("addr: %08x\n", addr);
volatile uint32_t *a = (volatile uint32_t *) addr;
//*a = 0xaabb;
//*(a+1) = 0xccdd;
iot_printf("align test a: %08x\r\n", *(a));
iot_printf("align test a: %08x\r\n", *(a+1));
}
void instruction_illegal()
{
void (*pgm_start)(void) = (void*) 0x001003d1;
pgm_start();
}
void invalid_instruction_access()
{
void (*pgm_start)(void) = (void*) 0x80000040;
pgm_start();
}
void exception_test(void)
{
#if 1
iot_printf("invalid_instruction_access\n");
invalid_instruction_access();
#endif
#if 1
iot_printf("instruction_illegal\n");
instruction_illegal();
#endif
#if 1
iot_printf("misalign_access\n");
misalign_access();
#endif
#if 1
iot_printf("addr_invalid\n");
addr_invalid();
#endif
}
void test_init()
{
/* init common modules */
iot_bitops_init();
/* init os related modules and utilities */
os_utils_init();
/*init uart module*/
iot_uart_init(1);
exception_test();
}
void iot_task_1(void *arg)
{
iot_printf("task 1 entry....\n");
for(;;) {
test_init();
os_delete_task(test_init_handle);
}
}
int32_t iot_task_init()
{
/* start plc lib task */
test_init_handle = os_create_task(iot_task_1, NULL, 9);
//create the tasks;
if(test_init_handle != NULL) {
iot_printf("task 1 init successfully...\n");
}
return 0;
}
int32_t iot_task_start()
{
//start the tasks;
os_start_kernel();
return 0;
}
static int32_t iot_platform_init()
{
/*platform intialization*/
platform_init();
//resource initializations;
system_clock_init();
system_uart_init();
dbg_uart_init();
dbg_uart_stage1_init();
return 0;
}
int32_t iot_module_init(void)
{
//platform intialization;
iot_platform_init();
//create all the tasks;
iot_task_init();
iot_printf("starting...\n");
return 0;
}
int32_t iot_module_start(void)
{
int32_t res = 0;
res = iot_task_start();
return res;
}
#include "apb_dma.h"
int main(void)
{
//module init;
iot_module_init();
iot_module_start();
return 0;
}