Changeset 50 for trunk/kernel/mm/ppm.h


Ignore:
Timestamp:
Jun 26, 2017, 3:15:11 PM (7 years ago)
Author:
alain
Message:

bloup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/mm/ppm.h

    r18 r50  
    3232#include <page.h>
    3333
    34 #define  PPM_SIGNATURE     0xBABEF00D
    3534
    3635/*****************************************************************************************
    3736 * This structure defines the Physical Memory Manager in a cluster.
    38  * In all clusters, the physical memory bank starts at address 0.
    39  * The segments kcode and kdata are mapped in the first "offset" pages.
    40  * The physical page descriptors array is implemented just after this offset zone.
    41  * The main service provided by the PMM is the dynamic allocation of physical pages.
     37 * In all clusters, the physical memory bank starts at local physical address 0.
     38 * The size of this local physical memory is defined by the <pages_nr> field in the
     39 * boot_info structure. It is split in three parts:
     40 * - the "kernel_code" section contains the kernel code, loaded by the boot-loader.
     41 *   It starts at PPN = 0 and the size is defined by the <pages_offset> field in the
     42 *   boot_info structure.
     43 * - the "pages_tbl" section contains the physical page descriptors array. It starts
     44 *   at PPN = pages_offset, and it contains one entry per small physical page in cluster.
     45 *   It is created and initialized by the hal_ppm_create() function. "the
     46 * - The "kernel_heap" section contains all physical pages that are are not in the
     47 *   in the kernel_code and pages_tbl sections, and that have not been reserved by the
     48 *   architecture specific bootloader. The reserved pages are defined in the boot_info
     49 *   structure.
     50 *
     51 * The main service provided by the PMM is the dynamic allocation of physical pages
     52 * from the "kernel_heap" section.
    4253 * This low-level allocator implements the buddy algorithm: an allocated block is
    43  * is an integer number n of 4 Kbytes pages, and n (called order) is a power of 2.
     54 * an integer number n of 4 Kbytes pages, and n (called order) is a power of 2.
    4455 ****************************************************************************************/
     56
    4557typedef struct ppm_s
    4658{
    47         uint32_t       signature;               /*! set when initialised                    */
    48         spinlock_t     free_lock;               /*! lock protecting free_pages[] array      */
     59        spinlock_t     free_lock;               /*! lock protecting free_pages[] lists      */
    4960        list_entry_t   free_pages_root[CONFIG_PPM_MAX_ORDER];  /*! roots of free lists      */
    5061        uint32_t       free_pages_nr[CONFIG_PPM_MAX_ORDER];    /*! numbers of free pages    */
    51     uint32_t       total_free_pages;        /*! total number of free pages              */
    5262        page_t       * pages_tbl;               /*! pointer on page descriptors array       */
    53         uint32_t       pages_nr;                /*! total number of 4 Kbytes physical page  */
    54     uint32_t       pages_offset;            /*! allocated pages for kcode & kdata       */
    55     uint32_t       pages_desc;              /*! allocated pages for pages_tbl[] array   */
    56     spinlock_t     dirty_lock;              /*! lock protecting the dirty list          */
     63        uint32_t       pages_nr;                /*! total number of small physical page     */
     64    spinlock_t     dirty_lock;              /*! lock protecting the dirty pages list    */
    5765    list_entry_t   dirty_root;              /*! root of dirty pages list                */
     66    void         * vaddr_base;              /*! pointer on local physical memory base   */
    5867}
    5968ppm_t;
     
    8089 * @ order        : ln2( number of 4 Kbytes pages)
    8190 * @ returns a pointer on the page descriptor if success / NULL otherwise
    82  ****************************************************************************************/
     91 **************************************************************************************à))**/
    8392page_t * ppm_alloc_pages( uint32_t order );
    8493
     
    93102
    94103/*****************************************************************************************
    95  * This function check if a page descriptor is valid.
     104 * This function check if a page descriptor pointer is valid.
    96105 *****************************************************************************************
    97106 * @ page         : pointer on a page descriptor
     
    101110
    102111/*****************************************************************************************
    103  * Get the page base address from the page descriptor pointer.
     112 * Get the page virtual address from the page descriptor pointer.
    104113 *****************************************************************************************
    105114 * @ page         : pointer to page descriptor
    106  * @ returns page base address
     115 * @ returns virtual address of page itself.
    107116 ****************************************************************************************/
    108 inline void* ppm_page2base( page_t * page );
     117inline void* ppm_page2vaddr( page_t * page );
    109118
    110119/*****************************************************************************************
    111  * Get the page descriptor pointer from the page base address.
     120 * Get the page descriptor pointer from the page virtual address.
    112121 *****************************************************************************************
    113  * @ vaddr        : page base address
     122 * @ vaddr        : page virtual address
    114123 * @ returns pointer on page descriptor
    115124 ****************************************************************************************/
    116 inline page_t * ppm_base2page( void * vaddr );
     125inline page_t * ppm_vaddr2page( void * vaddr );
    117126
    118127/*****************************************************************************************
     
    133142
    134143/*****************************************************************************************
    135  * Get the page base address from the PPN.
     144 * Get the page virtual address from the PPN.
    136145 *****************************************************************************************
    137146 * @ ppn          : physical page number
    138  * @ returns page base address
     147 * @ returns page virtual address.
    139148 ****************************************************************************************/
    140 inline void* ppm_ppn2base( ppn_t ppn );
     149inline void* ppm_ppn2vaddr( ppn_t ppn );
    141150
    142151/*****************************************************************************************
    143  * Get the PPN from the page base address.
     152 * Get the PPN from the page virtual address.
    144153 *****************************************************************************************
    145  * @ vaddr        : page base address
    146  * @ returns physical page number
     154 * @ vaddr        : page virtual address
     155 * @ returns physical page number.
    147156 ****************************************************************************************/
    148 inline ppn_t ppm_base2ppn( void * base );
     157inline ppn_t ppm_vaddr2ppn( void * base );
    149158
    150159/*****************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.