static int pit_save(struct v3_chkpt_ctx * ctx, void * private_data) {
struct pit * pit_state = (struct pit *)private_data;
- V3_CHKPT_STD_SAVE(ctx, pit_state->pit_counter);
- V3_CHKPT_STD_SAVE(ctx, pit_state->pit_reload);
- V3_CHKPT_STD_SAVE(ctx, pit_state->ch_0);
- V3_CHKPT_STD_SAVE(ctx, pit_state->ch_1);
- V3_CHKPT_STD_SAVE(ctx, pit_state->ch_2);
- V3_CHKPT_STD_SAVE(ctx, pit_state->speaker);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, pit_state->pit_counter,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, pit_state->pit_reload,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, pit_state->ch_0,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, pit_state->ch_1,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, pit_state->ch_2,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, pit_state->speaker,savefailout);
return 0;
+
+ savefailout:
+ PrintError("Failed to save pit\n");
+ return -1;
}
static int pit_load(struct v3_chkpt_ctx * ctx, void * private_data) {
struct pit * pit_state = (struct pit *)private_data;
- V3_CHKPT_STD_LOAD(ctx, pit_state->pit_counter);
- V3_CHKPT_STD_LOAD(ctx, pit_state->pit_reload);
- V3_CHKPT_STD_LOAD(ctx, pit_state->ch_0);
- V3_CHKPT_STD_LOAD(ctx, pit_state->ch_1);
- V3_CHKPT_STD_LOAD(ctx, pit_state->ch_2);
- V3_CHKPT_STD_LOAD(ctx, pit_state->speaker);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, pit_state->pit_counter,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, pit_state->pit_reload,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, pit_state->ch_0,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, pit_state->ch_1,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, pit_state->ch_2,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, pit_state->speaker,loadfailout);
return 0;
+
+ loadfailout:
+ PrintError("Failed to load pit\n");
+ return -1;
}
#endif
static int pic_save(struct v3_chkpt_ctx * ctx, void * private_data) {
struct pic_internal * pic = (struct pic_internal *)private_data;
- v3_chkpt_save_8(ctx, "MASTER_IRR", &(pic->master_irr));
- v3_chkpt_save_8(ctx, "SLAVE_IRR", &(pic->slave_irr));
+ V3_CHKPT_SAVE(ctx, "MASTER_IRR", pic->master_irr, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_IRR", pic->slave_irr, savefailout);
- v3_chkpt_save_8(ctx, "MASTER_ISR", &(pic->master_isr));
- v3_chkpt_save_8(ctx, "SLAVE_ISR", &(pic->slave_isr));
+ V3_CHKPT_SAVE(ctx, "MASTER_ISR", pic->master_isr, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_ISR", pic->slave_isr, savefailout);
- v3_chkpt_save_8(ctx, "MASTER_ELCR", &(pic->master_elcr));
- v3_chkpt_save_8(ctx, "SLAVE_ELCR", &(pic->slave_elcr));
- v3_chkpt_save_8(ctx, "MASTER_ELCR_MASK", &(pic->master_elcr_mask));
- v3_chkpt_save_8(ctx, "SLAVE_ELCR_MASK", &(pic->slave_elcr_mask));
+ V3_CHKPT_SAVE(ctx, "MASTER_ELCR", pic->master_elcr, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_ELCR", pic->slave_elcr, savefailout);
+ V3_CHKPT_SAVE(ctx, "MASTER_ELCR_MASK", pic->master_elcr_mask, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_ELCR_MASK", pic->slave_elcr_mask, savefailout);
- v3_chkpt_save_8(ctx, "MASTER_ICW1", &(pic->master_icw1));
- v3_chkpt_save_8(ctx, "MASTER_ICW2", &(pic->master_icw2));
- v3_chkpt_save_8(ctx, "MASTER_ICW3", &(pic->master_icw3));
- v3_chkpt_save_8(ctx, "MASTER_ICW4", &(pic->master_icw4));
+ V3_CHKPT_SAVE(ctx, "MASTER_ICW1", pic->master_icw1, savefailout);
+ V3_CHKPT_SAVE(ctx, "MASTER_ICW2", pic->master_icw2, savefailout);
+ V3_CHKPT_SAVE(ctx, "MASTER_ICW3", pic->master_icw3, savefailout);
+ V3_CHKPT_SAVE(ctx, "MASTER_ICW4", pic->master_icw4, savefailout);
- v3_chkpt_save_8(ctx, "SLAVE_ICW1", &(pic->slave_icw1));
- v3_chkpt_save_8(ctx, "SLAVE_ICW2", &(pic->slave_icw2));
- v3_chkpt_save_8(ctx, "SLAVE_ICW3", &(pic->slave_icw3));
- v3_chkpt_save_8(ctx, "SLAVE_ICW4", &(pic->slave_icw4));
+ V3_CHKPT_SAVE(ctx, "SLAVE_ICW1", pic->slave_icw1, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_ICW2", pic->slave_icw2, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_ICW3", pic->slave_icw3, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_ICW4", pic->slave_icw4, savefailout);
- v3_chkpt_save_8(ctx, "MASTER_IMR", &(pic->master_imr));
- v3_chkpt_save_8(ctx, "SLAVE_IMR", &(pic->slave_imr));
- v3_chkpt_save_8(ctx, "MASTER_OCW2", &(pic->master_ocw2));
- v3_chkpt_save_8(ctx, "MASTER_OCW3", &(pic->master_ocw3));
- v3_chkpt_save_8(ctx, "SLAVE_OCW2", &(pic->slave_ocw2));
- v3_chkpt_save_8(ctx, "SLAVE_OCW3", &(pic->slave_ocw3));
+ V3_CHKPT_SAVE(ctx, "MASTER_IMR", pic->master_imr, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_IMR", pic->slave_imr, savefailout);
+ V3_CHKPT_SAVE(ctx, "MASTER_OCW2", pic->master_ocw2, savefailout);
+ V3_CHKPT_SAVE(ctx, "MASTER_OCW3", pic->master_ocw3, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_OCW2", pic->slave_ocw2, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_OCW3", pic->slave_ocw3, savefailout);
- v3_chkpt_save_8(ctx, "MASTER_STATE", &(pic->master_state));
- v3_chkpt_save_8(ctx, "SLAVE_STATE", &(pic->slave_state));
+ V3_CHKPT_SAVE(ctx, "MASTER_STATE", pic->master_state, savefailout);
+ V3_CHKPT_SAVE(ctx, "SLAVE_STATE", pic->slave_state, savefailout);
return 0;
+ savefailout:
+ PrintError("Failed to save PIC\n");
+ return -1;
+
}
static int pic_load(struct v3_chkpt_ctx * ctx, void * private_data) {
struct pic_internal * pic = (struct pic_internal *)private_data;
- v3_chkpt_load_8(ctx, "MASTER_IRR", &(pic->master_irr));
- v3_chkpt_load_8(ctx, "SLAVE_IRR", &(pic->slave_irr));
+ V3_CHKPT_LOAD(ctx, "MASTER_IRR", pic->master_irr, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_IRR", pic->slave_irr, loadfailout);
- v3_chkpt_load_8(ctx, "MASTER_ISR", &(pic->master_isr));
- v3_chkpt_load_8(ctx, "SLAVE_ISR", &(pic->slave_isr));
+ V3_CHKPT_LOAD(ctx, "MASTER_ISR", pic->master_isr, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_ISR", pic->slave_isr, loadfailout);
- v3_chkpt_load_8(ctx, "MASTER_ELCR", &(pic->master_elcr));
- v3_chkpt_load_8(ctx, "SLAVE_ELCR", &(pic->slave_elcr));
- v3_chkpt_load_8(ctx, "MASTER_ELCR_MASK", &(pic->master_elcr_mask));
- v3_chkpt_load_8(ctx, "SLAVE_ELCR_MASK", &(pic->slave_elcr_mask));
+ V3_CHKPT_LOAD(ctx, "MASTER_ELCR", pic->master_elcr, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_ELCR", pic->slave_elcr, loadfailout);
+ V3_CHKPT_LOAD(ctx, "MASTER_ELCR_MASK", pic->master_elcr_mask, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_ELCR_MASK", pic->slave_elcr_mask, loadfailout);
- v3_chkpt_load_8(ctx, "MASTER_ICW1", &(pic->master_icw1));
- v3_chkpt_load_8(ctx, "MASTER_ICW2", &(pic->master_icw2));
- v3_chkpt_load_8(ctx, "MASTER_ICW3", &(pic->master_icw3));
- v3_chkpt_load_8(ctx, "MASTER_ICW4", &(pic->master_icw4));
+ V3_CHKPT_LOAD(ctx, "MASTER_ICW1", pic->master_icw1, loadfailout);
+ V3_CHKPT_LOAD(ctx, "MASTER_ICW2", pic->master_icw2, loadfailout);
+ V3_CHKPT_LOAD(ctx, "MASTER_ICW3", pic->master_icw3, loadfailout);
+ V3_CHKPT_LOAD(ctx, "MASTER_ICW4", pic->master_icw4, loadfailout);
- v3_chkpt_load_8(ctx, "SLAVE_ICW1", &(pic->slave_icw1));
- v3_chkpt_load_8(ctx, "SLAVE_ICW2", &(pic->slave_icw2));
- v3_chkpt_load_8(ctx, "SLAVE_ICW3", &(pic->slave_icw3));
- v3_chkpt_load_8(ctx, "SLAVE_ICW4", &(pic->slave_icw4));
+ V3_CHKPT_LOAD(ctx, "SLAVE_ICW1", pic->slave_icw1, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_ICW2", pic->slave_icw2, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_ICW3", pic->slave_icw3, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_ICW4", pic->slave_icw4, loadfailout);
- v3_chkpt_load_8(ctx, "MASTER_IMR", &(pic->master_imr));
- v3_chkpt_load_8(ctx, "SLAVE_IMR", &(pic->slave_imr));
- v3_chkpt_load_8(ctx, "MASTER_OCW2", &(pic->master_ocw2));
- v3_chkpt_load_8(ctx, "MASTER_OCW3", &(pic->master_ocw3));
- v3_chkpt_load_8(ctx, "SLAVE_OCW2", &(pic->slave_ocw2));
- v3_chkpt_load_8(ctx, "SLAVE_OCW3", &(pic->slave_ocw3));
+ V3_CHKPT_LOAD(ctx, "MASTER_IMR", pic->master_imr, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_IMR", pic->slave_imr, loadfailout);
+ V3_CHKPT_LOAD(ctx, "MASTER_OCW2", pic->master_ocw2, loadfailout);
+ V3_CHKPT_LOAD(ctx, "MASTER_OCW3", pic->master_ocw3, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_OCW2", pic->slave_ocw2, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_OCW3", pic->slave_ocw3, loadfailout);
- v3_chkpt_load_8(ctx, "MASTER_STATE", &(pic->master_state));
- v3_chkpt_load_8(ctx, "SLAVE_STATE", &(pic->slave_state));
+ V3_CHKPT_LOAD(ctx, "MASTER_STATE", pic->master_state, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SLAVE_STATE", pic->slave_state, loadfailout);
return 0;
+
+ loadfailout:
+ PrintError("Failed to load PIC\n");
+ return -1;
}
#endif
int i = 0;
uint32_t temp;
- V3_CHKPT_STD_SAVE(ctx, apic_state->num_apics);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->num_apics,savefailout);
//V3_CHKPT_STD_SAVE(ctx,apic_state->state_lock);
for (i = 0; i < apic_state->num_apics; i++) {
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].base_addr);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].base_addr_msr);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].lapic_id);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].apic_ver);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].ext_apic_ctrl);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].local_vec_tbl);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].tmr_vec_tbl);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].tmr_div_cfg);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].lint0_vec_tbl);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].lint1_vec_tbl);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].perf_ctr_loc_vec_tbl);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].therm_loc_vec_tbl);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].err_vec_tbl);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].err_status);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].spurious_int);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].int_cmd);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].log_dst);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].dst_fmt);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].base_addr,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].base_addr_msr,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].lapic_id,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].apic_ver,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].ext_apic_ctrl,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].local_vec_tbl,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].tmr_vec_tbl,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].tmr_div_cfg,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].lint0_vec_tbl,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].lint1_vec_tbl,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].perf_ctr_loc_vec_tbl,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].therm_loc_vec_tbl,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].err_vec_tbl,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].err_status,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].spurious_int,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].int_cmd,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].log_dst,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].dst_fmt,savefailout);
// APR and PPR are stored only for compatability
// TPR is in APIC_TPR, APR and PPR are derived
temp = get_apic_apr(&(apic_state->apics[i]));
- V3_CHKPT_STD_SAVE(ctx, temp);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, temp,savefailout);
temp = get_apic_tpr(&(apic_state->apics[i]));
- V3_CHKPT_STD_SAVE(ctx, temp);
+ V3_CHKPT_SAVE_AUTOTAG(ctx,temp,savefailout);
temp = get_apic_ppr(&(apic_state->apics[i]));
- V3_CHKPT_STD_SAVE(ctx, temp);
-
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].ext_apic_feature);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].spec_eoi);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].tmr_cur_cnt);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].tmr_init_cnt);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].ext_intr_vec_tbl);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].rem_rd_data);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].ipi_state);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].int_req_reg);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].int_svc_reg);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].int_en_reg);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].trig_mode_reg);
- V3_CHKPT_STD_SAVE(ctx, apic_state->apics[i].eoi);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, temp,savefailout);
+
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].ext_apic_feature,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].spec_eoi,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].tmr_cur_cnt,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].tmr_init_cnt,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].ext_intr_vec_tbl,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].rem_rd_data,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].ipi_state,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].int_req_reg,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].int_svc_reg,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].int_en_reg,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].trig_mode_reg,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, apic_state->apics[i].eoi,savefailout);
}
return 0;
+
+ savefailout:
+ PrintError("Failed to save apic\n");
+ return -1;
}
static int apic_load(struct v3_chkpt_ctx * ctx, void * private_data) {
int i = 0;
uint32_t temp;
- V3_CHKPT_STD_LOAD(ctx,apic_state->num_apics);
+ V3_CHKPT_LOAD_AUTOTAG(ctx,apic_state->num_apics, loadfailout);
for (i = 0; i < apic_state->num_apics; i++) {
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].base_addr);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].base_addr_msr);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].lapic_id);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].apic_ver);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].ext_apic_ctrl);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].local_vec_tbl);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].tmr_vec_tbl);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].tmr_div_cfg);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].lint0_vec_tbl);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].lint1_vec_tbl);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].perf_ctr_loc_vec_tbl);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].therm_loc_vec_tbl);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].err_vec_tbl);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].err_status);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].spurious_int);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].int_cmd);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].log_dst);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].dst_fmt);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].base_addr, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].base_addr_msr, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].lapic_id, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].apic_ver, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].ext_apic_ctrl, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].local_vec_tbl, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].tmr_vec_tbl, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].tmr_div_cfg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].lint0_vec_tbl, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].lint1_vec_tbl, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].perf_ctr_loc_vec_tbl, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].therm_loc_vec_tbl, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].err_vec_tbl, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].err_status, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].spurious_int, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].int_cmd, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].log_dst, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].dst_fmt, loadfailout);
// APR is ignored
- V3_CHKPT_STD_LOAD(ctx, temp);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, temp, loadfailout);
// TPR is written back to APIC_TPR
- V3_CHKPT_STD_LOAD(ctx, temp);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, temp, loadfailout);
set_apic_tpr(&(apic_state->apics[i]),temp);
// PPR is ignored
- V3_CHKPT_STD_LOAD(ctx, temp);
-
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].ext_apic_feature);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].spec_eoi);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].tmr_cur_cnt);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].tmr_init_cnt);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].ext_intr_vec_tbl);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].rem_rd_data);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].ipi_state);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].int_req_reg);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].int_svc_reg);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].int_en_reg);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].trig_mode_reg);
- V3_CHKPT_STD_LOAD(ctx, apic_state->apics[i].eoi);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, temp, loadfailout);
+
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].ext_apic_feature, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].spec_eoi, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].tmr_cur_cnt, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].tmr_init_cnt, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].ext_intr_vec_tbl, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].rem_rd_data, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].ipi_state, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].int_req_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].int_svc_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].int_en_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].trig_mode_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, apic_state->apics[i].eoi, loadfailout);
}
return 0;
+
+ loadfailout:
+ PrintError("Failed to load apic\n");
+ return -1;
+
}
#endif
static int cga_save(struct v3_chkpt_ctx * ctx, void * private_data) {
struct video_internal * cga = (struct video_internal *)private_data;
- v3_chkpt_save(ctx, "FRAMEBUFFER", FRAMEBUF_SIZE, cga->framebuf);
-
- V3_CHKPT_STD_SAVE(ctx, cga->misc_outp_reg);
- V3_CHKPT_STD_SAVE(ctx, cga->seq_index_reg);
- V3_CHKPT_STD_SAVE(ctx, cga->seq_data_regs[SEQ_REG_COUNT]);
- V3_CHKPT_STD_SAVE(ctx, cga->crtc_index_reg);
- V3_CHKPT_STD_SAVE(ctx, cga->crtc_data_regs[CRTC_REG_COUNT]);
- V3_CHKPT_STD_SAVE(ctx, cga->graphc_index_reg);
- V3_CHKPT_STD_SAVE(ctx, cga->graphc_data_regs[GRAPHC_REG_COUNT]);
- V3_CHKPT_STD_SAVE(ctx, cga->attrc_index_flipflop);
- V3_CHKPT_STD_SAVE(ctx, cga->attrc_index_reg);
- V3_CHKPT_STD_SAVE(ctx, cga->attrc_data_regs[ATTRC_REG_COUNT]);
- V3_CHKPT_STD_SAVE(ctx, cga->dac_indexr_reg);
- V3_CHKPT_STD_SAVE(ctx, cga->dac_indexr_color);
- V3_CHKPT_STD_SAVE(ctx, cga->dac_indexw_reg);
- V3_CHKPT_STD_SAVE(ctx, cga->dac_indexw_color);
- V3_CHKPT_STD_SAVE(ctx, cga->dac_data_regs[DAC_REG_COUNT]);
-
- V3_CHKPT_STD_SAVE(ctx, cga->activefb_addr);
- V3_CHKPT_STD_SAVE(ctx, cga->activefb_len);
- V3_CHKPT_STD_SAVE(ctx, cga->iorange);
- V3_CHKPT_STD_SAVE(ctx, cga->vres);
- V3_CHKPT_STD_SAVE(ctx, cga->hres);
- V3_CHKPT_STD_SAVE(ctx, cga->vchars);
- V3_CHKPT_STD_SAVE(ctx, cga->hchars);
- V3_CHKPT_STD_SAVE(ctx, cga->graphmode);
-
- V3_CHKPT_STD_SAVE(ctx, cga->dirty);
- V3_CHKPT_STD_SAVE(ctx, cga->reschanged);
-
- V3_CHKPT_STD_SAVE(ctx, cga->passthrough);
-
- v3_chkpt_save_16(ctx, "SCREEN_OFFSET", &(cga->screen_offset));
- v3_chkpt_save_16(ctx, "CURSOR_OFFSET", &(cga->cursor_offset));
+ if (v3_chkpt_save(ctx, "FRAMEBUFFER", FRAMEBUF_SIZE, cga->framebuf)) {
+ goto savefailout;
+ }
+
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->misc_outp_reg, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->seq_index_reg, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->seq_data_regs, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->crtc_index_reg, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->crtc_data_regs, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->graphc_index_reg, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->graphc_data_regs, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->attrc_index_flipflop, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->attrc_index_reg, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->attrc_data_regs, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->dac_indexr_reg, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->dac_indexr_color, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->dac_indexw_reg, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->dac_indexw_color, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->dac_data_regs, savefailout);
+
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->activefb_addr, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->activefb_len, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->iorange, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->vres, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->hres, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->vchars, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->hchars, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->graphmode, savefailout);
+
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->dirty, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->reschanged, savefailout);
+
+ V3_CHKPT_SAVE_AUTOTAG(ctx, cga->passthrough, savefailout);
+
+ V3_CHKPT_SAVE(ctx, "SCREEN_OFFSET", cga->screen_offset, savefailout);
+ V3_CHKPT_SAVE(ctx, "CURSOR_OFFSET", cga->cursor_offset, savefailout);
return 0;
+
+ savefailout:
+ PrintError("Failed to save CGA\n");
+ return -1;
+
}
static int cga_load(struct v3_chkpt_ctx * ctx, void * private_data) {
struct video_internal * cga = (struct video_internal *)private_data;
- v3_chkpt_load(ctx, "FRAMEBUFFER", FRAMEBUF_SIZE, cga->framebuf);
-
-
- V3_CHKPT_STD_LOAD(ctx, cga->misc_outp_reg);
- V3_CHKPT_STD_LOAD(ctx, cga->seq_index_reg);
- V3_CHKPT_STD_LOAD(ctx, cga->seq_data_regs[SEQ_REG_COUNT]);
- V3_CHKPT_STD_LOAD(ctx, cga->crtc_index_reg);
- V3_CHKPT_STD_LOAD(ctx, cga->crtc_data_regs[CRTC_REG_COUNT]);
- V3_CHKPT_STD_LOAD(ctx, cga->graphc_index_reg);
- V3_CHKPT_STD_LOAD(ctx, cga->graphc_data_regs[GRAPHC_REG_COUNT]);
- V3_CHKPT_STD_LOAD(ctx, cga->attrc_index_flipflop);
- V3_CHKPT_STD_LOAD(ctx, cga->attrc_index_reg);
- V3_CHKPT_STD_LOAD(ctx, cga->attrc_data_regs[ATTRC_REG_COUNT]);
- V3_CHKPT_STD_LOAD(ctx, cga->dac_indexr_reg);
- V3_CHKPT_STD_LOAD(ctx, cga->dac_indexr_color);
- V3_CHKPT_STD_LOAD(ctx, cga->dac_indexw_reg);
- V3_CHKPT_STD_LOAD(ctx, cga->dac_indexw_color);
- V3_CHKPT_STD_LOAD(ctx, cga->dac_data_regs[DAC_REG_COUNT]);
+ if (v3_chkpt_load(ctx, "FRAMEBUFFER", FRAMEBUF_SIZE, cga->framebuf)) {
+ goto loadfailout;
+ }
- V3_CHKPT_STD_LOAD(ctx, cga->activefb_addr);
- V3_CHKPT_STD_LOAD(ctx, cga->activefb_len);
- V3_CHKPT_STD_LOAD(ctx, cga->iorange);
- V3_CHKPT_STD_LOAD(ctx, cga->vres);
- V3_CHKPT_STD_LOAD(ctx, cga->hres);
- V3_CHKPT_STD_LOAD(ctx, cga->vchars);
- V3_CHKPT_STD_LOAD(ctx, cga->hchars);
- V3_CHKPT_STD_LOAD(ctx, cga->graphmode);
- V3_CHKPT_STD_LOAD(ctx, cga->dirty);
- V3_CHKPT_STD_LOAD(ctx, cga->reschanged);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->misc_outp_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->seq_index_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->seq_data_regs, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->crtc_index_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->crtc_data_regs, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->graphc_index_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->graphc_data_regs, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->attrc_index_flipflop, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->attrc_index_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->attrc_data_regs, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->dac_indexr_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->dac_indexr_color, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->dac_indexw_reg, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->dac_indexw_color, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->dac_data_regs, loadfailout);
+
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->activefb_addr, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->activefb_len, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->iorange, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->vres, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->hres, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->vchars, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->hchars, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->graphmode, loadfailout);
+
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->dirty, loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->reschanged, loadfailout);
+
+ V3_CHKPT_LOAD_AUTOTAG(ctx, cga->passthrough, loadfailout);
+
+ V3_CHKPT_LOAD(ctx, "SCREEN_OFFSET", cga->screen_offset, loadfailout);
+ V3_CHKPT_LOAD(ctx, "CURSOR_OFFSET", cga->cursor_offset, loadfailout);
- V3_CHKPT_STD_LOAD(ctx, cga->passthrough);
- v3_chkpt_load_16(ctx, "SCREEN_OFFSET", &(cga->screen_offset));
- v3_chkpt_load_16(ctx, "CURSOR_OFFSET", &(cga->cursor_offset));
+ return 0;
+ loadfailout:
+ PrintError("Failed to load cga\n");
+ return -1;
- return 0;
}
#endif
#ifdef V3_CONFIG_CHECKPOINT
#include <palacios/vmm_sprintf.h>
-static int ide_save(struct v3_chkpt_ctx * ctx, void * private_data) {
+
+static int ide_save_extended(struct v3_chkpt *chkpt, char *id, void * private_data) {
struct ide_internal * ide = (struct ide_internal *)private_data;
+ struct v3_chkpt_ctx *ctx=0;
int ch_num = 0;
int drive_num = 0;
char buf[128];
+ ctx=v3_chkpt_open_ctx(chkpt,id);
+
+ if (!ctx) {
+ PrintError("Failed to open context for save\n");
+ goto savefailout;
+ }
+
+ // nothing saved yet
+
+ v3_chkpt_close_ctx(ctx);ctx=0;
+
+
for (ch_num = 0; ch_num < 2; ch_num++) {
- struct v3_chkpt_ctx * ch_ctx = NULL;
struct ide_channel * ch = &(ide->channels[ch_num]);
- snprintf(buf, 128, "channel-%d", ch_num);
- ch_ctx = v3_chkpt_open_ctx(ctx->chkpt, ctx, buf);
+ snprintf(buf, 128, "%s-%d", id, ch_num);
+
+ ctx = v3_chkpt_open_ctx(chkpt, buf);
+
+ if (!ctx) {
+ PrintError("Unable to open context to save channel %d\n",ch_num);
+ goto savefailout;
+ }
- v3_chkpt_save_8(ch_ctx, "ERROR", &(ch->error_reg.val));
- v3_chkpt_save_8(ch_ctx, "FEATURES", &(ch->features.val));
- v3_chkpt_save_8(ch_ctx, "DRIVE_HEAD", &(ch->drive_head.val));
- v3_chkpt_save_8(ch_ctx, "STATUS", &(ch->status.val));
- v3_chkpt_save_8(ch_ctx, "CMD_REG", &(ch->cmd_reg));
- v3_chkpt_save_8(ch_ctx, "CTRL_REG", &(ch->ctrl_reg.val));
- v3_chkpt_save_8(ch_ctx, "DMA_CMD", &(ch->dma_cmd.val));
- v3_chkpt_save_8(ch_ctx, "DMA_STATUS", &(ch->dma_status.val));
- v3_chkpt_save_32(ch_ctx, "PRD_ADDR", &(ch->dma_prd_addr));
- v3_chkpt_save_32(ch_ctx, "DMA_TBL_IDX", &(ch->dma_tbl_index));
+ V3_CHKPT_SAVE(ctx, "ERROR", ch->error_reg.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "FEATURES", ch->features.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "DRIVE_HEAD", ch->drive_head.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "STATUS", ch->status.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "CMD_REG", ch->cmd_reg, savefailout);
+ V3_CHKPT_SAVE(ctx, "CTRL_REG", ch->ctrl_reg.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "DMA_CMD", ch->dma_cmd.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "DMA_STATUS", ch->dma_status.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "PRD_ADDR", ch->dma_prd_addr, savefailout);
+ V3_CHKPT_SAVE(ctx, "DMA_TBL_IDX", ch->dma_tbl_index, savefailout);
+ v3_chkpt_close_ctx(ctx); ctx=0;
for (drive_num = 0; drive_num < 2; drive_num++) {
- struct v3_chkpt_ctx * drive_ctx = NULL;
struct ide_drive * drive = &(ch->drives[drive_num]);
- snprintf(buf, 128, "drive-%d-%d", ch_num, drive_num);
- drive_ctx = v3_chkpt_open_ctx(ctx->chkpt, ch_ctx, buf);
+ snprintf(buf, 128, "%s-%d-%d", id, ch_num, drive_num);
+
+ ctx = v3_chkpt_open_ctx(chkpt, buf);
- v3_chkpt_save_8(drive_ctx, "DRIVE_TYPE", &(drive->drive_type));
- v3_chkpt_save_8(drive_ctx, "SECTOR_COUNT", &(drive->sector_count));
- v3_chkpt_save_8(drive_ctx, "SECTOR_NUM", &(drive->sector_num));
- v3_chkpt_save_16(drive_ctx, "CYLINDER", &(drive->cylinder));
+ if (!ctx) {
+ PrintError("Unable to open context to save drive %d\n",drive_num);
+ goto savefailout;
+ }
+
+ V3_CHKPT_SAVE(ctx, "DRIVE_TYPE", drive->drive_type, savefailout);
+ V3_CHKPT_SAVE(ctx, "SECTOR_COUNT", drive->sector_count, savefailout);
+ V3_CHKPT_SAVE(ctx, "SECTOR_NUM", drive->sector_num, savefailout);
+ V3_CHKPT_SAVE(ctx, "CYLINDER", drive->cylinder,savefailout);
- v3_chkpt_save_64(drive_ctx, "CURRENT_LBA", &(drive->current_lba));
- v3_chkpt_save_32(drive_ctx, "TRANSFER_LENGTH", &(drive->transfer_length));
- v3_chkpt_save_32(drive_ctx, "TRANSFER_INDEX", &(drive->transfer_index));
+ V3_CHKPT_SAVE(ctx, "CURRENT_LBA", drive->current_lba, savefailout);
+ V3_CHKPT_SAVE(ctx, "TRANSFER_LENGTH", drive->transfer_length, savefailout);
+ V3_CHKPT_SAVE(ctx, "TRANSFER_INDEX", drive->transfer_index, savefailout);
- v3_chkpt_save(drive_ctx, "DATA_BUF", DATA_BUFFER_SIZE, drive->data_buf);
+ V3_CHKPT_SAVE(ctx, "DATA_BUF", drive->data_buf, savefailout);
/* For now we'll just pack the type specific data at the end... */
/* We should probably add a new context here in the future... */
if (drive->drive_type == BLOCK_CDROM) {
- v3_chkpt_save(drive_ctx, "ATAPI_SENSE_DATA", 18, drive->cd_state.sense.buf);
- v3_chkpt_save_8(drive_ctx, "ATAPI_CMD", &(drive->cd_state.atapi_cmd));
- v3_chkpt_save(drive_ctx, "ATAPI_ERR_RECOVERY", 12, drive->cd_state.err_recovery.buf);
+ V3_CHKPT_SAVE(ctx, "ATAPI_SENSE_DATA", drive->cd_state.sense.buf, savefailout);
+ V3_CHKPT_SAVE(ctx, "ATAPI_CMD", drive->cd_state.atapi_cmd, savefailout);
+ V3_CHKPT_SAVE(ctx, "ATAPI_ERR_RECOVERY", drive->cd_state.err_recovery.buf, savefailout);
} else if (drive->drive_type == BLOCK_DISK) {
- v3_chkpt_save_32(drive_ctx, "ACCESSED", &(drive->hd_state.accessed));
- v3_chkpt_save_32(drive_ctx, "MULT_SECT_NUM", &(drive->hd_state.mult_sector_num));
- v3_chkpt_save_32(drive_ctx, "CUR_SECT_NUM", &(drive->hd_state.cur_sector_num));
+ V3_CHKPT_SAVE(ctx, "ACCESSED", drive->hd_state.accessed, savefailout);
+ V3_CHKPT_SAVE(ctx, "MULT_SECT_NUM", drive->hd_state.mult_sector_num, savefailout);
+ V3_CHKPT_SAVE(ctx, "CUR_SECT_NUM", drive->hd_state.cur_sector_num, savefailout);
+ } else if (drive->drive_type == BLOCK_NONE) {
+ // no drive connected, so no data
+ } else {
+ PrintError("Invalid drive type %d\n",drive->drive_type);
+ goto savefailout;
}
+
+ v3_chkpt_close_ctx(ctx); ctx=0;
}
}
+// goodout:
return 0;
+
+ savefailout:
+ PrintError("Failed to save IDE\n");
+ if (ctx) {v3_chkpt_close_ctx(ctx); }
+ return -1;
}
-static int ide_load(struct v3_chkpt_ctx * ctx, void * private_data) {
+static int ide_load_extended(struct v3_chkpt *chkpt, char *id, void * private_data) {
struct ide_internal * ide = (struct ide_internal *)private_data;
+ struct v3_chkpt_ctx *ctx=0;
int ch_num = 0;
int drive_num = 0;
char buf[128];
+ ctx=v3_chkpt_open_ctx(chkpt,id);
+
+ if (!ctx) {
+ PrintError("Failed to open context for load\n");
+ goto loadfailout;
+ }
+
+ // nothing saved yet
+
+ v3_chkpt_close_ctx(ctx);ctx=0;
+
for (ch_num = 0; ch_num < 2; ch_num++) {
- struct v3_chkpt_ctx * ch_ctx = NULL;
struct ide_channel * ch = &(ide->channels[ch_num]);
- snprintf(buf, 128, "channel-%d", ch_num);
- ch_ctx = v3_chkpt_open_ctx(ctx->chkpt, ctx, buf);
+ snprintf(buf, 128, "%s-%d", id, ch_num);
- v3_chkpt_load_8(ch_ctx, "ERROR", &(ch->error_reg.val));
- v3_chkpt_load_8(ch_ctx, "FEATURES", &(ch->features.val));
- v3_chkpt_load_8(ch_ctx, "DRIVE_HEAD", &(ch->drive_head.val));
- v3_chkpt_load_8(ch_ctx, "STATUS", &(ch->status.val));
- v3_chkpt_load_8(ch_ctx, "CMD_REG", &(ch->cmd_reg));
- v3_chkpt_load_8(ch_ctx, "CTRL_REG", &(ch->ctrl_reg.val));
- v3_chkpt_load_8(ch_ctx, "DMA_CMD", &(ch->dma_cmd.val));
- v3_chkpt_load_8(ch_ctx, "DMA_STATUS", &(ch->dma_status.val));
- v3_chkpt_load_32(ch_ctx, "PRD_ADDR", &(ch->dma_prd_addr));
- v3_chkpt_load_32(ch_ctx, "DMA_TBL_IDX", &(ch->dma_tbl_index));
+ ctx = v3_chkpt_open_ctx(chkpt, buf);
+
+ if (!ctx) {
+ PrintError("Unable to open context to load channel %d\n",ch_num);
+ goto loadfailout;
+ }
+ V3_CHKPT_LOAD(ctx, "ERROR", ch->error_reg.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "FEATURES", ch->features.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "DRIVE_HEAD", ch->drive_head.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "STATUS", ch->status.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "CMD_REG", ch->cmd_reg, loadfailout);
+ V3_CHKPT_LOAD(ctx, "CTRL_REG", ch->ctrl_reg.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "DMA_CMD", ch->dma_cmd.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "DMA_STATUS", ch->dma_status.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "PRD_ADDR", ch->dma_prd_addr, loadfailout);
+ V3_CHKPT_LOAD(ctx, "DMA_TBL_IDX", ch->dma_tbl_index, loadfailout);
+
+ v3_chkpt_close_ctx(ctx); ctx=0;
for (drive_num = 0; drive_num < 2; drive_num++) {
- struct v3_chkpt_ctx * drive_ctx = NULL;
struct ide_drive * drive = &(ch->drives[drive_num]);
- snprintf(buf, 128, "drive-%d-%d", ch_num, drive_num);
- drive_ctx = v3_chkpt_open_ctx(ctx->chkpt, ch_ctx, buf);
+ snprintf(buf, 128, "%s-%d-%d", id, ch_num, drive_num);
+
+ ctx = v3_chkpt_open_ctx(chkpt, buf);
- v3_chkpt_load_8(drive_ctx, "DRIVE_TYPE", &(drive->drive_type));
- v3_chkpt_load_8(drive_ctx, "SECTOR_COUNT", &(drive->sector_count));
- v3_chkpt_load_8(drive_ctx, "SECTOR_NUM", &(drive->sector_num));
- v3_chkpt_load_16(drive_ctx, "CYLINDER", &(drive->cylinder));
+ if (!ctx) {
+ PrintError("Unable to open context to load drive %d\n",drive_num);
+ goto loadfailout;
+ }
- v3_chkpt_load_64(drive_ctx, "CURRENT_LBA", &(drive->current_lba));
- v3_chkpt_load_32(drive_ctx, "TRANSFER_LENGTH", &(drive->transfer_length));
- v3_chkpt_load_32(drive_ctx, "TRANSFER_INDEX", &(drive->transfer_index));
+ V3_CHKPT_LOAD(ctx, "DRIVE_TYPE", drive->drive_type, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SECTOR_COUNT", drive->sector_count, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SECTOR_NUM", drive->sector_num, loadfailout);
+ V3_CHKPT_LOAD(ctx, "CYLINDER", drive->cylinder,loadfailout);
- v3_chkpt_load(drive_ctx, "DATA_BUF", DATA_BUFFER_SIZE, drive->data_buf);
+ V3_CHKPT_LOAD(ctx, "CURRENT_LBA", drive->current_lba, loadfailout);
+ V3_CHKPT_LOAD(ctx, "TRANSFER_LENGTH", drive->transfer_length, loadfailout);
+ V3_CHKPT_LOAD(ctx, "TRANSFER_INDEX", drive->transfer_index, loadfailout);
+ V3_CHKPT_LOAD(ctx, "DATA_BUF", drive->data_buf, loadfailout);
+
/* For now we'll just pack the type specific data at the end... */
/* We should probably add a new context here in the future... */
if (drive->drive_type == BLOCK_CDROM) {
- v3_chkpt_load(drive_ctx, "ATAPI_SENSE_DATA", 18, drive->cd_state.sense.buf);
- v3_chkpt_load_8(drive_ctx, "ATAPI_CMD", &(drive->cd_state.atapi_cmd));
- v3_chkpt_load(drive_ctx, "ATAPI_ERR_RECOVERY", 12, drive->cd_state.err_recovery.buf);
+ V3_CHKPT_LOAD(ctx, "ATAPI_SENSE_DATA", drive->cd_state.sense.buf, loadfailout);
+ V3_CHKPT_LOAD(ctx, "ATAPI_CMD", drive->cd_state.atapi_cmd, loadfailout);
+ V3_CHKPT_LOAD(ctx, "ATAPI_ERR_RECOVERY", drive->cd_state.err_recovery.buf, loadfailout);
} else if (drive->drive_type == BLOCK_DISK) {
- v3_chkpt_load_32(drive_ctx, "ACCESSED", &(drive->hd_state.accessed));
- v3_chkpt_load_32(drive_ctx, "MULT_SECT_NUM", &(drive->hd_state.mult_sector_num));
- v3_chkpt_load_32(drive_ctx, "CUR_SECT_NUM", &(drive->hd_state.cur_sector_num));
+ V3_CHKPT_LOAD(ctx, "ACCESSED", drive->hd_state.accessed, loadfailout);
+ V3_CHKPT_LOAD(ctx, "MULT_SECT_NUM", drive->hd_state.mult_sector_num, loadfailout);
+ V3_CHKPT_LOAD(ctx, "CUR_SECT_NUM", drive->hd_state.cur_sector_num, loadfailout);
+ } else if (drive->drive_type == BLOCK_NONE) {
+ // no drive connected, so no data
+ } else {
+ PrintError("Invalid drive type %d\n",drive->drive_type);
+ goto loadfailout;
}
}
}
-
+// goodout:
return 0;
+
+ loadfailout:
+ PrintError("Failed to load IDE\n");
+ if (ctx) {v3_chkpt_close_ctx(ctx); }
+ return -1;
+
}
static struct v3_device_ops dev_ops = {
.free = (int (*)(void *))ide_free,
#ifdef V3_CONFIG_CHECKPOINT
- .save = ide_save,
- .load = ide_load
+ .save_extended = ide_save_extended,
+ .load_extended = ide_load_extended
#endif
-
};
static int io_apic_save(struct v3_chkpt_ctx * ctx, void * private_data) {
struct io_apic_state * io_apic = (struct io_apic_state *)private_data;
- V3_CHKPT_STD_SAVE(ctx, io_apic->base_addr);
- V3_CHKPT_STD_SAVE(ctx, io_apic->index_reg);
- V3_CHKPT_STD_SAVE(ctx, io_apic->ioapic_id);
- V3_CHKPT_STD_SAVE(ctx, io_apic->ioapic_ver);
- V3_CHKPT_STD_SAVE(ctx, io_apic->ioapic_arb_id);
- V3_CHKPT_STD_SAVE(ctx, io_apic->redir_tbl);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, io_apic->base_addr,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, io_apic->index_reg,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, io_apic->ioapic_id,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, io_apic->ioapic_ver,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, io_apic->ioapic_arb_id,savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, io_apic->redir_tbl,savefailout);
return 0;
+
+ savefailout:
+ PrintError("ioapic save failed\n");
+ return -1;
}
static int io_apic_load(struct v3_chkpt_ctx * ctx, void * private_data) {
struct io_apic_state * io_apic = (struct io_apic_state *)private_data;
- V3_CHKPT_STD_LOAD(ctx, io_apic->base_addr);
- V3_CHKPT_STD_LOAD(ctx, io_apic->index_reg);
- V3_CHKPT_STD_LOAD(ctx, io_apic->ioapic_id);
- V3_CHKPT_STD_LOAD(ctx, io_apic->ioapic_ver);
- V3_CHKPT_STD_LOAD(ctx, io_apic->ioapic_arb_id);
- V3_CHKPT_STD_LOAD(ctx, io_apic->redir_tbl);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, io_apic->base_addr,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, io_apic->index_reg,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, io_apic->ioapic_id,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, io_apic->ioapic_ver,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, io_apic->ioapic_arb_id,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, io_apic->redir_tbl,loadfailout);
return 0;
+
+ loadfailout:
+ PrintError("ioapic load failed\n");
+ return -1;
+
}
#endif
static int keyboard_save(struct v3_chkpt_ctx * ctx, void * private_data) {
struct keyboard_internal * kbd = (struct keyboard_internal *)private_data;
- v3_chkpt_save_8(ctx, "CMD_REG", &(kbd->cmd.val));
- v3_chkpt_save_8(ctx, "STATUS_REG", &(kbd->status.val));
- v3_chkpt_save_8(ctx, "STATE", &(kbd->state));
- v3_chkpt_save_8(ctx, "MOUSE_STATE", &(kbd->mouse_state));
- v3_chkpt_save_8(ctx, "OUTPUT", &(kbd->output_byte));
- v3_chkpt_save_8(ctx, "INPUT", &(kbd->input_byte));
- v3_chkpt_save_8(ctx, "SCANCODE_SET", &(kbd->scancode_set));
- v3_chkpt_save_8(ctx, "MOUSE_ENABLED", &(kbd->mouse_enabled));
+ V3_CHKPT_SAVE(ctx, "CMD_REG", kbd->cmd.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "STATUS_REG", kbd->status.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "STATE", kbd->state, savefailout);
+ V3_CHKPT_SAVE(ctx, "MOUSE_STATE", kbd->mouse_state, savefailout);
+ V3_CHKPT_SAVE(ctx, "OUTPUT", kbd->output_byte, savefailout);
+ V3_CHKPT_SAVE(ctx, "INPUT", kbd->input_byte, savefailout);
+ V3_CHKPT_SAVE(ctx, "SCANCODE_SET", kbd->scancode_set, savefailout);
+ V3_CHKPT_SAVE(ctx, "MOUSE_ENABLED", kbd->mouse_enabled, savefailout);
return 0;
+
+ savefailout:
+ PrintError("Failed to save keyboard\n");
+ return -1;
+
}
struct keyboard_internal * kbd = (struct keyboard_internal *)private_data;
keyboard_reset_device(kbd);
- v3_chkpt_load_8(ctx, "CMD_REG", &(kbd->cmd.val));
- v3_chkpt_load_8(ctx, "STATUS_REG", &(kbd->status.val));
- v3_chkpt_load_8(ctx, "STATE", &(kbd->state));
- v3_chkpt_load_8(ctx, "MOUSE_STATE", &(kbd->mouse_state));
- v3_chkpt_load_8(ctx, "OUTPUT", &(kbd->output_byte));
- v3_chkpt_load_8(ctx, "INPUT", &(kbd->input_byte));
- v3_chkpt_load_8(ctx, "SCANCODE_SET", &(kbd->scancode_set));
- v3_chkpt_load_8(ctx, "MOUSE_ENABLED", &(kbd->mouse_enabled));
+ V3_CHKPT_LOAD(ctx, "CMD_REG", kbd->cmd.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "STATUS_REG", kbd->status.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "STATE", kbd->state, loadfailout);
+ V3_CHKPT_LOAD(ctx, "MOUSE_STATE", kbd->mouse_state, loadfailout);
+ V3_CHKPT_LOAD(ctx, "OUTPUT", kbd->output_byte, loadfailout);
+ V3_CHKPT_LOAD(ctx, "INPUT", kbd->input_byte, loadfailout);
+ V3_CHKPT_LOAD(ctx, "SCANCODE_SET", kbd->scancode_set, loadfailout);
+ V3_CHKPT_LOAD(ctx, "MOUSE_ENABLED", kbd->mouse_enabled, loadfailout);
return 0;
+
+ loadfailout:
+ PrintError("Failed to load keyboard\n");
+ return -1;
}
#endif
static int debug_save(struct v3_chkpt_ctx * ctx, void * private_data) {
struct debug_state * dbg = (struct debug_state *)private_data;
- V3_CHKPT_STD_SAVE(ctx, dbg->debug_buf);
- V3_CHKPT_STD_SAVE(ctx, dbg->debug_offset);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, dbg->debug_buf, savefailout);
+ V3_CHKPT_SAVE_AUTOTAG(ctx, dbg->debug_offset, savefailout);
return 0;
+
+ savefailout:
+ PrintError("Failed to save debug\n");
+ return -1;
+
}
static int debug_load(struct v3_chkpt_ctx * ctx, void * private_data) {
struct debug_state * dbg = (struct debug_state *)private_data;
- V3_CHKPT_STD_LOAD(ctx, dbg->debug_buf);
- V3_CHKPT_STD_LOAD(ctx, dbg->debug_offset);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, dbg->debug_buf,loadfailout);
+ V3_CHKPT_LOAD_AUTOTAG(ctx, dbg->debug_offset,loadfailout);
return 0;
+
+ loadfailout:
+ PrintError("Failed to load debug\n");
+ return -1;
}
#endif
#include <palacios/vmm_sprintf.h>
-static int pci_save(struct v3_chkpt_ctx * ctx, void * private_data) {
+static int pci_save_extended(struct v3_chkpt *chkpt, char *id, void * private_data) {
struct pci_internal * pci = (struct pci_internal *)private_data;
+ struct v3_chkpt_ctx *ctx=0;
char buf[128];
int i = 0;
-
- v3_chkpt_save_32(ctx, "ADDR_REG", &(pci->addr_reg.val));
- v3_chkpt_save_16(ctx, "IO_BASE", &(pci->dev_io_base));
+
+ ctx = v3_chkpt_open_ctx(chkpt,id);
+
+ if (!ctx) {
+ PrintError("Unable to open base context on save\n");
+ goto savefailout;
+ }
+
+ V3_CHKPT_SAVE(ctx, "ADDR_REG", pci->addr_reg.val, savefailout);
+ V3_CHKPT_SAVE(ctx, "IO_BASE", pci->dev_io_base, savefailout);
+
+ v3_chkpt_close_ctx(ctx); ctx=0;
for (i = 0; i < PCI_BUS_COUNT; i++) {
struct pci_bus * bus = &(pci->bus_list[i]);
struct rb_node * node = v3_rb_first(&(bus->devices));
struct pci_device * dev = NULL;
- struct v3_chkpt_ctx * bus_ctx = NULL;
- snprintf(buf, 128, "pci-%d", i);
+ snprintf(buf, 128, "%s-%d", id, i);
- bus_ctx = v3_chkpt_open_ctx(ctx->chkpt, ctx, buf);
+ ctx = v3_chkpt_open_ctx(chkpt, buf);
+
+ if (!ctx) {
+ PrintError("Failed to open context for %s\n", buf);
+ goto savefailout;
+ }
+
+ // nothing actually saved on the bus context... (later expansion)
+
+ v3_chkpt_close_ctx(ctx); ctx=0;
while (node) {
- struct v3_chkpt_ctx * dev_ctx = NULL;
int bar_idx = 0;
dev = rb_entry(node, struct pci_device, dev_tree_node);
- snprintf(buf, 128, "pci-%d.%d-%d", i, dev->dev_num, dev->fn_num);
- dev_ctx = v3_chkpt_open_ctx(bus_ctx->chkpt, bus_ctx, buf);
+ snprintf(buf, 128, "%s-%d.%d-%d", id, i, dev->dev_num, dev->fn_num);
+
+ ctx = v3_chkpt_open_ctx(chkpt, buf);
- v3_chkpt_save(dev_ctx, "CONFIG_SPACE", 256, dev->config_space);
+ if (!ctx) {
+ PrintError("Failed to open context for device\n");
+ goto savefailout;
+ }
+
+ V3_CHKPT_SAVE(ctx, "CONFIG_SPACE", dev->config_space, savefailout);
for (bar_idx = 0; bar_idx < 6; bar_idx++) {
snprintf(buf, 128, "BAR-%d", bar_idx);
- v3_chkpt_save_32(dev_ctx, buf, &(dev->bar[bar_idx].val));
+ V3_CHKPT_SAVE(ctx, buf, dev->bar[bar_idx].val, savefailout);
}
+
+ v3_chkpt_close_ctx(ctx); ctx=0;
node = v3_rb_next(node);
}
}
+// goodout:
return 0;
+
+ savefailout:
+ PrintError("Failed to save PCI\n");
+ if (ctx) { v3_chkpt_close_ctx(ctx); }
+ return -1;
+
}
-static int pci_load(struct v3_chkpt_ctx * ctx, void * private_data) {
+static int pci_load_extended(struct v3_chkpt *chkpt, char *id, void * private_data) {
struct pci_internal * pci = (struct pci_internal *)private_data;
+ struct v3_chkpt_ctx *ctx=0;
char buf[128];
int i = 0;
- v3_chkpt_load_32(ctx, "ADDR_REG", &(pci->addr_reg.val));
- v3_chkpt_load_16(ctx, "IO_BASE", &(pci->dev_io_base));
+ ctx = v3_chkpt_open_ctx(chkpt,id);
+
+ if (!ctx) {
+ PrintError("Unable to open base context on load\n");
+ goto loadfailout;
+ }
+
+ V3_CHKPT_LOAD(ctx, "ADDR_REG", pci->addr_reg.val, loadfailout);
+ V3_CHKPT_LOAD(ctx, "IO_BASE", pci->dev_io_base, loadfailout);
+
+ v3_chkpt_close_ctx(ctx); ctx=0;
for (i = 0; i < PCI_BUS_COUNT; i++) {
struct pci_bus * bus = &(pci->bus_list[i]);
struct rb_node * node = v3_rb_first(&(bus->devices));
struct pci_device * dev = NULL;
- struct v3_chkpt_ctx * bus_ctx = NULL;
snprintf(buf, 128, "pci-%d", i);
- bus_ctx = v3_chkpt_open_ctx(ctx->chkpt, ctx, buf);
+ ctx = v3_chkpt_open_ctx(chkpt, buf);
+
+ if (!ctx) {
+ PrintError("Failed to open context for %s\n", buf);
+ goto loadfailout;
+ }
+
+ // nothing actually saved on the bus context... (later expansion)
+
+ v3_chkpt_close_ctx(ctx); ctx=0;
while (node) {
- struct v3_chkpt_ctx * dev_ctx = NULL;
int bar_idx = 0;
dev = rb_entry(node, struct pci_device, dev_tree_node);
snprintf(buf, 128, "pci-%d.%d-%d", i, dev->dev_num, dev->fn_num);
- dev_ctx = v3_chkpt_open_ctx(bus_ctx->chkpt, bus_ctx, buf);
+
+ ctx = v3_chkpt_open_ctx(chkpt, buf);
- v3_chkpt_load(dev_ctx, "CONFIG_SPACE", 256, dev->config_space);
+ if (!ctx) {
+ PrintError("Failed to open context for device\n");
+ goto loadfailout;
+ }
+
+ V3_CHKPT_LOAD(ctx, "CONFIG_SPACE", dev->config_space, loadfailout);
for (bar_idx = 0; bar_idx < 6; bar_idx++) {
snprintf(buf, 128, "BAR-%d", bar_idx);
- v3_chkpt_load_32(dev_ctx, buf, &(dev->bar[bar_idx].val));
+ V3_CHKPT_LOAD(ctx, buf, dev->bar[bar_idx].val, loadfailout);
}
+ v3_chkpt_close_ctx(ctx); ctx=0;
+
node = v3_rb_next(node);
}
}
-
+// goodout:
return 0;
+
+ loadfailout:
+ PrintError("Failed to load PCI\n");
+ if (ctx) { v3_chkpt_close_ctx(ctx); }
+ return -1;
+
}
static struct v3_device_ops dev_ops = {
.free = (int (*)(void *))pci_free,
#ifdef V3_CONFIG_CHECKPOINT
- .save = pci_save,
- .load = pci_load
+ .save_extended = pci_save_extended,
+ .load_extended = pci_load_extended
#endif
};