mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-02 09:02:34 +02:00
Merge commit '5e109224fb3480d806e44d74587d052c7f88bf83' into master
This commit is contained in:
@@ -11,16 +11,16 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
struct ppc64_context {
|
||||
//GPRs
|
||||
/* GPRs */
|
||||
uint64_t gprs[32];
|
||||
uint64_t lr;
|
||||
uint64_t ccr;
|
||||
|
||||
//FPRs
|
||||
/* FPRs */
|
||||
uint64_t fprs[32];
|
||||
|
||||
#ifdef __ALTIVEC__
|
||||
//Altivec (VMX)
|
||||
/* Altivec (VMX) */
|
||||
uint64_t vmx[12 * 2];
|
||||
uint32_t vrsave;
|
||||
#endif
|
||||
@@ -43,7 +43,7 @@ __asm__(
|
||||
"swap_context:\n"
|
||||
".cfi_startproc\n"
|
||||
|
||||
//save GPRs
|
||||
/* save GPRs */
|
||||
"std 1, 8(4)\n"
|
||||
"std 2, 16(4)\n"
|
||||
"std 12, 96(4)\n"
|
||||
@@ -67,15 +67,15 @@ __asm__(
|
||||
"std 30, 240(4)\n"
|
||||
"std 31, 248(4)\n"
|
||||
|
||||
//save LR
|
||||
/* save LR */
|
||||
"mflr 5\n"
|
||||
"std 5, 256(4)\n"
|
||||
|
||||
//save CCR
|
||||
/* save CCR */
|
||||
"mfcr 5\n"
|
||||
"std 5, 264(4)\n"
|
||||
|
||||
//save FPRs
|
||||
/* save FPRs */
|
||||
"stfd 14, 384(4)\n"
|
||||
"stfd 15, 392(4)\n"
|
||||
"stfd 16, 400(4)\n"
|
||||
@@ -96,7 +96,7 @@ __asm__(
|
||||
"stfd 31, 520(4)\n"
|
||||
|
||||
#ifdef __ALTIVEC__
|
||||
//save VMX
|
||||
/* save VMX */
|
||||
"li 5, 528\n"
|
||||
"stvxl 20, 4, 5\n"
|
||||
"addi 5, 5, 16\n"
|
||||
@@ -123,12 +123,12 @@ __asm__(
|
||||
"stvxl 31, 4, 5\n"
|
||||
"addi 5, 5, 16\n"
|
||||
|
||||
//save VRSAVE
|
||||
/* save VRSAVE */
|
||||
"mfvrsave 5\n"
|
||||
"stw 5, 736(4)\n"
|
||||
#endif
|
||||
|
||||
//restore GPRs
|
||||
/* restore GPRs */
|
||||
"ld 1, 8(3)\n"
|
||||
"ld 2, 16(3)\n"
|
||||
"ld 12, 96(3)\n"
|
||||
@@ -152,15 +152,15 @@ __asm__(
|
||||
"ld 30, 240(3)\n"
|
||||
"ld 31, 248(3)\n"
|
||||
|
||||
//restore LR
|
||||
/* restore LR */
|
||||
"ld 5, 256(3)\n"
|
||||
"mtlr 5\n"
|
||||
|
||||
//restore CCR
|
||||
/* restore CCR */
|
||||
"ld 5, 264(3)\n"
|
||||
"mtcr 5\n"
|
||||
|
||||
//restore FPRs
|
||||
/* restore FPRs */
|
||||
"lfd 14, 384(3)\n"
|
||||
"lfd 15, 392(3)\n"
|
||||
"lfd 16, 400(3)\n"
|
||||
@@ -181,7 +181,7 @@ __asm__(
|
||||
"lfd 31, 520(3)\n"
|
||||
|
||||
#ifdef __ALTIVEC__
|
||||
//restore VMX
|
||||
/* restore VMX */
|
||||
"li 5, 528\n"
|
||||
"lvxl 20, 3, 5\n"
|
||||
"addi 5, 5, 16\n"
|
||||
@@ -208,12 +208,12 @@ __asm__(
|
||||
"lvxl 31, 3, 5\n"
|
||||
"addi 5, 5, 16\n"
|
||||
|
||||
//restore VRSAVE
|
||||
/* restore VRSAVE */
|
||||
"lwz 5, 720(3)\n"
|
||||
"mtvrsave 5\n"
|
||||
#endif
|
||||
|
||||
//branch to LR
|
||||
/* branch to LR */
|
||||
"blr\n"
|
||||
|
||||
".cfi_endproc\n"
|
||||
@@ -231,21 +231,21 @@ cothread_t co_derive(void* memory, unsigned int size, void (*coentry)(void)) {
|
||||
uint8_t* sp;
|
||||
struct ppc64_context* context = (struct ppc64_context*)memory;
|
||||
|
||||
//save current context into new context to initialize it
|
||||
/* save current context into new context to initialize it */
|
||||
swap_context(context, context);
|
||||
|
||||
//align stack
|
||||
/* align stack */
|
||||
sp = (uint8_t*)memory + size - STACK_ALIGN;
|
||||
sp = (uint8_t*)ALIGN(sp, STACK_ALIGN);
|
||||
|
||||
//write 0 for initial backchain
|
||||
/* write 0 for initial backchain */
|
||||
*(uint64_t*)sp = 0;
|
||||
|
||||
//create new frame with backchain
|
||||
/* create new frame with backchain */
|
||||
sp -= MIN_STACK_FRAME;
|
||||
*(uint64_t*)sp = (uint64_t)(sp + MIN_STACK_FRAME);
|
||||
|
||||
//update context with new stack (r1) and entrypoint (r12, lr)
|
||||
/* update context with new stack (r1) and entrypoint (r12, lr) */
|
||||
context->gprs[ 1] = (uint64_t)sp;
|
||||
context->gprs[12] = (uint64_t)coentry;
|
||||
context->lr = (uint64_t)coentry;
|
||||
|
Reference in New Issue
Block a user