Program Status Word: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
No edit summary
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(2 intermediate revisions by one other user not shown)
Line 65:
| Reserved and must be 0
|}
 
== Examples ==
 
=== Structure (S390) ===
<syntaxhighlight lang="c">
struct s390_psw {
uint32_t flags;
uint32_t address;
} __attribute__((packed, aligned(8)));
</syntaxhighlight>
 
=== Structure (z/Arch) ===
<syntaxhighlight lang="c">
struct s390x_psw {
uint32_t hi_flags;
uint32_t lo_flags; /* It's all zero except for the MSB (in S/390 order) */
uint32_t hi_address;
uint32_t lo_address;
} __attribute__((packed, aligned(8)));
</syntaxhighlight>
 
=== Portable PSW declaration ===
<syntaxhighlight lang="c">
/* Helper function to create a PSW adjusted to the current machine */
#if (MACHINE >= M_ZARCH)
# define S390_PSW_DEFAULT_TYPE struct s390x_psw
# define S390_PSW_DECL(name, address, flags)\
S390_PSW_DEFAULT_TYPE name = {\
(flags) | S390_PSW_AM64, S390_PSW_AM31, 0, (uint32_t)(address)\
}
#else
# define S390_PSW_DEFAULT_TYPE struct s390_psw
# define S390_PSW_DECL(name, address, flags)\
S390_PSW_DEFAULT_TYPE name = {\
(flags), (uint32_t)(address) + S390_PSW_DEFAULT_AMBIT\
}
#endif
 
const S390_PSW_DECL(
wait_io_psw,
0,
S390_PSW_ENABLE_ARCHMODE | S390_PSW_ENABLE_MCI | S390_PSW_WAIT_STATE| S390_PSW_IO_INT | S390_PSW_DAT
);
</syntaxhighlight>
 
=== Service Interrupt handler ===
<syntaxhighlight lang="asm">
.globl s390_supervisor_call_handler_stub
s390_supervisor_call_handler_stub:
stm %r0, %r15, S390_FLCGRSAV
lm %r0, %r15, S390_FLCCRSAV
 
larl %r15, int_stack_bottom
brasl %r14, s390_supervisor_call_handler
 
lm %r0, %r15, S390_FLCGRSAV
lpsw S390_FLCSOPSW
</syntaxhighlight>
 
== See also ==
=== External links ===
* [https://www.kernel.org/doc/html/v5.3/s390/debugging390.html Contains the structure of the PSW (in MSB order)]
 
=== Source code ===
* [https://sourceforge.net/p/pdos/gitcode/ci/master/tree/pdpclib/sapsupa.asm#l720 Example I/O PSWs (HLASM)]
* [https://github.com/udos-project/UDOS/blob/3f446f4117d78fddf181f1df2927a9437fb08035/kernel/s390/int_handler.S Handlers for different interrupts and exceptions (GAS)]
 
[[Category:S390]]