From 72cfe9dd686d5b3568173fbe6b5509fd7e072fca Mon Sep 17 00:00:00 2001 From: zhangjun <2281979437@qq.com> Date: Mon, 31 Jul 2017 12:05:45 +0800 Subject: [PATCH] =?UTF-8?q?modify=EF=BC=9A=20=20=20=20=20drivers/cpuusage.?= =?UTF-8?q?c=20modify=EF=BC=9A=20=20=20=20=20../../libcpu/risc-v/e310/stac?= =?UTF-8?q?k.c=20=09rmove=20unused=20macro=20definition=20modify=EF=BC=9A?= =?UTF-8?q?=20=20=20=20=20../../src/idle.c=20=09Return=20to=20the=20origin?= =?UTF-8?q?al=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/hifive1/Makefile | 126 --------------------------------- bsp/hifive1/drivers/cpuusage.c | 2 +- libcpu/risc-v/e310/stack.c | 16 +---- src/idle.c | 1 - 4 files changed, 3 insertions(+), 142 deletions(-) delete mode 100644 bsp/hifive1/Makefile diff --git a/bsp/hifive1/Makefile b/bsp/hifive1/Makefile deleted file mode 100644 index b7def9d3f3..0000000000 --- a/bsp/hifive1/Makefile +++ /dev/null @@ -1,126 +0,0 @@ -PREFIX = /home/zj/risc-v/riscv64-unknown-elf-gcc-20170612-x86_64-linux-centos6/bin/riscv64-unknown-elf- -CC = $(PREFIX)gcc -CPP = $(PREFIX)g++ -AS = $(PREFIX)gcc -AR = $(PREFIX)ar -LINK = $(PREFIX)gcc -SIZE = $(PREFIX)size -OBJDUMP = $(PREFIX)objdump -OBJCPY = $(PREFIX)objcopy -GDB = $(PREFIX)gdb -OPENOCD = /home/zj/risc-v/riscv-openocd-20170612-x86_64-linux-centos6/bin/openocd - -LIBS = -DEVICE = -mcpu=arm926ej-s -ffunction-sections -fdata-sections -CFLAGS = $(DEVICE) $(patsubst %, -I"%", $(CPATH)) -CXXFLAGS= $(CFLAGS) -AFLAGS = $(DEVICE) -c -x assembler-with-cpp -LFLAGS = $(DEVICE) -Wl,-Map=$(TARGET).map,-cref,-u,Reset_Handler \ - -T "ld" -nostartfiles $(patsubst %, -l%, $(LIBS)) \ - $(patsubst %, -L"%", $(LPATH)) - -CPATH = -LPATH = -################################################################ -BUILD = debug -#BUILD = release -#BUILD_LIB = yes -BUILD_LIB = no -################################################################ - -ifeq '$(BUILD)' 'debug' - CFLAGS += -O0 -gdwarf-2 - AFLAGS += -gdwarf-2 -else - CFLAGS += -O2 -endif - -ROOT_DIR = $(shell pwd) -SUB_DIR = ${shell ls -l "${ROOT_DIR}" | grep ^d | awk '{if($$9 != "build") print $$9 }'} -################################################################ -BUILD_DIR = $(ROOT_DIR)/build/$(BUILD) -BUILD_LIB_DIR =$(LPATH) -################################################################ -TARGET = rtthread -export CC CPP AS AR LINK SIZE OBJDUMP OBJCPY DEVICE CFLAGS CXXFLAGS ASFLAGS LFLAGS ROOT_DIR \ - BUILD BUILD_DIR BUILD_LIB_DIR - -SRC_FILE = ${wildcard *.c} -SRC_FILE += ${wildcard *.cpp} -SRC_FILE += ${wildcard *.s} -#SRC_FILE = ${shell ls *.c} -#OBJ_FILE = ${SRC_FILE:.c=.o} -TMP = ${patsubst %.c, %.o, ${SRC_FILE}} -TMP += ${patsubst %.cpp, %.o, ${SRC_FILE}} -TMP += ${patsubst %.s, %.o, ${SRC_FILE}} -OBJ_FILE = $(filter %.o, $(TMP)) - - -# Attempt to create a output directory. -$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}) -# Verify if it was successful. -BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd) -$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist)) - -#all: $(TARGET) -all: - scons -j4 - #${SIZE} -d "$(TARGET).axf" - ${OBJDUMP} -S -D "$(TARGET).axf" > "${TARGET}.s" - - -$(SUB_DIR):ECHO - -make -C "${ROOT_DIR}/$@" - -%.o:%.cpp - ${CPP} ${CXXFLAGS} -c "$^" -o "${BUILD_DIR}/$@" - -%.o:%.c - ${CC} ${CFLAGS} -c "$^" -o "${BUILD_DIR}/$@" - -%.o:%.s - ${AS} ${ASFLAGS} -c "$^" -o "${BUILD_DIR}/$@" - -ifneq "$(BUILD_LIB)" "yes" - -$(TARGET): $(SUB_DIR) $(OBJ_FILE) - cd "${BUILD_DIR}" && ${CC} $(filter %.o, $(shell ls "$(BUILD_DIR)")) ${LFLAGS} -o "$(ROOT_DIR)/$(TARGET)" - ${OBJCPY} -I elf32-littlearm -O ihex $(TARGET) $(TARGET).hex - ${OBJCPY} -I elf32-littlearm -O binary $(TARGET) $(TARGET).bin - ${SIZE} -d "$(TARGET)" - -else - -$(TARGET): $(SUB_DIR) $(OBJ_FILE) - cd "${BUILD_DIR}" && ${AR} -rc "$(BUILD_LIB_DIR)/lib${TARGET}.a" $(filter %.o, $(shell ls "$(BUILD_DIR)")) - -endif - -ECHO: - @echo ${SUB_DIR} - - -DEBUG_INTERFACE = jlink -#DEBUG_INTERFACE = stlink-v2 -#DEBUG_INTERFACE = ftdi/openjtag - -GDB_CMD = -ex "tar ext 127.0.0.1:3333" -#GDB_CMD += -ex "monitor reset halt" -#GDB_CMD += -ex "monitor step 0x20400000" -GDB_CMD += --command=.gdbinit - -run: - setsid ${OPENOCD} > /dev/null 2>&1 & - ${GDB} ${TARGET}.axf ${GDB_CMD} - killall -9 openocd - -programe: - setsid ${OPENOCD} > /dev/null 2>&1 & - ${GDB} ${TARGET}.axf -ex "tar ext 127.0.0.1:3333" -ex "monitor step 0x20400000" -ex "load ${TARGET}.axf" - killall -9 openocd - -clean: - -cd "${BUILD_DIR}" && rm * - -rm stm32* - -.PHONY: all diff --git a/bsp/hifive1/drivers/cpuusage.c b/bsp/hifive1/drivers/cpuusage.c index 5fe58a8bb8..659c2807d6 100644 --- a/bsp/hifive1/drivers/cpuusage.c +++ b/bsp/hifive1/drivers/cpuusage.c @@ -7,7 +7,7 @@ static rt_uint32_t idle_begin = 0,idle_count = 0; static rt_uint32_t run_begin = 0,run_count = 0; static rt_uint32_t update_tick = 0; static wtdog_count = 0; -#define jiffies 0 +#define jiffies rt_tick_get() void cpu_usage_idle_hook() { diff --git a/libcpu/risc-v/e310/stack.c b/libcpu/risc-v/e310/stack.c index eab608c753..a86fae70ff 100644 --- a/libcpu/risc-v/e310/stack.c +++ b/libcpu/risc-v/e310/stack.c @@ -19,22 +19,10 @@ * * Change Logs: * Date Author Notes - * 2011-01-13 weety copy from mini2440 + * 2017-07-31 zhangjun copy from mini2440 */ #include -/*****************************/ -/* CPU Mode */ -/*****************************/ -#define USERMODE 0x10 -#define FIQMODE 0x11 -#define IRQMODE 0x12 -#define SVCMODE 0x13 -#define ABORTMODE 0x17 -#define UNDEFMODE 0x1b -#define MODEMASK 0x1f -#define NOINT 0xc0 - /** * This function will initialize thread stack * @@ -86,7 +74,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, *(--stk) = 0xffffffff; /* t6 */ *(--stk) = 0xffffffff; /* tp */ *(--stk) = 0xffffffff; /* gp */ - *(--stk) = 0x880; /* mie */ + *(--stk) = 0x880; /* mie */ // *(--stk) = (rt_uint32_t)parameter; /* r0 : argument */ /* return task's current stack address */ return (rt_uint8_t *)stk; diff --git a/src/idle.c b/src/idle.c index 7373f280e1..db87baa484 100644 --- a/src/idle.c +++ b/src/idle.c @@ -183,7 +183,6 @@ void rt_thread_idle_excute(void) static void rt_thread_idle_entry(void *parameter) { - rt_hw_interrupt_enable(0x888); while (1) { #ifdef RT_USING_IDLE_HOOK