/* Set aside physical memory which is not touched or modified
 * across soft resets.
 */
int prom_retain(const char *name, unsigned long size,
		unsigned long align, unsigned long *paddr)
{
	unsigned long args[11];

	args[0] = (unsigned long) prom_callmethod_name;
	args[1] = 5;
	args[2] = 3;
	args[3] = (unsigned long) "SUNW,retain";
	args[4] = (unsigned int) prom_get_memory_ihandle();
	args[5] = align;
	args[6] = size;
	args[7] = (unsigned long) name;
	args[8] = (unsigned long) -1;
	args[9] = (unsigned long) -1;
	args[10] = (unsigned long) -1;

	p1275_cmd_direct(args);

	if (args[8])
		return (int) args[8];

	/* Next we get "phys_high" then "phys_low".  On 64-bit
	 * the phys_high cell is don't care since the phys_low
	 * cell has the full value.
	 */
	*paddr = args[10];

	return 0;
}
Example #2
0
/* Set property 'pname' at node 'node' to value 'value' which has a length
 * of 'size' bytes.  Return the number of bytes the prom accepted.
 */
int
prom_setprop(phandle node, const char *pname, char *value, int size)
{
	unsigned long args[8];

	if (size == 0)
		return 0;
	if ((pname == 0) || (value == 0))
		return 0;
	
#ifdef CONFIG_SUN_LDOMS
	if (ldom_domaining_enabled) {
		ldom_set_var(pname, value);
		return 0;
	}
#endif
	args[0] = (unsigned long) "setprop";
	args[1] = 4;
	args[2] = 1;
	args[3] = (unsigned int) node;
	args[4] = (unsigned long) pname;
	args[5] = (unsigned long) value;
	args[6] = size;
	args[7] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return (int) args[7];
}
Example #3
0
/* Return the property type string after property type 'oprop'
 * at node 'node' .  Returns NULL string if no more
 * property types for this node.
 */
char *prom_nextprop(phandle node, const char *oprop, char *buffer)
{
	unsigned long args[7];
	char buf[32];

	if ((s32)node == -1) {
		*buffer = 0;
		return buffer;
	}
	if (oprop == buffer) {
		strcpy (buf, oprop);
		oprop = buf;
	}

	args[0] = (unsigned long) prom_nextprop_name;
	args[1] = 3;
	args[2] = 1;
	args[3] = (unsigned int) node;
	args[4] = (unsigned long) oprop;
	args[5] = (unsigned long) buffer;
	args[6] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return buffer;
}
int prom_map(int mode, unsigned long size,
	     unsigned long vaddr, unsigned long paddr)
{
	unsigned long args[11];
	int ret;

	args[0] = (unsigned long) prom_callmethod_name;
	args[1] = 7;
	args[2] = 1;
	args[3] = (unsigned long) prom_map_name;
	args[4] = (unsigned int) prom_get_mmu_ihandle();
	args[5] = (unsigned int) mode;
	args[6] = size;
	args[7] = vaddr;
	args[8] = 0;
	args[9] = paddr;
	args[10] = (unsigned long) -1;

	p1275_cmd_direct(args);

	ret = (int) args[10];
	if (ret == 0)
		ret = -1;
	return ret;
}
void prom_idleself(void)
{
	unsigned long args[3];

	args[0] = (unsigned long) "SUNW,idle-self";
	args[1] = 0;
	args[2] = 0;
	p1275_cmd_direct(args);
}
void prom_stopcpu_cpuid(int cpuid)
{
	unsigned long args[4];

	args[0] = (unsigned long) "SUNW,stop-cpu-by-cpuid";
	args[1] = 1;
	args[2] = 0;
	args[3] = (unsigned int) cpuid;
	p1275_cmd_direct(args);
}
void prom_resumecpu(int cpunode)
{
	unsigned long args[4];

	args[0] = (unsigned long) "SUNW,resume-cpu";
	args[1] = 1;
	args[2] = 0;
	args[3] = (unsigned int) cpunode;
	p1275_cmd_direct(args);
}
void prom_sun4v_guest_soft_state(void)
{
	const char *svc = "SUNW,soft-state-supported";
	unsigned long args[3];

	if (!prom_service_exists(svc))
		return;
	args[0] = (unsigned long) svc;
	args[1] = 0;
	args[2] = 0;
	p1275_cmd_direct(args);
}
int prom_wakeupsystem(void)
{
	unsigned long args[4];

	args[0] = (unsigned long) "SUNW,wakeup-system";
	args[1] = 0;
	args[2] = 1;
	args[3] = (unsigned long) -1;
	p1275_cmd_direct(args);

	return (int) args[3];
}
void prom_startcpu_cpuid(int cpuid, unsigned long pc, unsigned long arg)
{
	unsigned long args[6];

	args[0] = (unsigned long) "SUNW,start-cpu-by-cpuid";
	args[1] = 3;
	args[2] = 0;
	args[3] = (unsigned int) cpuid;
	args[4] = pc;
	args[5] = arg;
	p1275_cmd_direct(args);
}
/* Set prom sync handler to call function 'funcp'. */
void prom_setcallback(callback_func_t funcp)
{
	unsigned long args[5];
	if (!funcp)
		return;
	args[0] = (unsigned long) "set-callback";
	args[1] = 1;
	args[2] = 1;
	args[3] = (unsigned long) funcp;
	args[4] = (unsigned long) -1;
	p1275_cmd_direct(args);
}
Example #12
0
static phandle prom_node_to_node(const char *type, phandle node)
{
	unsigned long args[5];

	args[0] = (unsigned long) type;
	args[1] = 1;
	args[2] = 1;
	args[3] = (unsigned int) node;
	args[4] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return (phandle) args[4];
}
/* Close the device described by device handle 'dhandle'. */
int
prom_devclose(int dhandle)
{
	unsigned long args[4];

	args[0] = (unsigned long) "close";
	args[1] = 1;
	args[2] = 0;
	args[3] = (unsigned int) dhandle;

	p1275_cmd_direct(args);

	return 0;
}
/* Forth evaluate the expression contained in 'fstring'. */
void prom_feval(const char *fstring)
{
	unsigned long args[5];

	if (!fstring || fstring[0] == 0)
		return;
	args[0] = (unsigned long) "interpret";
	args[1] = 1;
	args[2] = 1;
	args[3] = (unsigned long) fstring;
	args[4] = (unsigned long) -1;

	p1275_cmd_direct(args);
}
void prom_unmap(unsigned long size, unsigned long vaddr)
{
	unsigned long args[7];

	args[0] = (unsigned long) prom_callmethod_name;
	args[1] = 4;
	args[2] = 0;
	args[3] = (unsigned long) prom_unmap_name;
	args[4] = (unsigned int) prom_get_mmu_ihandle();
	args[5] = size;
	args[6] = vaddr;

	p1275_cmd_direct(args);
}
/* Reset and reboot the machine with the command 'bcommand'. */
void prom_reboot(const char *bcommand)
{
	unsigned long args[4];

#ifdef CONFIG_SUN_LDOMS
	if (ldom_domaining_enabled)
		ldom_reboot(bcommand);
#endif
	args[0] = (unsigned long) "boot";
	args[1] = 1;
	args[2] = 0;
	args[3] = (unsigned long) bcommand;

	p1275_cmd_direct(args);
}
Example #17
0
void
prom_puts(const char *s, int len)
{
	unsigned long args[7];

	args[0] = (unsigned long) "write";
	args[1] = 3;
	args[2] = 1;
	args[3] = (unsigned int) prom_stdout;
	args[4] = (unsigned long) s;
	args[5] = len;
	args[6] = (unsigned long) -1;

	p1275_cmd_direct(args);
}
void
prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)
{
	unsigned long args[7];

	args[0] = (unsigned long) "seek";
	args[1] = 3;
	args[2] = 1;
	args[3] = (unsigned int) dhandle;
	args[4] = seekhi;
	args[5] = seeklo;
	args[6] = (unsigned long) -1;

	p1275_cmd_direct(args);
}
int
prom_devopen(const char *dstr)
{
	unsigned long args[5];

	args[0] = (unsigned long) "open";
	args[1] = 1;
	args[2] = 1;
	args[3] = (unsigned long) dstr;
	args[4] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return (int) args[4];
}
/* Drop into the prom, but completely terminate the program.
 * No chance of continuing.
 */
void notrace prom_halt(void)
{
	unsigned long args[3];

#ifdef CONFIG_SUN_LDOMS
	if (ldom_domaining_enabled)
		ldom_power_off();
#endif
again:
	args[0] = (unsigned long) "exit";
	args[1] = 0;
	args[2] = 0;
	p1275_cmd_direct(args);
	goto again; /* PROM is out to get me -DaveM */
}
Example #21
0
phandle prom_finddevice(const char *name)
{
	unsigned long args[5];

	if (!name)
		return 0;
	args[0] = (unsigned long) "finddevice";
	args[1] = 1;
	args[2] = 1;
	args[3] = (unsigned long) name;
	args[4] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return (int) args[4];
}
Example #22
0
int prom_ihandle2path(int handle, char *buffer, int bufsize)
{
	unsigned long args[7];

	args[0] = (unsigned long) "instance-to-path";
	args[1] = 3;
	args[2] = 1;
	args[3] = (unsigned int) handle;
	args[4] = (unsigned long) buffer;
	args[5] = bufsize;
	args[6] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return (int) args[6];
}
void prom_halt_power_off(void)
{
	unsigned long args[3];

#ifdef CONFIG_SUN_LDOMS
	if (ldom_domaining_enabled)
		ldom_power_off();
#endif
	args[0] = (unsigned long) "SUNW,power-off";
	args[1] = 0;
	args[2] = 0;
	p1275_cmd_direct(args);

	/* if nothing else helps, we just halt */
	prom_halt();
}
int prom_service_exists(const char *service_name)
{
	unsigned long args[5];

	args[0] = (unsigned long) "test";
	args[1] = 1;
	args[2] = 1;
	args[3] = (unsigned long) service_name;
	args[4] = (unsigned long) -1;

	p1275_cmd_direct(args);

	if (args[4])
		return 0;
	return 1;
}
Example #25
0
inline phandle prom_inst2pkg(int inst)
{
	unsigned long args[5];
	phandle node;
	
	args[0] = (unsigned long) "instance-to-package";
	args[1] = 1;
	args[2] = 1;
	args[3] = (unsigned int) inst;
	args[4] = (unsigned long) -1;

	p1275_cmd_direct(args);

	node = (int) args[4];
	if ((s32)node == -1)
		return 0;
	return node;
}
Example #26
0
/* Return the length in bytes of property 'prop' at node 'node'.
 * Return -1 on error.
 */
int prom_getproplen(phandle node, const char *prop)
{
	unsigned long args[6];

	if (!node || !prop)
		return -1;

	args[0] = (unsigned long) "getproplen";
	args[1] = 2;
	args[2] = 1;
	args[3] = (unsigned int) node;
	args[4] = (unsigned long) prop;
	args[5] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return (int) args[5];
}
/* Load explicit I/D TLB entries. */
static long tlb_load(const char *type, unsigned long index,
		     unsigned long tte_data, unsigned long vaddr)
{
	unsigned long args[9];

	args[0] = (unsigned long) prom_callmethod_name;
	args[1] = 5;
	args[2] = 1;
	args[3] = (unsigned long) type;
	args[4] = (unsigned int) prom_get_mmu_ihandle();
	args[5] = vaddr;
	args[6] = tte_data;
	args[7] = index;
	args[8] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return (long) args[8];
}
Example #28
0
static int __prom_console_write_buf(const char *buf, int len)
{
    unsigned long args[7];
    int ret;

    args[0] = (unsigned long) "write";
    args[1] = 3;
    args[2] = 1;
    args[3] = (unsigned int) prom_stdout;
    args[4] = (unsigned long) buf;
    args[5] = (unsigned int) len;
    args[6] = (unsigned long) -1;

    p1275_cmd_direct(args);

    ret = (int) args[6];
    if (ret < 0)
        return -1;
    return ret;
}
Example #29
0
/* Non blocking get character from console input device, returns -1
 * if no input was taken.  This can be used for polling.
 */
inline int
prom_nbgetchar(void)
{
	unsigned long args[7];
	char inc;

	args[0] = (unsigned long) "read";
	args[1] = 3;
	args[2] = 1;
	args[3] = (unsigned int) prom_stdin;
	args[4] = (unsigned long) &inc;
	args[5] = 1;
	args[6] = (unsigned long) -1;

	p1275_cmd_direct(args);

	if (args[6] == 1)
		return inc;
	return -1;
}
Example #30
0
/* Return the first property type for node 'node'.
 * buffer should be at least 32B in length
 */
char *prom_firstprop(phandle node, char *buffer)
{
	unsigned long args[7];

	*buffer = 0;
	if ((s32)node == -1)
		return buffer;

	args[0] = (unsigned long) prom_nextprop_name;
	args[1] = 3;
	args[2] = 1;
	args[3] = (unsigned int) node;
	args[4] = 0;
	args[5] = (unsigned long) buffer;
	args[6] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return buffer;
}