Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!lll-lcc!ames!ucbcad!ucbvax!CUVMA.BITNET!POSTMAST
From: POSTMAST@CUVMA.BITNET
Newsgroups: comp.os.vms
Subject: Re: Returned Network Mail; 
Message-ID: <8707170456.AA14479@ucbvax.Berkeley.EDU>
Date: Mon, 13-Jul-87 08:27:00 EDT
Article-I.D.: ucbvax.8707170456.AA14479
Posted: Mon Jul 13 08:27:00 1987
Date-Received: Sat, 18-Jul-87 11:23:07 EDT
Sender: daemon@ucbvax.BERKELEY.EDU
Distribution: world
Organization: The ARPA Internet
Lines: 83

Received: by CUVMA (Mailer X1.24) id 3884; Mon, 13 Jul 87 06:53:35 EDT
Received: from CUCCVX(POSTMAST) by CUVMA (Mailer X1.24) id 3883;
          Mon, 13 Jul 87 06:53:34 EDT
Date:     Mon, 13-JUL-1987 06:50 EST
From:     
Subject:  Returned Network Mail
To:       MAILER@CUVMA
ReSent-Date: Mon, 13 Jul 87 06:53:34 EDT
ReSent-From: Network Mailer 
ReSent-To: POSTMAST@CUVMA

Your mail is being returned to you.
Reason for return is:
%MAIL-E-NOSUCHUSR, no such user MRGNAIR at node CUCCVX
Returned mail follows:
------------------------------
Received: From CUVMA(MAILER) by CUCCVX with RSCS id 3878
          for MRGNAIR@CUCCVX; Mon, 13-JUL-1987 06:50 EST
Received: from CUVMA.COLUMBIA.EDU by CUVMA.COLUMBIA.EDU (Mailer X1.24) with
 BSMTP id 3877; Mon, 13 Jul 87 06:53:17 EDT
Received: from CU20B.COLUMBIA.EDU by CUVMA.COLUMBIA.EDU on 07/13/87 at 06:53:17
 EDT
Received: from KL.SRI.Com by CU20B.COLUMBIA.EDU with TCP; Mon 13 Jul 87
 06:53:51-EDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Sat 11 Jul 87
 13:56:44-PDT
Received: by ucbvax.Berkeley.EDU (5.58/1.27)
    id AA11219; Sat, 11 Jul 87 13:36:33 PDT
Received: from USENET by ucbvax.Berkeley.EDU with netnews
    for info-vax@kl.sri.com (info-vax@kl.sri.com)
    (contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 11 Jul 87 13:36:33 GMT
From: ece-csc!ncrcae!ncr-sd!hp-sdd!ucsdhub!jack!man!crash!jeh@mcnc.org  (Jamie
 Hanrahan)
Organization: Crash TS, El Cajon, CA
Subject: Re: Help with a Kernal mode macro program
Message-Id: <1369@crash.CTS.COM>
References: <870708122836.001@sitvxb>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <870708122836.001@sitvxb> dstevens@sitvxb (David L Stevens) writes:
>
> ...the MOVC3
> statement in the Kernal Mode code, crashes the system every time I run it.

I replied to this via mail, but since then several not-quite-correct
responses have been posted as news, so here goes...

The folks who point out that MOVC3 clobbers R0-R5 are correct.  (And,
by the bye, LOC3 hits R0-R3.)  BUT, simply mentioning R2 through R5
in the kernel (not "kernal", please!) mode routine's entry point mask
is not sufficient to avoid the crashes.

The code shown is calling the VMS system routines EXE$IOLOCKR (lock
I/O data base via mutex for read) and EXE$IOUNLOCK (unlock I/O data
base mutex).  These routines require R4 to point to the current
process's PCB.  The call to IOLOCKR works because the $CMKRNL service
calls the target routine with R4 pointing to the PCB, but after the
MOVC3, R4 contains 0.  The mutex-handling routines check to ensure
that R4 is pointing to a valid PCB and bugcheck if it doesn't; hence
the crash.

R4 can be pushed at the beginning of the routine and popped just
before the call to UNLOCK, or pushed and popped around the MOVC3s.
Personally, I would put the following statement just before the calls
to both EXE$IOUNLOCK and EXE$IOLOCKR:

    MOVL    G^SCH$GL_CURPCB, R4     ; get addr of cur proc PCB

Sure, it's not necessary for IOLOCKR because of the context that
this code happens to run in... but that might change someday.
The MOVL makes the code less context-dependent, and also more
understandable.

One other thing:  All references to system-space labels
(EXE$IOLOCKR, EXE$UNLOCK) should be preceded with the G^ prefix
to ensure that they're position independent.

DISCLAIMER:  Names of system-space labels in the above were typed
from memory.  The suffixes are correct but the prefixes (EXE$,
SCH$, etc.) may be mixed up... it's late/early/not good.
------ End of forwarded mail by POSTMAST@CUVMA.