Changeset 00aece0 in mainline for kernel/arch/ia64


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/ia64
Files:
3 added
12 edited

Legend:

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

    rbd5f3b7 r00aece0  
    5252        arch/$(KARCH)/src/ivt.S \
    5353        arch/$(KARCH)/src/interrupt.c \
     54        arch/$(KARCH)/src/mm/km.c \
    5455        arch/$(KARCH)/src/mm/as.c \
    5556        arch/$(KARCH)/src/mm/frame.c \
  • kernel/arch/ia64/include/arch.h

    rbd5f3b7 r00aece0  
    3636#define KERN_ia64_ARCH_H_
    3737
    38 #include <arch/drivers/ski.h>
    39 
    4038extern void arch_pre_main(void);
    4139
  • kernel/arch/ia64/include/asm.h

    rbd5f3b7 r00aece0  
    3838#include <config.h>
    3939#include <typedefs.h>
    40 #include <typedefs.h>
    4140#include <arch/register.h>
     41#include <arch/legacyio.h>
    4242#include <trace.h>
    4343
    44 #define IA64_IOSPACE_ADDRESS  0xE001000000000000ULL
    45 
    4644#define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
    4745
     46/** Map the I/O port address to a legacy I/O address. */
     47NO_TRACE static inline uintptr_t p2a(volatile void *p)
     48{
     49        uintptr_t prt = (uintptr_t) p;
     50
     51        return legacyio_virt_base + (((prt >> 2) << 12) | (prt & 0xfff));
     52}
     53       
    4854NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
    4955{
    50         if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
    51                 uintptr_t prt = (uintptr_t) port;
    52        
    53                 *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
    54                     ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    55         } else {
     56        if (port < (ioport8_t *) IO_SPACE_BOUNDARY)
     57                *((ioport8_t *) p2a(port)) = v;
     58        else
    5659                *port = v;
    57         }
    5860       
    5961        asm volatile (
     
    6567NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v)
    6668{
    67         if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
    68                 uintptr_t prt = (uintptr_t) port;
    69        
    70                 *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
    71                     ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    72         } else {
     69        if (port < (ioport16_t *) IO_SPACE_BOUNDARY)
     70                *((ioport16_t *) p2a(port)) = v;
     71        else
    7372                *port = v;
    74         }
    7573       
    7674        asm volatile (
     
    8280NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v)
    8381{
    84         if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
    85                 uintptr_t prt = (uintptr_t) port;
    86        
    87                 *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
    88                     ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
    89         } else {
     82        if (port < (ioport32_t *) IO_SPACE_BOUNDARY)
     83                *((ioport32_t *) p2a(port)) = v;
     84        else
    9085                *port = v;
    91         }
    9286       
    9387        asm volatile (
     
    106100        );
    107101
    108         if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
    109                 uintptr_t prt = (uintptr_t) port;
    110 
    111                 v = *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
    112                     ((prt & 0xfff) | ((prt >> 2) << 12))));
    113         } else {
     102        if (port < (ioport8_t *) IO_SPACE_BOUNDARY)
     103                v = *((ioport8_t *) p2a(port));
     104        else
    114105                v = *port;
    115         }
    116106       
    117107        return v;
     
    127117        );
    128118
    129         if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
    130                 uintptr_t prt = (uintptr_t) port;
    131 
    132                 v = *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
    133                     ((prt & 0xfff) | ((prt >> 2) << 12))));
    134         } else {
     119        if (port < (ioport16_t *) IO_SPACE_BOUNDARY)
     120                v = *((ioport16_t *) p2a(port));
     121        else
    135122                v = *port;
    136         }
    137123       
    138124        return v;
     
    148134        );
    149135       
    150         if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
    151                 uintptr_t prt = (uintptr_t) port;
    152                
    153                 v = *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
    154                     ((prt & 0xfff) | ((prt >> 2) << 12))));
    155         } else {
     136        if (port < (ioport32_t *) IO_SPACE_BOUNDARY)
     137                v = *((ioport32_t *) p2a(port));
     138        else
    156139                v = *port;
    157         }
    158140
    159141        return v;
  • kernel/arch/ia64/include/interrupt.h

    rbd5f3b7 r00aece0  
    6161#define IRQ_KBD    (0x01 + LEGACY_INTERRUPT_BASE)
    6262#define IRQ_MOUSE  (0x0c + LEGACY_INTERRUPT_BASE)
    63 #define IRQ_NE2000 (0x09 + LEGACY_INTERRUPT_BASE)
    6463
    6564/** General Exception codes. */
  • kernel/arch/ia64/include/mm/frame.h

    rbd5f3b7 r00aece0  
    4343#include <typedefs.h>
    4444
    45 extern uintptr_t last_frame;
     45extern uintptr_t end_of_identity;
    4646
    47 extern void frame_arch_init(void);
     47extern void frame_low_arch_init(void);
     48extern void frame_high_arch_init(void);
    4849#define physmem_print()
    4950
  • kernel/arch/ia64/include/mm/page.h

    rbd5f3b7 r00aece0  
    4343
    4444/** Bit width of the TLB-locked portion of kernel address space. */
    45 #define KERNEL_PAGE_WIDTH  28  /* 256M */
    46 #define IO_PAGE_WIDTH      26  /* 64M */
    47 #define FW_PAGE_WIDTH      28  /* 256M */
    48 
    49 #define USPACE_IO_PAGE_WIDTH  12  /* 4K */
    50 
    51 
    52 /*
    53  * Statically mapped IO spaces - offsets to 0xe...00 of virtual addresses
    54  * because of "minimal virtual bits implemented is 51" it is possible to
    55  * have values up to 0x0007000000000000
    56  */
    57 
    58 /* Firmware area (bellow 4GB in phys mem) */
    59 #define FW_OFFSET   0x00000000F0000000
    60 /* Legacy IO space */
    61 #define IO_OFFSET   0x0001000000000000
    62 /* Videoram - now mapped to 0 as VGA text mode vram on 0xb8000 */
    63 #define VIO_OFFSET  0x0002000000000000
    64 
     45#define KERNEL_PAGE_WIDTH       28      /* 256M */
    6546
    6647#define PPN_SHIFT  12
  • kernel/arch/ia64/src/drivers/ski.c

    rbd5f3b7 r00aece0  
    219219                 * self-sufficient.
    220220                 */
     221                sysinfo_set_item_val("fb", NULL, true);
    221222                sysinfo_set_item_val("fb.kind", NULL, 6);
    222223               
  • kernel/arch/ia64/src/ia64.c

    rbd5f3b7 r00aece0  
    3434
    3535#include <arch.h>
    36 #include <arch/drivers/ski.h>
    37 #include <arch/drivers/it.h>
    38 #include <arch/interrupt.h>
    39 #include <arch/barrier.h>
    40 #include <arch/asm.h>
    41 #include <arch/register.h>
    4236#include <typedefs.h>
    43 #include <arch/context.h>
    44 #include <arch/stack.h>
    45 #include <arch/mm/page.h>
     37#include <errno.h>
    4638#include <interrupt.h>
    47 #include <mm/as.h>
    48 #include <config.h>
    4939#include <macros.h>
     40#include <str.h>
    5041#include <userspace.h>
    5142#include <console/console.h>
    52 #include <abi/proc/uarg.h>
    5343#include <syscall/syscall.h>
    54 #include <ddi/irq.h>
    55 #include <arch/bootinfo.h>
     44#include <sysinfo/sysinfo.h>
     45#include <arch/drivers/it.h>
     46#include <arch/drivers/kbd.h>
     47#include <arch/legacyio.h>
     48#include <genarch/drivers/ega/ega.h>
     49#include <genarch/drivers/i8042/i8042.h>
     50#include <genarch/drivers/ns16550/ns16550.h>
    5651#include <genarch/drivers/legacy/ia32/io.h>
    57 #include <genarch/drivers/ega/ega.h>
    5852#include <genarch/kbrd/kbrd.h>
    5953#include <genarch/srln/srln.h>
    60 #include <genarch/drivers/i8042/i8042.h>
    61 #include <genarch/drivers/ns16550/ns16550.h>
    62 #include <arch/drivers/kbd.h>
    63 #include <smp/smp.h>
    64 #include <smp/ipi.h>
    65 #include <arch/atomic.h>
    66 #include <panic.h>
    67 #include <print.h>
    68 #include <sysinfo/sysinfo.h>
    69 #include <str.h>
     54#include <mm/page.h>
     55#include <mm/km.h>
     56
     57#ifdef MACHINE_ski
     58#include <arch/drivers/ski.h>
     59#endif
    7060
    7161/* NS16550 as a COM 1 */
     
    7565
    7666static uint64_t iosapic_base = 0xfec00000;
     67uintptr_t legacyio_virt_base = 0;
    7768
    7869/** Performs ia64-specific initialization before main_bsp() is called. */
    7970void arch_pre_main(void)
    8071{
    81         init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS);
     72        init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS,
     73            CONFIG_INIT_TASKS);
    8274        size_t i;
     75
    8376        for (i = 0; i < init.cnt; i++) {
    84                 init.tasks[i].addr =
    85                     ((unsigned long) bootinfo->taskmap.tasks[i].addr) |
    86                     VRN_MASK;
     77                init.tasks[i].paddr =
     78                    (uintptr_t) bootinfo->taskmap.tasks[i].addr;
    8779                init.tasks[i].size = bootinfo->taskmap.tasks[i].size;
    8880                str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN,
     
    9385void arch_pre_mm_init(void)
    9486{
    95         /*
    96          * Set Interruption Vector Address (i.e. location of interruption vector
    97          * table).
    98          */
    99         iva_write((uintptr_t) &ivt);
    100         srlz_d();
    101        
    10287}
    10388
    10489static void iosapic_init(void)
    10590{
    106         uint64_t IOSAPIC = PA2KA((sysarg_t)(iosapic_base)) | FW_OFFSET;
     91        uintptr_t IOSAPIC = km_map(iosapic_base, PAGE_SIZE,
     92            PAGE_WRITE | PAGE_NOT_CACHEABLE);
    10793        int i;
    10894       
     
    131117{
    132118        if (config.cpu_active == 1) {
     119                /* Map the page with legacy I/O. */
     120                legacyio_virt_base = km_map(LEGACYIO_PHYS_BASE, LEGACYIO_SIZE,
     121                    PAGE_WRITE | PAGE_NOT_CACHEABLE);
     122
    133123                iosapic_init();
    134124                irq_init(INR_COUNT, INR_COUNT);
     
    198188        sysinfo_set_item_val("kbd.address.physical", NULL,
    199189            (uintptr_t) NS16550_BASE);
    200         sysinfo_set_item_val("kbd.address.kernel", NULL,
    201             (uintptr_t) NS16550_BASE);
    202190#endif
    203191       
    204192#ifdef CONFIG_I8042
    205         i8042_instance_t *i8042_instance = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD);
     193        i8042_instance_t *i8042_instance = i8042_init((i8042_t *) I8042_BASE,
     194            IRQ_KBD);
    206195        if (i8042_instance) {
    207196                kbrd_instance_t *kbrd_instance = kbrd_init();
     
    212201                }
    213202        }
    214        
    215         sysinfo_set_item_val("i8042", NULL, true);
    216         sysinfo_set_item_val("i8042.inr_a", NULL, IRQ_KBD);
    217         sysinfo_set_item_val("i8042.inr_b", NULL, IRQ_MOUSE);
    218         sysinfo_set_item_val("i8042.address.physical", NULL,
    219             (uintptr_t) I8042_BASE);
    220         sysinfo_set_item_val("i8042.address.kernel", NULL,
    221             (uintptr_t) I8042_BASE);
    222 #endif
    223 
    224         sysinfo_set_item_val("netif.ne2000.inr", NULL, IRQ_NE2000);
    225 
     203#endif
     204       
    226205        sysinfo_set_item_val("ia64_iospace", NULL, true);
    227206        sysinfo_set_item_val("ia64_iospace.address", NULL, true);
    228         sysinfo_set_item_val("ia64_iospace.address.virtual", NULL, IO_OFFSET);
     207        sysinfo_set_item_val("ia64_iospace.address.virtual", NULL, LEGACYIO_USER_BASE);
    229208}
    230209
     
    269248 * We use r13 (a.k.a. tp) for this purpose.
    270249 */
    271 sysarg_t sys_tls_set(sysarg_t addr)
    272 {
    273         return 0;
     250sysarg_t sys_tls_set(uintptr_t addr)
     251{
     252        return EOK;
    274253}
    275254
     
    277256{
    278257        pio_write_8((ioport8_t *)0x64, 0xfe);
    279         while (1)
    280                 ;
     258        while (1);
    281259}
    282260
  • kernel/arch/ia64/src/mm/frame.c

    rbd5f3b7 r00aece0  
    5151#define MINCONF 1
    5252
    53 uintptr_t last_frame = 0;
     53uintptr_t end_of_identity = -1ULL;
    5454
    55 void frame_arch_init(void)
     55static void frame_common_arch_init(bool low)
    5656{
    57         if (config.cpu_active == 1) {
    58                 unsigned int i;
    59                 for (i = 0; i < bootinfo->memmap_items; i++) {
    60                         if (bootinfo->memmap[i].type == MEMMAP_FREE_MEM) {
    61                                 uint64_t base = bootinfo->memmap[i].base;
    62                                 uint64_t size = bootinfo->memmap[i].size;
    63                                 uint64_t abase = ALIGN_UP(base, FRAME_SIZE);
     57        unsigned int i;
    6458
    65                                 if (size > FRAME_SIZE)
    66                                         size -= abase - base;
     59        for (i = 0; i < bootinfo->memmap_items; i++) {
     60                if (bootinfo->memmap[i].type != MEMMAP_FREE_MEM)
     61                        continue;
    6762
    68                                 if (size > MIN_ZONE_SIZE) {
    69                                         zone_create(abase >> FRAME_WIDTH,
    70                                             size >> FRAME_WIDTH,
    71                                             max(MINCONF, abase >> FRAME_WIDTH),
    72                                             0);
    73                                 }
    74                                 if (abase + size > last_frame)
    75                                         last_frame = abase + size;
     63                uintptr_t base = bootinfo->memmap[i].base;
     64                size_t size = bootinfo->memmap[i].size;
     65                uintptr_t abase = ALIGN_UP(base, FRAME_SIZE);
     66
     67                if (size > FRAME_SIZE)
     68                        size -= abase - base;
     69
     70                if (!frame_adjust_zone_bounds(low, &abase, &size))
     71                        continue;
     72
     73                if (size > MIN_ZONE_SIZE) {
     74                        pfn_t pfn = ADDR2PFN(abase);
     75                        size_t count = SIZE2FRAMES(size);
     76
     77                        if (low) {
     78                                zone_create(pfn, count, max(MINCONF, pfn),
     79                                    ZONE_AVAILABLE | ZONE_LOWMEM);
     80                        } else {
     81                                pfn_t conf = zone_external_conf_alloc(count);
     82                                if (conf != 0)
     83                                        zone_create(pfn, count, conf,
     84                                            ZONE_AVAILABLE | ZONE_HIGHMEM);
    7685                        }
    7786                }
    78                
    79                 /*
    80                  * Blacklist ROM regions.
    81                  */
    82                 frame_mark_unavailable(ADDR2PFN(ROM_BASE),
    83                     SIZE2FRAMES(ROM_SIZE));
     87        }
     88}
    8489
    85                 frame_mark_unavailable(ADDR2PFN(KERNEL_RESERVED_AREA_BASE),
    86                     SIZE2FRAMES(KERNEL_RESERVED_AREA_SIZE));
    87         }       
     90void frame_low_arch_init(void)
     91{
     92        if (config.cpu_active > 1)
     93                return;
     94       
     95        frame_common_arch_init(true);
     96       
     97        /*
     98         * Blacklist ROM regions.
     99         */
     100        frame_mark_unavailable(ADDR2PFN(ROM_BASE),
     101            SIZE2FRAMES(ROM_SIZE));
     102
     103        frame_mark_unavailable(ADDR2PFN(KERNEL_RESERVED_AREA_BASE),
     104            SIZE2FRAMES(KERNEL_RESERVED_AREA_SIZE));
     105
     106        /* PA2KA will work only on low-memory. */
     107        end_of_identity = PA2KA(config.physmem_end - FRAME_SIZE) + PAGE_SIZE;
     108}
     109
     110void frame_high_arch_init(void)
     111{
     112        if (config.cpu_active > 1)
     113                return;
     114       
     115        frame_common_arch_init(false);
    88116}
    89117
  • kernel/arch/ia64/src/mm/page.c

    rbd5f3b7 r00aece0  
    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/ia64/src/mm/tlb.c

    rbd5f3b7 r00aece0  
    5252#include <arch.h>
    5353#include <interrupt.h>
    54 
    55 #define IO_FRAME_BASE 0xFFFFC000000
     54#include <arch/legacyio.h>
    5655
    5756/** Invalidate all TLB entries. */
     
    467466}
    468467
     468static bool is_kernel_fault(uintptr_t va)
     469{
     470        region_register_t rr;
     471
     472        rr.word = rr_read(VA2VRN(va));
     473        rid_t rid = rr.map.rid;
     474        return (RID2ASID(rid) == ASID_KERNEL) && (VA2VRN(va) == VRN_KERNEL);
     475}
     476
    469477/** Instruction TLB fault handler for faults with VHPT turned off.
    470478 *
     
    480488        va = istate->cr_ifa; /* faulting address */
    481489       
    482         page_table_lock(AS, true);
     490        ASSERT(!is_kernel_fault(va));
     491
    483492        t = page_mapping_find(AS, va, true);
    484493        if (t) {
     
    488497                 */
    489498                itc_pte_copy(t);
    490                 page_table_unlock(AS, true);
    491499        } else {
    492500                /*
    493501                 * Forward the page fault to address space page fault handler.
    494502                 */
    495                 page_table_unlock(AS, true);
    496503                if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
    497504                        fault_if_from_uspace(istate, "Page fault at %p.",
     
    522529static int try_memmap_io_insertion(uintptr_t va, istate_t *istate)
    523530{
    524         if ((va >= IO_OFFSET ) && (va < IO_OFFSET + (1 << IO_PAGE_WIDTH))) {
     531        if ((va >= LEGACYIO_USER_BASE) && (va < LEGACYIO_USER_BASE + (1 << LEGACYIO_PAGE_WIDTH))) {
    525532                if (TASK) {
    526                         uint64_t io_page = (va & ((1 << IO_PAGE_WIDTH) - 1)) >>
    527                             USPACE_IO_PAGE_WIDTH;
     533                        uint64_t io_page = (va & ((1 << LEGACYIO_PAGE_WIDTH) - 1)) >>
     534                            LEGACYIO_SINGLE_PAGE_WIDTH;
    528535                       
    529536                        if (is_io_page_accessible(io_page)) {
    530537                                uint64_t page, frame;
    531538                               
    532                                 page = IO_OFFSET +
    533                                     (1 << USPACE_IO_PAGE_WIDTH) * io_page;
    534                                 frame = IO_FRAME_BASE +
    535                                     (1 << USPACE_IO_PAGE_WIDTH) * io_page;
     539                                page = LEGACYIO_USER_BASE +
     540                                    (1 << LEGACYIO_SINGLE_PAGE_WIDTH) * io_page;
     541                                frame = LEGACYIO_PHYS_BASE +
     542                                    (1 << LEGACYIO_SINGLE_PAGE_WIDTH) * io_page;
    536543                               
    537544                                tlb_entry_t entry;
     
    547554                                entry.ar = AR_READ | AR_WRITE;
    548555                                entry.ppn = frame >> PPN_SHIFT;
    549                                 entry.ps = USPACE_IO_PAGE_WIDTH;
     556                                entry.ps = LEGACYIO_SINGLE_PAGE_WIDTH;
    550557                               
    551558                                dtc_mapping_insert(page, TASK->as->asid, entry);
     
    570577{
    571578        if (istate->cr_isr.sp) {
    572                 /* Speculative load. Deffer the exception
    573                    until a more clever approach can be used.
    574                   
    575                    Currently if we try to find the mapping
    576                    for the speculative load while in the kernel,
    577                    we might introduce a livelock because of
    578                    the possibly invalid values of the address. */
     579                /*
     580                 * Speculative load. Deffer the exception until a more clever
     581                 * approach can be used. Currently if we try to find the
     582                 * mapping for the speculative load while in the kernel, we
     583                 * might introduce a livelock because of the possibly invalid
     584                 * values of the address.
     585                 */
    579586                istate->cr_ipsr.ed = true;
    580587                return;
     
    582589       
    583590        uintptr_t va = istate->cr_ifa;  /* faulting address */
    584        
    585         region_register_t rr;
    586         rr.word = rr_read(VA2VRN(va));
    587         rid_t rid = rr.map.rid;
    588         if (RID2ASID(rid) == ASID_KERNEL) {
    589                 if (VA2VRN(va) == VRN_KERNEL) {
     591        as_t *as = AS;
     592       
     593        if (is_kernel_fault(va)) {
     594                if (va < end_of_identity) {
    590595                        /*
    591                          * Provide KA2PA(identity) mapping for faulting piece of
    592                          * kernel address space.
     596                         * Create kernel identity mapping for low memory.
    593597                         */
    594598                        dtlb_kernel_mapping_insert(va, KA2PA(va), false, 0);
    595599                        return;
     600                } else {
     601                        as = AS_KERNEL;
    596602                }
    597603        }
    598604       
    599605       
    600         page_table_lock(AS, true);
    601         pte_t *entry = page_mapping_find(AS, va, true);
     606        pte_t *entry = page_mapping_find(as, va, true);
    602607        if (entry) {
    603608                /*
     
    606611                 */
    607612                dtc_pte_copy(entry);
    608                 page_table_unlock(AS, true);
    609613        } else {
    610                 page_table_unlock(AS, true);
    611614                if (try_memmap_io_insertion(va, istate))
    612615                        return;
     
    647650        uintptr_t va;
    648651        pte_t *t;
     652        as_t *as = AS;
    649653       
    650654        va = istate->cr_ifa;  /* faulting address */
    651655       
    652         page_table_lock(AS, true);
    653         t = page_mapping_find(AS, va, true);
     656        if (is_kernel_fault(va))
     657                as = AS_KERNEL;
     658
     659        t = page_mapping_find(as, va, true);
    654660        ASSERT((t) && (t->p));
    655661        if ((t) && (t->p) && (t->w)) {
     
    667673                }
    668674        }
    669         page_table_unlock(AS, true);
    670675}
    671676
     
    682687       
    683688        va = istate->cr_ifa;  /* faulting address */
    684        
    685         page_table_lock(AS, true);
     689
     690        ASSERT(!is_kernel_fault(va));
     691       
    686692        t = page_mapping_find(AS, va, true);
    687693        ASSERT((t) && (t->p));
     
    700706                }
    701707        }
    702         page_table_unlock(AS, true);
    703708}
    704709
     
    713718        uintptr_t va;
    714719        pte_t *t;
     720        as_t *as = AS;
    715721       
    716722        va = istate->cr_ifa;  /* faulting address */
    717723       
    718         page_table_lock(AS, true);
    719         t = page_mapping_find(AS, va, true);
     724        if (is_kernel_fault(va))
     725                as = AS_KERNEL;
     726
     727        t = page_mapping_find(as, va, true);
    720728        ASSERT((t) && (t->p));
    721729        if ((t) && (t->p)) {
     
    733741                }
    734742        }
    735         page_table_unlock(AS, true);
    736743}
    737744
     
    748755       
    749756        va = istate->cr_ifa;  /* faulting address */
     757
     758        ASSERT(!is_kernel_fault(va));
    750759       
    751760        /*
    752761         * Assume a write to a read-only page.
    753762         */
    754         page_table_lock(AS, true);
    755763        t = page_mapping_find(AS, va, true);
    756764        ASSERT((t) && (t->p));
     
    761769                panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL);
    762770        }
    763         page_table_unlock(AS, true);
    764771}
    765772
     
    777784        va = istate->cr_ifa;  /* faulting address */
    778785       
    779         page_table_lock(AS, true);
     786        ASSERT(!is_kernel_fault(va));
     787
    780788        t = page_mapping_find(AS, va, true);
    781789        ASSERT(t);
     
    790798                else
    791799                        dtc_pte_copy(t);
    792                 page_table_unlock(AS, true);
    793800        } else {
    794                 page_table_unlock(AS, true);
    795801                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
    796802                        fault_if_from_uspace(istate, "Page fault at %p.",
  • kernel/arch/ia64/src/start.S

    rbd5f3b7 r00aece0  
    3838#define KERNEL_TRANSLATION_I    0x0010000000000661
    3939#define KERNEL_TRANSLATION_D    0x0010000000000661
    40 #define KERNEL_TRANSLATION_VIO  0x0010000000000671
    41 #define KERNEL_TRANSLATION_IO   0x00100FFFFC000671
    42 #define KERNEL_TRANSLATION_FW   0x00100000F0000671
    4340
    4441.section K_TEXT_START, "ax"
     
    8885        itr.d dtr[r0] = r10
    8986       
    90         movl r7 = 1
    91         movl r8 = (VRN_KERNEL << VRN_SHIFT) | VIO_OFFSET
    92         mov cr.ifa = r8
    93         movl r10 = (KERNEL_TRANSLATION_VIO)
    94         itr.d dtr[r7] = r10
    95        
    96         mov r11 = cr.itir
    97         movl r10 = ~0xfc
    98         and r10 = r10, r11
    99         movl r11 = (IO_PAGE_WIDTH << PS_SHIFT)
    100         or r10 = r10, r11
    101         mov cr.itir = r10
    102        
    103         movl r7 = 2
    104         movl r8 = (VRN_KERNEL << VRN_SHIFT) | IO_OFFSET
    105         mov cr.ifa = r8
    106         movl r10 = (KERNEL_TRANSLATION_IO)
    107         itr.d dtr[r7] = r10
    108        
    109         # Setup mapping for firmware area (also SAPIC)
    110        
    111         mov r11 = cr.itir
    112         movl r10 = ~0xfc
    113         and r10 = r10, r11
    114         movl r11 = (FW_PAGE_WIDTH << PS_SHIFT)
    115         or r10 = r10, r11
    116         mov cr.itir = r10
    117        
    118         movl r7 = 3
    119         movl r8 = (VRN_KERNEL << VRN_SHIFT) | FW_OFFSET
    120         mov cr.ifa = r8
    121         movl r10 = (KERNEL_TRANSLATION_FW)
    122         itr.d dtr[r7] = r10
    123        
    124         # Initialize DSR
     87        # Initialize DCR
    12588       
    12689        movl r10 = (DCR_DP_MASK | DCR_DK_MASK | DCR_DX_MASK | DCR_DR_MASK | DCR_DA_MASK | DCR_DD_MASK | DCR_LC_MASK)
     
    156119         * Now we are paging.
    157120         */
     121
     122        #
     123        # Set Interruption Vector Address
     124        # (i.e. location of interruption vector table)
     125        #
     126        movl r8 = ivt ;;
     127        mov cr.iva = r8
     128        srlz.d ;;       
     129
    158130       
    159131        # Switch to register bank 1
     
    167139       
    168140        #
    169         # Initialize memory stack to some sane value and allocate a scratch are
     141        # Initialize memory stack to some sane value and allocate a scratch area
    170142        # on it.
    171143        #
Note: See TracChangeset for help on using the changeset viewer.