ESA/390 TRAP instruction 
Author Message
 ESA/390 TRAP instruction

Does anyone know how to use the TRAP instruction? Specifically how do you
set the address of the trap-program in the Trap Control Block so that the
TRAP instruction can branch to it?

Thanks.



Mon, 03 Mar 2003 03:00:00 GMT  
 ESA/390 TRAP instruction
Build your Trap Control Block with the address of the routine in it. Stuff
the address of the Trap Control Block in the DUCT. It took me a while to
get the whole thing working, but I finally did.
--
Dave Kienow



Quote:
> Does anyone know how to use the TRAP instruction? Specifically how do you
> set the address of the trap-program in the Trap Control Block so that the
> TRAP instruction can branch to it?

> Thanks.



Mon, 03 Mar 2003 03:00:00 GMT  
 ESA/390 TRAP instruction
How are you using TRAP2/TRAP4?



Quote:
> Build your Trap Control Block with the address of the routine in it.
Stuff
> the address of the Trap Control Block in the DUCT. It took me a while
to
> get the whole thing working, but I finally did.
> --
> Dave Kienow



> > Does anyone know how to use the TRAP instruction? Specifically how
do you
> > set the address of the trap-program in the Trap Control Block so
that the
> > TRAP instruction can branch to it?

> > Thanks.

--
... and this time, I mean it!

Sent via Deja.com http://www.deja.com/
Before you buy.



Mon, 03 Mar 2003 03:00:00 GMT  
 ESA/390 TRAP instruction
I was planning on using TRAP2 to replace our current method of setting
breakpoints (x'00') in our own de{*filter*}. Creating an abend in which our
error recovery picks up is not all that bad until I introduced conditional
breakpoints which might cause 10,000 or more abends until the appropriate
condition occurs. Development in our de{*filter*} is done in my "free" time
which I haven't had much of lately.
--
Dave Kienow



Quote:
> How are you using TRAP2/TRAP4?



> > Build your Trap Control Block with the address of the routine in it.
> Stuff
> > the address of the Trap Control Block in the DUCT. It took me a while
> to
> > get the whole thing working, but I finally did.
> > --
> > Dave Kienow



> > > Does anyone know how to use the TRAP instruction? Specifically how
> do you
> > > set the address of the trap-program in the Trap Control Block so
> that the
> > > TRAP instruction can branch to it?

> > > Thanks.

> --
> ... and this time, I mean it!

> Sent via Deja.com http://www.*-*-*.com/
> Before you buy.



Tue, 04 Mar 2003 03:00:00 GMT  
 ESA/390 TRAP instruction

Quote:
>How are you using TRAP2/TRAP4?



>> Build your Trap Control Block with the address of the routine in it.
>Stuff
>> the address of the Trap Control Block in the DUCT. It took me a while
>to
>> get the whole thing working, but I finally did.
>> --
>> Dave Kienow



>> > Does anyone know how to use the TRAP instruction? Specifically how
>do you
>> > set the address of the trap-program in the Trap Control Block so
>that the
>> > TRAP instruction can branch to it?

>> > Thanks.

>--
>.... and this time, I mean it!

>Sent via Deja.com http://www.deja.com/
>Before you buy.

(I haven't seen the original post yet on my mail server.)

I assume you're using RP to return from the trap program?  The RP
instruction is a little strange in that it uses a parameter list
that follows the instruction in the instruction address space.

Can you say what your application is for using the TRAPx
instructions?  I'm probably one of the first people who ever used
the TRAPx/RP instructions, so it's interesting to hear that other
people are using them.

Dave

P.S. Standard Disclaimer: I work for them, but I don't speak for them.



Tue, 04 Mar 2003 03:00:00 GMT  
 ESA/390 TRAP instruction
I have a program (set of PC routines) that run as a started task for
managing the TRAP2/TRAP4 interface. Basically, you call a macro
interface which sets up the DUCT, the trap manager, etc. (similar to
setting an ESTAEX). When the trap instruction hits, the list of trap
manangers is polled from newest to oldest.

The user handler routine receives control with:

R0==C'TRAP'
R1==Address of fake SDWA
R2==User parameter pointer
AR2==ALET of user parameter
R3-R12: Nothing of interest.
R13==Pointer to standard register save area.
R14==Return address
R15==Entry point address of user handler.

Upon return, if R15==F'-4', then the user handler didn't
recognize the trap as its own. The trap manager polls the
next oldest user handler. R15==F'0' means "percolate", the
user handler recognized its own trap but wants to quit
(a user abend is issued to force percolation). R15==F'4'
means the user handler recognized the trap as its own and
wants the trap manager to retry according to the settings
in the fake SDWA. You can set the retry registers, retry
address, etc. If the user handler is authorized (defined
by a supervisor state or system key routine), then it can
also modify most of the retry PSW bits. If the LOCAL, CML,
or CMS locks were held upon entry to the trap manager, the
locks are freed with bits set in the SDWA. Upon retry, the
locks are reacquired (subject to the SDWA controls). Thus,
you can single-step locally locked code.

The trap manager observes the rules for authorization and
cross memory mode (it even works for SRB mode).

This API works well, is very fast and secure (mostly), and
at least one commercial de{*filter*} for OS/390 already supports
it.

There are some security caveats, because of the hardware
design flaw of TRAP2/TRAP4. That is, the home space must
be trusted (no rogue programs, trojan horses, etc.). If you
are in a development environment, then this is not an issue.


Quote:


writes:
> >How are you using TRAP2/TRAP4?



> >> Build your Trap Control Block with the address of the routine in
it.
> >Stuff
> >> the address of the Trap Control Block in the DUCT. It took me a
while
> >to
> >> get the whole thing working, but I finally did.
> >> --
> >> Dave Kienow



> >> > Does anyone know how to use the TRAP instruction? Specifically
how
> >do you
> >> > set the address of the trap-program in the Trap Control Block so
> >that the
> >> > TRAP instruction can branch to it?

> >> > Thanks.

> >--
> >.... and this time, I mean it!

> >Sent via Deja.com http://www.*-*-*.com/
> >Before you buy.

> (I haven't seen the original post yet on my mail server.)

> I assume you're using RP to return from the trap program?  The RP
> instruction is a little strange in that it uses a parameter list
> that follows the instruction in the instruction address space.

> Can you say what your application is for using the TRAPx
> instructions?  I'm probably one of the first people who ever used
> the TRAPx/RP instructions, so it's interesting to hear that other
> people are using them.

> Dave

> P.S. Standard Disclaimer: I work for them, but I don't speak for them.

--
... and this time, I mean it!

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Thu, 06 Mar 2003 03:00:00 GMT  
 ESA/390 TRAP instruction
How does one place the address of the Trap Control Block in the DUCT? Are there
mappings for the DUCT and the Trap Control Block? THNX.
Quote:


> >How are you using TRAP2/TRAP4?



> >> Build your Trap Control Block with the address of the routine in it.
> >Stuff
> >> the address of the Trap Control Block in the DUCT. It took me a while
> >to
> >> get the whole thing working, but I finally did.
> >> --
> >> Dave Kienow



> >> > Does anyone know how to use the TRAP instruction? Specifically how
> >do you
> >> > set the address of the trap-program in the Trap Control Block so
> >that the
> >> > TRAP instruction can branch to it?

> >> > Thanks.

> >--
> >.... and this time, I mean it!

> >Sent via Deja.com http://www.deja.com/
> >Before you buy.

> (I haven't seen the original post yet on my mail server.)

> I assume you're using RP to return from the trap program?  The RP
> instruction is a little strange in that it uses a parameter list
> that follows the instruction in the instruction address space.

> Can you say what your application is for using the TRAPx
> instructions?  I'm probably one of the first people who ever used
> the TRAPx/RP instructions, so it's interesting to hear that other
> people are using them.

> Dave

> P.S. Standard Disclaimer: I work for them, but I don't speak for them.



Sat, 08 Mar 2003 03:00:00 GMT  
 ESA/390 TRAP instruction

Quote:


>> >How are you using TRAP2/TRAP4?



>> >> Build your Trap Control Block with the address of the routine in it.
>> >Stuff
>> >> the address of the Trap Control Block in the DUCT. It took me a while
>> >to
>> >> get the whole thing working, but I finally did.
>> >> --
>> >> Dave Kienow



>> >> > Does anyone know how to use the TRAP instruction? Specifically how
>> >do you
>> >> > set the address of the trap-program in the Trap Control Block so
>> >that the
>> >> > TRAP instruction can branch to it?

>> >> > Thanks.

>> >--
>> >.... and this time, I mean it!

>> >Sent via Deja.com http://www.deja.com/
>> >Before you buy.

>> (I haven't seen the original post yet on my mail server.)

>> I assume you're using RP to return from the trap program?  The RP
>> instruction is a little strange in that it uses a parameter list
>> that follows the instruction in the instruction address space.

>> Can you say what your application is for using the TRAPx
>> instructions?  I'm probably one of the first people who ever used
>> the TRAPx/RP instructions, so it's interesting to hear that other
>> people are using them.

>> Dave

>> P.S. Standard Disclaimer: I work for them, but I don't speak for them.

>How does one place the address of the Trap Control Block in the DUCT? Are there
>mappings for the DUCT and the Trap Control Block? THNX.

We used the ST instruction....Oh, wait....

The virtual address of the DUCT is in the Secondary Task Control
Block (STCB), mapped by the macro IHASTCB, which is pointed to by
the TCBSTCB field of the TCB.  You'll have to check the product
literature to be sure that it's acceptable to use that as an
interface, though, and if you'll need any locks to access those
fields.  And, since the DUCT is in protected storage, you'll need to
be authorized to be allowed to update it (Actually, I think the DUCT
is in fetch protected storage, so you'll have to be authorized to
even see it.).

I'm not aware of any mapping macros for the TRCB (Trap Control
Block), or the DUCT, although when we were coding the code that used
it, it was very early in the history of the TRCB, so it's possible
that mapping macros may have been written since then.

Dave

P.S. Standard Disclaimer: I work for them, but I don't speak for them.



Sun, 09 Mar 2003 03:00:00 GMT  
 ESA/390 TRAP instruction
My trap manager started task handles all of that stuff through
a callable API. The application uses a macro interface to
add/remove handler routines. Handlers are polled from newest
to oldest, subject to authority rules, each time a TRAP2 or
TRAP4 is executed by the unit of work (task or SRB). It works
in task mode, SRB mode, cross memory mode, locally locked,
with or without FRR.

At least one commercial OS/390 de{*filter*} supports the interface.
It dramatically improves debugging performance by not going
through RTM abend processing to call an ESTAE-type exit.

When the handler is called, it receives:
R0==C'TRAP'
R1==Pointer to a fake SDWA in the primary space (31-bit storage).
AR1==F'0'
R2==First word of user handler parameter.
AR2==Second word of user handler parameter.
R3 thru R12: Nothing
R13==Pointer to standard 72-byte register save area in primary space.
R14==Return address.
R15==Entry point address of user handler.

If you are currently using an ESTAE-type exit to debug code,
you can modify the exit to recognize R0==C'TRAP' as
process the "fake abend" appropriately. You can use your
same code to debug via abend or trap. Rather cool?

If the handler was defined by a system key routine, then
the handler receives control in key zero. If the handler
was defined by a supervisor state routine, then the
handler receives control in supervisor state. Otherwise,
problem state. The cross memory mode is the same as when
the TRAP was executed. Only handlers that have equal or
greater authority than the trapped program can get control.
Handlers with less authority are skipped in the poll.

The handler must set a return code in SDWARCDE of zero for
percolate (forces a user 1138 abend to terminate the trapped
program), or four to cause a retry according to the SDWA.
Set R15==F'-4' to indicate that the trap is not recognized
by the current handler; polling continues with the next
older handler. For retry, set the SDWARTYA to the retry
address (or just use the SETRP macro).

If the handler was not defined as supporting FRR mode, then
any local or CMS locks that were held are freed before calling
the handler. Unless the handler indicates in the SDWA to free
those locks, the trap manager will reacquire the locks on
retry. Thus, you can single-step locally locked code, assuming
that your application can tolerate losing/regaining the lock.
This is probably not much of an issue when using a de{*filter*}
to develop an application.

You need a reasonable protocol to use TRAP2/TRAP4. My program
provides that protocol by supporting multiple trap handlers,
and an interface that most folks can understand and use. It
also supports nested TRAPs.

==================================================

Quote:


writes:


deja.com> writes:
> >> >How are you using TRAP2/TRAP4?



> >> >> Build your Trap Control Block with the address of the routine
in it.
> >> >Stuff
> >> >> the address of the Trap Control Block in the DUCT. It took me a
while
> >> >to
> >> >> get the whole thing working, but I finally did.
> >> >> --
> >> >> Dave Kienow



> >> >> > Does anyone know how to use the TRAP instruction?
Specifically how
> >> >do you
> >> >> > set the address of the trap-program in the Trap Control Block
so
> >> >that the
> >> >> > TRAP instruction can branch to it?

> >> >> > Thanks.

> >> >--
> >> >.... and this time, I mean it!

> >> >Sent via Deja.com http://www.*-*-*.com/
> >> >Before you buy.

> >> (I haven't seen the original post yet on my mail server.)

> >> I assume you're using RP to return from the trap program?  The RP
> >> instruction is a little strange in that it uses a parameter list
> >> that follows the instruction in the instruction address space.

> >> Can you say what your application is for using the TRAPx
> >> instructions?  I'm probably one of the first people who ever used
> >> the TRAPx/RP instructions, so it's interesting to hear that other
> >> people are using them.

> >> Dave

> >> P.S. Standard Disclaimer: I work for them, but I don't speak for
them.

> >How does one place the address of the Trap Control Block in the
DUCT? Are there
> >mappings for the DUCT and the Trap Control Block? THNX.

> We used the ST instruction....Oh, wait....

> The virtual address of the DUCT is in the Secondary Task Control
> Block (STCB), mapped by the macro IHASTCB, which is pointed to by
> the TCBSTCB field of the TCB.  You'll have to check the product
> literature to be sure that it's acceptable to use that as an
> interface, though, and if you'll need any locks to access those
> fields.  And, since the DUCT is in protected storage, you'll need to
> be authorized to be allowed to update it (Actually, I think the DUCT
> is in fetch protected storage, so you'll have to be authorized to
> even see it.).

> I'm not aware of any mapping macros for the TRCB (Trap Control
> Block), or the DUCT, although when we were coding the code that used
> it, it was very early in the history of the TRCB, so it's possible
> that mapping macros may have been written since then.

> Dave

> P.S. Standard Disclaimer: I work for them, but I don't speak for them.

--
... and this time, I mean it!

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 09 Mar 2003 03:00:00 GMT  
 ESA/390 TRAP instruction
I could not find any mappings. You have to be authorized. Following is how
I managed it:
(Sorry for the ugly format)

          MODESET KEY=ZERO,MODE=SUP * SWITCH TO SUPERVISOR STATE        

+         CNOP  0,4                                                      
+         BAL   1,*+8                                                    
+         DC    B'00000000000000000000000000111100'                      
+         L     1,0(0,1)                                          YM1995
+         SVC   107                                                      
 *                                                                      
          STCTL R0,RF,SAVECRS       * SAVE CONTROL REGISTERS            
 *                                                                      
          L     R2,SAVECRS+8        * GET CONTROL REGISTER 2 A(DUCT)    
 *                                                                      
          ACMODE CLEAR=YES          * SWITCH TO ACCESS REGISTER MODE    
+*
+*                                     ::::   ACCESS REGISTER MODE  ::::
+*
+ACMODE   EQU   512                 . ACCESS REGISTER MODE VALUE  D02699
+         SAC   ACMODE                                                  
+*        THE VALUE OF SYSSTATE IS NOW SET TO ASCENV=AR                
+         XC    UCEACREG,UCEACREG   CLEAR ACCESS REGISTERS              
+         LAM   AR0,ARF,UCEACREG    LOAD ZEROES INTO ALL ACCESS REGS    
 *                                                                      
          LA    R2,44(,R2)          * GET ADDR OF TRAP CTL BLOCK ADDR    
          LA    RF,TRAPCTL          * GET ADDR OF OUR TRAP CONTROL BLOCK
          LA    RF,1(,RF)           * TURN ON LOW ORDER BIT            
          STURA RF,R2               * SET TRAP CTL BLOCK ADDR IN DUCT    
 *                                                                      
          GPMODE CLEAR=NO           * SWITCH BACK TO GP MODE            
+*
+*                                    ....   GENERAL REGISTER MODE  ....
+*
+GPMODE   EQU   0                . GENERAL PURPOSE REG MODE VALUE D02699
+         SAC   GPMODE                                                  
+*        THE VALUE OF SYSSTATE IS NOW SET TO ASCENV=P                  
 *                                                                      
          MODESET KEY=NZERO,MODE=PROB * SWITCH BACK TO PROBLEM MODE      

+         CNOP  0,4                                                    
+         BAL   1,*+8                                                    
+         DC    B'00000000000000000000000000100100'                      
+         L     1,0(0,1)                                          YM1995
+         SVC   107                                                      
 *                                                                      

*   TRAP CONTROL BLOCK                                                  
TRAPCTL  DC    3A(0)                                                    
TRAPCSAV DC    A(TRAPSAVE)                                              
          DC    A(0)                                                    
          DC    A(TRAPPROG)                                              
          DC    10A(0)                                                  

--
Dave Kienow



Quote:
> How does one place the address of the Trap Control Block in the DUCT? Are
there
> mappings for the DUCT and the Trap Control Block? THNX.



writes:
> > >How are you using TRAP2/TRAP4?



> > >> Build your Trap Control Block with the address of the routine in it.
> > >Stuff
> > >> the address of the Trap Control Block in the DUCT. It took me a
while
> > >to
> > >> get the whole thing working, but I finally did.
> > >> --
> > >> Dave Kienow



> > >> > Does anyone know how to use the TRAP instruction? Specifically how
> > >do you
> > >> > set the address of the trap-program in the Trap Control Block so
> > >that the
> > >> > TRAP instruction can branch to it?

> > >> > Thanks.

> > >--
> > >.... and this time, I mean it!

> > >Sent via Deja.com http://www.deja.com/
> > >Before you buy.

> > (I haven't seen the original post yet on my mail server.)

> > I assume you're using RP to return from the trap program?  The RP
> > instruction is a little strange in that it uses a parameter list
> > that follows the instruction in the instruction address space.

> > Can you say what your application is for using the TRAPx
> > instructions?  I'm probably one of the first people who ever used
> > the TRAPx/RP instructions, so it's interesting to hear that other
> > people are using them.

> > Dave

> > P.S. Standard Disclaimer: I work for them, but I don't speak for them.



Sun, 09 Mar 2003 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Z/90, S/390, 370/ESA (slightly off topic)

2. ESA/390

3. New ESA/390 emulator on the PC

4. S/390 assembler instruction reference

5. S/390 Stack instructions

6. OS/390 release test periods Re: default variable initialization under os/390 v2r8

7. Cobol OS/390 to C OS/390 V2R6

8. Help Application Development in IBM 390 Assemblers.

9. Books on os/390

10. JNI and OS 390 C/C++

11. 390 emulator that runs on Linux x86

12. Info on ASM and Linkage conventions for Linux on s/390

 

 
Powered by phpBB® Forum Software