Exemplo n.º 1
0
void WPL_BspMallocInit(WP_U32 heapSize, void **res_private_heap)
{
/* Determine the starting address from the heap. */
   WP_U32 WPL_heapBaseAddress =
      PHYS_TO_KSEG0(wpl_bus_mappings[WP_BUS_HOST].actual_start +
               wpl_bus_mappings[WP_BUS_HOST].size);

   memset(&theHeaps[PRIVATE], 0, sizeof(wpl_heapinfo));

   WPLI_HeapSizing(&theHeaps[PRIVATE], (void *) WPL_heapBaseAddress,
                  (void *) (WPL_heapBaseAddress + heapSize));

   theHeaps[PRIVATE].pool_pginfo = &private_pginfo[0];
   theHeaps[PRIVATE].pool_pgfree = &private_pgfree[0];
   theHeaps[PRIVATE].page_dir = &private_page_dir[0];

   *res_private_heap = (void *) &theHeaps[PRIVATE];
   WPLI_HeapInit((wpl_heapinfo *)(*res_private_heap));

   return;
}
Exemplo n.º 2
0
/*ARGSUSED*/
int
mmrw(dev_t dev, struct uio *uio, int flags)
{
	struct iovec *iov;
	int error = 0, c;
	vaddr_t v;

	while (uio->uio_resid > 0 && error == 0) {
		iov = uio->uio_iov;
		if (iov->iov_len == 0) {
			uio->uio_iov++;
			uio->uio_iovcnt--;
			if (uio->uio_iovcnt < 0)
				panic("mmrw");
			continue;
		}
		switch (minor(dev)) {

/* minor device 0 is physical memory */
		case 0:
			v = uio->uio_offset;
			c = iov->iov_len;
			if (v + c > ctob(physmem))
				return (EFAULT);
			v = (vaddr_t)PHYS_TO_KSEG0(v);
			error = uiomove((caddr_t)v, c, uio);
			continue;

/* minor device 1 is kernel memory */
		case 1:
			v = uio->uio_offset;
			c = min(iov->iov_len, MAXPHYS);
			if ((v > KSEG0_BASE && v + c <= KSEG0_BASE + ctob(physmem)) ||
			    uvm_kernacc((caddr_t)v, c,
			    uio->uio_rw == UIO_READ ? B_READ : B_WRITE)) {
				error = uiomove((caddr_t)v, c, uio);
				continue;
			} else {
				return (EFAULT);
			}

/* minor device 2 is EOF/RATHOLE */
		case 2:
			if (uio->uio_rw == UIO_WRITE)
				uio->uio_resid = 0;
			return (0);

/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
		case 12:
			if (uio->uio_rw == UIO_WRITE) {
				c = iov->iov_len;
				break;
			}
			if (zeropage == NULL) {
				zeropage = (caddr_t)
				    malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
				bzero(zeropage, PAGE_SIZE);
			}
			c = min(iov->iov_len, PAGE_SIZE);
			error = uiomove(zeropage, c, uio);
			continue;

		default:
			return (ENODEV);
		}
		if (error)
			break;
		iov->iov_base += c;
		iov->iov_len -= c;
		uio->uio_offset += c;
		uio->uio_resid -= c;
	}
	return error;
}