Changeset ccc362a1 in mainline for kernel/arch/riscv64/src/mm/frame.c


Ignore:
Timestamp:
2017-08-21T18:46:34Z (7 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6c742f5e
Parents:
c16479e
Message:

riscv64: memory management routines, reflecting the latest Privileged Architecture specification (1.10)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/riscv64/src/mm/frame.c

    rc16479e rccc362a1  
    3232
    3333#include <mm/frame.h>
     34#include <arch/boot/boot.h>
    3435#include <arch/mm/frame.h>
     36#include <arch/drivers/ucb.h>
    3537#include <mm/as.h>
    3638#include <config.h>
     
    3941#include <align.h>
    4042#include <macros.h>
    41 
    4243#include <print.h>
    4344
    44 size_t hardcoded_unmapped_ktext_size = 0;
    45 size_t hardcoded_unmapped_kdata_size = 0;
     45uintptr_t physmem_start;
     46uintptr_t htif_frame;
     47uintptr_t pt_frame;
     48memmap_t memmap;
    4649
    4750void physmem_print(void)
     
    4952}
    5053
     54static void frame_common_arch_init(bool low)
     55{
     56        pfn_t minconf =
     57            max3(ADDR2PFN(physmem_start), htif_frame + 1, pt_frame + 1);
     58       
     59        for (size_t i = 0; i < memmap.cnt; i++) {
     60                /* To be safe, make the available zone possibly smaller */
     61                uintptr_t base = ALIGN_UP((uintptr_t) memmap.zones[i].start,
     62                    FRAME_SIZE);
     63                size_t size = ALIGN_DOWN(memmap.zones[i].size -
     64                    (base - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE);
     65               
     66                if (!frame_adjust_zone_bounds(low, &base, &size))
     67                        return;
     68               
     69                pfn_t pfn = ADDR2PFN(base);
     70                size_t count = SIZE2FRAMES(size);
     71                pfn_t conf;
     72               
     73                if (low) {
     74                        if ((minconf < pfn) || (minconf >= pfn + count))
     75                                conf = pfn;
     76                        else
     77                                conf = minconf;
     78                       
     79                        zone_create(pfn, count, conf,
     80                            ZONE_AVAILABLE | ZONE_LOWMEM);
     81                } else {
     82                        conf = zone_external_conf_alloc(count);
     83                        if (conf != 0)
     84                                zone_create(pfn, count, conf,
     85                                    ZONE_AVAILABLE | ZONE_HIGHMEM);
     86                }
     87        }
     88}
    5189
    5290void frame_low_arch_init(void)
    5391{
     92        frame_common_arch_init(true);
     93       
     94        frame_mark_unavailable(htif_frame, 1);
     95        frame_mark_unavailable(pt_frame, 1);
    5496}
    5597
    5698void frame_high_arch_init(void)
    5799{
     100        frame_common_arch_init(false);
    58101}
    59102
Note: See TracChangeset for help on using the changeset viewer.