Memory Map (S390): Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
No edit summary
m Bot: Replace deprecated source tag with syntaxhighlight
 
(One intermediate revision by one other user not shown)
Line 2:
 
== Detecting memory ==
<sourcesyntaxhighlight lang="c">
/* We are going to read in pairs of 1MiB and when we hit the memory limit we
* will instantly catch the program exception and stop counting, then it's just
Line 26:
return (size_t)probe;
}
</syntaxhighlight>
</source>
 
Now there needs to be a function to "catch" the exceptions recognized by the processor:
<sourcesyntaxhighlight lang="c">
/* Check if an address is valid - this only catches program exceptions to
* determine if it's valid or not */
Line 68 ⟶ 69:
return r;
}
</syntaxhighlight>
</source>
 
Some C compilers are known to crash or even ABEND during compilation if addresses of labels are taken via the && operator, alternatively using direct high-level assembler syntax:
 
<syntaxhighlight lang="asm">
* HwCheckAddress
* IN:
* pointer to address to probe
*
ENTRY @ZHWCHKA
@ZHWCHKA DS 0H
SAVE (14,12),,@ZHWCHKA
LR R12,R15
USING @ZHWCHKA,12
LR R11,R1
* CATCHPSW address on R1
L R1,=A(CATCHPSW)
* Save address of TMPSAVE on R2
L R2,=A(TMPSAVE)
* And FLCPNPSW on R3
L R3,FLCPNPSW
*
MVC 0(8,R2),0(R3)
* ... use a new PSW to catch the exceptions
MVC 0(8,R3),0(R1)
* Probe the address, if it raises a PC exception then
* we will simply catch it and return 1
L R1,0(R11)
L R15,0(R1)
* rc = 0
MVC 0(8,R3),0(R2)
L R15,=F'0'
RETURN (14,12),RC=(15)
CATCHPCR DS 0H
* rc = 1
MVC 0(8,R3),0(R2)
L R15,=F'1'
RETURN (14,12),RC=(15)
LTORG
DROP 12
*
CATCHPSW DS 0D
DC X'020E0000'
DC A(AMBIT+CATCHPCR)
TMPSAVE DS 1D
</syntaxhighlight>
 
== See also ===