void Obj_space_virt<SPACE>::caps_free() { Mem_space *ms = SPACE::mem_space(this); if (EXPECT_FALSE(!ms || !ms->dir())) return; Kmem_alloc *a = Kmem_alloc::allocator(); for (Cap_index i = Cap_index(0); i < obj_map_max_address(); i += Cap_diff(Obj::Caps_per_page)) { Entry *c = get_cap(i); if (!c) continue; Address cp = Address(ms->virt_to_phys(Address(c))); assert_kdb (cp != ~0UL); void *cv = (void*)Mem_layout::phys_to_pmem(cp); Obj::remove_cap_page_dbg_info(cv); a->q_unaligned_free(SPACE::ram_quota(this), Config::PAGE_SIZE, cv); } ms->dir()->destroy(Virt_addr(Mem_layout::Caps_start), Virt_addr(Mem_layout::Caps_end-1), Pdir::Super_level, Pdir::Depth, Kmem_alloc::q_allocator(SPACE::ram_quota(this))); }
void Generic_obj_space<SPACE>::caps_free() { Mem_space *ms = mem_space(); if (EXPECT_FALSE(!ms || !ms->dir())) return; Mapped_allocator *a = Mapped_allocator::allocator(); for (unsigned long i = 0; i < map_max_address().value(); i += Caps_per_page) { Entry *c = get_cap(i); if (!c) continue; Address cp = Address(ms->virt_to_phys(Address(c))); assert_kdb (cp != ~0UL); void *cv = (void*)Mem_layout::phys_to_pmem(cp); remove_dbg_info(cv); a->q_unaligned_free(ram_quota(), Config::PAGE_SIZE, cv); } #if defined (CONFIG_ARM) ms->dir()->free_page_tables((void*)Mem_layout::Caps_start, (void*)Mem_layout::Caps_end); #else ms->dir()->Pdir::alloc_cast<Mem_space_q_alloc>() ->destroy(Virt_addr(Mem_layout::Caps_start), Virt_addr(Mem_layout::Caps_end), Pdir::Depth - 1, Mem_space_q_alloc(ram_quota(), Mapped_allocator::allocator())); #endif }
typename Obj_space_virt<SPACE>::Entry * Obj_space_virt<SPACE>::get_cap(Cap_index index) { Mem_space *ms = SPACE::mem_space(this); Address phys = Address(ms->virt_to_phys((Address)cap_virt(index))); if (EXPECT_FALSE(phys == ~0UL)) return 0; return reinterpret_cast<Entry*>(Mem_layout::phys_to_pmem(phys)); }
typename Generic_obj_space<SPACE>::Entry * Generic_obj_space<SPACE>::alien_lookup(Address index) { Mem_space *ms = mem_space(); Address phys = Address(ms->virt_to_phys((Address)cap_virt(index))); if (EXPECT_FALSE(phys == ~0UL)) return 0; return reinterpret_cast<Entry*>(Mem_layout::phys_to_pmem(phys)); }
static void tbuf(Thread *t, Entry_frame *r) { Mem_space *s = t->mem_space(); Address ip = r->ip(); Address_type user; Unsigned8 *str; int len; char c; Jdb_entry_frame *entry_frame = reinterpret_cast<Jdb_entry_frame*>((char *)r - 8); /* Why the -8? The Jdb_entry_frame has two more members in the beginning * (see Trap_state_regs) so we're compensating for this with the -8. * Alex: Proper fix? */ user = entry_frame->from_user(); switch (entry_frame->param()) { case 0: // fiasco_tbuf_get_status() { Jdb_status_page_frame *regs = reinterpret_cast<Jdb_status_page_frame*>(entry_frame); regs->set(Mem_layout::Tbuf_ustatus_page); } break; case 1: // fiasco_tbuf_log() { Jdb_log_frame *regs = reinterpret_cast<Jdb_log_frame*>(entry_frame); Tb_entry_ke *tb = static_cast<Tb_entry_ke*>(Jdb_tbuf::new_entry()); str = regs->str(); tb->set(t, ip-4); for (len=0; (c = s->peek(str++, user)); len++) tb->set_buf(len, c); tb->term_buf(len); regs->set_tb_entry(tb); Jdb_tbuf::commit_entry(); } break; case 2: // fiasco_tbuf_clear() Jdb_tbuf::clear_tbuf(); break; case 3: // fiasco_tbuf_dump() return; // => Jdb case 4: // fiasco_tbuf_log_3val() { // interrupts are disabled in handle_slow_trap() Jdb_log_3val_frame *regs = reinterpret_cast<Jdb_log_3val_frame*>(entry_frame); Tb_entry_ke_reg *tb = static_cast<Tb_entry_ke_reg*>(Jdb_tbuf::new_entry()); str = regs->str(); tb->set(t, ip-4, regs->val1(), regs->val2(), regs->val3()); for (len=0; (c = s->peek(str++, user)); len++) tb->set_buf(len, c); tb->term_buf(len); regs->set_tb_entry(tb); Jdb_tbuf::commit_entry(); } break; case 5: // fiasco_tbuf_get_status_phys() { Jdb_status_page_frame *regs = reinterpret_cast<Jdb_status_page_frame*>(entry_frame); regs->set(s->virt_to_phys(Mem_layout::Tbuf_ustatus_page)); } break; case 6: // fiasco_timer_disable printf("JDB: no more timer disable\n"); //Timer::disable(); break; case 7: // fiasco_timer_enable printf("JDB: no more timer enable\n"); //Timer::enable(); break; case 8: // fiasco_tbuf_log_binary() // interrupts are disabled in handle_slow_trap() Jdb_log_frame *regs = reinterpret_cast<Jdb_log_frame*>(entry_frame); Tb_entry_ke_bin *tb = static_cast<Tb_entry_ke_bin*>(Jdb_tbuf::new_entry()); str = regs->str(); tb->set(t, ip-4); for (len=0; len < Tb_entry_ke_bin::SIZE; len++) tb->set_buf(len, s->peek(str++, user)); regs->set_tb_entry(tb); Jdb_tbuf::commit_entry(); break; } }