2004-07-16 02:26:21 -04:00
|
|
|
#define IMAGE_MAGIC 0x0f0e0d0c
|
2019-10-18 09:05:08 -04:00
|
|
|
#define IMAGE_VERSION 3
|
2004-07-16 02:26:21 -04:00
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
CELL magic;
|
|
|
|
|
CELL version;
|
|
|
|
|
/* all pointers in the image file are relocated from
|
|
|
|
|
relocation_base to here when the image is loaded */
|
2006-08-08 01:38:32 -04:00
|
|
|
CELL data_relocation_base;
|
2004-07-16 02:26:21 -04:00
|
|
|
/* tagged pointer to bootstrap quotation */
|
|
|
|
|
CELL boot;
|
|
|
|
|
/* tagged pointer to global namespace */
|
|
|
|
|
CELL global;
|
2005-05-10 22:30:58 -04:00
|
|
|
/* tagged pointer to t singleton */
|
|
|
|
|
CELL t;
|
|
|
|
|
/* tagged pointer to bignum 0 */
|
|
|
|
|
CELL bignum_zero;
|
|
|
|
|
/* tagged pointer to bignum 1 */
|
|
|
|
|
CELL bignum_pos_one;
|
|
|
|
|
/* tagged pointer to bignum -1 */
|
|
|
|
|
CELL bignum_neg_one;
|
2004-07-16 02:26:21 -04:00
|
|
|
/* size of heap */
|
2006-08-08 01:38:32 -04:00
|
|
|
CELL data_size;
|
2004-12-25 02:55:03 -05:00
|
|
|
/* size of code heap */
|
2006-08-08 01:38:32 -04:00
|
|
|
CELL code_size;
|
2004-12-25 02:55:03 -05:00
|
|
|
/* code relocation base */
|
2006-08-08 01:38:32 -04:00
|
|
|
CELL code_relocation_base;
|
2006-10-31 23:20:34 -05:00
|
|
|
} F_HEADER;
|
2004-12-25 02:55:03 -05:00
|
|
|
|
2019-10-18 09:05:08 -04:00
|
|
|
typedef struct {
|
|
|
|
|
const F_CHAR* image;
|
|
|
|
|
CELL ds_size, rs_size, cs_size;
|
|
|
|
|
CELL gen_count, young_size, aging_size;
|
|
|
|
|
CELL code_size;
|
|
|
|
|
bool secure_gc;
|
|
|
|
|
} F_PARAMETERS;
|
|
|
|
|
|
2019-10-18 09:05:06 -04:00
|
|
|
void load_image(F_PARAMETERS *p);
|
2006-10-31 23:20:34 -05:00
|
|
|
void init_objects(F_HEADER *h);
|
2019-10-18 09:05:08 -04:00
|
|
|
bool save_image(const F_CHAR *file);
|
2004-07-16 02:26:21 -04:00
|
|
|
void primitive_save_image(void);
|
2006-07-07 00:07:18 -04:00
|
|
|
|
|
|
|
|
/* relocation base of currently loaded image's data heap */
|
|
|
|
|
CELL data_relocation_base;
|
|
|
|
|
|
|
|
|
|
INLINE void data_fixup(CELL *cell)
|
|
|
|
|
{
|
|
|
|
|
if(TAG(*cell) != FIXNUM_TYPE && *cell != F)
|
2019-10-18 09:05:06 -04:00
|
|
|
*cell += (tenured.start - data_relocation_base);
|
2006-07-07 00:07:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CELL code_relocation_base;
|
|
|
|
|
|
2019-10-18 09:05:06 -04:00
|
|
|
INLINE void code_fixup(XT *cell)
|
2006-07-07 00:07:18 -04:00
|
|
|
{
|
2019-10-18 09:05:06 -04:00
|
|
|
CELL value = (CELL)*cell;
|
|
|
|
|
value += (code_heap.segment->start - code_relocation_base);
|
|
|
|
|
*cell = (XT)value;
|
2006-07-07 00:07:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void relocate_data();
|
|
|
|
|
void relocate_code();
|