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 ]

001 /* Copyright (C) 2000 Thomas Petazzoni
002    Copyright (C) 2004 David Decotigny
003 
004    This program is free software; you can redistribute it and/or
005    modify it under the terms of the GNU General Public License
006    as published by the Free Software Foundation; either version 2
007    of the License, or (at your option) any later version.
008    
009    This program is distributed in the hope that it will be useful,
010    but WITHOUT ANY WARRANTY; without even the implied warranty of
011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012    GNU General Public License for more details.
013    
014    You should have received a copy of the GNU General Public License
015    along with this program; if not, write to the Free Software
016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
017    USA. 
018 */
019 #ifndef _SOS_KMEM_VMM_H_
020 #define _SOS_KMEM_VMM_H_
021 
022 /**
023  * @file kmem_vmm.h
024  *
025  * Kernel Memory Allocator for multiple-page-sized objects residing in
026  * the kernel (virtual memory) space. Relies on the slab cache
027  * allocator to allocate its (internal) "range" data structure.
028  */
029 
030 #include <hwcore/paging.h>
031 
032 /* The base and top virtual addresses covered by the kernel allocator */
033 #define SOS_KMEM_VMM_BASE 0x4000 /* 16kB */
034 #define SOS_KMEM_VMM_TOP  SOS_PAGING_MIRROR_VADDR /* 1GB - 4MB */
035 
036 /** Opaque structure used internally and declared here for physmem.h */
037 struct sos_kmem_range;
038 
039 #include <sos/kmem_slab.h>
040 
041 /**
042  * Mark the areas belonging to SOS_KMEM_VMM_BASE and SOS_KMEM_VMM_TOP
043  * are either used or free. Those that are already mapped are marked
044  * as "used", and the 0..SOS_KMEM_VMM_BASE virtual addresses as marked
045  * as "used" too (to detect incorrect pointer dereferences).
046  */
047 sos_ret_t sos_kmem_vmm_setup(sos_vaddr_t kernel_core_base,
048                              sos_vaddr_t kernel_core_top);
049 
050 
051 /*
052  * Flags for kmem_vmm_new_range and kmem_vmm_alloc
053  */
054 /** Physical pages should be immediately mapped */
055 #define SOS_KMEM_VMM_MAP    (1<<0)
056 /** Allocation should either success or fail, without blocking */
057 #define SOS_KMEM_VMM_ATOMIC (1<<1)
058 
059 /**
060  * Allocate a new kernel area spanning one or multiple pages.
061  *
062  * @param range_base_vaddr If not NULL, the start address of the range
063  * is stored in this location
064  * @eturn a new range structure
065  */
066 struct sos_kmem_range *sos_kmem_vmm_new_range(sos_size_t  nb_pages,
067                                               sos_ui32_t  flags,
068                                               sos_vaddr_t *range_base_vaddr);
069 sos_vaddr_t sos_kmem_vmm_del_range(struct sos_kmem_range *range);
070 
071 
072 /**
073  * Straighforward variant of sos_kmem_vmm_new_range() returning the
074  * range's start address instead of the range structure
075  */
076 sos_vaddr_t sos_kmem_vmm_alloc(sos_size_t nb_pages,
077                                sos_ui32_t flags);
078 
079 /**
080  * @note you are perfectly allowed to give the address of the
081  * kernel image, or the address of the bios area here, it will work:
082  * the kernel/bios WILL be "deallocated". But if you really want to do
083  * this, well..., do expect some "surprises" ;)
084  */
085 sos_vaddr_t sos_kmem_vmm_free(sos_vaddr_t vaddr);
086 
087 
088 /* *****************************
089  * Reserved to kmem_slab.c ONLY.
090  */
091 /**
092  * Associate the range with the given slab.
093  */
094 sos_ret_t sos_kmem_vmm_set_slab(struct sos_kmem_range *range,
095                                 struct sos_kslab *slab);
096 
097 /**
098  * Retrieve the slab associated with the
099  * range covering vaddr.
100  *
101  * @return NULL if the range is not associated with a KMEM range
102  */
103 struct sos_kslab *sos_kmem_vmm_resolve_slab(sos_vaddr_t vaddr);
104 
105 #endif /* _SOS_KMEM_VMM_H_ */

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