[OpenBIOS] [PATCH] SPARC32: fix up obp_dumb_mmap() and obp_dumb_munmap()
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Fri Apr 21 00:46:31 CEST 2017
On 18/04/17 10:07, Mark Cave-Ayland wrote:
> obp_dumb_mmap() needs to call ofmem_map() rather than the low-level
> ofmem_arch_map_pages() function otherwise the specified area is mapped directly
> on the CPU without being recorded in the relevant memory node properties.
>
> This fixes Solaris 2.6 which uses obp_dumb_mmap() to map the kernel msgbuf and
> would otherwise trap on boot as the mapping was lost once the kernel had taken
> over memory management from OpenBIOS.
>
> While we're here, add a missing DPRINTF() to obp_dumb_mmap() and provide the
> corresponding obp_dumb_munmap() implementation.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
> ---
> arch/sparc32/lib.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/arch/sparc32/lib.c b/arch/sparc32/lib.c
> index d27b604..a53a396 100644
> --- a/arch/sparc32/lib.c
> +++ b/arch/sparc32/lib.c
> @@ -196,15 +196,25 @@ char *obp_dumb_mmap(char *va, int which_io, unsigned int pa,
> unsigned int size)
> {
> uint64_t mpa = ((uint64_t)which_io << 32) | (uint64_t)pa;
> + ucell virt;
> +
> + DPRINTF("obp_dumb_mmap: virta 0x%x, phys 0x%x, size %d\n", (unsigned int)va, pa, size);
> +
> + /* Claim virtual memory */
> + virt = ofmem_claim_virt(pointer2cell(va), size, 0);
>
> - ofmem_arch_map_pages(mpa, (unsigned long)va, size, ofmem_arch_default_translation_mode(mpa));
> - return va;
> + /* Map memory */
> + ofmem_map(mpa, virt, size, ofmem_arch_default_translation_mode(mpa));
> +
> + return cell2pointer(virt);
> }
>
> -void obp_dumb_munmap(__attribute__((unused)) char *va,
> - __attribute__((unused)) unsigned int size)
> +void obp_dumb_munmap(char *va, unsigned int size)
> {
> DPRINTF("obp_dumb_munmap: virta 0x%x, sz %d\n", (unsigned int)va, size);
> +
> + ofmem_unmap(pointer2cell(va), size);
> + ofmem_release_virt(pointer2cell(va), size);
> }
>
> char *obp_memalloc(char *va, unsigned int size, unsigned int align)
Applied to git master.
ATB,
Mark.
More information about the OpenBIOS
mailing list