Skip to content

Commit 390973a

Browse files
committed
Merge remote-tracking branch 'china/master'
2 parents 92e0f0d + 622e6d8 commit 390973a

File tree

14 files changed

+848
-13
lines changed

14 files changed

+848
-13
lines changed

components/libc/dlib/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Dlib(IAR) porting for RT-Thread.
2+
3+
Please define RT_USING_LIBC and compile RT-Thread with IAR compiler.
4+

components/libc/dlib/SConscript

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from building import *
2+
import rtconfig
3+
4+
src = Glob('*.c')
5+
cwd = GetCurrentDir()
6+
group = []
7+
8+
CPPPATH = [cwd]
9+
CPPDEFINES = ['RT_USING_DLIBC']
10+
11+
if rtconfig.PLATFORM == 'iar':
12+
group = DefineGroup('dlib', src, depend = ['RT_USING_LIBC'],
13+
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
14+
15+
Return('group')

components/libc/dlib/environ.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* File: environ.c
2+
* this file is part of RT-Thread RTOS
3+
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along
16+
* with this program; if not, write to the Free Software Foundation, Inc.,
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Change Logs:
20+
* Date Author Notes
21+
* 2015-01-28 Bernard first version
22+
*/
23+
24+
const char *__environ = "OS=RT-Thread";
25+

components/libc/dlib/rmtx.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* File : rmtx.c
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program; if not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Change Logs:
21+
* Date Author Notes
22+
* 2015-01-28 Bernard first version
23+
*/
24+
#include <rtthread.h>
25+
#include <yfuns.h>
26+
27+
/*
28+
* for IAR compiler, we recommand to define _DLIB_THREAD_SUPPORT
29+
* as 2 for dlib multi-thread support.
30+
*/
31+
32+
#if _DLIB_THREAD_SUPPORT
33+
void _Mtxinit(_Rmtx *m)
34+
{
35+
rt_mutex_t mutex;
36+
37+
RT_ASSERT(m != RT_NULL);
38+
39+
mutex = (rt_mutex_t)m;
40+
rt_mutex_init(mutex, "iarMtx", RT_IPC_FLAG_FIFO);
41+
}
42+
43+
void _Mtxdst(_Rmtx *m)
44+
{
45+
rt_mutex_t mutex;
46+
47+
RT_ASSERT(m != RT_NULL);
48+
49+
mutex = (rt_mutex_t)m;
50+
rt_mutex_detach(mutex);
51+
}
52+
53+
void _Mtxlock(_Rmtx *m)
54+
{
55+
rt_mutex_t mutex;
56+
57+
RT_ASSERT(m != RT_NULL);
58+
59+
mutex = (rt_mutex_t)m;
60+
rt_mutex_take(mutex, RT_WAITING_FOREVER);
61+
}
62+
63+
void _Mtxunlock(_Rmtx *m)
64+
{
65+
rt_mutex_t mutex;
66+
67+
RT_ASSERT(m != RT_NULL);
68+
69+
mutex = (rt_mutex_t)m;
70+
rt_mutex_release(mutex);
71+
}
72+
#endif
73+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* File : syscall_open.c
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program; if not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Change Logs:
21+
* Date Author Notes
22+
* 2015-01-28 Bernard first version
23+
*/
24+
25+
#include <rtthread.h>
26+
#include <yfuns.h>
27+
#ifdef RT_USING_DFS
28+
#include <dfs_posix.h>
29+
#endif
30+
31+
#pragma module_name = "?__open"
32+
33+
int __open(const char *filename, int mode)
34+
{
35+
if (mode & _LLIO_CREAT)
36+
{
37+
}
38+
39+
if (mode & _LLIO_TEXT)
40+
{
41+
/* we didn't support text mode */
42+
}
43+
44+
switch (mode & _LLIO_RDWRMASK)
45+
{
46+
case _LLIO_RDONLY:
47+
/* The file should be opened for read only. */
48+
break;
49+
50+
case _LLIO_WRONLY:
51+
/* The file should be opened for write only. */
52+
break;
53+
54+
case _LLIO_RDWR:
55+
/* The file should be opened for both reads and writes. */
56+
break;
57+
58+
default:
59+
return -1;
60+
}
61+
62+
return handle;
63+
}
64+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* File : syscall_read.c
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program; if not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Change Logs:
21+
* Date Author Notes
22+
* 2015-01-28 Bernard first version
23+
*/
24+
25+
#include <rtthread.h>
26+
#include <yfuns.h>
27+
28+
#pragma module_name = "?__read"
29+
size_t __read(int handle, unsigned char *buf, size_t len)
30+
{
31+
#ifdef RT_USING_DFS
32+
int size;
33+
#endif
34+
35+
if (handle == _LLIO_STDIN)
36+
{
37+
/* TODO */
38+
return 0;
39+
}
40+
41+
if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
42+
return _LLIO_ERROR;
43+
44+
#ifndef RT_USING_DFS
45+
return _LLIO_ERROR;
46+
#else
47+
size = read(handle - STDERR - 1, buf, len);
48+
return size;
49+
#endif
50+
}
51+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* File : syscall_write.c
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program; if not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Change Logs:
21+
* Date Author Notes
22+
* 2015-01-28 Bernard first version
23+
*/
24+
25+
#include <rtthread.h>
26+
#include <yfuns.h>
27+
28+
#pragma module_name = "?__write"
29+
30+
size_t __write(int handle, const unsigned char *buf, size_t len)
31+
{
32+
#ifdef RT_USING_DFS
33+
int size;
34+
#endif
35+
36+
if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
37+
{
38+
#ifndef RT_USING_CONSOLE
39+
return _LLIO_ERROR;
40+
#else
41+
rt_device_t console_device;
42+
43+
console_device = rt_console_get_device();
44+
if (console_device != 0) rt_device_write(console_device, 0, buf, len);
45+
46+
return len;
47+
#endif
48+
}
49+
50+
if (handle == STDIN) return -1;
51+
52+
#ifndef RT_USING_DFS
53+
return _LLIO_ERROR;
54+
#else
55+
size = write(handle - STDERR - 1, buf, len);
56+
return size;
57+
#endif
58+
}
59+

components/libc/dlib/syscalls.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* File : syscalls.c
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program; if not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Change Logs:
21+
* Date Author Notes
22+
* 2015-01-28 Bernard first version
23+
*/
24+
#include <rtthread.h>
25+
#ifdef RT_USING_DFS
26+
#include <dfs_file.h>
27+
#endif
28+
#include <yfuns.h>
29+
30+
#pragma module_name = "?__close"
31+
int __close(int handle)
32+
{
33+
if (handle == _LLIO_STDOUT ||
34+
handle == _LLIO_STDERR ||
35+
handle == _LLIO_STDIN)
36+
return _LLIO_ERROR;
37+
38+
#ifdef RT_USING_DFS
39+
return close(handle);
40+
#else
41+
return 0;
42+
#endif
43+
}
44+
45+
#pragma module_name = "?remove"
46+
int remove(const char *val)
47+
{
48+
#ifdef RT_USING_DFS
49+
dfs_file_unlink(val);
50+
#endif
51+
52+
return 0;
53+
}
54+
55+
#pragma module_name = "?__lseek"
56+
long __lseek(int handle, long offset, int whence)
57+
{
58+
#ifdef RT_USING_DFS
59+
#endif
60+
61+
if (handle == _LLIO_STDOUT ||
62+
handle == _LLIO_STDERR ||
63+
handle == _LLIO_STDIN)
64+
return _LLIO_ERROR;
65+
66+
return lseek(handle, offset, whence);
67+
}
68+

components/libc/dlib/syscalls.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* File: syscalls.h
2+
* this file is part of RT-Thread RTOS
3+
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along
16+
* with this program; if not, write to the Free Software Foundation, Inc.,
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Change Logs:
20+
* Date Author Notes
21+
* 2015-01-28 Bernard first version
22+
*/
23+

0 commit comments

Comments
 (0)