- PR -

デバイスドライバ RS-232-Cドライバのアプリケーションでフリーズ

1
投稿者投稿内容
ヤミーズ
常連さん
会議室デビュー日: 2004/09/06
投稿数: 27
お住まい・勤務地: 東京都世田谷区
投稿日時: 2005-04-21 15:02
いつも大変お世話になっております。

 キャラクタ型のRS-232-Cドライバを勉強中ですが、
アプリケーションをGDBで実行するといきなりlinuxがフリーズします。
考えられる原因、調査方法などはありませんでしょうか?

【GDB実行】
 ※1行目すらブレイクせずフリーズしてしまう。
 ※アプリケーション名:sample
 ※-gでシンボル情報つきでコンパイルしてます。

 [root@localhost port]# gdb ./sample
 GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
 Copyright 2003 Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you are
 welcome to change it and/or distribute copies of it under certain conditions.
 Type "show copying" to see the conditions.
 There is absolutely no warranty for GDB. Type "show warranty" for details.
 This GDB was configured as "i386-redhat-linux-gnu"...
 (gdb) b 1
 Breakpoint 1 at 0x8048664: file sample.c, line 1.
 (gdb) run
 Starting program: /home/m-satou/port/sample

  ★★フリーズ★★


【プログラム】
○アプリケーション
 /*メイン関数*/
 main()
 {
  int fd, pid, len;
  char buf[1];
  struct termios tattr;
  int speed = TTDRV_9600;
  char* devfile = "/dev/ttdrv1";
 
 #if 0
  /* デバイスファイル名 */
  if (argc > 1) devfile = argv[1];
  /* 通信速度指定 */
  if (argc > 2) {
  speed = get_speed(argv[2]);
  if (speed < 0) usage();
  }
 #endif
 
  /* サンプルドライバを open する */
  if ((fd = open(devfile, O_RDWR)) == -1) {
  fprintf(stderr,"%s open error.\n",devfile);
  exit(1);
  }
  /* 通信速度設定 */
  if (ioctl(fd, TTDRV_SETSPEED, &speed) == -1) {
  perror("ioctl");
  exit(1);
  }
   ・
   ・
   ・

○ドライバ
 /*-------------------------------------------*/
 /* デバイスドライバ登録処理 */
 /*-------------------------------------------*/
 int ttdrv_init(void)
 {
  int iRet;
  /* キャラクタ型デバイスドライバ登録 */
  iRet = register_chrdev(TTDRV_MAJOR,"ttdrv",&ttdrv_fops);
  if (iRet < 0) {
  printk(KERN_NOTICE "ERR:ttdrv:init_modlue: register_chardev ret=%d\n",
  iRet);
  return iRet;
  }
  /*ドライバが使用するI/Oポートを確保*/
  if( check_region( ttdrv[0].base, 8 ) < 0 ){
  printk( KERN_DEBUG "check_region1 err ");
  }
  request_region(ttdrv[0].base, 8, "ttdrv1");/*COM1: 3F8-3FF*/
 
  if( check_region( ttdrv[1].base, 8 ) < 0 ){
  printk( KERN_DEBUG "check_region2 err ");
  }
  request_region(ttdrv[1].base, 8, "ttdrv2");/*COM2: 2F8-2FF*/
  return 0;
 }


【環境】
○/dev/
 crw-r--r-- 1 root root 60, 0 4月 21 13:56 /dev/ttdrv1
 crw-r--r-- 1 root root 60, 1 4月 21 13:56 /dev/ttdrv2

○/proc/ioports
 02f8-02ff : ttdrv2
 03f8-03ff : ttdrv1

○/sbin/lsmod
 [root@localhost port]# /sbin/insmod ttdrv.o
 Warning: loading ttdrv.o will taint the kernel: no license
  See http://www.tux.org/lkml/#export-tainted for information about tainted modules
 Module ttdrv loaded, with warnings
 [root@localhost port]# /sbin/lsmod
 Module Size Used by Tainted: P
 ttdrv 5736 0 (unused)

以上 宜しくお願いいたします。
コブラ
ぬし
会議室デビュー日: 2003/07/18
投稿数: 1038
お住まい・勤務地: 神奈川
投稿日時: 2005-04-22 21:16
2.4 系ですが、

#define __KERNEL__
#define MODULE

これらの定数と、

#include <linux/module.h>

モジュール用のインクルードファイルと、

init_module();
cleanup_module();

こういう「決まり事」は不要になったのでしょうか?

[ メッセージ編集済み 編集者: コブラ 編集日時 2005-04-22 21:17 ]
1

スキルアップ/キャリアアップ(JOB@IT)