优化串口
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
message("========use armv7_8.cmake")
|
message("========use armv7_8.cmake")
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -O0 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -DMKRTOS \
|
set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -Ofast -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -DMKRTOS \
|
||||||
-std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -u=_printf_float \
|
-std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -u=_printf_float \
|
||||||
-nostartfiles -nodefaultlibs -nostdlib -nostdinc \
|
-nostartfiles -nodefaultlibs -nostdlib -nostdinc \
|
||||||
-fno-stack-protector -Wl,--gc-section -D__ARM_ARCH_7M__ \
|
-fno-stack-protector -Wl,--gc-section -D__ARM_ARCH_7M__ \
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
|
|||||||
-Wno-unused-function \
|
-Wno-unused-function \
|
||||||
-Wno-unused-variable \
|
-Wno-unused-variable \
|
||||||
-Wno-builtin-declaration-mismatch \
|
-Wno-builtin-declaration-mismatch \
|
||||||
-Ofast \
|
|
||||||
")
|
")
|
||||||
|
|
||||||
|
# -Ofast \
|
||||||
# message(编译参数:${CMAKE_C_FLAGS})
|
# message(编译参数:${CMAKE_C_FLAGS})
|
||||||
|
|
||||||
# cortex-m 系列处理器采用相同的内核arch
|
# cortex-m 系列处理器采用相同的内核arch
|
||||||
|
|||||||
@@ -35,11 +35,15 @@ void uart_tigger(irq_entry_t *irq)
|
|||||||
{
|
{
|
||||||
/* read one byte from the receive data register */
|
/* read one byte from the receive data register */
|
||||||
q_enqueue(&queue, usart_data_receive(PRINT_USARTx));
|
q_enqueue(&queue, usart_data_receive(PRINT_USARTx));
|
||||||
|
usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, TRUE);
|
||||||
|
}
|
||||||
|
if (usart_interrupt_flag_get(PRINT_USARTx, USART_IDLEF_FLAG) != RESET)
|
||||||
|
{
|
||||||
if (irq->irq->wait_thread && thread_get_status(irq->irq->wait_thread) == THREAD_SUSPEND)
|
if (irq->irq->wait_thread && thread_get_status(irq->irq->wait_thread) == THREAD_SUSPEND)
|
||||||
{
|
{
|
||||||
thread_ready_remote(irq->irq->wait_thread, TRUE);
|
thread_ready_remote(irq->irq->wait_thread, TRUE);
|
||||||
}
|
}
|
||||||
|
usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +76,8 @@ void uart_init(void)
|
|||||||
usart_receiver_enable(PRINT_USARTx, TRUE);
|
usart_receiver_enable(PRINT_USARTx, TRUE);
|
||||||
|
|
||||||
usart_interrupt_enable(PRINT_USARTx, USART_RDBF_INT, TRUE);
|
usart_interrupt_enable(PRINT_USARTx, USART_RDBF_INT, TRUE);
|
||||||
|
usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, TRUE);
|
||||||
|
|
||||||
usart_enable(PRINT_USARTx, TRUE);
|
usart_enable(PRINT_USARTx, TRUE);
|
||||||
|
|
||||||
uart_is_init=1;
|
uart_is_init=1;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ typedef struct thread_wait_entry
|
|||||||
slist_head_t node;
|
slist_head_t node;
|
||||||
thread_t *th;
|
thread_t *th;
|
||||||
umword_t times;
|
umword_t times;
|
||||||
umword_t times_debug;
|
// umword_t times_debug;
|
||||||
} thread_wait_entry_t;
|
} thread_wait_entry_t;
|
||||||
void thread_check_timeout(void);
|
void thread_check_timeout(void);
|
||||||
thread_wait_entry_t *thread_sleep_del(thread_t *th);
|
thread_wait_entry_t *thread_sleep_del(thread_t *th);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ static inline void thread_wait_entry_init(thread_wait_entry_t *entry,
|
|||||||
slist_init(&entry->node);
|
slist_init(&entry->node);
|
||||||
entry->th = th;
|
entry->th = th;
|
||||||
entry->times = times;
|
entry->times = times;
|
||||||
entry->times_debug = 0;
|
// entry->times_debug = 0;
|
||||||
}
|
}
|
||||||
static void thread_timeout_init(void)
|
static void thread_timeout_init(void)
|
||||||
{
|
{
|
||||||
@@ -48,22 +48,27 @@ void thread_check_timeout(void)
|
|||||||
thread_wait_entry_t *next = slist_next_entry(
|
thread_wait_entry_t *next = slist_next_entry(
|
||||||
pos, (slist_head_t *)wait_list,
|
pos, (slist_head_t *)wait_list,
|
||||||
node);
|
node);
|
||||||
|
// pos->times_debug++;
|
||||||
pos->times_debug++;
|
|
||||||
if (pos->times != 0)
|
if (pos->times != 0)
|
||||||
{
|
{
|
||||||
pos->times--;
|
pos->times--;
|
||||||
|
// pos->times_debug = 0;
|
||||||
if (pos->times == 0)
|
if (pos->times == 0)
|
||||||
{
|
{
|
||||||
assert(pos->th->status == THREAD_SUSPEND);
|
assert(pos->th->status == THREAD_SUSPEND);
|
||||||
slist_del(&pos->node);
|
slist_del(&pos->node);
|
||||||
thread_ready(pos->th, TRUE);
|
thread_ready(pos->th, TRUE);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// if (pos->times_debug >= 3000)
|
||||||
|
// {
|
||||||
|
// printk("thread:0x%x block times %d.\n", pos->th, pos->times_debug);
|
||||||
|
// }
|
||||||
} // !< 如果是0,则一直休眠
|
} // !< 如果是0,则一直休眠
|
||||||
if (pos->times_debug%2000 == 0)
|
// if (pos->times_debug%2000 == 0)
|
||||||
{
|
// {
|
||||||
// printk("thread 0x%x block %d sec.\n", pos->th, pos->times_debug /1000);
|
// // printk("thread 0x%x block %d sec.\n", pos->th, pos->times_debug /1000);
|
||||||
}
|
// }
|
||||||
pos = next;
|
pos = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
export TOOLCHAIN=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/bin/
|
# export TOOLCHAIN=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/bin/
|
||||||
export TOOLCHAIN_LIB=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
|
# export TOOLCHAIN_LIB=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
|
||||||
|
|
||||||
# linux build
|
# linux build
|
||||||
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
|
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||||
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7e-m/fpu
|
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7e-m/fpu
|
||||||
|
|
||||||
# mac compile
|
# mac compile
|
||||||
# export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||||
# export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m+fp/softfp
|
export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m+fp/softfp
|
||||||
|
|
||||||
# windows compile
|
# windows compile
|
||||||
# export TOOLCHAIN=/d/GNUArmEmbeddedToolchain/102021.10/bin/
|
# export TOOLCHAIN=/d/GNUArmEmbeddedToolchain/102021.10/bin/
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "malloc_impl.h"
|
#include "malloc_impl.h"
|
||||||
|
#include "u_malloc.h"
|
||||||
void *aligned_alloc(size_t align, size_t len)
|
void *aligned_alloc(size_t align, size_t len)
|
||||||
{
|
{
|
||||||
unsigned char *mem, *new;
|
unsigned char *mem, *new;
|
||||||
@@ -19,9 +19,9 @@ void *aligned_alloc(size_t align, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (align <= SIZE_ALIGN)
|
if (align <= SIZE_ALIGN)
|
||||||
return malloc(len);
|
return u_malloc(len);
|
||||||
|
|
||||||
if (!(mem = malloc(len + align-1)))
|
if (!(mem = u_malloc(len + align-1)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
new = (void *)((uintptr_t)mem + align-1 & -align);
|
new = (void *)((uintptr_t)mem + align-1 & -align);
|
||||||
@@ -48,6 +48,6 @@ void *aligned_alloc(size_t align, size_t len)
|
|||||||
n->psize = c->csize = C_INUSE | (new-mem);
|
n->psize = c->csize = C_INUSE | (new-mem);
|
||||||
n->csize = t->psize -= new-mem;
|
n->csize = t->psize -= new-mem;
|
||||||
|
|
||||||
__bin_chunk(c);
|
u__bin_chunk(c);
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,5 +34,6 @@ struct bin {
|
|||||||
|
|
||||||
#define IS_MMAPPED(c) !((c)->csize & (C_INUSE))
|
#define IS_MMAPPED(c) !((c)->csize & (C_INUSE))
|
||||||
|
|
||||||
|
void u__bin_chunk(struct chunk *self);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
// #include "fork_impl.h"
|
// #include "fork_impl.h"
|
||||||
|
|
||||||
void u_free(void *p);
|
void u_free(void *p);
|
||||||
static void __bin_chunk(struct chunk *self);
|
|
||||||
// #define malloc __libc_malloc_impl
|
// #define malloc __libc_malloc_impl
|
||||||
// #define realloc __libc_realloc
|
// #define realloc __libc_realloc
|
||||||
// #define free __libc_free
|
// #define free __libc_free
|
||||||
@@ -400,7 +399,7 @@ void *u_realloc(void *p, size_t n)
|
|||||||
struct chunk *split = (void *)((char *)self + n);
|
struct chunk *split = (void *)((char *)self + n);
|
||||||
self->csize = split->psize = n | C_INUSE;
|
self->csize = split->psize = n | C_INUSE;
|
||||||
split->csize = next->psize = n0-n | C_INUSE;
|
split->csize = next->psize = n0-n | C_INUSE;
|
||||||
__bin_chunk(split);
|
u__bin_chunk(split);
|
||||||
return CHUNK_TO_MEM(self);
|
return CHUNK_TO_MEM(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,7 +432,7 @@ copy_free_ret:
|
|||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __bin_chunk(struct chunk *self)
|
void u__bin_chunk(struct chunk *self)
|
||||||
{
|
{
|
||||||
struct chunk *next = NEXT_CHUNK(self);
|
struct chunk *next = NEXT_CHUNK(self);
|
||||||
|
|
||||||
@@ -517,7 +516,7 @@ void u_free(void *p)
|
|||||||
if (IS_MMAPPED(self))
|
if (IS_MMAPPED(self))
|
||||||
unmap_chunk(self);
|
unmap_chunk(self);
|
||||||
else
|
else
|
||||||
__bin_chunk(self);
|
u__bin_chunk(self);
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
static void __malloc_donate(char *start, char *end)
|
static void __malloc_donate(char *start, char *end)
|
||||||
|
|||||||
@@ -85,8 +85,6 @@ static void console_read_func(void)
|
|||||||
if (!sys_tty.is_nl && L_ICANON(&sys_tty))
|
if (!sys_tty.is_nl && L_ICANON(&sys_tty))
|
||||||
{
|
{
|
||||||
tty_write_hw(&sys_tty);
|
tty_write_hw(&sys_tty);
|
||||||
// 规范模式下没有成一行
|
|
||||||
cons_read_unlock();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ int main(int args, char *argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
again:
|
again:
|
||||||
ret = ns_query_svr("/eth", &net_drv_hd, 0x1);
|
ret = ns_query_svr("/dev/eth", &net_drv_hd, 0x1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
// 0代表根节点
|
// 0代表根节点
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
printf("argv[%d]: %s\n", i, argv[i]);
|
printf("argv[%d]: %s\n", i, argv[i]);
|
||||||
}
|
}
|
||||||
exit(-1);
|
// exit(-1);
|
||||||
net_test();
|
net_test();
|
||||||
fs_test3();
|
fs_test3();
|
||||||
fs_test2();
|
fs_test2();
|
||||||
|
|||||||
@@ -96,9 +96,7 @@ int main(int argc, char *argv[])
|
|||||||
blk_drv_init(&net_drv);
|
blk_drv_init(&net_drv);
|
||||||
ret = rpc_meta_init_def(TASK_THIS, &hd);
|
ret = rpc_meta_init_def(TASK_THIS, &hd);
|
||||||
assert(ret >= 0);
|
assert(ret >= 0);
|
||||||
// fs_svr_init();
|
ns_register("/dev/eth", hd, 0);
|
||||||
// mkdir("/dev", 0777);
|
|
||||||
ns_register("/eth", hd, 0);
|
|
||||||
meta_reg_svr_obj(&net_drv.svr, BLK_DRV_PROT);
|
meta_reg_svr_obj(&net_drv.svr, BLK_DRV_PROT);
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user