/[rtmk]/rtmk/vm-page.c
ViewVC logotype

Diff of /rtmk/vm-page.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by jrydberg, Tue Jan 29 18:31:45 2002 UTC revision 1.4 by jrydberg, Wed Feb 6 19:57:00 2002 UTC
# Line 1  Line 1 
1  /* VM page.  /* VM page.
2     Copyright 1999, 2000, 2001 Johan Rydberg, jrydberg@opencores.org.     Copyright 1999, 2000, 2001, 2002 Johan Rydberg, jrydberg@opencores.org.
3    
4  This program is free software; you can redistribute it and/or modify  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
# Line 61  static spin_lock_t page_hash_lock [PAGE_ Line 61  static spin_lock_t page_hash_lock [PAGE_
61    
62  /* Cache for VM page structures.  Might come handy.  */  /* Cache for VM page structures.  Might come handy.  */
63  static struct kmem_cache *page_cache;  static struct kmem_cache *page_cache;
64    static struct kmem_cache *fict_cache;
65    
66  /* Initialize page stuff that is needed after the VM system is bootstrapped. */  /* Initialize page stuff that is needed after the VM system is bootstrapped. */
67    
# Line 69  vm_page_module_init (void) Line 70  vm_page_module_init (void)
70  {  {
71    page_cache = kmem_cache_create ("page cache",    page_cache = kmem_cache_create ("page cache",
72                                    sizeof (struct vm_page), 0);                                    sizeof (struct vm_page), 0);
73    assert (page_cache);    fict_cache = kmem_cache_create ("fict cache",
74                                      sizeof (struct vm_page), 0);
75      assert (page_cache && fict_cache);
76  }  }
77    
78    
# Line 191  vm_page_load (vm_offset_t start, vm_offs Line 194  vm_page_load (vm_offset_t start, vm_offs
194    
195    
196  /* Release PAGE.  Put it on the free list.  */  /* Release PAGE.  Put it on the free list.  */
   
197  void  void
198  vm_page_release (struct vm_page *page)  vm_page_release (struct vm_page *page)
199  {  {
200    /* ??? is this the correct macro?  */    if (page->fictitious_p)
201    page_free_count++;      {
202    queue_enter (&page_free_list, page, struct vm_page *, listq);        kmem_cache_free (fict_cache, page);
203        }
204      else
205        {
206          page_free_count++;
207          queue_enter (&page_free_list, page, struct vm_page *, listq);
208        }
209  }  }
210    
211  /* Allocate a new page from the free list.  This may start the  /* Allocate a new page from the free list.  This may start the
# Line 217  vm_page_allocate (void) Line 225  vm_page_allocate (void)
225    return page;    return page;
226  }  }
227    
228    /* Allocate a fictitious page.  We returned page have no
229       physical page assigned.  On failure NULL is returned.  */
230    
231    struct vm_page *
232    vm_page_fictitious_allocate (void)
233    {
234      struct vm_page *page;
235    
236      page = (struct vm_page *) kmem_cache_alloc (fict_cache);
237      if (page)
238        {
239          memset (page, 0, sizeof (struct vm_page));
240          page->fictitious_p = true;
241        }
242      return page;
243    }
244    
245    /* Assign a physical address, PA, to PAGE.  */
246    
247    void
248    vm_page_assign (struct vm_page *page, vm_offset_t pa)
249    {
250      ASSERT (page->fictitious_p == true);
251      page->phys_addr = pa;
252    }
253    
254    
255  /* Grab a physical page.  The physical page address is returned.  */  /* Grab a physical page.  The physical page address is returned.  */
256    
257  void *  void *

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26