Skip to content

Commit

Permalink
vcpu_enter and vcpu_exit now flushes vm's output consoles.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvraj1803 committed Nov 2, 2023
1 parent 24a12e8 commit 57e6cbf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/vcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

extern struct vm* vmlist[CONFIG_MAX_VMs];
extern struct vm* current;
extern uint8_t vm_connected_to_uart;

static uint64_t read_aux_mu(struct vm* _vm, uint64_t addr){
if((addr >= AUX_MU_IO_REG && addr <= AUX_MU_BAUD_REG) && ((_vm->cpu.aux_regs.aux_enables & 1) == 0)) return 0; // Invalid AUX MU address being read or AUX MU not enabled.
Expand Down Expand Up @@ -351,6 +352,10 @@ void vcpu_exit(){
current->state = VM_WAITING;
vmlist[VMID_SHELL]->state = VM_RUNNING;

if(current->vmid == vm_connected_to_uart){
console_flush(&current->output_console);
}

// save when vm was last active physically.
current->cpu.system_timer_regs.last_recorded_physical_timer_count = get_phys_time();
}
Expand All @@ -359,6 +364,10 @@ void vcpu_enter(){
vmlist[VMID_SHELL]->state = VM_WAITING;
current->state = VM_RUNNING;

if(current->vmid == vm_connected_to_uart){
console_flush(&current->output_console);
}

// once vm is back alive, update for how long it was dead.
uint64_t current_time = get_phys_time();
uint64_t time_inactive = current_time - current->cpu.system_timer_regs.last_recorded_physical_timer_count;
Expand Down

0 comments on commit 57e6cbf

Please sign in to comment.