message: paging: Make map, map_heap properly generic
diff: @@ -4,7 +4,7 @@ use core::ptr;
  use x86_64::instructions::tlb;
  use x86_64::structures::paging::mapper::UnmapError;
  use x86_64::structures::paging::{
  - Mapper, Page, PageTableIndex, PhysFrame, RecursivePageTable, Size1GiB, Size2MiB, Size4KiB,
  + Mapper, Page, PageTableIndex, PhysFrame, RecursivePageTable, Size2MiB, Size4KiB,
  };
  #[cfg(feature = "smp")]
  @@ -124,12 +124,15 @@ pub extern "C" fn virt_to_phys(virtual_address: VirtAddr) -> PhysAddr {
  /// * `physical_address` - First physical address to map these pages to
  /// * `flags` - Flags from PageTableEntryFlags to set for the page table entry (e.g. WRITABLE or NO_EXECUTE).
  /// The PRESENT flags is set automatically.
  -pub fn map<S: PageSize>(
  +pub fn map<S>(
  virtual_address: VirtAddr,
  physical_address: PhysAddr,
  count: usize,
  flags: PageTableEntryFlags,
  -) {
  +) where
  + S: PageSize + Debug,
  + RecursivePageTable<'static>: Mapper<S>,
  +{
  let pages = {
  let start = Page::<S>::containing_address(x86_64::VirtAddr::new(virtual_address.0));
  let end = start + count as u64;
  @@ -147,10 +150,6 @@ pub fn map<S: PageSize>(
  trace!("Mapping {pages:?} to {frames:?} with {flags:?}");
  for (page, frame) in pages.zip(frames) {
  - match S::SIZE {
  - Size4KiB::SIZE => {
  - let page = Page::<Size4KiB>::from_start_address(page.start_address()).unwrap();
  - let frame = PhysFrame::from_start_address(frame.start_address()).unwrap();
  unsafe {
  // TODO: Require explicit unmaps
  if let Ok((_frame, flush)) = recursive_page_table().unmap(page) {
  @@ -162,35 +161,16 @@ pub fn map<S: PageSize>(
  .flush();
  }
  }
  - Size2MiB::SIZE => {
  - let page = Page::<Size2MiB>::from_start_address(page.start_address()).unwrap();
  - let frame = PhysFrame::from_start_address(frame.start_address()).unwrap();
  - unsafe {
  - recursive_page_table()
  - .map_to(page, frame, flags, &mut physicalmem::FrameAlloc)
  - .unwrap()
  - .flush();
  - }
  - }
  - Size1GiB::SIZE => {
  - let page = Page::<Size1GiB>::from_start_address(page.start_address()).unwrap();
  - let frame = PhysFrame::from_start_address(frame.start_address()).unwrap();
  - unsafe {
  - recursive_page_table()
  - .map_to(page, frame, flags, &mut physicalmem::FrameAlloc)
  - .unwrap()
  - .flush();
  - }
  - }
  - _ => unreachable!(),
  - }
  - }
  #[cfg(feature = "smp")]
  apic::ipi_tlb_flush();
  }
  -pub fn map_heap<S: PageSize>(virt_addr: VirtAddr, count: usize) {
  +pub fn map_heap<S: PageSize>(virt_addr: VirtAddr, count: usize)
  +where
  + S: PageSize + Debug,
  + RecursivePageTable<'static>: Mapper<S>,
  +{
  let flags = {
  let mut flags = PageTableEntryFlags::empty();
  flags.normal().writable().execute_disable();
  