Wrapper which runs a closure with a specified page table Ensures that the original page table is restored after the closure finishes.
(page_table_physaddr: u64, func: F)
| 424 | /// Ensures that the original page table is restored after the |
| 425 | /// closure finishes. |
| 426 | fn with_pagetable<F, R>(page_table_physaddr: u64, func: F) -> R where |
| 427 | F: FnOnce() -> R { |
| 428 | // Store the page table and switch back before returning |
| 429 | let original_page_table = memory::active_pagetable_physaddr(); |
| 430 | |
| 431 | // Switch to the new user page table |
| 432 | // |
| 433 | // Note: We don't need to turn off interrupts because |
| 434 | // schedule_next() saves the page table for each thread. This |
| 435 | // thread temporarily has a different page table to the other |
| 436 | // threads. |
| 437 | memory::switch_to_pagetable(page_table_physaddr); |
| 438 | |
| 439 | let result = func(); |
| 440 | |
| 441 | // Switch back to original page table |
| 442 | memory::switch_to_pagetable(original_page_table); |
| 443 | |
| 444 | result |
| 445 | } |
| 446 | |
| 447 | pub struct Params { |
| 448 | pub handles: Vec<Arc<RwLock<Rendezvous>>>, |
no test coverage detected