mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-21 10:36:04 +08:00
Merge branch 'master' into dev-4.0.x
This commit is contained in:
@@ -1,398 +0,0 @@
|
||||
diff --git a/dfs_yaffs2.c b/dfs_yaffs2.c
|
||||
index 4b056ae..e63d5d4 100644
|
||||
--- a/dfs_yaffs2.c
|
||||
+++ b/dfs_yaffs2.c
|
||||
@@ -39,7 +39,6 @@ static int dfs_yaffs_mount(struct dfs_filesystem* fs,
|
||||
const void* data)
|
||||
{
|
||||
unsigned index;
|
||||
- ynandif_Geometry *g;
|
||||
|
||||
/*1. find a empty entry in partition table */
|
||||
for (index = 0; index < NAND_DEVICE_PART_MAX ; index ++)
|
||||
diff --git a/yaffs/direct/yaffsfs.c b/yaffs/direct/yaffsfs.c
|
||||
index 17fc502..1f47ea7 100644
|
||||
--- a/yaffs/direct/yaffsfs.c
|
||||
+++ b/yaffs/direct/yaffsfs.c
|
||||
@@ -1367,7 +1367,7 @@ off_t yaffs_lseek(int handle, off_t offset, int whence)
|
||||
if(offset >= 0)
|
||||
pos = offset;
|
||||
} else if(whence == SEEK_CUR) {
|
||||
- if( (fd->position + offset) >= 0)
|
||||
+ if( ((int)fd->position + offset) >= 0)
|
||||
pos = (fd->position + offset);
|
||||
} else if(whence == SEEK_END) {
|
||||
fSize = yaffs_get_obj_length(obj);
|
||||
diff --git a/yaffs/direct/yportenv.h b/yaffs/direct/yportenv.h
|
||||
index f693c16..ac0a737 100644
|
||||
--- a/yaffs/direct/yportenv.h
|
||||
+++ b/yaffs/direct/yportenv.h
|
||||
@@ -45,7 +45,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef loff_t
|
||||
- typedef unsigned long loff_t;
|
||||
+ typedef long loff_t;
|
||||
#endif
|
||||
|
||||
#ifndef dev_t
|
||||
@@ -66,7 +66,7 @@
|
||||
#elif defined (__GNUC__) && !defined(__CC_ARM)
|
||||
|
||||
#ifndef loff_t
|
||||
- typedef unsigned long loff_t;
|
||||
+ typedef long loff_t;
|
||||
#endif
|
||||
|
||||
#ifndef dev_t
|
||||
diff --git a/yaffs/yaffs_guts.c b/yaffs/yaffs_guts.c
|
||||
index d72aa5b..08db8c8 100644
|
||||
--- a/yaffs/yaffs_guts.c
|
||||
+++ b/yaffs/yaffs_guts.c
|
||||
@@ -280,7 +280,7 @@ static void yaffs_handle_chunk_wr_error(struct yaffs_dev *dev, int nand_chunk,
|
||||
|
||||
static inline int yaffs_hash_fn(int n)
|
||||
{
|
||||
- n = abs(n);
|
||||
+ n = n > 0 ? n : -n;
|
||||
return n % YAFFS_NOBJECT_BUCKETS;
|
||||
}
|
||||
|
||||
@@ -319,9 +319,9 @@ static int yaffs_check_chunk_erased(struct yaffs_dev *dev, int nand_chunk)
|
||||
int retval = YAFFS_OK;
|
||||
u8 *data = yaffs_get_temp_buffer(dev);
|
||||
struct yaffs_ext_tags tags;
|
||||
- int result;
|
||||
|
||||
- result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags);
|
||||
+
|
||||
+ yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags);
|
||||
|
||||
if (tags.ecc_result > YAFFS_ECC_RESULT_NO_ERROR)
|
||||
retval = YAFFS_FAIL;
|
||||
@@ -347,9 +347,9 @@ static int yaffs_verify_chunk_written(struct yaffs_dev *dev,
|
||||
int retval = YAFFS_OK;
|
||||
struct yaffs_ext_tags temp_tags;
|
||||
u8 *buffer = yaffs_get_temp_buffer(dev);
|
||||
- int result;
|
||||
|
||||
- result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags);
|
||||
+
|
||||
+ yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags);
|
||||
if (memcmp(buffer, data, dev->data_bytes_per_chunk) ||
|
||||
temp_tags.obj_id != tags->obj_id ||
|
||||
temp_tags.chunk_id != tags->chunk_id ||
|
||||
@@ -1478,7 +1478,7 @@ static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev)
|
||||
struct yaffs_obj *the_obj;
|
||||
int usage;
|
||||
int i;
|
||||
- int pushout;
|
||||
+ /* int pushout; */
|
||||
|
||||
if (dev->param.n_caches < 1)
|
||||
return NULL;
|
||||
@@ -1499,7 +1499,7 @@ static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev)
|
||||
the_obj = dev->cache[0].object;
|
||||
usage = -1;
|
||||
cache = NULL;
|
||||
- pushout = -1;
|
||||
+ /* pushout = -1; */
|
||||
|
||||
for (i = 0; i < dev->param.n_caches; i++) {
|
||||
if (dev->cache[i].object &&
|
||||
@@ -1509,7 +1509,7 @@ static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev)
|
||||
usage = dev->cache[i].last_use;
|
||||
the_obj = dev->cache[i].object;
|
||||
cache = &dev->cache[i];
|
||||
- pushout = i;
|
||||
+ /* pushout = i; */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3167,7 +3167,7 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in)
|
||||
struct yaffs_obj_hdr *oh;
|
||||
struct yaffs_dev *dev;
|
||||
struct yaffs_ext_tags tags;
|
||||
- int result;
|
||||
+
|
||||
int alloc_failed = 0;
|
||||
|
||||
if (!in || !in->lazy_loaded || in->hdr_chunk < 1)
|
||||
@@ -3177,7 +3177,7 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in)
|
||||
in->lazy_loaded = 0;
|
||||
buf = yaffs_get_temp_buffer(dev);
|
||||
|
||||
- result = yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags);
|
||||
+ yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags);
|
||||
oh = (struct yaffs_obj_hdr *)buf;
|
||||
|
||||
in->yst_mode = oh->yst_mode;
|
||||
@@ -3189,6 +3189,7 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in)
|
||||
yaffs_clone_str(oh->alias);
|
||||
if (!in->variant.symlink_variant.alias)
|
||||
alloc_failed = 1; /* Not returned */
|
||||
+ alloc_failed = alloc_failed;
|
||||
}
|
||||
yaffs_release_temp_buffer(dev, buf);
|
||||
}
|
||||
@@ -3274,7 +3275,7 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force,
|
||||
struct yaffs_dev *dev = in->my_dev;
|
||||
int prev_chunk_id;
|
||||
int ret_val = 0;
|
||||
- int result = 0;
|
||||
+
|
||||
int new_chunk_id;
|
||||
struct yaffs_ext_tags new_tags;
|
||||
struct yaffs_ext_tags old_tags;
|
||||
@@ -3297,7 +3298,7 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force,
|
||||
prev_chunk_id = in->hdr_chunk;
|
||||
|
||||
if (prev_chunk_id > 0) {
|
||||
- result = yaffs_rd_chunk_tags_nand(dev, prev_chunk_id,
|
||||
+ yaffs_rd_chunk_tags_nand(dev, prev_chunk_id,
|
||||
buffer, &old_tags);
|
||||
|
||||
yaffs_verify_oh(in, oh, &old_tags, 0);
|
||||
@@ -3921,7 +3922,7 @@ int yaffs_del_obj(struct yaffs_obj *obj)
|
||||
list_del_init(&obj->variant.dir_variant.dirty);
|
||||
}
|
||||
return yaffs_del_dir(obj);
|
||||
- break;
|
||||
+ //break;
|
||||
case YAFFS_OBJECT_TYPE_SYMLINK:
|
||||
ret_val = yaffs_del_symlink(obj);
|
||||
break;
|
||||
@@ -3993,17 +3994,17 @@ static int yaffs_unlink_worker(struct yaffs_obj *obj)
|
||||
switch (obj->variant_type) {
|
||||
case YAFFS_OBJECT_TYPE_FILE:
|
||||
return yaffs_del_file(obj);
|
||||
- break;
|
||||
+ //break;
|
||||
case YAFFS_OBJECT_TYPE_DIRECTORY:
|
||||
list_del_init(&obj->variant.dir_variant.dirty);
|
||||
return yaffs_del_dir(obj);
|
||||
- break;
|
||||
+ //break;
|
||||
case YAFFS_OBJECT_TYPE_SYMLINK:
|
||||
return yaffs_del_symlink(obj);
|
||||
- break;
|
||||
+ //break;
|
||||
case YAFFS_OBJECT_TYPE_SPECIAL:
|
||||
return yaffs_generic_obj_del(obj);
|
||||
- break;
|
||||
+ //break;
|
||||
case YAFFS_OBJECT_TYPE_HARDLINK:
|
||||
case YAFFS_OBJECT_TYPE_UNKNOWN:
|
||||
default:
|
||||
@@ -4421,7 +4422,7 @@ int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size)
|
||||
} else if (obj->short_name[0]) {
|
||||
strcpy(name, obj->short_name);
|
||||
} else if (obj->hdr_chunk > 0) {
|
||||
- int result;
|
||||
+
|
||||
u8 *buffer = yaffs_get_temp_buffer(obj->my_dev);
|
||||
|
||||
struct yaffs_obj_hdr *oh = (struct yaffs_obj_hdr *)buffer;
|
||||
@@ -4429,7 +4430,7 @@ int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size)
|
||||
memset(buffer, 0, obj->my_dev->data_bytes_per_chunk);
|
||||
|
||||
if (obj->hdr_chunk > 0) {
|
||||
- result = yaffs_rd_chunk_tags_nand(obj->my_dev,
|
||||
+ yaffs_rd_chunk_tags_nand(obj->my_dev,
|
||||
obj->hdr_chunk,
|
||||
buffer, NULL);
|
||||
}
|
||||
@@ -4490,16 +4491,16 @@ unsigned yaffs_get_obj_type(struct yaffs_obj *obj)
|
||||
switch (obj->variant_type) {
|
||||
case YAFFS_OBJECT_TYPE_FILE:
|
||||
return DT_REG;
|
||||
- break;
|
||||
+ //break;
|
||||
case YAFFS_OBJECT_TYPE_DIRECTORY:
|
||||
return DT_DIR;
|
||||
- break;
|
||||
+ //break;
|
||||
case YAFFS_OBJECT_TYPE_SYMLINK:
|
||||
return DT_LNK;
|
||||
- break;
|
||||
+ //break;
|
||||
case YAFFS_OBJECT_TYPE_HARDLINK:
|
||||
return DT_REG;
|
||||
- break;
|
||||
+ //break;
|
||||
case YAFFS_OBJECT_TYPE_SPECIAL:
|
||||
if (S_ISFIFO(obj->yst_mode))
|
||||
return DT_FIFO;
|
||||
@@ -4510,10 +4511,10 @@ unsigned yaffs_get_obj_type(struct yaffs_obj *obj)
|
||||
if (S_ISSOCK(obj->yst_mode))
|
||||
return DT_SOCK;
|
||||
return DT_REG;
|
||||
- break;
|
||||
+ //break;
|
||||
default:
|
||||
return DT_REG;
|
||||
- break;
|
||||
+ //break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4837,7 +4838,7 @@ int yaffs_guts_initialise(struct yaffs_dev *dev)
|
||||
dev->n_erased_blocks = 0;
|
||||
dev->n_free_chunks = 0;
|
||||
dev->alloc_block = -1;
|
||||
- dev->alloc_page = -1;
|
||||
+ dev->alloc_page = (u32)(-1);
|
||||
dev->n_deleted_files = 0;
|
||||
dev->n_unlinked_files = 0;
|
||||
dev->n_bg_deletions = 0;
|
||||
diff --git a/yaffs/yaffs_packedtags2.c b/yaffs/yaffs_packedtags2.c
|
||||
index 820bc41..9306623 100644
|
||||
--- a/yaffs/yaffs_packedtags2.c
|
||||
+++ b/yaffs/yaffs_packedtags2.c
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
/* Also, the top 4 bits of the object Id are set to the object type. */
|
||||
#define EXTRA_OBJECT_TYPE_SHIFT (28)
|
||||
-#define EXTRA_OBJECT_TYPE_MASK ((0x0f) << EXTRA_OBJECT_TYPE_SHIFT)
|
||||
+#define EXTRA_OBJECT_TYPE_MASK ((0x0fUL) << EXTRA_OBJECT_TYPE_SHIFT)
|
||||
|
||||
static void yaffs_dump_packed_tags2_tags_only(
|
||||
const struct yaffs_packed_tags2_tags_only *ptt)
|
||||
@@ -129,7 +129,7 @@ void yaffs_unpack_tags2_tags_only(struct yaffs_ext_tags *t,
|
||||
t->extra_parent_id = ptt->chunk_id & (~(ALL_EXTRA_FLAGS));
|
||||
t->extra_is_shrink = ptt->chunk_id & EXTRA_SHRINK_FLAG ? 1 : 0;
|
||||
t->extra_shadows = ptt->chunk_id & EXTRA_SHADOWS_FLAG ? 1 : 0;
|
||||
- t->extra_obj_type = ptt->obj_id >> EXTRA_OBJECT_TYPE_SHIFT;
|
||||
+ t->extra_obj_type = (enum yaffs_obj_type)(ptt->obj_id >> EXTRA_OBJECT_TYPE_SHIFT);
|
||||
t->obj_id &= ~EXTRA_OBJECT_TYPE_MASK;
|
||||
|
||||
if (t->extra_obj_type == YAFFS_OBJECT_TYPE_HARDLINK)
|
||||
diff --git a/yaffs/yaffs_verify.c b/yaffs/yaffs_verify.c
|
||||
index b3e540d..1758125 100644
|
||||
--- a/yaffs/yaffs_verify.c
|
||||
+++ b/yaffs/yaffs_verify.c
|
||||
@@ -223,7 +223,7 @@ void yaffs_verify_oh(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh,
|
||||
void yaffs_verify_file(struct yaffs_obj *obj)
|
||||
{
|
||||
int required_depth;
|
||||
- int actual_depth;
|
||||
+ //int actual_depth;
|
||||
u32 last_chunk;
|
||||
u32 the_chunk;
|
||||
u32 x;
|
||||
@@ -252,7 +252,7 @@ void yaffs_verify_file(struct yaffs_obj *obj)
|
||||
required_depth++;
|
||||
}
|
||||
|
||||
- actual_depth = obj->variant.file_variant.top_level;
|
||||
+ //actual_depth = obj->variant.file_variant.top_level;
|
||||
|
||||
/* Check that the chunks in the tnode tree are all correct.
|
||||
* We do this by scanning through the tnode tree and
|
||||
diff --git a/yaffs/yaffs_yaffs1.c b/yaffs/yaffs_yaffs1.c
|
||||
index da6a40f..8e7f4b2 100644
|
||||
--- a/yaffs/yaffs_yaffs1.c
|
||||
+++ b/yaffs/yaffs_yaffs1.c
|
||||
@@ -23,7 +23,7 @@ int yaffs1_scan(struct yaffs_dev *dev)
|
||||
{
|
||||
struct yaffs_ext_tags tags;
|
||||
int blk;
|
||||
- int result;
|
||||
+ //int result;
|
||||
int chunk;
|
||||
int c;
|
||||
int deleted;
|
||||
@@ -84,7 +84,7 @@ int yaffs1_scan(struct yaffs_dev *dev)
|
||||
cond_resched();
|
||||
|
||||
bi = yaffs_get_block_info(dev, blk);
|
||||
- state = bi->block_state;
|
||||
+ state = (enum yaffs_block_state)(bi->block_state);
|
||||
|
||||
deleted = 0;
|
||||
|
||||
@@ -95,7 +95,7 @@ int yaffs1_scan(struct yaffs_dev *dev)
|
||||
/* Read the tags and decide what to do */
|
||||
chunk = blk * dev->param.chunks_per_block + c;
|
||||
|
||||
- result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL,
|
||||
+ yaffs_rd_chunk_tags_nand(dev, chunk, NULL,
|
||||
&tags);
|
||||
|
||||
/* Let's have a good look at this chunk... */
|
||||
@@ -181,7 +181,7 @@ int yaffs1_scan(struct yaffs_dev *dev)
|
||||
yaffs_set_chunk_bit(dev, blk, c);
|
||||
bi->pages_in_use++;
|
||||
|
||||
- result = yaffs_rd_chunk_tags_nand(dev, chunk,
|
||||
+ yaffs_rd_chunk_tags_nand(dev, chunk,
|
||||
chunk_data,
|
||||
NULL);
|
||||
|
||||
diff --git a/yaffs/yaffs_yaffs2.c b/yaffs/yaffs_yaffs2.c
|
||||
index 5761e96..69acd20 100644
|
||||
--- a/yaffs/yaffs_yaffs2.c
|
||||
+++ b/yaffs/yaffs_yaffs2.c
|
||||
@@ -946,7 +946,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev,
|
||||
int is_shrink;
|
||||
int is_unlinked;
|
||||
struct yaffs_ext_tags tags;
|
||||
- int result;
|
||||
+ //int result;
|
||||
int alloc_failed = 0;
|
||||
int chunk = blk * dev->param.chunks_per_block + chunk_in_block;
|
||||
struct yaffs_file_var *file_var;
|
||||
@@ -954,12 +954,12 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev,
|
||||
struct yaffs_symlink_var *sl_var;
|
||||
|
||||
if (summary_available) {
|
||||
- result = yaffs_summary_fetch(dev, &tags, chunk_in_block);
|
||||
+ yaffs_summary_fetch(dev, &tags, chunk_in_block);
|
||||
tags.seq_number = bi->seq_number;
|
||||
}
|
||||
|
||||
if (!summary_available || tags.obj_id == 0) {
|
||||
- result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL, &tags);
|
||||
+ yaffs_rd_chunk_tags_nand(dev, chunk, NULL, &tags);
|
||||
dev->tags_used++;
|
||||
} else {
|
||||
dev->summary_used++;
|
||||
@@ -1114,7 +1114,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev,
|
||||
* invalid data until needed.
|
||||
*/
|
||||
|
||||
- result = yaffs_rd_chunk_tags_nand(dev,
|
||||
+ yaffs_rd_chunk_tags_nand(dev,
|
||||
chunk,
|
||||
chunk_data,
|
||||
NULL);
|
||||
@@ -1349,7 +1349,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev)
|
||||
int n_to_scan = 0;
|
||||
enum yaffs_block_state state;
|
||||
int c;
|
||||
- int deleted;
|
||||
+ //int deleted;
|
||||
LIST_HEAD(hard_list);
|
||||
struct yaffs_block_info *bi;
|
||||
u32 seq_number;
|
||||
@@ -1467,7 +1467,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev)
|
||||
/* get the block to scan in the correct order */
|
||||
blk = block_index[block_iter].block;
|
||||
bi = yaffs_get_block_info(dev, blk);
|
||||
- deleted = 0;
|
||||
+ //deleted = 0;
|
||||
|
||||
summary_available = yaffs_summary_read(dev, dev->sum_tags, blk);
|
||||
|
||||
diff --git a/yaffs_osglue.c b/yaffs_osglue.c
|
||||
index 2c34f99..4f2e5db 100644
|
||||
--- a/yaffs_osglue.c
|
||||
+++ b/yaffs_osglue.c
|
||||
@@ -58,7 +58,6 @@ void yaffsfs_LockInit(void)
|
||||
#else
|
||||
|
||||
static rt_mutex_t mutex = RT_NULL;
|
||||
-static rt_sem_t sem = RT_NULL;
|
||||
void yaffsfs_Lock(void)
|
||||
{
|
||||
rt_mutex_take(mutex, RT_WAITING_FOREVER);
|
||||
@@ -1,46 +0,0 @@
|
||||
how to use yaffs under rt-thread.
|
||||
|
||||
There are three steps.
|
||||
1. get yaffs tarball from official repo.
|
||||
the repo of official repo is here.
|
||||
http://www.aleph1.co.uk/gitweb?p=yaffs2.git;a=summary
|
||||
then you should find the 2011-6-28's snapshot, download the tarball
|
||||
http://www.aleph1.co.uk/gitweb?p=yaffs2.git;a=snapshot;h=2df51cdb98e799c4d10b4cc7dd7e8858aa79e7d8;sf=tgz
|
||||
|
||||
decompress the yaffs.tar.gz to rt-thread\components\dfs\filesystems\yaffs2\yaffs
|
||||
|
||||
2. patch yaffs.diff
|
||||
open an terminal.
|
||||
(1) on windows
|
||||
open cmd command prompt, then use [cd] command to come current path
|
||||
for example
|
||||
F:\Project\svn\rt-thread\components\dfs\filesystems\yaffs2>
|
||||
then type command
|
||||
patch -p1 < yaffs.diff
|
||||
|
||||
you will get some log information as followings
|
||||
F:\Project\svn\rt-thread\components\dfs\filesystems\yaffs2>patch -p1 < yaffs.diff
|
||||
patching file `dfs_yaffs2.c'
|
||||
patching file `yaffs/direct/yaffs_list.h'
|
||||
patching file `yaffs/direct/yaffs_nandif.c'
|
||||
patching file `yaffs/direct/ydirectenv.h'
|
||||
patching file `yaffs/direct/yportenv.h'
|
||||
patching file `yaffs_nandcfg.c'
|
||||
patching file `yaffs_osglue.c'
|
||||
|
||||
now you can delete yaffs.diff
|
||||
there is another patch file, as the name shows, it is to fix compile
|
||||
warning, so it is not necessary. If you want, you can use the
|
||||
following command.
|
||||
patch -p1 < fixwarning.diff
|
||||
|
||||
(2) on linux
|
||||
Help yourself. Since you have use linux as your os, I believe in you.
|
||||
|
||||
3.add nand driver and compile
|
||||
In order to use yaffs, you should provide a nand driver which is needed
|
||||
by yaffs. There is an example file in rt-thread\components\dfs\filesystems\uffs\nand.
|
||||
you should modify yaffs_nandcfg.c according to your nand driver.
|
||||
then you can use scons or IDE like MDK or IAR to compile.
|
||||
|
||||
enjoy !
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
* File : dfs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
* File : dfs_file.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
* File : dfs_fs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
|
||||
#ifndef DFS_POLL_H__
|
||||
#define DFS_POLL_H__
|
||||
|
||||
@@ -6,6 +15,7 @@
|
||||
#ifdef RT_USING_POSIX
|
||||
#include <sys/time.h> /* for struct timeval */
|
||||
|
||||
#if !defined(POLLIN) && !defined(POLLOUT)
|
||||
#define POLLIN (0x01)
|
||||
#define POLLRDNORM (0x01)
|
||||
#define POLLRDBAND (0x01)
|
||||
@@ -19,8 +29,6 @@
|
||||
#define POLLHUP (0x08)
|
||||
#define POLLNVAL (0x10)
|
||||
|
||||
#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
|
||||
|
||||
typedef unsigned int nfds_t;
|
||||
|
||||
struct pollfd
|
||||
@@ -29,9 +37,10 @@ struct pollfd
|
||||
short events;
|
||||
short revents;
|
||||
};
|
||||
#endif /* !defined(POLLIN) && !defined(POLLOUT) */
|
||||
|
||||
#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
|
||||
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* RT_USING_POSIX */
|
||||
|
||||
#endif /* DFS_POLL_H__ */
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
* File : dfs_posix.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
@@ -55,13 +41,15 @@ int closedir(DIR* d);
|
||||
/* file api*/
|
||||
int open(const char *file, int flags, ...);
|
||||
int close(int d);
|
||||
#ifdef RT_USING_NEWLIB
|
||||
|
||||
#if defined(RT_USING_NEWLIB) && defined(_EXFUN)
|
||||
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte));
|
||||
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte));
|
||||
#else
|
||||
int read(int fd, void *buf, size_t len);
|
||||
int write(int fd, const void *buf, size_t len);
|
||||
#endif
|
||||
|
||||
off_t lseek(int fd, off_t offset, int whence);
|
||||
int rename(const char *from, const char *to);
|
||||
int unlink(const char *pathname);
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
|
||||
#ifndef DFS_PRIVATE_H__
|
||||
#define DFS_PRIVATE_H__
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
|
||||
#ifndef DFS_SELECT_H__
|
||||
#define DFS_SELECT_H__
|
||||
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
* File : dfs.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
@@ -199,7 +185,7 @@ int fd_new(void)
|
||||
if (idx == fdt->maxfd)
|
||||
{
|
||||
idx = -(1 + DFS_FD_OFFSET);
|
||||
dbg_log(DBG_ERROR, "DFS fd new is failed! Could not found an empty fd entry.");
|
||||
LOG_E( "DFS fd new is failed! Could not found an empty fd entry.");
|
||||
goto __result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
/*
|
||||
* File : dfs_file.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2005-02-22 Bernard The first version.
|
||||
@@ -60,7 +46,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dbg_log(DBG_LOG, "open file:%s\n", fullpath);
|
||||
LOG_D("open file:%s", fullpath);
|
||||
|
||||
/* Check whether file is already open */
|
||||
if (fd_is_open(fullpath) == 0)
|
||||
@@ -79,7 +65,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
dbg_log(DBG_LOG, "open in filesystem:%s\n", fs->ops->name);
|
||||
LOG_D("open in filesystem:%s", fs->ops->name);
|
||||
fd->fops = fs->ops->fops; /* set file ops */
|
||||
|
||||
/* initialize the fd item */
|
||||
@@ -96,7 +82,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
|
||||
else
|
||||
fd->path = rt_strdup(dfs_subdir(fs->path, fullpath));
|
||||
rt_free(fullpath);
|
||||
dbg_log(DBG_LOG, "Actual file path: %s\n", fd->path);
|
||||
LOG_D("Actual file path: %s", fd->path);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -119,7 +105,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
|
||||
rt_free(fd->path);
|
||||
fd->path = NULL;
|
||||
|
||||
dbg_log(DBG_ERROR, "open failed\n");
|
||||
LOG_E("open failed");
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -131,7 +117,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
|
||||
fd->flags |= DFS_F_DIRECTORY;
|
||||
}
|
||||
|
||||
dbg_log(DBG_INFO, "open successful\n");
|
||||
LOG_I("open successful");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -389,8 +375,8 @@ int dfs_file_stat(const char *path, struct stat *buf)
|
||||
|
||||
if ((fs = dfs_filesystem_lookup(fullpath)) == NULL)
|
||||
{
|
||||
dbg_log(DBG_ERROR,
|
||||
"can't find mounted filesystem on this path:%s\n", fullpath);
|
||||
LOG_E(
|
||||
"can't find mounted filesystem on this path:%s", fullpath);
|
||||
rt_free(fullpath);
|
||||
|
||||
return -ENOENT;
|
||||
@@ -419,8 +405,8 @@ int dfs_file_stat(const char *path, struct stat *buf)
|
||||
if (fs->ops->stat == NULL)
|
||||
{
|
||||
rt_free(fullpath);
|
||||
dbg_log(DBG_ERROR,
|
||||
"the filesystem didn't implement this function\n");
|
||||
LOG_E(
|
||||
"the filesystem didn't implement this function");
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
* File : dfs_fs.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
@@ -69,7 +55,7 @@ int dfs_register(const struct dfs_filesystem_ops *ops)
|
||||
if (empty == NULL)
|
||||
{
|
||||
rt_set_errno(-ENOSPC);
|
||||
dbg_log(DBG_ERROR, "There is no space to register this file system (%d).\n", ops->name);
|
||||
LOG_E("There is no space to register this file system (%d).", ops->name);
|
||||
ret = -1;
|
||||
}
|
||||
else if (ret == RT_EOK)
|
||||
@@ -318,7 +304,7 @@ int dfs_mount(const char *device_name,
|
||||
if ((fs == NULL) && (iter == &filesystem_table[DFS_FILESYSTEMS_MAX]))
|
||||
{
|
||||
rt_set_errno(-ENOSPC);
|
||||
dbg_log(DBG_ERROR, "There is no space to mount this file system (%s).\n", filesystemtype);
|
||||
LOG_E("There is no space to mount this file system (%s).", filesystemtype);
|
||||
goto err1;
|
||||
}
|
||||
|
||||
@@ -451,7 +437,7 @@ int dfs_mkfs(const char *fs_name, const char *device_name)
|
||||
if (dev_id == NULL)
|
||||
{
|
||||
rt_set_errno(-ENODEV);
|
||||
dbg_log(DBG_ERROR, "Device (%s) was not found\n", device_name);
|
||||
LOG_E("Device (%s) was not found", device_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -472,7 +458,7 @@ int dfs_mkfs(const char *fs_name, const char *device_name)
|
||||
const struct dfs_filesystem_ops *ops = filesystem_operation_table[index];
|
||||
if (ops->mkfs == NULL)
|
||||
{
|
||||
dbg_log(DBG_ERROR, "The file system (%s) mkfs function was not implement\n", fs_name);
|
||||
LOG_E("The file system (%s) mkfs function was not implement", fs_name);
|
||||
rt_set_errno(-ENOSYS);
|
||||
return -1;
|
||||
}
|
||||
@@ -480,7 +466,7 @@ int dfs_mkfs(const char *fs_name, const char *device_name)
|
||||
return ops->mkfs(dev_id);
|
||||
}
|
||||
|
||||
dbg_log(DBG_ERROR, "File system (%s) was not found.\n", fs_name);
|
||||
LOG_E("File system (%s) was not found.", fs_name);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
* File : dfs_posix.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
@@ -124,7 +110,7 @@ RTM_EXPORT(close);
|
||||
* @return the actual read data buffer length. If the returned value is 0, it
|
||||
* may be reach the end of file, please check errno.
|
||||
*/
|
||||
#ifdef RT_USING_NEWLIB
|
||||
#if defined(RT_USING_NEWLIB) && defined(_EXFUN)
|
||||
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int fd, void *buf, size_t len))
|
||||
#else
|
||||
int read(int fd, void *buf, size_t len)
|
||||
@@ -168,7 +154,7 @@ RTM_EXPORT(read);
|
||||
*
|
||||
* @return the actual written data buffer length.
|
||||
*/
|
||||
#ifdef RT_USING_NEWLIB
|
||||
#if defined(RT_USING_NEWLIB) && defined(_EXFUN)
|
||||
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int fd, const void *buf, size_t len))
|
||||
#else
|
||||
int write(int fd, const void *buf, size_t len)
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
* File : poll.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
* File : select.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
|
||||
@@ -72,6 +72,10 @@ config RT_USING_PIN
|
||||
bool "Using generic GPIO device drivers"
|
||||
default y
|
||||
|
||||
config RT_USING_ADC
|
||||
bool "Using ADC device drivers"
|
||||
default n
|
||||
|
||||
config RT_USING_PWM
|
||||
bool "Using PWM device drivers"
|
||||
default n
|
||||
@@ -104,6 +108,10 @@ config RT_USING_MTD
|
||||
default n
|
||||
endif
|
||||
|
||||
config RT_USING_PM
|
||||
bool "Using Power Management device drivers"
|
||||
default n
|
||||
|
||||
config RT_USING_RTC
|
||||
bool "Using RTC device drivers"
|
||||
default n
|
||||
@@ -114,9 +122,8 @@ config RT_USING_RTC
|
||||
default n
|
||||
config RTC_SYNC_USING_NTP
|
||||
bool "Using NTP auto sync RTC time"
|
||||
select PKG_USING_NETUTILS
|
||||
select PKG_NETUTILS_NTP
|
||||
default n
|
||||
depends on PKG_NETUTILS_NTP
|
||||
default y
|
||||
|
||||
if RTC_SYNC_USING_NTP
|
||||
config RTC_NTP_FIRST_SYNC_DELAY
|
||||
@@ -392,6 +399,23 @@ menu "Using USB"
|
||||
bool "Enable to use device as winusb device"
|
||||
default n
|
||||
endif
|
||||
if RT_USB_DEVICE_CDC
|
||||
config RT_VCOM_TASK_STK_SIZE
|
||||
int "virtual com thread stack size"
|
||||
default 512
|
||||
config RT_VCOM_TX_USE_DMA
|
||||
bool "Enable to use dma for vcom tx"
|
||||
default n
|
||||
config RT_VCOM_SERNO
|
||||
string "serial number of virtual com"
|
||||
default "32021919830108"
|
||||
config RT_VCOM_SER_LEN
|
||||
int "serial number length of virtual com"
|
||||
default 14
|
||||
config RT_VCOM_TX_TIMEOUT
|
||||
int "tx timeout(ticks) of virtual com"
|
||||
default 1000
|
||||
endif
|
||||
if RT_USB_DEVICE_WINUSB
|
||||
config RT_WINUSB_GUID
|
||||
string "Guid for winusb"
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-05-07 aozima the first version
|
||||
* 2018-11-16 Ernest Chen add finsh command and update adc function
|
||||
*/
|
||||
|
||||
#ifndef __ADC_H__
|
||||
#define __ADC_H__
|
||||
#include <rtthread.h>
|
||||
|
||||
struct rt_adc_device;
|
||||
struct rt_adc_ops
|
||||
{
|
||||
rt_err_t (*enabled)(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled);
|
||||
rt_err_t (*convert)(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
|
||||
};
|
||||
|
||||
struct rt_adc_device
|
||||
{
|
||||
struct rt_device parent;
|
||||
const struct rt_adc_ops *ops;
|
||||
};
|
||||
typedef struct rt_adc_device *rt_adc_device_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RT_ADC_CMD_ENABLE,
|
||||
RT_ADC_CMD_DISABLE,
|
||||
} rt_adc_cmd_t;
|
||||
|
||||
rt_err_t rt_hw_adc_register(rt_adc_device_t adc,const char *name, const struct rt_adc_ops *ops, const void *user_data);
|
||||
|
||||
rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_uint32_t channel);
|
||||
rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_uint32_t channel);
|
||||
rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_uint32_t channel);
|
||||
|
||||
#endif /* __ADC_H__ */
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-06-02 Bernard the first version
|
||||
* 2018-08-02 Tanek split run and sleep modes, support custom mode
|
||||
*/
|
||||
|
||||
#ifndef __PM_H__
|
||||
#define __PM_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifndef PM_HAS_CUSTOM_CONFIG
|
||||
|
||||
/* All modes used for rt_pm_request() adn rt_pm_release() */
|
||||
enum
|
||||
{
|
||||
/* run modes */
|
||||
PM_RUN_MODE_NORMAL = 0,
|
||||
|
||||
/* sleep modes */
|
||||
PM_SLEEP_MODE_SLEEP,
|
||||
PM_SLEEP_MODE_TIMER,
|
||||
PM_SLEEP_MODE_SHUTDOWN,
|
||||
};
|
||||
|
||||
/* The name of all modes used in the msh command "pm_dump" */
|
||||
#define PM_MODE_NAMES \
|
||||
{ \
|
||||
"Running Mode", \
|
||||
\
|
||||
"Sleep Mode", \
|
||||
"Timer Mode", \
|
||||
"Shutdown Mode", \
|
||||
}
|
||||
|
||||
/* run mode count : 1 */
|
||||
#define PM_RUN_MODE_COUNT 1
|
||||
/* sleep mode count : 3 */
|
||||
#define PM_SLEEP_MODE_COUNT 3
|
||||
|
||||
/* support redefining default run mode */
|
||||
#ifndef PM_RUN_MODE_DEFAULT
|
||||
#define PM_RUN_MODE_DEFAULT 0
|
||||
#endif
|
||||
|
||||
/* support redefining default sleep mode */
|
||||
#ifndef PM_SLEEP_MODE_DEFAULT
|
||||
#define PM_SLEEP_MODE_DEFAULT (PM_SLEEP_MODE_START)
|
||||
#endif
|
||||
|
||||
/* support redefining the minimum tick into sleep mode */
|
||||
#ifndef PM_MIN_ENTER_SLEEP_TICK
|
||||
#define PM_MIN_ENTER_SLEEP_TICK (1)
|
||||
#endif
|
||||
|
||||
#else /* PM_HAS_CUSTOM_CONFIG */
|
||||
|
||||
#include <pm_cfg.h>
|
||||
|
||||
#ifndef PM_RUN_MODE_COUNT
|
||||
#error "You must defined PM_RUN_MODE_COUNT on pm_cfg.h"
|
||||
#endif
|
||||
|
||||
#ifndef PM_SLEEP_MODE_COUNT
|
||||
#error "You must defined PM_SLEEP_MODE_COUNT on pm_cfg.h"
|
||||
#endif
|
||||
|
||||
#ifndef PM_MODE_DEFAULT
|
||||
#error "You must defined PM_MODE_DEFAULT on pm_cfg.h"
|
||||
#endif
|
||||
|
||||
#ifndef PM_MODE_NAMES
|
||||
#error "You must defined PM_MODE_NAMES on pm_cfg.h"
|
||||
#endif
|
||||
|
||||
#ifndef PM_RUN_MODE_DEFAULT
|
||||
#error "You must defined PM_RUN_MODE_DEFAULT on pm_cfg.h"
|
||||
#endif
|
||||
|
||||
/* The default sleep mode(PM_SLEEP_MODE_DEFAULT) are not required.
|
||||
* If the default mode is defined, it is requested once in rt_system_pm_init()
|
||||
*/
|
||||
|
||||
#endif /* PM_HAS_CUSTOM_CONFIG */
|
||||
|
||||
/* run mode must start at 0 */
|
||||
#define PM_RUN_MODE_START 0
|
||||
/* the values of the run modes and sleep mode must be consecutive */
|
||||
#define PM_SLEEP_MODE_START PM_RUN_MODE_COUNT
|
||||
/* all mode count */
|
||||
#define PM_MODE_COUNT (PM_RUN_MODE_COUNT + PM_SLEEP_MODE_COUNT)
|
||||
/* The last mode, will be request in rt_system_pm_init() */
|
||||
#define PM_MODE_MAX (PM_RUN_MODE_COUNT + PM_SLEEP_MODE_COUNT - 1)
|
||||
|
||||
#if PM_MODE_COUNT > 32
|
||||
#error "The number of modes cannot exceed 32"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* device control flag to request or release power
|
||||
*/
|
||||
#define RT_PM_DEVICE_CTRL_REQUEST 0x01
|
||||
#define RT_PM_DEVICE_CTRL_RELEASE 0x02
|
||||
|
||||
struct rt_pm;
|
||||
|
||||
/**
|
||||
* low power mode operations
|
||||
*/
|
||||
struct rt_pm_ops
|
||||
{
|
||||
void (*enter)(struct rt_pm *pm);
|
||||
void (*exit)(struct rt_pm *pm);
|
||||
|
||||
#if PM_RUN_MODE_COUNT > 1
|
||||
void (*frequency_change)(struct rt_pm *pm, rt_uint32_t frequency);
|
||||
#endif
|
||||
|
||||
void (*timer_start)(struct rt_pm *pm, rt_uint32_t timeout);
|
||||
void (*timer_stop)(struct rt_pm *pm);
|
||||
rt_tick_t (*timer_get_tick)(struct rt_pm *pm);
|
||||
};
|
||||
|
||||
struct rt_device_pm_ops
|
||||
{
|
||||
#if PM_RUN_MODE_COUNT > 1
|
||||
void (*frequency_change)(const struct rt_device* device);
|
||||
#endif
|
||||
|
||||
void (*suspend)(const struct rt_device* device);
|
||||
void (*resume) (const struct rt_device* device);
|
||||
};
|
||||
|
||||
struct rt_device_pm
|
||||
{
|
||||
const struct rt_device* device;
|
||||
const struct rt_device_pm_ops* ops;
|
||||
};
|
||||
|
||||
/**
|
||||
* power management
|
||||
*/
|
||||
struct rt_pm
|
||||
{
|
||||
struct rt_device parent;
|
||||
|
||||
/* modes */
|
||||
rt_uint8_t modes[PM_MODE_COUNT];
|
||||
rt_uint8_t current_mode; /* current pm mode */
|
||||
rt_uint8_t exit_count;
|
||||
|
||||
/* the list of device, which has PM feature */
|
||||
rt_uint8_t device_pm_number;
|
||||
struct rt_device_pm* device_pm;
|
||||
struct rt_semaphore device_lock;
|
||||
|
||||
/* if the mode has timer, the corresponding bit is 1*/
|
||||
rt_uint32_t timer_mask;
|
||||
|
||||
const struct rt_pm_ops *ops;
|
||||
};
|
||||
|
||||
void rt_pm_enter(void);
|
||||
void rt_pm_exit(void);
|
||||
|
||||
void rt_pm_request(rt_ubase_t mode);
|
||||
void rt_pm_release(rt_ubase_t mode);
|
||||
|
||||
void rt_pm_register_device(struct rt_device* device, const struct rt_device_pm_ops* ops);
|
||||
void rt_pm_unregister_device(struct rt_device* device);
|
||||
|
||||
void rt_system_pm_init(const struct rt_pm_ops *ops,
|
||||
rt_uint8_t timer_mask,
|
||||
void *user_data);
|
||||
|
||||
#endif /* __PM_H__ */
|
||||
@@ -225,7 +225,7 @@ extern "C" {
|
||||
#ifndef USB_TIMEOUT_LONG
|
||||
#define USB_TIMEOUT_LONG (RT_TICK_PER_SECOND * 5) /* 5s */
|
||||
#endif
|
||||
#ifndf USB_DEBOUNCE_TIME
|
||||
#ifndef USB_DEBOUNCE_TIME
|
||||
#define USB_DEBOUNCE_TIME (RT_TICK_PER_SECOND / 5) /* 0.2s */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -99,10 +99,18 @@ extern "C" {
|
||||
#include "drivers/cputime.h"
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_ADC
|
||||
#include "drivers/adc.h"
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_PWM
|
||||
#include "drivers/rt_drv_pwm.h"
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_PM
|
||||
#include "drivers/pm.h"
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_WIFI
|
||||
#include "drivers/wlan.h"
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,10 @@ group = []
|
||||
|
||||
if GetDepend(['RT_USING_PIN']):
|
||||
src = src + ['pin.c']
|
||||
|
||||
|
||||
if GetDepend(['RT_USING_ADC']):
|
||||
src = src + ['adc.c']
|
||||
|
||||
if GetDepend(['RT_USING_PWM']):
|
||||
src = src + ['rt_drv_pwm.c']
|
||||
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-05-07 aozima the first version
|
||||
* 2018-11-16 Ernest Chen add finsh command and update adc function
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME "adc"
|
||||
#define DBG_LEVEL DBG_INFO
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
|
||||
static rt_size_t _adc_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
rt_size_t i;
|
||||
struct rt_adc_device *adc = (struct rt_adc_device *)dev;
|
||||
rt_uint32_t *value = (rt_uint32_t *)buffer;
|
||||
|
||||
for (i = 0; i < size; i += sizeof(int))
|
||||
{
|
||||
result = adc->ops->convert(adc, pos + i, value);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
value++;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static rt_err_t _adc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
rt_adc_device_t adc = (struct rt_adc_device *)dev;
|
||||
|
||||
if (adc->ops->enabled != RT_NULL)
|
||||
{
|
||||
return -RT_ENOSYS;
|
||||
}
|
||||
if (cmd == RT_ADC_CMD_ENABLE)
|
||||
{
|
||||
result = adc->ops->enabled(adc, (rt_uint32_t)args, RT_TRUE);
|
||||
}
|
||||
else if (cmd == RT_ADC_CMD_DISABLE)
|
||||
{
|
||||
result = adc->ops->enabled(adc, (rt_uint32_t)args, RT_FALSE);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rt_hw_adc_register(rt_adc_device_t device, const char *name, const struct rt_adc_ops *ops, const void *user_data)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
RT_ASSERT(ops != RT_NULL && ops->convert != RT_NULL);
|
||||
|
||||
device->parent.type = RT_Device_Class_Miscellaneous;
|
||||
device->parent.init = RT_NULL;
|
||||
device->parent.open = RT_NULL;
|
||||
device->parent.close = RT_NULL;
|
||||
device->parent.read = _adc_read;
|
||||
device->parent.write = RT_NULL;
|
||||
device->parent.control = _adc_control;
|
||||
|
||||
device->ops = ops;
|
||||
device->parent.user_data = (void *)user_data;
|
||||
|
||||
result = rt_device_register(&device->parent, name, RT_DEVICE_FLAG_RDWR);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_uint32_t channel)
|
||||
{
|
||||
rt_uint32_t value;
|
||||
|
||||
RT_ASSERT(dev);
|
||||
|
||||
dev->ops->convert(dev, channel, &value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_uint32_t channel)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
|
||||
RT_ASSERT(dev);
|
||||
if (dev->ops->enabled != RT_NULL)
|
||||
{
|
||||
result = dev->ops->enabled(dev, channel, RT_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = -RT_ENOSYS;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_uint32_t channel)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
|
||||
RT_ASSERT(dev);
|
||||
if (dev->ops->enabled != RT_NULL)
|
||||
{
|
||||
result = dev->ops->enabled(dev, channel, RT_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = -RT_ENOSYS;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
|
||||
static int adc(int argc, char **argv)
|
||||
{
|
||||
int value = 0;
|
||||
int result = RT_EOK;
|
||||
static rt_adc_device_t adc_device = RT_NULL;
|
||||
char *result_str;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (!strcmp(argv[1], "probe"))
|
||||
{
|
||||
if (argc == 3)
|
||||
{
|
||||
adc_device = (rt_adc_device_t)rt_device_find(argv[2]);
|
||||
result_str = (adc_device == RT_NULL) ? "failure" : "success";
|
||||
rt_kprintf("probe %s %s \n", argv[2], result_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("adc probe <adc_name> - probe adc by name\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (adc_device == RT_NULL)
|
||||
{
|
||||
rt_kprintf("Please using 'adc probe <adc_name>' first\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
if (!strcmp(argv[1], "enable"))
|
||||
{
|
||||
if (argc == 3)
|
||||
{
|
||||
result = rt_adc_enable(adc_device, atoi(argv[2]));
|
||||
result_str = (result == RT_EOK) ? "success" : "failure";
|
||||
rt_kprintf("%s channel %d enables %s \n", adc_device->parent.parent.name, atoi(argv[2]), result_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("adc enable <channel> - enable adc channel\n");
|
||||
}
|
||||
}
|
||||
else if (!strcmp(argv[1], "read"))
|
||||
{
|
||||
if (argc == 3)
|
||||
{
|
||||
value = rt_adc_read(adc_device, atoi(argv[2]));
|
||||
rt_kprintf("%s channel %d read value is 0x%08X \n", adc_device->parent.parent.name, atoi(argv[2]), value);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("adc read <channel> - read adc value on the channel\n");
|
||||
}
|
||||
}
|
||||
else if (!strcmp(argv[1], "disable"))
|
||||
{
|
||||
if (argc == 3)
|
||||
{
|
||||
result = rt_adc_disable(adc_device, atoi(argv[2]));
|
||||
result_str = (result == RT_EOK) ? "success" : "failure";
|
||||
rt_kprintf("%s channel %d disable %s \n", adc_device->parent.parent.name, atoi(argv[2]), result_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("adc disable <channel> - disable adc channel\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Unknown command. Please enter 'adc' for help\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Usage: \n");
|
||||
rt_kprintf("adc probe <adc_name> - probe adc by name\n");
|
||||
rt_kprintf("adc read <channel> - read adc value on the channel\n");
|
||||
rt_kprintf("adc disable <channel> - disable adc channel\n");
|
||||
rt_kprintf("adc enable <channel> - enable adc channel\n");
|
||||
result = -RT_ERROR;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
MSH_CMD_EXPORT(adc, adc function);
|
||||
|
||||
#endif /* FINSH_USING_MSH */
|
||||
@@ -0,0 +1,14 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = []
|
||||
CPPPATH = [cwd + '/../include']
|
||||
group = []
|
||||
|
||||
if GetDepend(['RT_USING_PM']):
|
||||
src = src + ['pm.c']
|
||||
|
||||
if len(src):
|
||||
group = DefineGroup('DeviceDrivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@
|
||||
#include <drivers/mmcsd_core.h>
|
||||
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME "[SDIO]"
|
||||
#define DBG_SECTION_NAME "SDIO"
|
||||
#ifdef RT_SDIO_DEBUG
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#else
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <drivers/mmc.h>
|
||||
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME "[SDIO]"
|
||||
#define DBG_SECTION_NAME "SDIO"
|
||||
#ifdef RT_SDIO_DEBUG
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#else
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <drivers/sdio.h>
|
||||
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME "[SDIO]"
|
||||
#define DBG_SECTION_NAME "SDIO"
|
||||
#ifdef RT_SDIO_DEBUG
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#else
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <drivers/sd.h>
|
||||
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME "[SDIO]"
|
||||
#define DBG_SECTION_NAME "SDIO"
|
||||
#ifdef RT_SDIO_DEBUG
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#else
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <drivers/sd.h>
|
||||
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME "[SDIO]"
|
||||
#define DBG_SECTION_NAME "SDIO"
|
||||
#ifdef RT_SDIO_DEBUG
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#else
|
||||
|
||||
@@ -70,19 +70,19 @@ static int serial_fops_open(struct dfs_fd *fd)
|
||||
switch (fd->flags & O_ACCMODE)
|
||||
{
|
||||
case O_RDONLY:
|
||||
dbg_log(DBG_LOG, "fops open: O_RDONLY!\n");
|
||||
LOG_D("fops open: O_RDONLY!");
|
||||
flags = RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_RDONLY;
|
||||
break;
|
||||
case O_WRONLY:
|
||||
dbg_log(DBG_LOG, "fops open: O_WRONLY!\n");
|
||||
LOG_D("fops open: O_WRONLY!");
|
||||
flags = RT_DEVICE_FLAG_WRONLY;
|
||||
break;
|
||||
case O_RDWR:
|
||||
dbg_log(DBG_LOG, "fops open: O_RDWR!\n");
|
||||
LOG_D("fops open: O_RDWR!");
|
||||
flags = RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_RDWR;
|
||||
break;
|
||||
default:
|
||||
dbg_log(DBG_ERROR, "fops open: unknown mode - %d!\n", fd->flags & O_ACCMODE);
|
||||
LOG_E("fops open: unknown mode - %d!", fd->flags & O_ACCMODE);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
serial = (struct rt_serial_device *)dev;
|
||||
|
||||
dbg_log(DBG_LOG, "open serial device: 0x%08x with open flag: 0x%04x\n",
|
||||
LOG_D("open serial device: 0x%08x with open flag: 0x%04x",
|
||||
dev, oflag);
|
||||
/* check device flag with the open flag */
|
||||
if ((oflag & RT_DEVICE_FLAG_DMA_RX) && !(dev->flag & RT_DEVICE_FLAG_DMA_RX))
|
||||
|
||||
@@ -402,14 +402,17 @@ static void sf(uint8_t argc, char **argv) {
|
||||
} else {
|
||||
char *spi_dev_name = argv[2];
|
||||
rtt_dev_bak = rtt_dev;
|
||||
|
||||
/* delete the old SPI flash device */
|
||||
if(rtt_dev_bak) {
|
||||
rt_sfud_flash_delete(rtt_dev_bak);
|
||||
}
|
||||
|
||||
rtt_dev = rt_sfud_flash_probe("sf_cmd", spi_dev_name);
|
||||
if (!rtt_dev) {
|
||||
return;
|
||||
}
|
||||
/* already probe then delete the old SPI flash device */
|
||||
if(rtt_dev_bak) {
|
||||
rt_sfud_flash_delete(rtt_dev_bak);
|
||||
}
|
||||
|
||||
sfud_dev = (sfud_flash_t)rtt_dev->user_data;
|
||||
if (sfud_dev->chip.capacity < 1024 * 1024) {
|
||||
rt_kprintf("%d KB %s is current selected device.\n", sfud_dev->chip.capacity / 1024, sfud_dev->name);
|
||||
|
||||
@@ -22,7 +22,12 @@
|
||||
|
||||
#ifdef RT_USB_DEVICE_CDC
|
||||
|
||||
#define TX_TIMEOUT 1000
|
||||
#ifdef RT_VCOM_TX_TIMEOUT
|
||||
#define VCOM_TX_TIMEOUT RT_VCOM_TX_TIMEOUT
|
||||
#else /*!RT_VCOM_TX_TIMEOUT*/
|
||||
#define VCOM_TX_TIMEOUT 1000
|
||||
#endif /*RT_VCOM_TX_TIMEOUT*/
|
||||
|
||||
#define CDC_RX_BUFSIZE 128
|
||||
#define CDC_MAX_PACKET_SIZE 64
|
||||
#define VCOM_DEVICE "vcom"
|
||||
@@ -82,6 +87,7 @@ struct vcom_tx_msg
|
||||
rt_size_t size;
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
static struct udevice_descriptor dev_desc =
|
||||
{
|
||||
USB_DESC_LENGTH_DEVICE, //bLength;
|
||||
@@ -101,6 +107,7 @@ static struct udevice_descriptor dev_desc =
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
ALIGN(4)
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier), //bLength
|
||||
@@ -115,6 +122,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
|
||||
};
|
||||
|
||||
/* communcation interface descriptor */
|
||||
ALIGN(4)
|
||||
const static struct ucdc_comm_descriptor _comm_desc =
|
||||
{
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
@@ -184,6 +192,7 @@ const static struct ucdc_comm_descriptor _comm_desc =
|
||||
};
|
||||
|
||||
/* data interface descriptor */
|
||||
ALIGN(4)
|
||||
const static struct ucdc_data_descriptor _data_desc =
|
||||
{
|
||||
/* interface descriptor */
|
||||
@@ -217,7 +226,7 @@ const static struct ucdc_data_descriptor _data_desc =
|
||||
0x00,
|
||||
},
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
static char serno[_SER_NO_LEN + 1] = {'\0'};
|
||||
RT_WEAK rt_err_t vcom_get_stored_serno(char *serno, int size);
|
||||
|
||||
@@ -225,7 +234,7 @@ rt_err_t vcom_get_stored_serno(char *serno, int size)
|
||||
{
|
||||
return RT_ERROR;
|
||||
}
|
||||
|
||||
ALIGN(4)
|
||||
const static char* _ustring[] =
|
||||
{
|
||||
"Language",
|
||||
@@ -876,7 +885,7 @@ static void vcom_tx_thread_entry(void* parameter)
|
||||
|
||||
rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request);
|
||||
|
||||
if (rt_completion_wait(&data->wait, TX_TIMEOUT) != RT_EOK)
|
||||
if (rt_completion_wait(&data->wait, VCOM_TX_TIMEOUT) != RT_EOK)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("vcom tx timeout\n"));
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ struct hid_s
|
||||
};
|
||||
|
||||
/* CustomHID_ConfigDescriptor */
|
||||
ALIGN(4)
|
||||
const rt_uint8_t _report_desc[]=
|
||||
{
|
||||
#ifdef RT_USB_DEVICE_HID_KEYBOARD
|
||||
@@ -239,6 +240,7 @@ const rt_uint8_t _report_desc[]=
|
||||
#endif
|
||||
}; /* CustomHID_ReportDescriptor */
|
||||
|
||||
ALIGN(4)
|
||||
static struct udevice_descriptor _dev_desc =
|
||||
{
|
||||
USB_DESC_LENGTH_DEVICE, //bLength;
|
||||
@@ -258,6 +260,7 @@ static struct udevice_descriptor _dev_desc =
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
ALIGN(4)
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier), //bLength
|
||||
@@ -273,6 +276,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
|
||||
|
||||
|
||||
/* hid interface descriptor */
|
||||
ALIGN(4)
|
||||
const static struct uhid_comm_descriptor _hid_comm_desc =
|
||||
{
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
@@ -357,7 +361,7 @@ const static struct uhid_comm_descriptor _hid_comm_desc =
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
ALIGN(4)
|
||||
const static char* _ustring[] =
|
||||
{
|
||||
"Language",
|
||||
|
||||
@@ -68,6 +68,7 @@ struct mstorage
|
||||
struct rt_device_blk_geometry geometry;
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
static struct udevice_descriptor dev_desc =
|
||||
{
|
||||
USB_DESC_LENGTH_DEVICE, //bLength;
|
||||
@@ -87,6 +88,7 @@ static struct udevice_descriptor dev_desc =
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
ALIGN(4)
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier), //bLength
|
||||
@@ -101,7 +103,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
|
||||
};
|
||||
|
||||
|
||||
|
||||
ALIGN(4)
|
||||
const static struct umass_descriptor _mass_desc =
|
||||
{
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
@@ -148,6 +150,7 @@ const static struct umass_descriptor _mass_desc =
|
||||
},
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
const static char* _ustring[] =
|
||||
{
|
||||
"Language",
|
||||
@@ -170,6 +173,7 @@ static rt_size_t _read_10(ufunction_t func, ustorage_cbw_t cbw);
|
||||
static rt_size_t _write_10(ufunction_t func, ustorage_cbw_t cbw);
|
||||
static rt_size_t _verify_10(ufunction_t func, ustorage_cbw_t cbw);
|
||||
|
||||
ALIGN(4)
|
||||
static struct scsi_cmd cmd_data[] =
|
||||
{
|
||||
{SCSI_TEST_UNIT_READY, _test_unit_ready, 6, FIXED, 0, DIR_NONE},
|
||||
|
||||
@@ -214,6 +214,7 @@ const static char* _ustring[] =
|
||||
USB_STRING_OS
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
|
||||
{
|
||||
.bFirstInterfaceNumber = USB_DYNAMIC,
|
||||
@@ -222,7 +223,9 @@ struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
|
||||
.subCompatibleID = {'5', '1', '6', '2', '0', '0', '1', 0x00},
|
||||
.reserved2 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
ALIGN(4)
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier), //bLength
|
||||
|
||||
@@ -24,6 +24,7 @@ struct winusb_device
|
||||
|
||||
typedef struct winusb_device * winusb_device_t;
|
||||
|
||||
ALIGN(4)
|
||||
static struct udevice_descriptor dev_desc =
|
||||
{
|
||||
USB_DESC_LENGTH_DEVICE, //bLength;
|
||||
@@ -41,7 +42,9 @@ static struct udevice_descriptor dev_desc =
|
||||
USB_STRING_SERIAL_INDEX, //iSerialNumber;
|
||||
USB_DYNAMIC, //bNumConfigurations;
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
ALIGN(4)
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier), //bLength
|
||||
@@ -55,6 +58,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
|
||||
0,
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
struct winusb_descriptor _winusb_desc =
|
||||
{
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
@@ -102,7 +106,7 @@ struct winusb_descriptor _winusb_desc =
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
ALIGN(4)
|
||||
const static char* _ustring[] =
|
||||
{
|
||||
"Language",
|
||||
@@ -113,11 +117,14 @@ const static char* _ustring[] =
|
||||
"Interface",
|
||||
USB_STRING_OS//must be
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
struct usb_os_proerty winusb_proerty[] =
|
||||
{
|
||||
USB_OS_PROERTY_DESC(USB_OS_PROERTY_TYPE_REG_SZ,"DeviceInterfaceGUID",RT_WINUSB_GUID),
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
struct usb_os_function_comp_id_descriptor winusb_func_comp_id_desc =
|
||||
{
|
||||
.bFirstInterfaceNumber = USB_DYNAMIC,
|
||||
|
||||
@@ -639,7 +639,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
int level = *((int *)args);
|
||||
|
||||
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_POWERSAVE, "RT_WLAN_CMD_SET_POWERSAVE");
|
||||
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_SET_POWERSAVE, "RT_WLAN_CMD_SET_POWERSAVE");
|
||||
if (wlan->ops->wlan_set_powersave)
|
||||
wlan->ops->wlan_set_powersave(wlan, level);
|
||||
break;
|
||||
@@ -648,7 +648,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
int *level = args;
|
||||
|
||||
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_POWERSAVE, "RT_WLAN_CMD_GET_POWERSAVE");
|
||||
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_GET_POWERSAVE, "RT_WLAN_CMD_GET_POWERSAVE");
|
||||
if (wlan->ops->wlan_get_powersave)
|
||||
*level = wlan->ops->wlan_get_powersave(wlan);
|
||||
break;
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
|
||||
#include "finsh.h"
|
||||
|
||||
long hello(void)
|
||||
@@ -98,6 +101,17 @@ static long _list_thread(struct rt_list_node *list)
|
||||
else if (stat == RT_THREAD_INIT) rt_kprintf(" init ");
|
||||
else if (stat == RT_THREAD_CLOSE) rt_kprintf(" close ");
|
||||
|
||||
#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
|
||||
ptr = (rt_uint8_t *)thread->stack_addr + thread->stack_size;
|
||||
while (*ptr == '#')ptr --;
|
||||
|
||||
rt_kprintf(" 0x%08x 0x%08x %02d%% 0x%08x %03d\n",
|
||||
((rt_ubase_t)thread->sp - (rt_ubase_t)thread->stack_addr),
|
||||
thread->stack_size,
|
||||
((rt_ubase_t)ptr - (rt_ubase_t)thread->stack_addr) * 100 / thread->stack_size,
|
||||
thread->remaining_tick,
|
||||
thread->error);
|
||||
#else
|
||||
ptr = (rt_uint8_t *)thread->stack_addr;
|
||||
while (*ptr == '#')ptr ++;
|
||||
|
||||
@@ -108,6 +122,7 @@ static long _list_thread(struct rt_list_node *list)
|
||||
/ thread->stack_size,
|
||||
thread->remaining_tick,
|
||||
thread->error);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -831,3 +846,6 @@ void list_prefix(char *prefix)
|
||||
static int dummy = 0;
|
||||
FINSH_VAR_EXPORT(dummy, finsh_type_int, dummy variable for finsh)
|
||||
#endif
|
||||
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
* 2014-01-03 Bernard msh can execute module.
|
||||
* 2017-07-19 Aubr.Cool limit argc to RT_FINSH_ARG_MAX
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
|
||||
#include "msh.h"
|
||||
#include <finsh.h>
|
||||
@@ -610,3 +613,4 @@ void msh_auto_complete(char *prefix)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FINSH_USING_MSH */
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <finsh.h>
|
||||
|
||||
#include "msh.h"
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
|
||||
#include <finsh.h>
|
||||
#include "msh.h"
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_posix.h>
|
||||
|
||||
@@ -418,5 +419,4 @@ int cmd_free(int argc, char **argv)
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(cmd_free, __cmd_free, Show the memory usage in the system.);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* FINSH_USING_MSH */
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <finsh.h>
|
||||
|
||||
#include "msh.h"
|
||||
|
||||
#if defined(FINSH_USING_MSH) && defined(RT_USING_DFS)
|
||||
|
||||
#include <finsh.h>
|
||||
#include "msh.h"
|
||||
#include <dfs_posix.h>
|
||||
|
||||
static int msh_readline(int fd, char *line_buf, int size)
|
||||
@@ -137,4 +137,5 @@ int msh_exec_script(const char *cmd_line, int size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* defined(FINSH_USING_MSH) && defined(RT_USING_DFS) */
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include <rthw.h>
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
|
||||
#include "finsh.h"
|
||||
#include "shell.h"
|
||||
|
||||
@@ -847,3 +849,6 @@ int finsh_system_init(void)
|
||||
return 0;
|
||||
}
|
||||
INIT_APP_EXPORT(finsh_system_init);
|
||||
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
|
||||
#include "finsh.h"
|
||||
|
||||
long hello(void);
|
||||
@@ -63,3 +68,6 @@ struct finsh_syscall *_syscall_table_end = &_syscall_table[sizeof(_syscall_tab
|
||||
struct finsh_sysvar *_sysvar_table_begin = NULL;
|
||||
struct finsh_sysvar *_sysvar_table_end = NULL;
|
||||
#endif
|
||||
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
Import('rtconfig')
|
||||
from building import *
|
||||
|
||||
src = Glob('*.c')
|
||||
comm = 'libcpu/' + rtconfig.ARCH
|
||||
if (rtconfig.CPU == 'cortex-m4') or (rtconfig.CPU == 'cortex-m3'):
|
||||
comm = 'libcpu/cortexm'
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
if rtconfig.PLATFORM == 'armcc':
|
||||
src = src + Glob(comm + '/*.c') + Glob(comm + '/*_rvds.S')
|
||||
|
||||
if rtconfig.PLATFORM == 'gcc':
|
||||
src = src + Glob(comm + '/*.c') + Glob(comm + '/*_gcc.S')
|
||||
|
||||
if rtconfig.PLATFORM == 'iar':
|
||||
src = src + Glob(comm + '/*.c') + Glob(comm + '/*_iar.S')
|
||||
|
||||
CPPPATH = [cwd, cwd + '/' + comm]
|
||||
|
||||
group = DefineGroup('gdb', src, depend = ['RT_USING_GDB'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* This provides the functions that GDB needs to share between
|
||||
* different portions.
|
||||
*
|
||||
* GDB stub.
|
||||
*
|
||||
* Migarte form linux to rt-thread by Wzyy2
|
||||
* Original edition : KGDB stub
|
||||
*
|
||||
* File : gdb_stub.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Develop 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
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2014-07-04 Wzyy2 first version
|
||||
*/
|
||||
#ifndef __GDB_STUB_H__
|
||||
#define __GDB_STUB_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <arch_gdb.h>
|
||||
|
||||
|
||||
#ifndef RT_GDB_MAX_BREAKPOINTS
|
||||
#define GDB_MAX_BREAKPOINTS 20
|
||||
#else
|
||||
#define GDB_MAX_BREAKPOINTS RT_GDB_MAX_BREAKPOINTS
|
||||
#endif
|
||||
|
||||
|
||||
// Signal definitions
|
||||
#define SIGHUP 1 /* hangup */
|
||||
#define SIGINT 2 /* interrupt */ //irq or fiq
|
||||
#define SIGQUIT 3 /* quit */
|
||||
#define SIGILL 4 /* illegal instruction (not reset when caught) */
|
||||
#define SIGTRAP 5 /* trace trap (not reset when caught) */
|
||||
#define SIGIOT 6 /* IOT instruction */
|
||||
#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
|
||||
#define SIGEMT 7 /* EMT instruction */
|
||||
#define SIGFPE 8 /* floating point exception */
|
||||
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
||||
#define SIGBUS 10 /* bus error */ //abort or reserved
|
||||
#define SIGSEGV 11 /* segmentation violation */
|
||||
#define SIGSYS 12 /* bad argument to system call */
|
||||
#define SIGPIPE 13 /* write on a pipe with no one to read it */
|
||||
#define SIGALRM 14 /* alarm clock */
|
||||
#define SIGTERM 15 /* software termination signal from kill */
|
||||
|
||||
enum gdb_bptype {
|
||||
BP_BREAKPOINT = 0,
|
||||
BP_HARDWARE_BREAKPOINT,
|
||||
BP_WRITE_WATCHPOINT,
|
||||
BP_READ_WATCHPOINT,
|
||||
BP_ACCESS_WATCHPOINT,
|
||||
BP_POKE_BREAKPOINT,
|
||||
};
|
||||
|
||||
enum gdb_bpstate {
|
||||
BP_UNDEFINED = 0,
|
||||
BP_REMOVED,
|
||||
BP_SET,
|
||||
BP_ACTIVE
|
||||
};
|
||||
|
||||
struct gdb_bkpt {
|
||||
unsigned long bpt_addr;
|
||||
unsigned char saved_instr[BREAK_INSTR_SIZE];
|
||||
enum gdb_bptype type;
|
||||
enum gdb_bpstate state;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct gdb_arch - Describe architecture specific values.
|
||||
* @gdb_bpt_instr: The instruction to trigger a breakpoint.
|
||||
* @flags: Flags for the breakpoint, currently just %GDB_HW_BREAKPOINT.
|
||||
* @set_hw_breakpoint: Allow an architecture to specify how to set a hardware
|
||||
* breakpoint.
|
||||
* @remove_hw_breakpoint: Allow an architecture to specify how to remove a
|
||||
* hardware breakpoint.
|
||||
* @remove_all_hw_break: Allow an architecture to specify how to remove all
|
||||
* hardware breakpoints.
|
||||
*/
|
||||
struct gdb_arch {
|
||||
unsigned char gdb_bpt_instr[BREAK_INSTR_SIZE];
|
||||
unsigned long flags;
|
||||
|
||||
int (*set_hw_breakpoint)(unsigned long, int, enum gdb_bptype);
|
||||
int (*remove_hw_breakpoint)(unsigned long, int, enum gdb_bptype);
|
||||
void (*remove_all_hw_break)(void);
|
||||
};
|
||||
/**
|
||||
* struct gdb_io - Describe the interface for an I/O driver to talk with KGDB.
|
||||
* @read_char: Pointer to a function that will return one char.
|
||||
* @write_char: Pointer to a function that will write one char.
|
||||
* @flush: Pointer to a function that will flush any pending writes.
|
||||
* @init: Pointer to a function that will initialize the device.
|
||||
*/
|
||||
struct gdb_io {
|
||||
int (*read_char) (void);
|
||||
void (*write_char) (char);
|
||||
void (*flush) (void);
|
||||
int (*init) (void);
|
||||
};
|
||||
|
||||
extern int gdb_connected;
|
||||
extern void* volatile gdb_mem_fault_handler;
|
||||
|
||||
int gdb_hex2long(char **ptr, unsigned long *long_val);
|
||||
int gdb_mem2hex(char *mem, char *buf, int count);
|
||||
int gdb_hex2mem(char *buf, char *mem, int count);
|
||||
int gdb_ebin2mem(char *buf, char *mem, int count);
|
||||
int gdb_set_sw_break(unsigned long addr);
|
||||
int gdb_remove_sw_break(unsigned long addr);
|
||||
int gdb_isremovedbreak(unsigned long addr);
|
||||
void gdb_console_write(const char *s, unsigned count);
|
||||
int gdb_handle_exception(int signo, void *regs);
|
||||
|
||||
/* hal */
|
||||
extern struct gdb_io gdb_io_ops;
|
||||
extern rt_device_t gdb_dev;
|
||||
void gdb_start();
|
||||
void gdb_set_device(const char* device_name);
|
||||
|
||||
|
||||
|
||||
#endif /* __GDB_STUB_H__ */
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* I/O and interface portion of GDB stub
|
||||
*
|
||||
* File : hal_stub.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Develop 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
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2014-07-04 Wzyy2 first version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include "gdb_stub.h"
|
||||
|
||||
#ifdef RT_USING_SERIAL
|
||||
#include <rtdevice.h>
|
||||
#endif
|
||||
|
||||
rt_device_t gdb_dev = RT_NULL;
|
||||
static struct rt_serial_device *gdb_serial;
|
||||
char gdb_io_set;
|
||||
|
||||
void gdb_uart_putc(char c);
|
||||
int gdb_uart_getc();
|
||||
|
||||
|
||||
/*if you want to use something instead of the serial,change it */
|
||||
struct gdb_io gdb_io_ops = {
|
||||
gdb_uart_getc,
|
||||
gdb_uart_putc
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup gdb_stub
|
||||
*
|
||||
* This function will get GDB stubs started, with a proper environment
|
||||
*/
|
||||
void gdb_start()
|
||||
{
|
||||
if (gdb_dev == RT_NULL)
|
||||
rt_kprintf("GDB: no gdb_dev found,please set it first\n");
|
||||
else
|
||||
gdb_breakpoint();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup gdb_stub
|
||||
*
|
||||
* This function sets the input device of gdb_stub.
|
||||
*
|
||||
* @param device_name the name of new input device.
|
||||
*/
|
||||
void gdb_set_device(const char* device_name)
|
||||
{
|
||||
rt_device_t dev = RT_NULL;
|
||||
dev = rt_device_find(device_name);
|
||||
if(dev == RT_NULL){
|
||||
rt_kprintf("GDB: can not find device: %s\n", device_name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* open this device and set the new device */
|
||||
if (rt_device_open(dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_STREAM) == RT_EOK)
|
||||
{
|
||||
gdb_dev = dev;
|
||||
gdb_serial = (struct rt_serial_device *)gdb_dev;
|
||||
}
|
||||
}
|
||||
|
||||
void gdb_uart_putc(char c)
|
||||
{
|
||||
#ifdef RT_GDB_DEBUG
|
||||
rt_kprintf("%c",c);
|
||||
#endif
|
||||
rt_device_write(gdb_dev, 0, &c, 1);
|
||||
}
|
||||
|
||||
/* polling */
|
||||
int gdb_uart_getc()
|
||||
{
|
||||
int ch;
|
||||
|
||||
#ifdef RT_USING_SERIAL
|
||||
ch = -1;
|
||||
do {
|
||||
ch = gdb_serial->ops->getc(gdb_serial);
|
||||
} while (ch == -1);
|
||||
#else
|
||||
rt_device_read(gdb_dev, 0, &ch, 1);
|
||||
#endif
|
||||
|
||||
#ifdef RT_GDB_DEBUG
|
||||
rt_kprintf("%c",ch);
|
||||
#endif
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* ARM GDB support
|
||||
* arch-specific portion of GDB stub
|
||||
*
|
||||
* File : arch_gdb.h(arm)
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Develop 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
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2014-07-04 wzyy2 first version
|
||||
*/
|
||||
#ifndef __ARM_GDB_H__
|
||||
#define __ARM_GDB_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
|
||||
#ifndef RT_GDB_HAVE_HWBP
|
||||
#define RT_GDB_HAVE_HWBP 0
|
||||
#endif
|
||||
#ifndef RT_GDB_HAVE_SWBP
|
||||
#define RT_GDB_HAVE_SWBP 1
|
||||
#endif
|
||||
|
||||
|
||||
#if RT_GDB_HAVE_HWBP
|
||||
#error GDB:No hardware_breakpoint support
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* By doing this as an undefined instruction trap, we force a mode
|
||||
* switch from SVC to UND mode, allowing us to save full kernel state.
|
||||
* We also define a GDB_COMPILED_BREAK which can be used to compile
|
||||
* in breakpoints.
|
||||
*/
|
||||
#define BREAK_INSTR_SIZE 4
|
||||
#define GDB_BREAKINST 0xe7ffdefe
|
||||
#define GDB_COMPILED_BREAK 0xe7ffdeff
|
||||
#define CACHE_FLUSH_IS_SAFE 1
|
||||
|
||||
#define ARM_GP_REGS 16
|
||||
#define ARM_FP_REGS 8
|
||||
#define ARM_EXTRA_REGS 2
|
||||
#define GDB_MAX_REGS (ARM_GP_REGS + (ARM_FP_REGS * 3) + ARM_EXTRA_REGS)
|
||||
#define NUMREGBYTES (GDB_MAX_REGS << 2)
|
||||
|
||||
|
||||
//#define BUFMAX ((NUMREGBYTES << 1) + 10)
|
||||
#define BUFMAX 400
|
||||
|
||||
enum regnames {
|
||||
GDB_R0, /*0*/
|
||||
GDB_R1, /*1*/
|
||||
GDB_R2, /*2*/
|
||||
GDB_R3, /*3*/
|
||||
GDB_R4, /*4*/
|
||||
GDB_R5, /*5*/
|
||||
GDB_R6, /*6*/
|
||||
GDB_R7, /*7*/
|
||||
GDB_R8, /*8*/
|
||||
GDB_R9, /*9*/
|
||||
GDB_R10, /*10*/
|
||||
GDB_FP, /*11*/
|
||||
GDB_IP, /*12*/
|
||||
GDB_SPT, /*13*/
|
||||
GDB_LR, /*14*/
|
||||
GDB_PC, /*15*/
|
||||
GDB_CPSR = GDB_MAX_REGS-1
|
||||
};
|
||||
|
||||
/* arch */
|
||||
extern struct gdb_arch arch_gdb_ops;
|
||||
void gdb_breakpoint();
|
||||
void gdb_get_register(unsigned long *gdb_regs);
|
||||
void gdb_put_register(unsigned long *gdb_regs);
|
||||
void gdb_set_register(void *hw_regs);
|
||||
int gdb_arch_handle_exception(char *remcom_in_buffer,
|
||||
char *remcom_out_buffer);
|
||||
void gdb_flush_icache_range(unsigned long start, unsigned long end);
|
||||
int gdb_undef_hook(void *regs);
|
||||
|
||||
int gdb_handle_exception(int signo, void *regs);
|
||||
|
||||
#endif /* __ARM_GDB_H__ */
|
||||
@@ -1,499 +0,0 @@
|
||||
/*
|
||||
* ARM GDB support
|
||||
* arch-specific portion of GDB stub
|
||||
*
|
||||
* File : arm_stub.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Develop 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
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2014-07-04 Wzyy2 first version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include <gdb_stub.h>
|
||||
#include <arch_gdb.h>
|
||||
|
||||
#define PS_N 0x80000000
|
||||
#define PS_Z 0x40000000
|
||||
#define PS_C 0x20000000
|
||||
#define PS_V 0x10000000
|
||||
|
||||
#define IS_THUMB_ADDR(addr) ((addr) & 1)
|
||||
#define MAKE_THUMB_ADDR(addr) ((addr) | 1)
|
||||
#define UNMAKE_THUMB_ADDR(addr) ((addr) & ~1)
|
||||
|
||||
static int compiled_break = 0;
|
||||
static unsigned long step_addr = 0;
|
||||
static int ins_will_execute(unsigned long ins);
|
||||
static unsigned long target_ins(unsigned long *pc, unsigned long ins);
|
||||
|
||||
|
||||
/*struct gdb_arch - Describe architecture specific values.*/
|
||||
struct gdb_arch arch_gdb_ops = {
|
||||
.gdb_bpt_instr = {0xfe, 0xde, 0xff, 0xe7} //Little-Endian
|
||||
};
|
||||
|
||||
struct rt_gdb_register
|
||||
{
|
||||
rt_uint32_t r0;
|
||||
rt_uint32_t r1;
|
||||
rt_uint32_t r2;
|
||||
rt_uint32_t r3;
|
||||
rt_uint32_t r4;
|
||||
rt_uint32_t r5;
|
||||
rt_uint32_t r6;
|
||||
rt_uint32_t r7;
|
||||
rt_uint32_t r8;
|
||||
rt_uint32_t r9;
|
||||
rt_uint32_t r10;
|
||||
rt_uint32_t fp;
|
||||
rt_uint32_t ip;
|
||||
rt_uint32_t sp;
|
||||
rt_uint32_t lr;
|
||||
rt_uint32_t pc;
|
||||
rt_uint32_t cpsr;
|
||||
rt_uint32_t ORIG_r0;
|
||||
}*regs;
|
||||
|
||||
/**
|
||||
* gdb_breakpoint - generate a compiled_breadk
|
||||
* It is used to sync up with a debugger and stop progarm
|
||||
*/
|
||||
void gdb_breakpoint()
|
||||
{
|
||||
asm(".word 0xe7ffdeff");
|
||||
}
|
||||
|
||||
void gdb_set_register(void *hw_regs)
|
||||
{
|
||||
regs = (struct rt_gdb_register *)hw_regs;
|
||||
}
|
||||
void gdb_get_register(unsigned long *gdb_regs)
|
||||
{
|
||||
int regno;
|
||||
/* Initialize all to zero. */
|
||||
for (regno = 0; regno < GDB_MAX_REGS; regno++)
|
||||
gdb_regs[regno] = 0;
|
||||
|
||||
gdb_regs[GDB_R0] = regs->r0;
|
||||
gdb_regs[GDB_R1] = regs->r1;
|
||||
gdb_regs[GDB_R2] = regs->r2;
|
||||
gdb_regs[GDB_R3] = regs->r3;
|
||||
gdb_regs[GDB_R4] = regs->r4;
|
||||
gdb_regs[GDB_R5] = regs->r5;
|
||||
gdb_regs[GDB_R6] = regs->r6;
|
||||
gdb_regs[GDB_R7] = regs->r7;
|
||||
gdb_regs[GDB_R8] = regs->r8;
|
||||
gdb_regs[GDB_R9] = regs->r9;
|
||||
gdb_regs[GDB_R10] = regs->r10;
|
||||
gdb_regs[GDB_FP] = regs->fp;
|
||||
gdb_regs[GDB_IP] = regs->ip;
|
||||
gdb_regs[GDB_SPT] = regs->sp;
|
||||
gdb_regs[GDB_LR] = regs->lr;
|
||||
gdb_regs[GDB_PC] = regs->pc;
|
||||
gdb_regs[GDB_CPSR] = regs->cpsr;
|
||||
|
||||
};
|
||||
|
||||
|
||||
void gdb_put_register(unsigned long *gdb_regs)
|
||||
{
|
||||
regs->r0 = gdb_regs[GDB_R0];
|
||||
regs->r1 = gdb_regs[GDB_R1];
|
||||
regs->r2 = gdb_regs[GDB_R2];
|
||||
regs->r3 = gdb_regs[GDB_R3];
|
||||
regs->r4 = gdb_regs[GDB_R4];
|
||||
regs->r5 = gdb_regs[GDB_R5];
|
||||
regs->r6 = gdb_regs[GDB_R6];
|
||||
regs->r7 = gdb_regs[GDB_R7];
|
||||
regs->r8 = gdb_regs[GDB_R8];
|
||||
regs->r9 = gdb_regs[GDB_R9];
|
||||
regs->r10 = gdb_regs[GDB_R10];
|
||||
regs->fp = gdb_regs[GDB_FP];
|
||||
regs->ip = gdb_regs[GDB_IP];
|
||||
regs->sp = gdb_regs[GDB_SPT];
|
||||
regs->lr = gdb_regs[GDB_LR];
|
||||
regs->pc = gdb_regs[GDB_PC];
|
||||
regs->cpsr = gdb_regs[GDB_CPSR];
|
||||
}
|
||||
|
||||
|
||||
/* It will be called during process_packet */
|
||||
int gdb_arch_handle_exception(char *remcom_in_buffer,
|
||||
char *remcom_out_buffer)
|
||||
{
|
||||
unsigned long addr,curins;
|
||||
char *ptr;
|
||||
|
||||
/*clear single step*/
|
||||
if (step_addr) {
|
||||
gdb_remove_sw_break(step_addr);
|
||||
step_addr = 0;
|
||||
}
|
||||
|
||||
switch (remcom_in_buffer[0]) {
|
||||
case 'D':
|
||||
case 'k':
|
||||
case 'c':
|
||||
/*
|
||||
* If this was a compiled breakpoint, we need to move
|
||||
* to the next instruction or we will breakpoint
|
||||
* over and over again
|
||||
*/
|
||||
ptr = &remcom_in_buffer[1];
|
||||
if (gdb_hex2long(&ptr, &addr))
|
||||
regs->pc = addr;
|
||||
else if (compiled_break == 1)
|
||||
regs->pc += 4;
|
||||
compiled_break = 0;
|
||||
return 0;
|
||||
|
||||
case 's':
|
||||
ptr = &remcom_in_buffer[1];
|
||||
if (gdb_hex2long(&ptr, &addr))
|
||||
regs->pc = addr;
|
||||
|
||||
curins = *(unsigned long*)(regs->pc);
|
||||
if (ins_will_execute(curins))
|
||||
//Decode instruction to decide what the next pc will be
|
||||
step_addr = target_ins((unsigned long *)regs->pc, curins);
|
||||
else
|
||||
step_addr = regs->pc + 4;
|
||||
|
||||
#ifdef RT_GDB_DEBUG
|
||||
rt_kprintf("\n next will be %x \n",step_addr);
|
||||
#endif
|
||||
gdb_set_sw_break(step_addr);
|
||||
|
||||
if (compiled_break == 1)
|
||||
regs->pc += 4;
|
||||
compiled_break = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
/* flush icache to let the sw breakpoint working */
|
||||
void gdb_flush_icache_range(unsigned long start, unsigned long end)
|
||||
{
|
||||
#ifdef RT_GDB_ICACHE
|
||||
extern void mmu_invalidate_icache();
|
||||
mmu_invalidate_icache(); //for arm,wo can only invalidate it
|
||||
#endif
|
||||
}
|
||||
|
||||
/* register a hook in undef*/
|
||||
int gdb_undef_hook(void *regs)
|
||||
{
|
||||
struct rt_gdb_register *tmp_reg = (struct rt_gdb_register *)regs;
|
||||
unsigned long *tmp_pc = (unsigned long *)tmp_reg->pc;
|
||||
|
||||
/* it is a compiled break */
|
||||
if (*tmp_pc == GDB_COMPILED_BREAK) {
|
||||
compiled_break = 1;
|
||||
gdb_handle_exception(SIGTRAP, regs);
|
||||
return 1;
|
||||
|
||||
}
|
||||
/* it is a sw break */
|
||||
else if (*tmp_pc == GDB_BREAKINST) {
|
||||
gdb_handle_exception(SIGTRAP, regs);
|
||||
return 1;
|
||||
}
|
||||
/*or we just go */
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static unsigned long gdb_arch_regs[GDB_MAX_REGS];
|
||||
static int ins_will_execute(unsigned long ins)
|
||||
{
|
||||
unsigned long psr = regs->cpsr; // condition codes
|
||||
int res = 0;
|
||||
switch ((ins & 0xF0000000) >> 28) {
|
||||
case 0x0: // EQ
|
||||
res = (psr & PS_Z) != 0;
|
||||
break;
|
||||
case 0x1: // NE
|
||||
res = (psr & PS_Z) == 0;
|
||||
break;
|
||||
case 0x2: // CS
|
||||
res = (psr & PS_C) != 0;
|
||||
break;
|
||||
case 0x3: // CC
|
||||
res = (psr & PS_C) == 0;
|
||||
break;
|
||||
case 0x4: // MI
|
||||
res = (psr & PS_N) != 0;
|
||||
break;
|
||||
case 0x5: // PL
|
||||
res = (psr & PS_N) == 0;
|
||||
break;
|
||||
case 0x6: // VS
|
||||
res = (psr & PS_V) != 0;
|
||||
break;
|
||||
case 0x7: // VC
|
||||
res = (psr & PS_V) == 0;
|
||||
break;
|
||||
case 0x8: // HI
|
||||
res = ((psr & PS_C) != 0) && ((psr & PS_Z) == 0);
|
||||
break;
|
||||
case 0x9: // LS
|
||||
res = ((psr & PS_C) == 0) || ((psr & PS_Z) != 0);
|
||||
break;
|
||||
case 0xA: // GE
|
||||
res = ((psr & (PS_N|PS_V)) == (PS_N|PS_V)) ||
|
||||
((psr & (PS_N|PS_V)) == 0);
|
||||
break;
|
||||
case 0xB: // LT
|
||||
res = ((psr & (PS_N|PS_V)) == PS_N) ||
|
||||
((psr & (PS_N|PS_V)) == PS_V);
|
||||
break;
|
||||
case 0xC: // GT
|
||||
res = ((psr & (PS_N|PS_V)) == (PS_N|PS_V)) ||
|
||||
((psr & (PS_N|PS_V)) == 0);
|
||||
res = ((psr & PS_Z) == 0) && res;
|
||||
break;
|
||||
case 0xD: // LE
|
||||
res = ((psr & (PS_N|PS_V)) == PS_N) ||
|
||||
((psr & (PS_N|PS_V)) == PS_V);
|
||||
res = ((psr & PS_Z) == PS_Z) || res;
|
||||
break;
|
||||
case 0xE: // AL
|
||||
res = 1;
|
||||
break;
|
||||
case 0xF: // NV
|
||||
if (((ins & 0x0E000000) >> 24) == 0xA)
|
||||
res = 1;
|
||||
else
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static unsigned long RmShifted(int shift)
|
||||
{
|
||||
unsigned long Rm = gdb_arch_regs[shift & 0x00F];
|
||||
int shift_count;
|
||||
if ((shift & 0x010) == 0) {
|
||||
shift_count = (shift & 0xF80) >> 7;
|
||||
} else {
|
||||
shift_count = gdb_arch_regs[(shift & 0xF00) >> 8];
|
||||
}
|
||||
switch ((shift & 0x060) >> 5) {
|
||||
case 0x0: // Logical left
|
||||
Rm <<= shift_count;
|
||||
break;
|
||||
case 0x1: // Logical right
|
||||
Rm >>= shift_count;
|
||||
break;
|
||||
case 0x2: // Arithmetic right
|
||||
Rm = (unsigned long)((long)Rm >> shift_count);
|
||||
break;
|
||||
case 0x3: // Rotate right
|
||||
if (shift_count == 0) {
|
||||
// Special case, RORx
|
||||
Rm >>= 1;
|
||||
if (gdb_arch_regs[GDB_CPSR] & PS_C) Rm |= 0x80000000;
|
||||
} else {
|
||||
Rm = (Rm >> shift_count) | (Rm << (32-shift_count));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return Rm;
|
||||
}
|
||||
|
||||
// Decide the next instruction to be executed for a given instruction
|
||||
static unsigned long target_ins(unsigned long *pc, unsigned long ins)
|
||||
{
|
||||
unsigned long new_pc, offset, op2;
|
||||
unsigned long Rn;
|
||||
int i, reg_count, c;
|
||||
|
||||
gdb_get_register(gdb_arch_regs);
|
||||
|
||||
switch ((ins & 0x0C000000) >> 26) {
|
||||
case 0x0:
|
||||
// BX or BLX
|
||||
if ((ins & 0x0FFFFFD0) == 0x012FFF10) {
|
||||
new_pc = (unsigned long)gdb_arch_regs[ins & 0x0000000F];
|
||||
return new_pc;
|
||||
}
|
||||
// Data processing
|
||||
new_pc = (unsigned long)(pc+1);
|
||||
if ((ins & 0x0000F000) == 0x0000F000) {
|
||||
// Destination register is PC
|
||||
if ((ins & 0x0FBF0000) != 0x010F0000) {
|
||||
Rn = (unsigned long)gdb_arch_regs[(ins & 0x000F0000) >> 16];
|
||||
if ((ins & 0x000F0000) == 0x000F0000) Rn += 8; // PC prefetch!
|
||||
if ((ins & 0x02000000) == 0) {
|
||||
op2 = RmShifted(ins & 0x00000FFF);
|
||||
} else {
|
||||
op2 = ins & 0x000000FF;
|
||||
i = (ins & 0x00000F00) >> 8; // Rotate count
|
||||
op2 = (op2 >> (i*2)) | (op2 << (32-(i*2)));
|
||||
}
|
||||
switch ((ins & 0x01E00000) >> 21) {
|
||||
case 0x0: // AND
|
||||
new_pc = Rn & op2;
|
||||
break;
|
||||
case 0x1: // EOR
|
||||
new_pc = Rn ^ op2;
|
||||
break;
|
||||
case 0x2: // SUB
|
||||
new_pc = Rn - op2;
|
||||
break;
|
||||
case 0x3: // RSB
|
||||
new_pc = op2 - Rn;
|
||||
break;
|
||||
case 0x4: // ADD
|
||||
new_pc = Rn + op2;
|
||||
break;
|
||||
case 0x5: // ADC
|
||||
c = (gdb_arch_regs[GDB_CPSR] & PS_C) != 0;
|
||||
new_pc = Rn + op2 + c;
|
||||
break;
|
||||
case 0x6: // SBC
|
||||
c = (gdb_arch_regs[GDB_CPSR] & PS_C) != 0;
|
||||
new_pc = Rn - op2 + c - 1;
|
||||
break;
|
||||
case 0x7: // RSC
|
||||
c = (gdb_arch_regs[GDB_CPSR] & PS_C) != 0;
|
||||
new_pc = op2 - Rn +c - 1;
|
||||
break;
|
||||
case 0x8: // TST
|
||||
case 0x9: // TEQ
|
||||
case 0xA: // CMP
|
||||
case 0xB: // CMN
|
||||
break; // PC doesn't change
|
||||
case 0xC: // ORR
|
||||
new_pc = Rn | op2;
|
||||
break;
|
||||
case 0xD: // MOV
|
||||
new_pc = op2;
|
||||
break;
|
||||
case 0xE: // BIC
|
||||
new_pc = Rn & ~op2;
|
||||
break;
|
||||
case 0xF: // MVN
|
||||
new_pc = ~op2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new_pc;
|
||||
case 0x1:
|
||||
if ((ins & 0x02000010) == 0x02000010) {
|
||||
// Undefined!
|
||||
return (unsigned long)(pc+1);
|
||||
} else {
|
||||
if ((ins & 0x00100000) == 0) {
|
||||
// STR
|
||||
return (unsigned long)(pc+1);
|
||||
} else {
|
||||
// LDR
|
||||
if ((ins & 0x0000F000) != 0x0000F000) {
|
||||
// Rd not PC
|
||||
return (unsigned long)(pc+1);
|
||||
} else {
|
||||
Rn = (unsigned long)gdb_arch_regs[(ins & 0x000F0000) >> 16];
|
||||
if ((ins & 0x000F0000) == 0x000F0000) Rn += 8; // PC prefetch!
|
||||
if (ins & 0x01000000) {
|
||||
// Add/subtract offset before
|
||||
if ((ins & 0x02000000) == 0) {
|
||||
// Immediate offset
|
||||
if (ins & 0x00800000) {
|
||||
// Add offset
|
||||
Rn += (ins & 0x00000FFF);
|
||||
} else {
|
||||
// Subtract offset
|
||||
Rn -= (ins & 0x00000FFF);
|
||||
}
|
||||
} else {
|
||||
// Offset is in a register
|
||||
if (ins & 0x00800000) {
|
||||
// Add offset
|
||||
Rn += RmShifted(ins & 0x00000FFF);
|
||||
} else {
|
||||
// Subtract offset
|
||||
Rn -= RmShifted(ins & 0x00000FFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
return *(unsigned long *)Rn;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (unsigned long)(pc+1);
|
||||
case 0x2: // Branch, LDM/STM
|
||||
if ((ins & 0x02000000) == 0) {
|
||||
// LDM/STM
|
||||
if ((ins & 0x00100000) == 0) {
|
||||
// STM
|
||||
return (unsigned long)(pc+1);
|
||||
} else {
|
||||
// LDM
|
||||
if ((ins & 0x00008000) == 0) {
|
||||
// PC not in list
|
||||
return (unsigned long)(pc+1);
|
||||
} else {
|
||||
Rn = (unsigned long)gdb_arch_regs[(ins & 0x000F0000) >> 16];
|
||||
if ((ins & 0x000F0000) == 0x000F0000) Rn += 8; // PC prefetch!
|
||||
offset = ins & 0x0000FFFF;
|
||||
reg_count = 0;
|
||||
for (i = 0; i < 15; i++) {
|
||||
if (offset & (1<<i)) reg_count++;
|
||||
}
|
||||
if (ins & 0x00800000) {
|
||||
// Add offset
|
||||
Rn += reg_count*4;
|
||||
} else {
|
||||
// Subtract offset
|
||||
Rn -= 4;
|
||||
}
|
||||
return *(unsigned long *)Rn;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Branch
|
||||
if (ins_will_execute(ins)) {
|
||||
offset = (ins & 0x00FFFFFF) << 2;
|
||||
if (ins & 0x00800000)
|
||||
offset |= 0xFC000000; // sign extend
|
||||
new_pc = (unsigned long)(pc+2) + offset;
|
||||
// If its BLX, make new_pc a thumb address.
|
||||
if ((ins & 0xFE000000) == 0xFA000000) {
|
||||
if ((ins & 0x01000000) == 0x01000000)
|
||||
new_pc |= 2;
|
||||
new_pc = MAKE_THUMB_ADDR(new_pc);
|
||||
}
|
||||
|
||||
return new_pc;
|
||||
} else {
|
||||
// Falls through
|
||||
return (unsigned long)(pc+1);
|
||||
}
|
||||
}
|
||||
case 0x3: // Coprocessor & SWI
|
||||
if (((ins & 0x03000000) == 0x03000000) && ins_will_execute(ins)) {
|
||||
// SWI
|
||||
// TODO(wzyy2) some problems.
|
||||
extern unsigned long vector_swi;
|
||||
return vector_swi;
|
||||
} else {
|
||||
return (unsigned long)(pc+1);
|
||||
}
|
||||
default:
|
||||
// Never reached - but fixes compiler warning.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user