| 436 | pub const TIMER_CHOICE_ADDR: u64 = IRQ_NUMBER_ADDR + 4; |
| 437 | |
| 438 | pub unsafe extern "C" fn get_next_timer_choice(ctx: *mut c_void, choice: *mut u8) -> bool { |
| 439 | let ctx = &mut *ctx.cast::<Context>(); |
| 440 | let vm = unsafe { &mut *ctx.vm }; |
| 441 | |
| 442 | let mut buf = [0]; |
| 443 | if vm |
| 444 | .cpu |
| 445 | .mem |
| 446 | .get_io_memory_mut(ctx.io_handle.unwrap()) |
| 447 | .read(TIMER_CHOICE_ADDR, &mut buf) |
| 448 | .is_err() |
| 449 | { |
| 450 | vm.cpu.exception = Exception::new(ExceptionCode::ReadWatch, TIMER_CHOICE_ADDR); |
| 451 | return false; |
| 452 | } |
| 453 | *choice = buf[0]; |
| 454 | true |
| 455 | } |