mstatus 真的会用到 SIE/SPIE/SPP 这些位吗?还是只是为了保证 mstatus 作为 sstatus 的超集而保留的?
对于 mstatus :
那么 mstatus.SIE/SPIE/SPP 有什么实际作用呢?
贴一个Reddit上的回答:
They do exactly the same thing when a trap is delegated to S mode for handling.
There is only one physical status register, but different views of it, with M-mode being able to see and change anything and S-mode seeing only a subset.
经过测试发现确实如此:
[firmware_main] Clear MSTATUS_MIE | MSTATUS_SIE for mstatus
[firmware_main] mstatus is 0x0
[firmware_main] sstatus is 0x0
[firmware_main] Set MSTATUS_SIE for mstatus
[firmware_main] mstatus is 0x2
[firmware_main] sstatus is 0x2
[firmware_main] Clear MSTATUS_MIE | MSTATUS_SIE for mstatus
[firmware_main] mstatus is 0x0
[firmware_main] sstatus is 0x0
[firmware_main] Set SSTATUS_SIE for sstatus
[firmware_main] mstatus is 0x2
[firmware_main] sstatus is 0x2