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.h (Article 4) and /sos/physmem.h (Article 5)


001 /* Copyright (C) 2004  David Decotigny            001 /* Copyright (C) 2004  David Decotigny
002                                                   002 
003    This program is free software; you can redi    003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU Genera    004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundatio    005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any lat    006    of the License, or (at your option) any later version.
007                                                   007    
008    This program is distributed in the hope tha    008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the     009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR    010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details    011    GNU General Public License for more details.
012                                                   012    
013    You should have received a copy of the GNU     013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to t    014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 3    015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA.                                           016    USA. 
017 */                                                017 */
018 #ifndef _SOS_PHYSMEM_H_                           018 #ifndef _SOS_PHYSMEM_H_
019 #define _SOS_PHYSMEM_H_                           019 #define _SOS_PHYSMEM_H_
020                                                   020 
021 /**                                               021 /**
022  * @file physmem.h                                022  * @file physmem.h
023  *                                                023  *
024  * Physical pages of memory                       024  * Physical pages of memory
025  */                                               025  */
026                                                   026 
027 #include <sos/errno.h>                            027 #include <sos/errno.h>
028 #include <sos/types.h>                            028 #include <sos/types.h>
029 #include <sos/macros.h>                           029 #include <sos/macros.h>
030                                                   030 
031 /** The size of a physical page (arch-dependen    031 /** The size of a physical page (arch-dependent) */
032 #define SOS_PAGE_SIZE  (4*1024)                   032 #define SOS_PAGE_SIZE  (4*1024)
033                                                   033 
034 /** The corresponding shift */                    034 /** The corresponding shift */
035 #define SOS_PAGE_SHIFT 12 /* 4 kB = 2^12 B */     035 #define SOS_PAGE_SHIFT 12 /* 4 kB = 2^12 B */
036                                                   036 
037 /** The corresponding mask */                     037 /** The corresponding mask */
038 #define SOS_PAGE_MASK  ((1<<12) - 1)              038 #define SOS_PAGE_MASK  ((1<<12) - 1)
039                                                   039 
040 #define SOS_PAGE_ALIGN_INF(val) \                 040 #define SOS_PAGE_ALIGN_INF(val) \
041   SOS_ALIGN_INF((val), SOS_PAGE_SIZE)             041   SOS_ALIGN_INF((val), SOS_PAGE_SIZE)
042 #define SOS_PAGE_ALIGN_SUP(val) \                 042 #define SOS_PAGE_ALIGN_SUP(val) \
043   SOS_ALIGN_SUP((val), SOS_PAGE_SIZE)             043   SOS_ALIGN_SUP((val), SOS_PAGE_SIZE)
044                                                   044 
045                                                   045 
046 /**                                               046 /**
047  * This is the reserved physical interval for     047  * This is the reserved physical interval for the x86 video memory and
048  * BIOS area. In physmem.c, we have to mark th    048  * BIOS area. In physmem.c, we have to mark this area as "used" in
049  * order to prevent from allocating it. And in    049  * order to prevent from allocating it. And in paging.c, we'd better
050  * map it in virtual space if we really want t    050  * map it in virtual space if we really want to be able to print to
051  * the screen (for debugging purpose, at least    051  * the screen (for debugging purpose, at least): for this, the
052  * simplest is to identity-map this area in vi    052  * simplest is to identity-map this area in virtual space (note
053  * however that this mapping could also be non    053  * however that this mapping could also be non-identical).
054  */                                               054  */
055 #define BIOS_N_VIDEO_START 0xa0000                055 #define BIOS_N_VIDEO_START 0xa0000
056 #define BIOS_N_VIDEO_END   0x100000               056 #define BIOS_N_VIDEO_END   0x100000
057                                                   057 
058                                                   058 
059 /**                                               059 /**
060  * Initialize the physical memory subsystem, f    060  * Initialize the physical memory subsystem, for the physical area [0,
061  * ram_size). This routine takes into account     061  * ram_size). This routine takes into account the BIOS and video
062  * areas, to prevent them from future allocati    062  * areas, to prevent them from future allocations.
063  *                                                063  *
064  * @param ram_size The size of the RAM that wi    064  * @param ram_size The size of the RAM that will be managed by this subsystem
065  *                                                065  *
066  * @param kernel_core_base The lowest address     066  * @param kernel_core_base The lowest address for which the kernel
067  * assumes identity mapping (ie virtual addres    067  * assumes identity mapping (ie virtual address == physical address)
068  * will be stored here                            068  * will be stored here
069  *                                                069  *
070  * @param kernel_core_top The top address for     070  * @param kernel_core_top The top address for which the kernel
071  * assumes identity mapping (ie virtual addres    071  * assumes identity mapping (ie virtual address == physical address)
072  * will be stored here                            072  * will be stored here
073  */                                               073  */
074 sos_ret_t sos_physmem_setup(sos_size_t ram_siz    074 sos_ret_t sos_physmem_setup(sos_size_t ram_size,
075                             /* out */sos_paddr    075                             /* out */sos_paddr_t *kernel_core_base,
076                             /* out */sos_paddr    076                             /* out */sos_paddr_t *kernel_core_top);
077                                                   077 
078 /**                                               078 /**
079  * Retrieve the total number of pages, and the    079  * Retrieve the total number of pages, and the number of free pages
080  */                                               080  */
081 sos_ret_t sos_physmem_get_state(/* out */sos_c    081 sos_ret_t sos_physmem_get_state(/* out */sos_count_t *total_ppages,
082                                 /* out */sos_c    082                                 /* out */sos_count_t *used_ppages);
083                                                   083 
084                                                   084 
085 /**                                               085 /**
086  * Get a free page.                               086  * Get a free page.
087  *                                                087  *
088  * @return The (physical) address of the (phys    088  * @return The (physical) address of the (physical) page allocated, or
089  * NULL when none currently available.            089  * NULL when none currently available.
090  *                                                090  *
091  * @param can_block TRUE if the function is al    091  * @param can_block TRUE if the function is allowed to block
092  * @note The page returned has a reference cou    092  * @note The page returned has a reference count equal to 1.
093  */                                               093  */
094 sos_paddr_t sos_physmem_ref_physpage_new(sos_b    094 sos_paddr_t sos_physmem_ref_physpage_new(sos_bool_t can_block);
095                                                   095 
096                                                   096 
097 /**                                               097 /**
098  * Increment the reference count of a given ph    098  * Increment the reference count of a given physical page. Useful for
099  * VM code which tries to map a precise physic    099  * VM code which tries to map a precise physical address.
100  *                                                100  *
101  * @return TRUE when the page was previously i    101  * @return TRUE when the page was previously in use, FALSE when the
102  * page was previously in the free list, <0 wh    102  * page was previously in the free list, <0 when the page address is
103  * invalid.                                       103  * invalid.
104  */                                               104  */
105 sos_ret_t sos_physmem_ref_physpage_at(sos_padd    105 sos_ret_t sos_physmem_ref_physpage_at(sos_paddr_t ppage_paddr);
106                                                   106 
107                                                   107 
108 /**                                               108 /**
109  * Decrement the reference count of the given     109  * Decrement the reference count of the given physical page. When this
110  * reference count reaches 0, the page is mark    110  * reference count reaches 0, the page is marked free, ie is available
111  * for future sos_physmem_get_physpage()          111  * for future sos_physmem_get_physpage()
112  *                                                112  *
113  * @return FALSE when the page is still in use    113  * @return FALSE when the page is still in use, TRUE when the page is now
114  * unreferenced, <0 when the page address is i    114  * unreferenced, <0 when the page address is invalid
115  */                                               115  */
116 sos_ret_t sos_physmem_unref_physpage(sos_paddr    116 sos_ret_t sos_physmem_unref_physpage(sos_paddr_t ppage_paddr);
117                                                   117 
118                                                   118 
                                                   >> 119 #include <sos/kmem_vmm.h>
                                                   >> 120 
                                                   >> 121 /**
                                                   >> 122  * Return the kernel memory allocation range associated with the given
                                                   >> 123  * physical page, or NULL when page has no associated range
                                                   >> 124  */
                                                   >> 125 struct sos_kmem_range* sos_physmem_get_kmem_range(sos_paddr_t ppage_paddr);
                                                   >> 126 
                                                   >> 127 
                                                   >> 128 /**
                                                   >> 129  * Set the kernel memory allocation range associated to the given
                                                   >> 130  * physical page.
                                                   >> 131  * @return error if page is invalid
                                                   >> 132  */
                                                   >> 133 sos_ret_t sos_physmem_set_kmem_range(sos_paddr_t ppage_paddr,
                                                   >> 134                                      struct sos_kmem_range *range);
                                                   >> 135 
119 #endif /* _SOS_PHYSMEM_H_ */                      136 #endif /* _SOS_PHYSMEM_H_ */
                                                      

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