diff options
| author | Bernard Xiong <[email protected]> | 2021-05-28 16:20:08 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-28 16:20:08 +0800 |
| commit | 92beddf3bccf6346e26aa097f82464456fb8e6bd (patch) | |
| tree | 197e4a108118dda016ea02274172f0c40e7ee8ed /bsp/simulator | |
| parent | b18a99b44240ec3152011e159cc24a5af8dff0ce (diff) | |
| parent | 03f4d40e30f3c94e1db0b3a65b3610dee695694a (diff) | |
Merge pull request #4737 from mysterywolf/3,1,xformatv3.1.5
[lts 3.1.x] format codes
Diffstat (limited to 'bsp/simulator')
| -rwxr-xr-x | bsp/simulator/applications/application.c | 2 | ||||
| -rw-r--r-- | bsp/simulator/drivers/module_win32.c | 152 | ||||
| -rw-r--r-- | bsp/simulator/pcap/pcap_netif.c | 116 |
3 files changed, 135 insertions, 135 deletions
diff --git a/bsp/simulator/applications/application.c b/bsp/simulator/applications/application.c index 429c04dd39..5f8ef3204e 100755 --- a/bsp/simulator/applications/application.c +++ b/bsp/simulator/applications/application.c @@ -23,7 +23,7 @@ void rt_init_thread_entry(void *parameter) platform_init(); mnt_init(); - platform_post_init(); + platform_post_init(); #if defined(PKG_USING_GUIENGINE) && defined(GUIENGINE_USING_DEMO) { diff --git a/bsp/simulator/drivers/module_win32.c b/bsp/simulator/drivers/module_win32.c index 6f4461e75b..81a98eca87 100644 --- a/bsp/simulator/drivers/module_win32.c +++ b/bsp/simulator/drivers/module_win32.c @@ -126,7 +126,7 @@ void rt_module_unload_sethook(void (*hook)(rt_module_t module)) */ int rt_system_module_init(void) { - return 0; + return 0; } /** @@ -236,9 +236,9 @@ rt_module_t rt_module_open(const char *path) struct dfs_filesystem *fs; appentry_t fptr; HINSTANCE hinstlib; - rt_module_t module; + rt_module_t module; - char * winpath = RT_NULL; + char * winpath = RT_NULL; char * name = RT_NULL; RT_DEBUG_NOT_IN_INTERRUPT; @@ -349,60 +349,60 @@ FINSH_FUNCTION_EXPORT_ALIAS(rt_module_open, exec, exec module from a file); #define RT_MODULE_ARG_MAX 8 static int _rt_module_split_arg(char* cmd, rt_size_t length, char* argv[]) { - int argc = 0; - char *ptr = cmd; + int argc = 0; + char *ptr = cmd; - while ((ptr - cmd) < length) - { - /* strip bank and tab */ - while ((*ptr == ' ' || *ptr == '\t') && (ptr -cmd)< length) - *ptr++ = '\0'; - /* check whether it's the end of line */ - if ((ptr - cmd)>= length) break; + while ((ptr - cmd) < length) + { + /* strip bank and tab */ + while ((*ptr == ' ' || *ptr == '\t') && (ptr -cmd)< length) + *ptr++ = '\0'; + /* check whether it's the end of line */ + if ((ptr - cmd)>= length) break; - /* handle string with quote */ - if (*ptr == '"') - { - argv[argc++] = ++ptr; + /* handle string with quote */ + if (*ptr == '"') + { + argv[argc++] = ++ptr; - /* skip this string */ - while (*ptr != '"' && (ptr-cmd) < length) - if (*ptr ++ == '\\') ptr ++; - if ((ptr - cmd) >= length) break; + /* skip this string */ + while (*ptr != '"' && (ptr-cmd) < length) + if (*ptr ++ == '\\') ptr ++; + if ((ptr - cmd) >= length) break; - /* skip '"' */ - *ptr ++ = '\0'; - } - else - { - argv[argc++] = ptr; - while ((*ptr != ' ' && *ptr != '\t') && (ptr - cmd) < length) - ptr ++; - } + /* skip '"' */ + *ptr ++ = '\0'; + } + else + { + argv[argc++] = ptr; + while ((*ptr != ' ' && *ptr != '\t') && (ptr - cmd) < length) + ptr ++; + } - if (argc >= RT_MODULE_ARG_MAX) break; - } + if (argc >= RT_MODULE_ARG_MAX) break; + } - return argc; + return argc; } /* module main thread entry */ static void module_main_entry(void* parameter) { - int argc; - char *argv[RT_MODULE_ARG_MAX]; - typedef int (*main_func_t)(int argc, char** argv); + int argc; + char *argv[RT_MODULE_ARG_MAX]; + typedef int (*main_func_t)(int argc, char** argv); - rt_module_t module = (rt_module_t) parameter; - if (module == RT_NULL || module->module_cmd_line == RT_NULL) return; + rt_module_t module = (rt_module_t) parameter; + if (module == RT_NULL || module->module_cmd_line == RT_NULL) return; - rt_memset(argv, 0x00, sizeof(argv)); - argc = _rt_module_split_arg((char*)module->module_cmd_line, module->module_cmd_size, argv); - if (argc == 0) return ; + rt_memset(argv, 0x00, sizeof(argv)); + argc = _rt_module_split_arg((char*)module->module_cmd_line, module->module_cmd_size, argv); + if (argc == 0) return ; - /* do the main function */ - ((main_func_t)module->module_entry)(argc, argv); - return; + /* do the main function */ + ((main_func_t)module->module_entry)(argc, argv); + return; } /** @@ -419,25 +419,25 @@ rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int line_ struct dfs_filesystem *fs; appentry_t fptr; HINSTANCE hinstlib; - rt_module_t module; + rt_module_t module; - char * winpath = RT_NULL; + char * winpath = RT_NULL; char * name = RT_NULL; - char *full_path = RT_NULL; + char *full_path = RT_NULL; RT_DEBUG_NOT_IN_INTERRUPT; /* check parameters */ RT_ASSERT(path != RT_NULL); - if (*path != '/') - { - full_path = dfs_normalize_path(RT_NULL, path); - } - else - { - full_path = (const char*)path; - } + if (*path != '/') + { + full_path = dfs_normalize_path(RT_NULL, path); + } + else + { + full_path = (const char*)path; + } /* app module should only in DFS_WIN32 */ fs = dfs_filesystem_lookup(full_path); @@ -452,14 +452,14 @@ rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int line_ if ((winpath = dfs_win32_dirdup((char *)full_path)) == RT_NULL) { rt_kprintf("out of memory, exit", path); - goto __exit; + goto __exit; } hinstlib = LoadLibrary(winpath); if (hinstlib == NULL) { rt_kprintf("error: unable to open %s\n", winpath); - goto __exit; + goto __exit; } fptr = (appentry_t)GetProcAddress(hinstlib, "main"); @@ -467,21 +467,21 @@ rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int line_ { rt_kprintf("error: unable to find function in %s\n", winpath); FreeLibrary(hinstlib); - goto __exit; + goto __exit; } - /* release winpath */ - rt_free(winpath); + /* release winpath */ + rt_free(winpath); /* get the name of the module */ name = _module_name(path); /* allocate module */ module = (struct rt_module *)rt_object_allocate(RT_Object_Class_Module, name); - if (!module) - { - goto __exit; - } + if (!module) + { + goto __exit; + } module->nref = 0; module->module_entry = fptr; @@ -494,11 +494,11 @@ rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int line_ if (module->module_entry != 0) { - /* set module argument */ - module->module_cmd_line = (rt_uint8_t*)rt_malloc(line_size + 1); - rt_memcpy(module->module_cmd_line, cmd_line, line_size); - module->module_cmd_line[line_size] = '\0'; - module->module_cmd_size = line_size; + /* set module argument */ + module->module_cmd_line = (rt_uint8_t*)rt_malloc(line_size + 1); + rt_memcpy(module->module_cmd_line, cmd_line, line_size); + module->module_cmd_line[line_size] = '\0'; + module->module_cmd_size = line_size; #ifdef RT_USING_SLAB /* init module memory allocator */ @@ -510,10 +510,10 @@ rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int line_ module->page_cnt = 0; #endif - /* create module thread */ - module->module_thread = rt_thread_create(name, - module_main_entry, module, - 2048, RT_THREAD_PRIORITY_MAX - 2, 10); + /* create module thread */ + module->module_thread = rt_thread_create(name, + module_main_entry, module, + 2048, RT_THREAD_PRIORITY_MAX - 2, 10); /* set module id */ module->module_thread->module_id = (void *)module; @@ -539,11 +539,11 @@ rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int line_ return module; __exit: - if (full_path != path) rt_free(full_path); - if (name != RT_NULL) rt_free(full_path); - if (winpath != RT_NULL)rt_free(winpath); + if (full_path != path) rt_free(full_path); + if (name != RT_NULL) rt_free(full_path); + if (winpath != RT_NULL)rt_free(winpath); - return RT_NULL; + return RT_NULL; /* FreeLibrary(hinstlib); */ } diff --git a/bsp/simulator/pcap/pcap_netif.c b/bsp/simulator/pcap/pcap_netif.c index 3d9d76dfcf..0aef477185 100644 --- a/bsp/simulator/pcap/pcap_netif.c +++ b/bsp/simulator/pcap/pcap_netif.c @@ -33,12 +33,12 @@ struct pcap_netif { - /* inherit from ethernet device */ - struct eth_device parent; + /* inherit from ethernet device */ + struct eth_device parent; pcap_t *tap; - /* interface address info. */ - rt_uint8_t dev_addr[MAX_ADDR_LEN]; /* hw address */ + /* interface address info. */ + rt_uint8_t dev_addr[MAX_ADDR_LEN]; /* hw address */ }; static struct pcap_netif pcap_netif_device; static struct rt_semaphore sem_lock; @@ -57,7 +57,7 @@ static void pcap_thread_entry(void* parameter) /* Open the adapter */ if ((tap = pcap_open_live(netif->name, - 65536, // portion of the packet to capture. + 65536, // portion of the packet to capture. 1, // promiscuous mode (nonzero means promiscuous) 1, // read timeout, 0 blocked, -1 no timeout errbuf )) == NULL) @@ -84,7 +84,7 @@ static void pcap_thread_entry(void* parameter) p = pbuf_alloc(PBUF_LINK, header->len, PBUF_RAM); pbuf_take(p, pkt_data, header->len); - + /* send to packet mailbox */ rt_mb_send_wait(packet_mb, (rt_uint32_t)p, RT_WAITING_FOREVER); /* notify eth rx thread to receive packet */ @@ -130,7 +130,7 @@ static rt_err_t pcap_netif_init(rt_device_t dev) { rt_kprintf("Select (%s) as network interface\n", d->description); packet_mb = rt_mb_create("pcap", 64, RT_IPC_FLAG_FIFO); - tid = rt_thread_create("pcap", pcap_thread_entry, d, + tid = rt_thread_create("pcap", pcap_thread_entry, d, 2048, RT_THREAD_PRIORITY_MAX - 1, 10); if (tid != RT_NULL) { @@ -147,7 +147,7 @@ static rt_err_t pcap_netif_init(rt_device_t dev) static rt_err_t pcap_netif_open(rt_device_t dev, rt_uint16_t oflag) { - return RT_EOK; + return RT_EOK; } static rt_err_t pcap_netif_close(rt_device_t dev) @@ -157,42 +157,42 @@ static rt_err_t pcap_netif_close(rt_device_t dev) tap = NETIF_PCAP(dev); pcap_close(tap); - return RT_EOK; + return RT_EOK; } static rt_size_t pcap_netif_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size) { - rt_set_errno(-RT_ENOSYS); - return 0; + rt_set_errno(-RT_ENOSYS); + return 0; } static rt_size_t pcap_netif_write (rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size) { - rt_set_errno(-RT_ENOSYS); - return 0; + rt_set_errno(-RT_ENOSYS); + return 0; } static rt_err_t pcap_netif_control(rt_device_t dev, int cmd, void *args) { - switch (cmd) - { - case NIOCTL_GADDR: - /* get mac address */ - if (args) rt_memcpy(args, pcap_netif_device.dev_addr, 6); - else return -RT_ERROR; - break; + switch (cmd) + { + case NIOCTL_GADDR: + /* get mac address */ + if (args) rt_memcpy(args, pcap_netif_device.dev_addr, 6); + else return -RT_ERROR; + break; - default : - break; - } + default : + break; + } - return RT_EOK; + return RT_EOK; } rt_err_t pcap_netif_tx( rt_device_t dev, struct pbuf* p) { - struct pbuf *q; - rt_uint8_t *ptr; + struct pbuf *q; + rt_uint8_t *ptr; rt_uint8_t buf[2048]; rt_err_t result = RT_EOK; pcap_t *tap; @@ -200,18 +200,18 @@ rt_err_t pcap_netif_tx( rt_device_t dev, struct pbuf* p) tap = NETIF_PCAP(dev); - /* lock EMAC device */ - rt_sem_take(&sem_lock, RT_WAITING_FOREVER); + /* lock EMAC device */ + rt_sem_take(&sem_lock, RT_WAITING_FOREVER); - /* copy data to tx buffer */ - q = p; - ptr = (rt_uint8_t*)buf; - while (q) - { - memcpy(ptr, q->payload, q->len); - ptr += q->len; - q = q->next; - } + /* copy data to tx buffer */ + q = p; + ptr = (rt_uint8_t*)buf; + while (q) + { + memcpy(ptr, q->payload, q->len); + ptr += q->len; + q = q->next; + } rt_enter_critical(); res = pcap_sendpacket(tap, buf, p->tot_len); @@ -223,15 +223,15 @@ rt_err_t pcap_netif_tx( rt_device_t dev, struct pbuf* p) result = -RT_ERROR; } - /* unlock EMAC device */ - rt_sem_release(&sem_lock); + /* unlock EMAC device */ + rt_sem_release(&sem_lock); return result; } struct pbuf *pcap_netif_rx(rt_device_t dev) { - struct pbuf* p = RT_NULL; + struct pbuf* p = RT_NULL; rt_mb_recv(packet_mb, (rt_uint32_t*)&p, 0); @@ -240,28 +240,28 @@ struct pbuf *pcap_netif_rx(rt_device_t dev) void pcap_netif_hw_init(void) { - rt_sem_init(&sem_lock, "eth_lock", 1, RT_IPC_FLAG_FIFO); + rt_sem_init(&sem_lock, "eth_lock", 1, RT_IPC_FLAG_FIFO); - pcap_netif_device.dev_addr[0] = 0x00; - pcap_netif_device.dev_addr[1] = 0x60; - pcap_netif_device.dev_addr[2] = 0x37; - /* set mac address: (only for test) */ - pcap_netif_device.dev_addr[3] = 0x12; - pcap_netif_device.dev_addr[4] = 0x34; - pcap_netif_device.dev_addr[5] = 0x56; + pcap_netif_device.dev_addr[0] = 0x00; + pcap_netif_device.dev_addr[1] = 0x60; + pcap_netif_device.dev_addr[2] = 0x37; + /* set mac address: (only for test) */ + pcap_netif_device.dev_addr[3] = 0x12; + pcap_netif_device.dev_addr[4] = 0x34; + pcap_netif_device.dev_addr[5] = 0x56; - pcap_netif_device.parent.parent.init = pcap_netif_init; - pcap_netif_device.parent.parent.open = pcap_netif_open; - pcap_netif_device.parent.parent.close = pcap_netif_close; - pcap_netif_device.parent.parent.read = pcap_netif_read; - pcap_netif_device.parent.parent.write = pcap_netif_write; - pcap_netif_device.parent.parent.control = pcap_netif_control; - pcap_netif_device.parent.parent.user_data = RT_NULL; + pcap_netif_device.parent.parent.init = pcap_netif_init; + pcap_netif_device.parent.parent.open = pcap_netif_open; + pcap_netif_device.parent.parent.close = pcap_netif_close; + pcap_netif_device.parent.parent.read = pcap_netif_read; + pcap_netif_device.parent.parent.write = pcap_netif_write; + pcap_netif_device.parent.parent.control = pcap_netif_control; + pcap_netif_device.parent.parent.user_data = RT_NULL; - pcap_netif_device.parent.eth_rx = pcap_netif_rx; - pcap_netif_device.parent.eth_tx = pcap_netif_tx; + pcap_netif_device.parent.eth_rx = pcap_netif_rx; + pcap_netif_device.parent.eth_tx = pcap_netif_tx; - eth_device_init(&(pcap_netif_device.parent), "e0"); + eth_device_init(&(pcap_netif_device.parent), "e0"); } #include <finsh.h> |
