Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1c01e6c in mainline


Ignore:
Timestamp:
2011-11-26T16:37:37Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
056ddc30
Parents:
9aed144
Message:

Replace hw_map() implementations with one generic.
Currently the kernel is broken because of missing page allocator.

Location:
kernel
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/abs32le/src/mm/page.c

    r9aed144 r1c01e6c  
    5656}
    5757
    58 
    59 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    60 {
    61         return physaddr;
    62 }
    63 
    6458void page_fault(unsigned int n __attribute__((unused)), istate_t *istate)
    6559{
  • kernel/arch/amd64/src/mm/page.c

    r9aed144 r1c01e6c  
    9898}
    9999
    100 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    101 {
    102         if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
    103                 panic("Unable to map physical memory %p (%zu bytes).",
    104                     (void *) physaddr, size);
    105        
    106         uintptr_t virtaddr = PA2KA(last_frame);
    107         pfn_t i;
    108        
    109         page_table_lock(AS_KERNEL, true);
    110        
    111         for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
    112                 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE);
    113        
    114         page_table_unlock(AS_KERNEL, true);
    115        
    116         last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
    117        
    118         return virtaddr;
    119 }
    120 
    121100/** @}
    122101 */
  • kernel/arch/arm32/src/mm/page.c

    r9aed144 r1c01e6c  
    8282}
    8383
    84 /** Maps device into the kernel space.
    85  *
    86  * Maps physical address of device into kernel virtual address space (so it can
    87  * be accessed only by kernel through virtual address).
    88  *
    89  * @param physaddr Physical address where device is connected.
    90  * @param size Length of area where device is present.
    91  *
    92  * @return Virtual address where device will be accessible.
    93  */
    94 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    95 {
    96         if (last_frame + ALIGN_UP(size, PAGE_SIZE) >
    97             KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) {
    98                 panic("Unable to map physical memory %p (%d bytes).",
    99                     (void *) physaddr, size);
    100         }
    101        
    102         uintptr_t virtaddr = PA2KA(last_frame);
    103         pfn_t i;
    104 
    105         page_table_lock(AS_KERNEL, true);
    106         for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) {
    107                 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i),
    108                     physaddr + PFN2ADDR(i),
    109                     PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL);
    110         }
    111         page_table_unlock(AS_KERNEL, true);
    112        
    113         last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
    114         return virtaddr;
    115 }
    116 
    11784/** @}
    11885 */
  • kernel/arch/ia32/src/mm/page.c

    r9aed144 r1c01e6c  
    8585}
    8686
    87 
    88 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    89 {
    90         if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
    91                 panic("Unable to map physical memory %p (%zu bytes).",
    92                     (void *) physaddr, size);
    93        
    94         uintptr_t virtaddr = PA2KA(last_frame);
    95         pfn_t i;
    96         page_table_lock(AS_KERNEL, true);
    97         for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) {
    98                 uintptr_t addr = PFN2ADDR(i);
    99                 page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr, PAGE_NOT_CACHEABLE | PAGE_WRITE);
    100         }
    101         page_table_unlock(AS_KERNEL, true);
    102        
    103         last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
    104        
    105         return virtaddr;
    106 }
    107 
    10887void page_fault(unsigned int n __attribute__((unused)), istate_t *istate)
    10988{
  • kernel/arch/ia64/src/mm/page.c

    r9aed144 r1c01e6c  
    255255}
    256256
    257 uintptr_t hw_map(uintptr_t physaddr, size_t size __attribute__ ((unused)))
    258 {
    259         /* THIS is a dirty hack. */
    260         return (uintptr_t)((uint64_t)(PA2KA(physaddr)) + VIO_OFFSET);
    261 }
    262 
    263257/** @}
    264258 */
  • kernel/arch/mips32/src/mm/page.c

    r9aed144 r1c01e6c  
    4343}
    4444
    45 /** Map device into kernel space
    46  * - on mips, all devices are already mapped into kernel space,
    47  *   translate the physical address to uncached area
    48  */
    49 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    50 {
    51         return physaddr + 0xa0000000;
    52 }
    53 
    5445/** @}
    5546 */
  • kernel/arch/mips64/src/mm/page.c

    r9aed144 r1c01e6c  
    4343}
    4444
    45 /** Map device into kernel space
    46  * - on mips, all devices are already mapped into kernel space,
    47  *   translate the physical address to uncached area
    48  */
    49 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    50 {
    51         return physaddr + 0xffffffffa0000000;
    52 }
    53 
    5445/** @}
    5546 */
  • kernel/arch/ppc32/src/mm/page.c

    r9aed144 r1c01e6c  
    4646}
    4747
    48 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    49 {
    50         if (last_frame + ALIGN_UP(size, PAGE_SIZE) >
    51             KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
    52                 panic("Unable to map physical memory %p (%zu bytes).",
    53                     (void *) physaddr, size);
    54        
    55         uintptr_t virtaddr = PA2KA(last_frame);
    56         pfn_t i;
    57         page_table_lock(AS_KERNEL, true);
    58         for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
    59                 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i),
    60                     physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE);
    61         page_table_unlock(AS_KERNEL, true);
    62        
    63         last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
    64        
    65         return virtaddr;
    66 }
    67 
    6848/** @}
    6949 */
  • kernel/arch/sparc64/src/mm/page.c

    r9aed144 r1c01e6c  
    5151}
    5252
    53 /** Map memory-mapped device into virtual memory.
    54  *
    55  * We are currently using identity mapping for mapping device registers.
    56  *
    57  * @param physaddr Physical address of the page where the device is
    58  *                 located.
    59  * @param size     Size of the device's registers.
    60  *
    61  * @return Virtual address of the page where the device is mapped.
    62  *
    63  */
    64 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    65 {
    66         return PA2KA(physaddr);
    67 }
    68 
    6953/** @}
    7054 */
  • kernel/generic/src/mm/page.c

    r9aed144 r1c01e6c  
    7474#include <syscall/copy.h>
    7575#include <errno.h>
     76#include <align.h>
    7677
    7778/** Virtual operations for page subsystem. */
     
    175176        return page_mapping_operations->mapping_find(as, page, nolock);
    176177}
     178
     179uintptr_t hw_map(uintptr_t physaddr, size_t size)
     180{
     181        uintptr_t virtaddr = (uintptr_t) NULL;  // FIXME
     182        pfn_t i;
     183
     184        page_table_lock(AS_KERNEL, true);
     185        for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) {
     186                uintptr_t addr = PFN2ADDR(i);
     187                page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr,
     188                    PAGE_NOT_CACHEABLE | PAGE_WRITE);
     189        }
     190        page_table_unlock(AS_KERNEL, true);
     191       
     192        return virtaddr;
     193}
     194
    177195
    178196/** Syscall wrapper for getting mapping of a virtual page.
Note: See TracChangeset for help on using the changeset viewer.