1 // Copyright 2017 The Fuchsia Authors 2 // 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file or at 5 // https://opensource.org/licenses/MIT 6 #pragma once 7 #include <iovec.h> 8 #include <sys/types.h> 9 #include <vm/pmm.h> 10 #include <zircon/types.h> 11 12 __BEGIN_CDECLS 13 // This library exists to calculate memory ranges to be used as arenas 14 // for the pmm based on a predefined memory limit. The limit is passed in 15 // MB via the kernel.memory-limit-mb cmdline argument. The library will 16 // calculate memory arenas based on provided ranges, reserved boot regions, 17 // and the limit provided and add those to the system when 18 // memory_limit_add_arenas is called. 19 // 20 // Checks if a memory limit exists and initializes the lib bookkeeping. 21 // 22 // Returns ZX_OK on success, ZX_ERR_BAD_STATE if already initialized, or 23 // ERR_NOT_SUPPORTED if no memory limit was passed via kernel.memory-limit-mb 24 zx_status_t memory_limit_init(); 25 26 // Adds a given range of memory to the memory allocator to use in 27 // sorting out memory arenas. 28 // 29 // @range_base: the start address of the range. 30 // @range_size: size of the range in bytes 31 // @arena_template: a structure containing the default values for flags, 32 // priority, and name used for arenas created by this function in the 33 // event of any failure conditions. 34 // 35 // Returns ZX_OK on completion, and ZX_ERR_INVALID_ARGS if parameters are 36 // invalid 37 zx_status_t memory_limit_add_range(uintptr_t range_base, 38 size_t range_size, 39 pmm_arena_info_t arena_template); 40 41 // Uses the ranges provided by memory_limit_add_range to calculate the 42 // acceptable memory arenas to fit within our imposed memory limitations 43 // while still including all required reserved boot regions. 44 // 45 // @arena_template: a structure containing the default values for flags, 46 // priority, and name used for arenas created by this function in the 47 // event of any failure conditions. 48 zx_status_t memory_limit_add_arenas(pmm_arena_info_t arena_template); 49 50 __END_CDECLS 51