/DragonOS/kernel/src/mm/ |
H A D | c_adapter.rs | 38 let vaddr = VirtAddr::new(ptr as usize); in do_kmalloc() localVariable 40 if unlikely(guard.contains_key(&vaddr)) { in do_kmalloc() 43 drop(Vec::from_raw_parts(vaddr.data() as *mut u8, len, cap)); in do_kmalloc() 47 vaddr in do_kmalloc() 51 guard.insert(vaddr, (vaddr, len, cap)); in do_kmalloc() 52 return vaddr.data(); in do_kmalloc() 59 pub unsafe extern "C" fn kfree(vaddr: usize) -> usize { in kfree() 60 let vaddr = VirtAddr::new(vaddr); in kfree() localVariable 62 let p = guard.remove(&vaddr); in kfree() 66 error!("kfree: vaddr {:?} not found in C Allocation Map", vaddr); in kfree() [all …]
|
H A D | no_init.rs | 75 let vaddr = VirtAddr::new(p); in allocate_page() localVariable 76 assert!(vaddr.check_aligned(MMArch::PAGE_SIZE)); in allocate_page() 77 return Some(vaddr); in allocate_page() 112 let vaddr = EARLY_IOREMAP_PAGES.lock_irqsave().allocate_page()?; in allocate() localVariable 113 let paddr = MMA::virt_2_phys(vaddr)?; in allocate() 121 let vaddr = MMA::phys_2_virt(address); in free() localVariable 122 if let Some(vaddr) = vaddr { in free() 123 EARLY_IOREMAP_PAGES.lock_irqsave().free_page(vaddr); in free() 143 pub unsafe fn pseudo_map_phys(vaddr: VirtAddr, paddr: PhysAddr, count: PageFrameCount) { in pseudo_map_phys() 146 pseudo_map_phys_with_flags(vaddr, paddr, count, flags); in pseudo_map_phys() [all …]
|
H A D | mmio_buddy.rs | 105 fn create_region(&self, vaddr: VirtAddr) -> MmioBuddyAddrRegion { in create_region() 108 let region: MmioBuddyAddrRegion = MmioBuddyAddrRegion::new(vaddr); in create_region() 125 fn give_back_block(&self, vaddr: VirtAddr, exp: u32) -> Result<i32, SystemError> { in give_back_block() 127 if (vaddr.data() & ((1 << exp) - 1)) != 0 { in give_back_block() 130 let region: MmioBuddyAddrRegion = self.create_region(vaddr); in give_back_block() 151 let vaddr = self.calculate_block_vaddr(region.vaddr, exp - 1); in split_block() localVariable 152 let new_region: MmioBuddyAddrRegion = self.create_region(vaddr); in split_block() 334 fn calculate_block_vaddr(&self, vaddr: VirtAddr, exp: u32) -> VirtAddr { in calculate_block_vaddr() 335 return VirtAddr::new(vaddr.data() ^ (1 << exp as usize)); in calculate_block_vaddr() 352 vaddr: VirtAddr, in pop_buddy_block() [all …]
|
H A D | early_ioremap.rs | 112 let vaddr = Self::idx_to_virt(start_slot); in map() localVariable 118 unsafe { pseudo_map_phys_ro(vaddr, phys, page_count) } in map() 120 unsafe { pseudo_map_phys(vaddr, phys, page_count) } in map() 137 return Ok((vaddr, map_size)); in map() 178 let vaddr = Self::idx_to_virt(idx); in unmap() localVariable 182 unsafe { pseudo_unmap_phys(vaddr, count) }; in unmap()
|
H A D | kernel_mapper.rs | 104 mut vaddr: VirtAddr, in map_phys_with_size() 117 let flusher = self.mapper.map_phys(vaddr, paddr, flags).unwrap(); in map_phys_with_size() 123 vaddr += MMArch::PAGE_SIZE; in map_phys_with_size()
|
H A D | mmio.h | 5 extern int rs_mmio_release(uint64_t vaddr, uint64_t length);
|
/DragonOS/kernel/src/debug/ |
H A D | kallsyms.c | 20 #define symbol_to_write(vaddr, tv, etv) \ argument 21 ((vaddr < tv || vaddr > etv) ? 0 : 1) 29 uint64_t vaddr; member 61 int retval = sscanf(str, "%llx %c %512c", &entry->vaddr, &entry->type, symbol_name); in read_symbol() 119 text_vaddr = symbol_table[i].vaddr; in read_map() 121 etext_vaddr = symbol_table[i].vaddr; in read_map() 146 if (!symbol_to_write(symbol_table[i].vaddr, text_vaddr, etext_vaddr)) in generate_result() 149 if (symbol_table[i].vaddr == last_vaddr) in generate_result() 153 printf("\t.quad\t%#llx\n", symbol_table[i].vaddr); in generate_result() 156 last_vaddr = symbol_table[i].vaddr; in generate_result() [all …]
|
/DragonOS/kernel/src/driver/firmware/efi/ |
H A D | memmap.rs | 19 pub(super) vaddr: Option<VirtAddr>, field 38 vaddr: None, 49 return self.vaddr.map(|v| v + self.size); in map_end_vaddr() 79 if unlikely(self.inner.vaddr.unwrap_or(VirtAddr::new(0)).is_null()) { in next() 83 let vaddr = self.inner.vaddr? + self.offset; in next() localVariable 85 let res = unsafe { *(vaddr.data() as *const Self::Item) }; in next() 117 let mut vaddr = EarlyIoRemap::map( in do_efi_memmap_init() localVariable 122 .map(|(vaddr, _)| vaddr)?; in do_efi_memmap_init() 124 vaddr += offset; in do_efi_memmap_init() 126 inner_guard.mmap.vaddr = Some(vaddr); in do_efi_memmap_init() [all …]
|
H A D | tables.rs | 108 let vaddr = EarlyIoRemap::map_not_aligned(prev_paddr, MMArch::PAGE_SIZE, true) in parse_config_tables() localVariable 118 (vaddr.data() as *const LinuxEFIMemReserveTable) in parse_config_tables() 133 EarlyIoRemap::unmap(vaddr).unwrap(); in parse_config_tables() 139 (vaddr.data() as *const LinuxEFIMemReserveTable).add(1) in parse_config_tables() 150 EarlyIoRemap::unmap(vaddr).unwrap(); in parse_config_tables() 156 EarlyIoRemap::unmap(vaddr).unwrap(); in parse_config_tables() 403 let vaddr = EarlyIoRemap::map_not_aligned(table_paddr, table_map_size, true); in match_table() localVariable 405 if let Err(e) = vaddr { in match_table() 409 Some(vaddr.unwrap()) in match_table() 416 if let Some(vaddr) = vendor_table_vaddr { in match_table() [all …]
|
/DragonOS/kernel/src/arch/x86_64/process/ |
H A D | table.rs | 63 unsafe fn set_tss_descriptor(index: u16, vaddr: VirtAddr) { in set_tss_descriptor() 69 let vaddr = vaddr.data() as u64; in set_tss_descriptor() localVariable 71 | ((vaddr & 0xffff) << 16) in set_tss_descriptor() 72 | (((vaddr >> 16) & 0xff) << 32) in set_tss_descriptor() 74 | (((vaddr >> 24) & 0xff) << 56); in set_tss_descriptor() 75 gdt[index as usize + 1] = (vaddr >> 32) & 0xffffffff; in set_tss_descriptor()
|
/DragonOS/docs/kernel/memory_management/ |
H A D | mmio.md | 93 │ │ │ list │ │ │ vaddr │ │ vaddr │ │ 149 vaddr: u64, 162 …; `MmioFreeRegionList`中的元素类型为`MmioBuddyAddrRegion`结构体,`MmioBuddyAddrRegion`记录了内存块的起始地址(vaddr)。 170 | __create_region(&self, vaddr) | 将虚拟地址传入,创建新的内存块地址结构体 … 171 | __give_back_block(&self, vaddr, exp) | 将地址为vaddr,幂为exp的内存块归还给buddy … 176 | __buddy_block_vaddr(&self, vaddr, exp) | 根据地址和内存块大小,计算伙伴块虚拟内存的地址 … 177 | __pop_buddy_block( &self, vaddr,exp,list_guard) | 寻找并弹出指定内存块的伙伴块 … 189 | mmio_release(vaddr, length) | 取消地址为vaddr,大小为length的mmio的映射并将其归还到buddy中 |
|
/DragonOS/kernel/src/driver/virtio/ |
H A D | virtio_impl.rs | 56 vaddr: NonNull<u8>, in dma_dealloc() 66 let vaddr = VirtAddr::new(vaddr.as_ptr() as usize); in dma_dealloc() localVariable 70 .remap(vaddr, kernel_page_flags(vaddr)) in dma_dealloc() 96 let vaddr = VirtAddr::new(buffer.as_ptr() as *mut u8 as usize); in share() localVariable 99 return MMArch::virt_2_phys(vaddr).unwrap().data(); in share()
|
H A D | transport_pci.rs | 455 vaddr: VirtAddr, 494 Self::Misaligned { vaddr, alignment } => write!( in fmt() 497 vaddr, alignment in fmt() 532 let vaddr = (bar_info in get_bar_region() localVariable 536 if vaddr.data() % align_of::<T>() != 0 { in get_bar_region() 538 vaddr, in get_bar_region() 542 let vaddr = NonNull::new(vaddr.data() as *mut u8).unwrap(); in get_bar_region() localVariable 543 Ok(vaddr.cast()) in get_bar_region()
|
H A D | transport_mmio.rs | 53 let vaddr = mmio_guard.vaddr() + page_offset; in new() localVariable 54 let header = NonNull::new(vaddr.data() as *mut VirtIOHeader).unwrap(); in new()
|
/DragonOS/kernel/src/driver/net/ |
H A D | dma.rs | 47 pub unsafe fn dma_dealloc(paddr: usize, vaddr: NonNull<u8>, pages: usize) -> i32 { in dma_dealloc() 55 let vaddr = VirtAddr::new(vaddr.as_ptr() as usize); in dma_dealloc() localVariable 59 .remap(vaddr, kernel_page_flags(vaddr)) in dma_dealloc()
|
/DragonOS/kernel/src/arch/x86_64/include/asm/ |
H A D | asm.h | 333 static __always_inline void __write8b(uint64_t vaddr, uint64_t value) in __write8b() argument 335 asm volatile("movq %%rdx, 0(%%rax)" ::"a"(vaddr), "d"(value) in __write8b() 346 static __always_inline void __write4b(uint64_t vaddr, uint32_t value) in __write4b() argument 348 asm volatile("movl %%edx, 0(%%rax)" ::"a"(vaddr), "d"(value) in __write4b() 359 static __always_inline uint64_t __read8b(uint64_t vaddr) in __read8b() argument 364 : "a"(vaddr) in __read8b() 376 static __always_inline uint32_t __read4b(uint64_t vaddr) in __read4b() argument 381 : "a"(vaddr) in __read4b()
|
/DragonOS/kernel/src/arch/riscv64/driver/ |
H A D | of.rs | 34 let vaddr = mmio_guard.vaddr() + offset; in map_fdt() localVariable 37 bp_guard.arch.fdt_vaddr.replace(vaddr); in map_fdt()
|
/DragonOS/kernel/src/arch/riscv64/mm/ |
H A D | init.rs | 110 let vaddr = unsafe { MMArch::phys_2_virt(paddr) }.unwrap(); in riscv_mm_init() localVariable 111 let flags = kernel_page_flags::<MMArch>(vaddr).set_execute(true); in riscv_mm_init() 114 .map_phys(vaddr, paddr, flags) in riscv_mm_init() 189 let vaddr = VirtAddr::new(base.data() + i * MMArch::PAGE_SIZE); in remap_at_low_address() localVariable 190 let flags = kernel_page_flags::<MMArch>(vaddr).set_execute(true); in remap_at_low_address() 193 .map_phys(vaddr, paddr, flags) in remap_at_low_address() 210 let vaddr = VirtAddr::new(base.data() + i * MMArch::PAGE_SIZE); in unmap_at_low_address() localVariable 214 .unmap_phys(vaddr, true) in unmap_at_low_address()
|
/DragonOS/kernel/src/ipc/ |
H A D | syscall.rs | 308 pub fn shmat(id: ShmId, vaddr: VirtAddr, shmflg: ShmFlags) -> Result<usize, SystemError> { in shmat() 317 let r = match vaddr.data() { in shmat() 323 .find_free(vaddr, size) in shmat() 352 .contains(vaddr) in shmat() 354 if vma.lock_irqsave().region().start() != vaddr { in shmat() 359 let _ = UserBufferReader::new(vaddr.data() as *const u8, size, true)?; in shmat() 365 .translate(vaddr) in shmat() 375 let mut virt = VirtPageFrame::new(vaddr); in shmat() 400 vaddr.data() in shmat() 420 pub fn shmdt(vaddr: VirtAddr) -> Result<usize, SystemError> { in shmdt() [all …]
|
/DragonOS/kernel/src/arch/riscv64/interrupt/ |
H A D | handle.rs | 151 let vaddr = trap_frame.badaddr; in do_trap_insn_page_fault() localVariable 156 vaddr, cause, epc in do_trap_insn_page_fault() 165 let vaddr = trap_frame.badaddr; in do_trap_load_page_fault() localVariable 170 vaddr, cause in do_trap_load_page_fault()
|
/DragonOS/kernel/src/arch/x86_64/smp/ |
H A D | mod.rs | 41 vaddr: usize, field 49 let vaddr = if let Some(t) = smp_cpu_manager() in smp_ap_start() localVariable 61 let v = ApStartStackInfo { vaddr }; in smp_ap_start() 72 off_rsp = const(offset_of!(ApStartStackInfo, vaddr)), in smp_init_switch_stack() 270 let vaddr = unsafe { in arch_init() localVariable 273 let ptr = vaddr.data() as *mut u64; in arch_init()
|
/DragonOS/kernel/src/libs/lib_ui/ |
H A D | screen_manager.rs | 125 vaddr: VirtAddr, in new_device_buffer() 135 buf: ScmBuffer::DeviceBuffer(vaddr), in new_device_buffer() 167 ScmBuffer::DeviceBuffer(vaddr) => { in copy_from_nonoverlapping() 170 unsafe { core::slice::from_raw_parts_mut(vaddr.data() as *mut u8, len) }; in copy_from_nonoverlapping() 172 ScmBuffer::DeviceBuffer(vaddr) => { in copy_from_nonoverlapping() 174 unsafe { core::slice::from_raw_parts(vaddr.data() as *const u8, len) }; in copy_from_nonoverlapping() 187 ScmBuffer::DeviceBuffer(vaddr) => { in copy_from_nonoverlapping() 190 core::slice::from_raw_parts(vaddr.data() as *const u8, len) in copy_from_nonoverlapping()
|
/DragonOS/kernel/src/driver/video/ |
H A D | mod.rs | 91 let buf_vaddr = mmio_guard.vaddr(); in init_frame_buffer() 97 if let ScmBuffer::DeviceBuffer(vaddr) = &mut (frame_buffer_info_guard).buf { in init_frame_buffer() 98 *vaddr = buf_vaddr; in init_frame_buffer() 271 if let ScmBuffer::DeviceBuffer(vaddr) = manager.device_buffer().buf { in run() 272 let p: *mut u8 = vaddr.as_ptr(); in run()
|
/DragonOS/kernel/crates/klog_types/src/ |
H A D | lib.rs | 130 pub vaddr: Option<usize>, field 135 pub fn new(layout: core::alloc::Layout, vaddr: Option<usize>, paddr: Option<usize>) -> Self { in new() 138 vaddr, in new() 150 &format_args!("{:#x}", *self.vaddr.as_ref().unwrap_or(&0)), in fmt()
|
/DragonOS/kernel/src/arch/x86_64/mm/ |
H A D | mod.rs | 299 if let Some(vaddr) = phys.data().checked_add(Self::PHYS_OFFSET) { in phys_2_virt() 300 return Some(VirtAddr::new(vaddr)); in phys_2_virt() 505 let vaddr = unsafe { MMArch::phys_2_virt(paddr) }.unwrap(); in allocator_init() localVariable 506 let flags = kernel_page_flags::<MMArch>(vaddr); in allocator_init() 509 .map_phys(vaddr, paddr, flags) in allocator_init() 599 let vaddr = unsafe { MMArch::phys_2_virt(paddr).unwrap() }; in test_buddy() localVariable 602 vaddr.data() as *mut u8, in test_buddy() 714 let vaddr = VirtAddr::new(i * MMArch::PAGE_SIZE); in remap_at_low_address() localVariable 715 let flags = kernel_page_flags::<MMArch>(vaddr); in remap_at_low_address() 718 .map_phys(vaddr, paddr, flags) in remap_at_low_address() [all …]
|