2019-06-03 13:44:50 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-03-05 19:49:29 +08:00
|
|
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
|
2022-06-07 20:50:26 +08:00
|
|
|
bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot)
|
2012-03-05 19:49:29 +08:00
|
|
|
{
|
2022-06-07 20:50:26 +08:00
|
|
|
unsigned long last_addr = phys_addr + size - 1;
|
2012-03-05 19:49:29 +08:00
|
|
|
|
2022-06-07 20:50:26 +08:00
|
|
|
/* Don't allow outside PHYS_MASK */
|
|
|
|
if (last_addr & ~PHYS_MASK)
|
|
|
|
return false;
|
2012-03-05 19:49:29 +08:00
|
|
|
|
2022-06-07 20:50:26 +08:00
|
|
|
/* Don't allow RAM to be mapped. */
|
2021-07-01 09:51:19 +08:00
|
|
|
if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr))))
|
2022-06-07 20:50:26 +08:00
|
|
|
return false;
|
2013-10-24 22:54:17 +08:00
|
|
|
|
2022-06-07 20:50:26 +08:00
|
|
|
return true;
|
2013-10-24 22:54:17 +08:00
|
|
|
}
|
2014-04-08 06:39:52 +08:00
|
|
|
|
2014-11-22 05:50:42 +08:00
|
|
|
/*
|
|
|
|
* Must be called after early_fixmap_init
|
|
|
|
*/
|
2014-04-08 06:39:52 +08:00
|
|
|
void __init early_ioremap_init(void)
|
|
|
|
{
|
|
|
|
early_ioremap_setup();
|
|
|
|
}
|
2022-05-10 08:34:28 +08:00
|
|
|
|
|
|
|
bool arch_memremap_can_ram_remap(resource_size_t offset, size_t size,
|
|
|
|
unsigned long flags)
|
|
|
|
{
|
|
|
|
unsigned long pfn = PHYS_PFN(offset);
|
|
|
|
|
|
|
|
return pfn_is_map_memory(pfn);
|
|
|
|
}
|