Changeset 00aece0 in mainline for kernel/arch/sparc64


Ignore:
Timestamp:
2012-02-18T16:47:38Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4449c6c
Parents:
bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/arch/sparc64
Files:
5 added
12 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/Makefile.inc

    rbd5f3b7 r00aece0  
    6868        arch/$(KARCH)/src/fpu_context.c \
    6969        arch/$(KARCH)/src/dummy.s \
     70        arch/$(KARCH)/src/mm/$(USARCH)/km.c \
    7071        arch/$(KARCH)/src/mm/$(USARCH)/as.c \
    7172        arch/$(KARCH)/src/mm/$(USARCH)/frame.c \
  • kernel/arch/sparc64/include/mm/sun4u/frame.h

    rbd5f3b7 r00aece0  
    7272typedef union frame_address frame_address_t;
    7373
    74 extern uintptr_t last_frame;
    7574extern uintptr_t end_of_identity;
    7675
    77 extern void frame_arch_init(void);
     76extern void frame_low_arch_init(void);
     77extern void frame_high_arch_init(void);
    7878#define physmem_print()
    7979
  • kernel/arch/sparc64/include/mm/sun4v/frame.h

    rbd5f3b7 r00aece0  
    4646#include <typedefs.h>
    4747
    48 extern uintptr_t last_frame;
    49 extern void frame_arch_init(void);
     48extern void frame_low_arch_init(void);
     49extern void frame_high_arch_init(void);
    5050#define physmem_print()
    5151
  • kernel/arch/sparc64/src/drivers/kbd.c

    rbd5f3b7 r00aece0  
    4040#include <mm/page.h>
    4141#include <arch/mm/page.h>
     42#include <mm/km.h>
    4243#include <typedefs.h>
    4344#include <align.h>
     
    113114        size_t offset = pa - aligned_addr;
    114115       
    115         ns16550_t *ns16550 = (ns16550_t *)
    116            (hw_map(aligned_addr, offset + size) + offset);
     116        ns16550_t *ns16550 = (ns16550_t *) (km_map(aligned_addr, offset + size,
     117            PAGE_WRITE | PAGE_NOT_CACHEABLE) + offset);
    117118       
    118119        ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, inr, cir, cir_arg);
     
    132133        sysinfo_set_item_val("kbd", NULL, true);
    133134        sysinfo_set_item_val("kbd.inr", NULL, inr);
    134         sysinfo_set_item_val("kbd.address.kernel", NULL,
    135             (uintptr_t) ns16550);
    136135        sysinfo_set_item_val("kbd.address.physical", NULL, pa);
    137136        sysinfo_set_item_val("kbd.type.ns16550", NULL, true);
  • kernel/arch/sparc64/src/drivers/pci.c

    rbd5f3b7 r00aece0  
    3939#include <genarch/ofw/upa.h>
    4040#include <arch/trap/interrupt.h>
    41 #include <mm/page.h>
     41#include <mm/km.h>
    4242#include <mm/slab.h>
    4343#include <typedefs.h>
     
    109109        pci->model = PCI_SABRE;
    110110        pci->op = &pci_sabre_ops;
    111         pci->reg = (uint64_t *) hw_map(paddr, reg[SABRE_INTERNAL_REG].size);
     111        pci->reg = (uint64_t *) km_map(paddr, reg[SABRE_INTERNAL_REG].size,
     112            PAGE_WRITE | PAGE_NOT_CACHEABLE);
    112113
    113114        /*
     
    156157        pci->model = PCI_PSYCHO;
    157158        pci->op = &pci_psycho_ops;
    158         pci->reg = (uint64_t *) hw_map(paddr, reg[PSYCHO_INTERNAL_REG].size);
     159        pci->reg = (uint64_t *) km_map(paddr, reg[PSYCHO_INTERNAL_REG].size,
     160            PAGE_WRITE | PAGE_NOT_CACHEABLE);
    159161
    160162        /*
  • kernel/arch/sparc64/src/mm/page.c

    rbd5f3b7 r00aece0  
    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/arch/sparc64/src/mm/sun4u/frame.c

    rbd5f3b7 r00aece0  
    4141#include <macros.h>
    4242
    43 uintptr_t last_frame = (uintptr_t) NULL;
    44 
    4543/** Create memory zones according to information stored in memmap.
    4644 *
    4745 * Walk the memory map and create frame zones according to it.
    4846 */
    49 void frame_arch_init(void)
     47static void frame_common_arch_init(bool low)
    5048{
    51         if (config.cpu_active == 1) {
    52                 unsigned int i;
     49        unsigned int i;
     50       
     51        for (i = 0; i < memmap.cnt; i++) {
     52                uintptr_t base;
     53                size_t size;
     54
     55                /*
     56                 * The memmap is created by HelenOS boot loader.
     57                 * It already contains no holes.
     58                 */
     59
     60                /* To be safe, make the available zone possibly smaller */
     61                base = ALIGN_UP((uintptr_t) memmap.zones[i].start, FRAME_SIZE);
     62                size = ALIGN_DOWN(memmap.zones[i].size -
     63                    (base - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE);
    5364               
    54                 for (i = 0; i < memmap.cnt; i++) {
    55                         /* To be safe, make the available zone possibly smaller */
    56                         uintptr_t new_start = ALIGN_UP((uintptr_t) memmap.zones[i].start,
    57                             FRAME_SIZE);
    58                         size_t new_size = ALIGN_DOWN(memmap.zones[i].size -
    59                             (new_start - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE);
    60                        
    61                         /*
    62                          * The memmap is created by HelenOS boot loader.
    63                          * It already contains no holes.
    64                          */
    65                        
    66                         pfn_t confdata = ADDR2PFN(new_start);
    67                        
     65                if (!frame_adjust_zone_bounds(low, &base, &size))
     66                        continue;
     67 
     68                pfn_t confdata;
     69                pfn_t pfn = ADDR2PFN(base);
     70                size_t count = SIZE2FRAMES(size);
     71
     72                if (low) {
     73                        confdata = pfn;
    6874                        if (confdata == ADDR2PFN(KA2PA(PFN2ADDR(0))))
    6975                                confdata = ADDR2PFN(KA2PA(PFN2ADDR(2)));
    7076                       
    71                         zone_create(ADDR2PFN(new_start), SIZE2FRAMES(new_size),
    72                             confdata, 0);
    73                        
    74                         last_frame = max(last_frame, new_start + new_size);
     77                        zone_create(pfn, count, confdata,
     78                            ZONE_AVAILABLE | ZONE_LOWMEM);
     79                } else {
     80                        confdata = zone_external_conf_alloc(count);
     81                        if (confdata != 0)
     82                                zone_create(pfn, count, confdata,
     83                                    ZONE_AVAILABLE | ZONE_HIGHMEM);
    7584                }
    76                
    77                 /*
    78                  * On sparc64, physical memory can start on a non-zero address.
    79                  * The generic frame_init() only marks PFN 0 as not free, so we
    80                  * must mark the physically first frame not free explicitly
    81                  * here, no matter what is its address.
    82                  */
    83                 frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1);
    8485        }
     86}
     87
     88void frame_low_arch_init(void)
     89{
     90        if (config.cpu_active > 1)
     91                return;
    8592       
    86         end_of_identity = PA2KA(last_frame);
     93        frame_common_arch_init(true);
     94       
     95        /*
     96         * On sparc64, physical memory can start on a non-zero address.
     97         * The generic frame_init() only marks PFN 0 as not free, so we
     98         * must mark the physically first frame not free explicitly
     99         * here, no matter what is its address.
     100         */
     101        frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1);
     102
     103        /* PA2KA will work only on low-memory. */
     104        end_of_identity = PA2KA(config.physmem_end - FRAME_SIZE) + PAGE_SIZE;
     105}
     106
     107void frame_high_arch_init(void)
     108{
     109        if (config.cpu_active > 1)
     110                return;
     111
     112        frame_common_arch_init(false);
    87113}
    88114
  • kernel/arch/sparc64/src/mm/sun4u/tlb.c

    rbd5f3b7 r00aece0  
    206206        pte_t *t;
    207207
    208         page_table_lock(AS, true);
    209208        t = page_mapping_find(AS, page_16k, true);
    210209        if (t && PTE_EXECUTABLE(t)) {
     
    218217                itsb_pte_copy(t, index);
    219218#endif
    220                 page_table_unlock(AS, true);
    221219        } else {
    222220                /*
     
    224222                 * handler.
    225223                 */
    226                 page_table_unlock(AS, true);
    227224                if (as_page_fault(page_16k, PF_ACCESS_EXEC, istate) ==
    228225                    AS_PF_FAULT) {
     
    250247        size_t index;
    251248        pte_t *t;
     249        as_t *as = AS;
    252250
    253251        page_8k = (uint64_t) tag.vpn << MMU_PAGE_WIDTH;
     
    261259                            "Dereferencing NULL pointer.");
    262260                } else if (page_8k >= end_of_identity) {
    263                         /*
    264                          * The kernel is accessing the I/O space.
    265                          * We still do identity mapping for I/O,
    266                          * but without caching.
    267                          */
    268                         dtlb_insert_mapping(page_8k, KA2PA(page_8k),
    269                             PAGESIZE_8K, false, false);
    270                         return;
     261                        /* Kernel non-identity. */
     262                        as = AS_KERNEL;
     263                } else {
     264                        do_fast_data_access_mmu_miss_fault(istate, tag,
     265                    "Unexpected kernel page fault.");
    271266                }
    272                 do_fast_data_access_mmu_miss_fault(istate, tag, "Unexpected "
    273                     "kernel page fault.");
    274         }
    275 
    276         page_table_lock(AS, true);
    277         t = page_mapping_find(AS, page_16k, true);
     267        }
     268
     269        t = page_mapping_find(as, page_16k, true);
    278270        if (t) {
    279271                /*
     
    286278                dtsb_pte_copy(t, index, true);
    287279#endif
    288                 page_table_unlock(AS, true);
    289280        } else {
    290281                /*
    291282                 * Forward the page fault to the address space page fault
    292283                 * handler.
    293                  */             
    294                 page_table_unlock(AS, true);
     284                 */
    295285                if (as_page_fault(page_16k, PF_ACCESS_READ, istate) ==
    296286                    AS_PF_FAULT) {
     
    314304        size_t index;
    315305        pte_t *t;
     306        as_t *as = AS;
    316307
    317308        page_16k = ALIGN_DOWN((uint64_t) tag.vpn << MMU_PAGE_WIDTH, PAGE_SIZE);
    318309        index = tag.vpn % MMU_PAGES_PER_PAGE;   /* 16K-page emulation */
    319310
    320         page_table_lock(AS, true);
    321         t = page_mapping_find(AS, page_16k, true);
     311        if (tag.context == ASID_KERNEL)
     312                as = AS_KERNEL;
     313
     314        t = page_mapping_find(as, page_16k, true);
    322315        if (t && PTE_WRITABLE(t)) {
    323316                /*
     
    334327                dtsb_pte_copy(t, index, false);
    335328#endif
    336                 page_table_unlock(AS, true);
    337329        } else {
    338330                /*
     
    340332                 * handler.
    341333                 */             
    342                 page_table_unlock(AS, true);
    343334                if (as_page_fault(page_16k, PF_ACCESS_WRITE, istate) ==
    344335                    AS_PF_FAULT) {
  • kernel/arch/sparc64/src/mm/sun4v/frame.c

    rbd5f3b7 r00aece0  
    4545 * Walk the memory map and create frame zones according to it.
    4646 */
    47 void frame_arch_init(void)
     47static void frame_common_arch_init(bool low)
    4848{
    49         if (config.cpu_active == 1) {
    50                 unsigned int i;
     49        unsigned int i;
    5150               
    52                 for (i = 0; i < memmap.cnt; i++) {
    53                         /* To be safe, make the available zone possibly smaller */
    54                         uintptr_t new_start = ALIGN_UP((uintptr_t) memmap.zones[i].start,
    55                             FRAME_SIZE);
    56                         size_t new_size = ALIGN_DOWN(memmap.zones[i].size -
    57                             (new_start - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE);
    58                        
    59                         /*
    60                          * The memmap is created by HelenOS boot loader.
    61                          * It already contains no holes.
    62                          */
    63                        
    64                         pfn_t confdata = ADDR2PFN(new_start);
    65                        
     51        for (i = 0; i < memmap.cnt; i++) {
     52                uintptr_t base;
     53                size_t size;
     54
     55                /*
     56                 * The memmap is created by HelenOS boot loader.
     57                 * It already contains no holes.
     58                 */
     59
     60                /* To be safe, make the available zone possibly smaller */
     61                base = ALIGN_UP((uintptr_t) memmap.zones[i].start, FRAME_SIZE);
     62                size = ALIGN_DOWN(memmap.zones[i].size -
     63                    (base - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE);
     64               
     65                if (!frame_adjust_zone_bounds(low, &base, &size))
     66                        continue;
     67
     68                pfn_t confdata;
     69                pfn_t pfn = ADDR2PFN(base);
     70                size_t count = SIZE2FRAMES(size);
     71
     72                if (low) {
     73                        confdata = pfn;
    6674                        if (confdata == ADDR2PFN(KA2PA(PFN2ADDR(0))))
    6775                                confdata = ADDR2PFN(KA2PA(PFN2ADDR(2)));
    6876                       
    69                         zone_create(ADDR2PFN(new_start), SIZE2FRAMES(new_size),
    70                             confdata, 0);
     77                        zone_create(pfn, count, confdata,
     78                            ZONE_AVAILABLE | ZONE_LOWMEM);
     79                } else {
     80                        confdata = zone_external_conf_alloc(count);
     81                        if (confdata != 0)
     82                                zone_create(pfn, count, confdata,
     83                                    ZONE_AVAILABLE | ZONE_HIGHMEM);
    7184                }
    72                
    73                 /*
    74                  * On sparc64, physical memory can start on a non-zero address.
    75                  * The generic frame_init() only marks PFN 0 as not free, so we
    76                  * must mark the physically first frame not free explicitly
    77                  * here, no matter what is its address.
    78                  */
    79                 frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1);
    8085        }
     86}
     87
     88
     89void frame_low_arch_init(void)
     90{
     91        if (config.cpu_active > 1)
     92                return;
     93
     94        frame_common_arch_init(true);
     95
     96        /*
     97         * On sparc64, physical memory can start on a non-zero address.
     98         * The generic frame_init() only marks PFN 0 as not free, so we
     99         * must mark the physically first frame not free explicitly
     100         * here, no matter what is its address.
     101         */
     102        frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1);
     103}
     104
     105void frame_high_arch_init(void)
     106{
     107        if (config.cpu_active > 1)
     108                return;
     109
     110        frame_common_arch_init(false);
    81111}
    82112
  • kernel/arch/sparc64/src/mm/sun4v/tlb.c

    rbd5f3b7 r00aece0  
    218218        pte_t *t;
    219219
    220         page_table_lock(AS, true);
    221220        t = page_mapping_find(AS, va, true);
    222221
     
    231230                itsb_pte_copy(t);
    232231#endif
    233                 page_table_unlock(AS, true);
    234232        } else {
    235233                /*
     
    237235                 * handler.
    238236                 */
    239                 page_table_unlock(AS, true);
    240237                if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
    241238                        do_fast_instruction_access_mmu_miss_fault(istate,
     
    274271        }
    275272
    276         page_table_lock(AS, true);
    277273        t = page_mapping_find(AS, va, true);
    278274        if (t) {
     
    286282                dtsb_pte_copy(t, true);
    287283#endif
    288                 page_table_unlock(AS, true);
    289284        } else {
    290285                /*
     
    292287                 * handler.
    293288                 */             
    294                 page_table_unlock(AS, true);
    295289                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
    296290                        do_fast_data_access_mmu_miss_fault(istate, page_and_ctx,
     
    316310        uint16_t ctx = DMISS_CONTEXT(page_and_ctx);
    317311
    318         page_table_lock(AS, true);
    319312        t = page_mapping_find(AS, va, true);
    320313        if (t && PTE_WRITABLE(t)) {
     
    331324                dtsb_pte_copy(t, false);
    332325#endif
    333                 page_table_unlock(AS, true);
    334326        } else {
    335327                /*
     
    337329                 * handler.
    338330                 */             
    339                 page_table_unlock(AS, true);
    340331                if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
    341332                        do_fast_data_access_protection_fault(istate, page_and_ctx,
  • kernel/arch/sparc64/src/sun4u/sparc64.c

    rbd5f3b7 r00aece0  
    6262        size_t i;
    6363        for (i = 0; i < init.cnt; i++) {
    64                 init.tasks[i].addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr;
     64                init.tasks[i].paddr = KA2PA(bootinfo->taskmap.tasks[i].addr);
    6565                init.tasks[i].size = bootinfo->taskmap.tasks[i].size;
    6666                str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN,
  • kernel/arch/sparc64/src/sun4v/sparc64.c

    rbd5f3b7 r00aece0  
    6464        size_t i;
    6565        for (i = 0; i < init.cnt; i++) {
    66                 init.tasks[i].addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr;
     66                init.tasks[i].paddr = KA2PA(bootinfo->taskmap.tasks[i].addr);
    6767                init.tasks[i].size = bootinfo->taskmap.tasks[i].size;
    6868                str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN,
Note: See TracChangeset for help on using the changeset viewer.