Turnstone Operating System
Loading...
Searching...
No Matches
frame.h File Reference

frame allocator header More...

#include <types.h>
#include <memory.h>

Classes

struct  frame_t
 frame definition More...
 
struct  frame_allocator_t
 frame allocator class More...
 

Macros

#define ___MEMORY_FRAME_H   0
 
#define FRAME_SIZE   4096
 
#define FRAME_ATTRIBUTE_OLD_RESERVED   0x0000000100000000
 
#define FRAME_ATTRIBUTE_ACPI_RECLAIM_MEMORY   0x0000000200000000
 
#define FRAME_ATTRIBUTE_ACPI   0x0000000400000000
 
#define FRAME_ATTRIBUTE_RESERVED_PAGE_MAPPED   0x0000000800000000
 
#define frame_allocator_new()   frame_allocator_new_ext(NULL);
 

Typedefs

typedef enum frame_type_t frame_type_t
 short hand for enum frame_type_e
 
typedef enum frame_allocation_type_t frame_allocation_type_t
 short hand for enum frame_allocation_type_e
 
typedef struct frame_t frame_t
 short hand for struct frame_s
 
typedef int8_t(* fa_allocate_frame_by_count_f) (struct frame_allocator_t *self, uint64_t count, frame_allocation_type_t fa_type, frame_t **fs, uint64_t *alloc_list_size)
 allocate frame with count More...
 
typedef int8_t(* fa_allocate_frame_f) (struct frame_allocator_t *self, frame_t *f)
 allocate frame with given reference frame, ref frame not used in anywhere as is. it is only for reference. More...
 
typedef int8_t(* fa_release_frame_f) (struct frame_allocator_t *self, frame_t *f)
 release frame with given reference frame, ref frame not used in anywhere as is. it is only for reference. More...
 
typedef frame_t *(* fa_get_reserved_frames_of_address_f) (struct frame_allocator_t *self, void *address)
 returns the frame that address resides or null More...
 
typedef int8_t(* fa_cleanup_f) (struct frame_allocator_t *self)
 cleans old reserved frames More...
 
typedef int8_t(* fa_reserve_system_frames_f) (struct frame_allocator_t *self, frame_t *f)
 reserve frames for mmio More...
 
typedef int8_t(* fa_release_acpi_reclaim_memory_f) (struct frame_allocator_t *self)
 release frames with attribute FRAME_TYPE_ACPI_RECLAIM_MEMORY More...
 
typedef uint64_t(* fa_get_total_frame_count_f) (struct frame_allocator_t *self)
 returns total frame count More...
 
typedef uint64_t(* fa_get_allocated_frame_count_f) (struct frame_allocator_t *self)
 returns used frame count More...
 
typedef uint64_t(* fa_get_free_frame_count_f) (struct frame_allocator_t *self)
 returns free frame count More...
 
typedef struct frame_allocator_t frame_allocator_t
 short hand for struct frame_allocator_t
 

Enumerations

enum  frame_type_t {
  FRAME_TYPE_FREE , FRAME_TYPE_USED , FRAME_TYPE_RESERVED , FRAME_TYPE_ACPI_RECLAIM_MEMORY ,
  FRAME_TYPE_ACPI_CODE , FRAME_TYPE_ACPI_DATA
}
 frame types More...
 
enum  frame_allocation_type_t {
  FRAME_ALLOCATION_TYPE_RELAX = 1 << 1 , FRAME_ALLOCATION_TYPE_BLOCK = 1 << 2 , FRAME_ALLOCATION_TYPE_UNDER_4G = 1 << 3 , FRAME_ALLOCATION_TYPE_USED = 1 << 7 ,
  FRAME_ALLOCATION_TYPE_RESERVED = 1 << 8 , FRAME_ALLOCATION_TYPE_OLD_RESERVED = 1 << 15
}
 frame allocation types More...
 

Functions

frame_allocator_tframe_allocator_new_ext (memory_heap_t *heap)
 creates a frame allocator More...
 
void frame_allocator_print (frame_allocator_t *fa)
 prints frame allocator contents More...
 
void frame_allocator_map_page_of_acpi_code_data_frames (frame_allocator_t *fa)
 map virtual pages of acpi code and data frames More...
 
frame_allocator_tframe_get_allocator (void)
 
void frame_set_allocator (frame_allocator_t *fa)
 

Detailed Description

frame allocator header

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Macro Definition Documentation

◆ ___MEMORY_FRAME_H

#define ___MEMORY_FRAME_H   0

prevent duplicate header error macro

◆ frame_allocator_new

#define frame_allocator_new ( )    frame_allocator_new_ext(NULL);

creates frame allocator at default heap

◆ FRAME_ATTRIBUTE_ACPI

#define FRAME_ATTRIBUTE_ACPI   0x0000000400000000

frame attribure for acpi memory

◆ FRAME_ATTRIBUTE_ACPI_RECLAIM_MEMORY

#define FRAME_ATTRIBUTE_ACPI_RECLAIM_MEMORY   0x0000000200000000

frame attribure for acpi reclaim memory

◆ FRAME_ATTRIBUTE_OLD_RESERVED

#define FRAME_ATTRIBUTE_OLD_RESERVED   0x0000000100000000

frame attribure for reserved frames before relinked start

◆ FRAME_ATTRIBUTE_RESERVED_PAGE_MAPPED

#define FRAME_ATTRIBUTE_RESERVED_PAGE_MAPPED   0x0000000800000000

frame attribure for reserved pages which are mapped

◆ FRAME_SIZE

#define FRAME_SIZE   4096

frame size (4K)

Typedef Documentation

◆ fa_allocate_frame_by_count_f

typedef int8_t(* fa_allocate_frame_by_count_f) (struct frame_allocator_t *self, uint64_t count, frame_allocation_type_t fa_type, frame_t **fs, uint64_t *alloc_list_size)

allocate frame with count

Parameters
[in]selfframe allocator
[in]countframe count for allocation
[in]fa_typeframe allocation types can be or'ed values
[out]fslist of frames that allocated
[out]alloc_list_sizefs length
Returns
0 if succeed.

◆ fa_allocate_frame_f

typedef int8_t(* fa_allocate_frame_f) (struct frame_allocator_t *self, frame_t *f)

allocate frame with given reference frame, ref frame not used in anywhere as is. it is only for reference.

Parameters
[in]selfframe allocator
[in]freferance frame,
Returns
0 if succeed.

◆ fa_cleanup_f

typedef int8_t(* fa_cleanup_f) (struct frame_allocator_t *self)

cleans old reserved frames

Parameters
[in]selfframe allocator
Returns
0 if succeed.

◆ fa_get_allocated_frame_count_f

typedef uint64_t(* fa_get_allocated_frame_count_f) (struct frame_allocator_t *self)

returns used frame count

Parameters
[in]selfframe allocator
Returns
used frame count

◆ fa_get_free_frame_count_f

typedef uint64_t(* fa_get_free_frame_count_f) (struct frame_allocator_t *self)

returns free frame count

Parameters
[in]selfframe allocator
Returns
free frame count

◆ fa_get_reserved_frames_of_address_f

typedef frame_t *(* fa_get_reserved_frames_of_address_f) (struct frame_allocator_t *self, void *address)

returns the frame that address resides or null

Parameters
[in]selfframe allocator
[in]addresssearch address
Returns
frame of given address or null

◆ fa_get_total_frame_count_f

typedef uint64_t(* fa_get_total_frame_count_f) (struct frame_allocator_t *self)

returns total frame count

Parameters
[in]selfframe allocator
Returns
total frame count

◆ fa_release_acpi_reclaim_memory_f

typedef int8_t(* fa_release_acpi_reclaim_memory_f) (struct frame_allocator_t *self)

release frames with attribute FRAME_TYPE_ACPI_RECLAIM_MEMORY

Parameters
[in]selfframe allocator
Returns
0 if succeed.

◆ fa_release_frame_f

typedef int8_t(* fa_release_frame_f) (struct frame_allocator_t *self, frame_t *f)

release frame with given reference frame, ref frame not used in anywhere as is. it is only for reference.

Parameters
[in]selfframe allocator
[in]freferance frame,
Returns
0 if succeed.

◆ fa_reserve_system_frames_f

typedef int8_t(* fa_reserve_system_frames_f) (struct frame_allocator_t *self, frame_t *f)

reserve frames for mmio

Parameters
[in]selfframe allocator
[in]freference frame not used as is.
Returns
0 if succeed.

Enumeration Type Documentation

◆ frame_allocation_type_t

frame allocation types

Enumerator
FRAME_ALLOCATION_TYPE_RELAX 

frames reserved non blockly

FRAME_ALLOCATION_TYPE_BLOCK 

frames should be continuous

FRAME_ALLOCATION_TYPE_UNDER_4G 

frames should be under 4G

FRAME_ALLOCATION_TYPE_USED 

frames for using

FRAME_ALLOCATION_TYPE_RESERVED 

frames for reserved area

FRAME_ALLOCATION_TYPE_OLD_RESERVED 

frames for old reserved area (reserved areas before relinking)

◆ frame_type_t

frame types

Enumerator
FRAME_TYPE_FREE 

free frame

FRAME_TYPE_USED 

frames are allocated

FRAME_TYPE_RESERVED 

frames are for reserved memory

FRAME_TYPE_ACPI_RECLAIM_MEMORY 

frames for acpi area

FRAME_TYPE_ACPI_CODE 

frames for acpi code

FRAME_TYPE_ACPI_DATA 

frames for acpi data

Function Documentation

◆ frame_allocator_map_page_of_acpi_code_data_frames()

void frame_allocator_map_page_of_acpi_code_data_frames ( frame_allocator_t fa)

map virtual pages of acpi code and data frames

Parameters
[in]faframe allocator

◆ frame_allocator_new_ext()

frame_allocator_t * frame_allocator_new_ext ( memory_heap_t heap)

creates a frame allocator

Parameters
[in]heapwhere frame will be reside
Returns
frame allocator

◆ frame_allocator_print()

void frame_allocator_print ( frame_allocator_t fa)

prints frame allocator contents

Parameters
[in]faframe allocator