添加coremark romlib dtest

This commit is contained in:
2025-06-26 11:09:45 +08:00
parent 9588134f2c
commit aaba0e5991
4 changed files with 286 additions and 6 deletions

View File

@@ -0,0 +1,63 @@
# OUTPUT type
# 1 - .out
# 2 - .a
# 3 - .so
OUTPUT_TYPE = 1
OUTPUT_NAME = kl3_romlib_test
#SUB_DIRS = $(TOPDIR)/common/os_shim/dtestos
SUB_DIRS = $(TOPDIR)/dtest/dtest3/common
# .h files dir
ADD_INCLUDE += $(TOPDIR)/plc/halphy/inc $(TOPDIR)/inc/compiler/gcc $(TOPDIR)/common/io_lib/inc $(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 $(TOPDIR)/driver/inc/pib
PRE_MARCO += _MODULE_NAME_=\"LEDC\" _MODULE_VERSION_=\"V1.0.0\"
LD_SCRIPT = link_soc.lds
OPT_FLAG = -Os -Wno-error=int-conversion
ifeq ($(gcc), arm)
ADD_INCLUDE += $(TOPDIR)/os/freertos/src/portable/ARM_CM3
else
ADD_INCLUDE += $(TOPDIR)/os/freertos/src/portable/RISCV $(TOPDIR)/dtest/dtest3/common
endif
ifeq ($(gcc),arm)
ADD_LIB = cm3
ADD_LIBDIR = $(TOPDIR)/startup/cm3
else
ifeq ($(target), kunlun3)
ADD_LIB = riscv
ADD_LIBDIR =$(TOPDIR)/startup/riscv3
ADD_INCLUDE += $(TOPDIR)/driver/src/hw3/inc
endif
endif
# lib dir
ADD_LIBDIR += $(TOPDIR)/driver $(TOPDIR)/common $(TOPDIR)/os
# lib need to ld together
ADD_LIB += os 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,140 @@
#include "os_types.h"
#include "dbg_io.h"
#include "iot_io.h"
#include "cpu.h"
#include "watchdog.h"
// #include "platform.h"
#include "iot_gptmr_api.h"
#include "iot_clock.h"
#include "clk.h"
#include "strformat.h"
#include "uart.h"
#include "string.h"
typedef int (*iot_sprintf_t)(char* str, const char* format, ...);
typedef int (*iot_snprintf_t)(char* str, size_t size, const char* format, ...);
typedef int (*iot_vsnprintf_t)(char* str, size_t size, const char* format, va_list ap);
typedef int32_t (*iot_printf_t)(const char* fmt, ...);
typedef int (*format_str_t)(const str_format_context* ctxt, const char* format, ...);
typedef int (*format_str_v_t)(const str_format_context* ctxt, const char* format, va_list ap);
typedef void* (*memmove_t)(void* dest, const void* src, size_t n);
iot_sprintf_t rom_iot_sprintf;
iot_snprintf_t rom_iot_snprintf;
iot_vsnprintf_t rom_iot_vsnprintf;
iot_printf_t rom_iot_printf;
iot_printf_t dtest_iot_printf;
format_str_t rom_format_str;
format_str_v_t rom_format_str_v;
str_format_context* rom_log_ctxt;
extern struct uart_ctrl uart_e_ctrl;
memmove_t rom_memmove;
#define PROVIDE(s) rom_##s
#define PUT_PORT 0
static void uart_flush(void)
{
while (uart_e_ctrl.tx_fifo_cnt(PUT_PORT)) __asm volatile("nop\n");
return;
}
static StrFormatResult uart_puts(void *user_data, const char *data, unsigned int len)
{
(void)user_data;
uint8_t c;
int i = 0;
while (i < len) {
c = *(data+i);
if (c == '\n'){
uart_e_ctrl.try_putc(PUT_PORT,'\r');
}
uart_e_ctrl.try_putc(PUT_PORT,c);
i++;
}
uart_flush();
return 0;
}
int rom_iot_vsnprintf_test(char *str, size_t size, const char *format, ...)
{
int res;
va_list ap;
va_start(ap, format);
res = rom_iot_vsnprintf(str, size, format, ap);
va_end(ap);
return res;
}
#pragma GCC diagnostic ignored "-Wint-conversion"
void fun_pointer_init() {
PROVIDE(iot_sprintf = 0x0004455e);
PROVIDE(iot_printf = 0x00044616);
PROVIDE(iot_snprintf = 0x000445f6);
PROVIDE(iot_vsnprintf = 0x000445ca);
PROVIDE(log_ctxt = 0x100005a4);
PROVIDE(format_str = 0x0004451e);
PROVIDE(format_str_v = 0x0004451e);
PROVIDE(memmove = 0x0004654e);
rom_log_ctxt->write_str = uart_puts;
dtest_iot_printf = (int)&iot_printf;
}
int rom_format_str_v_test(const char *format, ...)
{
int res;
va_list ap;
va_start(ap, format);
res = rom_format_str_v(rom_log_ctxt, format, ap);
va_end(ap);
return res;
}
static char g_buff[1024];
static char g_buff2[1024];
int main(void) {
iot_interrupt_init();
dbg_uart_init();
clk_core_init();
clk_core_freq_set(CLK_FRQ_150M);
fun_pointer_init();
iot_printf("print by iot_printf()\n");
dtest_iot_printf("print by dtest_iot_printf()\n");
iot_snprintf(g_buff, 1024, "print by iot_snprintf()\n");
iot_printf("%s", g_buff);
rom_iot_snprintf(g_buff, 1024, "print by rom_iot_snprintf()\n");
iot_printf("%s", g_buff);
rom_iot_vsnprintf_test(g_buff, 1024, "print by rom_iot_vsnprintf()\n");
iot_printf("%s", g_buff);
iot_printf("rom_iot_printf() test\n");
rom_iot_printf("print by rom_iot_printf()\n");
iot_printf("rom_format_str() test\n");
rom_format_str(rom_log_ctxt, "print by rom_format_str()\n");
iot_printf("rom_format_str_v() test\n");
rom_format_str_v_test("print by rom_format_str_v()\n");
iot_printf("print test end\n");
memmove(g_buff, g_buff2, 1024);
iot_printf("%s", g_buff);
rom_memmove(g_buff, "print by rom_memmove()\n", 24);
iot_printf("%s", g_buff);
while (1);
}