Ejemplo n.º 1
0
void *
mmap(void *addr, size_t len, int32_t prot, uint32_t flags,
	ihandle_t fildes, int32_t off)
{
	ihandle_t dev_ihandle, parent_ihandle;
	phandle_t dev_phandle, parent_phandle;
	void *rp;
	static char reg_prop[100], dev_name[100], bus_type[100];
	uint32_t *reg_ptr;
	uint_t adr_cells, size_cells;

	dev_ihandle = fildes;
	dev_phandle = prom_getphandle(dev_ihandle);
	prom_getprop(dev_phandle, "reg", reg_prop);
	reg_ptr = (uint32_t *)reg_prop;

	parent_ihandle = get_parent_ihandle(dev_ihandle);
	parent_phandle = prom_getphandle(parent_ihandle);

	prom_getprop(parent_phandle, "#address-cells", (caddr_t)&adr_cells);
	prom_getprop(parent_phandle, "#size-cells", (caddr_t)&size_cells);

	prom_getprop(dev_phandle, "name", dev_name);
	prom_getprop(parent_phandle, "device_type", bus_type);

	/*
	 * Flashprom devices need special handling of offset arg
	 * as specified by the /dev/flashprom driver
	 */

	if ((strcmp(dev_name, "flashprom") == 0)) {
		if (off != NULL) {
			reg_ptr += ((off >> 28) & 0xf)
			    * (adr_cells + size_cells);
			off = (off & 0xfffffff);
			*(reg_ptr + 1) += off;
		}
		rp = (void *)prom_mapin(parent_ihandle, reg_ptr,
		    adr_cells, len);

		return ((void *)((int32_t)rp & 0xffffffff));
	}
Ejemplo n.º 2
0
void
kmdb_prom_preserve_kctx_init(void)
{
	pnode_t	pnode;
	int	val;

	pnode = (pnode_t)prom_getphandle(prom_mmu_ihandle());
	if (prom_getprop(pnode, PROM_KCTX_PRESERVED_PROPNAME,
	    (caddr_t)&val) == 0) {
		kmdb_prom_preserve_kctx = 1;
	}
}
Ejemplo n.º 3
0
ihandle_t
get_parent_ihandle(ihandle_t child_ihandle)
{
	char parent_name[OBP_MAXPATHLEN];
	phandle_t  child_phandle, parent_phandle;

	child_phandle = prom_getphandle(child_ihandle);
	parent_phandle = prom_parentnode(child_phandle);
	prom_phandle_to_path(parent_phandle, parent_name, OBP_MAXPATHLEN);

	return (prom_open(parent_name));
}
Ejemplo n.º 4
0
/*
 * This service converts the given physical address into a text string,
 * representing the name of the field-replacable part for the given
 * physical address. In other words, it tells the kernel which ecache
 * module got the (un)correctable ECC error.
 */
int
prom_serengeti_get_ecacheunum(int cpuid, unsigned long long physaddr, char *buf,
		uint_t buflen, int *ustrlen)
{
	cell_t ci[12];
	int rv;
	ihandle_t imemory = prom_memory_ihandle();

	*ustrlen = -1;
	if ((imemory == (ihandle_t)-1))
		return (-1);

	if (prom_test_method("SUNW,Serengeti,get-ecache-unum",
	    prom_getphandle(imemory)) != 0)
		return (-1);

	ci[0] = p1275_ptr2cell("call-method");		/* Service name */
	ci[1] = (cell_t)7;				/* #argument cells */
	ci[2] = (cell_t)2;				/* #result cells */
	ci[3] = p1275_ptr2cell("SUNW,Serengeti,get-ecache-unum");
							/* Arg1: Method name */
	ci[4] = p1275_ihandle2cell(imemory);		/* Arg2: mem. ihandle */
	ci[5] = p1275_uint2cell(buflen);		/* Arg3: buflen */
	ci[6] = p1275_ptr2cell(buf);			/* Arg4: buf */
	ci[7] = p1275_ull2cell_high(physaddr);		/* Arg5: physhi */
	ci[8] = p1275_ull2cell_low(physaddr);		/* Arg6: physlo */
	ci[9] = p1275_int2cell(cpuid);			/* Arg7: cpuid */
	ci[10] = (cell_t)-1;				/* ret1: catch result */
	ci[11] = (cell_t)-1;				/* ret2: length */

	promif_preprom();
	rv = p1275_cif_handler(&ci);
	promif_postprom();

	if (rv != 0)
		return (rv);
	if (p1275_cell2int(ci[10]) != 0)	/* Res1: catch result */
		return (-1);	/* "SUNW,Serengeti,get-ecache-unum" failed */
	*ustrlen = p1275_cell2uint(ci[11]);	/* Res2: unum str length */
	return (0);
}