Stan writes:
>Sample code to get the CCR (Coprocessor Configuration Register):
[pascal example snipped]:
And since Mark is primarily working in C, I'll provide the following
examples:
extern int get_control_reg(int reg);
int getccr(void)
{
/*
* Get the coprocessor control register.
*/
return get_control_reg(10) & 0xff;
}
I'll also provide an example on how to determine the architecture level
because this requires the use of assembly in gcc and is a good exercise:
typedef struct {
int spaceid;
unsigned int offset;
} LONGPOINTER;
extern LONGPOINTER _get_monarch_model(void);
int machinetype(void)
{
/*
* Get the address of the IVA.
*/
LONGPOINTER lptr = _get_monarch_model();
lptr.offset += 6 * sizeof(int);
asm("ldw %0, %%r31" : : "m" (lptr.offset));
asm("ldw %0, %%r28" : : "m" (lptr.spaceid));
asm("mtsp %r28,%sr1");
asm("ldw 0(%sr1,%r31), %r28");
}
You can check out the GNU documentation at
http://www.dis.com/gnu/gcc_toc.html for an explanation on how to use the
assembly features if you're curious!
Regards,
M.