Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Devices updated for revised checkpoint interface
[palacios.git] / palacios / src / devices / cga.c
index d99275e..60baa54 100644 (file)
@@ -1118,85 +1118,99 @@ static int cga_free(struct video_internal * video_state) {
 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
@@ -1220,6 +1234,12 @@ static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     PrintDebug("video: init_device\n");
 
     video_state = (struct video_internal *)V3_Malloc(sizeof(struct video_internal));
+
+    if (!video_state) {
+       PrintError("Cannot allocate space for CGA state\n");
+       return -1;
+    }
+
     memset(video_state, 0, sizeof(struct video_internal));
 
     struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, video_state);
@@ -1233,7 +1253,15 @@ static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     video_state->dev = dev;
 
     video_state->framebuf_pa = (addr_t)V3_AllocPages(FRAMEBUF_SIZE / 4096);
+
+    if (!video_state->framebuf_pa) { 
+       PrintError("Cannot allocate frame buffer\n");
+       V3_Free(video_state);
+       return -1;
+    }
+
     video_state->framebuf = V3_VAddr((void *)(video_state->framebuf_pa));
+
     memset(video_state->framebuf, 0, FRAMEBUF_SIZE);
 
     PrintDebug("PA of array: %p\n", (void *)(video_state->framebuf_pa));