优化串口
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include "malloc_impl.h"
|
||||
|
||||
#include "u_malloc.h"
|
||||
void *aligned_alloc(size_t align, size_t len)
|
||||
{
|
||||
unsigned char *mem, *new;
|
||||
@@ -19,9 +19,9 @@ void *aligned_alloc(size_t align, size_t len)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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->csize = t->psize -= new-mem;
|
||||
|
||||
__bin_chunk(c);
|
||||
u__bin_chunk(c);
|
||||
return new;
|
||||
}
|
||||
|
||||
@@ -34,5 +34,6 @@ struct bin {
|
||||
|
||||
#define IS_MMAPPED(c) !((c)->csize & (C_INUSE))
|
||||
|
||||
void u__bin_chunk(struct chunk *self);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
// #include "fork_impl.h"
|
||||
|
||||
void u_free(void *p);
|
||||
static void __bin_chunk(struct chunk *self);
|
||||
// #define malloc __libc_malloc_impl
|
||||
// #define realloc __libc_realloc
|
||||
// #define free __libc_free
|
||||
@@ -400,7 +399,7 @@ void *u_realloc(void *p, size_t n)
|
||||
struct chunk *split = (void *)((char *)self + n);
|
||||
self->csize = split->psize = n | C_INUSE;
|
||||
split->csize = next->psize = n0-n | C_INUSE;
|
||||
__bin_chunk(split);
|
||||
u__bin_chunk(split);
|
||||
return CHUNK_TO_MEM(self);
|
||||
}
|
||||
|
||||
@@ -433,7 +432,7 @@ copy_free_ret:
|
||||
return new;
|
||||
}
|
||||
|
||||
static void __bin_chunk(struct chunk *self)
|
||||
void u__bin_chunk(struct chunk *self)
|
||||
{
|
||||
struct chunk *next = NEXT_CHUNK(self);
|
||||
|
||||
@@ -517,7 +516,7 @@ void u_free(void *p)
|
||||
if (IS_MMAPPED(self))
|
||||
unmap_chunk(self);
|
||||
else
|
||||
__bin_chunk(self);
|
||||
u__bin_chunk(self);
|
||||
}
|
||||
#if 0
|
||||
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))
|
||||
{
|
||||
tty_write_hw(&sys_tty);
|
||||
// 规范模式下没有成一行
|
||||
cons_read_unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ int main(int args, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
again:
|
||||
ret = ns_query_svr("/eth", &net_drv_hd, 0x1);
|
||||
ret = ns_query_svr("/dev/eth", &net_drv_hd, 0x1);
|
||||
if (ret < 0)
|
||||
{
|
||||
// 0代表根节点
|
||||
|
||||
@@ -19,7 +19,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
printf("argv[%d]: %s\n", i, argv[i]);
|
||||
}
|
||||
exit(-1);
|
||||
// exit(-1);
|
||||
net_test();
|
||||
fs_test3();
|
||||
fs_test2();
|
||||
|
||||
@@ -96,9 +96,7 @@ int main(int argc, char *argv[])
|
||||
blk_drv_init(&net_drv);
|
||||
ret = rpc_meta_init_def(TASK_THIS, &hd);
|
||||
assert(ret >= 0);
|
||||
// fs_svr_init();
|
||||
// mkdir("/dev", 0777);
|
||||
ns_register("/eth", hd, 0);
|
||||
ns_register("/dev/eth", hd, 0);
|
||||
meta_reg_svr_obj(&net_drv.svr, BLK_DRV_PROT);
|
||||
while (1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user