提交 6b31d549 编写于 作者: B bernard.xiong@gmail.com

cleanup some comments.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1898 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 a54b523e
...@@ -30,16 +30,12 @@ extern "C" { ...@@ -30,16 +30,12 @@ extern "C" {
*/ */
/*@{*/ /*@{*/
/** /* RT-Thread version information */
* RT-Thread version information
*/
#define RT_VERSION 1L /**< major version number */ #define RT_VERSION 1L /**< major version number */
#define RT_SUBVERSION 0L /**< minor version number */ #define RT_SUBVERSION 0L /**< minor version number */
#define RT_REVISION 0L /**< revise version number */ #define RT_REVISION 0L /**< revise version number */
/** /* RT-Thread basic data type definitions */
* RT-Thread basic data type definitions
*/
typedef signed char rt_int8_t; /**< 8bit integer type */ typedef signed char rt_int8_t; /**< 8bit integer type */
typedef signed short rt_int16_t; /**< 16bit integer type */ typedef signed short rt_int16_t; /**< 16bit integer type */
typedef signed long rt_int32_t; /**< 32bit integer type */ typedef signed long rt_int32_t; /**< 32bit integer type */
...@@ -60,9 +56,7 @@ typedef rt_ubase_t rt_size_t; /**< Type for size numbe ...@@ -60,9 +56,7 @@ typedef rt_ubase_t rt_size_t; /**< Type for size numbe
typedef rt_ubase_t rt_dev_t; /**< Type for device */ typedef rt_ubase_t rt_dev_t; /**< Type for device */
typedef rt_base_t rt_off_t; /**< Type for offset */ typedef rt_base_t rt_off_t; /**< Type for offset */
/** /* boolean type definitions */
* boolean type definitions
*/
#define RT_TRUE 1 /**< boolean true */ #define RT_TRUE 1 /**< boolean true */
#define RT_FALSE 0 /**< boolean fails */ #define RT_FALSE 0 /**< boolean fails */
/*@}*/ /*@}*/
...@@ -140,7 +134,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset ...@@ -140,7 +134,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset
* @addtogroup Error * @addtogroup Error
*/ */
/*@{*/ /*@{*/
/** RT-Thread error code definitions */ /* RT-Thread error code definitions */
#define RT_EOK 0 /**< There is no error */ #define RT_EOK 0 /**< There is no error */
#define RT_ERROR 1 /**< A generic error happens */ #define RT_ERROR 1 /**< A generic error happens */
#define RT_ETIMEOUT 2 /**< Timed out */ #define RT_ETIMEOUT 2 /**< Timed out */
...@@ -395,11 +389,11 @@ struct rt_thread ...@@ -395,11 +389,11 @@ struct rt_thread
rt_ubase_t init_tick; /**< thread's initialized tick */ rt_ubase_t init_tick; /**< thread's initialized tick */
rt_ubase_t remaining_tick; /**< remaining tick */ rt_ubase_t remaining_tick; /**< remaining tick */
struct rt_timer thread_timer; /**< thread timer */ struct rt_timer thread_timer; /**< built-in thread timer */
void (*cleanup)(struct rt_thread *tid); /**< cleanup function when thread exit */ void (*cleanup)(struct rt_thread *tid); /**< cleanup function when thread exit */
rt_uint32_t user_data; /**< user data */ rt_uint32_t user_data; /**< private user data beyond this thread */
}; };
/*@}*/ /*@}*/
...@@ -409,7 +403,7 @@ struct rt_thread ...@@ -409,7 +403,7 @@ struct rt_thread
/*@{*/ /*@{*/
/** /**
* IPC flags and control command defitions * IPC flags and control command definitions
*/ */
#define RT_IPC_FLAG_FIFO 0x00 /**< FIFOed IPC. @ref IPC. */ #define RT_IPC_FLAG_FIFO 0x00 /**< FIFOed IPC. @ref IPC. */
#define RT_IPC_FLAG_PRIO 0x01 /**< PRIOed IPC. @ref IPC. */ #define RT_IPC_FLAG_PRIO 0x01 /**< PRIOed IPC. @ref IPC. */
...@@ -497,7 +491,7 @@ struct rt_mailbox ...@@ -497,7 +491,7 @@ struct rt_mailbox
rt_uint16_t entry; /**< index of messages in msg_pool */ rt_uint16_t entry; /**< index of messages in msg_pool */
rt_uint16_t in_offset, out_offset; /**< in/output offset of the message buffer */ rt_uint16_t in_offset, out_offset; /**< in/output offset of the message buffer */
rt_list_t suspend_sender_thread; /**< sender thread suspended on this mb */ rt_list_t suspend_sender_thread; /**< sender thread suspended on this mailbox */
}; };
typedef struct rt_mailbox *rt_mailbox_t; typedef struct rt_mailbox *rt_mailbox_t;
#endif #endif
......
...@@ -73,8 +73,9 @@ rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc) ...@@ -73,8 +73,9 @@ rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc)
* This function will suspend a thread to a specified list. IPC object or some double-queue * This function will suspend a thread to a specified list. IPC object or some double-queue
* object (mailbox etc.) contains this kind of list. * object (mailbox etc.) contains this kind of list.
* *
* @param ipc the IPC object * @param list the IPC suspended thread list
* @param thread the thread object to be suspended * @param thread the thread object to be suspended
* @param flag the IPC object flag, which shall be RT_IPC_FLAG_FIFO/RT_IPC_FLAG_PRIO.
* *
* @return the operation status, RT_EOK on successful * @return the operation status, RT_EOK on successful
*/ */
...@@ -1352,7 +1353,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout) ...@@ -1352,7 +1353,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout)
rt_hw_interrupt_enable(temp); rt_hw_interrupt_enable(temp);
return -RT_EFULL; return -RT_EFULL;
} }
RT_DEBUG_NOT_IN_INTERRUPT; RT_DEBUG_NOT_IN_INTERRUPT;
/* suspend current thread */ /* suspend current thread */
rt_ipc_list_suspend(&(mb->suspend_sender_thread), thread, mb->parent.parent.flag); rt_ipc_list_suspend(&(mb->suspend_sender_thread), thread, mb->parent.parent.flag);
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#define IS_AX(s) ((s.sh_flags & SHF_ALLOC) && (s.sh_flags & SHF_EXECINSTR)) #define IS_AX(s) ((s.sh_flags & SHF_ALLOC) && (s.sh_flags & SHF_EXECINSTR))
#define IS_AW(s) ((s.sh_flags & SHF_ALLOC) && (s.sh_flags & SHF_WRITE)) #define IS_AW(s) ((s.sh_flags & SHF_ALLOC) && (s.sh_flags & SHF_WRITE))
#define PAGE_COUNT_MAX 256 #define PAGE_COUNT_MAX 256
/* module memory allocator */ /* module memory allocator */
struct rt_mem_head struct rt_mem_head
...@@ -68,11 +68,11 @@ static char *_strip_name(const char *string) ...@@ -68,11 +68,11 @@ static char *_strip_name(const char *string)
int i = 0, p = 0, q = 0; int i = 0, p = 0, q = 0;
const char *str = string; const char *str = string;
char *dest = RT_NULL; char *dest = RT_NULL;
while (*str != '\n' && *str != '\0') while (*str != '\n' && *str != '\0')
{ {
if (*str =='/' ) p = i + 1; if (*str =='/' ) p = i + 1;
if (*str == '.') q = i; if (*str == '.') q = i;
str++; i++; str++; i++;
} }
...@@ -204,7 +204,7 @@ static int rt_module_arm_relocate(struct rt_module *module, Elf32_Rel *rel, Elf3 ...@@ -204,7 +204,7 @@ static int rt_module_arm_relocate(struct rt_module *module, Elf32_Rel *rel, Elf3
RT_DEBUG_LOG(RT_DEBUG_MODULE, RT_DEBUG_LOG(RT_DEBUG_MODULE,
("R_ARM_GOT_BREL: 0x%x -> 0x%x 0x%x\n", where, *where, sym_val)); ("R_ARM_GOT_BREL: 0x%x -> 0x%x 0x%x\n", where, *where, sym_val));
break; break;
#endif #endif
case R_ARM_RELATIVE: case R_ARM_RELATIVE:
*where += (Elf32_Addr)sym_val; *where += (Elf32_Addr)sym_val;
//RT_DEBUG_LOG(RT_DEBUG_MODULE, //RT_DEBUG_LOG(RT_DEBUG_MODULE,
...@@ -225,14 +225,14 @@ static int rt_module_arm_relocate(struct rt_module *module, Elf32_Rel *rel, Elf3 ...@@ -225,14 +225,14 @@ static int rt_module_arm_relocate(struct rt_module *module, Elf32_Rel *rel, Elf3
if (offset & 0x01000000) if (offset & 0x01000000)
offset -= 0x02000000; offset -= 0x02000000;
offset += sym_val - (Elf32_Addr)where; offset += sym_val - (Elf32_Addr)where;
if (!(offset & 1) || offset <= (rt_int32_t)0xff000000 || if (!(offset & 1) || offset <= (rt_int32_t)0xff000000 ||
offset >= (rt_int32_t)0x01000000) offset >= (rt_int32_t)0x01000000)
{ {
rt_kprintf("only Thumb addresses allowed\n"); rt_kprintf("only Thumb addresses allowed\n");
return -1; return -1;
} }
sign = (offset >> 24) & 1; sign = (offset >> 24) & 1;
j1 = sign ^ (~(offset >> 23) & 1); j1 = sign ^ (~(offset >> 23) & 1);
j2 = sign ^ (~(offset >> 22) & 1); j2 = sign ^ (~(offset >> 22) & 1);
...@@ -243,7 +243,7 @@ static int rt_module_arm_relocate(struct rt_module *module, Elf32_Rel *rel, Elf3 ...@@ -243,7 +243,7 @@ static int rt_module_arm_relocate(struct rt_module *module, Elf32_Rel *rel, Elf3
((offset >> 1) & 0x07ff)); ((offset >> 1) & 0x07ff));
upper = *(rt_uint16_t *)where; upper = *(rt_uint16_t *)where;
lower = *(rt_uint16_t *)((Elf32_Addr)where + 2); lower = *(rt_uint16_t *)((Elf32_Addr)where + 2);
break; break;
default: default:
return -1; return -1;
} }
...@@ -357,7 +357,7 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr) ...@@ -357,7 +357,7 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr)
rt_uint32_t index, module_size = 0; rt_uint32_t index, module_size = 0;
RT_ASSERT(module_ptr != RT_NULL); RT_ASSERT(module_ptr != RT_NULL);
if(rt_memcmp(elf_module->e_ident, RTMMAG, SELFMAG) == 0) if(rt_memcmp(elf_module->e_ident, RTMMAG, SELFMAG) == 0)
{ {
/* rtmlinker finished */ /* rtmlinker finished */
...@@ -434,7 +434,7 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr) ...@@ -434,7 +434,7 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr)
RT_DEBUG_LOG(RT_DEBUG_MODULE, RT_DEBUG_LOG(RT_DEBUG_MODULE,
("relocate symbol %s shndx %d\n", strtab + sym->st_name, sym->st_shndx)); ("relocate symbol %s shndx %d\n", strtab + sym->st_name, sym->st_shndx));
if((sym->st_shndx != SHT_NULL) || (ELF_ST_BIND(sym->st_info) == STB_LOCAL)) if((sym->st_shndx != SHT_NULL) || (ELF_ST_BIND(sym->st_info) == STB_LOCAL))
rt_module_arm_relocate(module, rel, (Elf32_Addr)(module->module_space + sym->st_value)); rt_module_arm_relocate(module, rel, (Elf32_Addr)(module->module_space + sym->st_value));
else if(!linked) else if(!linked)
{ {
...@@ -466,14 +466,14 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr) ...@@ -466,14 +466,14 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr)
#if 0 #if 0
for (index = 0; index < elf_module->e_shnum; index ++) for (index = 0; index < elf_module->e_shnum; index ++)
{ {
/* find .dynsym section */ /* find .dynsym section */
rt_uint8_t* shstrab = (rt_uint8_t*) module_ptr + shdr[elf_module->e_shstrndx].sh_offset; rt_uint8_t* shstrab = (rt_uint8_t*) module_ptr + shdr[elf_module->e_shstrndx].sh_offset;
if (rt_strcmp((const char *)(shstrab + shdr[index].sh_name), ELF_GOT) == 0) if (rt_strcmp((const char *)(shstrab + shdr[index].sh_name), ELF_GOT) == 0)
{ {
rt_hw_set_got_base(module->module_space + shdr[index].sh_offset); rt_hw_set_got_base(module->module_space + shdr[index].sh_offset);
break; break;
} }
} }
#endif #endif
...@@ -493,7 +493,7 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr) ...@@ -493,7 +493,7 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr)
rt_uint8_t *strtab = RT_NULL; rt_uint8_t *strtab = RT_NULL;
symtab =(Elf32_Sym *)((rt_uint8_t *)module_ptr + shdr[index].sh_offset); symtab =(Elf32_Sym *)((rt_uint8_t *)module_ptr + shdr[index].sh_offset);
strtab = (rt_uint8_t *)module_ptr + shdr[shdr[index].sh_link].sh_offset; strtab = (rt_uint8_t *)module_ptr + shdr[shdr[index].sh_link].sh_offset;
for (i=0; i<shdr[index].sh_size/sizeof(Elf32_Sym); i++) for (i=0; i<shdr[index].sh_size/sizeof(Elf32_Sym); i++)
{ {
...@@ -517,24 +517,24 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr) ...@@ -517,24 +517,24 @@ static struct rt_module* _load_shared_object(const char* name, void* module_ptr)
} }
} }
} }
return module; return module;
} }
static struct rt_module* _load_relocated_object(const char* name, void* module_ptr) static struct rt_module* _load_relocated_object(const char* name, void* module_ptr)
{ {
rt_uint32_t index, rodata_addr = 0, bss_addr = 0, data_addr = 0; rt_uint32_t index, rodata_addr = 0, bss_addr = 0, data_addr = 0;
rt_uint32_t module_addr = 0, module_size = 0; rt_uint32_t module_addr = 0, module_size = 0;
struct rt_module* module = RT_NULL; struct rt_module* module = RT_NULL;
rt_uint8_t *ptr, *strtab, *shstrab; rt_uint8_t *ptr, *strtab, *shstrab;
rt_bool_t linked = RT_FALSE; rt_bool_t linked = RT_FALSE;
if(rt_memcmp(elf_module->e_ident, RTMMAG, SELFMAG) == 0) if(rt_memcmp(elf_module->e_ident, RTMMAG, SELFMAG) == 0)
{ {
/* rtmlinker finished */ /* rtmlinker finished */
linked = RT_TRUE; linked = RT_TRUE;
} }
/* get the ELF image size */ /* get the ELF image size */
for (index = 0; index < elf_module->e_shnum; index++) for (index = 0; index < elf_module->e_shnum; index++)
{ {
...@@ -548,7 +548,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p ...@@ -548,7 +548,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p
if (IS_PROG(shdr[index]) && IS_ALLOC(shdr[index])) if (IS_PROG(shdr[index]) && IS_ALLOC(shdr[index]))
{ {
module_size += shdr[index].sh_size; module_size += shdr[index].sh_size;
} }
/* data */ /* data */
if (IS_PROG(shdr[index]) && IS_AW(shdr[index])) if (IS_PROG(shdr[index]) && IS_AW(shdr[index]))
{ {
...@@ -558,7 +558,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p ...@@ -558,7 +558,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p
if (IS_NOPROG(shdr[index]) && IS_AW(shdr[index])) if (IS_NOPROG(shdr[index]) && IS_AW(shdr[index]))
{ {
module_size += shdr[index].sh_size; module_size += shdr[index].sh_size;
} }
} }
/* no text, data and bss on image */ /* no text, data and bss on image */
...@@ -599,11 +599,11 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p ...@@ -599,11 +599,11 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p
RT_DEBUG_LOG(RT_DEBUG_MODULE,("load rodata 0x%x, size %d, rodata 0x%x\n", ptr, shdr[index].sh_size, *(rt_uint32_t*)data_addr)); RT_DEBUG_LOG(RT_DEBUG_MODULE,("load rodata 0x%x, size %d, rodata 0x%x\n", ptr, shdr[index].sh_size, *(rt_uint32_t*)data_addr));
ptr += shdr[index].sh_size; ptr += shdr[index].sh_size;
} }
/* load data section */ /* load data section */
if (IS_PROG(shdr[index]) && IS_AW(shdr[index])) if (IS_PROG(shdr[index]) && IS_AW(shdr[index]))
{ {
rt_memcpy(ptr, (rt_uint8_t*)elf_module + shdr[index].sh_offset, shdr[index].sh_size); rt_memcpy(ptr, (rt_uint8_t*)elf_module + shdr[index].sh_offset, shdr[index].sh_size);
data_addr = (rt_uint32_t)ptr; data_addr = (rt_uint32_t)ptr;
RT_DEBUG_LOG(RT_DEBUG_MODULE,("load data 0x%x, size %d, data 0x%x\n", ptr, shdr[index].sh_size, *(rt_uint32_t*)data_addr)); RT_DEBUG_LOG(RT_DEBUG_MODULE,("load data 0x%x, size %d, data 0x%x\n", ptr, shdr[index].sh_size, *(rt_uint32_t*)data_addr));
ptr += shdr[index].sh_size; ptr += shdr[index].sh_size;
...@@ -614,7 +614,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p ...@@ -614,7 +614,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p
{ {
rt_memset(ptr, 0, shdr[index].sh_size); rt_memset(ptr, 0, shdr[index].sh_size);
bss_addr = (rt_uint32_t)ptr; bss_addr = (rt_uint32_t)ptr;
RT_DEBUG_LOG(RT_DEBUG_MODULE,("load bss 0x%x, size %d,\n", ptr, shdr[index].sh_size)); RT_DEBUG_LOG(RT_DEBUG_MODULE,("load bss 0x%x, size %d,\n", ptr, shdr[index].sh_size));
} }
} }
...@@ -644,12 +644,12 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p ...@@ -644,12 +644,12 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p
{ {
Elf32_Sym *sym = &symtab[ELF32_R_SYM(rel->r_info)]; Elf32_Sym *sym = &symtab[ELF32_R_SYM(rel->r_info)];
RT_DEBUG_LOG(RT_DEBUG_MODULE,("relocate symbol: %s\n", strtab + sym->st_name)); RT_DEBUG_LOG(RT_DEBUG_MODULE,("relocate symbol: %s\n", strtab + sym->st_name));
if (sym->st_shndx != STN_UNDEF) if (sym->st_shndx != STN_UNDEF)
{ {
if((ELF_ST_TYPE(sym->st_info) == STT_SECTION) if((ELF_ST_TYPE(sym->st_info) == STT_SECTION)
|| (ELF_ST_TYPE(sym->st_info) == STT_OBJECT)) || (ELF_ST_TYPE(sym->st_info) == STT_OBJECT))
{ {
if (rt_strncmp(shstrab + shdr[sym->st_shndx].sh_name, ELF_RODATA, 8) == 0) if (rt_strncmp(shstrab + shdr[sym->st_shndx].sh_name, ELF_RODATA, 8) == 0)
{ {
/* relocate rodata section */ /* relocate rodata section */
...@@ -658,30 +658,30 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p ...@@ -658,30 +658,30 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p
} }
else if(strncmp(shstrab + shdr[sym->st_shndx].sh_name, ELF_BSS, 5) == 0) else if(strncmp(shstrab + shdr[sym->st_shndx].sh_name, ELF_BSS, 5) == 0)
{ {
/* relocate bss section */ /* relocate bss section */
RT_DEBUG_LOG(RT_DEBUG_MODULE,("bss\n")); RT_DEBUG_LOG(RT_DEBUG_MODULE,("bss\n"));
rt_module_arm_relocate(module, rel, (Elf32_Addr)bss_addr + sym->st_value); rt_module_arm_relocate(module, rel, (Elf32_Addr)bss_addr + sym->st_value);
} }
else if(strncmp(shstrab + shdr[sym->st_shndx].sh_name, ELF_DATA, 6) == 0) else if(strncmp(shstrab + shdr[sym->st_shndx].sh_name, ELF_DATA, 6) == 0)
{ {
/* relocate data section */ /* relocate data section */
RT_DEBUG_LOG(RT_DEBUG_MODULE,("data\n")); RT_DEBUG_LOG(RT_DEBUG_MODULE,("data\n"));
rt_module_arm_relocate(module, rel, (Elf32_Addr)data_addr + sym->st_value); rt_module_arm_relocate(module, rel, (Elf32_Addr)data_addr + sym->st_value);
} }
} }
} }
else if(ELF_ST_TYPE(sym->st_info) == STT_FUNC ) else if(ELF_ST_TYPE(sym->st_info) == STT_FUNC )
{ {
/* relocate function */ /* relocate function */
rt_module_arm_relocate(module, rel, rt_module_arm_relocate(module, rel,
(Elf32_Addr)((rt_uint8_t*)module->module_space - module_addr + sym->st_value)); (Elf32_Addr)((rt_uint8_t*)module->module_space - module_addr + sym->st_value));
} }
else else
{ {
Elf32_Addr addr; Elf32_Addr addr;
if(ELF32_R_TYPE(rel->r_info) != R_ARM_V4BX) if(ELF32_R_TYPE(rel->r_info) != R_ARM_V4BX)
{ {
RT_DEBUG_LOG(RT_DEBUG_MODULE,("relocate symbol: %s\n", strtab + sym->st_name)); RT_DEBUG_LOG(RT_DEBUG_MODULE,("relocate symbol: %s\n", strtab + sym->st_name));
/* need to resolve symbol in kernel symbol table */ /* need to resolve symbol in kernel symbol table */
addr = rt_module_symbol_find(strtab + sym->st_name); addr = rt_module_symbol_find(strtab + sym->st_name);
...@@ -689,7 +689,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p ...@@ -689,7 +689,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p
{ {
rt_module_arm_relocate(module, rel, addr); rt_module_arm_relocate(module, rel, addr);
RT_DEBUG_LOG(RT_DEBUG_MODULE,("symbol addr 0x%x\n", addr)); RT_DEBUG_LOG(RT_DEBUG_MODULE,("symbol addr 0x%x\n", addr));
} }
else rt_kprintf("can't find %s in kernel symbol table\n", strtab + sym->st_name); else rt_kprintf("can't find %s in kernel symbol table\n", strtab + sym->st_name);
} }
else else
...@@ -717,7 +717,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p ...@@ -717,7 +717,7 @@ static struct rt_module* _load_relocated_object(const char* name, void* module_p
rt_module_t rt_module_load(const char* name, void* module_ptr) rt_module_t rt_module_load(const char* name, void* module_ptr)
{ {
rt_module_t module; rt_module_t module;
RT_DEBUG_NOT_IN_INTERRUPT; RT_DEBUG_NOT_IN_INTERRUPT;
rt_kprintf("rt_module_load: %s ,", name); rt_kprintf("rt_module_load: %s ,", name);
...@@ -736,7 +736,7 @@ rt_module_t rt_module_load(const char* name, void* module_ptr) ...@@ -736,7 +736,7 @@ rt_module_t rt_module_load(const char* name, void* module_ptr)
rt_kprintf(" module class error\n"); rt_kprintf(" module class error\n");
return RT_NULL; return RT_NULL;
} }
if(elf_module->e_type == ET_REL) if(elf_module->e_type == ET_REL)
{ {
module = _load_relocated_object(name, module_ptr); module = _load_relocated_object(name, module_ptr);
...@@ -751,8 +751,8 @@ rt_module_t rt_module_load(const char* name, void* module_ptr) ...@@ -751,8 +751,8 @@ rt_module_t rt_module_load(const char* name, void* module_ptr)
return RT_NULL; return RT_NULL;
} }
if(module == RT_NULL) return RT_NULL; if(module == RT_NULL) return RT_NULL;
/* init module object container */ /* init module object container */
rt_module_init_object_container(module); rt_module_init_object_container(module);
...@@ -780,7 +780,7 @@ rt_module_t rt_module_load(const char* name, void* module_ptr) ...@@ -780,7 +780,7 @@ rt_module_t rt_module_load(const char* name, void* module_ptr)
module->module_thread->module_id = (void*)module; module->module_thread->module_id = (void*)module;
module->parent.flag = RT_MODULE_FLAG_WITHENTRY; module->parent.flag = RT_MODULE_FLAG_WITHENTRY;
/* startup module thread */ /* startup module thread */
rt_thread_startup(module->module_thread); rt_thread_startup(module->module_thread);
} }
...@@ -805,7 +805,7 @@ rt_module_t rt_module_load(const char* name, void* module_ptr) ...@@ -805,7 +805,7 @@ rt_module_t rt_module_load(const char* name, void* module_ptr)
/** /**
* This function will load a module from a file * This function will load a module from a file
* *
* @param filename the file name of application module * @param path the full path of application module
* *
* @return the module object * @return the module object
* *
...@@ -894,7 +894,7 @@ rt_err_t rt_module_unload(rt_module_t module) ...@@ -894,7 +894,7 @@ rt_err_t rt_module_unload(rt_module_t module)
RT_ASSERT(module != RT_NULL); RT_ASSERT(module != RT_NULL);
rt_kprintf("rt_module_unload: %s\n", module->parent.name); rt_kprintf("rt_module_unload: %s\n", module->parent.name);
/* module has entry point */ /* module has entry point */
if ((module->parent.flag & RT_MODULE_FLAG_WITHOUTENTRY) != RT_MODULE_FLAG_WITHOUTENTRY) if ((module->parent.flag & RT_MODULE_FLAG_WITHOUTENTRY) != RT_MODULE_FLAG_WITHOUTENTRY)
{ {
...@@ -1068,13 +1068,13 @@ rt_err_t rt_module_unload(rt_module_t module) ...@@ -1068,13 +1068,13 @@ rt_err_t rt_module_unload(rt_module_t module)
if(module->page_cnt > 0) if(module->page_cnt > 0)
{ {
struct rt_page_info *page = (struct rt_page_info *)module->page_array; struct rt_page_info *page = (struct rt_page_info *)module->page_array;
rt_kprintf("warning: module memory still hasn't been free finished\n"); rt_kprintf("warning: module memory still hasn't been free finished\n");
while(module->page_cnt != 0) while(module->page_cnt != 0)
{ {
rt_module_free_page(module, page[0].page_ptr, page[0].npage); rt_module_free_page(module, page[0].page_ptr, page[0].npage);
} }
} }
#endif #endif
...@@ -1174,7 +1174,7 @@ static void *rt_module_malloc_page(rt_size_t npages) ...@@ -1174,7 +1174,7 @@ static void *rt_module_malloc_page(rt_size_t npages)
* *
* @param page_ptr the page address to be released. * @param page_ptr the page address to be released.
* @param npages the number of page shall be released. * @param npages the number of page shall be released.
* *
* @note this function is used for RT-Thread Application Module * @note this function is used for RT-Thread Application Module
*/ */
static void rt_module_free_page(rt_module_t module, void *page_ptr, rt_size_t npages) static void rt_module_free_page(rt_module_t module, void *page_ptr, rt_size_t npages)
...@@ -1197,7 +1197,7 @@ static void rt_module_free_page(rt_module_t module, void *page_ptr, rt_size_t np ...@@ -1197,7 +1197,7 @@ static void rt_module_free_page(rt_module_t module, void *page_ptr, rt_size_t np
page[i].npage -= npages; page[i].npage -= npages;
} }
else if(page[i].npage == npages) else if(page[i].npage == npages)
{ {
for(index=i; index<module->page_cnt-1; index++) for(index=i; index<module->page_cnt-1; index++)
{ {
page[index].page_ptr = page[index + 1].page_ptr; page[index].page_ptr = page[index + 1].page_ptr;
...@@ -1205,8 +1205,8 @@ static void rt_module_free_page(rt_module_t module, void *page_ptr, rt_size_t np ...@@ -1205,8 +1205,8 @@ static void rt_module_free_page(rt_module_t module, void *page_ptr, rt_size_t np
} }
page[module->page_cnt - 1].page_ptr = RT_NULL; page[module->page_cnt - 1].page_ptr = RT_NULL;
page[module->page_cnt - 1].npage = 0; page[module->page_cnt - 1].npage = 0;
module->page_cnt--; module->page_cnt--;
} }
else RT_ASSERT(RT_FALSE); else RT_ASSERT(RT_FALSE);
rt_current_module->page_cnt--; rt_current_module->page_cnt--;
...@@ -1260,7 +1260,7 @@ void *rt_module_malloc(rt_size_t size) ...@@ -1260,7 +1260,7 @@ void *rt_module_malloc(rt_size_t size)
*prev = b->next; *prev = b->next;
rt_kprintf("rt_module_malloc 0x%x, %d\n",b + 1, size); rt_kprintf("rt_module_malloc 0x%x, %d\n",b + 1, size);
rt_sem_release(&mod_sem); rt_sem_release(&mod_sem);
return (void *)(b + 1); return (void *)(b + 1);
} }
...@@ -1271,8 +1271,8 @@ void *rt_module_malloc(rt_size_t size) ...@@ -1271,8 +1271,8 @@ void *rt_module_malloc(rt_size_t size)
if ((up = (struct rt_mem_head *)rt_module_malloc_page(npage)) == RT_NULL) return RT_NULL; if ((up = (struct rt_mem_head *)rt_module_malloc_page(npage)) == RT_NULL) return RT_NULL;
up->size = npage * RT_MM_PAGE_SIZE / sizeof(struct rt_mem_head); up->size = npage * RT_MM_PAGE_SIZE / sizeof(struct rt_mem_head);
for (prev = (struct rt_mem_head **)&rt_current_module->mem_list; (b = *prev) != RT_NULL; prev = &(b->next)) for (prev = (struct rt_mem_head **)&rt_current_module->mem_list; (b = *prev) != RT_NULL; prev = &(b->next))
{ {
if (b > up + up->size) break; if (b > up + up->size) break;
} }
...@@ -1337,10 +1337,10 @@ void rt_module_free(rt_module_t module, void *addr) ...@@ -1337,10 +1337,10 @@ void rt_module_free(rt_module_t module, void *addr)
{ {
*prev = b->next; *prev = b->next;
} }
rt_module_free_page(module, b, npage); rt_module_free_page(module, b, npage);
} }
} }
/* unlock */ /* unlock */
rt_sem_release(&mod_sem); rt_sem_release(&mod_sem);
...@@ -1352,7 +1352,7 @@ void rt_module_free(rt_module_t module, void *addr) ...@@ -1352,7 +1352,7 @@ void rt_module_free(rt_module_t module, void *addr)
{ {
n->size = b->size + n->size; n->size = b->size + n->size;
n->next = b->next; n->next = b->next;
if ((rt_uint32_t)n % RT_MM_PAGE_SIZE == 0) if ((rt_uint32_t)n % RT_MM_PAGE_SIZE == 0)
{ {
int npage = n->size * sizeof(struct rt_page_info) / RT_MM_PAGE_SIZE; int npage = n->size * sizeof(struct rt_page_info) / RT_MM_PAGE_SIZE;
...@@ -1368,7 +1368,7 @@ void rt_module_free(rt_module_t module, void *addr) ...@@ -1368,7 +1368,7 @@ void rt_module_free(rt_module_t module, void *addr)
*prev = r; *prev = r;
} }
else *prev = n->next; else *prev = n->next;
rt_module_free_page(module, n, npage); rt_module_free_page(module, n, npage);
} }
} }
...@@ -1404,9 +1404,9 @@ void rt_module_free(rt_module_t module, void *addr) ...@@ -1404,9 +1404,9 @@ void rt_module_free(rt_module_t module, void *addr)
} }
else else
{ {
*prev = b; *prev = b;
} }
} }
} }
else else
{ {
...@@ -1501,7 +1501,7 @@ void list_memlist(const char* name) ...@@ -1501,7 +1501,7 @@ void list_memlist(const char* name)
rt_module_t module; rt_module_t module;
struct rt_mem_head **prev; struct rt_mem_head **prev;
struct rt_mem_head *b; struct rt_mem_head *b;
module = rt_module_find(name); module = rt_module_find(name);
if (module == RT_NULL) return; if (module == RT_NULL) return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册