LispBM
Loading...
Searching...
No Matches
Macros | Functions | Variables
lbm_image.c File Reference
#include <extensions.h>
#include <lbm_image.h>
#include <heap.h>
#include <env.h>
#include <lbm_flat_value.h>
#include <eval_cps.h>
Include dependency graph for lbm_image.c:

Macros

#define IMAGE_INITIALIZED   (uint32_t)0xBEEF2001
 
#define CONSTANT_HEAP_IX   (uint32_t)0x02
 
#define BINDING_CONST   (uint32_t)0x03
 
#define BINDING_FLAT   (uint32_t)0x04
 
#define STARTUP_ENTRY   (uint32_t)0x05
 
#define SYMBOL_ENTRY   (uint32_t)0x06
 
#define SYMBOL_LINK_ENTRY   (uint32_t)0x07
 
#define EXTENSION_TABLE   (uint32_t)0x08
 
#define VERSION_ENTRY   (uint32_t)0x09
 
#define DOWNWARDS   true
 
#define UPWARDS   false
 

Functions

uint32_t * lbm_image_get_image (void)
 
uint32_t lbm_image_get_size (void)
 
int32_t lbm_image_get_write_index (void)
 
bool lbm_image_has_extensions (void)
 
uint32_t read_u32 (int32_t index)
 
uint64_t read_u64 (int32_t index)
 
bool write_u32 (uint32_t w, int32_t *i, bool direction)
 
bool write_u64 (uint64_t dw, int32_t *i, bool direction)
 
bool fv_write_u8 (uint8_t b)
 
bool fv_write_flush (void)
 
bool fv_write_u32 (uint32_t w)
 
bool fv_write_u64 (uint64_t dw)
 
bool write_lbm_uint (lbm_uint ptr_val, int32_t *i, bool direction)
 
bool write_lbm_value (lbm_value v, int32_t *i, bool direction)
 
static bool i_f_cons (void)
 
static bool i_f_lisp_array (uint32_t size)
 
static bool i_f_sym (lbm_value sym)
 
static bool i_f_i (lbm_int i)
 
static bool i_f_u (lbm_uint u)
 
static bool i_f_b (uint8_t b)
 
static bool i_f_i32 (int32_t w)
 
static bool i_f_u32 (uint32_t w)
 
static bool i_f_float (float f)
 
static bool i_f_double (double d)
 
static bool i_f_i64 (int64_t w)
 
static bool i_f_u64 (uint64_t w)
 
static bool i_f_lbm_array (uint32_t num_bytes, uint8_t *data)
 
static bool image_flatten_value (lbm_value v)
 
char * lbm_image_get_version (void)
 
bool image_const_heap_write (lbm_uint w, lbm_uint ix)
 
lbm_uintlbm_image_add_symbol (char *name, lbm_uint id, lbm_uint symlist)
 
lbm_uintlbm_image_add_and_link_symbol (char *name, lbm_uint id, lbm_uint symlist, lbm_uint *link)
 
bool lbm_image_save_global_env (void)
 
bool lbm_image_save_extensions (void)
 
bool lbm_image_save_constant_heap_ix (void)
 
bool lbm_image_exists (void)
 
void lbm_image_init (uint32_t *image_mem_address, uint32_t image_size_words, lbm_image_write_fun image_write_fun)
 
void lbm_image_create (char *version_str)
 
bool lbm_image_boot (void)
 

Variables

static lbm_image_write_fun image_write = NULL
 
static uint32_t * image_address = NULL
 
static int32_t write_index = 0
 
static uint32_t image_size = 0
 
static bool image_has_extensions = false
 
static char * image_version = NULL
 
uint32_t fv_buf_ix = 0
 
uint8_t fv_buf [4] = {0}
 
lbm_const_heap_t image_const_heap
 
lbm_uint image_const_heap_start_ix = 0
 
static uint32_t last_const_heap_ix = 0
 

Macro Definition Documentation

◆ BINDING_CONST

#define BINDING_CONST   (uint32_t)0x03

◆ BINDING_FLAT

#define BINDING_FLAT   (uint32_t)0x04

◆ CONSTANT_HEAP_IX

#define CONSTANT_HEAP_IX   (uint32_t)0x02

◆ DOWNWARDS

#define DOWNWARDS   true

◆ EXTENSION_TABLE

#define EXTENSION_TABLE   (uint32_t)0x08

◆ IMAGE_INITIALIZED

#define IMAGE_INITIALIZED   (uint32_t)0xBEEF2001

◆ STARTUP_ENTRY

#define STARTUP_ENTRY   (uint32_t)0x05

◆ SYMBOL_ENTRY

#define SYMBOL_ENTRY   (uint32_t)0x06

◆ SYMBOL_LINK_ENTRY

#define SYMBOL_LINK_ENTRY   (uint32_t)0x07

◆ UPWARDS

#define UPWARDS   false

◆ VERSION_ENTRY

#define VERSION_ENTRY   (uint32_t)0x09

Function Documentation

◆ fv_write_flush()

bool fv_write_flush ( void  )

◆ fv_write_u32()

bool fv_write_u32 ( uint32_t  w)

◆ fv_write_u64()

bool fv_write_u64 ( uint64_t  dw)

◆ fv_write_u8()

bool fv_write_u8 ( uint8_t  b)

◆ i_f_b()

static bool i_f_b ( uint8_t  b)
static

◆ i_f_cons()

static bool i_f_cons ( void  )
static

◆ i_f_double()

static bool i_f_double ( double  d)
static

◆ i_f_float()

static bool i_f_float ( float  f)
static

◆ i_f_i()

static bool i_f_i ( lbm_int  i)
static

◆ i_f_i32()

static bool i_f_i32 ( int32_t  w)
static

◆ i_f_i64()

static bool i_f_i64 ( int64_t  w)
static

◆ i_f_lbm_array()

static bool i_f_lbm_array ( uint32_t  num_bytes,
uint8_t *  data 
)
static

◆ i_f_lisp_array()

static bool i_f_lisp_array ( uint32_t  size)
static

◆ i_f_sym()

static bool i_f_sym ( lbm_value  sym)
static

◆ i_f_u()

static bool i_f_u ( lbm_uint  u)
static

◆ i_f_u32()

static bool i_f_u32 ( uint32_t  w)
static

◆ i_f_u64()

static bool i_f_u64 ( uint64_t  w)
static

◆ image_const_heap_write()

bool image_const_heap_write ( lbm_uint  w,
lbm_uint  ix 
)

◆ image_flatten_value()

static bool image_flatten_value ( lbm_value  v)
static

◆ lbm_image_add_and_link_symbol()

lbm_uint * lbm_image_add_and_link_symbol ( char *  name,
lbm_uint  id,
lbm_uint  symlist,
lbm_uint link 
)

Add a symbol to the image and "link" it to a C address (variable).

Parameters
nameSymbol name.
idSymbol id.
symlistPtr to rest of symbol list.
linkptr where to store the symbol ID on image-boot.
Returns
pointer to head of symbol list.

◆ lbm_image_add_symbol()

lbm_uint * lbm_image_add_symbol ( char *  name,
lbm_uint  id,
lbm_uint  symlist 
)

Add a symbol to the image. Symbols added to the image are restored upon image-boot.

Parameters
nameSymbol name.
idSymbol id.
symlistPtr to rest of symbol list.
Returns
pointer to head of symbol list.

◆ lbm_image_boot()

bool lbm_image_boot ( void  )

Boot an existing image. Restores the datastructures stored in the image.

Returns
true on success, false otherwise.

◆ lbm_image_create()

void lbm_image_create ( char *  version_str)

Create an image at the address and of the size given to lbm_image_init.

Parameters
version_stra zero terminated version string or NULL.

◆ lbm_image_exists()

bool lbm_image_exists ( void  )

An image exists the memory area given to lbm_image_init to store the image in contains the IMAGE_INITIALIZED field at the start (top) of the image area.

Returns
true if image exists, false otherwise.

◆ lbm_image_get_image()

uint32_t * lbm_image_get_image ( void  )

lbm_image_get_image provides a pointer to the starting point of an image. The starting point of an image is the lowest address, even though writing to an image is done top-down.

Returns
pointer to image.

◆ lbm_image_get_size()

uint32_t lbm_image_get_size ( void  )

Get the size of an image.

Returns
The size of the image in 32bit words

◆ lbm_image_get_version()

char * lbm_image_get_version ( void  )

Get the version string that was stored in the image. If no version string was stored in the image, the result is NULL.

Returns
pointer to version string or NULL.

◆ lbm_image_get_write_index()

int32_t lbm_image_get_write_index ( void  )

Images are written from the top towards the bottom. The write_index is the next free location of (32bit) word size in the image.

Returns
write index.

◆ lbm_image_has_extensions()

bool lbm_image_has_extensions ( void  )

Does the image have a stored extension table?

Returns
true if image contains extension table, false otherwise.

◆ lbm_image_init()

void lbm_image_init ( uint32_t *  image_mem_address,
uint32_t  image_size_words,
lbm_image_write_fun  image_write_fun 
)

◆ lbm_image_save_constant_heap_ix()

bool lbm_image_save_constant_heap_ix ( void  )

Save the current constant_heap index into the image for recovery upon restart.

Returns
true on success otherwise false.

◆ lbm_image_save_extensions()

bool lbm_image_save_extensions ( void  )

Save the extension table to the image.

Returns
true on success otherwise false.

◆ lbm_image_save_global_env()

bool lbm_image_save_global_env ( void  )

Save the global environment to the image.

Returns
true on success otherwise false.

◆ read_u32()

uint32_t read_u32 ( int32_t  index)

◆ read_u64()

uint64_t read_u64 ( int32_t  index)

◆ write_lbm_uint()

bool write_lbm_uint ( lbm_uint  ptr_val,
int32_t *  i,
bool  direction 
)

◆ write_lbm_value()

bool write_lbm_value ( lbm_value  v,
int32_t *  i,
bool  direction 
)

◆ write_u32()

bool write_u32 ( uint32_t  w,
int32_t *  i,
bool  direction 
)

◆ write_u64()

bool write_u64 ( uint64_t  dw,
int32_t *  i,
bool  direction 
)

Variable Documentation

◆ fv_buf

uint8_t fv_buf[4] = {0}

◆ fv_buf_ix

uint32_t fv_buf_ix = 0

◆ image_address

uint32_t* image_address = NULL
static

◆ image_const_heap

lbm_const_heap_t image_const_heap

◆ image_const_heap_start_ix

lbm_uint image_const_heap_start_ix = 0

◆ image_has_extensions

bool image_has_extensions = false
static

◆ image_size

uint32_t image_size = 0
static

◆ image_version

char* image_version = NULL
static

◆ image_write

lbm_image_write_fun image_write = NULL
static

◆ last_const_heap_ix

uint32_t last_const_heap_ix = 0
static

◆ write_index

int32_t write_index = 0
static