SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /sos/physmem.c (Article 4) and /sos/physmem.c (Article 7)


001 /* Copyright (C) 2004  David Decotigny            001 /* Copyright (C) 2004  David Decotigny
                                                   >> 002    Copyright (C) 2000  The KOS Team
002                                                   003 
003    This program is free software; you can redi    004    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU Genera    005    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundatio    006    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any lat    007    of the License, or (at your option) any later version.
007                                                   008    
008    This program is distributed in the hope tha    009    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the     010    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR    011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details    012    GNU General Public License for more details.
012                                                   013    
013    You should have received a copy of the GNU     014    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to t    015    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 3    016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA.                                           017    USA. 
017 */                                                018 */
018 #include <sos/list.h>                             019 #include <sos/list.h>
019 #include <sos/macros.h>                           020 #include <sos/macros.h>
020 #include <sos/assert.h>                           021 #include <sos/assert.h>
021 #include <sos/klibc.h>                            022 #include <sos/klibc.h>
022                                                   023 
023 #include "physmem.h"                              024 #include "physmem.h"
024                                                   025 
025 /** A descriptor for a physical page in SOS */    026 /** A descriptor for a physical page in SOS */
026 struct physical_page_descr                        027 struct physical_page_descr
027 {                                                 028 {
028   /** The physical base address for the page *    029   /** The physical base address for the page */
029   sos_paddr_t paddr;                              030   sos_paddr_t paddr;
030                                                   031 
031   /** The reference count for this physical pa    032   /** The reference count for this physical page. > 0 means that the
032      page is in the used list. */              !! 033      page is in the nonfree list. */
033   sos_count_t ref_cnt;                            034   sos_count_t ref_cnt;
034                                                   035 
035   /** The other pages on the list (used, free) !! 036   /**
                                                   >> 037    * An additional counter for user-defined use. The management of this
                                                   >> 038    * counter is up to the user, however a simple set of rules applies:
                                                   >> 039    *   - it can only be incremented/decremented if the page is referenced
                                                   >> 040    *   - when it reaches 0, no automatic action is taken
                                                   >> 041    * The first rule means in particular that a page whose reference
                                                   >> 042    * count reaches 0 (=> will be freed) cannot have a custom_count
                                                   >> 043    * value > 0 ! The system will be HALTED if this ever happens
                                                   >> 044    */
                                                   >> 045   sos_count_t occupation_cnt;
                                                   >> 046 
                                                   >> 047 
                                                   >> 048   /** Some data associated with the page when it is mapped in kernel space */
                                                   >> 049   struct sos_kmem_range *kernel_range;
                                                   >> 050 
                                                   >> 051   /** The other pages on the list (nonfree, free) */
036   struct physical_page_descr *prev, *next;        052   struct physical_page_descr *prev, *next;
037 };                                                053 };
038                                                   054 
039 /** These are some markers present in the exec    055 /** These are some markers present in the executable file (see sos.lds) */
040 extern char __b_kernel, __e_kernel;               056 extern char __b_kernel, __e_kernel;
041                                                   057 
042 /** The array of ppage descriptors will be loc    058 /** The array of ppage descriptors will be located at this address */
043 #define PAGE_DESCR_ARRAY_ADDR \                   059 #define PAGE_DESCR_ARRAY_ADDR \
044   SOS_PAGE_ALIGN_SUP((sos_paddr_t) (& __e_kern    060   SOS_PAGE_ALIGN_SUP((sos_paddr_t) (& __e_kernel))
045 static struct physical_page_descr * physical_p    061 static struct physical_page_descr * physical_page_descr_array;
046                                                   062 
047 /** The list of physical pages currently avail    063 /** The list of physical pages currently available */
048 static struct physical_page_descr *free_ppage;    064 static struct physical_page_descr *free_ppage;
049                                                   065 
050 /** The list of physical pages currently in us !! 066 /** The list of physical pages currently allocated */
051 static struct physical_page_descr *used_ppage; !! 067 static struct physical_page_descr *nonfree_ppage;
052                                                   068 
053 /** We will store here the interval of valid p    069 /** We will store here the interval of valid physical addresses */
054 static sos_paddr_t physmem_base, physmem_top;     070 static sos_paddr_t physmem_base, physmem_top;
055                                                   071 
056 /** We store the number of pages used/free */  !! 072 /** We store the number of pages nonfree/free */
057 static sos_count_t physmem_total_pages, physme !! 073 static sos_count_t physmem_total_pages, physmem_nonfree_pages;
058                                                   074 
059 sos_ret_t sos_physmem_setup(sos_size_t ram_siz !! 075 sos_ret_t sos_physmem_subsystem_setup(sos_size_t ram_size,
060                             /* out */sos_paddr !! 076                                       /* out */sos_paddr_t *kernel_core_base,
061                             /* out */sos_paddr !! 077                                       /* out */sos_paddr_t *kernel_core_top)
062 {                                                 078 {
063   /* The iterator over the page descriptors */    079   /* The iterator over the page descriptors */
064   struct physical_page_descr *ppage_descr;        080   struct physical_page_descr *ppage_descr;
065                                                   081 
066   /* The iterator over the physical addresses     082   /* The iterator over the physical addresses */
067   sos_paddr_t ppage_addr;                         083   sos_paddr_t ppage_addr;
068                                                   084 
069   /* Make sure ram size is aligned on a page b    085   /* Make sure ram size is aligned on a page boundary */
070   ram_size = SOS_PAGE_ALIGN_INF(ram_size);/* Y    086   ram_size = SOS_PAGE_ALIGN_INF(ram_size);/* Yes, we may lose at most a page */
071                                                   087 
072   /* Reset the used/free page lists before bui !! 088   /* Reset the nonfree/free page lists before building them */
073   free_ppage = used_ppage = NULL;              !! 089   free_ppage = nonfree_ppage = NULL;
074   physmem_total_pages = physmem_used_pages = 0 !! 090   physmem_total_pages = physmem_nonfree_pages = 0;
075                                                   091 
076   /* Make sure that there is enough memory to     092   /* Make sure that there is enough memory to store the array of page
077      descriptors */                               093      descriptors */
078   *kernel_core_base = SOS_PAGE_ALIGN_INF((sos_    094   *kernel_core_base = SOS_PAGE_ALIGN_INF((sos_paddr_t)(& __b_kernel));
079   *kernel_core_top                                095   *kernel_core_top
080     = PAGE_DESCR_ARRAY_ADDR                       096     = PAGE_DESCR_ARRAY_ADDR
081       + SOS_PAGE_ALIGN_SUP( (ram_size >> SOS_P    097       + SOS_PAGE_ALIGN_SUP( (ram_size >> SOS_PAGE_SHIFT)
082                             * sizeof(struct ph    098                             * sizeof(struct physical_page_descr));
083   if (*kernel_core_top > ram_size)                099   if (*kernel_core_top > ram_size)
084     return -SOS_ENOMEM;                           100     return -SOS_ENOMEM;
085                                                   101 
086   /* Page 0-4kB is not available in order to r    102   /* Page 0-4kB is not available in order to return address 0 as a
087      means to signal "no page available" */       103      means to signal "no page available" */
088   physmem_base = SOS_PAGE_SIZE;                   104   physmem_base = SOS_PAGE_SIZE;
089   physmem_top  = ram_size;                        105   physmem_top  = ram_size;
090                                                   106 
091   /* Setup the page descriptor arrray */          107   /* Setup the page descriptor arrray */
092   physical_page_descr_array                       108   physical_page_descr_array
093     = (struct physical_page_descr*)PAGE_DESCR_    109     = (struct physical_page_descr*)PAGE_DESCR_ARRAY_ADDR;
094                                                   110 
095   /* Scan the list of physical pages */           111   /* Scan the list of physical pages */
096   for (ppage_addr = 0,                            112   for (ppage_addr = 0,
097          ppage_descr = physical_page_descr_arr    113          ppage_descr = physical_page_descr_array ;
098        ppage_addr < physmem_top ;                 114        ppage_addr < physmem_top ;
099        ppage_addr += SOS_PAGE_SIZE,               115        ppage_addr += SOS_PAGE_SIZE,
100          ppage_descr ++)                          116          ppage_descr ++)
101     {                                             117     {
102       enum { PPAGE_MARK_RESERVED, PPAGE_MARK_F    118       enum { PPAGE_MARK_RESERVED, PPAGE_MARK_FREE,
103              PPAGE_MARK_KERNEL, PPAGE_MARK_HWM    119              PPAGE_MARK_KERNEL, PPAGE_MARK_HWMAP } todo;
104                                                   120 
105       memset(ppage_descr, 0x0, sizeof(struct p    121       memset(ppage_descr, 0x0, sizeof(struct physical_page_descr));
106                                                   122 
107       /* Init the page descriptor for this pag    123       /* Init the page descriptor for this page */
108       ppage_descr->paddr = ppage_addr;            124       ppage_descr->paddr = ppage_addr;
109                                                   125 
110       /* Reserved : 0 ... base */                 126       /* Reserved : 0 ... base */
111       if (ppage_addr < physmem_base)              127       if (ppage_addr < physmem_base)
112         todo = PPAGE_MARK_RESERVED;               128         todo = PPAGE_MARK_RESERVED;
113                                                   129 
114       /* Free : base ... BIOS */                  130       /* Free : base ... BIOS */
115       else if ((ppage_addr >= physmem_base)       131       else if ((ppage_addr >= physmem_base)
116                && (ppage_addr < BIOS_N_VIDEO_S    132                && (ppage_addr < BIOS_N_VIDEO_START))
117         todo = PPAGE_MARK_FREE;                   133         todo = PPAGE_MARK_FREE;
118                                                   134 
119       /* Used : BIOS */                           135       /* Used : BIOS */
120       else if ((ppage_addr >= BIOS_N_VIDEO_STA    136       else if ((ppage_addr >= BIOS_N_VIDEO_START)
121                && (ppage_addr < BIOS_N_VIDEO_E    137                && (ppage_addr < BIOS_N_VIDEO_END))
122         todo = PPAGE_MARK_HWMAP;                  138         todo = PPAGE_MARK_HWMAP;
123                                                   139 
124       /* Free : BIOS ... kernel */                140       /* Free : BIOS ... kernel */
125       else if ((ppage_addr >= BIOS_N_VIDEO_END    141       else if ((ppage_addr >= BIOS_N_VIDEO_END)
126                && (ppage_addr < (sos_paddr_t)     142                && (ppage_addr < (sos_paddr_t) (& __b_kernel)))
127         todo = PPAGE_MARK_FREE;                   143         todo = PPAGE_MARK_FREE;
128                                                   144 
129       /* Used : Kernel code/data/bss + physcal    145       /* Used : Kernel code/data/bss + physcal page descr array */
130       else if ((ppage_addr >= *kernel_core_bas    146       else if ((ppage_addr >= *kernel_core_base)
131                 && (ppage_addr < *kernel_core_    147                 && (ppage_addr < *kernel_core_top))
132         todo = PPAGE_MARK_KERNEL;                 148         todo = PPAGE_MARK_KERNEL;
133                                                   149 
134       /* Free : first page of descr ... end of    150       /* Free : first page of descr ... end of RAM */
135       else                                        151       else
136         todo = PPAGE_MARK_FREE;                   152         todo = PPAGE_MARK_FREE;
137                                                   153 
138       /* Actually does the insertion in the us !! 154       /* Actually does the insertion in the nonfree/free page lists */
139       physmem_total_pages ++;                     155       physmem_total_pages ++;
140       switch (todo)                               156       switch (todo)
141         {                                         157         {
142         case PPAGE_MARK_FREE:                     158         case PPAGE_MARK_FREE:
143           ppage_descr->ref_cnt = 0;               159           ppage_descr->ref_cnt = 0;
144           list_add_head(free_ppage, ppage_desc    160           list_add_head(free_ppage, ppage_descr);
145           break;                                  161           break;
146                                                   162 
147         case PPAGE_MARK_KERNEL:                   163         case PPAGE_MARK_KERNEL:
148         case PPAGE_MARK_HWMAP:                    164         case PPAGE_MARK_HWMAP:
149           ppage_descr->ref_cnt = 1;               165           ppage_descr->ref_cnt = 1;
150           list_add_head(used_ppage, ppage_desc !! 166           list_add_head(nonfree_ppage, ppage_descr);
151           physmem_used_pages ++;               !! 167           physmem_nonfree_pages ++;
152           break;                                  168           break;
153                                                   169 
154         default:                                  170         default:
155           /* Reserved page: nop */                171           /* Reserved page: nop */
156           break;                                  172           break;
157         }                                         173         }
158     }                                             174     }
159                                                   175 
160   return SOS_OK;                                  176   return SOS_OK;
161 }                                                 177 }
162                                                   178 
163                                                   179 
164 sos_paddr_t sos_physmem_ref_physpage_new(sos_b    180 sos_paddr_t sos_physmem_ref_physpage_new(sos_bool_t can_block)
165 {                                                 181 {
166   struct physical_page_descr *ppage_descr;        182   struct physical_page_descr *ppage_descr;
167                                                   183 
168   if (! free_ppage)                               184   if (! free_ppage)
169     return (sos_paddr_t)NULL;                     185     return (sos_paddr_t)NULL;
170                                                   186 
171   /* Retrieve a page in the free list */          187   /* Retrieve a page in the free list */
172   ppage_descr = list_pop_head(free_ppage);        188   ppage_descr = list_pop_head(free_ppage);
173                                                   189 
174   /* The page is assumed not to be already use !! 190   /* The page is assumed not to be already in the nonfree list */
175   SOS_ASSERT_FATAL(ppage_descr->ref_cnt == 0);    191   SOS_ASSERT_FATAL(ppage_descr->ref_cnt == 0);
176                                                   192 
177   /* Mark the page as used (this of course set !! 193   /* Mark the page as nonfree (this of course sets the ref count to 1) */
178   ppage_descr->ref_cnt ++;                        194   ppage_descr->ref_cnt ++;
179                                                   195 
180   /* Put the page in the used list */          !! 196   /* The page descriptor should be unmodified since previous
181   list_add_tail(used_ppage, ppage_descr);      !! 197      deallocation. Otherwise this means that something unauthorized
182   physmem_used_pages ++;                       !! 198      overwrote the page descriptor table contents ! */
                                                   >> 199   SOS_ASSERT_FATAL(ppage_descr->occupation_cnt == 0);
                                                   >> 200   SOS_ASSERT_FATAL(ppage_descr->kernel_range == NULL);
                                                   >> 201   
                                                   >> 202   /* Put the page in the nonfree list */
                                                   >> 203   list_add_tail(nonfree_ppage, ppage_descr);
                                                   >> 204   physmem_nonfree_pages ++;
183                                                   205 
184   return ppage_descr->paddr;                      206   return ppage_descr->paddr;
185 }                                                 207 }
186                                                   208 
187                                                   209 
188 /**                                               210 /**
189  * Helper function to get the physical page de    211  * Helper function to get the physical page descriptor for the given
190  * physical page address.                         212  * physical page address.
191  *                                                213  *
192  * @return NULL when out-of-bounds or non-page    214  * @return NULL when out-of-bounds or non-page-aligned
193  */                                               215  */
194 inline static struct physical_page_descr *        216 inline static struct physical_page_descr *
195 get_page_descr_at_paddr(sos_paddr_t ppage_padd    217 get_page_descr_at_paddr(sos_paddr_t ppage_paddr)
196 {                                                 218 {
197   /* Don't handle non-page-aligned addresses *    219   /* Don't handle non-page-aligned addresses */
198   if (ppage_paddr & SOS_PAGE_MASK)                220   if (ppage_paddr & SOS_PAGE_MASK)
199     return NULL;                                  221     return NULL;
200                                                   222   
201   /* Don't support out-of-bounds requests */      223   /* Don't support out-of-bounds requests */
202   if ((ppage_paddr < physmem_base) || (ppage_p    224   if ((ppage_paddr < physmem_base) || (ppage_paddr >= physmem_top))
203     return NULL;                                  225     return NULL;
204                                                   226 
205   return physical_page_descr_array + (ppage_pa    227   return physical_page_descr_array + (ppage_paddr >> SOS_PAGE_SHIFT);
206 }                                                 228 }
207                                                   229 
208                                                   230 
209 sos_ret_t sos_physmem_ref_physpage_at(sos_padd    231 sos_ret_t sos_physmem_ref_physpage_at(sos_paddr_t ppage_paddr)
210 {                                                 232 {
211   struct physical_page_descr *ppage_descr         233   struct physical_page_descr *ppage_descr
212     = get_page_descr_at_paddr(ppage_paddr);       234     = get_page_descr_at_paddr(ppage_paddr);
213                                                   235 
214   if (! ppage_descr)                              236   if (! ppage_descr)
215     return -SOS_EINVAL;                           237     return -SOS_EINVAL;
216                                                   238 
217   /* Increment the reference count for the pag    239   /* Increment the reference count for the page */
218   ppage_descr->ref_cnt ++;                        240   ppage_descr->ref_cnt ++;
219                                                   241 
220   /* If the page is newly referenced (ie we ar    242   /* If the page is newly referenced (ie we are the only owners of the
221      page => ref cnt == 1), transfer it in the !! 243      page => ref cnt == 1), transfer it in the nonfree pages list */
222   if (ppage_descr->ref_cnt == 1)                  244   if (ppage_descr->ref_cnt == 1)
223     {                                             245     {
                                                   >> 246       /* The page descriptor should be unmodified since previous
                                                   >> 247          deallocation. Otherwise this means that something unauthorized
                                                   >> 248          overwrote the page descriptor table contents ! */
                                                   >> 249       SOS_ASSERT_FATAL(ppage_descr->occupation_cnt == 0);
                                                   >> 250       SOS_ASSERT_FATAL(ppage_descr->kernel_range == NULL);
                                                   >> 251       
224       list_delete(free_ppage, ppage_descr);       252       list_delete(free_ppage, ppage_descr);
225       list_add_tail(used_ppage, ppage_descr);  !! 253       list_add_tail(nonfree_ppage, ppage_descr);
226       physmem_used_pages ++;                   !! 254       physmem_nonfree_pages ++;
227                                                   255 
228       /* The page is newly referenced */          256       /* The page is newly referenced */
229       return FALSE;                               257       return FALSE;
230     }                                             258     }
231                                                !! 259   
232   /* The page was already referenced by someon    260   /* The page was already referenced by someone */
233   return TRUE;                                    261   return TRUE;
234 }                                                 262 }
235                                                   263 
236                                                   264 
237 sos_ret_t                                         265 sos_ret_t
238 sos_physmem_unref_physpage(sos_paddr_t ppage_p    266 sos_physmem_unref_physpage(sos_paddr_t ppage_paddr)
239 {                                                 267 {
240   /* By default the return value indicates tha    268   /* By default the return value indicates that the page is still
241      used */                                      269      used */
242   sos_ret_t retval = FALSE;                       270   sos_ret_t retval = FALSE;
243                                                   271 
244   struct physical_page_descr *ppage_descr         272   struct physical_page_descr *ppage_descr
245     = get_page_descr_at_paddr(ppage_paddr);       273     = get_page_descr_at_paddr(ppage_paddr);
246                                                   274 
247   if (! ppage_descr)                              275   if (! ppage_descr)
248     return -SOS_EINVAL;                           276     return -SOS_EINVAL;
249                                                   277 
250   /* Don't do anything if the page is not in t !! 278   /* Don't do anything if the page is not in the nonfree list */
251   if (ppage_descr->ref_cnt <= 0)                  279   if (ppage_descr->ref_cnt <= 0)
252     return -SOS_EINVAL;                           280     return -SOS_EINVAL;
253                                                   281 
254   /* Unreference the page, and, when no mappin    282   /* Unreference the page, and, when no mapping is active anymore, put
255      the page in the free list */                 283      the page in the free list */
256   ppage_descr->ref_cnt--;                         284   ppage_descr->ref_cnt--;
257   if (ppage_descr->ref_cnt <= 0)               !! 285   if (ppage_descr->ref_cnt == 0)
258     {                                             286     {
259       /* Transfer the page, considered USED, t !! 287       /* Make sure that the occupation counter is set to 0 */
260       list_delete(used_ppage, ppage_descr);    !! 288       SOS_ASSERT_FATAL(ppage_descr->occupation_cnt == 0);
261       physmem_used_pages --;                   !! 289 
                                                   >> 290       /* Reset associated kernel range */
                                                   >> 291       ppage_descr->kernel_range = NULL;
                                                   >> 292   
                                                   >> 293       /* Transfer the page, considered NON-FREE, to the free list */
                                                   >> 294       list_delete(nonfree_ppage, ppage_descr);
                                                   >> 295       physmem_nonfree_pages --;
262       list_add_head(free_ppage, ppage_descr);     296       list_add_head(free_ppage, ppage_descr);
263                                                   297 
264       /* Indicate that the page is now unrefer    298       /* Indicate that the page is now unreferenced */
265       retval = TRUE;                              299       retval = TRUE;
266     }                                             300     }
267                                                   301 
                                                   >> 302   /* The page was already referenced by someone */
268   return retval;                                  303   return retval;
                                                   >> 304 }
                                                   >> 305 
                                                   >> 306 
                                                   >> 307 sos_ret_t sos_physmem_get_physpage_refcount(sos_paddr_t ppage_paddr)
                                                   >> 308 {
                                                   >> 309   struct physical_page_descr *ppage_descr
                                                   >> 310     = get_page_descr_at_paddr(ppage_paddr);
                                                   >> 311 
                                                   >> 312   if (! ppage_descr)
                                                   >> 313     return -SOS_EINVAL;
                                                   >> 314 
                                                   >> 315   return ppage_descr->ref_cnt;
                                                   >> 316 }
                                                   >> 317 
                                                   >> 318 
                                                   >> 319 sos_ret_t sos_physmem_inc_physpage_occupation(sos_paddr_t ppage_paddr)
                                                   >> 320 {
                                                   >> 321   struct physical_page_descr *ppage_descr
                                                   >> 322     = get_page_descr_at_paddr(ppage_paddr);
                                                   >> 323 
                                                   >> 324   if (! ppage_descr)
                                                   >> 325     return -SOS_EINVAL;
                                                   >> 326 
                                                   >> 327   /* Don't do anything if the page is not in the nonfree list */
                                                   >> 328   SOS_ASSERT_FATAL(ppage_descr->ref_cnt > 0);
                                                   >> 329 
                                                   >> 330   ppage_descr->occupation_cnt ++;
                                                   >> 331   return (ppage_descr->occupation_cnt > 1);
                                                   >> 332 }
                                                   >> 333 
                                                   >> 334 
                                                   >> 335 sos_ret_t sos_physmem_dec_physpage_occupation(sos_paddr_t ppage_paddr)
                                                   >> 336 {
                                                   >> 337   struct physical_page_descr *ppage_descr
                                                   >> 338     = get_page_descr_at_paddr(ppage_paddr);
                                                   >> 339 
                                                   >> 340   if (! ppage_descr)
                                                   >> 341     return -SOS_EINVAL;
                                                   >> 342 
                                                   >> 343   /* Don't do anything if the page is not in the nonfree list */
                                                   >> 344   SOS_ASSERT_FATAL(ppage_descr->ref_cnt > 0);
                                                   >> 345   SOS_ASSERT_FATAL(ppage_descr->occupation_cnt > 0);
                                                   >> 346 
                                                   >> 347   ppage_descr->occupation_cnt --;
                                                   >> 348   return (ppage_descr->occupation_cnt == 0);
                                                   >> 349 }
                                                   >> 350 
                                                   >> 351 
                                                   >> 352 struct sos_kmem_range* sos_physmem_get_kmem_range(sos_paddr_t ppage_paddr)
                                                   >> 353 {
                                                   >> 354   struct physical_page_descr *ppage_descr
                                                   >> 355     = get_page_descr_at_paddr(ppage_paddr);
                                                   >> 356 
                                                   >> 357   if (! ppage_descr)
                                                   >> 358     return NULL;
                                                   >> 359 
                                                   >> 360   return ppage_descr->kernel_range;
                                                   >> 361 }
                                                   >> 362 
                                                   >> 363 
                                                   >> 364 sos_ret_t sos_physmem_set_kmem_range(sos_paddr_t ppage_paddr,
                                                   >> 365                                      struct sos_kmem_range *range)
                                                   >> 366 {
                                                   >> 367   struct physical_page_descr *ppage_descr
                                                   >> 368     = get_page_descr_at_paddr(ppage_paddr);
                                                   >> 369 
                                                   >> 370   if (! ppage_descr)
                                                   >> 371     return -SOS_EINVAL;
                                                   >> 372 
                                                   >> 373   ppage_descr->kernel_range = range;
                                                   >> 374   return SOS_OK;
                                                   >> 375 }
                                                   >> 376 
                                                   >> 377 sos_ret_t sos_physmem_get_state(/* out */sos_count_t *total_ppages,
                                                   >> 378                                 /* out */sos_count_t *nonfree_ppages)
                                                   >> 379 {
                                                   >> 380   if (total_ppages)
                                                   >> 381     *total_ppages = physmem_total_pages;
                                                   >> 382   if (nonfree_ppages)
                                                   >> 383     *nonfree_ppages = physmem_nonfree_pages;
                                                   >> 384   return SOS_OK;
269 }                                                 385 }
                                                      

source navigation ] diff markup ] identifier search ] general search ]