summaryrefslogtreecommitdiff
path: root/bsp/simulator/drivers
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-03-20 22:39:00 +0800
committerMeco Man <[email protected]>2021-03-20 22:39:32 +0800
commite37abb2b81c2a8796f7b0a5d8f859036d262a841 (patch)
tree61425bc2e4c7b0837d230507d085bea0a5a5e9b9 /bsp/simulator/drivers
parent061182271fbf02cf5c3410e3c8083a062a31a2b3 (diff)
[simulator] 手动-自动格式化整理
Diffstat (limited to 'bsp/simulator/drivers')
-rwxr-xr-xbsp/simulator/drivers/board.c9
-rw-r--r--bsp/simulator/drivers/board.h9
-rw-r--r--bsp/simulator/drivers/dfs_win32.c8
-rw-r--r--bsp/simulator/drivers/module_win32.c160
-rw-r--r--bsp/simulator/drivers/nanddrv_file.c8
-rwxr-xr-xbsp/simulator/drivers/sd_sim.c8
-rwxr-xr-xbsp/simulator/drivers/sdl_fb.c16
-rw-r--r--bsp/simulator/drivers/sst25vfxx_mtd.h8
-rw-r--r--bsp/simulator/drivers/sst25vfxx_mtd_sim.c10
-rw-r--r--bsp/simulator/drivers/tap_netif.c204
-rw-r--r--bsp/simulator/drivers/uart_console.c24
-rw-r--r--bsp/simulator/drivers/uart_console.h9
12 files changed, 243 insertions, 230 deletions
diff --git a/bsp/simulator/drivers/board.c b/bsp/simulator/drivers/board.c
index 2bf10263f2..b5037d6575 100755
--- a/bsp/simulator/drivers/board.c
+++ b/bsp/simulator/drivers/board.c
@@ -1,17 +1,12 @@
/*
- * File : board.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2009 RT-Thread Develop Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2009-01-05 Bernard first implementation
*/
-
#include <rthw.h>
#include <rtthread.h>
diff --git a/bsp/simulator/drivers/board.h b/bsp/simulator/drivers/board.h
index 7edb856505..1643b0de5a 100644
--- a/bsp/simulator/drivers/board.h
+++ b/bsp/simulator/drivers/board.h
@@ -1,17 +1,12 @@
/*
- * File : board.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2009, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2009-09-22 Bernard add board.h to this bsp
*/
-
#ifndef __BOARD_H__
#define __BOARD_H__
void rt_hw_board_init(void);
diff --git a/bsp/simulator/drivers/dfs_win32.c b/bsp/simulator/drivers/dfs_win32.c
index b275751efb..b910c2bf83 100644
--- a/bsp/simulator/drivers/dfs_win32.c
+++ b/bsp/simulator/drivers/dfs_win32.c
@@ -1,11 +1,7 @@
/*
- * File : rtthread.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006-2012, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/simulator/drivers/module_win32.c b/bsp/simulator/drivers/module_win32.c
index 8fcf3ef2fe..81a98eca87 100644
--- a/bsp/simulator/drivers/module_win32.c
+++ b/bsp/simulator/drivers/module_win32.c
@@ -1,11 +1,7 @@
/*
- * File : module.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -130,7 +126,7 @@ void rt_module_unload_sethook(void (*hook)(rt_module_t module))
*/
int rt_system_module_init(void)
{
- return 0;
+ return 0;
}
/**
@@ -240,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;
@@ -353,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;
}
/**
@@ -423,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);
@@ -456,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");
@@ -471,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;
@@ -498,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 */
@@ -514,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;
@@ -543,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/drivers/nanddrv_file.c b/bsp/simulator/drivers/nanddrv_file.c
index 075ed7f5d8..c47ffdbbe4 100644
--- a/bsp/simulator/drivers/nanddrv_file.c
+++ b/bsp/simulator/drivers/nanddrv_file.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
#include <rtdevice.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/bsp/simulator/drivers/sd_sim.c b/bsp/simulator/drivers/sd_sim.c
index b317e5428d..41c495403a 100755
--- a/bsp/simulator/drivers/sd_sim.c
+++ b/bsp/simulator/drivers/sd_sim.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
diff --git a/bsp/simulator/drivers/sdl_fb.c b/bsp/simulator/drivers/sdl_fb.c
index 98da565a2a..986c3139de 100755
--- a/bsp/simulator/drivers/sdl_fb.c
+++ b/bsp/simulator/drivers/sdl_fb.c
@@ -1,7 +1,13 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
#include <rtthread.h>
-
#include <stdio.h>
-
#ifdef _WIN32
#include <sdl.h>
#else
@@ -190,7 +196,7 @@ static void sdlfb_hw_init(void)
SDL_PixelFormatEnumToMasks(SDL_SCREEN_FORMAT, &bpp, &Rmask, &Gmask,
&Bmask, &Amask);
- _device.surface = SDL_CreateRGBSurface(0, SDL_SCREEN_WIDTH, SDL_SCREEN_HEIGHT,
+ _device.surface = SDL_CreateRGBSurface(0, SDL_SCREEN_WIDTH, SDL_SCREEN_HEIGHT,
bpp, Rmask, Gmask, Bmask, Amask);
}
@@ -255,7 +261,7 @@ static void *sdl_loop(void *lpParam)
int motion_tick = 50;
int mouse_id = 1;
-
+
#ifndef _WIN32
sigset_t sigmask, oldmask;
/* set the getchar without buffer */
@@ -455,7 +461,7 @@ static void *sdl_loop(void *lpParam)
exit(1);
break;
}
-
+
}
rt_hw_exit();
return 0;
diff --git a/bsp/simulator/drivers/sst25vfxx_mtd.h b/bsp/simulator/drivers/sst25vfxx_mtd.h
index cb0bb84129..202c6884a3 100644
--- a/bsp/simulator/drivers/sst25vfxx_mtd.h
+++ b/bsp/simulator/drivers/sst25vfxx_mtd.h
@@ -1,11 +1,7 @@
/*
- * File : sst25vfxx_mtd.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/bsp/simulator/drivers/sst25vfxx_mtd_sim.c b/bsp/simulator/drivers/sst25vfxx_mtd_sim.c
index cd8894f612..4460e1da3b 100644
--- a/bsp/simulator/drivers/sst25vfxx_mtd_sim.c
+++ b/bsp/simulator/drivers/sst25vfxx_mtd_sim.c
@@ -1,11 +1,7 @@
/*
- * File : rtdef.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -20,7 +16,7 @@
#ifdef RT_USING_MTD_NOR
#define NOR_SIM "nor.bin"
-/* JEDEC Manufacturer��s ID */
+/* JEDEC Manufacturer’s ID */
#define MF_ID (0xBF)
/* JEDEC Device ID : Memory Type */
#define MT_ID (0x25)
diff --git a/bsp/simulator/drivers/tap_netif.c b/bsp/simulator/drivers/tap_netif.c
index a8cd865c5e..8bac666cc0 100644
--- a/bsp/simulator/drivers/tap_netif.c
+++ b/bsp/simulator/drivers/tap_netif.c
@@ -33,7 +33,7 @@
#include <netif/ethernetif.h>
#define MAX_ADDR_LEN 6
-#define TAP_IFNAME "RT-net"
+#define TAP_IFNAME "RT-net"
//=============
// TAP IOCTLs
@@ -112,13 +112,13 @@ static tap_win32_overlapped_t tap_overlapped;
/************************************************************************/
struct tap_netif
{
- /* inherit from ethernet device */
- struct eth_device parent;
+ /* inherit from ethernet device */
+ struct eth_device parent;
- tap_win32_overlapped_t *handle;
+ tap_win32_overlapped_t *handle;
- /* 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 */
};
#define NETIF_DEVICE(netif) ((struct tap_netif*)(netif))
#define NETIF_TAP(netif) (NETIF_DEVICE(netif)->handle)
@@ -505,12 +505,12 @@ static void tap_win32_thread_entry(void* param)
unsigned long read_size;
BOOL result;
DWORD dwError;
- tun_buffer_t* buffer;
- struct eth_device* eth;
+ tun_buffer_t* buffer;
+ struct eth_device* eth;
- eth = (struct eth_device*) &tap_netif_device;
- overlapped = NETIF_TAP(&tap_netif_device);
- buffer = get_buffer_from_free_list(overlapped);
+ eth = (struct eth_device*) &tap_netif_device;
+ overlapped = NETIF_TAP(&tap_netif_device);
+ buffer = get_buffer_from_free_list(overlapped);
for (;;) {
result = ReadFile(overlapped->handle,
@@ -548,15 +548,15 @@ static void tap_win32_thread_entry(void* param)
}
if(read_size > 0) {
- // rt_kprintf("rx packet, length=%d\n", read_size);
+ // rt_kprintf("rx packet, length=%d\n", read_size);
- buffer->read_size = read_size;
+ buffer->read_size = read_size;
put_buffer_on_output_queue(overlapped, buffer);
- /* notify eth rx thread to receive packet */
- eth_device_ready(eth);
+ /* notify eth rx thread to receive packet */
+ eth_device_ready(eth);
- buffer = get_buffer_from_free_list(overlapped);
+ buffer = get_buffer_from_free_list(overlapped);
}
}
}
@@ -649,143 +649,143 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle,
static rt_err_t tap_netif_init(rt_device_t dev)
{
- rt_thread_t tid;
- tap_win32_overlapped_t *handle;
+ rt_thread_t tid;
+ tap_win32_overlapped_t *handle;
- if (tap_win32_open(&handle, TAP_IFNAME) < 0) {
- printf("tap: Could not open '%s'\n", TAP_IFNAME);
- return -RT_ERROR;
- }
+ if (tap_win32_open(&handle, TAP_IFNAME) < 0) {
+ printf("tap: Could not open '%s'\n", TAP_IFNAME);
+ return -RT_ERROR;
+ }
- tap_netif_device.handle = handle;
+ tap_netif_device.handle = handle;
- /* create recv thread */
- tid = rt_thread_create("tap", tap_win32_thread_entry, RT_NULL,
- 2048, RT_THREAD_PRIORITY_MAX - 1, 10);
- if (tid != RT_NULL)
- {
- rt_thread_startup(tid);
- }
+ /* create recv thread */
+ tid = rt_thread_create("tap", tap_win32_thread_entry, RT_NULL,
+ 2048, RT_THREAD_PRIORITY_MAX - 1, 10);
+ if (tid != RT_NULL)
+ {
+ rt_thread_startup(tid);
+ }
- rt_thread_sleep(RT_TICK_PER_SECOND);
+ rt_thread_sleep(RT_TICK_PER_SECOND);
- return RT_EOK;
+ return RT_EOK;
}
static rt_err_t tap_netif_open(rt_device_t dev, rt_uint16_t oflag)
{
- return RT_EOK;
+ return RT_EOK;
}
static rt_err_t tap_netif_close(rt_device_t dev)
{
- return RT_EOK;
+ return RT_EOK;
}
static rt_size_t tap_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 tap_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 tap_netif_control(rt_device_t dev, int cmd, void *args)
{
- switch (cmd)
- {
- case NIOCTL_GADDR:
- /* get mac address */
- if (args) rt_memcpy(args, tap_netif_device.dev_addr, 6);
- else return -RT_ERROR;
- break;
+ switch (cmd)
+ {
+ case NIOCTL_GADDR:
+ /* get mac address */
+ if (args) rt_memcpy(args, tap_netif_device.dev_addr, 6);
+ else return -RT_ERROR;
+ break;
- default :
- break;
- }
+ default :
+ break;
+ }
- return RT_EOK;
+ return RT_EOK;
}
rt_err_t tap_netif_tx( rt_device_t dev, struct pbuf* p)
{
- struct pbuf *q;
- char buffer[2048];
- int length;
- tap_win32_overlapped_t *handle;
- unsigned char* ptr;
+ struct pbuf *q;
+ char buffer[2048];
+ int length;
+ tap_win32_overlapped_t *handle;
+ unsigned char* ptr;
- handle = NETIF_TAP(dev);
+ handle = NETIF_TAP(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*)buffer;
- while (q)
- {
- memcpy(ptr, q->payload, q->len);
- ptr += q->len;
- q = q->next;
- }
- length = p->tot_len;
+ /* copy data to tx buffer */
+ q = p;
+ ptr = (rt_uint8_t*)buffer;
+ while (q)
+ {
+ memcpy(ptr, q->payload, q->len);
+ ptr += q->len;
+ q = q->next;
+ }
+ length = p->tot_len;
- tap_win32_write(handle, buffer, length);
+ tap_win32_write(handle, buffer, length);
- /* unlock EMAC device */
- rt_sem_release(&sem_lock);
+ /* unlock EMAC device */
+ rt_sem_release(&sem_lock);
- return RT_EOK;
+ return RT_EOK;
}
struct pbuf *tap_netif_rx(rt_device_t dev)
{
- struct pbuf* p = RT_NULL;
- tap_win32_overlapped_t *handle;
- rt_uint8_t *buf;
- int max_size = 4096;
- int size;
+ struct pbuf* p = RT_NULL;
+ tap_win32_overlapped_t *handle;
+ rt_uint8_t *buf;
+ int max_size = 4096;
+ int size;
- handle = NETIF_TAP(dev);
+ handle = NETIF_TAP(dev);
- size = tap_win32_read(handle, &buf, max_size);
- if (size > 0) {
- p = pbuf_alloc(PBUF_LINK, size, PBUF_RAM);
- pbuf_take(p, buf, size);
+ size = tap_win32_read(handle, &buf, max_size);
+ if (size > 0) {
+ p = pbuf_alloc(PBUF_LINK, size, PBUF_RAM);
+ pbuf_take(p, buf, size);
- tap_win32_free_buffer(handle, buf);
- }
+ tap_win32_free_buffer(handle, buf);
+ }
- return p;
+ return p;
}
void tap_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);
- tap_netif_device.dev_addr[0] = 0x00;
- tap_netif_device.dev_addr[1] = 0x60;
- tap_netif_device.dev_addr[2] = 0x37;
- /* set mac address: (only for test) */
- tap_netif_device.dev_addr[3] = 0x12;
- tap_netif_device.dev_addr[4] = 0x34;
- tap_netif_device.dev_addr[5] = 0x56;
+ tap_netif_device.dev_addr[0] = 0x00;
+ tap_netif_device.dev_addr[1] = 0x60;
+ tap_netif_device.dev_addr[2] = 0x37;
+ /* set mac address: (only for test) */
+ tap_netif_device.dev_addr[3] = 0x12;
+ tap_netif_device.dev_addr[4] = 0x34;
+ tap_netif_device.dev_addr[5] = 0x56;
- tap_netif_device.parent.parent.init = tap_netif_init;
- tap_netif_device.parent.parent.open = tap_netif_open;
- tap_netif_device.parent.parent.close = tap_netif_close;
- tap_netif_device.parent.parent.read = tap_netif_read;
- tap_netif_device.parent.parent.write = tap_netif_write;
- tap_netif_device.parent.parent.control = tap_netif_control;
- tap_netif_device.parent.parent.user_data= RT_NULL;
+ tap_netif_device.parent.parent.init = tap_netif_init;
+ tap_netif_device.parent.parent.open = tap_netif_open;
+ tap_netif_device.parent.parent.close = tap_netif_close;
+ tap_netif_device.parent.parent.read = tap_netif_read;
+ tap_netif_device.parent.parent.write = tap_netif_write;
+ tap_netif_device.parent.parent.control = tap_netif_control;
+ tap_netif_device.parent.parent.user_data= RT_NULL;
- tap_netif_device.parent.eth_rx = tap_netif_rx;
- tap_netif_device.parent.eth_tx = tap_netif_tx;
+ tap_netif_device.parent.eth_rx = tap_netif_rx;
+ tap_netif_device.parent.eth_tx = tap_netif_tx;
- eth_device_init(&(tap_netif_device.parent), "e0");
+ eth_device_init(&(tap_netif_device.parent), "e0");
}
diff --git a/bsp/simulator/drivers/uart_console.c b/bsp/simulator/drivers/uart_console.c
index 913daf2311..8fd799b297 100644
--- a/bsp/simulator/drivers/uart_console.c
+++ b/bsp/simulator/drivers/uart_console.c
@@ -1,5 +1,13 @@
-#include <stdio.h>
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+#include <stdio.h>
#include <rthw.h>
#include <rtdevice.h>
#include <rtthread.h>
@@ -88,11 +96,11 @@ static struct termios oldt, newt;
/*simulate windows' getch(), it works!!*/
static void set_stty(void)
{
- /* get terminal input's attribute */
+ /* get terminal input's attribute */
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
- /* set termios' local mode */
+ /* set termios' local mode */
newt.c_lflag &= ~(ECHO|ICANON);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
}
@@ -117,10 +125,10 @@ static void * ThreadforKeyGet(void * lpParam)
#ifndef _WIN32
sigset_t sigmask, oldmask;
- /* set the getchar without buffer */
- sigfillset(&sigmask);
- pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
- set_stty();
+ /* set the getchar without buffer */
+ sigfillset(&sigmask);
+ pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
+ set_stty();
#endif
(void)lpParam; //prevent compiler warnings
@@ -217,7 +225,7 @@ static int console_putc(struct rt_serial_device *serial, char c)
level = rt_hw_interrupt_disable();
fwrite(&c, 1, 1, stdout);
- fflush(stdout);
+ fflush(stdout);
rt_hw_interrupt_enable(level);
return 1;
}
diff --git a/bsp/simulator/drivers/uart_console.h b/bsp/simulator/drivers/uart_console.h
index 149a7a21f8..8ea20cc2f4 100644
--- a/bsp/simulator/drivers/uart_console.h
+++ b/bsp/simulator/drivers/uart_console.h
@@ -1,3 +1,12 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+
#ifndef UART_CONSOLE_H__
#define UART_CONSOLE_H__