Code: Select all
/* Fetch topofstack from current task pointer */ ldr x0, =pxCurrentTCB ldr x0, [x0] ldr x0, [x0] /* now restore the special registers */ ldp x1, x2, [x0], #16 msr SPSR_EL1, x2 msr ELR_EL1, x1 ldp x3, x4, [x0], #16 msr TPIDR_EL1, x4 msr SP_EL0, x3 /*** x3 is return value for stack NFI where it should go .. here just so I can see it */ /* restore general registers x2-x30 */ ldp x30, xzr, [x0], #16 ldp x28, x29, [x0], #16 ldp x26, x27, [x0], #16 ldp x24, x25, [x0], #16 ldp x22, x23, [x0], #16 ldp x20, x21, [x0], #16 ldp x18, x19, [x0], #16 ldp x16, x17, [x0], #16 ldp x14, x15, [x0], #16 ldp x12, x13, [x0], #16 ldp x10, x11, [x0], #16 ldp x8, x9, [x0], #16 ldp x6, x7, [x0], #16 ldp x4, x5, [x0], #16 ldp x2, x3, [x0], #16 mov sp, x0 ldp x0, x1, [sp], #16 eret
Code: Select all
static uint64_t Task1Stack __attribute__((aligned(16))); static uint64_t Task2Stack __attribute__((aligned(16)));
To change between execution states at the same Exception level, you have to switch to a higher Exception level then return to the original Exception level. For example, you might have 32-bit and 64-bit applications running under a 64-bit OS. In this case, the 32-bit application can execute and generate a Supervisor Call (SVC) instruction, or receive an interrupt, causing a switch to EL1 and AArch64. (See Exception handling instructions.) The OS can then do a task switch and return to EL0 in AArch64.
That is referring to changing execution state, i.e. going from AArch32 -> AArch64.LdB wrote: ↑Tue Nov 20, 2018 3:09 pmUPDATE: Nope looks like I was right .. dammit that is ugly
You had me querying it, I had to check the ARM to be sure. The interrupt masks are automatically set on entering so you don't have to worry about another one happening before you are ready.
eret doesn't touch the stack pointer as there is nothing on the stack that it needs. Are you setting the SP to a correct value w.r.t. alignment? Normally it should always be 16 byte aligned (though I think it generates an exception if you try to use an unaligned SP to access memory).LdB wrote: ↑Wed Nov 21, 2018 3:05 amClose but no cigar .. the SP is moving a bit +0 to +32 from the value I set it. It would appears sometimes it pulls stuff back off the stack on the eret other times not. I am even more mystified now. I assume there must be a flag to tell me if it's going to pull back the stack on return searching documents .