|
@@ -165,3 +165,145 @@ smp_callin(void)
|
|
|
|
|
|
DBGS(("smp_callin: commencing CPU %d current %p active_mm %p\n",
|
|
DBGS(("smp_callin: commencing CPU %d current %p active_mm %p\n",
|
|
cpuid, current, current->active_mm));
|
|
cpuid, current, current->active_mm));
|
|
|
|
+
|
|
|
|
+ preempt_disable();
|
|
|
|
+ /* Do nothing. */
|
|
|
|
+ cpu_idle();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* Wait until hwrpb->txrdy is clear for cpu. Return -1 on timeout. */
|
|
|
|
+static int
|
|
|
|
+wait_for_txrdy (unsigned long cpumask)
|
|
|
|
+{
|
|
|
|
+ unsigned long timeout;
|
|
|
|
+
|
|
|
|
+ if (!(hwrpb->txrdy & cpumask))
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ timeout = jiffies + 10*HZ;
|
|
|
|
+ while (time_before(jiffies, timeout)) {
|
|
|
|
+ if (!(hwrpb->txrdy & cpumask))
|
|
|
|
+ return 0;
|
|
|
|
+ udelay(10);
|
|
|
|
+ barrier();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return -1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Send a message to a secondary's console. "START" is one such
|
|
|
|
+ * interesting message. ;-)
|
|
|
|
+ */
|
|
|
|
+static void __cpuinit
|
|
|
|
+send_secondary_console_msg(char *str, int cpuid)
|
|
|
|
+{
|
|
|
|
+ struct percpu_struct *cpu;
|
|
|
|
+ register char *cp1, *cp2;
|
|
|
|
+ unsigned long cpumask;
|
|
|
|
+ size_t len;
|
|
|
|
+
|
|
|
|
+ cpu = (struct percpu_struct *)
|
|
|
|
+ ((char*)hwrpb
|
|
|
|
+ + hwrpb->processor_offset
|
|
|
|
+ + cpuid * hwrpb->processor_size);
|
|
|
|
+
|
|
|
|
+ cpumask = (1UL << cpuid);
|
|
|
|
+ if (wait_for_txrdy(cpumask))
|
|
|
|
+ goto timeout;
|
|
|
|
+
|
|
|
|
+ cp2 = str;
|
|
|
|
+ len = strlen(cp2);
|
|
|
|
+ *(unsigned int *)&cpu->ipc_buffer[0] = len;
|
|
|
|
+ cp1 = (char *) &cpu->ipc_buffer[1];
|
|
|
|
+ memcpy(cp1, cp2, len);
|
|
|
|
+
|
|
|
|
+ /* atomic test and set */
|
|
|
|
+ wmb();
|
|
|
|
+ set_bit(cpuid, &hwrpb->rxrdy);
|
|
|
|
+
|
|
|
|
+ if (wait_for_txrdy(cpumask))
|
|
|
|
+ goto timeout;
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ timeout:
|
|
|
|
+ printk("Processor %x not ready\n", cpuid);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * A secondary console wants to send a message. Receive it.
|
|
|
|
+ */
|
|
|
|
+static void
|
|
|
|
+recv_secondary_console_msg(void)
|
|
|
|
+{
|
|
|
|
+ int mycpu, i, cnt;
|
|
|
|
+ unsigned long txrdy = hwrpb->txrdy;
|
|
|
|
+ char *cp1, *cp2, buf[80];
|
|
|
|
+ struct percpu_struct *cpu;
|
|
|
|
+
|
|
|
|
+ DBGS(("recv_secondary_console_msg: TXRDY 0x%lx.\n", txrdy));
|
|
|
|
+
|
|
|
|
+ mycpu = hard_smp_processor_id();
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < NR_CPUS; i++) {
|
|
|
|
+ if (!(txrdy & (1UL << i)))
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ DBGS(("recv_secondary_console_msg: "
|
|
|
|
+ "TXRDY contains CPU %d.\n", i));
|
|
|
|
+
|
|
|
|
+ cpu = (struct percpu_struct *)
|
|
|
|
+ ((char*)hwrpb
|
|
|
|
+ + hwrpb->processor_offset
|
|
|
|
+ + i * hwrpb->processor_size);
|
|
|
|
+
|
|
|
|
+ DBGS(("recv_secondary_console_msg: on %d from %d"
|
|
|
|
+ " HALT_REASON 0x%lx FLAGS 0x%lx\n",
|
|
|
|
+ mycpu, i, cpu->halt_reason, cpu->flags));
|
|
|
|
+
|
|
|
|
+ cnt = cpu->ipc_buffer[0] >> 32;
|
|
|
|
+ if (cnt <= 0 || cnt >= 80)
|
|
|
|
+ strcpy(buf, "<<< BOGUS MSG >>>");
|
|
|
|
+ else {
|
|
|
|
+ cp1 = (char *) &cpu->ipc_buffer[11];
|
|
|
|
+ cp2 = buf;
|
|
|
|
+ strcpy(cp2, cp1);
|
|
|
|
+
|
|
|
|
+ while ((cp2 = strchr(cp2, '\r')) != 0) {
|
|
|
|
+ *cp2 = ' ';
|
|
|
|
+ if (cp2[1] == '\n')
|
|
|
|
+ cp2[1] = ' ';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DBGS((KERN_INFO "recv_secondary_console_msg: on %d "
|
|
|
|
+ "message is '%s'\n", mycpu, buf));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ hwrpb->txrdy = 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Convince the console to have a secondary cpu begin execution.
|
|
|
|
+ */
|
|
|
|
+static int __cpuinit
|
|
|
|
+secondary_cpu_start(int cpuid, struct task_struct *idle)
|
|
|
|
+{
|
|
|
|
+ struct percpu_struct *cpu;
|
|
|
|
+ struct pcb_struct *hwpcb, *ipcb;
|
|
|
|
+ unsigned long timeout;
|
|
|
|
+
|
|
|
|
+ cpu = (struct percpu_struct *)
|
|
|
|
+ ((char*)hwrpb
|
|
|
|
+ + hwrpb->processor_offset
|
|
|
|
+ + cpuid * hwrpb->processor_size);
|
|
|
|
+ hwpcb = (struct pcb_struct *) cpu->hwpcb;
|
|
|
|
+ ipcb = &task_thread_info(idle)->pcb;
|
|
|
|
+
|
|
|
|
+ /* Initialize the CPU's HWPCB to something just good enough for
|
|
|
|
+ us to get started. Immediately after starting, we'll swpctx
|
|
|
|
+ to the target idle task's pcb. Reuse the stack in the mean
|
|
|
|
+ time. Precalculate the target PCBB. */
|
|
|
|
+ hwpcb->ksp = (unsigned long)ipcb + sizeof(union thread_union) - 16;
|
|
|
|
+ hwpcb->usp = 0;
|
|
|
|
+ hwpcb->ptbr = ipcb->ptbr;
|