[Krafton Jungle] PintOS 2.0.0
크래프톤 정글 PintOS
 
Loading...
Searching...
No Matches
palloc.h File Reference
#include <stdint.h>
#include <stddef.h>
Include dependency graph for palloc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  palloc_flags { PAL_ASSERT = 001 , PAL_ZERO = 002 , PAL_USER = 004 }
 

Functions

uint64_t palloc_init (void)
 
void * palloc_get_page (enum palloc_flags)
 
void * palloc_get_multiple (enum palloc_flags, size_t page_cnt)
 
void palloc_free_page (void *)
 
void palloc_free_multiple (void *, size_t page_cnt)
 

Variables

size_t user_page_limit
 

Enumeration Type Documentation

◆ palloc_flags

Enumerator
PAL_ASSERT 
PAL_ZERO 
PAL_USER 
8 {
9 PAL_ASSERT = 001, /* Panic on failure. */
10 PAL_ZERO = 002, /* Zero page contents. */
11 PAL_USER = 004 /* User page. */
12};
@ PAL_ZERO
Definition: palloc.h:10
@ PAL_USER
Definition: palloc.h:11
@ PAL_ASSERT
Definition: palloc.h:9

Function Documentation

◆ palloc_free_multiple()

void palloc_free_multiple ( void *  pages,
size_t  page_cnt 
)
307 {
308 struct pool *pool;
309 size_t page_idx;
310
311 ASSERT (pg_ofs (pages) == 0);
312 if (pages == NULL || page_cnt == 0)
313 return;
314
315 if (page_from_pool (&kernel_pool, pages))
316 pool = &kernel_pool;
317 else if (page_from_pool (&user_pool, pages))
318 pool = &user_pool;
319 else
320 NOT_REACHED ();
321
322 page_idx = pg_no (pages) - pg_no (pool->base);
323
324#ifndef NDEBUG
325 memset (pages, 0xcc, PGSIZE * page_cnt);
326#endif
327 ASSERT (bitmap_all (pool->used_map, page_idx, page_cnt));
328 bitmap_set_multiple (pool->used_map, page_idx, page_cnt, false);
329}
void bitmap_set_multiple(struct bitmap *, size_t start, size_t cnt, bool)
Definition: bitmap.c:199
bool bitmap_all(const struct bitmap *, size_t start, size_t cnt)
Definition: bitmap.c:260
#define ASSERT(CONDITION)
Definition: debug.h:30
#define NOT_REACHED()
Definition: debug.h:34
static bool page_from_pool(const struct pool *, void *page)
Definition: palloc.c:359
static struct pool kernel_pool user_pool
Definition: palloc.c:37
#define NULL
Definition: stddef.h:4
void * memset(void *, int, size_t)
Definition: string.c:258
Definition: palloc.c:30
struct bitmap * used_map
Definition: palloc.c:32
uint8_t * base
Definition: palloc.c:33
#define PGSIZE
Definition: vaddr.h:20
#define pg_no(va)
Definition: vaddr.h:26
#define pg_ofs(va)
Definition: vaddr.h:24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ palloc_free_page()

void palloc_free_page ( void *  page)
333 {
335}
void palloc_free_multiple(void *pages, size_t page_cnt)
Definition: palloc.c:307
Definition: vm.h:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ palloc_get_multiple()

void * palloc_get_multiple ( enum  palloc_flags,
size_t  page_cnt 
)
263 {
264 struct pool *pool = flags & PAL_USER ? &user_pool : &kernel_pool;
265
267 size_t page_idx = bitmap_scan_and_flip (pool->used_map, 0, page_cnt, false);
269 void *pages;
270
271 if (page_idx != BITMAP_ERROR)
272 pages = pool->base + PGSIZE * page_idx;
273 else
274 pages = NULL;
275
276 if (pages) {
277 if (flags & PAL_ZERO)
278 memset (pages, 0, PGSIZE * page_cnt);
279 } else {
280 if (flags & PAL_ASSERT)
281 PANIC ("palloc_get: out of pages");
282 }
283
284 return pages;
285}
size_t bitmap_scan_and_flip(struct bitmap *, size_t start, size_t cnt, bool)
Definition: bitmap.c:293
#define BITMAP_ERROR
Definition: bitmap.h:36
#define PANIC(...)
Definition: debug.h:14
struct lock lock
Definition: palloc.c:31
void lock_release(struct lock *)
Definition: synch.c:243
void lock_acquire(struct lock *)
Definition: synch.c:202
Here is the call graph for this function:
Here is the caller graph for this function:

◆ palloc_get_page()

void * palloc_get_page ( enum  palloc_flags)
301 {
302 return palloc_get_multiple (flags, 1);
303}
void * palloc_get_multiple(enum palloc_flags flags, size_t page_cnt)
Definition: palloc.c:263
Here is the call graph for this function:
Here is the caller graph for this function:

◆ palloc_init()

uint64_t palloc_init ( void  )
239 {
240 /* End of the kernel as recorded by the linker.
241 See kernel.lds.S. */
242 extern char _end;
243 struct area base_mem = { .size = 0 };
244 struct area ext_mem = { .size = 0 };
245
246 resolve_area_info (&base_mem, &ext_mem);
247 printf ("Pintos booting with: \n");
248 printf ("\tbase_mem: 0x%llx ~ 0x%llx (Usable: %'llu kB)\n",
249 base_mem.start, base_mem.end, base_mem.size / 1024);
250 printf ("\text_mem: 0x%llx ~ 0x%llx (Usable: %'llu kB)\n",
251 ext_mem.start, ext_mem.end, ext_mem.size / 1024);
252 populate_pools (&base_mem, &ext_mem);
253 return ext_mem.end;
254}
static void resolve_area_info(struct area *base_mem, struct area *ext_mem)
Definition: palloc.c:80
static void populate_pools(struct area *base_mem, struct area *ext_mem)
Definition: palloc.c:123
int printf(const char *,...) PRINTF_FORMAT(1
Definition: palloc.c:67
uint64_t start
Definition: palloc.c:68
uint64_t size
Definition: palloc.c:70
uint64_t end
Definition: palloc.c:69
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ user_page_limit

size_t user_page_limit
extern