X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fcga.c;h=0b6b4512e3d2c8838b1d2ad2beddc91598a22261;hb=d0652a946b5d7dcee13c9d445b103f37284059aa;hp=00816095dad23e49629feed59b0fb773d0fa4495;hpb=5d1bbcc86de011e3f0d115b6f10fd8645cdf855e;p=palacios.git diff --git a/palacios/src/devices/cga.c b/palacios/src/devices/cga.c index 0081609..0b6b451 100644 --- a/palacios/src/devices/cga.c +++ b/palacios/src/devices/cga.c @@ -612,8 +612,10 @@ static int inp_status1_read(struct guest_info * core, uint16_t port, void * dest /* next write to attrc selects the index rather than data */ video_state->attrc_index_flipflop = 0; + memset(dest, 0x0, length); - return notimpl_port_read(priv_data, __FUNCTION__, port, dest, length); + handle_port_read(priv_data, __FUNCTION__, port, dest, length, 1); + return length; } static int feat_ctrl_read(struct guest_info * core, uint16_t port, void * dest, uint_t length, void * priv_data) { @@ -1116,6 +1118,8 @@ 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]); @@ -1146,12 +1150,18 @@ static int cga_save(struct v3_chkpt_ctx * ctx, void * private_data) { 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)); + return 0; } 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]); @@ -1182,6 +1192,10 @@ static int cga_load(struct v3_chkpt_ctx * ctx, void * private_data) { 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; } @@ -1206,6 +1220,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); @@ -1219,7 +1239,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));