Changeset 50 for trunk/kernel/mm/ppm.h
- Timestamp:
- Jun 26, 2017, 3:15:11 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/ppm.h
r18 r50 32 32 #include <page.h> 33 33 34 #define PPM_SIGNATURE 0xBABEF00D35 34 36 35 /***************************************************************************************** 37 36 * 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. 42 53 * This low-level allocator implements the buddy algorithm: an allocated block is 43 * isan 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. 44 55 ****************************************************************************************/ 56 45 57 typedef struct ppm_s 46 58 { 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 */ 49 60 list_entry_t free_pages_root[CONFIG_PPM_MAX_ORDER]; /*! roots of free lists */ 50 61 uint32_t free_pages_nr[CONFIG_PPM_MAX_ORDER]; /*! numbers of free pages */ 51 uint32_t total_free_pages; /*! total number of free pages */52 62 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 */ 57 65 list_entry_t dirty_root; /*! root of dirty pages list */ 66 void * vaddr_base; /*! pointer on local physical memory base */ 58 67 } 59 68 ppm_t; … … 80 89 * @ order : ln2( number of 4 Kbytes pages) 81 90 * @ returns a pointer on the page descriptor if success / NULL otherwise 82 ************************************************************************************** **/91 **************************************************************************************à))**/ 83 92 page_t * ppm_alloc_pages( uint32_t order ); 84 93 … … 93 102 94 103 /***************************************************************************************** 95 * This function check if a page descriptor is valid.104 * This function check if a page descriptor pointer is valid. 96 105 ***************************************************************************************** 97 106 * @ page : pointer on a page descriptor … … 101 110 102 111 /***************************************************************************************** 103 * Get the page baseaddress from the page descriptor pointer.112 * Get the page virtual address from the page descriptor pointer. 104 113 ***************************************************************************************** 105 114 * @ page : pointer to page descriptor 106 * @ returns page base address115 * @ returns virtual address of page itself. 107 116 ****************************************************************************************/ 108 inline void* ppm_page2 base( page_t * page );117 inline void* ppm_page2vaddr( page_t * page ); 109 118 110 119 /***************************************************************************************** 111 * Get the page descriptor pointer from the page baseaddress.120 * Get the page descriptor pointer from the page virtual address. 112 121 ***************************************************************************************** 113 * @ vaddr : page baseaddress122 * @ vaddr : page virtual address 114 123 * @ returns pointer on page descriptor 115 124 ****************************************************************************************/ 116 inline page_t * ppm_ base2page( void * vaddr );125 inline page_t * ppm_vaddr2page( void * vaddr ); 117 126 118 127 /***************************************************************************************** … … 133 142 134 143 /***************************************************************************************** 135 * Get the page baseaddress from the PPN.144 * Get the page virtual address from the PPN. 136 145 ***************************************************************************************** 137 146 * @ ppn : physical page number 138 * @ returns page base address147 * @ returns page virtual address. 139 148 ****************************************************************************************/ 140 inline void* ppm_ppn2 base( ppn_t ppn );149 inline void* ppm_ppn2vaddr( ppn_t ppn ); 141 150 142 151 /***************************************************************************************** 143 * Get the PPN from the page baseaddress.152 * Get the PPN from the page virtual address. 144 153 ***************************************************************************************** 145 * @ vaddr : page baseaddress146 * @ returns physical page number 154 * @ vaddr : page virtual address 155 * @ returns physical page number. 147 156 ****************************************************************************************/ 148 inline ppn_t ppm_ base2ppn( void * base );157 inline ppn_t ppm_vaddr2ppn( void * base ); 149 158 150 159 /*****************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.