Exemplo n.º 1
0
/*
 * Map a set of physical memory pages into the kernel virtual address space.
 * Return a pointer to where it is mapped.
 *
 * This uses a pre-established static mapping if one exists for the requested
 * range, otherwise it allocates kva space and maps the physical pages into it.
 *
 * This routine is intended to be used for mapping device memory, NOT real
 * memory; the mapping type is inherently VM_MEMATTR_DEVICE in
 * pmap_kenter_device().
 */
void *
pmap_mapdev(vm_offset_t pa, vm_size_t size)
{
	vm_offset_t va, offset;
	void * rva;

	/* First look in the static mapping table. */
	if ((rva = arm_devmap_ptov(pa, size)) != NULL)
		return (rva);

	offset = pa & PAGE_MASK;
	pa = trunc_page(pa);
	size = round_page(size + offset);

#ifdef __aarch64__
	if (early_boot) {
		akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size);
		va = akva_devmap_vaddr;
		KASSERT(va >= VM_MAX_KERNEL_ADDRESS - L2_SIZE,
		    ("Too many early devmap mappings"));
	} else
#endif
		va = kva_alloc(size);
	if (!va)
		panic("pmap_mapdev: Couldn't alloc kernel virtual memory");

	pmap_kenter_device(va, size, pa);

	return ((void *)(va + offset));
}
Exemplo n.º 2
0
/*
 * This code which manipulates the watchdog hardware is here to implement
 * cpu_reset() because the watchdog is the only way for software to reset the
 * chip.  Why here and not in imx_wdog.c?  Because there's no requirement that
 * the watchdog driver be compiled in, but it's nice to be able to reboot even
 * if it's not.
 */
void
imx_wdog_cpu_reset(vm_offset_t wdcr_physaddr)
{
	volatile uint16_t * pcr;

	/*
	 * The deceptively simple write of WDOG_CR_WDE enables the watchdog,
	 * sets the timeout to its minimum value (half a second), and also
	 * clears the SRS bit which results in the SFTW (software-requested
	 * reset) bit being set in the watchdog status register after the reset.
	 * This is how software can distinguish a reset from a wdog timeout.
	 */
	if ((pcr = arm_devmap_ptov(wdcr_physaddr, sizeof(*pcr))) == NULL) {
		printf("cpu_reset() can't find its control register... locking up now.");
	} else {
		*pcr = WDOG_CR_WDE;
	}
	for (;;)
		continue;
}