Jun 17, 1999 onl50t: Solaris 2.6 cc ドライバのデバッグ. cc ドライバのデバッグ#01(その1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (http://www-online.kek.jp/~inoue/CAMAC/ onl50t-sol2.6/Desktop/debug-step01.txt) 高エネルギー加速器研究機構 素粒子原子核研究所 物理、オンライングループ 井上 栄二 (1). 現状確認 (A). 株式会社ロジックハウスの白田様より SPARC CPU-50T を借用した。 (B). FORCE,CPU-50(UltraSPARC-IIi 300MHz)、に Solaris2.6 のシステムを インストールした。 (C). /etc の下の各設定、および /export/home の作成をやった。 (D). "Solaris2.6 Hardware: 5/98 SMCC Desktop 日本語版 SPARC版"では ディスクレス・クライアントを設定することはできないことを確認した。 (E). CPU-50T に Solaris2.6用の VMEドライバ、FRCvme-2.3.1 をインストール した。 (F). onl50t に ccドライバをインストールした。 (G). サンプル・プログラムを実行した。 (1). cam1、シングル・アクション 24ビット camac read/write の実行 NG. システムはパニックを起こしてリブートしてしまう。 (2). cam3、camac LAM割り込み処理の実行 NG. システムはパニックを起こしてリブートしてしまう。 (3). cam2、ブロック転送 16ビット read/write の実行 ok. 正常に実行できた。 (4). cam2、ブロック転送 24ビット read/write の実行 ok. 正常に実行できた。 (2). ここでやるべきこと onl50t 上で クラッシュ時の savecoreファイルを入手してデバッグをする。 (3). savecoreファイルの入手 (3-1). /etc/rc2.d/S20syssetup の修正 株式会社ロジックハウスの高橋さんからのメール。 >こちらで調査するに当たり、前回同様に >クラッシュダンプを提供して貰えますか? (3-1-1). /etc/rc2.d/S20sysetupファイルの設定 onl50t# pwd /etc/rc2.d onl50t# ls K20spc S47asppp S74syslog S89bdconfig K60nfs.server S69inet S74xntpd S90loc.ja.cssd K76snmpdx S70uucp S75cron S91afbinit K77dmi S71rpc S76nscd S91leoconfig README S71sysid.sys S80PRESERVE S92rtvc-config S01MOUNTFSYS S72autoinstall S80lp S92volmgt S05RMTMPFILES S72inetsvc S80spc S93cacheos.finish S20sysetup S73cachefs.daemon S85power S94Wnn6 S21perf S73nfs.client S88sendmail S99audit S30sysid.net S74autofs S88utmpd S99dtlogin onl50t# ls -l S20sysetup -rwxr--r-- 2 root sys 822 Jul 16 1997 S20sysetup onl50t# cat S20sysetup #!/bin/sh # # Copyright(c) 1984-1997, by Sun Microsystems, Inc. # All rights reserved. # #ident "@(#)sysetup 1.15 97/04/24 SMI" /* SVr4.0 1.4.2.1 */ # This file contains system setup requirements for the system. set `/usr/bin/who -r` if [ $9 != "S" -a $9 != "1" ] then exit fi # if the prtconf command exists, then, the system configuration # is printed # Default is not to do this. Too noisy, to long. #if [ -x /usr/sbin/prtconf ] #then # /usr/sbin/prtconf #fi # If there are trademark files, print them. if [ -d /etc/tm ] then /usr/bin/cat /etc/tm/* 2> /dev/null fi ## ## Default is to not do a savecore ## #if [ ! -d /var/crash/`uname -n` ] #then mkdir -m 0700 -p /var/crash/`uname -n` #fi # echo 'checking for crash dump...\c ' #savecore /var/crash/`uname -n` # echo '' onl50t# vi S20sysetup #!/bin/sh # # Copyright(c) 1984-1997, by Sun Microsystems, Inc. # All rights reserved. # #ident "@(#)sysetup 1.15 97/04/24 SMI" /* SVr4.0 1.4.2.1 */ # This file contains system setup requirements for the system. set `/usr/bin/who -r` if [ $9 != "S" -a $9 != "1" ] then exit fi # if the prtconf command exists, then, the system configuration # is printed # Default is not to do this. Too noisy, to long. #if [ -x /usr/sbin/prtconf ] #then # /usr/sbin/prtconf #fi # If there are trademark files, print them. if [ -d /etc/tm ] then /usr/bin/cat /etc/tm/* 2> /dev/null fi ## ## Default is to not do a savecore ## if [ ! -d /var/crash/`uname -n` ] then mkdir -m 0700 -p /var/crash/`uname -n` fi echo 'checking for crash dump...\c ' savecore /var/crash/`uname -n` echo '' "S20sysetup" 40 lines, 816 characters onl50t# ここで、システムをリブートする。 onl50t console login: root Password: Last login: Thu Jun 10 11:24:44 on console Jun 15 14:00:05 onl50t login: ROOT LOGIN /dev/console Sun Microsystems Inc. SunOS 5.6 Generic August 1997 Starting OpenWindows in 5 seconds (type Control-C to interrupt) ^C# /usr/sbin/shutdown -i0 -g0 Shutdown started. Tue Jun 15 14:00:15 JST 1999 Do you want to continue? (y or n): y Broadcast Message from root (console) on onl50t Tue Jun 15 14:00:16... THE SYSTEM IS BEING SHUT DOWN NOW ! ! ! Log off now or risk your files being damaged showmount: onl50t: RPC: Program not registered Changing to init state 0 - please wait # INIT: New run level: 0 The system is coming down. Please wait. System services are now being stopped. Print services stopped. Stopping the syslog service. syslogd: going down on signal 15 Jun 15 14:00:58 snmpdx: received signal 15 Jun 15 14:00:58 cssd: Got sig#15, sending it to all CSes and exit The system is down. syncing file systems... done Program terminated ok boot disk3 -r Resetting ... FORCE,CPU-50(UltraSPARC-IIi 300MHz), No Keyboard OpenBoot 3.10.6, 256 MB memory installed, Serial #9180267. Ethernet address 0:80:42:b:a4:6b, Host ID: 808c146b. Executing last command: boot disk3 -r Boot device: /pci@1f,0/scsi@4/disk@3,0 File and args: -r SunOS Release 5.6 Version Generic_105181-05 [UNIX(R) System V Release 4.0] Copyright (c) 1983-1997, Sun Microsystems, Inc. configuring network interfaces: hme0. Hostname: onl50t Configuring the /devices directory FRCvme V2.3.1 VME Nexus ( Universe) NOTICE: VME: slavewin at vme=0x0, size=0x100000 space=0x302061f CAMAC device driver V1.3x, 1991-1993 by Y.TAKEUCHI (T.I.T.) cc0 at vme0: vme16d16 0xff00 VME level 4 vector 0xff sparc ipl 7 vmeplus0 at vme0: vme16d16 0x0 and vme24d16 0x0 and vme32d16 0x0 and vme16d32 0x 0 and vme24d32 0x0 and vme32d32 0x0 and space 0x2f offset 0x0 and space 0x6f offset 0x0 and space 0x10 offset 0x0 and space 0x11 offset 0x0 and space 0x50 offset 0x0 and space 0x51 offset 0x0 vmedma0 at vme0 vmefdma0 at vme0 vmedvma0 at vme0 vmectl0 at vme0 Configuring the /dev directory Configuring the /dev directory (compatibility devices) The system is coming up. Please wait. checking ufs filesystems /dev/rdsk/c0t3d0s5: is clean. /dev/rdsk/c0t3d0s4: is clean. /dev/rdsk/c0t3d0s7: is clean. /dev/rdsk/c0t3d0s3: is clean. checking for crash dump...System went down at Mon Jun 14 16:16:45 1999 Saving 3152 pages of image in vmcore.0 3152 pages saved. Processing modules: Done. Constructing Namelist file: /var/crash/onl50t/unix.0 Namelist file complete. add net default: gateway ICCFP1 NIS domainname is kek.jp starting rpc services: rpcbind keyserv done. Setting netmask of hme0 to 255.255.248.0 Setting default interface for multicast: add net 224.0.0.0: gateway onl50t syslog service starting. Print services started. starting Kana-Kanji converters: cssd. volume management starting. Wnn6: Key License Server started.... Nihongo Multi Client Server (Wnn6 R2.30) Finished Reading Files The system is ready. onl50t console login: システムは正常に立ち上がった。 コア・ファイルを確認。 onl50t# pwd /var/crash/onl50t onl50t# ls -l total 52370 -rw-rw-rw- 1 root root 2 Jun 15 14:03 bounds -rw-r--r-- 1 root root 921900 Jun 15 14:03 unix.0 -rw-r--r-- 1 root root 25853952 Jun 15 14:03 vmcore.0 onl50t# ok. 正常に作られている。 (3-2). cam1、camac サンプル・プログラムを実行した時の savecore を入手する (3-2-1). cam1 を実行する onl50t[44]% pwd /export/home/onl50t/inoue/CAMAC/Driver/FORCE-5V-sol2.5 onl50t[45]% cam1 cam1プログラムはここでフリーズした。 システムはパニックを起こしてリブートしてしまった。 この時のコンソール上のメッセージは次のとおり。 CAMAC device driver V1.3x, 1991-1993 by Y.TAKEUCHI (T.I.T. ) cc0 at vme0: vme16d16 0xff00 VME level 4 vector 0xff sparc ipl 7 D TRAP: cpu=0 type=0x31 rp=0x302ad840 addr=0xeffff94c mmu_fsr=0x0 cam1: trap type = 0x31 addr=0xeffff94c pid=379, pc=0x60c67e88, sp=0x302ad8d0, tstate=0x900001e05, context=0x2b9 g1-g7: 608bb3e0, 0, 10055f08, 360, 0, 0, 60b63080 Begin traceback... sp = 302ad8d0 Called from 100740d0, fp=302ad948, args=f00000 80046302 effff94c 100003 6004db00 606818e0 Called from 10055f70, fp=302ada18, args=60b4a6a0 302ada78 60c5bba8 ef7fb438 ef7f abc8 b Called from 1002ec94, fp=302ada80, args=60b4a638 302adae0 104265a4 ef7a23b4 0 0 Called from 11330, fp=effff8a8, args=3 80046302 effff94c ef7a23b4 0 0 End traceback... panic[cpu0]/thread=0x60b63080: trap syncing file systems... 7 done 2867 static and sysmap kernel pages 35 dynamic kernel data pages 193 kernel-pageable pages 0 segkmap kernel pages 0 segvn kernel pages 86 current user process pages 3181 total pages (3181 chunks) dumping to vp 601de4cc, offset 487030 3181 total pages, dump succeeded rebooting... Resetting ... FORCE,CPU-50(UltraSPARC-IIi 300MHz), No Keyboard OpenBoot 3.10.6, 256 MB memory installed, Serial #9180267. Ethernet address 0:80:42:b:a4:6b, Host ID: 808c146b. Executing last command: boot <--- "Break"キーで中断して boot コマンドを入力。 ok ok boot disk3 -r Boot device: /pci@1f,0/scsi@4/disk@3,0 File and args: -r SunOS Release 5.6 Version Generic_105181-05 [UNIX(R) System V Release 4.0] Copyright (c) 1983-1997, Sun Microsystems, Inc. configuring network interfaces: hme0. Hostname: onl50t The / file system (/dev/rdsk/c0t3d0s0) is being checked. /dev/rdsk/c0t3d0s0: 3942 files, 53024 used, 852836 free /dev/rdsk/c0t3d0s0: (364 frags, 106559 blocks, 0.0% fragmentation) The /usr file system (/dev/rdsk/c0t3d0s6) is being checked. /dev/rdsk/c0t3d0s6: 28673 files, 546575 used, 3798781 free /dev/rdsk/c0t3d0s6: (1909 frags, 474609 blocks, 0.0% fragmentation) Configuring the /devices directory FRCvme V2.3.1 VME Nexus ( Universe) NOTICE: VME: slavewin at vme=0x0, size=0x100000 space=0x302061f CAMAC device driver V1.3x, 1991-1993 by Y.TAKEUCHI (T.I.T.) cc0 at vme0: vme16d16 0xff00 VME level 4 vector 0xff sparc ipl 7 vmeplus0 at vme0: vme16d16 0x0 and vme24d16 0x0 and vme32d16 0x0 and vme16d32 0x 0 and vme24d32 0x0 and vme32d32 0x0 and space 0x2f offset 0x0 and space 0x6f offset 0x0 and space 0x10 offset 0x0 and space 0x11 offset 0x0 and space 0x50 offset 0x0 and space 0x51 offset 0x0 vmedma0 at vme0 vmefdma0 at vme0 vmedvma0 at vme0 vmectl0 at vme0 Configuring the /dev directory Configuring the /dev directory (compatibility devices) The system is coming up. Please wait. checking ufs filesystems /dev/rdsk/c0t3d0s5: is stable. /dev/rdsk/c0t3d0s4: is stable. /dev/rdsk/c0t3d0s7: is stable. /dev/rdsk/c0t3d0s3: 704 files, 30160 used, 641514 free /dev/rdsk/c0t3d0s3: (202 frags, 80164 blocks, 0.0% fragmentation) checking for crash dump...System went down at Tue Jun 15 14:14:55 1999 Saving 3181 pages of image in vmcore.1 3181 pages saved. Processing modules: Done. Constructing Namelist file: /var/crash/onl50t/unix.1 Namelist file complete. add net default: gateway ICCFP1 NIS domainname is kek.jp starting rpc services: rpcbind keyserv done. Setting netmask of hme0 to 255.255.248.0 Setting default interface for multicast: add net 224.0.0.0: gateway onl50t syslog service starting. Print services started. starting Kana-Kanji converters: cssd. volume management starting. Wnn6: Key License Server started.... Nihongo Multi Client Server (Wnn6 R2.30) Finished Reading Files The system is ready. onl50t console login: (3-2-2). コア・ファイルをチェック onl50t# pwd /var/crash/onl50t onl50t# ls -l total 105202 -rw-rw-rw- 1 root root 2 Jun 15 14:18 bounds -rw-r--r-- 1 root root 921900 Jun 15 14:03 unix.0 -rw-r--r-- 1 root root 921900 Jun 15 14:18 unix.1 -rw-r--r-- 1 root root 25853952 Jun 15 14:03 vmcore.0 -rw-r--r-- 1 root root 26091520 Jun 15 14:18 vmcore.1 onl50t# adb -k unix.1 vmcore.1 physmem 7b09 $c complete_panic(?) + 24 do_panic(0x1,0x302ad65c,0x1040c3e8,0x0,0x0,0x0) vcmn_err(0x3,0x1040d408,0x3,0x302ad65c,0x60b63080,0x4) + 190 cmn_err(0x3,0x1040d408,0xeffff8a8,0x129,0x129,0x10406400) + 1c die(0x31,0x302ad840,0xeffff94c,0x0,0x1040d408,0x0) + a0 trap(0x302ad840,0x0,0xefffe000,0x1,0x0,0x5) + 830 $ root on /pci@1f,0/scsi@4/disk@3,0:a fstype ufs PCI-device: ebus@1, ebus #0 su0 at ebus0: offset 14,3803f8 su0 is /pci@1f,0/ebus@1/su@14,3803f8 su1 at ebus0: offset 14,3602f8 su1 is /pci@1f,0/ebus@1/su@14,3602f8 keyboard is major <37> minor <0> mouse is major <37> minor <1> se0 at ebus0: offset 14,400000 se0 is /pci@1f,0/ebus@1/se@14,400000 stdin is major <20> minor <0> stdout is major <20> minor <0> SUNW,hme0: CheerIO 2.0 (Rev Id = c1) Found SUNW,hme0 is /pci@1f,0/pci@2,1/network@1,1 PCI-device: network@1,1, hme #1 SUNW,hme1 is /pci@1f,0/network@1,1 SUNW,hme0: Using Internal Transceiver SUNW,hme0: 100 Mbps full-duplex Link Up dump on /dev/dsk/c0t3d0s1 size 268960K VME: Universe rev. 1 at 0x6078e000 VME: LCA rev. 2 at 0xfffa8000 FRCvme V2.3.1 VME Nexus ( Universe) NOTICE: VME: slavewin at vme=0x0, size=0x100000 space=0x302061f PCI-device: vme@5, VME #0 CAMAC device driver V1.3x, 1991-1993 by Y.TAKEUCHI (T.I.T.) cc0 at vme0: vme16d16 0xff00 VME level 4 vector 0xff sparc ipl 7 cc0 is /pci@1f,0/vme@5/cc@2d,ff00 pseudo-device: winlock0 winlock0 is /pseudo/winlock@0 pseudo-device: lockstat0 lockstat0 is /pseudo/lockstat@0 pseudo-device: vol0 vol0 is /pseudo/vol@0 pseudo-device: llc10 llc10 is /pseudo/llc1@0 SUNW,CS42310 at ebus0: offset 14,200000 SUNW,CS42310 is /pci@1f,0/ebus@1/SUNW,CS4231@14,200000 pci1011,240 is /pci@1f,0/pci@2,1/pci@2 pseudo-device: pm0 pm0 is /pseudo/pm@0 pseudo-device: tod0 tod0 is /pseudo/tod@0 pem: no event handler ecpp0 at ebus0: offset 14,3403bc ecpp0 is /pci@1f,0/ebus@1/ecpp@14,3403bc vmeplus0 at vme0: vme16d16 0x0 and vme24d16 0x0 and vme32d16 0x0 and vme16d32 0x0 and vme24d32 0x0 and vme32d32 0x0 and space 0x 2f offset 0x0 and space 0x6f offset 0x0 and space 0x10 offset 0x0 and space 0x11 offset 0x0 and space 0x50 offset 0x0 and space 0x51 offset 0x0 vmeplus0 is /pci@1f,0/vme@5/vmeplus@2d,0 vmedma0 at vme0 vmedma0 is /pci@1f,0/vme@5/vmedma vmefdma0 at vme0 vmefdma0 is /pci@1f,0/vme@5/vmefdma vmedvma0 at vme0 vmedvma0 is /pci@1f,0/vme@5/vmedvma vmectl0 at vme0 vmectl0 is /pci@1f,0/vme@5/vmectl sysconfig0: LCA is CPU-50/520 sysconfig0 at ebus0: offset 14,600000 sysconfig0 is /pci@1f,0/ebus@1/sysconfig@14,600000 BAD TRAP: cpu=0 type=0x31 rp=0x302ad840 addr=0xeffff94c mmu_fsr= 0x0 cam1: trap type = 0x31 addr=0xeffff94c pid=379, pc=0x60c67e88, sp=0x302ad8d0, tstate=0x900001e05, conte xt=0x2b9 g1-g7: 608bb3e0, 0, 10055f08, 360, 0, 0, 60b63080 Begin traceback... sp = 302ad8d0 Called from 100740d0, fp=302ad948, args=f00000 80046302 effff94c 100003 6004db00 606818e0 Called from 10055f70, fp=302ada18, args=60b4a6a0 302ada78 60c5bb a8 ef7fb438 ef7fabc8 b Called from 1002ec94, fp=302ada80, args=60b4a638 302adae0 104265 a4 ef7a23b4 0 0 Called from 11330, fp=effff8a8, args=3 80046302 effff94c ef7a23b 4 0 0 End traceback... panic[cpu0]/thread=0x60b63080: trap syncing file systems... 7 done 2867 static and sysmap kernel pages 35 dynamic kernel data pages 193 kernel-pageable pages 0 segkmap kernel pages 0 segvn kernel pages 86 current user process pages 3181 total pages (3181 chunks) dumping to vp 601de4cc, offset 0x302ad840$ 1) ? atoi(argv[1]): 20; if (CAM_Open()) { perror("Open error: "); exit(1); } printf("cam1: step2\n"); CSETCR(0); printf("cam1: step3\n"); CGENC(); printf("cam1: step4\n"); CGENZ(); printf("cam1: step5\n"); CSETI(); printf("cam1: step6\n"); CREMI(); printf("cam1: step7\n"); while (loop-- > 0) { : onl50t[42]% (3-3-2). cam1プログラムをコンパイルして再実行 onl50t[43]% make cam1 cc -O cam1.c -o cam1 -I. -L. -lcamac onl50t[44]% onl50t[44]% cam1 cam1: step1 cam1: step2 "CSETCR(0)"文を実行中にクラッシュを起こしている。 CSETCRルーチンをチェック。 onl50t[46]% pwd /export/home/onl50t/inoue/CAMAC/Driver/FORCE-5V-sol2.5 onl50t[47]% grep CSETCR * cam1.c: CSETCR(0); cam1.c.org: CSETCR(0); cam3.c: status += CSETCR(0); camlib.c:CSETCR(crate) forlib.c: return CSETCR(*crate); onl50t[48]% onl50t[48]% vi camlib.c : CSETCR(crate) int crate; { return ioctl(cc_path, CCIOC_SET_CRATE, &crate); } : onl50t[49]% onl50t[50]% grep CCIOC_SET_CRATE * camlib.c: return ioctl(cc_path, CCIOC_SET_CRATE, &crate); cc.c: case CCIOC_SET_CRATE: cc.c-org: case CCIOC_SET_CRATE: cc.h:#define CCIOC_SET_CRATE _IOW('c',2,int) /* set crate # */ cc.h-org:#define CCIOC_SET_CRATE _IOW('c',2,int) /* set crate # */ onl50t[51]% Writing Device Drivers Converting a SunOS 4.x Device Driver to SunOS 5.6 ioctl() SunOS 4.x system: int xxioctl(dev, cmd, data, flag) dev_t dev; int cmd, flag; caddr_t data; SunOS 5.x system: int xxioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, int *rvalp); In the SunOS 4.x system, ioctl() command arguments were defined as follows: #define XXIOCTL1 _IOR(m, 1, u_int) The _IOR( ), _IOW( ), and _IOWR( ) macros were used to encode the direction and size of the data transfer. The kernel would then automatically copy the data into or out of the kernel. This is no longer the case. To do a data transfer, the driver is now required to use ddi_copyin(9F) and ddi_copyout(9F) explicitly. Do not dereference arg directly. In addition, use the new method of a left-shifted letter OR'ed with number: #define XXIOC ('x'<<8) #define XXIOCTL1 (XXIOC | 1) The credential pointer can be used to check credentials on the call (with drv_priv(9F)), and the return value pointer can be used to return a value that has meaning (as opposed to the old method of always getting zero back for success). This number should be positive to avoid confusion with applications that check for ioctl(2) returning a negative value for failure. 株式会社ロジックハウスの高橋さんからのメール。 ---ここから >cc_ioctl()の以下の行を削除して >試して頂けますか? > > /* lock out clock */ > s = spl5(); >... >... >... > splx(s); ---ここまで spl ルーチンについて Locking Changes Starting with the SunOS 4.1.2 system, only one processor can be in the kernel at any one time. This is accomplished by using a master lock around the entire kernel. When a processor needs to execute kernel code, it needs to acquire the lock (this excludes other processors from running the code protected by the lock) and then release the lock when it is through. Because of this master lock, drivers written for uniprocessor systems did not change for multiprocessor systems. Two processors could not execute driver code at the same time. In the SunOS 5.x system, instead of one master lock, there are many smaller locks that protect smaller regions of code. For example, there may be a kernel lock that protects access to a particular vnode, and one that protects an inode. Only one processor can be running code dealing with that vnode at a time, but another could be accessing an inode. This allows a greater degree of concurrency. However, because the kernel is multithreaded, it is possible that two (or more) threads are in driver code at the same time. 1. One thread could be in an entry point, and another in the interrupt routine. The driver had to handle this in the SunOS 4.x system, but with the restriction that the interrupt routine blocked the user context routine while it ran. 2. Two threads could be in a routine at the same time. This could not happen in the SunOS4.x system. Both of these cases are similar to situations present in the SunOS 4.x system, but now these threads could run at the same time on different CPUs. The driver must be prepared to handle these types of occurrences. Mutual Exclusion Locks In the SunOS 4.x system, a driver had to be careful when accessing data shared between the tophalf and the interrupt routine. Because the interrupt could occur asynchronously, the interrupt routine could corrupt data or simply hang. To prevent this, portions of the top half of the driver would raise, using the various spl routines, the interrupt priority level of the CPU to block the interrupt from being handled: s = splr(pritospl(6)); /* access shared data */ (void)splx(s); In the SunOS 5.x system, this no longer works. Changing the interrupt priority level of one CPU does not necessarily prevent another CPU from handling the interrupt. Also, two top-half routines may be running simultaneously with the interrupt running on a third CPU. To solve this problem, the SunOS 5.x system provides: 1. A uniform module of execution--even interrupts run as threads. This blurs the distinction between the tophalf and the bottomhalf, as effectively every routine is a bottomhalf routine. 2. A number of locking mechanisms-a common mechanism is to use mutual exclusion locks(mutexes): mutex_enter(&mu); /* access shared data */ mutex_exit(&mu); A subtle difference from the SunOS 4.x system is that, because everything is run by kernel threads, the interrupt routine needs to explicitly acquire and release the mutex. In the SunOS4.x system, this was implicit since the interrupt handler automatically ran at an elevated priority. See "Locking Primitives" on page 78 for more information on locking. SunOS 5.x のシステムでは splルーチンは機能しない。 (3-3-3). splルーチンをはずして cam1プログラムを実行してみる cc.cファイルを修正する。 onl50t[51]% vi cc.c : static int cc_ioctl(dev_t dev, int cmd, int arg, int flag, cred_t *cred_p, int *rval_p) { /* register struct cc_device *cc = &ccdevice[0]; */ register struct cc_device *cc; /* register struct K_REG *k = cc->k; */ u_short sdat; int idat, *data = (int *)arg; int s; minor_t unit; unit = getminor(dev); cc = ddi_get_soft_state(cc_state,unit); switch (cmd) { case CCIOC_CHK_BRANCH: *(int *)data = cc->max_branch; break; case CCIOC_SET_BRANCH: if (*(int *)data >= 0 && *(int *)data < cc->max_branch) cc->cur_branch = *(int *)data; break; case CCIOC_SET_CRATE: if (*(int *)data >= 0 && *(int *)data < MAX_CRATE) cc->cur_crate = *(int *)data; break; case CCIOC_WAIT_LAM : cc->interrupt = 0; cc->k->lamc = CC_INT_AUTO_CLEAR | CC_INT_ENABLE | intrpri; /* lock out clock */ /* by E.Inoue s = spl5(); */ if (cc->interrupt & CC_INT_LAM) { cc->interrupt &= ~CC_INT_LAM; return 0; } /* mutex_enter(&cc->mutex); */ /* start MUTEX */ cc->timeout_id = timeout(cc_timeout, (caddr_t)&unit, *(int *)data * hz); mutex_enter(&cc->mutex); /* start MUTEX */ /* wait interrupt */ /* cv_timedwait(&cc->cv, &cc->mutex, timeout); if (cc->interrupt == 0) cc->interrupt |= CC_INT_TIMEOUT; */ if (cv_wait_sig(&cc->cv, &cc->mutex) == 0) { untimeout(cc->timeout_id); mutex_exit(&cc->mutex); /* end MUTEX */ return EINTR; } mutex_exit(&cc->mutex); /* end MUTEX */ /* by E.Inoue splx(s); */ if( cc->interrupt & CC_INT_LAM ) { cc->interrupt &= ~CC_INT_LAM; : "cc.c" 2920 lines, 73462 characters onl50t[52]% cc.cファイルをコンパイルし直す。 onl50t[53]% make ./script/cc_build.sh [Building for sun4u] rm -f cc.o onl50t[54]% ccドライバをロードし直す。 onl50t# pwd /export/home/onl50t/inoue/CAMAC/Driver/FORCE-5V-sol2.5 onl50t# make unload ./script/cc_unload.sh [Removing CAMAC device driver] [Removing CAMAC device driver from system] [Deleting CAMAC device files] onl50t# make load ./script/cc_load.sh [Installing CAMAC device driver] [Adding CAMAC device driver to system] [Configuring CAMAC device driver] [Making CAMAC device files] sun4u onl50t# cam1プログラムを実行する。 onl50t[55]% cam1 cam1: step1 cam1: step2 cam1プログラムはここでフリーズした。 システムはパニックを起こしてリブートしてしまった。 以下はコンソール上のメッセージ。 vmectl0 at vme0 BAD TRAP: cpu=0 type=0x31 rp=0x301fb840 addr=0xeffff94c mmu_fsr=0x0 cam1: trap type = 0x31 addr=0xeffff94c pid=809, pc=0x60d47e88, sp=0x301fb8d0, tstate=0x900001e05, context=0x5ae g1-g7: 6003cca0, 0, 10055f08, 360, 0, 0, 60afc1a0 Begin traceback... sp = 301fb8d0 Called from 100740d0, fp=301fb948, args=f00000 80046302 effff94c 100003 6004dc80 60683780 Called from 10055f70, fp=301fba18, args=60b18080 301fba78 60c67b30 ef7fb438 ef7f abc8 b Called from 1002ec94, fp=301fba80, args=60b18018 301fbae0 104265a4 ef7a23b4 0 0 Called from 11370, fp=effff8a8, args=3 80046302 effff94c ef7a23b4 0 0 End traceback... panic[cpu0]/thread=0x60afc1a0: trap syncing file systems... [1] 3 done 3049 static and sysmap kernel pages 25 dynamic kernel data pages 252 kernel-pageable pages 0 segkmap kernel pages 0 segvn kernel pages 94 current user process pages 3420 total pages (3420 chunks) dumping to vp 601de4cc, offset 483206 3420 total pages, dump succeeded rebooting... Resetting ... FORCE,CPU-50(UltraSPARC-IIi 300MHz), No Keyboard OpenBoot 3.10.6, 256 MB memory installed, Serial #9180267. Ethernet address 0:80:42:b:a4:6b, Host ID: 808c146b. Initializing Memory / ok ok boot disk3 -r Boot device: /pci@1f,0/scsi@4/disk@3,0 File and args: -r SunOS Release 5.6 Version Generic_105181-05 [UNIX(R) System V Release 4.0] Copyright (c) 1983-1997, Sun Microsystems, Inc. configuring network interfaces: hme0. Hostname: onl50t The / file system (/dev/rdsk/c0t3d0s0) is being checked. /dev/rdsk/c0t3d0s0: FREE BLK COUNT(S) WRONG IN SUPERBLK (SALVAGED) /dev/rdsk/c0t3d0s0: 3959 files, 160278 used, 745582 free /dev/rdsk/c0t3d0s0: (366 frags, 93152 blocks, 0.0% fragmentation) Configuring the /devices directory FRCvme V2.3.1 VME Nexus ( Universe) NOTICE: VME: slavewin at vme=0x0, size=0x100000 space=0x302061f CAMAC device driver V1.3x, 1991-1993 by Y.TAKEUCHI (T.I.T.) cc0 at vme0: vme16d16 0xff00 VME level 4 vector 0xff sparc ipl 7 vmeplus0 at vme0: vme16d16 0x0 and vme24d16 0x0 and vme32d16 0x0 and vme16d32 0x 0 and vme24d32 0x0 and vme32d32 0x0 and space 0x2f offset 0x0 and space 0x6f offset 0x0 and space 0x10 offset 0x0 and space 0x11 offset 0x0 and space 0x50 offset 0x0 and space 0x51 offset 0x0 vmedma0 at vme0 vmefdma0 at vme0 vmedvma0 at vme0 vmectl0 at vme0 Configuring the /dev directory Configuring the /dev directory (compatibility devices) The system is coming up. Please wait. checking ufs filesystems /dev/rdsk/c0t3d0s5: is stable. /dev/rdsk/c0t3d0s4: is stable. /dev/rdsk/c0t3d0s7: is stable. /dev/rdsk/c0t3d0s3: is stable. checking for crash dump...System went down at Thu Jun 17 14:36:25 1999 Saving 3420 pages of image in vmcore.4 3420 pages saved. Processing modules: Done. Constructing Namelist file: /var/crash/onl50t/unix.4 Namelist file complete. add net default: gateway ICCFP1 NIS domainname is kek.jp starting rpc services: rpcbind keyserv done. Setting netmask of hme0 to 255.255.248.0 Setting default interface for multicast: add net 224.0.0.0: gateway onl50t syslog service starting. Print services started. starting Kana-Kanji converters: cssd. volume management starting. Wnn6: Key License Server started.... Nihongo Multi Client Server (Wnn6 R2.30) Finished Reading Files The system is ready. onl50t console login: クラッシュ・ファイルをチェックする。 onl50t# pwd /var/crash/onl50t onl50t# adb -k unix.4 vmcore.4 physmem 7b09 $c complete_panic(?) + 24 do_panic(0x1,0x301fb65c,0x1040c3e8,0x0,0x0,0x0) vcmn_err(0x3,0x1040d408,0x3,0x301fb65c,0x60afc1a0,0x4) + 190 cmn_err(0x3,0x1040d408,0xeffff8a8,0x129,0x129,0x10406400) + 1c die(0x31,0x301fb840,0xeffff94c,0x0,0x1040d408,0x0) + a0 trap(0x301fb840,0x0,0xefffe000,0x1,0x0,0x5) + 830 $ root on /pci@1f,0/scsi@4/disk@3,0:a fstype ufs PCI-device: ebus@1, ebus #0 su0 at ebus0: offset 14,3803f8 su0 is /pci@1f,0/ebus@1/su@14,3803f8 su1 at ebus0: offset 14,3602f8 su1 is /pci@1f,0/ebus@1/su@14,3602f8 keyboard is major <37> minor <0> mouse is major <37> minor <1> se0 at ebus0: offset 14,400000 se0 is /pci@1f,0/ebus@1/se@14,400000 stdin is major <20> minor <0> stdout is major <20> minor <0> SUNW,hme0: CheerIO 2.0 (Rev Id = c1) Found SUNW,hme0 is /pci@1f,0/pci@2,1/network@1,1 PCI-device: network@1,1, hme #1 SUNW,hme1 is /pci@1f,0/network@1,1 SUNW,hme0: Using Internal Transceiver SUNW,hme0: 100 Mbps full-duplex Link Up dump on /dev/dsk/c0t3d0s1 size 268960K VME: Universe rev. 1 at 0x6078e000 VME: LCA rev. 2 at 0xfffa8000 FRCvme V2.3.1 VME Nexus ( Universe) NOTICE: VME: slavewin at vme=0x0, size=0x100000 space=0x302061f PCI-device: vme@5, VME #0 CAMAC device driver V1.3x, 1991-1993 by Y.TAKEUCHI (T.I.T.) cc0 at vme0: vme16d16 0xff00 VME level 4 vector 0xff sparc ipl 7 cc0 is /pci@1f,0/vme@5/cc@2d,ff00 pseudo-device: winlock0 winlock0 is /pseudo/winlock@0 pseudo-device: lockstat0 lockstat0 is /pseudo/lockstat@0 pseudo-device: vol0 vol0 is /pseudo/vol@0 pseudo-device: llc10 llc10 is /pseudo/llc1@0 SUNW,CS42310 at ebus0: offset 14,200000 SUNW,CS42310 is /pci@1f,0/ebus@1/SUNW,CS4231@14,200000 pci1011,240 is /pci@1f,0/pci@2,1/pci@2 pseudo-device: pm0 pm0 is /pseudo/pm@0 pseudo-device: tod0 tod0 is /pseudo/tod@0 pem: no event handler ecpp0 at ebus0: offset 14,3403bc ecpp0 is /pci@1f,0/ebus@1/ecpp@14,3403bc vmeplus0 at vme0: vme16d16 0x0 and vme24d16 0x0 and vme32d16 0x0 and vme16d32 0x0 and vme24d32 0x0 and vme32d32 0x0 and space 0x 2f offset 0x0 and space 0x6f offset 0x0 and space 0x10 offset 0x0 and space 0x11 offset 0x0 and space 0x50 offset 0x0 and space 0x51 offset 0x0 vmeplus0 is /pci@1f,0/vme@5/vmeplus@2d,0 vmedma0 at vme0 vmedma0 is /pci@1f,0/vme@5/vmedma vmefdma0 at vme0 vmefdma0 is /pci@1f,0/vme@5/vmefdma vmedvma0 at vme0 vmedvma0 is /pci@1f,0/vme@5/vmedvma vmectl0 at vme0 vmectl0 is /pci@1f,0/vme@5/vmectl sysconfig0: LCA is CPU-50/520 sysconfig0 at ebus0: offset 14,600000 sysconfig0 is /pci@1f,0/ebus@1/sysconfig@14,600000 BAD TRAP: cpu=0 type=0x31 rp=0x301fb840 addr=0xeffff94c mmu_fsr= 0x0 cam1: trap type = 0x31 addr=0xeffff94c pid=809, pc=0x60d47e88, sp=0x301fb8d0, tstate=0x900001e05, conte xt=0x5ae g1-g7: 6003cca0, 0, 10055f08, 360, 0, 0, 60afc1a0 Begin traceback... sp = 301fb8d0 Called from 100740d0, fp=301fb948, args=f00000 80046302 effff94c 100003 6004dc80 60683780 Called from 10055f70, fp=301fba18, args=60b18080 301fba78 60c67b 30 ef7fb438 ef7fabc8 b Called from 1002ec94, fp=301fba80, args=60b18018 301fbae0 104265 a4 ef7a23b4 0 0 Called from 11370, fp=effff8a8, args=3 80046302 effff94c ef7a23b 4 0 0 End traceback... panic[cpu0]/thread=0x60afc1a0: trap syncing file systems... [1] 3 done 3049 static and sysmap kernel pages 25 dynamic kernel data pages 252 kernel-pageable pages 0 segkmap kernel pages 0 segvn kernel pages 94 current user process pages 3420 total pages (3420 chunks) dumping to vp 601de4cc, offset 0x60d47e88/i cc_ioctl+0xd0: ld [%l0], %l0 $q onl50t# ---xxxx ここまでやった(継続中) --- (6). セクション (6-1). サブセクション (6-1-1). サブサブセクション