Nov 29, 1999 onl50t: Solaris7 cc ドライバのテスト --- cc ドライバのデバッグ#01 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (http://www-online.kek.jp/~inoue/CAMAC/onl50t-sol7/ Desktop/debug-step01.txt) 高エネルギー加速器研究機構 素粒子原子核研究所 物理、オンライングループ 井上 栄二 (1). 現状確認 (A). SPARC CPU-50T、Solaris7 が届いた。 (B). FORCE,CPU-50(UltraSPARC-IIi 300MHz)、に Solaris 7 のシステムを インストールした。 (C). /etc の下のシステム設定の途中、同一SCSIケーブル上に narrow の ディスクと wide のディスクを混在してつないだらシステムが立ち 上がらなくなってしまった。 (D). wide のディスクを narrow のディスクに替えてもらった。 (E). FORCE,CPU-50(UltraSPARC-IIi 300MHz)、に Solaris 7 のシステムを 再インストールした。 (F). /etc の下の各設定、および /export/home の作成をやった。 (G). CPU-50T に Solaris7用の VMEドライバ、FRCvme-2.4.1 をインストール した。 (H). onl50t に ccドライバを make load しようとしたが、64ビット対応に なっていないために組み込めない。 (2). ここでやるべきこと ccドライバを64ビット対応にする。 (3). 症状確認 (3-1). 32ビット対応のccドライバのコンパイル onl50t% pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t% make clean \rm -f cc *.o libcamac.a cam1 cam2 cam3 *~ core onl50t% make ./script/cc_build.sh [Building for sun4u] rm -f cc.o cc -O -c camlib.c -o camlib.o -I. cc -O -c forlib.c -o forlib.o -I. rm -f libcamac.a ar rcv libcamac.a camlib.o forlib.o a - camlib.o a - forlib.o ar: writing libcamac.a cc -O cam1.c -o cam1 -I. -L. -lcamac f77 -fast -O3 -u cam2.f -o cam2 -I. -L. -lcamac cam2.f: MAIN: cc -O cam3.c -o cam3 -I. -L. -lcamac onl50t% ok. 正常にコンパイルできた。 (3-2). 32ビット対応のccドライバのロード、アンロード onl50t# pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t# make load ./script/cc_load.sh [Installing CAMAC device driver] [Adding CAMAC device driver to system] drvconfig: Driver (cc) failed to attach Warning: Driver (cc) successfully added to system but failed to attach [Configuring CAMAC device driver] [Making CAMAC device files] sun4u 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] drvconfig: Driver (cc) failed to attach Warning: Driver (cc) successfully added to system but failed to attach [Configuring CAMAC device driver] [Making CAMAC device files] sun4u onl50t# NG. drvconfig を実行時に failed する。 drvconfig: Driver (cc) failed to attach Warning: Driver (cc) successfully added to system but failed to attach (3-3). ログのチェック /var/messagesファイルをチェック。 onl50t[24]% vi /var/adm/messages : Nov 26 14:14:57 onl50t unix: vmefdma0 at vme0: space 0xad,0 and space 0xbd,0 and space 0x8d,0 and vme16d16,0x0 and vme24d16,0x0 and vme32d16,0x0 and vme16d32,0x 0 and vme24d32,0x0 and vme32d32,0x0 and space 0x3f,0 and space 0x3c,0 and space 0xf,0 and space 0xc,0 and space 0x20,0 Nov 26 14:14:57 onl50t unix: vmefdma0 is /pci@1f,0/vme@5/vmefdma@ad,0 Nov 26 14:14:57 onl50t unix: vmedvma0 at vme0 Nov 26 14:14:57 onl50t unix: vmedvma0 is /pci@1f,0/vme@5/vmedvma Nov 26 14:14:57 onl50t unix: vmectl0 at vme0 Nov 26 14:14:57 onl50t unix: vmectl0 is /pci@1f,0/vme@5/vmectl Nov 26 14:14:57 onl50t unix: NOTICE: cc: 64-bit driver module not found : onl50t[25]% 64-bit driver module が見つからないと言っている。 /devicesファイルのチェック (4). 関連事項のチェック (4-1). man のチェック drvconfig の man onl50t[53]% man drvconfig Reformatting page. Wait... done Maintenance Commands drvconfig(1M) NAME drvconfig - configure the /devices directory SYNOPSIS drvconfig [ -bn ] [ -a alias_name ] [ -c class_name ] [ -i drivername ] [ -m major_num ] [ -r rootdir ] DESCRIPTION The default operation of drvconfig is to create the /dev- ices directory tree that describes, in the filesystem namespace, the hardware layout of a particular machine. Hardware devices present on the machine and powered on as well as pseudo-drivers are represented under /devices. Nor- mally this command is run automatically after a new driver has been installed (with add_drv(1M)) and the system has been rebooted. /etc/minor_perm file drvconfig reads the /etc/minor_perm file to obtain permis- sion information and applies the permissions only to nodes that it has just created. It does not change permissions on already existing nodes. The format of the /etc/minor_perm file is as follows: name:minor_name permissions owner group minor_name may be the actual name of the minor node, or con- tain shell metacharacters to represent several minor nodes (see sh(1)). For example: sd:* 0640 root sys zs:[a-z],cu 0600 uucp uucp mm:kmem 0640 root bin The first line sets all devices exported by the sd node to 0640 permissions, owned by root, with group sys. In the second line, devices such as a,cu and z,cu exported by the zs driver are set to 0600 permission, owned by uucp, with group uucp. In the third line the kmem device exported by the mm driver is set to 0640 permission, owned by root, with group bin. OPTIONS The following options may be of use to system administrators and driver developers: -i drivername Only configure the devices for the named driver. The following options are used by the implementa- tion of add_drv(1M) and rem_drv(1M), and may not SunOS 5.7 Last change: 26 Jan 1996 1 Maintenance Commands drvconfig(1M) be supported in future versions of Solaris: -b Add a new major number to name binding into the kernel's internal name_to_major tables. This option is not normally used directly, but is used by other utilities such as add_drv(1M). Use of the -b option requires that -i and -m be used also. No /devices entries are created. -n Do not try to load and attach any drivers, or if the -i option is given, do not try to attach the driver named drivername. -a alias_name Add the name alias_name to the list of aliases that this driver is known by. This option, if used, must be used with the -m major_num, the -b and the -i drivername options. -c class_name The driver being added to the system exports the class class_name. This option is not normally used directly, but is used by other utilities. It is only effective when used with the -b option. -m major_num Specify the major number major_num for this driver to add to the kernel's name_to_major binding tables. -r rootdir Build the device tree under the directory speci- fied by rootdir instead of the default /devices directory. EXIT STATUS 0 Successful completion. non-zero An error occurred. FILES /devices device nodes directory /etc/minor_perm minor mode permissions /etc/name_to_major major number binding /etc/driver_classes driver class binding file SunOS 5.7 Last change: 26 Jan 1996 2 Maintenance Commands drvconfig(1M) ATTRIBUTES See attributes(5) for descriptions of the following attri- butes: ____________________________________________________________ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |_____________________________|_____________________________| | Availability | SUNWcsu | |_____________________________|_____________________________| SEE ALSO sh(1), add_drv(1M), devlinks(1M), disks(1M), modinfo(1M), modload(1M), modunload(1M), ports(1M), rem_drv(1M), tapes(1M), path_to_inst(4), attributes(5) NOTES This document does not constitute an API. /etc/minor_perm, /etc/name_to_major, /etc/driver_classes, and /devices may not exist or may have different contents or interpretations in a future release. The existence of this notice does not imply that any other documentation that lacks this notice constitutes an API. SunOS 5.7 Last change: 26 Jan 1996 3 onl50t[54]% add_drv の man onl50t[55]% man add_drv Reformatting page. Wait... done Maintenance Commands add_drv(1M) NAME add_drv - add a new device driver to the system SYNOPSIS add_drv [ -b basedir ] [ -c class_name ] [ -i 'identify_name...' ] [ -m 'permission','...' ] [ -n ] [ -f ] [ -v ] device_driver DESCRIPTION The add_drv command is used to inform the system about newly installed device drivers. Each device on the system has a name associated with it. This name is represented by the name property for the dev- ice. Similarly, the device may also have a list of driver names associated with it. This list is represented by the compatible property for the device. The system determines which devices will be managed by the driver being added by examining the contents of the name property and the compatible property (if it exists) on each device. If the value in the name property does not match the driver being added, each entry in the compatible pro- perty is tried, in order, until either a match occurs or there are no more entries in the compatible property. In some cases, adding a new driver may require a reconfi- guration boot. See the NOTES section. OPTIONS -b basedir Installs the driver on the system with a root directory of basedir rather than installing on the system executing add_drv . This option is typi- cally used in package post-installation scripts when the package is not being installed on the system executing the pkgadd command. The system using basedir as its root directory must reboot to complete the driver installation. -c class_name The driver being added to the system exports the class class_name. -i 'identify_name' A white-space separated list of aliases for the driver device_driver. -m 'permission' Specify the file system permissions for device nodes created by the system on behalf of device_driver. SunOS 5.7 Last change: 5 Aug 1998 1 Maintenance Commands add_drv(1M) -n Do not try to load and attach device_driver, just modify the system configuration files for the device_driver. -f Normally if a reconfiguration boot is required to complete the configuration of the driver into the system, add_drv will not add the driver. The force flag forces add_drv to add the driver even if a reconfiguration boot is required. See the -v flag. -v The verbose flag causes add_drv to provide addi- tional information regarding the success or failure of a driver's configuration into the sys- tem. See the EXAMPLES section. EXAMPLES Example 1: Adding The SUNW, Example Driver to the System The following example adds the SUNW,example driver to the system, with an alias name of SUNW,alias. It assumes the driver has already been copied to /usr/kernel/drv. example# add_drv -m '* 0666 bin bin','a 0644 root sys' \ -i 'SUNW,alias' SUNW,example Every minor node created by the system for the SUNW,example driver will have the permission 0666, and be owned by user bin in the group bin, except for the minor device a, which will be owned by root, group sys, and have a permission of 0644. Example 2: Adding The Driver To The Client /export/root/sun1 The following example adds the driver to the client /export/root/sun1. The driver is installed and loaded when the client machine, sun1, is rebooted. This second example produces the same result as the first, except the changes are on the diskless client, sun1, and the client must be rebooted for the driver to be installed. example# add_drv -m '* 0666 bin bin','a 0644 root sys' \ -i 'SUNW,alias' -b /export/root/sun1 \ SUNW,example Example 3: Adding A Driver For A Device That Is Already Managed By An Existing Driver The following example illustrates the case where a new driver is added for a device that is already managed by an existing driver. Consider a device that is currently managed by the driver dumb_framebuffer. The name and compatible properties for this device are as follows: SunOS 5.7 Last change: 5 Aug 1998 2 Maintenance Commands add_drv(1M) name="display" compatible="whizzy_framebuffer", "dumb_framebuffer" If add_drv is used to add the whizzy_framebuffer driver, the following will result. example# add_drv whizzy_framebuffer Error: Could not install driver (whizzy_framebuffer) Device managed by another driver. If the -v flag is specified, the following will result. example# add_drv -v whizzy_framebuffer Error: Could not install driver (whizzy_framebuffer) Device managed by another driver. Driver installation failed because the following entries in /devices would be affected: /devices/iommu@f,e0000000/sbus@f,e0001000/display[:*] (Device currently managed by driver "dumb_framebuffer") The following entries in /dev would be affected: /dev/fbs/dumb_framebuffer0 If the -v and -f flags are specified, the driver will be added resulting in the following. example# add_drv -vf whizzy_framebuffer A reconfiguration boot must be performed to complete the installation of this driver. The following entries in /devices will be affected: /devices/iommu@f,e0000000/sbus@f,e0001000/display[:*] (Device currently managed by driver "dumb_framebuffer" The following entries in /dev will be affected: /dev/fbs/dumb_framebuffer0 The above example is currently only relevant to devices exporting a generic device name. EXIT STATUS add_drv returns 0 on success and 1 on failure. FILES /kernel/drv boot device drivers /usr/kernel/drv other drivers that could potentially be shared between platforms /platform/`uname -i`/kernel/drv SunOS 5.7 Last change: 5 Aug 1998 3 Maintenance Commands add_drv(1M) platform-dependent drivers /etc/driver_aliases driver aliases file /etc/driver_classes driver classes file /etc/minor_perm minor node permissions /etc/name_to_major major number binding ATTRIBUTES See attributes(5) for descriptions of the following attri- butes: ____________________________________________________________ | ATTRIBUTE TYPE | ATTRIBUTE | |_____________________________|_____________________________| | VALUE | | |_____________________________|_____________________________| | Availability | SUNWcsu | |_____________________________|_____________________________| SEE ALSO boot(1M), devlinks(1M), disks(1M), drvconfig(1M), kernel(1M), modinfo(1M), ports(1M), rem_drv(1M), tapes(1M), driver.conf(4), system(4), attributes(5), ddi_create_minor_node(9F) Writing Device Drivers NOTES Aliases may require quoting (with double-quotes) if they contain numbers. It is possible to add a driver for a device already being managed by a different driver, where the driver being added appears in the device's compatible list before the current driver. In such cases, a reconfiguration boot is required (see boot(1M) and kernel(1M)). After the reconfiguration boot, device nodes in /devices, entries in /dev, and references to these files may no longer be valid (see the -v flag). If a reconfiguration boot would be required to complete the driver installation, add_drv will fail unless the -f option is specified. See Example 3 in the EXAMPLES sec- tion. BUGS SunOS 5.7 Last change: 5 Aug 1998 4 Maintenance Commands add_drv(1M) add_drv will accept a full pathname for device_driver. However, the kernel does not use the full pathname; it only uses the final component and searches the internal driver search path for the driver. This can lead to the kernel loading a different driver than expected. For this reason, it is not recommended that you use add_drv with a full pathname. See kernel(1M) for more information on the driver search path. SunOS 5.7 Last change: 5 Aug 1998 5 onl50t[56]% ) (4-2). のチェック ---xxxx(ここまでやった。継続中) onl50t% pwd /export/home/onl50t/inoue/CAMAC onl50t% ls -l total 0 onl50t% ftp online.kek.jp Connected to onlax2.kek.jp. 220 onlax2.kek.jp FTP server (Digital UNIX Version 5.60) ready. Name (online.kek.jp:inoue): anonymous 331 Guest login ok, send ident as password. Password: 230 Guest login ok, access restrictions apply. ftp> dir 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls (130.87.217.131,32793). total 4 d--x--x--x 2 0 0 512 Jun 17 1997 bin drwxr-xr-x 3 0 0 512 Jun 17 1997 etc drwxr-xr-x 4 60002 60002 512 Jun 17 1997 pub -rw-r--r-- 1 0 0 125 Jun 17 1997 welcome.msg 226 Transfer complete. 253 bytes received in 0.23 seconds (1.07 Kbytes/s) ftp> cd pub/kek/camac 250 CWD command successful. ftp> dir 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls (130.87.217.131,32794). total 3310 -rw-r--r-- 1 0 10 1173 Apr 19 1995 122d_to_e.tar.gz -rw-r--r-- 1 0 10 24125 Jul 26 16:54 FORCE-50T-sol2.6.tar.gz -rw-r--r-- 1 0 10 22160 Nov 19 1997 FORCE-5V-sol2.5.tar.gz -rw-r--r-- 1 0 10 2494 Dec 2 1994 README -rw-r--r-- 1 0 10 30106 Oct 13 15:17 SPARC-status.html -rw-r--r-- 1 0 10 21435 Dec 13 1994 camac.sol2-1.30.tar.gz -rw-r--r-- 1 0 10 169539 Aug 18 1993 camac.sparc-1.22b.tar.Z -rw-r--r-- 1 0 10 91662 Aug 18 1993 camac.sparc-1.22b.tar.gz -rw-r--r-- 1 0 10 198417 Aug 19 1993 camac.sparc-1.22c.tar.Z -rw-r--r-- 1 0 10 110755 Aug 19 1993 camac.sparc-1.22c.tar.gz -rw-r--r-- 1 0 10 199103 Sep 4 1993 camac.sparc-1.22d.tar.Z -rw-r--r-- 1 0 10 110752 Sep 4 1993 camac.sparc-1.22d.tar.gz -rw-r--r-- 1 0 10 287493 Apr 20 1995 camacv1.01_decs.tar.Z -rw-r--r-- 1 0 10 231505 Dec 2 1994 camacv1.01_hprt.tar.Z -rw-r--r-- 1 0 10 132002 Dec 2 1994 camacv1.01_hprt.tar.gz -rw-r--r-- 1 0 10 283202 Dec 2 1994 camacv1.0_decs.tar.Z -rw-r--r-- 1 0 10 159495 Dec 2 1994 camacv1.0_decs.tar.gz -rw-r--r-- 1 0 10 216777 Sep 13 1994 camacv1.0_hprt.tar.Z -rw-r--r-- 1 0 10 122114 Sep 13 1994 camacv1.0_hprt.tar.gz -rw-r--r-- 1 0 10 87379 Nov 30 1994 camlib-docs-1.0.tar.Z -rw-r--r-- 1 0 10 51118 Nov 30 1994 camlib-docs-1.0.tar.gz -rw-r--r-- 1 0 10 13589 Jan 17 1995 sparc-3ce.tar.gz -rw-r--r-- 1 0 10 233395 Aug 18 1993 tdaq-1.00.tar.Z -rw-r--r-- 1 0 10 121288 Apr 2 1992 tdaq-1.00.tar.gz -rw-r--r-- 1 0 10 277799 Jan 20 1995 vme-3CE.tar.gz 226 Transfer complete. 1909 bytes received in 0.05 seconds (37.47 Kbytes/s) ftp> binary 200 Type set to I. ftp> get FORCE-50T-sol2.6.tar.gz 200 PORT command successful. 150 Opening BINARY mode data connection for FORCE-50T-sol2.6.tar.gz (130.87.217. 131,32795) (24125 bytes). 226 Transfer complete. local: FORCE-50T-sol2.6.tar.gz remote: FORCE-50T-sol2.6.tar.gz 24125 bytes received in 0.07 seconds (338.14 Kbytes/s) ftp> quit 221 Goodbye. onl50t% ls -l total 48 -rw-r--r-- 1 inoue kek 24125 Nov 24 15:31 FORCE-50T-sol2.6.tar.gz onl50t% onl50t% gzip -d FORCE-50T-sol2.6.tar.gz onl50t% ls -l total 288 -rw-r--r-- 1 inoue kek 132096 Jul 26 16:53 FORCE-50T-sol2.6.tar onl50t% tar xvf FORCE-50T-sol2.6.tar x FORCE-50T-sol2.6, 0 bytes, 0 tape blocks x FORCE-50T-sol2.6/Makefile, 2041 bytes, 4 tape blocks x FORCE-50T-sol2.6/README, 3624 bytes, 8 tape blocks x FORCE-50T-sol2.6/cam1.c, 1170 bytes, 3 tape blocks x FORCE-50T-sol2.6/cam2.f, 2295 bytes, 5 tape blocks x FORCE-50T-sol2.6/cam3.c, 2055 bytes, 5 tape blocks x FORCE-50T-sol2.6/camlib.c, 9740 bytes, 20 tape blocks x FORCE-50T-sol2.6/camlib.h, 1415 bytes, 3 tape blocks x FORCE-50T-sol2.6/cc.c, 74943 bytes, 147 tape blocks x FORCE-50T-sol2.6/cc.conf, 288 bytes, 1 tape blocks x FORCE-50T-sol2.6/cc.h, 2931 bytes, 6 tape blocks x FORCE-50T-sol2.6/cc_common.h, 2288 bytes, 5 tape blocks x FORCE-50T-sol2.6/cc_config.h, 876 bytes, 2 tape blocks x FORCE-50T-sol2.6/forlib.c, 3289 bytes, 7 tape blocks x FORCE-50T-sol2.6/k2917.h, 4058 bytes, 8 tape blocks x FORCE-50T-sol2.6/script, 0 bytes, 0 tape blocks x FORCE-50T-sol2.6/script/cc_build.sh, 234 bytes, 1 tape blocks x FORCE-50T-sol2.6/script/cc_load.sh, 808 bytes, 2 tape blocks x FORCE-50T-sol2.6/script/cc_unload.sh, 270 bytes, 1 tape blocks x FORCE-50T-sol2.6/script/cc_build.gcc.sh, 233 bytes, 1 tape blocks x FORCE-50T-sol2.6/script/cc_link.sh, 528 bytes, 2 tape blocks x FORCE-50T-sol2.6/script/awk1.txt, 66 bytes, 1 tape blocks x FORCE-50T-sol2.6/script/awk2.txt, 37 bytes, 1 tape blocks onl50t% (3-2). 展開したキットをコンパイルする (3-2-1). コンパイラのバージョンをチェック onl50t% which cc /kek/compilers/ws5.0/SUNWspro/bin/cc onl50t% which f77 /kek/compilers/ws5.0/SUNWspro/bin/f77 onl50t% cc -V cc: WorkShop Compilers 5.0 98/12/15 C 5.0 usage: cc [ options] files. Use 'cc -flags' for details onl50t% f77 -V f77: WorkShop Compilers 5.0 98/12/15 FORTRAN 77 5.0 Usage: f77 [ options ] files. Use 'f77 -flags' for details onl50t% (3-2-2). CAMACドライバをコンパイルする onl50t% pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t% make clean \rm -f cc *.o libcamac.a cam1 cam2 cam3 *~ core onl50t% ls -l total 234 -rw-r--r-- 1 inoue kek 2041 Jul 19 15:30 Makefile -rw-r--r-- 1 inoue kek 3624 Jul 26 14:10 README -rw-r--r-- 1 inoue kek 1170 Jul 16 10:47 cam1.c -rw-r--r-- 1 inoue kek 2295 Jul 16 10:47 cam2.f -rw-r--r-- 1 inoue kek 2055 Jul 16 10:47 cam3.c -rw-r--r-- 1 inoue kek 9740 Jul 16 10:47 camlib.c -rw-r--r-- 1 inoue kek 1415 Jul 16 10:47 camlib.h -rw-r--r-- 1 inoue kek 74943 Jul 26 15:32 cc.c -rw-r--r-- 1 inoue kek 288 Jul 16 10:47 cc.conf -rw-r--r-- 1 inoue kek 2931 Jul 26 16:45 cc.h -rw-r--r-- 1 inoue kek 2288 Jul 16 10:47 cc_common.h -rw-r--r-- 1 inoue kek 876 Jul 16 10:47 cc_config.h -rw-r--r-- 1 inoue kek 3289 Jul 16 10:47 forlib.c -rw-r--r-- 1 inoue kek 4058 Jul 16 10:47 k2917.h drwxr-xr-x 2 inoue kek 512 Jul 16 14:59 script onl50t% make ./script/cc_build.sh [Building for sun4u] "cc.c", line 174: warning: initialization type mismatch "cc.c", line 943: warning: improper pointer/integer combination: arg #1 "cc.c", line 1019: warning: argument #1 is incompatible with prototype: prototype: pointer to function(pointer to void) returning void : "/usr/i nclude/sys/systm.h", line 100 argument : pointer to function(pointer to char) returning void "cc.c", line 1019: warning: improper pointer/integer combination: op "=" "cc.c", line 1029: warning: improper pointer/integer combination: arg #1 "cc.c", line 2801: warning: argument #1 is incompatible with prototype: prototype: pointer to function(pointer to void) returning void : "/usr/i nclude/sys/systm.h", line 100 argument : pointer to function(pointer to char) returning void "cc.c", line 2801: warning: improper pointer/integer combination: op "=" rm -f cc.o cc -O -c camlib.c -o camlib.o -I. cc -O -c forlib.c -o forlib.o -I. rm -f libcamac.a ar rcv libcamac.a camlib.o forlib.o a - camlib.o a - forlib.o ar: writing libcamac.a cc -O cam1.c -o cam1 -I. -L. -lcamac f77 -fast -O3 -u cam2.f -o cam2 -I. -L. -lcamac cam2.f: MAIN: cc -O cam3.c -o cam3 -I. -L. -lcamac onl50t% これらコンパイル時の warning は、onl8v1、Solaris7 でコンパイルした時と 全く同じである。 ここでも onl8v1、Solaris7 でとった処置と同じ処置を とることにする。 (4). ccドライバの見直し (4-1). ""cc.c", line 174: warning" のチェック ""cc.c", line 174: warning: initialization type mismatch" の warning に 対する処置。 (4-1-1). ioctl() の man をチェック onl50t% man -s 9e ioctl Reformatting page. Wait... done Driver Entry Points ioctl(9E) NAME ioctl - control a character device SYNOPSIS #include #include #include #include #include #include int prefixioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_p); INTERFACE LEVEL Architecture independent level 1 (DDI/DKI). This entry point is optional. ARGUMENTS dev Device number. cmd Command argument the driver ioctl() routine interprets as the operation to be performed. arg Passes parameters between a user program and the driver. When used with terminals, the argument is the address of a user program structure containing driver or hardware settings. Alternatively, the argument may be a value that has meaning only to the driver. The interpretation of the argument is driver dependent and usually depends on the com- mand type; the kernel does not interpret the argu- ment. mode A bit field that contains: o Information set when the device was opened. The driver may use it to determine if the device was opened for reading or writing. The driver can make this determination by checking the FREAD or FWRITE flags. See the flag argument description of the open() routine for further values. o Information on whether the caller is a 32- bit or 64-bit thread. o In some circumstances address space informa- tion about the arg argument. See below. cred_p Pointer to the user credential structure. SunOS 5.7 Last change: 3 Dec 1996 1 Driver Entry Points ioctl(9E) rval_p Pointer to return value for calling process. The driver may elect to set the value which is valid only if the ioctl() succeeds. DESCRIPTION ioctl() provides character-access drivers with an alternate entry point that can be used for almost any operation other than a simple transfer of characters in and out of buffers. Most often, ioctl() is used to control device hardware parameters and establish the protocol used by the driver in processing data. The kernel determines that this is a character device, and looks up the entry point routines in cb_ops(9S). The kernel then packages the user request and arguments as integers and passes them to the driver's ioctl() routine. The kernel itself does no processing of the passed command, so it is up to the user program and the driver to agree on what the arguments mean. I/O control commands are used to implement the terminal set- tings passed from ttymon(1M) and stty(1), to format disk devices, to implement a trace driver for debugging, and to clean up character queues. Since the kernel does not inter- pret the command type that defines the operation, a driver is free to define its own commands. Drivers that use an ioctl() routine typically have a com- mand to ``read'' the current ioctl() settings, and at least one other that sets new settings. Drivers can use the mode argument to determine if the device unit was opened for reading or writing, if necessary, by checking the FREAD or FWRITE setting. If the third argument, arg, is a pointer to a user buffer, the driver can call the copyin(9F) and copyout(9F) func- tions to transfer data between kernel and user space. Other kernel subsystems may need to call into the drivers ioctl() routine. Drivers that intend to allow their ioctl() routine to be used in this way should publish the ddi- kernel-ioctl property on the associated devinfo node(s). When the ddi-kernel-ioctl property is present, the mode argument is used to pass address space information about arg through to the driver. If the driver expects arg to contain a buffer address, and the FKIOCTL flag is set in mode, then the driver should assume that it is being handed a kernel buffer address. Otherwise, arg may be the address of a buffer from a user program. The driver can use ddi_copyin(9F) and ddi_copyout(9F) perform the correct type of copy operation for either kernel or user address spaces. SunOS 5.7 Last change: 3 Dec 1996 2 Driver Entry Points ioctl(9E) See the example on ddi_copyout(9F). Drivers have to interact with 32-bit and 64-bit applica- tions. If a device driver shares data structures with the application (for example, through exported kernel memory) and the driver gets recompiled for a 64-bit kernel but the application remains 32-bit, binary layout of any data struc- tures will be incompatible if they contain longs or pointers. The driver needs to know whether there is a model mismatch between the current thread and the kernel and take necessary action. The mode argument has additional bits set to determine the C Language Type Model which the current thread expects. mode has FILP32 set if the current thread expects 32-bit ( ILP32) semantics, or FLP64 if the current thread expects 64-bit ( LP64) semantics. mode is used in combination with ddi_model_convert_from(9F) and the FMODELS mask to determine whether there is a data model mismatch between the current thread and the device driver (see the example below). The device driver might have to adjust the shape of data structures before exporting them to a user thread which supports a different data model. To implement I/O control commands for a driver the following two steps are required: 1. Define the I/O control command names and the associ- ated value in the driver's header and comment the com- mands. 2. Code the ioctl() routine in the driver that defines the functionality for each I/O control command name that is in the header. The ioctl() routine is coded with instructions on the proper action to take for each command. It is commonly a switch statement, with each case definition corresponding to an ioctl() name to identify the action that should be taken. However, the command passed to the driver by the user process is an integer value associated with the command name in the header. RETURN VALUES ioctl() should return 0 on success, or the appropriate error number. The driver may also set the value returned to the calling process through rval_p. EXAMPLES Example 1: ioctl() entry point The following is an example of the ioctl() entry point and how to support 32-bit and 64-bit applications with the same device driver. SunOS 5.7 Last change: 3 Dec 1996 3 Driver Entry Points ioctl(9E) struct passargs32 { int len; caddr32_t addr; }; struct passargs { int len; caddr_t addr; }; xxioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, int *rvalp) { struct passargs pa; #ifdef _MULTI_DATAMODEL switch (ddi_model_convert_from(mode & FMODELS)) { case DDI_MODEL_ILP32: { struct passargs32 pa32; ddi_copyin(arg, &pa32, sizeof (struct passargs32), mode); pa.len = pa32.len; pa.address = pa32.address; break; } case DDI_MODEL_NONE: ddi_copyin(arg, &pa, sizeof (struct passargs), mode); break; } #else /* _MULTI_DATAMODEL */ ddi_copyin(arg, &pa, sizeof (struct passargs), mode); #endif /* _MULTI_DATAMODEL */ do_ioctl(&pa); .... } SEE ALSO stty(1), ttymon(1M), dkio(7I), fbio(7I), termio(7I), open(9E), put(9E), srv(9E), copyin(9F), copyout(9F), ddi_copyin(9F), ddi_copyout(9F), ddi_model_convert_from(9F), cb_ops(9S) WARNINGS Non-STREAMS driver ioctl() routines must make sure that user data is copied into or out of the kernel address space explicitly using copyin(9F), copyout(9F), ddi_copyin(9F), or ddi_copyout(9F), as appropriate. It is a severe error to simply dereference pointers to the user address space, even when in user context. SunOS 5.7 Last change: 3 Dec 1996 4 Driver Entry Points ioctl(9E) Failure to use the appropriate copying routines can result in panics under load on some platforms, and reproducible panics on others. NOTES STREAMS drivers do not have ioctl() routines. The stream head converts I/O control commands to M_IOCTL messages, which are handled by the driver's put(9E) or srv(9E) rou- tine. SunOS 5.7 Last change: 3 Dec 1996 5 onl50t% man によると arg引数のタイプは intptr_t になっているが、cc.cファイルでは intタイプになっている。 修正する。 (4-1-2). cc.cファイルを修正 onl50t% pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t% vi cc.c : 134 static int cc_write(dev_t dev, struct uio *uio, cred_t *cred_p); 135 /* E.Inoue 136 static int cc_ioctl(dev_t dev, int cmd, int arg, int flag, cred_t *cred_ p, 137 int *rval_p); 138 end */ 139 static int cc_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t * cred_p, 140 int *rval_p); 141 static int cc_strategy(struct buf *bp); : 958 static int 959 cc_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cred_p, int *rval_p) 960 /* E.Inoue 961 cc_ioctl(dev_t dev, int cmd, int arg, int flag, cred_t *cred_p, int *rva l_p) 962 end */ 963 { 964 /* register struct cc_device *cc = &ccdevice[0]; */ 965 register struct cc_device *cc; : "cc.c" 2930 lines, 75160 characters onl50t% (4-1-3). cc.cファイルを再コンパイル onl50t% pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t% make clean \rm -f cc *.o libcamac.a cam1 cam2 cam3 *~ core onl50t% make ./script/cc_build.sh [Building for sun4u] "cc.c", line 947: warning: improper pointer/integer combination: arg #1 "cc.c", line 1026: warning: argument #1 is incompatible with prototype: prototype: pointer to function(pointer to void) returning void : "/usr/include/sys/systm.h", line 100 argument : pointer to function(pointer to char) returning void "cc.c", line 1026: warning: improper pointer/integer combination: op "=" "cc.c", line 1036: warning: improper pointer/integer combination: arg #1 "cc.c", line 2808: warning: argument #1 is incompatible with prototype: prototype: pointer to function(pointer to void) returning void : "/usr/include/sys/systm.h", line 100 argument : pointer to function(pointer to char) returning void "cc.c", line 2808: warning: improper pointer/integer combination: op "=" rm -f cc.o cc -O -c camlib.c -o camlib.o -I. cc -O -c forlib.c -o forlib.o -I. rm -f libcamac.a ar rcv libcamac.a camlib.o forlib.o a - camlib.o a - forlib.o ar: writing libcamac.a cc -O cam1.c -o cam1 -I. -L. -lcamac f77 -fast -O3 -u cam2.f -o cam2 -I. -L. -lcamac cam2.f: MAIN: cc -O cam3.c -o cam3 -I. -L. -lcamac onl50t% ok. ""cc.c", line 174: warning: initialization type mismatch" の warning は 出なくなった。 (4-2). ""cc.c", line 947: warning" のチェック ""cc.c", line 947: warning: improper pointer/integer combination: arg #1" の warning に対する処置。 (4-2-1). cc.cファイル をチェック onl50t% vi cc.c : 62 struct cc_device { 63 int status; /* current system status */ : 102 int timeout_id; : 117 /* end */ 118 } ccdevice[NCC]; : 905 static u_int 906 cc_intr(int unit) 907 { 908 /* register struct cc_device *cc = &ccdevice[0]; */ 909 register struct cc_device *cc; : 947 untimeout(cc->timeout_id); : onl50t% (4-2-2). untimeout の man をチェック onl50t% man untimeout Kernel Functions for Drivers untimeout(9F) NAME untimeout - cancel previous timeout function call SYNOPSIS #include #include clock_t untimeout(timeout_id_t id); INTERFACE LEVEL Architecture independent level 1 (DDI/DKI). PARAMETERS id Opaque timeout ID from a previous timeout(9F) call. DESCRIPTION untimeout() cancels a pending timeout(9F) request. untimeout() will not return until the pending callback is cancelled or has run. Because of this, locks acquired by the callback routine should not be held across the call to untimeout() or a deadlock may result. Since no mutex should be held across the call to untimeout(), there is a race condition between the occurrence of an expected event and the execution of the timeout handler. In particular, it should be noted that no problems will result from calling untimeout() for a timeout which is either running on another CPU, or has already com- pleted. Drivers should be structured with the understanding that the arrival of both an interrupt and a timeout for that interrupt can occasionally occur, in either order. RETURN VALUES untimeout() returns -1 if the id is not found. Otherwise, it returns an integer value greater than or equal to 0. CONTEXT untimeout() can be called from user or interrupt context. EXAMPLES Example 1: In the following example, the device driver has issued an IO request and is waiting for the device to respond. If the device does not respond within 5 seconds, the device driver will print out an error message to the console. static void xxtimeout_handler(void *arg) { struct xxstate *xsp = (struct xxstate *)arg; SunOS 5.7 Last change: 18 Feb 1998 1 Kernel Functions for Drivers untimeout(9F) mutex_enter(&xsp->lock); cv_signal(&xsp->cv); xsp->flags |= TIMED_OUT; mutex_exit(&xsp->lock); xsp->timeout_id = 0; } static uint_t xxintr(caddr_t arg) { struct xxstate *xsp = (struct xxstate *)arg; . . . mutex_enter(&xsp->lock); /* Service interrupt */ cv_signal(&xsp->cv); mutex_exit(&xsp->lock); if (xsp->timeout_id != 0) { (void) untimeout(xsp->timeout_id); xsp->timeout_id = 0; } return(DDI_INTR_CLAIMED); } static void xxcheckcond(struct xxstate *xsp) { . . . xsp->timeout_id = timeout(xxtimeout_handler, xsp, (5 * drv_usectohz(1000000))); mutex_enter(&xsp->lock); while (/* Waiting for interrupt or timeout*/) cv_wait(&xsp->cv, &xsp->lock); if (xsp->flags & TIMED_OUT) cmn_err(CE_WARN, "Device not responding"); . . . mutex_exit(&xsp->lock); . . . } SEE ALSO open(9E), cv_signal(9F), cv_wait_sig(9F), delay(9F), timeout(9F) Writing Device Drivers SunOS 5.7 Last change: 18 Feb 1998 2 onl50t% man によると untimeout()で使用する引数は、timeout_id_tタイプであるが cc.cファイルではこの引数を int で定義している。 timeout_id変数を timeout_id_tタイプで定義してコンパイルしてみる。 (4-2-3). cc.c を修正 onl50t% vi cc.c : 102 /* E.Inoue 103 int timeout_id; 104 end */ 105 timeout_id_t timeout_id; 106 struct buf *bp; : "cc.c" 2933 lines, 75208 characters onl50t% (4-2-4). cc.cファイルを再コンパイル onl50t% pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t% make clean \rm -f cc *.o libcamac.a cam1 cam2 cam3 *~ core onl50t% make ./script/cc_build.sh [Building for sun4u] "cc.c", line 1029: warning: argument #1 is incompatible with prototype: prototype: pointer to function(pointer to void) returning void : "/usr/include/sys/systm.h", line 100 argument : pointer to function(pointer to char) returning void "cc.c", line 2811: warning: argument #1 is incompatible with prototype: prototype: pointer to function(pointer to void) returning void : "/usr/include/sys/systm.h", line 100 argument : pointer to function(pointer to char) returning void rm -f cc.o cc -O -c camlib.c -o camlib.o -I. cc -O -c forlib.c -o forlib.o -I. rm -f libcamac.a ar rcv libcamac.a camlib.o forlib.o a - camlib.o a - forlib.o ar: writing libcamac.a cc -O cam1.c -o cam1 -I. -L. -lcamac f77 -fast -O3 -u cam2.f -o cam2 -I. -L. -lcamac cam2.f: MAIN: cc -O cam3.c -o cam3 -I. -L. -lcamac onl50t% ok. 行番号947 の warning "improper pointer/integer combination: arg #1" は出なくなった。 (4-3). ""cc.c", line 1029: warning" のチェック "cc.c", line 1029: warning: argument #1 is incompatible with prototype: prototype: pointer to function(pointer to void) returning void : "/usr/include/sys/systm.h", line 100 の warning に対する処置。 (4-3-1). cc.cファイル をチェック onl50t% vi cc.c : 961 static int 962 cc_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cred_p, int *rval_p) 963 /* E.Inoue 964 cc_ioctl(dev_t dev, int cmd, int arg, int flag, cred_t *cred_p, int *rva l_p) 965 end */ 966 { 967 /* register struct cc_device *cc = &ccdevice[0]; */ 968 register struct cc_device *cc; : 979 unit = getminor(dev); : 1029 cc->timeout_id = timeout(cc_timeout, (caddr_t)&unit, cc->data1 * hz); : onl50t% (4-3-2). timeout、getminor の man をチェック onl50t% man -k timeout devmap_set_ctx_timeout devmap_set_ctx_timeout (9f) - set the timeout value for the context management callback ldap_ufn_timeout ldap_ufn (3n) - LDAP user friendly search functions notimeout curs_inopts (3x) - curses terminal input option control routines notimeout notimeout (3xc) - set timed blocking or non-blocking read qtimeout qtimeout (9f) - execute a function after a specified length of time quntimeout quntimeout (9f) - cancel previous qtimeout function call timeout curs_inopts (3x) - curses terminal input option control routines timeout notimeout (3xc) - set timed blocking or non-blocking read timeout timeout (9f) - execute a function after a specified length of time untimeout untimeout (9f) - cancel previous timeout function call wtimeout curs_inopts (3x) - curses terminal input option control routines wtimeout notimeout (3xc) - set timed blocking or non-blocking read onl50t% onl50t% man -s 9f timeout Reformatting page. Wait... done Kernel Functions for Drivers timeout(9F) NAME timeout - execute a function after a specified length of time SYNOPSIS #include #include timeout_id_t timeout(void (* func)(void *), void *arg, clock_t ticks); INTERFACE LEVEL Architecture independent level 1 (DDI/DKI). PARAMETERS func Kernel function to invoke when the time increment expires. arg Argument to the function. ticks Number of clock ticks to wait before the function is called. DESCRIPTION The timeout() function schedules the specified function to be called after a specified time interval. The exact time interval over which the timeout takes effect cannot be guaranteed, but the value given is a close approximation. The function called by timeout() must adhere to the same restrictions as a driver soft interrupt handler. The function called by timeout() is run in interrupt context and must not sleep or call other functions which may sleep. RETURN VALUES timeout() returns an opaque non-zero timeout identifier that can be passed to untimeout(9F) to cancel the request. CONTEXT timeout() can be called from user or interrupt context. EXAMPLES Example 1: Using timeout() In the following example, the device driver has issued an IO request and is waiting for the device to respond. If the device does not respond within 5 seconds, the device driver will print out an error message to the console. static void xxtimeout_handler(void *arg) SunOS 5.7 Last change: 19 Feb 1998 1 Kernel Functions for Drivers timeout(9F) { struct xxstate *xsp = (struct xxstate *)arg; mutex_enter(>lock); cv_signal(>cv); xsp->flags |= TIMED_OUT; mutex_exit(>lock); xsp->timeout_id = 0; } static uint_t xxintr(caddr_t arg) { struct xxstate *xsp = (struct xxstate *)arg; . . . mutex_enter(>lock); /* Service interrupt */ cv_signal(>cv); mutex_exit(>lock); if (xsp->timeout_id != 0) { (void) untimeout(xsp->timeout_id); xsp->timeout_id = 0; } return(DDI_INTR_CLAIMED); } static void xxcheckcond(struct xxstate *xsp) { . . . xsp->timeout_id = timeout(xxtimeout_handler, xsp, 5 * drv_usectohz(1000000)); mutex_enter(>lock); while (/* Waiting for interrupt or timeout*/) cv_wait(>cv, >lock); if (xsp->flags & TIMED_OUT) cmn_err(CE_WARN, "Device not responding"); . . . mutex_exit(>lock); . SunOS 5.7 Last change: 19 Feb 1998 2 Kernel Functions for Drivers timeout(9F) . . } SEE ALSO bufcall(9F), delay(9F), untimeout(9F) Writing Device Drivers SunOS 5.7 Last change: 19 Feb 1998 3 onl50t% onl50t% man getminor Kernel Functions for Drivers getminor(9F) NAME getminor - get minor device number SYNOPSIS #include #include #include minor_t getminor(dev_t dev); INTERFACE LEVEL Architecture independent level 1 (DDI/DKI). PARAMETERS dev Device number. DESCRIPTION getminor() extracts the minor number from a device number. RETURN VALUES The minor number. CONTEXT getminor() can be called from user or interrupt context. EXAMPLES See the getmajor(9F) manual page for an example of how to use getminor(). SEE ALSO getmajor(9F), makedevice(9F) Writing Device Drivers WARNINGS No validity checking is performed. If dev is invalid, an invalid number is returned. SunOS 5.7 Last change: 11 Apr 1991 1 onl50t% onl50t% vi /usr/include/sys/systm.h : 100 timeout_id_t timeout(void (*)(void *), void *, clock_t); 101 timeout_id_t realtime_timeout(void (*)(void *), void *, clock_t); 102 clock_t untimeout(timeout_id_t); : onl50t% 参考のために Solaris2.6 での timeout(9F) を man でチェックする。 onlsun1[85]% man -s 9f timeout マニュアルを清書中です。しばらくお待ちください... 終了 Kernel Functions for Drivers timeout(9F) NAME timeout - execute a function after a specified length of time SYNOPSIS #include #include int timeout(void (*func )(), caddr_t arg, clock_t ticks); INTERFACE LEVEL Architecture independent level 1 (DDI/DKI). ARGUMENTS func Kernel function to invoke when the time increment expires. arg Argument to the function. ticks Number of clock ticks to wait before the function is called. DESCRIPTION The timeout() function schedules the specified function to be called after a specified time interval. The exact time interval over which the timeout takes effect cannot be guaranteed, but the value given is a close approximation. The function called by timeout() must adhere to the same restrictions as a driver soft interrupt handler. The timeout() function returns an identifier that may be passed to the untimeout(9F) function to cancel a pending request. timeout() can be called from user or interrupt context. The function called by timeout() is run in interrupt context and must not sleep or call other functions which may sleep. RETURN VALUES Under normal conditions, timeout() returns an integer timeout identifier not equal to zero. If, however, the timeout table is full, the system will panic with the fol- lowing panic message: PANIC: Timeout table overflow CONTEXT timeout() can be called from user or interrupt context. SunOS 5.6 Last change: 19 Sep 1996 1 Kernel Functions for Drivers timeout(9F) EXAMPLES In the following example, the device driver has issued an IO request and is waiting for the device to respond. If the device does not respond within 5 seconds, the device driver will print out an error message to the console. static void xxtimeout_handler(caddr_t arg) { struct xxstate *xsp = (struct xxstate *)arg; mutex_enter(&xsp->lock); cv_signal(&xsp->cv); xsp->flags |= TIMED_OUT; mutex_exit(&xsp->lock); xsp->timeout_id = 0; } static u_int xxintr(caddr_t arg) { struct xxstate *xsp = (struct xxstate *)arg; . . . mutex_enter(&xsp->lock); /* Service interrupt */ cv_signal(&xsp->cv); mutex_exit(&xsp->lock); if (xsp->timeout_id != 0) { (void) untimeout(xsp->timeout_id); xsp->timeout_id = 0; } return(DDI_INTR_CLAIMED); } static void xxcheckcond(struct xxstate *xsp) { . . . xsp->timeout_id = timeout(xxtimeout_handler, (caddr_t)xsp, 5 * drv_usectohz(1000000)); mutex_enter(&xsp->lock); while (/* Waiting for interrupt or timeout*/) SunOS 5.6 Last change: 19 Sep 1996 2 Kernel Functions for Drivers timeout(9F) cv_wait(&xsp->cv, &xsp->lock); if (xsp->flags & TIMED_OUT) cmn_err(CE_WARN, "Device not responding"); . . . mutex_exit(&xsp->lock); . . . } SEE ALSO bufcall(9F), delay(9F), untimeout(9F) Writing Device Drivers SunOS 5.6 Last change: 19 Sep 1996 3 onlsun1[86]% 参考のために Solaris2.6 での getminor(9F) を man でチェックする。 onlsun1[87]% man -s 9f getminor マニュアルを清書中です。しばらくお待ちください... 終了 Kernel Functions for Drivers getminor(9F) NAME getminor - get minor device number SYNOPSIS #include #include #include minor_t getminor(dev_t dev); INTERFACE LEVEL Architecture independent level 1 (DDI/DKI). ARGUMENTS dev Device number. DESCRIPTION getminor() extracts the minor number from a device number. RETURN VALUES%) The minor number. CONTEXT getminor() can be called from user or interrupt context. EXAMPLE See the getmajor(9F) manual page for an example of how to use getminor. SEE ALSO getmajor(9F), makedevice(9F) Writing Device Drivers WARNINGS No validity checking is performed. If dev is invalid, an invalid number is returned. SunOS 5.6 Last change: 11 Apr 1991 1 onlsun1[88]% man によると timeout()のタイプおよびtimeout()で使用する引数の タイプが Solaris2.6 と Solaris7 とでは異なっている。 Solris7 timeout_id_t timeout(void (* func)(void *), void *arg, clock_t ticks); Solris2.6 int timeout(void (*func )(), caddr_t arg, clock_t ticks); cc.cファイルに対する処置. (1). cc->timeout_id のタイプを "int" から "timeout_id_t" へ変更。 (2). cc_timeout エントリーポイント宣言文の引数のタイプ "caddr_t" を削除。 (3). cc_timeout() ルーチンの引数のタイプ "caddr_t"を削除。 (4). timeout()カーネル関数呼び出し時に2番目の引数のタイプを "caddr_t" としていたのを削除。 以上の変更をしてコンパイルし直してみる。 (4-3-3). cc.c を修正 onl50t% vi cc.c : 102 /* E.Inoue 103 int timeout_id; 104 end */ 105 timeout_id_t timeout_id; : 149 /* E.Inoue 150 static void cc_timeout(caddr_t unit); 151 end */ 152 static void cc_timeout(void *unit); : 874 static void 875 cc_timeout(void *unit) 876 /* E.Inoue 877 cc_timeout(caddr_t unit) 878 end */ 879 { 880 /* register struct cc_device *cc = &ccdevice[0]; */ 881 register struct cc_device *cc; 882 883 /* cc = ddi_get_soft_state(cc_state,unit); */ 884 /* E.Inoue 885 cc = ddi_get_soft_state(cc_state,(int)*unit); 886 end */ 887 cc = ddi_get_soft_state(cc_state,(int)unit); : 967 static int 968 cc_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cred_p, int *rval_p) 969 /* E.Inoue 970 cc_ioctl(dev_t dev, int cmd, int arg, int flag, cred_t *cred_p, int *rva l_p) 971 end */ 972 { : 1038 /* E.Inoue 1039 cc->timeout_id = timeout(cc_timeout, (caddr_t)&unit, cc->data1 * hz); 1040 end */ 1041 cc->timeout_id = timeout(cc_timeout, (void *)unit, cc->data1 * hz ); : 2687 static int cc_strategy(struct buf *bp) 2688 { 2689 /* register struct cc_device *cc = &ccdevice[0]; */ 2690 register struct cc_device *cc; : 2823 /* E.Inoue 2824 cc->timeout_id = timeout(cc_timeout, (caddr_t)&unit, CC_TIMEOUT_DMA * hz); 2825 end */ 2826 cc->timeout_id = timeout(cc_timeout, (void *)unit, CC_TIMEOUT_DMA * hz); : "cc.c" 2948 lines, 75563 characters onl50t% (4-3-4). cc.cファイルを再コンパイル onl50t% pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t% make clean \rm -f cc *.o libcamac.a cam1 cam2 cam3 *~ core onl50t% make ./script/cc_build.sh [Building for sun4u] rm -f cc.o cc -O -c camlib.c -o camlib.o -I. cc -O -c forlib.c -o forlib.o -I. rm -f libcamac.a ar rcv libcamac.a camlib.o forlib.o a - camlib.o a - forlib.o ar: writing libcamac.a cc -O cam1.c -o cam1 -I. -L. -lcamac f77 -fast -O3 -u cam2.f -o cam2 -I. -L. -lcamac cam2.f: MAIN: cc -O cam3.c -o cam3 -I. -L. -lcamac onl50t% ok. コンパイル時の warning は出なくなった。 onl8v1、Solaris7 で ccドライバをコンパイルした時に問題になった spln() および splx()関数は不必要なのでここでコメントアウトしておく。 参考. spln() 関数は CPUレベルを n に設定する。 splx(s) 関数は CPUレベルを直前に格納してレベルに復元する。 onl50t% vi cc.c : 970 static int 971 cc_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cred_p, int *rval_p) 972 /* E.Inoue 973 cc_ioctl(dev_t dev, int cmd, int arg, int flag, cred_t *cred_p, int *rva l_p) 974 end */ 975 { 976 /* register struct cc_device *cc = &ccdevice[0]; */ 977 register struct cc_device *cc; : 1025 /* lock out clock */ 1026 /* by E.Inoue 1027 s = spl5(); <--- すでにコメントアウトしてある。 1028 */ : 1057 /* by E.Inoue 1058 splx(s); <--- すでにコメントアウトしてある。 1059 */ : 2046 int cc_waitint(cc) 2047 struct cc_device *cc; 2048 { : 2055 /* lock out clock */ 2056 /* E.Inoue 2057 s = spl5(); <--- コメントアウトする。 2058 end */ : 2076 /* E.Inoue 2077 splx(s); <--- コメントアウトする。 2078 end */ : 2099 /* lock out clock */ 2100 /* E.Inoue 2101 s = spl5(); <--- コメントアウトする。 2102 end */ : 2121 /* E.Inoue 2122 splx(s); <--- コメントアウトする。 2123 end */ : "cc.c" 2956 lines, 75639 characters onl50t% (4-3-5). cc.cファイルを再コンパイル onl50t% pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t% make clean \rm -f cc *.o libcamac.a cam1 cam2 cam3 *~ core onl50t% make ./script/cc_build.sh [Building for sun4u] rm -f cc.o cc -O -c camlib.c -o camlib.o -I. cc -O -c forlib.c -o forlib.o -I. rm -f libcamac.a ar rcv libcamac.a camlib.o forlib.o a - camlib.o a - forlib.o ar: writing libcamac.a cc -O cam1.c -o cam1 -I. -L. -lcamac f77 -fast -O3 -u cam2.f -o cam2 -I. -L. -lcamac cam2.f: MAIN: cc -O cam3.c -o cam3 -I. -L. -lcamac onl50t% ok. 正常にコンパイルできた。 (5). ccドライバのインストール (5-1). "make install" をやる onl50t# ls -l /usr/local /usr/local: No such file or directory onl50t# df -k Filesystem kbytes used avail capacity Mounted on /proc 0 0 0 0% /proc /dev/dsk/c0t3d0s0 109527 54975 43600 56% / /dev/dsk/c0t3d0s6 941279 617358 267445 70% /usr fd 0 0 0 0% /dev/fd /dev/dsk/c0t3d0s1 29583 6370 20255 24% /var /dev/dsk/c0t3d0s7 7436613 38157 7324090 1% /export/home swap 326328 8 326320 1% /tmp /dev/dsk/c0t2d0s0 905860 399300 452209 47% /mnt /dev/dsk/c0t2d0s6 4345356 546572 3755331 13% /mnt1 onl50t# ls -l /usr total 146 drwxrwxr-x 2 root bin 1024 Nov 18 14:55 4lib lrwxrwxrwx 1 root root 5 Nov 18 14:38 5bin -> ./bin lrwxrwxrwx 1 root root 9 Nov 18 14:30 X -> ./openwin lrwxrwxrwx 1 root root 10 Nov 18 14:42 adm -> ../var/adm drwx------ 8 root bin 512 Nov 18 14:37 aset drwxrwxr-x 4 root bin 7680 Nov 18 14:58 bin drwxr-xr-x 4 bin bin 512 Nov 18 14:33 ccs drwxrwxr-x 10 root bin 512 Nov 18 14:52 demo lrwxrwxrwx 1 root root 16 Nov 18 14:35 dict -> ./share/lib/dict drwxrwxr-x 9 root bin 512 Nov 18 14:41 dt drwxrwxr-x 2 root bin 512 Nov 18 14:32 games drwxrwxr-x 21 root bin 3584 Nov 18 14:57 include lrwxrwxrwx 1 root other 7 Nov 18 14:42 java -> java1.1 drwxrwxr-x 6 root bin 512 Nov 18 14:47 java1.1 drwxrwxr-x 7 root bin 512 Nov 18 14:47 java1.2 drwxr-xr-x 9 root sys 512 Nov 18 14:32 kernel drwxrwxr-x 2 bin bin 512 Nov 18 14:33 kvm drwxrwxr-x 44 root bin 10240 Nov 24 10:54 lib drwx------ 2 root root 8192 Nov 18 14:30 lost+found lrwxrwxrwx 1 root root 11 Nov 18 14:32 mail -> ../var/mail lrwxrwxrwx 1 root root 11 Nov 18 14:39 man -> ./share/man drwxrwxr-x 4 root sys 512 Nov 18 14:32 net lrwxrwxrwx 1 root root 11 Nov 18 14:32 news -> ../var/news drwxr-xr-x 5 bin bin 512 Nov 18 14:42 oasys drwxrwxr-x 2 root bin 512 Nov 18 14:32 old drwxrwxr-x 8 root bin 512 Nov 18 14:38 openwin drwxr-xr-x 8 root sys 1024 Nov 18 15:02 platform lrwxrwxrwx 1 root root 15 Nov 18 14:32 preserve -> ../var/preserve drwxr-xr-x 4 bin bin 512 Nov 18 14:35 proc lrwxrwxrwx 1 root root 15 Nov 18 14:32 pub -> ./share/lib/pub drwxr-xr-x 5 bin bin 512 Nov 18 14:33 sadm drwxrwxr-x 6 root bin 5120 Nov 18 15:04 sbin drwxr-xr-x 6 root sys 512 Nov 18 14:32 share drwxr-xr-x 6 root bin 512 Nov 18 14:55 snadm lrwxrwxrwx 1 root root 12 Nov 18 14:32 spool -> ../var/spool lrwxrwxrwx 1 root root 11 Nov 18 14:32 src -> ./share/src lrwxrwxrwx 1 root root 10 Nov 18 14:32 tmp -> ../var/tmp drwxrwxr-x 4 root bin 2048 Nov 18 14:56 ucb drwxr-xr-x 4 bin bin 512 Nov 18 14:56 ucbinclude drwxr-xr-x 3 bin bin 1024 Nov 18 14:56 ucblib drwxr-xr-x 7 bin bin 512 Nov 18 14:42 vmsys drwxr-xr-x 5 root bin 512 Nov 18 14:59 xpg4 onl50t# mkdir /usr/local onl50t# pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t# ls -l total 654 -rw-r--r-- 1 inoue kek 2041 Jul 19 15:30 Makefile -rw-r--r-- 1 inoue kek 3624 Jul 26 14:10 README -rwxr-xr-x 1 inoue kek 14252 Nov 26 11:26 cam1 -rw-r--r-- 1 inoue kek 1170 Jul 16 10:47 cam1.c -rwxr-xr-x 1 inoue kek 104924 Nov 26 11:26 cam2 -rw-r--r-- 1 inoue kek 2295 Jul 16 10:47 cam2.f -rwxr-xr-x 1 inoue kek 14648 Nov 26 11:26 cam3 -rw-r--r-- 1 inoue kek 2055 Jul 16 10:47 cam3.c -rw-r--r-- 1 inoue kek 9740 Jul 16 10:47 camlib.c -rw-r--r-- 1 inoue kek 1415 Jul 16 10:47 camlib.h -rw-r--r-- 1 inoue kek 9640 Nov 26 11:26 camlib.o -rw-r--r-- 1 inoue kek 41632 Nov 26 11:26 cc -rw-r--r-- 1 inoue kek 75639 Nov 25 16:47 cc.c -rw-r--r-- 1 inoue kek 288 Jul 16 10:47 cc.conf -rw-r--r-- 1 inoue kek 2931 Jul 26 16:45 cc.h -rw-r--r-- 1 inoue kek 2288 Jul 16 10:47 cc_common.h -rw-r--r-- 1 inoue kek 876 Jul 16 10:47 cc_config.h -rw-r--r-- 1 inoue kek 3289 Jul 16 10:47 forlib.c -rw-r--r-- 1 inoue kek 3492 Nov 26 11:26 forlib.o -rw-r--r-- 1 inoue kek 4058 Jul 16 10:47 k2917.h -rw-r--r-- 1 inoue kek 13992 Nov 26 11:26 libcamac.a drwxr-xr-x 2 inoue kek 512 Jul 16 14:59 script onl50t# onl50t# make install /usr/ucb/install -d /usr/local/vme/camac/include /usr/ucb/install -d /usr/local/vme/camac/lib /usr/ucb/install -m 644 camlib.h cc_config.h cc_common.h cc.h \ k2917.h /usr/local/vme/camac/include /usr/ucb/install -m 644 libcamac.a /usr/local/vme/camac/lib onl50t# ls -lLR /usr/local /usr/local: total 2 drwxr-xr-x 3 root other 512 Nov 26 11:37 vme /usr/local/vme: total 2 drwxr-xr-x 4 root other 512 Nov 26 11:37 camac /usr/local/vme/camac: total 4 drwxr-xr-x 2 root other 512 Nov 26 11:37 include drwxr-xr-x 2 root other 512 Nov 26 11:37 lib /usr/local/vme/camac/include: total 26 -rw-r--r-- 1 root staff 1415 Nov 26 11:37 camlib.h -rw-r--r-- 1 root staff 2931 Nov 26 11:37 cc.h -rw-r--r-- 1 root staff 2288 Nov 26 11:37 cc_common.h -rw-r--r-- 1 root staff 876 Nov 26 11:37 cc_config.h -rw-r--r-- 1 root staff 4058 Nov 26 11:37 k2917.h /usr/local/vme/camac/lib: total 28 -rw-r--r-- 1 root staff 13992 Nov 26 11:37 libcamac.a onl50t# 続いて、ccドライバをロードして camac の実行テストを行う。 (3-4). ここで、システムを立ちあげ直す onl50t# pwd /export/home/onl50t/inoue/CAMAC/FORCE-50T-sol2.6 onl50t# make load ./script/cc_load.sh [Installing CAMAC device driver] [Adding CAMAC device driver to system] drvconfig: Driver (cc) failed to attach Warning: Driver (cc) successfully added to system but failed to attach [Configuring CAMAC device driver] [Making CAMAC device files] sun4u 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] drvconfig: Driver (cc) failed to attach Warning: Driver (cc) successfully added to system but failed to attach [Configuring CAMAC device driver] [Making CAMAC device files] sun4u onl50t# # /usr/sbin/shutdown -i0 -g0 Shutdown started. Fri Nov 26 14:11:58 JST 1999 Do you want to continue? (y or n): y Changing to init state 0 - please wait Broadcast Message from root (console) on onl50t Fri Nov 26 14:11:59... THE SYSTEM onl50t IS BEING SHUT DOWN NOW ! ! ! Log off now or risk your files being damaged # INIT: New run level: 0 The system is coming down. Please wait. System services are now being stopped. Print services stopped. syslogd: going down on signal 15 The system is down. INIT: failed write of utmpx entry:"s0" INIT: failed write of utmpx entry:"fw" syncing file systems... done Program terminated ok ok boot -r Resetting ... screen not found. Can't open input device. Keyboard not present. Using ttya for input and output. FORCE,CPU-50(UltraSPARC-IIi 300MHz), No Keyboard OpenBoot 3.10.8, 256 MB memory installed, Serial #9204337. Ethernet address 0:80:42:10:2:74, Host ID: 808c7271. Executing last command: boot -r Boot device: /pci@1f,0/scsi@4/disk@3,0:a File and args: -r SunOS Release 5.7 Version Generic_106541-06 64-bit [UNIX(R) System V Release 4.0 ] Copyright (c) 1983-1999, Sun Microsystems, Inc. configuring network interfaces: hme0 hme1. Hostname: onl50t Configuring the /devices directory Configuring the /dev directory Configuring the /dev directory (compatibility devices) The system is coming up. Please wait. checking ufs filesystems /dev/rdsk/c0t3d0s7: is clean. NIS domainname is kek.jp starting rpc services: rpcbind keyserv done. Setting netmask of hme0 to 255.255.248.0 SUNW,hme1: Link Down - cable problem? Setting default interface for multicast: add net 224.0.0.0: gateway onl50t syslog service starting. Print services started. volume management starting. The system is ready. onl50t console login: NG. /devices directory に ccファイルが作られたというメッセージが 出力されない。 /var/messagesファイルをチェック。 onl50t[24]% vi /var/adm/messages : Nov 26 14:14:57 onl50t unix: vmefdma0 at vme0: space 0xad,0 and space 0xbd,0 and space 0x8d,0 and vme16d16,0x0 and vme24d16,0x0 and vme32d16,0x0 and vme16d32,0x 0 and vme24d32,0x0 and vme32d32,0x0 and space 0x3f,0 and space 0x3c,0 and space 0xf,0 and space 0xc,0 and space 0x20,0 Nov 26 14:14:57 onl50t unix: vmefdma0 is /pci@1f,0/vme@5/vmefdma@ad,0 Nov 26 14:14:57 onl50t unix: vmedvma0 at vme0 Nov 26 14:14:57 onl50t unix: vmedvma0 is /pci@1f,0/vme@5/vmedvma Nov 26 14:14:57 onl50t unix: vmectl0 at vme0 Nov 26 14:14:57 onl50t unix: vmectl0 is /pci@1f,0/vme@5/vmectl Nov 26 14:14:57 onl50t unix: NOTICE: cc: 64-bit driver module not found : onl50t[25]% 64-bit対応の ccドライバが見つからなかったと言っている。 現在の ccドライバを64-bit対応にするにはどうすればよいか。 チェック。 --- (6). セクション (6-1). サブセクション (6-1-1). サブサブセクション