generic
[Memory management]


Files

file  as.h
file  asid.h
file  buddy.h
file  frame.h
file  page.h
file  slab.h
file  tlb.h
file  as.c
 Address space related functions.
file  backend_anon.c
 Backend for anonymous memory address space areas.
file  backend_elf.c
 Backend for address space areas backed by an ELF image.
file  backend_phys.c
 Backend for address space areas backed by continuous physical memory.
file  buddy.c
 Buddy allocator framework.
file  frame.c
 Physical frame allocator.
file  page.c
 Virtual Address Translation subsystem.
file  slab.c
 Slab allocator.
file  tlb.c
 Generic TLB shootdown algorithm.

Data Structures

struct  buddy_system_operations
struct  buddy_system
struct  page_mapping_operations
struct  slab_magazine_t
struct  slab_mag_cache_t
struct  slab_cache_t
struct  tlb_shootdown_msg
struct  frame_t
struct  zone_t
struct  slab_t

Defines

#define AS_AREA_READ   1
#define AS_AREA_WRITE   2
#define AS_AREA_EXEC   4
#define AS_AREA_CACHEABLE   8
#define ASID_KERNEL   0
#define ASID_INVALID   1
#define ASID_START   2
#define ASID_MAX   ASID_MAX_ARCH
#define ASIDS_ALLOCABLE   ((ASID_MAX+1)-ASID_START)
#define BUDDY_SYSTEM_INNER_BLOCK   0xff
#define ONE_FRAME   0
#define TWO_FRAMES   1
#define STACK_FRAMES   ONE_FRAME
#define ZONES_MAX   16
#define ZONE_JOIN   0x1
#define FRAME_KA   0x1
#define FRAME_PANIC   0x2
#define FRAME_ATOMIC   0x4
#define FRAME_NO_RECLAIM   0x8
#define FRAME_OK   0
#define FRAME_NO_MEMORY   1
#define FRAME_ERROR   2
#define IS_BUDDY_ORDER_OK(index, order)   ((~(((__native) -1) << (order)) & (index)) == 0)
#define IS_BUDDY_LEFT_BLOCK(zone, frame)   (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
#define IS_BUDDY_RIGHT_BLOCK(zone, frame)   (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
#define IS_BUDDY_LEFT_BLOCK_ABS(zone, frame)   (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
#define IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame)   (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
#define frame_alloc(order, flags)   frame_alloc_generic(order, flags, NULL, NULL)
#define frame_alloc_rc(order, flags, status)   frame_alloc_generic(order, flags, status, NULL)
#define frame_alloc_rc_zone(order, flags, status, zone)   frame_alloc_generic(order, flags, status, zone)
#define PAGE_CACHEABLE_SHIFT   0
#define PAGE_NOT_CACHEABLE_SHIFT   PAGE_CACHEABLE_SHIFT
#define PAGE_PRESENT_SHIFT   1
#define PAGE_NOT_PRESENT_SHIFT   PAGE_PRESENT_SHIFT
#define PAGE_USER_SHIFT   2
#define PAGE_KERNEL_SHIFT   PAGE_USER_SHIFT
#define PAGE_READ_SHIFT   3
#define PAGE_WRITE_SHIFT   4
#define PAGE_EXEC_SHIFT   5
#define PAGE_GLOBAL_SHIFT   6
#define PAGE_NOT_CACHEABLE   (0<<PAGE_CACHEABLE_SHIFT)
#define PAGE_CACHEABLE   (1<<PAGE_CACHEABLE_SHIFT)
#define PAGE_PRESENT   (0<<PAGE_PRESENT_SHIFT)
#define PAGE_NOT_PRESENT   (1<<PAGE_PRESENT_SHIFT)
#define PAGE_USER   (1<<PAGE_USER_SHIFT)
#define PAGE_KERNEL   (0<<PAGE_USER_SHIFT)
#define PAGE_READ   (1<<PAGE_READ_SHIFT)
#define PAGE_WRITE   (1<<PAGE_WRITE_SHIFT)
#define PAGE_EXEC   (1<<PAGE_EXEC_SHIFT)
#define PAGE_GLOBAL   (1<<PAGE_GLOBAL_SHIFT)
#define SLAB_MIN_MALLOC_W   4
#define SLAB_MAX_MALLOC_W   18
#define SLAB_MAG_SIZE   4
#define SLAB_INSIDE_SIZE   (PAGE_SIZE >> 3)
#define SLAB_MAX_BADNESS(cache)   ((PAGE_SIZE << (cache)->order) >> 2)
#define SLAB_RECLAIM_ALL   0x1
#define SLAB_CACHE_NOMAGAZINE   0x1
#define SLAB_CACHE_SLINSIDE   0x2
#define SLAB_CACHE_MAGDEFERRED   (0x4 | SLAB_CACHE_NOMAGAZINE)
#define TLB_MESSAGE_QUEUE_LEN   10

Typedefs

typedef enum pf_access pf_access_t
typedef page_mapping_operations page_mapping_operations_t
typedef enum tlb_invalidate_type tlb_invalidate_type_t
typedef tlb_shootdown_msg tlb_shootdown_msg_t

Enumerations

enum  pf_access { PF_ACCESS_READ, PF_ACCESS_WRITE, PF_ACCESS_EXEC }
enum  tlb_invalidate_type { TLB_INVL_INVALID = 0, TLB_INVL_ALL, TLB_INVL_ASID, TLB_INVL_PAGES }

Functions

asid_t asid_get (void)
void asid_put (asid_t asid)
void asid_install (as_t *as)
asid_t asid_find_free (void)
void asid_put_arch (asid_t asid)
void buddy_system_create (buddy_system_t *b, __u8 max_order, buddy_system_operations_t *op, void *data)
link_tbuddy_system_alloc (buddy_system_t *b, __u8 i)
bool buddy_system_can_alloc (buddy_system_t *b, __u8 order)
void buddy_system_free (buddy_system_t *b, link_t *block)
void buddy_system_structure_print (buddy_system_t *b, size_t elem_size)
size_t buddy_conf_size (int max_order)
link_tbuddy_system_alloc_block (buddy_system_t *b, link_t *block)
static __address PFN2ADDR (pfn_t frame)
static pfn_t ADDR2PFN (__address addr)
static count_t SIZE2FRAMES (size_t size)
void frame_init (void)
pfn_t frame_alloc_generic (__u8 order, int flags, int *status, int *pzone)
void frame_free (pfn_t pfn)
void frame_reference_add (pfn_t pfn)
int zone_create (pfn_t start, count_t count, pfn_t confframe, int flags)
void * frame_get_parent (pfn_t frame, int hint)
void frame_set_parent (pfn_t frame, void *data, int hint)
void frame_mark_unavailable (pfn_t start, count_t count)
__address zone_conf_size (count_t count)
void zone_merge (int z1, int z2)
void zone_merge_all (void)
void zone_print_list (void)
void zone_print_one (int znum)
void page_init (void)
void page_table_lock (as_t *as, bool lock)
void page_table_unlock (as_t *as, bool unlock)
void page_mapping_insert (as_t *as, __address page, __address frame, int flags)
void page_mapping_remove (as_t *as, __address page)
pte_tpage_mapping_find (as_t *as, __address page)
pte_tpage_table_create (int flags)
void page_table_destroy (pte_t *page_table)
void map_structure (__address s, size_t size)
__address hw_map (__address physaddr, size_t size)
slab_cache_tslab_cache_create (char *name, size_t size, size_t align, int(*constructor)(void *obj, int kmflag), int(*destructor)(void *obj), int flags)
void slab_cache_destroy (slab_cache_t *cache)
void * slab_alloc (slab_cache_t *cache, int flags)
void slab_free (slab_cache_t *cache, void *obj)
count_t slab_reclaim (int flags)
void slab_cache_init (void)
void slab_enable_cpucache (void)
void slab_print_list (void)
void * malloc (unsigned int size, int flags)
void free (void *obj)
void tlb_init (void)
void tlb_shootdown_start (tlb_invalidate_type_t type, asid_t asid, __address page, count_t count)
void tlb_shootdown_finalize (void)
void tlb_shootdown_ipi_recv (void)
void tlb_arch_init (void)
void tlb_print (void)
void tlb_shootdown_ipi_send (void)
void tlb_invalidate_all (void)
void tlb_invalidate_asid (asid_t asid)
void tlb_invalidate_pages (asid_t asid, __address page, count_t cnt)
 SPINLOCK_INITIALIZE (inactive_as_with_asid_lock)
 LIST_INITIALIZE (inactive_as_with_asid_head)
static int area_flags_to_page_flags (int aflags)
static as_area_tfind_area_and_lock (as_t *as, __address va)
static bool check_area_conflicts (as_t *as, __address va, size_t size, as_area_t *avoid_area)
static void sh_info_remove_reference (share_info_t *sh_info)
void as_init (void)
as_tas_create (int flags)
void as_destroy (as_t *as)
as_area_tas_area_create (as_t *as, int flags, size_t size, __address base, int attrs, mem_backend_t *backend, mem_backend_data_t *backend_data)
int as_area_resize (as_t *as, __address address, size_t size, int flags)
int as_area_destroy (as_t *as, __address address)
int as_area_share (as_t *src_as, __address src_base, size_t acc_size, as_t *dst_as, __address dst_base, int dst_flags_mask)
bool as_area_check_access (as_area_t *area, pf_access_t access)
int as_page_fault (__address page, pf_access_t access, istate_t *istate)
void as_switch (as_t *old, as_t *new)
int as_area_get_flags (as_area_t *a)
size_t as_get_size (__address base)
int used_space_insert (as_area_t *a, __address page, count_t count)
int used_space_remove (as_area_t *a, __address page, count_t count)
__native sys_as_area_create (__address address, size_t size, int flags)
__native sys_as_area_resize (__address address, size_t size, int flags)
__native sys_as_area_destroy (__address address)
static int anon_page_fault (as_area_t *area, __address addr, pf_access_t access)
static void anon_frame_free (as_area_t *area, __address page, __address frame)
static void anon_share (as_area_t *area)
static int elf_page_fault (as_area_t *area, __address addr, pf_access_t access)
static void elf_frame_free (as_area_t *area, __address page, __address frame)
static void elf_share (as_area_t *area)
static int phys_page_fault (as_area_t *area, __address addr, pf_access_t access)
static void phys_share (as_area_t *area)
static index_t frame_index (zone_t *zone, frame_t *frame)
static index_t frame_index_abs (zone_t *zone, frame_t *frame)
static int frame_index_valid (zone_t *zone, index_t index)
static index_t make_frame_index (zone_t *zone, frame_t *frame)
static void frame_initialize (frame_t *frame)
static int zones_add_zone (zone_t *newzone)
static zone_tfind_zone_and_lock (pfn_t frame, int *pzone)
static int zone_can_alloc (zone_t *z, __u8 order)
static zone_tfind_free_zone_lock (__u8 order, int *pzone)
static link_tzone_buddy_find_block (buddy_system_t *b, link_t *child, __u8 order)
static void zone_buddy_print_id (buddy_system_t *b, link_t *block)
static link_tzone_buddy_find_buddy (buddy_system_t *b, link_t *block)
static link_tzone_buddy_bisect (buddy_system_t *b, link_t *block)
static link_tzone_buddy_coalesce (buddy_system_t *b, link_t *block_1, link_t *block_2)
static void zone_buddy_set_order (buddy_system_t *b, link_t *block, __u8 order)
static __u8 zone_buddy_get_order (buddy_system_t *b, link_t *block)
static void zone_buddy_mark_busy (buddy_system_t *b, link_t *block)
static void zone_buddy_mark_available (buddy_system_t *b, link_t *block)
static pfn_t zone_frame_alloc (zone_t *zone, __u8 order)
static void zone_frame_free (zone_t *zone, index_t frame_idx)
static frame_tzone_get_frame (zone_t *zone, index_t frame_idx)
static void zone_mark_unavailable (zone_t *zone, index_t frame_idx)
static void _zone_merge (zone_t *z, zone_t *z1, zone_t *z2)
static void return_config_frames (zone_t *newzone, zone_t *oldzone)
static void zone_reduce_region (zone_t *zone, pfn_t frame_idx, count_t count)
static void zone_construct (pfn_t start, count_t count, zone_t *z, int flags)
 SPINLOCK_INITIALIZE (slab_cache_lock)
static LIST_INITIALIZE (slab_cache_list)
static slab_tslab_space_alloc (slab_cache_t *cache, int flags)
static count_t slab_space_free (slab_cache_t *cache, slab_t *slab)
static slab_tobj2slab (void *obj)
static count_t slab_obj_destroy (slab_cache_t *cache, void *obj, slab_t *slab)
static void * slab_obj_create (slab_cache_t *cache, int flags)
static slab_magazine_tget_mag_from_cache (slab_cache_t *cache, int first)
static void put_mag_to_cache (slab_cache_t *cache, slab_magazine_t *mag)
static count_t magazine_destroy (slab_cache_t *cache, slab_magazine_t *mag)
static slab_magazine_tget_full_current_mag (slab_cache_t *cache)
static void * magazine_obj_get (slab_cache_t *cache)
static slab_magazine_tmake_empty_current_mag (slab_cache_t *cache)
static int magazine_obj_put (slab_cache_t *cache, void *obj)
static int comp_objects (slab_cache_t *cache)
static int badness (slab_cache_t *cache)
static void make_magcache (slab_cache_t *cache)
static void _slab_cache_create (slab_cache_t *cache, char *name, size_t size, size_t align, int(*constructor)(void *obj, int kmflag), int(*destructor)(void *obj), int flags)
static count_t _slab_reclaim (slab_cache_t *cache, int flags)
static void _slab_free (slab_cache_t *cache, void *obj, slab_t *slab)
 SPINLOCK_INITIALIZE (tlblock)

Variables

spinlock_t asidlock
link_t as_with_asid_head
page_mapping_operations_tpage_mapping_operations
as_operations_t * as_operations = NULL
as_tAS_KERNEL = NULL
mem_backend_t anon_backend
mem_backend_t elf_backend
mem_backend_t phys_backend
struct {
 SPINLOCK_DECLARE (lock)
   const char *   name
   iroutine   f
   int   count
   zone_t *   info [ZONES_MAX]
zones
static struct buddy_system_operations zone_buddy_system_operations
page_mapping_operations_tpage_mapping_operations = NULL
static slab_cache_t mag_cache
static slab_cache_t slab_cache_cache
static slab_cache_tslab_extern_cache
static slab_cache_tmalloc_caches [SLAB_MAX_MALLOC_W-SLAB_MIN_MALLOC_W+1]
char * malloc_names []

Define Documentation

#define AS_AREA_CACHEABLE   8
 

Definition at line 42 of file as.h.

Referenced by area_flags_to_page_flags(), as_area_share(), load_segment(), sys_as_area_create(), and task_run_program().

#define AS_AREA_EXEC   4
 

Definition at line 41 of file as.h.

Referenced by area_flags_to_page_flags(), as_area_check_access(), as_area_create(), and load_segment().

#define AS_AREA_READ   1
 

Address space area flags.

Definition at line 39 of file as.h.

Referenced by area_flags_to_page_flags(), as_area_check_access(), load_segment(), and task_run_program().

#define AS_AREA_WRITE   2
 

Definition at line 40 of file as.h.

Referenced by area_flags_to_page_flags(), as_area_check_access(), as_area_create(), elf_share(), load_segment(), and task_run_program().

#define ASID_INVALID   1
 

Definition at line 51 of file asid.h.

Referenced by as_create(), as_destroy(), as_switch(), asid_get(), and tlb_shootdown_start().

#define ASID_KERNEL   0
 

Definition at line 50 of file asid.h.

Referenced by as_create().

#define ASID_MAX   ASID_MAX_ARCH
 

Definition at line 53 of file asid.h.

#define ASID_START   2
 

Definition at line 52 of file asid.h.

Referenced by asid_fifo_init().

#define ASIDS_ALLOCABLE   ((ASID_MAX+1)-ASID_START)
 

Definition at line 57 of file asid.h.

Referenced by asid_fifo_init(), and asid_get().

#define BUDDY_SYSTEM_INNER_BLOCK   0xff
 

Definition at line 41 of file buddy.h.

Referenced by buddy_system_alloc_block(), buddy_system_create(), and buddy_system_free().

#define frame_alloc order,
flags   )     frame_alloc_generic(order, flags, NULL, NULL)
 

Definition at line 92 of file frame.h.

Referenced by anon_page_fault(), clock_counter_init(), cpu_init(), klog_init(), page_arch_init(), pt_mapping_insert(), and ptl0_create().

#define frame_alloc_rc order,
flags,
status   )     frame_alloc_generic(order, flags, status, NULL)
 

Definition at line 93 of file frame.h.

Referenced by fb_init(), and thr_constructor().

#define frame_alloc_rc_zone order,
flags,
status,
zone   )     frame_alloc_generic(order, flags, status, zone)
 

Definition at line 94 of file frame.h.

Referenced by slab_space_alloc().

#define FRAME_ATOMIC   0x4
 

Definition at line 62 of file frame.h.

Referenced by clock_counter_init(), cpu_init(), fb_init(), frame_alloc_generic(), ipc_irq_send_msg(), ipc_irq_send_notif(), klog_init(), and make_empty_current_mag().

#define FRAME_ERROR   2
 

Definition at line 67 of file frame.h.

#define FRAME_KA   0x1
 

Definition at line 60 of file frame.h.

Referenced by cpu_init(), page_arch_init(), pt_mapping_insert(), ptl0_create(), slab_space_alloc(), and thr_constructor().

#define FRAME_NO_MEMORY   1
 

Definition at line 66 of file frame.h.

Referenced by frame_alloc_generic().

#define FRAME_NO_RECLAIM   0x8
 

Definition at line 63 of file frame.h.

Referenced by frame_alloc_generic(), and make_empty_current_mag().

#define FRAME_OK   0
 

Definition at line 65 of file frame.h.

Referenced by frame_alloc_generic(), and slab_space_alloc().

#define FRAME_PANIC   0x2
 

Definition at line 61 of file frame.h.

Referenced by cpu_init(), frame_alloc_generic(), page_arch_init(), and ptl0_create().

#define IS_BUDDY_LEFT_BLOCK zone,
frame   )     (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
 

Definition at line 87 of file frame.h.

#define IS_BUDDY_LEFT_BLOCK_ABS zone,
frame   )     (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
 

Definition at line 89 of file frame.h.

Referenced by zone_buddy_find_buddy().

#define IS_BUDDY_ORDER_OK index,
order   )     ((~(((__native) -1) << (order)) & (index)) == 0)
 

Definition at line 86 of file frame.h.

Referenced by zone_buddy_find_buddy().

#define IS_BUDDY_RIGHT_BLOCK zone,
frame   )     (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
 

Definition at line 88 of file frame.h.

#define IS_BUDDY_RIGHT_BLOCK_ABS zone,
frame   )     (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
 

Definition at line 90 of file frame.h.

Referenced by zone_buddy_find_buddy().

#define ONE_FRAME   0
 

Definition at line 47 of file frame.h.

Referenced by anon_page_fault(), pt_mapping_insert(), and ptl0_create().

#define PAGE_CACHEABLE   (1<<PAGE_CACHEABLE_SHIFT)
 

Definition at line 55 of file page.h.

Referenced by area_flags_to_page_flags(), page_arch_init(), and pt_mapping_insert().

#define PAGE_CACHEABLE_SHIFT   0
 

Definition at line 43 of file page.h.

#define PAGE_EXEC   (1<<PAGE_EXEC_SHIFT)
 

Definition at line 65 of file page.h.

Referenced by area_flags_to_page_flags(), and pt_mapping_insert().

#define PAGE_EXEC_SHIFT   5
 

Definition at line 51 of file page.h.

#define PAGE_GLOBAL   (1<<PAGE_GLOBAL_SHIFT)
 

Definition at line 67 of file page.h.

Referenced by page_arch_init().

#define PAGE_GLOBAL_SHIFT   6
 

Definition at line 52 of file page.h.

#define PAGE_KERNEL   (0<<PAGE_USER_SHIFT)
 

Definition at line 61 of file page.h.

#define PAGE_KERNEL_SHIFT   PAGE_USER_SHIFT
 

Definition at line 48 of file page.h.

#define PAGE_NOT_CACHEABLE   (0<<PAGE_CACHEABLE_SHIFT)
 

Definition at line 54 of file page.h.

Referenced by hw_map(), and map_structure().

#define PAGE_NOT_CACHEABLE_SHIFT   PAGE_CACHEABLE_SHIFT
 

Definition at line 44 of file page.h.

#define PAGE_NOT_PRESENT   (1<<PAGE_PRESENT_SHIFT)
 

Definition at line 58 of file page.h.

Referenced by pt_mapping_find(), pt_mapping_insert(), and pt_mapping_remove().

#define PAGE_NOT_PRESENT_SHIFT   PAGE_PRESENT_SHIFT
 

Definition at line 46 of file page.h.

#define PAGE_PRESENT   (0<<PAGE_PRESENT_SHIFT)
 

Definition at line 57 of file page.h.

Referenced by area_flags_to_page_flags(), and pt_mapping_insert().

#define PAGE_PRESENT_SHIFT   1
 

Definition at line 45 of file page.h.

#define PAGE_READ   (1<<PAGE_READ_SHIFT)
 

Definition at line 63 of file page.h.

Referenced by area_flags_to_page_flags().

#define PAGE_READ_SHIFT   3
 

Definition at line 49 of file page.h.

#define PAGE_USER   (1<<PAGE_USER_SHIFT)
 

Definition at line 60 of file page.h.

Referenced by area_flags_to_page_flags(), and pt_mapping_insert().

#define PAGE_USER_SHIFT   2
 

Definition at line 47 of file page.h.

#define PAGE_WRITE   (1<<PAGE_WRITE_SHIFT)
 

Definition at line 64 of file page.h.

Referenced by area_flags_to_page_flags(), and pt_mapping_insert().

#define PAGE_WRITE_SHIFT   4
 

Definition at line 50 of file page.h.

#define SLAB_CACHE_MAGDEFERRED   (0x4 | SLAB_CACHE_NOMAGAZINE)
 

We add magazine cache later, if we have this flag

Definition at line 66 of file slab.h.

Referenced by btree_init(), slab_cache_init(), and slab_enable_cpucache().

#define SLAB_CACHE_NOMAGAZINE   0x1
 

Do not use per-cpu cache

Definition at line 63 of file slab.h.

Referenced by _slab_cache_create(), _slab_free(), _slab_reclaim(), slab_alloc(), slab_cache_destroy(), and slab_cache_init().

#define SLAB_CACHE_SLINSIDE   0x2
 

Have control structure inside SLAB

Definition at line 64 of file slab.h.

Referenced by _slab_cache_create(), badness(), comp_objects(), slab_cache_init(), slab_print_list(), slab_space_alloc(), and slab_space_free().

#define SLAB_INSIDE_SIZE   (PAGE_SIZE >> 3)
 

If object size is less, store control structure inside SLAB

Definition at line 53 of file slab.h.

Referenced by _slab_cache_create().

#define SLAB_MAG_SIZE   4
 

Initial Magazine size (TODO: dynamically growing magazines)

Definition at line 50 of file slab.h.

Referenced by make_empty_current_mag(), and slab_cache_init().

#define SLAB_MAX_BADNESS cache   )     ((PAGE_SIZE << (cache)->order) >> 2)
 

Maximum wasted space we allow for cache

Definition at line 56 of file slab.h.

Referenced by _slab_cache_create().

#define SLAB_MAX_MALLOC_W   18
 

Maximum size to be allocated by malloc

Definition at line 47 of file slab.h.

Referenced by malloc(), and slab_cache_init().

#define SLAB_MIN_MALLOC_W   4
 

Minimum size to be allocated by malloc

Definition at line 44 of file slab.h.

Referenced by malloc(), and slab_cache_init().

#define SLAB_RECLAIM_ALL   0x1
 

Reclaim all possible memory, because we are in memory stress

Definition at line 59 of file slab.h.

Referenced by _slab_reclaim(), frame_alloc_generic(), and slab_cache_destroy().

#define STACK_FRAMES   ONE_FRAME
 

Definition at line 53 of file frame.h.

Referenced by cpu_init(), thr_constructor(), and thread_create().

#define TLB_MESSAGE_QUEUE_LEN   10
 

Number of TLB shootdown messages that can be queued in processor tlb_messages queue.

Definition at line 46 of file tlb.h.

Referenced by tlb_shootdown_ipi_recv(), and tlb_shootdown_start().

#define TWO_FRAMES   1
 

Definition at line 48 of file frame.h.

#define ZONE_JOIN   0x1
 

If possible, merge with neighbouring zones

Definition at line 58 of file frame.h.

#define ZONES_MAX   16
 

Maximum number of zones in system

Definition at line 56 of file frame.h.

Referenced by zones_add_zone().


Typedef Documentation

typedef struct page_mapping_operations page_mapping_operations_t
 

Definition at line 83 of file page.h.

typedef enum pf_access pf_access_t
 

Definition at line 75 of file page.h.

typedef enum tlb_invalidate_type tlb_invalidate_type_t
 

Definition at line 55 of file tlb.h.

typedef struct tlb_shootdown_msg tlb_shootdown_msg_t
 

Definition at line 64 of file tlb.h.


Enumeration Type Documentation

enum pf_access
 

Page fault access type.

Enumerator:
PF_ACCESS_READ 
PF_ACCESS_WRITE 
PF_ACCESS_EXEC 

Definition at line 70 of file page.h.

enum tlb_invalidate_type
 

Type of TLB shootdown message.

Enumerator:
TLB_INVL_INVALID  Invalid type.
TLB_INVL_ALL  Invalidate all entries in TLB.
TLB_INVL_ASID  Invalidate all entries belonging to one address space.
TLB_INVL_PAGES  Invalidate specified page range belonging to one address space.

Definition at line 49 of file tlb.h.


Function Documentation

static void _slab_cache_create slab_cache_t cache,
char *  name,
size_t  size,
size_t  align,
int(*)(void *obj, int kmflag)  constructor,
int(*)(void *obj)  destructor,
int  flags
[static]
 

Initialize allocated memory as a slab cache

Definition at line 563 of file slab.c.

References ALIGN_UP, badness(), comp_objects(), fnzb, interrupts_disable(), interrupts_restore(), list_append(), list_initialize(), make_magcache(), memsetb(), SIZE2FRAMES(), SLAB_CACHE_NOMAGAZINE, SLAB_CACHE_SLINSIDE, SLAB_INSIDE_SIZE, SLAB_MAX_BADNESS, spinlock_initialize(), spinlock_lock, and spinlock_unlock().

Referenced by slab_cache_create(), and slab_cache_init().

Here is the call graph for this function:

static void _slab_free slab_cache_t cache,
void *  obj,
slab_t slab
[static]
 

Return object to cache, use slab if known

Definition at line 748 of file slab.c.

References slab_cache_t::allocated_objs, atomic_dec(), slab_cache_t::flags, interrupts_disable(), interrupts_restore(), magazine_obj_put(), SLAB_CACHE_NOMAGAZINE, and slab_obj_destroy().

Referenced by free(), and slab_free().

Here is the call graph for this function:

static count_t _slab_reclaim slab_cache_t cache,
int  flags
[static]
 

Reclaim space occupied by objects that are already free

Parameters:
flags If contains SLAB_RECLAIM_ALL, do aggressive freeing
Returns:
Number of freed pages

Definition at line 647 of file slab.c.

References atomic_get(), config, config_t::cpu_count, slab_mag_cache_t::current, slab_cache_t::flags, get_mag_from_cache(), slab_mag_cache_t::last, slab_cache_t::mag_cache, slab_cache_t::magazine_counter, magazine_destroy(), NULL, SLAB_CACHE_NOMAGAZINE, SLAB_RECLAIM_ALL, spinlock_lock, and spinlock_unlock().

Referenced by slab_cache_destroy(), and slab_reclaim().

Here is the call graph for this function:

static void _zone_merge zone_t z,
zone_t z1,
zone_t z2
[static]
 

Join 2 zones

Expect zone_t *z to point to space at least zone_conf_size large

Assume z1 & z2 are locked

Parameters:
z Target zone structure pointer
z1 Zone to merge
z2 Zone to merge

Definition at line 538 of file frame.c.

References ASSERT, zone_t::base, buddy_conf_size(), zone_t::buddy_system, buddy_system_create(), zone_t::busy_count, zone_t::count, zone_t::flags, fnzb, frame_initialize(), zone_t::free_count, overlaps(), spinlock_initialize(), and zone_buddy_system_operations.

Referenced by zone_merge().

Here is the call graph for this function:

static pfn_t ADDR2PFN __address  addr  )  [static]
 

Definition at line 74 of file frame.h.

References FRAME_WIDTH.

Referenced by anon_frame_free(), anon_share(), elf_frame_free(), elf_share(), frame_arch_init(), frame_init(), hw_map(), obj2slab(), ptl0_destroy(), return_config_frames(), sh_info_remove_reference(), slab_space_alloc(), slab_space_free(), and thr_destructor().

void anon_frame_free as_area_t area,
__address  page,
__address  frame
[static]
 

Free a frame that is backed by the anonymous memory backend.

The address space area and page tables must be already locked.

Parameters:
area Ignored.
page Ignored.
frame Frame to be released.

Definition at line 159 of file backend_anon.c.

References ADDR2PFN(), and frame_free().

Here is the call graph for this function:

int anon_page_fault as_area_t area,
__address  addr,
pf_access_t  access
[static]
 

Service a page fault in the anonymous memory address space area.

The address space area and page tables must be already locked.

Parameters:
area Pointer to the address space area.
addr Faulting virtual address.
access Access mode that caused the fault (i.e. read/write/exec).
Returns:
AS_PF_FAULT on failure (i.e. page fault) or AS_PF_OK on success (i.e. serviced).

Definition at line 74 of file backend_anon.c.

References ALIGN_DOWN, as_area_check_access(), btree_insert(), btree_search(), frame_alloc, FRAME_SIZE, btree_node::key, btree_node::keys, memsetb(), mutex_lock, ONE_FRAME, PAGE_SIZE, and PFN2ADDR().

Here is the call graph for this function:

void anon_share as_area_t area  )  [static]
 

Share the anonymous address space area.

Sharing of anonymous area is done by duplicating its entire mapping to the pagemap. Page faults will primarily search for frames there.

The address space and address space area must be already locked.

Parameters:
area Address space area to be shared.

Definition at line 173 of file backend_anon.c.

References ADDR2PFN(), ASSERT, btree_insert(), count, frame_reference_add(), btree_node::key, btree_node::keys, list_get_instance, mutex_lock, link::next, NULL, page_mapping_find(), PAGE_SIZE, page_table_lock(), page_table_unlock(), and btree_node::value.

Here is the call graph for this function:

int area_flags_to_page_flags int  aflags  )  [static]
 

Convert address space area flags to page flags.

Parameters:
aflags Flags of some address space area.
Returns:
Flags to be passed to page_mapping_insert().

Definition at line 832 of file as.c.

References AS_AREA_CACHEABLE, AS_AREA_EXEC, AS_AREA_READ, AS_AREA_WRITE, PAGE_CACHEABLE, PAGE_EXEC, PAGE_PRESENT, PAGE_READ, PAGE_USER, and PAGE_WRITE.

Referenced by as_area_get_flags().

bool as_area_check_access as_area_t area,
pf_access_t  access
 

Check access mode for address space area.

The address space area must be locked prior to this call.

Parameters:
area Address space area.
access Access mode.
Returns:
False if access violates area's permissions, true otherwise.

Definition at line 634 of file as.c.

References AS_AREA_EXEC, AS_AREA_READ, AS_AREA_WRITE, PF_ACCESS_EXEC, PF_ACCESS_READ, and PF_ACCESS_WRITE.

Referenced by anon_page_fault(), elf_page_fault(), and phys_page_fault().

as_area_t* as_area_create as_t as,
int  flags,
size_t  size,
__address  base,
int  attrs,
mem_backend_t *  backend,
mem_backend_data_t *  backend_data
 

Create address space area of common attributes.

The created address space area is added to the target address space.

Parameters:
as Target address space.
flags Flags of the area memory.
size Size of area.
base Base address of area.
attrs Attributes of the area.
backend Address space area backend. NULL if no backend is used.
backend_data NULL or a pointer to an array holding two void *.
Returns:
Address space area on success or NULL on failure.

Definition at line 198 of file as.c.

References AS_AREA_EXEC, AS_AREA_WRITE, btree_create(), btree_insert(), check_area_conflicts(), interrupts_disable(), interrupts_restore(), malloc(), memsetb(), mutex_initialize(), mutex_lock, mutex_unlock(), NULL, PAGE_SIZE, and SIZE2FRAMES().

Referenced by as_area_share(), ddi_physmem_map(), load_segment(), sys_as_area_create(), and task_run_program().

Here is the call graph for this function:

int as_area_destroy as_t as,
__address  address
 

Destroy address space area.

Parameters:
as Address space.
address Address withing the area to be deleted.
Returns:
Zero on success or a value from errno.h on failure.

Definition at line 417 of file as.c.

References AS, ASSERT, ENOENT, find_area_and_lock(), interrupts_disable(), interrupts_restore(), btree_node::key, btree_node::keys, list_get_instance, mutex_lock, mutex_unlock(), link::next, page_mapping_find(), page_mapping_remove(), PAGE_SIZE, page_table_lock(), page_table_unlock(), TLB_INVL_PAGES, tlb_shootdown_start(), and btree_node::value.

Referenced by as_destroy(), and sys_as_area_destroy().

Here is the call graph for this function:

int as_area_get_flags as_area_t a  ) 
 

Compute flags for virtual address translation subsytem.

The address space area must be locked. Interrupts must be disabled.

Parameters:
a Address space area.
Returns:
Flags to be used in page_mapping_insert().

Definition at line 862 of file as.c.

References area_flags_to_page_flags().

Referenced by phys_page_fault().

Here is the call graph for this function:

int as_area_resize as_t as,
__address  address,
size_t  size,
int  flags
 

Find address space area and change it.

Parameters:
as Address space.
address Virtual address belonging to the area to be changed. Must be page-aligned.
size New size of the virtual memory block starting at address.
flags Flags influencing the remap operation. Currently unused.
Returns:
Zero on success or a value from errno.h otherwise.

Definition at line 258 of file as.c.

References AS, ASSERT, ENOENT, ENOTSUP, EPERM, find_area_and_lock(), interrupts_disable(), interrupts_restore(), list_empty(), list_get_instance, mutex_lock, mutex_unlock(), overlaps(), page_mapping_find(), page_mapping_remove(), PAGE_SIZE, page_table_lock(), page_table_unlock(), PAGE_WIDTH, panic, phys_backend, SIZE2FRAMES(), TLB_INVL_PAGES, tlb_shootdown_start(), and used_space_remove().

Referenced by sys_as_area_resize().

Here is the call graph for this function:

int as_area_share as_t src_as,
__address  src_base,
size_t  acc_size,
as_t dst_as,
__address  dst_base,
int  dst_flags_mask
 

Share address space area with another or the same address space.

Address space area mapping is shared with a new address space area. If the source address space area has not been shared so far, a new sh_info is created. The new address space area simply gets the sh_info of the source area. The process of duplicating the mapping is done through the backend share function.

Parameters:
src_as Pointer to source address space.
src_base Base address of the source address space area.
acc_size Expected size of the source area.
dst_as Pointer to destination address space.
dst_base Target base address.
dst_flags_mask Destination address space area flags mask.
Returns:
Zero on success or ENOENT if there is no such task or if there is no such address space area, EPERM if there was a problem in accepting the area or ENOMEM if there was a problem in allocating destination address space area. ENOTSUP is returned if an attempt to share non-anonymous address space area is detected.

Definition at line 517 of file as.c.

References AS_AREA_CACHEABLE, as_area_create(), btree_create(), ENOENT, ENOMEM, ENOTSUP, EPERM, find_area_and_lock(), interrupts_disable(), interrupts_restore(), malloc(), mutex_initialize(), mutex_lock, mutex_unlock(), PAGE_SIZE, and sh_info_remove_reference().

Referenced by answer_preprocess().

Here is the call graph for this function:

as_t* as_create int  flags  ) 
 

Create address space.

Parameters:
flags Flags that influence way in wich the address space is created.

Definition at line 114 of file as.c.

References ASID_INVALID, ASID_KERNEL, btree_create(), link_initialize(), malloc(), mutex_initialize(), and page_table_create().

Referenced by as_init(), and task_run_program().

Here is the call graph for this function:

void as_destroy as_t as  ) 
 

Destroy adress space.

When there are no tasks referencing this address space (i.e. its refcount is zero), the address space can be destroyed.

Definition at line 140 of file as.c.

References AS, as_area_destroy(), AS_KERNEL, ASID_INVALID, asid_put, ASSERT, interrupts_disable(), list_empty(), list_get_instance, list_remove(), spinlock_lock, and spinlock_unlock().

Referenced by task_destroy(), and task_run_program().

Here is the call graph for this function:

size_t as_get_size __address  base  ) 
 

Return size of the address space area with given base.

Definition at line 1070 of file as.c.

References AS, find_area_and_lock(), interrupts_disable(), interrupts_restore(), mutex_unlock(), and PAGE_SIZE.

Referenced by request_preprocess().

Here is the call graph for this function:

void as_init void   ) 
 

Initialize address space subsystem.

Definition at line 101 of file as.c.

References as_arch_init(), as_create(), AS_KERNEL, and panic.

Referenced by main_bsp_separated_stack().

Here is the call graph for this function:

int as_page_fault __address  page,
pf_access_t  access,
istate_t istate
 

Handle page fault within the current address space.

This is the high-level page fault handler. It decides whether the page fault can be resolved by any backend and if so, it invokes the backend to resolve the page fault.

Interrupts are assumed disabled.

Parameters:
page Faulting page.
access Access mode that caused the fault (i.e. read/write/exec).
istate Pointer to interrupted state.
Returns:
AS_PF_FAULT on page fault, AS_PF_OK on success or AS_PF_DEFER if the fault was caused by copy_to_uspace() or copy_from_uspace().

Definition at line 664 of file as.c.

References AS, ASSERT, find_area_and_lock(), mutex_lock, mutex_unlock(), page_mapping_find(), page_table_lock(), page_table_unlock(), PF_ACCESS_EXEC, PF_ACCESS_READ, PF_ACCESS_WRITE, and THREAD.

Referenced by find_mapping_and_check().

Here is the call graph for this function:

void as_switch as_t old,
as_t new
 

Switch address spaces.

Note that this function cannot sleep as it is essentially a part of scheduling. Sleeping here would lead to deadlock on wakeup.

Parameters:
old Old address space or NULL.
new New address space.

Definition at line 762 of file as.c.

References AS, as_install_arch, AS_KERNEL, asid_get, ASID_INVALID, ASSERT, interrupts_disable(), interrupts_restore(), list_append(), list_remove(), mutex_lock_active, mutex_unlock(), spinlock_lock, and spinlock_unlock().

Referenced by scheduler_separated_stack().

Here is the call graph for this function:

asid_t asid_find_free void   ) 
 

Allocate free ASID.

Allocation runs in O(1).

Returns:
Free ASID.

Definition at line 81 of file asid_fifo.c.

References fifo_pop.

Referenced by asid_get().

asid_t asid_get void   ) 
 

Allocate free address space identifier.

Interrupts must be disabled and inactive_as_with_asid_lock must be held prior to this call

Returns:
New ASID.

Definition at line 83 of file asid.c.

References asid_find_free(), ASID_INVALID, asidlock, ASIDS_ALLOCABLE, asids_allocated, ASSERT, list_empty(), list_get_instance, list_remove(), mutex_lock_active, mutex_unlock(), link::next, spinlock_lock, spinlock_unlock(), tlb_invalidate_asid(), TLB_INVL_ASID, tlb_shootdown_finalize(), and tlb_shootdown_start().

Here is the call graph for this function:

void asid_install as_t as  ) 
 

void asid_put asid_t  asid  ) 
 

Release address space identifier.

This code relies on architecture dependent functionality.

Parameters:
asid ASID to be released.

Definition at line 163 of file asid.c.

References asid_put_arch(), asidlock, asids_allocated, interrupts_disable(), interrupts_restore(), spinlock_lock, and spinlock_unlock().

Here is the call graph for this function:

void asid_put_arch asid_t  asid  ) 
 

Return ASID among free ASIDs.

This operation runs in O(1).

Parameters:
asid ASID being freed.

Definition at line 92 of file asid_fifo.c.

References fifo_push.

Referenced by asid_put().

static int badness slab_cache_t cache  )  [static]
 

Return wasted space in slab

Definition at line 531 of file slab.c.

References comp_objects(), slab_cache_t::flags, slab_cache_t::order, PAGE_SIZE, slab_cache_t::size, and SLAB_CACHE_SLINSIDE.

Referenced by _slab_cache_create().

Here is the call graph for this function:

size_t buddy_conf_size int  max_order  ) 
 

Return size needed for the buddy configuration data

Definition at line 51 of file buddy.c.

Referenced by _zone_merge(), zone_conf_size(), and zone_construct().

link_t * buddy_system_alloc buddy_system_t b,
__u8  i
 

Allocate block from buddy system.

Parameters:
b Buddy system pointer.
i Returned block will be 2^i big.
Returns:
Block of data represented by link_t.

Definition at line 170 of file buddy.c.

References ASSERT, buddy_system_operations::bisect, buddy_system_free(), list_empty(), list_remove(), buddy_system_operations::mark_busy, buddy_system::max_order, link::next, NULL, buddy_system::op, buddy_system::order, and buddy_system_operations::set_order.

Referenced by zone_frame_alloc().

Here is the call graph for this function:

link_t * buddy_system_alloc_block buddy_system_t b,
link_t block
 

Allocate PARTICULAR block from buddy system

@ return Block of data or NULL if no such block was found

Definition at line 130 of file buddy.c.

References ASSERT, buddy_system_operations::bisect, buddy_system_free(), BUDDY_SYSTEM_INNER_BLOCK, buddy_system_operations::find_block, buddy_system_operations::get_order, list_remove(), buddy_system_operations::mark_available, buddy_system_operations::mark_busy, buddy_system::op, and buddy_system_operations::set_order.

Referenced by zone_mark_unavailable().

Here is the call graph for this function:

bool buddy_system_can_alloc buddy_system_t b,
__u8  i
 

Check if buddy system can allocate block

Parameters:
b Buddy system pointer
i Size of the block (2^i)
Returns:
True if block can be allocated

Definition at line 104 of file buddy.c.

References list_empty(), buddy_system::max_order, and buddy_system::order.

Referenced by zone_can_alloc().

Here is the call graph for this function:

void buddy_system_create buddy_system_t b,
__u8  max_order,
buddy_system_operations_t op,
void *  data
 

Create buddy system

Allocate memory for and initialize new buddy system.

Parameters:
b Preallocated buddy system control data.
max_order The biggest allocable size will be 2^max_order.
op Operations for new buddy system.
data Pointer to be used by implementation.
Returns:
New buddy system.

Definition at line 68 of file buddy.c.

References ASSERT, buddy_system_operations::bisect, BUDDY_SYSTEM_INNER_BLOCK, buddy_system_operations::coalesce, buddy_system::data, buddy_system_operations::find_buddy, buddy_system_operations::get_order, list_initialize(), buddy_system_operations::mark_busy, buddy_system::max_order, buddy_system::op, buddy_system::order, and buddy_system_operations::set_order.

Referenced by _zone_merge(), and zone_construct().

Here is the call graph for this function:

void buddy_system_free buddy_system_t b,
link_t block
 

Return block to buddy system.

Parameters:
b Buddy system pointer.
block Block to return.

Definition at line 230 of file buddy.c.

References ASSERT, BUDDY_SYSTEM_INNER_BLOCK, buddy_system_operations::find_buddy, buddy_system_operations::get_order, list_append(), list_remove(), buddy_system::max_order, buddy_system::op, and buddy_system::order.

Referenced by buddy_system_alloc(), buddy_system_alloc_block(), and zone_frame_free().

Here is the call graph for this function:

void buddy_system_structure_print buddy_system_t b,
size_t  elem_size
 

Prints out structure of buddy system

Parameters:
b Pointer to buddy system
elem_size Element size

Definition at line 291 of file buddy.c.

References list_empty(), buddy_system::max_order, link::next, buddy_system::order, and printf().

Here is the call graph for this function:

bool check_area_conflicts as_t as,
__address  va,
size_t  size,
as_area_t avoid_area
[static]
 

Check area conflicts with other areas.

The address space must be locked and interrupts must be disabled.

Parameters:
as Address space.
va Starting virtual address of the area being tested.
size Size of the area being tested.
avoid_area Do not touch this area.
Returns:
True if there is no conflict, false otherwise.

Definition at line 997 of file as.c.

References btree_leaf_node_left_neighbour(), btree_leaf_node_right_neighbour(), btree_search(), btree_node::keys, mutex_lock, mutex_unlock(), NULL, overlaps(), PAGE_SIZE, and btree_node::value.

Referenced by as_area_create().

Here is the call graph for this function:

static int comp_objects slab_cache_t cache  )  [static]
 

Return number of objects that fit in certain cache size

Definition at line 522 of file slab.c.

References slab_cache_t::flags, slab_cache_t::order, PAGE_SIZE, slab_cache_t::size, and SLAB_CACHE_SLINSIDE.

Referenced by _slab_cache_create(), and badness().

void elf_frame_free as_area_t area,
__address  page,
__address  frame
[static]
 

Free a frame that is backed by the ELF backend.

The address space area and page tables must be already locked.

Parameters:
area Pointer to the address space area.
page Page that is mapped to frame. Must be aligned to PAGE_SIZE.
frame Frame to be released.

Definition at line 204 of file backend_elf.c.

References ADDR2PFN(), ALIGN_UP, ASSERT, frame_free(), FRAME_SIZE, PAGE_SIZE, PAGE_WIDTH, and PF_W.

Here is the call graph for this function:

int elf_page_fault as_area_t area,
__address  addr,
pf_access_t  access
[static]
 

Service a page fault in the ELF backend address space area.

The address space area and page tables must be already locked.

Parameters:
area Pointer to the address space area.
addr Faulting virtual address.
access Access mode that caused the fault (i.e. read/write/exec).
Returns:
AS_PF_FAULT on failure (i.e. page fault) or AS_PF_OK on success (i.e. serviced).

Definition at line 73 of file backend_elf.c.

References ALIGN_DOWN, ALIGN_UP, as_area_check_access(), ASSERT, btree_search(), FRAME_SIZE, btree_node::key, btree_node::keys, mutex_lock, PAGE_SIZE, and PAGE_WIDTH.

Here is the call graph for this function:

void elf_share as_area_t area  )  [static]
 

Share ELF image backed address space area.

If the area is writable, then all mapped pages are duplicated in the pagemap. Otherwise only portions of the area that are not backed by the ELF image are put into the pagemap.

The address space and address space area must be locked prior to the call.

Parameters:
area Address space area.

Definition at line 243 of file backend_elf.c.

References ADDR2PFN(), AS_AREA_WRITE, ASSERT, btree_insert(), btree_leaf_node_left_neighbour(), btree_search(), count, frame_reference_add(), btree_node::key, btree_node::keys, btree_node::leaf_link, list_get_instance, mutex_lock, link::next, NULL, page_mapping_find(), PAGE_SIZE, page_table_lock(), page_table_unlock(), and btree_node::value.

Here is the call graph for this function:

as_area_t * find_area_and_lock as_t as,
__address  va
[static]
 

Find address space area and lock it.

The address space must be locked and interrupts must be disabled.

Parameters:
as Address space.
va Virtual address.
Returns:
Locked address space area containing va on success or NULL on failure.

Definition at line 941 of file as.c.

References btree_search(), btree_node::keys, mutex_lock, PAGE_SIZE, and btree_node::value.

Referenced by as_area_destroy(), as_area_resize(), as_area_share(), as_get_size(), and as_page_fault().

Here is the call graph for this function:

static zone_t* find_free_zone_lock __u8  order,
int *  pzone
[static]
 

Find AND LOCK zone that can allocate order frames

Assume interrupts are disabled!!

Parameters:
order Size (2^order) of free space we are trying to find
pzone Pointer to preferred zone or NULL, on return contains zone number

Definition at line 233 of file frame.c.

References NULL, spinlock_lock, spinlock_unlock(), zone_can_alloc(), and zones.

Referenced by frame_alloc_generic().

Here is the call graph for this function:

static zone_t* find_zone_and_lock pfn_t  frame,
int *  pzone
[static]
 

Try to find a zone where can we find the frame

Parameters:
frame Frame number contained in zone
pzone If not null, it is used as zone hint. Zone index is filled into the variable on success.
Returns:
Pointer to LOCKED zone containing frame
Assume interrupts disable

Definition at line 187 of file frame.c.

References zone_t::base, zone_t::count, NULL, spinlock_lock, spinlock_unlock(), and zones.

Referenced by frame_free(), frame_get_parent(), frame_mark_unavailable(), frame_reference_add(), and frame_set_parent().

Here is the call graph for this function:

pfn_t frame_alloc_generic __u8  order,
int  flags,
int *  status,
int *  pzone
 

Allocate power-of-two frames of physical memory.

Parameters:
order Allocate exactly 2^order frames.
flags Flags for host zone selection and address processing.
status Allocation status (FRAME_OK on success), unused if NULL.
pzone Preferred zone
Returns:
Allocated frame.

Definition at line 934 of file frame.c.

References ASSERT, zone_t::base, find_free_zone_lock(), FRAME_ATOMIC, FRAME_NO_MEMORY, FRAME_NO_RECLAIM, FRAME_OK, FRAME_PANIC, interrupts_disable(), interrupts_restore(), NULL, panic, slab_reclaim(), SLAB_RECLAIM_ALL, spinlock_unlock(), and zone_frame_alloc().

Here is the call graph for this function:

void frame_free pfn_t  pfn  ) 
 

Free a frame.

Find respective frame structure for supplied PFN. Decrement frame reference count. If it drops to zero, move the frame structure to free list.

Parameters:
pfn Frame number of the frame to be freed.

Definition at line 1000 of file frame.c.

References ASSERT, zone_t::base, find_zone_and_lock(), interrupts_disable(), interrupts_restore(), NULL, spinlock_unlock(), and zone_frame_free().

Referenced by anon_frame_free(), elf_frame_free(), ptl0_destroy(), sh_info_remove_reference(), slab_space_alloc(), slab_space_free(), and thr_destructor().

Here is the call graph for this function:

void * frame_get_parent pfn_t  frame,
int  hint
 

Definition at line 912 of file frame.c.

References ASSERT, zone_t::base, find_zone_and_lock(), frame_t::parent, spinlock_unlock(), and zone_get_frame().

Referenced by obj2slab().

Here is the call graph for this function:

static index_t frame_index zone_t zone,
frame_t frame
[static]
 

Definition at line 104 of file frame.c.

References zone_t::frames.

Referenced by zone_buddy_find_block(), zone_buddy_find_buddy(), and zone_buddy_print_id().

static index_t frame_index_abs zone_t zone,
frame_t frame
[static]
 

Definition at line 108 of file frame.c.

References zone_t::base, and zone_t::frames.

Referenced by zone_buddy_find_buddy().

static int frame_index_valid zone_t zone,
index_t  index
[static]
 

Definition at line 112 of file frame.c.

References zone_t::count.

Referenced by zone_buddy_find_buddy().

void frame_init void   ) 
 

Initialize physical memory management

Initialize physical memory managemnt.

Definition at line 1068 of file frame.c.

References init_task_t::addr, ADDR2PFN(), config_t::base, init_t::cnt, config, config_t::cpu_active, frame_arch_init(), frame_mark_unavailable(), init, config_t::kernel_size, init_task_t::size, SIZE2FRAMES(), spinlock_initialize(), init_t::tasks, and zones.

Referenced by main_ap(), and main_bsp_separated_stack().

Here is the call graph for this function:

static void frame_initialize frame_t frame  )  [static]
 

Initialize frame structure

Initialize frame structure.

Parameters:
frame Frame structure to be initialized.

Definition at line 129 of file frame.c.

References frame_t::buddy_order, and frame_t::refcount.

Referenced by _zone_merge(), and zone_construct().

void frame_mark_unavailable pfn_t  start,
count_t  count
 

Mark given range unavailable in frame zones

Definition at line 1048 of file frame.c.

References zone_t::base, find_zone_and_lock(), spinlock_unlock(), and zone_mark_unavailable().

Referenced by frame_init().

Here is the call graph for this function:

void frame_reference_add pfn_t  pfn  ) 
 

Add reference to frame.

Find respective frame structure for supplied PFN and increment frame reference count.

Parameters:
pfn Frame number of the frame to be freed.

Definition at line 1026 of file frame.c.

References ASSERT, zone_t::base, find_zone_and_lock(), zone_t::frames, interrupts_disable(), interrupts_restore(), NULL, frame_t::refcount, and spinlock_unlock().

Referenced by anon_share(), and elf_share().

Here is the call graph for this function:

void frame_set_parent pfn_t  pfn,
void *  data,
int  hint
 

Set parent of frame

Definition at line 902 of file frame.c.

References ASSERT, zone_t::base, find_zone_and_lock(), frame_t::parent, spinlock_unlock(), and zone_get_frame().

Referenced by slab_space_alloc().

Here is the call graph for this function:

void free void *  obj  ) 
 

Definition at line 900 of file slab.c.

References _slab_free(), slab_t::cache, and obj2slab().

Referenced by bubblesort(), code_free(), code_from_uspace(), futex_ht_remove_callback(), qsort(), sh_info_remove_reference(), slab_cache_destroy(), sys_io(), sys_sysinfo_valid(), sys_sysinfo_value(), sys_thread_create(), task_destroy(), and uinit().

Here is the call graph for this function:

static slab_magazine_t* get_full_current_mag slab_cache_t cache  )  [static]
 

Find full magazine, set it as current and return it

Assume cpu_magazine lock is held

Definition at line 384 of file slab.c.

References slab_magazine_t::busy, CPU, slab_mag_cache_t::current, get_mag_from_cache(), slab_mag_cache_t::last, slab_cache_t::mag_cache, magazine_destroy(), and NULL.

Referenced by magazine_obj_get().

Here is the call graph for this function:

static slab_magazine_t* get_mag_from_cache slab_cache_t cache,
int  first
[static]
 

Finds a full magazine in cache, takes it from list and returns it

Parameters:
first If true, return first, else last mag

Definition at line 327 of file slab.c.

References atomic_dec(), slab_magazine_t::link, list_empty(), list_get_instance, list_remove(), slab_cache_t::magazine_counter, slab_cache_t::magazines, link::next, NULL, link::prev, spinlock_lock, and spinlock_unlock().

Referenced by _slab_reclaim(), and get_full_current_mag().

Here is the call graph for this function:

__address hw_map __address  physaddr,
size_t  size
 

Definition at line 291 of file page.c.

References ADDR2PFN(), ALIGN_UP, AS_KERNEL, FRAME_SIZE, KERNEL_ADDRESS_SPACE_END_ARCH, last_frame, page_mapping_insert(), PAGE_NOT_CACHEABLE, PAGE_SIZE, panic, and PFN2ADDR().

Referenced by fb_init().

Here is the call graph for this function:

static LIST_INITIALIZE slab_cache_list   )  [static]
 

LIST_INITIALIZE inactive_as_with_asid_head   ) 
 

This list contains address spaces that are not active on any processor and that have valid ASID.

static count_t magazine_destroy slab_cache_t cache,
slab_magazine_t mag
[static]
 

Free all objects in magazine and free memory associated with magazine

Returns:
Number of freed pages

Definition at line 363 of file slab.c.

References atomic_dec(), slab_magazine_t::busy, slab_cache_t::cached_objs, NULL, slab_magazine_t::objs, and slab_obj_destroy().

Referenced by _slab_reclaim(), and get_full_current_mag().

Here is the call graph for this function:

static void* magazine_obj_get slab_cache_t cache  )  [static]
 

Try to find object in CPU-cache magazines

Returns:
Pointer to object or NULL if not available

Definition at line 418 of file slab.c.

References atomic_dec(), slab_magazine_t::busy, slab_cache_t::cached_objs, CPU, get_full_current_mag(), slab_cache_t::mag_cache, NULL, slab_magazine_t::objs, spinlock_lock, and spinlock_unlock().

Referenced by slab_alloc().

Here is the call graph for this function:

static int magazine_obj_put slab_cache_t cache,
void *  obj
[static]
 

Put object into CPU-cache magazine

Returns:
0 - success, -1 - could not get memory

Definition at line 495 of file slab.c.

References atomic_inc(), slab_magazine_t::busy, slab_cache_t::cached_objs, CPU, slab_cache_t::mag_cache, make_empty_current_mag(), slab_magazine_t::objs, spinlock_lock, and spinlock_unlock().

Referenced by _slab_free().

Here is the call graph for this function:

static slab_magazine_t* make_empty_current_mag slab_cache_t cache  )  [static]
 

Assure that the current magazine is empty, return pointer to it, or NULL if no empty magazine is available and cannot be allocated

Assume mag_cache[CPU->id].lock is held

We have 2 magazines bound to processor. First try the current. If full, try the last. If full, put to magazines list. allocate new, exchange last & current

Definition at line 453 of file slab.c.

References slab_magazine_t::busy, CPU, slab_mag_cache_t::current, FRAME_ATOMIC, FRAME_NO_RECLAIM, slab_mag_cache_t::last, mag_cache, slab_cache_t::mag_cache, NULL, put_mag_to_cache(), slab_magazine_t::size, slab_alloc(), and SLAB_MAG_SIZE.

Referenced by magazine_obj_put().

Here is the call graph for this function:

static index_t make_frame_index zone_t zone,
frame_t frame
[static]
 

Compute pfn_t from frame_t pointer & zone pointer

Definition at line 118 of file frame.c.

References zone_t::frames.

Referenced by zone_frame_alloc().

static void make_magcache slab_cache_t cache  )  [static]
 

Initialize mag_cache structure in slab cache

Definition at line 546 of file slab.c.

References ASSERT, config, config_t::cpu_count, slab_cache_t::mag_cache, malloc(), memsetb(), and spinlock_initialize().

Referenced by _slab_cache_create(), and slab_enable_cpucache().

Here is the call graph for this function:

void * malloc unsigned int  size,
int  flags
 

Definition at line 885 of file slab.c.

References ASSERT, fnzb, malloc_caches, slab_alloc(), SLAB_MAX_MALLOC_W, and SLAB_MIN_MALLOC_W.

Referenced by as_area_create(), as_area_share(), as_create(), bubblesort(), code_from_uspace(), cpu_init(), fb_init(), futex_find(), hash_table_create(), ipc_irq_make_table(), make_magcache(), qsort(), sys_io(), sys_sysinfo_valid(), sys_sysinfo_value(), sys_thread_create(), sysinfo_create_path(), task_create(), and task_run_program().

Here is the call graph for this function:

void map_structure __address  s,
size_t  size
 

Map memory structure

Identity-map memory structure considering possible crossings of page boundaries.

Parameters:
s Address of the structure.
size Size of the structure.

Definition at line 72 of file page.c.

References AS_KERNEL, page_mapping_insert(), PAGE_NOT_CACHEABLE, and PAGE_SIZE.

Here is the call graph for this function:

static slab_t* obj2slab void *  obj  )  [static]
 

Map object to slab structure

Definition at line 216 of file slab.c.

References ADDR2PFN(), and frame_get_parent().

Referenced by free(), and slab_obj_destroy().

Here is the call graph for this function:

void page_init void   ) 
 

Definition at line 58 of file page.c.

References page_arch_init().

Referenced by main_ap(), and main_bsp_separated_stack().

Here is the call graph for this function:

pte_t * page_mapping_find as_t as,
__address  page
 

Find mapping for virtual page

Find mapping for virtual page.

The page table must be locked and interrupts must be disabled.

Parameters:
as Address space to wich page belongs.
page Virtual page.
Returns:
NULL if there is no such mapping; requested mapping otherwise.

Definition at line 134 of file page.c.

References ASSERT, page_mapping_operations::mapping_find, and page_mapping_operations.

Referenced by anon_share(), as_area_destroy(), as_area_resize(), as_page_fault(), elf_share(), find_mapping_and_check(), sys_futex_sleep_timeout(), and sys_futex_wakeup().

void page_mapping_insert as_t as,
__address  page,
__address  frame,
int  flags
 

Insert mapping of page to frame.

Map virtual address page to physical address frame using flags. Allocate and setup any missing page tables.

The page table must be locked and interrupts must be disabled.

Parameters:
as Address space to wich page belongs.
page Virtual address of the page to be mapped.
frame Physical address of memory frame to which the mapping is done.
flags Flags to be used for mapping.

Definition at line 96 of file page.c.

References ASSERT, page_mapping_operations::mapping_insert, and page_mapping_operations.

Referenced by hw_map(), map_structure(), page_arch_init(), and phys_page_fault().

void page_mapping_remove as_t as,
__address  page
 

Remove mapping of page.

Remove any mapping of page within address space as. TLB shootdown should follow in order to make effects of this call visible.

The page table must be locked and interrupts must be disabled.

Parameters:
as Address space to wich page belongs.
page Virtual address of the page to be demapped.

Definition at line 115 of file page.c.

References ASSERT, page_mapping_operations::mapping_remove, and page_mapping_operations.

Referenced by as_area_destroy(), and as_area_resize().

pte_t * page_table_create int  flags  ) 
 

Create page table.

Depending on architecture, create either address space private or global page table.

Parameters:
flags Flags saying whether the page table is for kernel address space.
Returns:
First entry of the page table.

Definition at line 876 of file as.c.

References as_operations, and ASSERT.

Referenced by as_create().

void page_table_destroy pte_t page_table  ) 
 

Destroy page table.

Destroy page table in architecture specific way.

Parameters:
page_table Physical address of PTL0.

Definition at line 890 of file as.c.

References as_operations, and ASSERT.

void page_table_lock as_t as,
bool  lock
 

Lock page table.

This function should be called before any page_mapping_insert(), page_mapping_remove() and page_mapping_find().

Locking order is such that address space areas must be locked prior to this call. Address space can be locked prior to this call in which case the lock argument is false.

Parameters:
as Address space.
lock If false, do not attempt to lock as->lock.

Definition at line 910 of file as.c.

References as_operations, and ASSERT.

Referenced by anon_share(), as_area_destroy(), as_area_resize(), as_page_fault(), elf_share(), find_mapping_and_check(), pht_refill(), sys_futex_sleep_timeout(), and sys_futex_wakeup().

void page_table_unlock as_t as,
bool  unlock
 

Unlock page table.

Parameters:
as Address space.
unlock If false, do not attempt to unlock as->lock.

Definition at line 923 of file as.c.

References as_operations, and ASSERT.

Referenced by anon_share(), as_area_destroy(), as_area_resize(), as_page_fault(), elf_share(), find_mapping_and_check(), pht_refill(), sys_futex_sleep_timeout(), and sys_futex_wakeup().

static __address PFN2ADDR pfn_t  frame  )  [static]
 

Definition at line 69 of file frame.h.

References FRAME_WIDTH.

Referenced by anon_page_fault(), clock_counter_init(), cpu_init(), fb_init(), hw_map(), klog_init(), page_arch_init(), pt_mapping_insert(), ptl0_create(), slab_space_alloc(), thr_constructor(), zone_create(), zone_merge(), zone_print_list(), and zone_print_one().

int phys_page_fault as_area_t area,
__address  addr,
pf_access_t  access
[static]
 

Service a page fault in the address space area backed by physical memory.

The address space area and page tables must be already locked.

Parameters:
area Pointer to the address space area.
addr Faulting virtual address.
access Access mode that caused the fault (i.e. read/write/exec).
Returns:
AS_PF_FAULT on failure (i.e. page fault) or AS_PF_OK on success (i.e. serviced).

Definition at line 68 of file backend_phys.c.

References ALIGN_DOWN, AS, as_area_check_access(), as_area_get_flags(), ASSERT, FRAME_SIZE, page_mapping_insert(), PAGE_SIZE, panic, and used_space_insert().

Here is the call graph for this function:

void phys_share as_area_t area  )  [static]
 

Share address space area backed by physical memory.

Do actually nothing as sharing of address space areas that are backed up by physical memory is very easy. Note that the function must be defined so that as_area_share() will succeed.

Definition at line 90 of file backend_phys.c.

static void put_mag_to_cache slab_cache_t cache,
slab_magazine_t mag
[static]
 

Prepend magazine to magazine list in cache

Definition at line 348 of file slab.c.

References atomic_inc(), slab_magazine_t::link, list_prepend(), slab_cache_t::magazine_counter, slab_cache_t::magazines, spinlock_lock, and spinlock_unlock().

Referenced by make_empty_current_mag().

Here is the call graph for this function:

static void return_config_frames zone_t newzone,
zone_t oldzone
[static]
 

Return old configuration frames into the zone

We have several cases

  • the conf. data is outside of zone -> exit, shall we call frame_free??
  • the conf. data was created by zone_create or updated with reduce_region -> free every frame

Parameters:
newzone The actual zone where freeing should occur
oldzone Pointer to old zone configuration data that should be freed from new zone

Definition at line 620 of file frame.c.

References ADDR2PFN(), ASSERT, zone_t::base, frame_t::buddy_order, zone_t::busy_count, zone_t::count, zone_t::frames, SIZE2FRAMES(), zone_conf_size(), and zone_frame_free().

Referenced by zone_merge().

Here is the call graph for this function:

void sh_info_remove_reference share_info_t *  sh_info  )  [static]
 

Remove reference to address space area share info.

If the reference count drops to 0, the sh_info is deallocated.

Parameters:
sh_info Pointer to address space area share info.

Definition at line 1475 of file as.c.

References ADDR2PFN(), ASSERT, btree_destroy(), frame_free(), free(), btree_node::keys, list_get_instance, mutex_lock, mutex_unlock(), link::next, and btree_node::value.

Referenced by as_area_share().

Here is the call graph for this function:

static count_t SIZE2FRAMES size_t  size  )  [static]
 

Definition at line 79 of file frame.h.

References FRAME_WIDTH.

Referenced by _slab_cache_create(), as_area_create(), as_area_resize(), fb_init(), frame_arch_init(), frame_init(), return_config_frames(), zone_create(), and zone_merge().

void * slab_alloc slab_cache_t cache,
int  flags
 

Allocate new object from cache - if no flags given, always returns memory

Definition at line 725 of file slab.c.

References slab_cache_t::allocated_objs, atomic_inc(), slab_cache_t::flags, interrupts_disable(), interrupts_restore(), magazine_obj_get(), NULL, SLAB_CACHE_NOMAGAZINE, and slab_obj_create().

Referenced by _btree_insert(), btree_create(), ipc_call_alloc(), make_empty_current_mag(), malloc(), node_split(), slab_cache_create(), slab_space_alloc(), thr_constructor(), and thread_create().

Here is the call graph for this function:

slab_cache_t * slab_cache_create char *  name,
size_t  size,
size_t  align,
int(*)(void *obj, int kmflag)  constructor,
int(*)(void *obj)  destructor,
int  flags
 

Create slab cache

Definition at line 626 of file slab.c.

References _slab_cache_create(), slab_alloc(), and slab_cache_cache.

Referenced by btree_init(), ipc_init(), slab_cache_init(), and thread_init().

Here is the call graph for this function:

void slab_cache_destroy slab_cache_t cache  ) 
 

Check that there are no slabs and remove cache from system

Definition at line 691 of file slab.c.

References _slab_reclaim(), slab_cache_t::flags, free(), slab_cache_t::full_slabs, interrupts_disable(), interrupts_restore(), slab_cache_t::link, list_empty(), list_remove(), slab_cache_t::mag_cache, panic, slab_cache_t::partial_slabs, slab_cache_cache, SLAB_CACHE_NOMAGAZINE, slab_free(), SLAB_RECLAIM_ALL, spinlock_lock, and spinlock_unlock().

Here is the call graph for this function:

void slab_cache_init void   ) 
 

Initialize slab subsytem

Definition at line 817 of file slab.c.

References _slab_cache_create(), mag_cache, malloc_caches, malloc_names, NULL, slab_cache_cache, slab_cache_create(), SLAB_CACHE_MAGDEFERRED, SLAB_CACHE_NOMAGAZINE, SLAB_CACHE_SLINSIDE, slab_extern_cache, SLAB_MAG_SIZE, SLAB_MAX_MALLOC_W, and SLAB_MIN_MALLOC_W.

Referenced by main_bsp_separated_stack().

Here is the call graph for this function:

void slab_enable_cpucache void   ) 
 

Enable cpu_cache

Kernel calls this function, when it knows the real number of processors. Allocate slab for cpucache and enable it on all existing slabs that are SLAB_CACHE_MAGDEFERRED

Definition at line 861 of file slab.c.

References slab_cache_t::flags, list_get_instance, make_magcache(), link::next, SLAB_CACHE_MAGDEFERRED, spinlock_lock, and spinlock_unlock().

Referenced by main_bsp_separated_stack().

Here is the call graph for this function:

void slab_free slab_cache_t cache,
void *  obj
 

Return slab object to cache

Definition at line 765 of file slab.c.

References _slab_free(), and NULL.

Referenced by _btree_remove(), ipc_call_free(), slab_cache_destroy(), slab_space_free(), thr_constructor(), thr_destructor(), thread_create(), and thread_destroy().

Here is the call graph for this function:

static void* slab_obj_create slab_cache_t cache,
int  flags
[static]
 

Take new object from slab or create new if needed

Returns:
Object address or null

Definition at line 274 of file slab.c.

References slab_t::available, slab_cache_t::constructor, slab_cache_t::full_slabs, slab_t::link, list_empty(), list_get_instance, list_prepend(), list_remove(), link::next, slab_t::nextavail, NULL, slab_cache_t::partial_slabs, slab_cache_t::size, slab_obj_destroy(), slab_space_alloc(), spinlock_lock, spinlock_unlock(), and slab_t::start.

Referenced by slab_alloc().

Here is the call graph for this function:

static count_t slab_obj_destroy slab_cache_t cache,
void *  obj,
slab_t slab
[static]
 

Return object to slab and call a destructor

Parameters:
slab If the caller knows directly slab of the object, otherwise NULL
Returns:
Number of freed pages

Definition at line 232 of file slab.c.

References ASSERT, slab_t::available, slab_t::cache, slab_cache_t::destructor, slab_t::link, list_prepend(), list_remove(), slab_t::nextavail, obj2slab(), slab_cache_t::objects, slab_cache_t::partial_slabs, slab_cache_t::size, slab_space_free(), spinlock_lock, spinlock_unlock(), and slab_t::start.

Referenced by _slab_free(), magazine_destroy(), and slab_obj_create().

Here is the call graph for this function:

void slab_print_list void   ) 
 

Definition at line 795 of file slab.c.

References slab_cache_t::allocated_objs, slab_cache_t::allocated_slabs, atomic_get(), slab_cache_t::cached_objs, slab_cache_t::flags, interrupts_disable(), interrupts_restore(), list_get_instance, slab_cache_t::name, link::next, slab_cache_t::objects, slab_cache_t::order, printf(), slab_cache_t::size, SLAB_CACHE_SLINSIDE, spinlock_lock, and spinlock_unlock().

Referenced by cmd_slabs().

Here is the call graph for this function:

count_t slab_reclaim int  flags  ) 
 

Definition at line 771 of file slab.c.

References _slab_reclaim(), list_get_instance, link::next, spinlock_lock, and spinlock_unlock().

Referenced by frame_alloc_generic().

Here is the call graph for this function:

static slab_t* slab_space_alloc slab_cache_t cache,
int  flags
[static]
 

Allocate frames for slab space and initialize

Definition at line 157 of file slab.c.

References ADDR2PFN(), slab_cache_t::allocated_slabs, atomic_inc(), slab_t::available, slab_t::cache, slab_cache_t::flags, frame_alloc_rc_zone, frame_free(), FRAME_KA, FRAME_OK, frame_set_parent(), slab_t::nextavail, NULL, slab_cache_t::objects, slab_cache_t::order, PAGE_SIZE, PFN2ADDR(), slab_cache_t::size, slab_alloc(), SLAB_CACHE_SLINSIDE, slab_extern_cache, and slab_t::start.

Referenced by slab_obj_create().

Here is the call graph for this function:

static count_t slab_space_free slab_cache_t cache,
slab_t slab
[static]
 

Deallocate space associated with slab

Returns:
number of freed frames

Definition at line 204 of file slab.c.

References ADDR2PFN(), slab_cache_t::allocated_slabs, atomic_dec(), slab_cache_t::flags, frame_free(), slab_cache_t::order, SLAB_CACHE_SLINSIDE, slab_extern_cache, slab_free(), and slab_t::start.

Referenced by slab_obj_destroy().

Here is the call graph for this function:

SPINLOCK_INITIALIZE tlblock   ) 
 

This lock is used for synchronisation between sender and recipients of TLB shootdown message. It must be acquired before CPU structure lock.

SPINLOCK_INITIALIZE slab_cache_lock   ) 
 

SPINLOCK_INITIALIZE inactive_as_with_asid_lock   ) 
 

This lock protects inactive_as_with_asid_head list. It must be acquired before as_t mutex.

__native sys_as_area_create __address  address,
size_t  size,
int  flags
 

Wrapper for as_area_create().

Definition at line 1512 of file as.c.

References anon_backend, AS, AS_AREA_CACHEABLE, as_area_create(), and NULL.

Here is the call graph for this function:

__native sys_as_area_destroy __address  address  ) 
 

Wrapper for as_area_destroy.

Definition at line 1527 of file as.c.

References AS, and as_area_destroy().

Here is the call graph for this function:

__native sys_as_area_resize __address  address,
size_t  size,
int  flags
 

Wrapper for as_area_resize.

Definition at line 1521 of file as.c.

References AS, and as_area_resize().

Here is the call graph for this function:

void tlb_arch_init void   ) 
 

Initialize Page Hash Table.

Setup the Page Hash Table with no entries.

Definition at line 43 of file tlb.c.

References tlb_invalidate_all().

Referenced by tlb_init().

Here is the call graph for this function:

void tlb_init void   ) 
 

Definition at line 62 of file tlb.c.

References tlb_arch_init().

Referenced by main_ap(), and main_bsp_separated_stack().

Here is the call graph for this function:

void tlb_invalidate_all void   ) 
 

Definition at line 49 of file tlb.c.

Referenced by before_thread_runs_arch(), tlb_arch_init(), tlb_invalidate_asid(), tlb_invalidate_pages(), and tlb_shootdown_ipi_recv().

void tlb_invalidate_asid asid_t  asid  ) 
 

Invalidate all entries in TLB that belong to specified address space.

Parameters:
asid This parameter is ignored as the architecture doesn't support it.

Definition at line 62 of file tlb.c.

References tlb_invalidate_all().

Referenced by asid_get(), and tlb_shootdown_ipi_recv().

Here is the call graph for this function:

void tlb_invalidate_pages asid_t  asid,
__address  page,
count_t  cnt
 

Invalidate TLB entries for specified page range belonging to specified address space.

Parameters:
asid This parameter is ignored as the architecture doesn't support it.
page Address of the first page whose entry is to be invalidated.
cnt Number of entries to invalidate.

Definition at line 73 of file tlb.c.

References tlb_invalidate_all().

Referenced by tlb_shootdown_ipi_recv().

Here is the call graph for this function:

void tlb_print void   ) 
 

Print contents of Page Hash Table.

Definition at line 81 of file tlb.c.

Referenced by cmd_tlb().

void tlb_shootdown_finalize void   ) 
 

Finish TLB shootdown sequence.

Definition at line 128 of file tlb.c.

References CPU, and spinlock_unlock().

Referenced by asid_get().

Here is the call graph for this function:

void tlb_shootdown_ipi_recv void   ) 
 

Receive TLB shootdown message.

Definition at line 140 of file tlb.c.

References ASSERT, count, CPU, panic, spinlock_lock, spinlock_unlock(), tlb_invalidate_all(), tlb_invalidate_asid(), tlb_invalidate_pages(), TLB_INVL_ALL, TLB_INVL_ASID, TLB_INVL_PAGES, and TLB_MESSAGE_QUEUE_LEN.

Here is the call graph for this function:

void tlb_shootdown_ipi_send void   ) 
 

Definition at line 134 of file tlb.c.

References ipi_broadcast().

Here is the call graph for this function:

void tlb_shootdown_start tlb_invalidate_type_t  type,
asid_t  asid,
__address  page,
count_t  count
 

Send TLB shootdown message.

This function attempts to deliver TLB shootdown message to all other processors.

This function must be called with interrupts disabled.

Parameters:
type Type describing scope of shootdown.
asid Address space, if required by type.
page Virtual page address, if required by type.
count Number of pages, if required by type.

Definition at line 81 of file tlb.c.

References ASID_INVALID, config, CPU, config_t::cpu_count, cpus, spinlock_lock, TLB_INVL_ALL, and TLB_MESSAGE_QUEUE_LEN.

Referenced by as_area_destroy(), as_area_resize(), and asid_get().

int used_space_insert as_area_t a,
__address  page,
count_t  count
 

Mark portion of address space area as used.

The address space area must be already locked.

Parameters:
a Address space area.
page First page to be marked.
count Number of page to be marked.
Returns:
0 on failure and 1 on success.

Definition at line 1098 of file as.c.

References ALIGN_DOWN, ASSERT, btree_insert(), btree_leaf_node_left_neighbour(), btree_leaf_node_right_neighbour(), btree_remove(), btree_search(), btree_node::key, btree_node::keys, overlaps(), PAGE_SIZE, and btree_node::value.

Referenced by phys_page_fault().

Here is the call graph for this function:

int used_space_remove as_area_t a,
__address  page,
count_t  count
 

Mark portion of address space area as unused.

The address space area must be already locked.

Parameters:
a Address space area.
page First page to be marked.
count Number of page to be marked.
Returns:
0 on failure and 1 on success.

Definition at line 1325 of file as.c.

References ALIGN_DOWN, ASSERT, btree_remove(), btree_search(), btree_node::key, btree_node::keys, PAGE_SIZE, and btree_node::value.

Referenced by as_area_resize().

Here is the call graph for this function:

static link_t* zone_buddy_bisect buddy_system_t b,
link_t block
[static]
 

Buddy system bisect implementation

Parameters:
b Buddy system.
block Block to bisect
Returns:
right block

Definition at line 349 of file frame.c.

References frame_t::buddy_link, frame_t::buddy_order, and list_get_instance.

static link_t* zone_buddy_coalesce buddy_system_t b,
link_t block_1,
link_t block_2
[static]
 

Buddy system coalesce implementation

Parameters:
b Buddy system.
block_1 First block
block_2 First block's buddy
Returns:
Coalesced block (actually block that represents lower address)

Definition at line 366 of file frame.c.

References list_get_instance.

static link_t* zone_buddy_find_block buddy_system_t b,
link_t child,
__u8  order
[static]
 

Buddy system find_block implementation

Find block that is parent of current list. That means go to lower addresses, until such block is found

Parameters:
order - Order of parent must be different then this parameter!!

Definition at line 273 of file frame.c.

References frame_t::buddy_link, frame_t::buddy_order, buddy_system::data, frame_index(), zone_t::frames, list_get_instance, and NULL.

Here is the call graph for this function:

static link_t* zone_buddy_find_buddy buddy_system_t b,
link_t block
[static]
 

Buddy system find_buddy implementation

Parameters:
b Buddy system.
block Block for which buddy should be found
Returns:
Buddy for given block if found

Definition at line 311 of file frame.c.

References ASSERT, frame_t::buddy_link, frame_t::buddy_order, buddy_system::data, frame_index(), frame_index_abs(), frame_index_valid(), zone_t::frames, IS_BUDDY_LEFT_BLOCK_ABS, IS_BUDDY_ORDER_OK, IS_BUDDY_RIGHT_BLOCK_ABS, list_get_instance, NULL, and frame_t::refcount.

Here is the call graph for this function:

static __u8 zone_buddy_get_order buddy_system_t b,
link_t block
[static]
 

Buddy system get_order implementation

Parameters:
b Buddy system.
block Buddy system block
Returns:
Order of block

Definition at line 396 of file frame.c.

References frame_t::buddy_order, and list_get_instance.

static void zone_buddy_mark_available buddy_system_t b,
link_t block
[static]
 

Buddy system mark_available implementation

Parameters:
b Buddy system
block Buddy system block

Definition at line 421 of file frame.c.

References list_get_instance, and frame_t::refcount.

static void zone_buddy_mark_busy buddy_system_t b,
link_t block
[static]
 

Buddy system mark_busy implementation

Parameters:
b Buddy system
block Buddy system block

Definition at line 408 of file frame.c.

References list_get_instance, and frame_t::refcount.

static void zone_buddy_print_id buddy_system_t b,
link_t block
[static]
 

Definition at line 292 of file frame.c.

References buddy_system::data, frame_index(), list_get_instance, and printf().

Here is the call graph for this function:

static void zone_buddy_set_order buddy_system_t b,
link_t block,
__u8  order
[static]
 

Buddy system set_order implementation

Parameters:
b Buddy system.
block Buddy system block
order Order to set

Definition at line 383 of file frame.c.

References frame_t::buddy_order, and list_get_instance.

static int zone_can_alloc zone_t z,
__u8  order
[static]
 

Returns:
True if zone can allocate specified order

Definition at line 220 of file frame.c.

References zone_t::buddy_system, and buddy_system_can_alloc().

Referenced by find_free_zone_lock(), and zone_merge().

Here is the call graph for this function:

__address zone_conf_size count_t  count  ) 
 

Compute configuration data size for zone

Parameters:
count Size of zone in frames
Returns:
Size of zone configuration info (in bytes)

Definition at line 820 of file frame.c.

References buddy_conf_size(), and fnzb.

Referenced by return_config_frames(), zone_create(), and zone_merge().

Here is the call graph for this function:

static void zone_construct pfn_t  start,
count_t  count,
zone_t z,
int  flags
[static]
 

Create frame zone

Create new frame zone.

Parameters:
start Physical address of the first frame within the zone.
count Count of frames in zone
z Address of configuration information of zone
flags Zone flags.
Returns:
Initialized zone.

Definition at line 779 of file frame.c.

References zone_t::base, buddy_conf_size(), zone_t::buddy_system, buddy_system_create(), zone_t::busy_count, zone_t::count, zone_t::flags, fnzb, frame_initialize(), zone_t::free_count, spinlock_initialize(), and zone_buddy_system_operations.

Here is the call graph for this function:

int zone_create pfn_t  start,
count_t  count,
pfn_t  confframe,
int  flags
 

Create and add zone to system

Parameters:
start First frame number (absolute)
count Size of zone in frames
confframe Where configuration frames are supposed to be. Automatically checks, that we will not disturb the kernel and possibly init. If confframe is given _outside_ this zone, it is expected, that the area is already marked BUSY and big enough to contain zone_conf_size() amount of data. If the confframe is inside the area, the zone free frame information is modified not to include it.
Returns:
Zone number or -1 on error

Definition at line 845 of file frame.c.

References init_task_t::addr, ASSERT, config_t::base, init_t::cnt, config, init, config_t::kernel_size, overlaps(), PFN2ADDR(), init_task_t::size, SIZE2FRAMES(), init_t::tasks, and zone_conf_size().

Referenced by frame_arch_init().

Here is the call graph for this function:

static pfn_t zone_frame_alloc zone_t zone,
__u8  order
[static]
 

Allocate frame in particular zone

Assume zone is locked Panics if allocation is impossible.

Parameters:
zone Zone to allocate from.
order Allocate exactly 2^order frames.
Returns:
Frame index in zone

Definition at line 453 of file frame.c.

References ASSERT, zone_t::buddy_system, buddy_system_alloc(), zone_t::busy_count, zone_t::free_count, list_get_instance, and make_frame_index().

Referenced by frame_alloc_generic(), and zone_merge().

Here is the call graph for this function:

static void zone_frame_free zone_t zone,
index_t  frame_idx
[static]
 

Free frame from zone

Assume zone is locked

Parameters:
zone Pointer to zone from which the frame is to be freed
frame_idx Frame index relative to zone

Definition at line 483 of file frame.c.

References ASSERT, frame_t::buddy_link, frame_t::buddy_order, zone_t::buddy_system, buddy_system_free(), zone_t::busy_count, zone_t::frames, zone_t::free_count, and frame_t::refcount.

Referenced by frame_free(), and return_config_frames().

Here is the call graph for this function:

static frame_t* zone_get_frame zone_t zone,
index_t  frame_idx
[static]
 

Return frame from zone

Definition at line 505 of file frame.c.

References ASSERT, count, and zone_t::frames.

Referenced by frame_get_parent(), frame_set_parent(), and zone_mark_unavailable().

static void zone_mark_unavailable zone_t zone,
index_t  frame_idx
[static]
 

Mark frame in zone unavailable to allocation

Definition at line 512 of file frame.c.

References ASSERT, frame_t::buddy_link, zone_t::buddy_system, buddy_system_alloc_block(), zone_t::free_count, frame_t::refcount, and zone_get_frame().

Referenced by frame_mark_unavailable().

Here is the call graph for this function:

void zone_merge int  z1,
int  z2
 

Merge zones z1 and z2

  • the zones must be 2 zones with no zone existing in between, which means that z2 = z1+1

  • When you create a new zone, the frame allocator configuration does not to be 2^order size. Once the allocator is running it is no longer possible, merged configuration data occupies more space :-/

Definition at line 687 of file frame.c.

References _zone_merge(), zone_t::base, zone_t::busy_count, zone_t::count, fnzb, interrupts_disable(), interrupts_restore(), PFN2ADDR(), return_config_frames(), SIZE2FRAMES(), spinlock_lock, spinlock_unlock(), zone_can_alloc(), zone_conf_size(), zone_frame_alloc(), zone_reduce_region(), and zones.

Referenced by zone_merge_all().

Here is the call graph for this function:

void zone_merge_all void   ) 
 

Merge all zones into one big zone

It is reasonable to do this on systems whose bios reports parts in chunks, so that we could have 1 zone (it's faster).

Definition at line 758 of file frame.c.

References count, zone_merge(), and zones.

Referenced by arch_post_mm_init().

Here is the call graph for this function:

void zone_print_list void   ) 
 

Prints list of zones

Definition at line 1096 of file frame.c.

References zone_t::base, zone_t::busy_count, zone_t::free_count, interrupts_disable(), NULL, PFN2ADDR(), printf(), spinlock_lock, spinlock_unlock(), and zones.

Referenced by cmd_zones().

Here is the call graph for this function:

void zone_print_one int  num  ) 
 

Prints zone details.

Parameters:
num Zone base address or zone number.

Definition at line 1119 of file frame.c.

References interrupts_disable(), NULL, PFN2ADDR(), spinlock_lock, and zones.

Referenced by cmd_zone().

Here is the call graph for this function:

static void zone_reduce_region zone_t zone,
pfn_t  frame_idx,
count_t  count
[static]
 

Reduce allocated block to count of order 0 frames

The allocated block need 2^order frames of space. Reduce all frames in block to order 0 and free the unneeded frames. This means, that when freeing the previously allocated block starting with frame_idx, you have to free every frame.

Parameters:
zone 
frame_idx Index to block
count Allocated space in block

Definition at line 653 of file frame.c.

References ASSERT, frame_t::buddy_order, zone_t::frames, and frame_t::refcount.

Referenced by zone_merge().

static int zones_add_zone zone_t newzone  )  [static]
 

Insert-sort zone into zones list

Parameters:
newzone New zone to be inserted into zone list
Returns:
zone number on success, -1 on error

Definition at line 144 of file frame.c.

References zone_t::base, zone_t::count, interrupts_disable(), overlaps(), panic, printf(), spinlock_lock, zones, and ZONES_MAX.

Here is the call graph for this function:


Variable Documentation

mem_backend_t anon_backend
 

Initial value:

 {
        .page_fault = anon_page_fault,
        .frame_free = anon_frame_free,
        .share = anon_share
}

Definition at line 58 of file backend_anon.c.

Referenced by sys_as_area_create(), and task_run_program().

as_t* AS_KERNEL = NULL
 

Kernel address space.

Definition at line 93 of file as.c.

Referenced by as_destroy(), as_init(), as_switch(), hw_map(), main_bsp_separated_stack(), map_structure(), page_arch_init(), pht_refill(), and ptl0_create().

as_operations_t* as_operations = NULL
 

Definition at line 81 of file as.c.

Referenced by as_arch_init(), page_table_create(), page_table_destroy(), page_table_lock(), and page_table_unlock().

link_t as_with_asid_head
 

spinlock_t asidlock
 

Referenced by asid_get(), and asid_put().

int count [inherited]
 

Definition at line 97 of file frame.c.

mem_backend_t elf_backend
 

Initial value:

 {
        .page_fault = elf_page_fault,
        .frame_free = elf_frame_free,
        .share = elf_share
}

Definition at line 57 of file backend_elf.c.

Referenced by load_segment().

iroutine f [inherited]
 

Definition at line 53 of file interrupt.c.

zone_t* info[ZONES_MAX] [inherited]
 

Definition at line 98 of file frame.c.

slab_cache_t mag_cache [static]
 

Magazine cache

Definition at line 118 of file slab.c.

Referenced by make_empty_current_mag(), and slab_cache_init().

slab_cache_t* malloc_caches[SLAB_MAX_MALLOC_W-SLAB_MIN_MALLOC_W+1] [static]
 

Caches for malloc

Definition at line 129 of file slab.c.

Referenced by malloc(), and slab_cache_init().

char* malloc_names[]
 

Initial value:

  {
        "malloc-16","malloc-32","malloc-64","malloc-128",
        "malloc-256","malloc-512","malloc-1K","malloc-2K",
        "malloc-4K","malloc-8K","malloc-16K","malloc-32K",
        "malloc-64K","malloc-128K","malloc-256K"
}

Definition at line 130 of file slab.c.

Referenced by slab_cache_init().

const char* name [inherited]
 

Definition at line 52 of file interrupt.c.

page_mapping_operations_t* page_mapping_operations = NULL
 

Virtual operations for page subsystem.

Definition at line 56 of file page.c.

Referenced by page_mapping_find(), page_mapping_insert(), and page_mapping_remove().

page_mapping_operations_t* page_mapping_operations
 

Virtual operations for page subsystem.

Definition at line 56 of file page.c.

Referenced by page_mapping_find(), page_mapping_insert(), and page_mapping_remove().

mem_backend_t phys_backend
 

Initial value:

 {
        .page_fault = phys_page_fault,
        .frame_free = NULL,
        .share = phys_share
}

Definition at line 52 of file backend_phys.c.

Referenced by as_area_resize(), and ddi_physmem_map().

slab_cache_t slab_cache_cache [static]
 

Cache for cache descriptors

Definition at line 120 of file slab.c.

Referenced by slab_cache_create(), slab_cache_destroy(), and slab_cache_init().

slab_cache_t* slab_extern_cache [static]
 

Cache for external slab descriptors This time we want per-cpu cache, so do not make it static

  • using slab for internal slab structures will not deadlock, as all slab structures are 'small' - control structures of their caches do not require further allocation

Definition at line 127 of file slab.c.

Referenced by slab_cache_init(), slab_space_alloc(), and slab_space_free().

struct buddy_system_operations zone_buddy_system_operations [static]
 

Initial value:

 {
        .find_buddy = zone_buddy_find_buddy,
        .bisect = zone_buddy_bisect,
        .coalesce = zone_buddy_coalesce,
        .set_order = zone_buddy_set_order,
        .get_order = zone_buddy_get_order,
        .mark_busy = zone_buddy_mark_busy,
        .mark_available = zone_buddy_mark_available,
        .find_block = zone_buddy_find_block,
        .print_id = zone_buddy_print_id
}

Definition at line 427 of file frame.c.

Referenced by _zone_merge(), and zone_construct().

struct { ... } zones
 

Referenced by find_free_zone_lock(), find_zone_and_lock(), frame_init(), zone_merge(), zone_merge_all(), zone_print_list(), zone_print_one(), and zones_add_zone().


Generated on Sun Jun 18 17:34:40 2006 for HelenOS Kernel (ppc64) by  doxygen 1.4.6