Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decoding this assembly inline code snippet on PowerPc

I have this below code snippet from kernel source for PowerPc

#define SPRN_IVOR32     0x210   /* Interrupt Vector Offset Register 32 */

unsigned long ivor[3];
ivor[0] = mfspr(SPRN_IVOR32);

#define __stringify_1(x)        #x
#define __stringify(x)          __stringify_1(x)

#define mfspr(rn)       ({unsigned long rval; \
                    asm volatile("mfspr %0," __stringify(rn) \
                            : "=r" (rval)); rval; })

Also, it this above exercise is about emulating MSR register's bits in PowerPc?

Can anyone help me on what exactly we are doing here?

like image 993
Amit Singh Tomar Avatar asked Sep 24 '26 01:09

Amit Singh Tomar


1 Answers

The mfspr macro generates an asm instruction mfspr which reads the given special purpose register into a register chosen by the compiler, which then gets assigned to rval hence becomes the return value of the expression.

As the comment says, SPRN_IVOR32 is the Interrupt Vector Offset Register 32, whose contents are thus fetched into ivor[0].

like image 120
Jester Avatar answered Sep 26 '26 02:09

Jester



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!