source: trunk/kernel/mm/page.h @ 569

Last change on this file since 569 was 567, checked in by alain, 6 years ago

Complete restructuration of kernel locks.

File size: 6.7 KB
RevLine 
[1]1/*
2 * page.h - physical page descriptor and related operations
3 *
4 * Authors Ghassan Almalles (2008,2009,2010,2011,2012)
5 *         Alain Greiner    (2016)
6 *
7 * Copyright (c) UPMC Sorbonne Universites
8 *
9 * This file is part of ALMOS-MKH.
10 *
11 * ALMOS-MKH is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2.0 of the License.
14 *
15 * ALMOS-MKH is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#ifndef _PAGE_H_
26#define _PAGE_H_
27
[14]28#include <kernel_config.h>
[457]29#include <hal_kernel_types.h>
[567]30#include <remote_busylock.h>
[1]31#include <list.h>
32
33/***   Forward declarations   ***/
34
35struct mapper_s;
[18]36
[1]37/*************************************************************************************
38 * This  defines the flags that can be attached to a physical page.
[567]39 * TODO : the PG_BUFFER and PG_IO_ERR flags semantic is not defined
[1]40 ************************************************************************************/
41
42#define PG_INIT             0x0001     // page descriptor has been initialised
43#define PG_RESERVED         0x0002     // cannot be allocated by PPM
44#define PG_FREE             0x0004     // page can be allocated by PPM
[18]45#define PG_INLOAD           0x0008     // on-going load from disk
[567]46#define PG_IO_ERR           0x0010     // mapper signals access error    TODO ??? [AG]
47#define PG_BUFFER           0x0020     // used in blockio.c              TODO ??? [AG]
[1]48#define PG_DIRTY            0x0040     // page has been written
[567]49#define PG_COW          0x0080     // page is copy-on-write
[1]50
51#define PG_ALL          0xFFFF     // All flags
52
53/*************************************************************************************
54 * This structure defines a physical page descriptor.
[567]55 * The busylock is used to test/modify the forks counter.
56 * NOTE: Size is 44 bytes for a 32 bits core...
57 * TODO : the refcount use has to be clarified [AG]
[1]58 ************************************************************************************/
59
60typedef struct page_s
61{
[23]62    uint32_t          flags;          /*! flags defined above                  (4)  */
[68]63    uint32_t          order;          /*! log2( number of small pages)         (4)  */
[1]64    struct mapper_s * mapper;         /*! local pointer on associated mapper   (4)  */
65    uint32_t          index;          /*! page index in mapper                 (4)  */
[18]66        list_entry_t      list;           /*! for both dirty pages and free pages  (8)  */
[567]67        uint32_t          refcount;       /*! reference counter TODO ??? [AG]      (4)  */
[433]68        uint32_t          forks;          /*! number of pending forks              (4)  */
[567]69        remote_busylock_t lock;           /*! protect all accesses to page         (12) */
[1]70}
71page_t;
72
73/*************************************************************************************
74 * This function initializes one page descriptor.
[23]75 *************************************************************************************
[1]76 * @ page    : pointer to page descriptor
77 ************************************************************************************/
78inline void page_init( page_t * page );
79
80/*************************************************************************************
[23]81 * This function atomically set one or several flags in page descriptor flags.
82 *************************************************************************************
[1]83 * @ page    : pointer to page descriptor.
[18]84 * @ value   : all non zero bits in value will be set.
[1]85 ************************************************************************************/
86inline void page_set_flag( page_t   * page,
[23]87                           uint32_t   value );
[1]88
89/*************************************************************************************
[23]90 * This function atomically reset one or several flags in page descriptor flags.
91 *************************************************************************************
[1]92 * @ page    : pointer to page descriptor.
[18]93 * @ value   : all non zero bits in value will be cleared.
[1]94 ************************************************************************************/
95inline void page_clear_flag( page_t   * page,
[23]96                             uint32_t   value );
[1]97
98/*************************************************************************************
[22]99 * This function tests the value of one or several flags in page descriptor flags.
[23]100 *************************************************************************************
[1]101 * @ page    : pointer to page descriptor.
102 * @ value   : all non zero bits will be tested.
[18]103 * @ returns true if at least one non zero bit in value is set / false otherwise.
[1]104 ************************************************************************************/
105inline bool_t page_is_flag( page_t   * page,
[23]106                            uint32_t   value );
[1]107
108/*************************************************************************************
[22]109 * This function resets to 0 all bytes in a given page.
[23]110 *************************************************************************************
[1]111 * @ page     : pointer on page descriptor.
112 ************************************************************************************/
113void page_zero( page_t * page );
114
115/*************************************************************************************
[22]116 * This blocking function atomically increments the page refcount.
[23]117 *************************************************************************************
[1]118 * @ page     : pointer on page descriptor.
119 ************************************************************************************/
120inline void page_refcount_up( page_t * page );
121
122/*************************************************************************************
[22]123 * This blocking function atomically decrements the page refcount.
[23]124 *************************************************************************************
[1]125 * @ page     : pointer on page descriptor.
126 ************************************************************************************/
127inline void page_refcount_down( page_t * page );
128
129/*************************************************************************************
130 * This function display the values contained in a page descriptor.
[23]131 *************************************************************************************
132 * @ page     : pointer on page descriptor.
[1]133 ************************************************************************************/
134void page_print( page_t * page );
135
136
137#endif  /* _PAGE_H_ */
Note: See TracBrowser for help on using the repository browser.