All pastes #22126 Raw Edit

Anonymous

public text v1 · immutable
#22126 ·published 2005-09-05 11:11 UTC
rendered paste body
int simple_mmap (struct file *filp, struct vm_area_struct *vma)
{
                                                                                                                             
#if 1
        unsigned long physical = PHYSICAL_ADDRESS    ;
                                                                                                                             
        /* Page should already be allocated by now, represented by vma->vm_start)  */
        printk (KERN_WARNING "end - start => %u\n", vma->vm_end - vma->vm_start) ;
                                                                                                                             
        vma->vm_flags = vma->vm_flags | VM_IO | VM_RESERVED ; /* Memory mapped I/O and DONT Swap out */
        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot) ; /* Dont Swap / Cache */
                                                                                                                             
        return io_remap_page_range (vma, vma->vm_start, physical,
                                   vma->vm_end - vma->vm_start,
                                   vma->vm_page_prot);
#else
    short * ptr = ioremap (PHYSICAL_ADDRESS, 1024) ;
        short * base_reg ;
        char v_rom_mac [6] ;
                                                                                                                             
        printk (KERN_WARNING "ptr => %u\n", ptr) ;
                                                                                                                             
        base_ptr = ptr ;
                                                                                                                             
        base_reg = (short *) ((char *) ptr + 14) ;
                                                                                                                             
        *base_reg = 1 ;
        get_rom_mac (v_rom_mac) ;
#endif
}