Skip to content

Commit

Permalink
powerpc/powermac: Constrain 'cpu_sleep()' for AIM to mpc745x
Browse files Browse the repository at this point in the history
Rename cpu_sleep() to mpc745x_sleep() to denote what it's actually
intended for.  This function is very G4-specific, and will not work on
any other CPU.  This will afterward eliminate a
platform_smp_timebase_sync() call by directly updating the timebase
instead.

(cherry picked from commit b6d8f3b)
  • Loading branch information
chmeeedalf authored and bdragon28 committed Apr 20, 2021
1 parent 26f2ebf commit ac42b63
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion sys/powerpc/aim/aim_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,9 @@ flush_disable_caches(void)
mtmsr(msr);
}

#ifndef __powerpc64__
void
cpu_sleep()
mpc745x_sleep()
{
static u_quad_t timebase = 0;
static register_t sprgs[4];
Expand Down Expand Up @@ -785,3 +786,4 @@ cpu_sleep()
enable_vec(curthread);
powerpc_sync();
}
#endif
6 changes: 5 additions & 1 deletion sys/powerpc/include/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,14 @@ extern register_t lpcr;

void cpu_halt(void);
void cpu_reset(void);
void cpu_sleep(void);
void flush_disable_caches(void);
void fork_trampoline(void);
void swi_vm(void *);
int cpu_machine_check(struct thread *, struct trapframe *, int *);


#ifndef __powerpc64__
void mpc745x_sleep(void);
#endif

#endif /* _MACHINE_CPU_H_ */
13 changes: 12 additions & 1 deletion sys/powerpc/powermac/platform_powermac.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ static int powermac_smp_get_bsp(platform_t, struct cpuref *cpuref);
static int powermac_smp_start_cpu(platform_t, struct pcpu *cpu);
static void powermac_smp_timebase_sync(platform_t, u_long tb, int ap);
static void powermac_reset(platform_t);
#ifndef __powerpc64__
static void powermac_sleep(platform_t);
#endif

static platform_method_t powermac_methods[] = {
PLATFORMMETHOD(platform_probe, powermac_probe),
Expand All @@ -83,7 +85,9 @@ static platform_method_t powermac_methods[] = {
PLATFORMMETHOD(platform_smp_timebase_sync, powermac_smp_timebase_sync),

PLATFORMMETHOD(platform_reset, powermac_reset),
#ifndef __powerpc64__
PLATFORMMETHOD(platform_sleep, powermac_sleep),
#endif

PLATFORMMETHOD_END
};
Expand Down Expand Up @@ -404,10 +408,17 @@ powermac_reset(platform_t platform)
OF_reboot();
}

#ifndef __powerpc64__
void
powermac_sleep(platform_t platform)
{
/* Only supports MPC745x for now. */
if (!MPC745X_P(mfspr(SPR_PVR) >> 16)) {
printf("sleep only supported for G4 PowerMac hardware.\n");
return;
}

*(unsigned long *)0x80 = 0x100;
cpu_sleep();
mpc745x_sleep();
}
#endif

0 comments on commit ac42b63

Please sign in to comment.