35 #define MAX_DEVWRITECNT 32 37 static int dev_list(
int argc,
uchar *argv[])
54 .manual_str =
"Print device list" 58 static int dev_open(
int argc,
uchar *argv[]);
66 .usage_str =
"<device_name>",
67 .manual_str =
"Open(only) device" 70 static int dev_open(
int argc,
uchar *argv[])
75 print_command_usage(&com_dev_open);
81 tprintf(
"return : 0x%p\n", dev);
87 static int dev_putc(
int argc,
uchar *argv[]);
95 .usage_str =
"<device_name> [data ...]",
96 .manual_str =
"1byte write data" 99 static int dev_putc(
int argc,
uchar *argv[])
108 print_command_usage(&com_dev_putc);
115 tprintf(
"Cannot open \"%s\".\n", argv[1]);
119 for(i=2; i<argc; i++) {
120 data = (
unsigned char)
hdstou(argv[i]);
127 tprintf(
"return : %d(0x%08X)\n", rt, rt);
135 static int dev_getc(
int argc,
uchar *argv[]);
143 .usage_str =
"<device_name>",
144 .manual_str =
"1byte read data" 147 static int dev_getc(
int argc,
uchar *argv[])
154 print_command_usage(&com_dev_getc);
161 tprintf(
"Cannot open \"%s\".\n", argv[1]);
167 tprintf(
"data : %02X\n", (
int)data);
169 tprintf(
"return : %d(0x%08X)\n", rt, rt);
177 static int dev_write(
int argc,
uchar *argv[]);
184 .command = dev_write,
185 .usage_str =
"<device_name> [data ...]",
186 .manual_str =
"Write data to device" 189 static int dev_write(
int argc,
uchar *argv[])
193 unsigned char buf[MAX_DEVWRITECNT];
194 unsigned char *bp = buf;
195 unsigned int len = 0;
199 print_command_usage(&com_dev_write);
206 tprintf(
"Cannot open \"%s\".\n", argv[1]);
210 for(i=2; i<argc; i++) {
211 if(argv[i][0] ==
'\'') {
212 (void)
strncopy(bp, &argv[i][1], MAX_DEVWRITECNT);
215 *bp = (
unsigned char)
hdstou(argv[i]);
225 tprintf(
"return : %d(0x%08X)\n", rt, rt);
232 #define MAX_DEVREADCNT 512 234 static int dev_read(
int argc,
uchar *argv[]);
242 .usage_str =
"<device_name> <size>",
243 .manual_str =
"Read data from device" 246 static int dev_read(
int argc,
uchar *argv[])
250 unsigned char buf[MAX_DEVREADCNT];
251 unsigned int size = 0;
255 print_command_usage(&com_dev_read);
262 tprintf(
"Cannot open \"%s\".\n", argv[1]);
268 if(size > MAX_DEVREADCNT) {
269 size = MAX_DEVREADCNT;
275 for(i=0; i<rt; i++) {
280 tprintf(
"return : %d(0x%08X)\n", rt, rt);
288 static int dev_dump(
int argc,
uchar *argv[]);
296 .usage_str =
"<device_name> [start [size]]",
297 .manual_str =
"Dump data from device" 300 static int dev_dump(
int argc,
uchar *argv[])
304 unsigned char buf[MAX_DEVREADCNT];
306 unsigned int size = MAX_DEVREADCNT;
310 print_command_usage(&com_dev_dump);
317 tprintf(
"Cannot open \"%s\".\n", argv[1]);
326 size = (
unsigned int)
hdstoi(argv[3]);
327 if(size > MAX_DEVREADCNT) {
328 size = MAX_DEVREADCNT;
335 for(j=0; j<rt; j+=16) {
342 tprintf(
"%02X ", (
int)buf[j+i]);
348 for(i=8; i<16; i++) {
350 tprintf(
"%02X ", (
int)buf[j+i]);
358 for(i=0; i<16; i++) {
360 if(((
' ' <= buf[j+i]) && (buf[j+i] <=
'Z'))
361 || ((
'a' <= buf[j+i]) && (buf[j+i] <=
'z'))) {
373 if(rd == ASCII_CTRL_C) {
381 tprintf(
"return : %d(0x%08X)\n", rt, rt);
389 static int dev_seek(
int argc,
uchar *argv[]);
397 .usage_str =
"<device_name> [offset [whence]]",
398 .manual_str =
"Seek device address" 401 static int dev_seek(
int argc,
uchar *argv[])
409 print_command_usage(&com_dev_seek);
416 tprintf(
"Cannot open \"%s\".\n", argv[1]);
430 tprintf(
"return : %d(0x%08X)\n", rt, rt);
438 static int dev_blockread(
int argc,
uchar *argv[]);
445 .command = dev_blockread,
446 .usage_str =
"<device_name> <sector> <count>",
447 .manual_str =
"Block read device" 450 static int dev_blockread(
int argc,
uchar *argv[])
453 unsigned char buf[MAX_DEVREADCNT];
454 unsigned int sector = 0;
455 unsigned int count = 0;
460 print_command_usage(&com_dev_blockread);
467 tprintf(
"Cannot open \"%s\".\n", argv[1]);
474 for(i=0; i<count; i++) {
479 xadump(512*i, buf, 512);
483 tprintf(
"return : %d(0x%08X)\n", rt, rt);
491 static int dev_capacity(
int argc,
uchar *argv[]);
498 .command = dev_capacity,
499 .usage_str =
"<device_name>",
500 .manual_str =
"Print device capacity" 505 static int dev_capacity(
int argc,
uchar *argv[])
511 print_command_usage(&com_dev_capacity);
518 tprintf(
"Cannot open \"%s\".\n", argv[1]);
524 tprintf(
"IOCMD_SD_GET_SECTOR_COUNT return %d\n", rt);
526 tprintf(
"Sector count : %d(0x%08X)\n", rt, rt);
531 tprintf(
"IOCMD_SD_GET_SECTOR_SIZE return %d\n", rt);
533 tprintf(
"Sector size : %d(0x%08X)\n", rt, rt);
538 tprintf(
"IOCMD_SD_GET_BLOCK_SIZE return %d\n", rt);
540 tprintf(
"Block size : %d(0x%08X)\n", rt, rt);
549 static int dev_ioctl(
int argc,
uchar *argv[]);
556 .command = dev_ioctl,
557 .usage_str =
"<device_name> <command> [arg]",
558 .manual_str =
"Ioctl device" 561 static int dev_ioctl(
int argc,
uchar *argv[])
564 unsigned int cmd = 0;
565 unsigned int arg = 0;
569 print_command_usage(&com_dev_ioctl);
576 tprintf(
"Cannot open \"%s\".\n", argv[1]);
590 tprintf(
"return : %d(0x%08X)\n", rt, rt);
598 static int dev_suspend(
int argc,
uchar *argv[]);
605 .command = dev_suspend,
606 .usage_str =
"[device_name]",
607 .manual_str =
"Suspend device" 610 static int dev_suspend(
int argc,
uchar *argv[])
623 tprintf(
"Cannot open \"%s\".\n", argv[1]);
629 tprintf(
"return : %d(0x%08X)\n", rt, rt);
637 static int dev_resume(
int argc,
uchar *argv[]);
644 .command = dev_resume,
645 .usage_str =
"[device_name]",
646 .manual_str =
"Resume device" 649 static int dev_resume(
int argc,
uchar *argv[])
662 tprintf(
"Cannot open \"%s\".\n", argv[1]);
668 tprintf(
"return : %d(0x%08X)\n", rt, rt);
676 static int dev_close(
int argc,
uchar *argv[]);
683 .command = dev_close,
684 .usage_str =
"<device_name>",
685 .manual_str =
"Close device" 688 static int dev_close(
int argc,
uchar *argv[])
694 print_command_usage(&com_dev_close);
702 tprintf(
"return : %ld(0x%08lX)\n", rt, rt);
729 .manual_str =
"Device operation commands",
730 .sublist = com_device_list
unsigned char uchar
GadgetSeedの文字(列)は unsigned char 型となる
static const struct st_shell_command com_dev_dump
デバイスより任意のサイズのデータを読み出しダンプ表示する
#define IOCMD_SD_GET_SECTOR_COUNT
セクタ数を取得する
static const struct st_shell_command com_dev_resume
デバイスをレジューム状態にする(実験的なAPI)
#define IOCMD_SD_GET_BLOCK_SIZE
消去ブロックサイズを取得する
static const struct st_shell_command com_dev_putc
デバイスに1バイトデータを書き込む
struct st_device * open_device(char *name)
デバイスをオープンする
static const struct st_shell_command com_dev_blockread
デバイスよりブロック読み出しを行う
int cgetcnw(unsigned char *rd)
標準入力より1文字を取得する(待ち無し)
int write_device(struct st_device *dev, const void *buf, unsigned int count)
デバイスにデータを書き込む
int read_device(struct st_device *dev, void *buf, unsigned int count)
デバイスよりデータを読み出す
const char * device_name(int num)
デバイス名を取得する
static const struct st_shell_command com_dev_suspend
デバイスをサスペンド状態にする(実験的なAPI)
int seek_device(struct st_device *dev, int offset, int whence)
デバイスのアクセスポイントを設定する
static const struct st_shell_command com_dev_ioctl
デバイスの制御(ioctl)を行う
unsigned int hdstou(uchar *str)
10進数または16進数文字列 unsigned int 変換
int suspend(void)
全デバイスを休止状態にする
int hdstoi(uchar *str)
10進数または16進数文字列 int 変換
int resume_device(struct st_device *dev)
デバイスを活性化する
#define IOCMD_SD_GET_SECTOR_SIZE
1セクタサイズを取得する
static const struct st_shell_command com_dev_getc
デバイスより1バイトデータを読み出す
static const struct st_shell_command com_dev_write
デバイスに任意のサイズのデータを書き込む
const char * device_explan(int num)
デバイス説明を取得する
int getc_device(struct st_device *dev, unsigned char *data)
デバイスよりデータを1バイト読み出す
static const struct st_shell_command com_dev_list
登録されているデバイスリスト表示
int dstoi(uchar *str)
10進数文字列 int 変換
unsigned int strleng(const uchar *str)
文字列長
static const struct st_shell_command com_dev_read
デバイスより任意のサイズのデータを読み出す
int cputc(unsigned char td)
標準出力より1文字を出力する
int putc_device(struct st_device *dev, unsigned char data)
デバイスにデータを1バイト書き込む
int suspend_device(struct st_device *dev)
デバイスを休止状態にする
int device_num(void)
登録されているデバイス数を取得する
int tprintf(const char *fmt,...)
簡易printf
static const struct st_shell_command com_dev_seek
デバイスのアクセス位置を設定する
ストレージデバイスドライバ ioctl 用マクロ定義
static const struct st_shell_command com_dev_open
デバイスを開く
uchar * strncopy(uchar *dest, const uchar *src, unsigned int n)
文字列コピー
int resume(void)
全デバイスを活性化する
static const struct st_shell_command com_dev_close
デバイスを閉じる
int close_device(struct st_device *dev)
デバイスをクローズする
static const struct st_shell_command com_dev_capacity
デバイスの容量を取得する
int ioctl_device(struct st_device *dev, unsigned int com, unsigned int arg, void *param)
デバイスを制御する
int block_read_device(struct st_device *dev, void *buf, unsigned int sector, unsigned int blkcount)
デバイスよりブロックデータを読み出す