  Debugging ioc$write_pci_config crash? 
 The Question is:
 
I have code that accesses PCI configuration registers but not in a device
driver. I use the sys$cmkrnl facility. About every 20-50 times I run the
code I crash the system. The crash occurs code around the OpenVMS
ioc$write_pci_config entry.
I suspect that the problem may be related to the fact that I don't raise IPL
in my cmkrnl routine. I have a uni-processor Alpha Server 1000.
Can you advise as to how to pursue a solution to this problem?
 
 The Answer is:
The Wizard finds it extremely difficult to debug system crashes without crash
dumps.  The first suggestion is to examine the crash dump and see what, exactly,
is causing the crash.  You will need the listings CD that corresponds to the
version of OpenVMS you're running.
 
Examination of the IOC$WRITE_PCI_CONFIG routine shows that it acquires the
MCHECK spinlock before calling the platform-specific routine that actually
writes PCI configuration registers.  When the MCHECK spinlock is acquired, IPL
is raised to 31 (decimal).
 
Device drivers generally call routines like IOC$WRITE_PCI_CONFIG from either
fork IPL (usually 8, holding the SPL$_IOLOCK8 spinlock) or device IPL (22,
holding the device lock).  You are probably calling from IPL 0, from process
address space.
 
If your crash is caused by a pagefault with IPL too high, then you must (at
minimum) lock the relevant code and linkage section into memory before calling
your kernel-mode routine.  If indeed your problem is related to IPL, this is the
most likely cause.
 
If your crash is caused by an invalid exception or similar, then you must
examine the crash dump to determine what went wrong.
 
If you are still interested in how to raise IPL, see the LOCK/UNLOCK macros (in
LIB.MLB, or [LIB]SYSMAR.MAR if you have the listings) for Macro32 programs, or
the sys_lock and sys_unlock macros (in SYS$LIB_C.TLB, or [LIB_H]VMS_MACROS.H)
for C programs.  It would help to acquire a copy of the "Writing OpenVMS Alpha
Device Drivers in C" book, too.
 
Without more information, this is about the best the Wizard can do.
