« Return to Thread: Addressing MVS control blocks from Hercules e.g. PSAAOLD/PSATOLD

Re: Addressing MVS control blocks from Hercules e.g. PSAAOLD/PSATOLD

by Roger Bowler :: Rate this Message:

Reply to Author | View in Thread

--- In hercules-390@..., michealbutz2002 wrote:
>  In cpu.c
> psa = (void*)(regs->mainstor + regs->PX);
> myasid = ((U16) *psa->psaaold->ascbasid
>  I am running this code under the Visual Studio debugger
> when I reference myasid I blow up  

You need to keep a clear distinction in your mind between pointers
that point into Intel storage and pointers that point into S/390
storage. You cannot mix the two. Another thing you need to take into
account is that mainstor is real storage and psaaold is a virtual
address pointing into common storage (E)SQA.

psa->psaaold->ascbasid is mixing up three different addressing
concepts and will almost certainly segfault.

Just to complicate matters further, Intel pointers are
"back-to-front", so for example 12345678 is stored in Intel storage as
78563412 (I gave up wondering why about 10 years ago :-))

The correct way to do it would be something like this:
- calculate the address of the PSA in mainstor
- use FETCH_FW to load the fullword at psaaold
- perform virt_to_abs translation to get address of ASCB in mainstor
- use FETCH_HW to load the halfword from ASCBASID

You must also deal with things like translation exceptions, addressing
exceptions, and crossing page boundaries (i.e. you cannot just add the
offset of the ASCBASID field to the starting address of the ASCB
unless you are sure that the ASCB does not cross a page boundary).

Give us a hint what you are trying to achieve. We might be able to
suggest another method.

Regards,
Roger Bowler
Hercules "the people's mainframe"

 « Return to Thread: Addressing MVS control blocks from Hercules e.g. PSAAOLD/PSATOLD