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