checkpoint.h 3.68 KB
/*
 * Copyright (C) 1996-1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * 
 * This file is part of the SimOS distribution. 
 * See LICENSE file for terms of the license. 
 *
 */

#ifndef SIMCPT_H 
#define SIMCPT_H

#include <stdio.h>
#include "simtypes.h"

typedef enum cptmode {CPT_SAVE = 0, CPT_RESTORE} CptMode;
typedef enum cptcompression {NO_COMPRESSION = 0, GZIP, COMPRESS, NUM_COMPRESS_TYPES} CptCompression;
typedef enum cptcompressmode {BIN_FILE_ONLY, CPT_FILE_ONLY, BOTH_FILES} CptCompressMode;
struct cptgroup;

typedef struct cptdescriptor {
  CptMode          mode;
  struct cptgroup *group;
} CptDescriptor;

typedef struct cptversion {
   int ver;         /* Current version */
   int sub;         /* Current sub-version */
   int saveVer;     /* Desired save version */
   int saveSub;     /* Desired save sub-version */
} CptVersion;

/* Default checkpoint save version numbers */
#define CPT_VERSION     4
#define CPT_SUB_VERSION 0

typedef int (CptCallback)(CptDescriptor *);

#define NO_INDEX -1
#define MAX_PATH_LENGTH 100

void Simcpt_Init(void);
void Simcpt_Register(char *tag, CptCallback callback, CPUType cputype);
void Simcpt_UseCompression(char *tag, CptCompression compress, CptCompressMode mode);

bool Simcpt_IsRemote(void);
void Simcpt_Checkpoint(CptMode mode, char *name);
int Simcpt_Restore(char *tag);

void Simcpt_Begin(CptDescriptor *cptd);
void Simcpt_End(CptDescriptor *cptd);

int Simcpt_GetMemoryCptFile(void);

int Simcpt_CptComment(CptDescriptor *cptd, char *comment);
int Simcpt_CptInt(CptDescriptor *cptd, char *name, int i1, int i2, int *val);
int Simcpt_CptChar(CptDescriptor *cptd, char *name, int i1, int i2, char *val);
int Simcpt_CptLong(CptDescriptor *cptd, char *name, int i1, int i2, long *val);
int Simcpt_CptULL(CptDescriptor *cptd, char *name, int i1, int i2, uint64 *val);
int Simcpt_CptUint(CptDescriptor *cptd, char *name, int i1, int i2, uint *val);
int Simcpt_CptUlong(CptDescriptor *cptd, char *name, int i1, int i2, unsigned long *val);
int Simcpt_CptUchar(CptDescriptor *cptd, char *name, int i1, int i2, unsigned char *val);
int Simcpt_CptHex(CptDescriptor *cptd, char *name, int i1, int i2, uint *val);
int Simcpt_CptString(CptDescriptor *cptd, char *name, int i1, int i2, char **val);
int Simcpt_CptBlock(CptDescriptor *cptd, char *name, int i1, int i2, void *val, int size, int outputFD);

int Simcpt_CptParamInt(CptDescriptor *cptd, char *name, int i1, int i2, int *paramAddr);

int Simcpt_OptionalInteger(CptDescriptor *cptd, char *name, int i1, int i2, int64 val);
int Simcpt_OptionalString(CptDescriptor *cptd, char *name, int i1, int i2, char *val);

void Simcpt_Preread_Numcells(void);
void Simcpt_Preread_Numether(void);

#define Simcpt_OptionalInt(CPTD,NAME,I1,I2,VAL) \
           Simcpt_OptionalInteger(CPTD,NAME,I1,I2,(int64)VAL)
#define Simcpt_OptionalChar(CPTD,NAME,I1,I2,VAL) \
           Simcpt_OptionalInteger(CPTD,NAME,I1,I2,(int64)VAL)
#define Simcpt_OptionalLong(CPTD,NAME,I1,I2,VAL) \
           Simcpt_OptionalInteger(CPTD,NAME,I1,I2,(int64)VAL)
#define Simcpt_OptionalULL(CPTD,NAME,I1,I2,VAL) \
           Simcpt_OptionalInteger(CPTD,NAME,I1,I2,(int64)VAL)
#define Simcpt_OptionalUint(CPTD,NAME,I1,I2,VAL) \
           Simcpt_OptionalInteger(CPTD,NAME,I1,I2,(int64)VAL)
#define Simcpt_OptionalUchar(CPTD,NAME,I1,I2,VAL) \
           Simcpt_OptionalInteger(CPTD,NAME,I1,I2,(int64)VAL)
#define Simcpt_OptionalHex(CPTD,NAME,I1,I2,VAL) \
           Simcpt_OptionalInteger(CPTD,NAME,I1,I2,(int64)VAL)

int Simcpt_GetMemoryCptFile( void );
int Simcpt_CanMmapMemoryCheckpoint( void );

extern char *CheckpointID;
extern int CheckpointCompress;
extern char *cptSaveDir;
extern char cptName[MAX_PATH_LENGTH];
extern CptVersion cptVersion;

#endif /* SIMCPT_H */