mirror of
https://github.com/torvalds/linux.git
synced 2024-12-09 12:41:33 +00:00
4f0234f4f9
Only adding cpus is supports at the moment, removal will come next. When new cpus are configured, the machine description is updated. When we get the configure request we pass in a cpu mask of to-be-added cpus to the mdesc CPU node parser so it only fetches information for those cpus. That code also proceeds to update the SMT/multi-core scheduling bitmaps. cpu_up() does all the work and we return the status back over the DS channel. CPUs via dr-cpu need to be booted straight out of the hypervisor, and this requires: 1) A new trampoline mechanism. CPUs are booted straight out of the hypervisor with MMU disabled and running in physical addresses with no mappings installed in the TLB. The new hvtramp.S code sets up the critical cpu state, installs the locked TLB mappings for the kernel, and turns the MMU on. It then proceeds to follow the logic of the existing trampoline.S SMP cpu bringup code. 2) All calls into OBP have to be disallowed when domaining is enabled. Since cpus boot straight into the kernel from the hypervisor, OBP has no state about that cpu and therefore cannot handle being invoked on that cpu. Luckily it's only a handful of interfaces which can be called after the OBP device tree is obtained. For example, rebooting, halting, powering-off, and setting options node variables. CPU removal support will require some infrastructure changes here. Namely we'll have to process the requests via a true kernel thread instead of in a workqueue. workqueues run on a per-cpu thread, but when unconfiguring we might need to force the thread to execute on another cpu if the current cpu is the one being removed. Removal of a cpu also causes the kernel to destroy that cpu's workqueue running thread. Another issue on removal is that we may have interrupts still pointing to the cpu-to-be-removed. So new code will be needed to walk the active INO list and retarget those cpus as-needed. Signed-off-by: David S. Miller <davem@davemloft.net>
152 lines
3.7 KiB
C
152 lines
3.7 KiB
C
/* $Id: p1275.c,v 1.22 2001/10/18 09:40:00 davem Exp $
|
|
* p1275.c: Sun IEEE 1275 PROM low level interface routines
|
|
*
|
|
* Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/string.h>
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <asm/openprom.h>
|
|
#include <asm/oplib.h>
|
|
#include <asm/system.h>
|
|
#include <asm/spitfire.h>
|
|
#include <asm/pstate.h>
|
|
#include <asm/ldc.h>
|
|
|
|
struct {
|
|
long prom_callback; /* 0x00 */
|
|
void (*prom_cif_handler)(long *); /* 0x08 */
|
|
unsigned long prom_cif_stack; /* 0x10 */
|
|
unsigned long prom_args [23]; /* 0x18 */
|
|
char prom_buffer [3000];
|
|
} p1275buf;
|
|
|
|
extern void prom_world(int);
|
|
|
|
extern void prom_cif_interface(void);
|
|
extern void prom_cif_callback(void);
|
|
|
|
/*
|
|
* This provides SMP safety on the p1275buf. prom_callback() drops this lock
|
|
* to allow recursuve acquisition.
|
|
*/
|
|
DEFINE_SPINLOCK(prom_entry_lock);
|
|
|
|
long p1275_cmd(const char *service, long fmt, ...)
|
|
{
|
|
char *p, *q;
|
|
unsigned long flags;
|
|
int nargs, nrets, i;
|
|
va_list list;
|
|
long attrs, x;
|
|
|
|
p = p1275buf.prom_buffer;
|
|
|
|
spin_lock_irqsave(&prom_entry_lock, flags);
|
|
|
|
p1275buf.prom_args[0] = (unsigned long)p; /* service */
|
|
strcpy (p, service);
|
|
p = (char *)(((long)(strchr (p, 0) + 8)) & ~7);
|
|
p1275buf.prom_args[1] = nargs = (fmt & 0x0f); /* nargs */
|
|
p1275buf.prom_args[2] = nrets = ((fmt & 0xf0) >> 4); /* nrets */
|
|
attrs = fmt >> 8;
|
|
va_start(list, fmt);
|
|
for (i = 0; i < nargs; i++, attrs >>= 3) {
|
|
switch (attrs & 0x7) {
|
|
case P1275_ARG_NUMBER:
|
|
p1275buf.prom_args[i + 3] =
|
|
(unsigned)va_arg(list, long);
|
|
break;
|
|
case P1275_ARG_IN_64B:
|
|
p1275buf.prom_args[i + 3] =
|
|
va_arg(list, unsigned long);
|
|
break;
|
|
case P1275_ARG_IN_STRING:
|
|
strcpy (p, va_arg(list, char *));
|
|
p1275buf.prom_args[i + 3] = (unsigned long)p;
|
|
p = (char *)(((long)(strchr (p, 0) + 8)) & ~7);
|
|
break;
|
|
case P1275_ARG_OUT_BUF:
|
|
(void) va_arg(list, char *);
|
|
p1275buf.prom_args[i + 3] = (unsigned long)p;
|
|
x = va_arg(list, long);
|
|
i++; attrs >>= 3;
|
|
p = (char *)(((long)(p + (int)x + 7)) & ~7);
|
|
p1275buf.prom_args[i + 3] = x;
|
|
break;
|
|
case P1275_ARG_IN_BUF:
|
|
q = va_arg(list, char *);
|
|
p1275buf.prom_args[i + 3] = (unsigned long)p;
|
|
x = va_arg(list, long);
|
|
i++; attrs >>= 3;
|
|
memcpy (p, q, (int)x);
|
|
p = (char *)(((long)(p + (int)x + 7)) & ~7);
|
|
p1275buf.prom_args[i + 3] = x;
|
|
break;
|
|
case P1275_ARG_OUT_32B:
|
|
(void) va_arg(list, char *);
|
|
p1275buf.prom_args[i + 3] = (unsigned long)p;
|
|
p += 32;
|
|
break;
|
|
case P1275_ARG_IN_FUNCTION:
|
|
p1275buf.prom_args[i + 3] =
|
|
(unsigned long)prom_cif_callback;
|
|
p1275buf.prom_callback = va_arg(list, long);
|
|
break;
|
|
}
|
|
}
|
|
va_end(list);
|
|
|
|
prom_world(1);
|
|
prom_cif_interface();
|
|
prom_world(0);
|
|
|
|
attrs = fmt >> 8;
|
|
va_start(list, fmt);
|
|
for (i = 0; i < nargs; i++, attrs >>= 3) {
|
|
switch (attrs & 0x7) {
|
|
case P1275_ARG_NUMBER:
|
|
(void) va_arg(list, long);
|
|
break;
|
|
case P1275_ARG_IN_STRING:
|
|
(void) va_arg(list, char *);
|
|
break;
|
|
case P1275_ARG_IN_FUNCTION:
|
|
(void) va_arg(list, long);
|
|
break;
|
|
case P1275_ARG_IN_BUF:
|
|
(void) va_arg(list, char *);
|
|
(void) va_arg(list, long);
|
|
i++; attrs >>= 3;
|
|
break;
|
|
case P1275_ARG_OUT_BUF:
|
|
p = va_arg(list, char *);
|
|
x = va_arg(list, long);
|
|
memcpy (p, (char *)(p1275buf.prom_args[i + 3]), (int)x);
|
|
i++; attrs >>= 3;
|
|
break;
|
|
case P1275_ARG_OUT_32B:
|
|
p = va_arg(list, char *);
|
|
memcpy (p, (char *)(p1275buf.prom_args[i + 3]), 32);
|
|
break;
|
|
}
|
|
}
|
|
va_end(list);
|
|
x = p1275buf.prom_args [nargs + 3];
|
|
|
|
spin_unlock_irqrestore(&prom_entry_lock, flags);
|
|
|
|
return x;
|
|
}
|
|
|
|
void prom_cif_init(void *cif_handler, void *cif_stack)
|
|
{
|
|
p1275buf.prom_cif_handler = (void (*)(long *))cif_handler;
|
|
p1275buf.prom_cif_stack = (unsigned long)cif_stack;
|
|
}
|