Hello,
I've been going through the powerpc port code in reference while porting a risc v board and there's a bit of the thread init code I don't understand.
After writing to the interrupt enable register, r31 is copied to r3 and r30 is copied to ctr but there I found no init of those regs( r30,r31) and the e200 documents make no specific mention of them in this context.
I found some documentation online that suggests linux uses r31 as the global pointer but this is specific to that kernel, OS X uses r13. Could someone point me in the right direction?
E200 Thread Init
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: E200 Thread Init
Hi,
Look in the thread context setup macro, those registers are initialized there:
The context structure is copied into registers on the first context switch. Those registers represent the thread start address and the thread argument pointer. This part is tricky and architecture-dependent, looking at other ports could help understand it, in PPC it looks complex because its EABI stack organization.
Is there any RISK V HW available? I would be interested trying it too.
Giovanni
Look in the thread context setup macro, those registers are initialized there:
Code: Select all
#define PORT_SETUP_CONTEXT(tp, wbase, wtop, pf, arg) { \
uint8_t *sp = (uint8_t *)(wtop) - sizeof(struct port_eabi_frame); \
((struct port_eabi_frame *)sp)->slink = 0; \
((struct port_eabi_frame *)sp)->shole = (uint32_t)_port_thread_start; \
(tp)->ctx.sp = (struct port_intctx *)(sp - sizeof(struct port_intctx)); \
(tp)->ctx.sp->r31 = (regppc_t)(arg); \
(tp)->ctx.sp->r30 = (regppc_t)(pf); \
}
The context structure is copied into registers on the first context switch. Those registers represent the thread start address and the thread argument pointer. This part is tricky and architecture-dependent, looking at other ports could help understand it, in PPC it looks complex because its EABI stack organization.
Is there any RISK V HW available? I would be interested trying it too.
Giovanni
Re: E200 Thread Init
Well the Risc V specs don't include any type of stack organization, it's essentially an exercise left to implementors. Our cpu also doesn't address this so it's a software detail now. It seems that the most important requirement is that a consistent organization is followed.
I've heard of about 2 or so Risc V boards (Rocket and Spike I believe) but I haven't gotten my hands on any of them. I'm working with our board and referencing the ppc code; most of what I have is rather untested code.
I've heard of about 2 or so Risc V boards (Rocket and Spike I believe) but I haven't gotten my hands on any of them. I'm working with our board and referencing the ppc code; most of what I have is rather untested code.