Changeset 46c20c8 in mainline for kernel/arch/ia64/src


Ignore:
Timestamp:
2010-11-26T20:08:10Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
45df59a
Parents:
fb150d78 (diff), ffdd2b9 (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/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/asm.S

    rfb150d78 r46c20c8  
    1 #
    2 # Copyright (c) 2005 Jakub Jermar
    3 # All rights reserved.
    4 #
    5 # Redistribution and use in source and binary forms, with or without
    6 # modification, are permitted provided that the following conditions
    7 # are met:
    8 #
    9 # - Redistributions of source code must retain the above copyright
    10 #   notice, this list of conditions and the following disclaimer.
    11 # - Redistributions in binary form must reproduce the above copyright
    12 #   notice, this list of conditions and the following disclaimer in the
    13 #   documentation and/or other materials provided with the distribution.
    14 # - The name of the author may not be used to endorse or promote products
    15 #   derived from this software without specific prior written permission.
    16 #
    17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    27 #
     1/*
     2 * Copyright (c) 2005 Jakub Jermar
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
    2828
    2929#include <arch/register.h>
    3030
    3131.text
    32 
    33 /** Copy memory from/to userspace.
    34  *
    35  * This memcpy() has been taken from the assembler output of
    36  * the generic _memcpy() and modified to have the failover part.
    37  *
    38  * @param in0 Destination address.
    39  * @param in1 Source address.
    40  * @param in2 Number of byte to copy.
    41  */
    4232.global memcpy
    4333.global memcpy_from_uspace
     
    4535.global memcpy_from_uspace_failover_address
    4636.global memcpy_to_uspace_failover_address
     37
     38/** Copy memory from/to userspace.
     39 *
     40 * This memcpy() has been taken from the assembler output of
     41 * the generic _memcpy() and modified to have the failover part.
     42 *
     43 * @param in0 Destination address.
     44 * @param in1 Source address.
     45 * @param in2 Number of byte to copy.
     46 *
     47 */
    4748memcpy:
    4849memcpy_from_uspace:
    4950memcpy_to_uspace:
    5051        alloc loc0 = ar.pfs, 3, 1, 0, 0
    51 
     52       
    5253        adds r14 = 7, in1
    5354        mov r2 = ar.lc
     
    5556        and r14 = -8, r14 ;;
    5657        cmp.ne p6, p7 = r14, in1
    57 (p7)    br.cond.dpnt 3f ;;
    58 0:
    59         cmp.ne p6, p7 = 0, in2
    60 (p7)    br.cond.dpnt 2f ;;
    61 (p6)    adds r14 = -1, in2
    62 (p6)    mov r16 = r0
    63 (p6)    mov r17 = r0 ;;
    64 (p6)    mov ar.lc = r14
    65 1:
    66         add r14 = r16, in1
    67         add r15 = r16, in0
    68         adds r17 = 1, r17 ;;
    69         ld1 r14 = [r14]
    70         mov r16 = r17 ;;
    71         st1 [r15] = r14
    72         br.cloop.sptk.few 1b ;;
    73 2:
    74         mov ar.lc = r2
    75         mov ar.pfs = loc0
    76         br.ret.sptk.many rp
    77 3:
    78         adds r14 = 7, in0 ;;
    79         and r14 = -8, r14 ;;
    80         cmp.eq p6, p7 = r14, in0
    81 (p7)    br.cond.dptk 0b
    82         shr.u r18 = in2, 3 ;;
    83         cmp.ne p6, p7 = 0, r18
    84 (p7)    br.cond.dpnt 5f ;;
    85 (p6)    adds r14 = -1, r18
    86 (p6)    mov r16 = r0
    87 (p6)    mov r17 = r0 ;;
    88 (p6)    mov ar.lc = r14
    89 4:
    90         shladd r14 = r16, 3, r0
    91         adds r16 = 1, r17 ;;
    92         add r15 = in1, r14
    93         add r14 = in0, r14
    94         mov r17 = r16 ;;
    95         ld8 r15 = [r15] ;;
    96         st8 [r14] = r15
    97         br.cloop.sptk.few 4b
    98 5:
    99         and r15 = 7, in2
    100         shladd r14 = r18, 3, r0
    101         mov r16 = r0
    102         mov r18 = r0 ;;
    103         cmp.eq p6, p7 = 0, r15
    104         add in0 = r14, in0
    105         adds r15 = -1, r15
    106         add r17 = r14, in1
    107 (p6)    br.cond.dpnt 2b ;;
    108         mov ar.lc = r15
    109 6:
    110         add r14 = r16, r17
    111         add r15 = r16, in0
    112         adds r16 = 1, r18 ;;
    113         ld1 r14 = [r14]
    114         mov r18 = r16 ;;
    115         st1 [r15] = r14
    116         br.cloop.sptk.few 6b ;;
    117         mov ar.lc = r2
    118         mov ar.pfs = loc0
    119         br.ret.sptk.many rp
    120        
     58        (p7) br.cond.dpnt 3f ;;
     59       
     60        0:
     61       
     62                cmp.ne p6, p7 = 0, in2
     63                (p7) br.cond.dpnt 2f ;;
     64                (p6) adds r14 = -1, in2
     65                (p6) mov r16 = r0
     66                (p6) mov r17 = r0 ;;
     67                (p6) mov ar.lc = r14
     68       
     69        1:
     70       
     71                add r14 = r16, in1
     72                add r15 = r16, in0
     73                adds r17 = 1, r17 ;;
     74                ld1 r14 = [r14]
     75                mov r16 = r17 ;;
     76                st1 [r15] = r14
     77                br.cloop.sptk.few 1b ;;
     78       
     79        2:
     80       
     81                mov ar.lc = r2
     82                mov ar.pfs = loc0
     83                br.ret.sptk.many rp
     84       
     85        3:
     86       
     87                adds r14 = 7, in0 ;;
     88                and r14 = -8, r14 ;;
     89                cmp.eq p6, p7 = r14, in0
     90                (p7) br.cond.dptk 0b
     91                shr.u r18 = in2, 3 ;;
     92                cmp.ne p6, p7 = 0, r18
     93                (p7) br.cond.dpnt 5f ;;
     94                (p6) adds r14 = -1, r18
     95                (p6) mov r16 = r0
     96                (p6) mov r17 = r0 ;;
     97                (p6) mov ar.lc = r14
     98       
     99        4:
     100       
     101                shladd r14 = r16, 3, r0
     102                adds r16 = 1, r17 ;;
     103                add r15 = in1, r14
     104                add r14 = in0, r14
     105                mov r17 = r16 ;;
     106                ld8 r15 = [r15] ;;
     107                st8 [r14] = r15
     108                br.cloop.sptk.few 4b
     109       
     110        5:
     111       
     112                and r15 = 7, in2
     113                shladd r14 = r18, 3, r0
     114                mov r16 = r0
     115                mov r18 = r0 ;;
     116                cmp.eq p6, p7 = 0, r15
     117                add in0 = r14, in0
     118                adds r15 = -1, r15
     119                add r17 = r14, in1
     120                (p6) br.cond.dpnt 2b ;;
     121                mov ar.lc = r15
     122       
     123        6:
     124       
     125                add r14 = r16, r17
     126                add r15 = r16, in0
     127                adds r16 = 1, r18 ;;
     128                ld1 r14 = [r14]
     129                mov r18 = r16 ;;
     130                st1 [r15] = r14
     131                br.cloop.sptk.few 6b ;;
     132                mov ar.lc = r2
     133                mov ar.pfs = loc0
     134                br.ret.sptk.many rp
     135
    121136memcpy_from_uspace_failover_address:
    122137memcpy_to_uspace_failover_address:
    123         mov r8 = r0                     /* return 0 on failure */
     138        /* Return 0 on failure */
     139        mov r8 = r0
    124140        mov ar.pfs = loc0
    125141        br.ret.sptk.many rp
     
    136152cpu_halt:
    137153        br cpu_halt
    138 
    139 .global panic_printf
    140 panic_printf:
    141         {
    142                 br.call.sptk.many b0=printf
    143         }
    144         br halt
    145154
    146155/** Switch to userspace - low level code.
     
    152161 * @param in4 Value to be stored in IPSR.
    153162 * @param in5 Value to be stored in RSC.
     163 *
    154164 */
    155165.global switch_to_userspace
    156166switch_to_userspace:
    157167        alloc loc0 = ar.pfs, 6, 3, 0, 0
    158         rsm (PSR_IC_MASK | PSR_I_MASK)          /* disable interruption collection and interrupts */
     168       
     169        /* Disable interruption collection and interrupts */
     170        rsm (PSR_IC_MASK | PSR_I_MASK)
    159171        srlz.d ;;
    160172        srlz.i ;;
     
    163175        mov cr.iip = in0
    164176        mov r12 = in1
    165 
     177       
    166178        xor r1 = r1, r1
    167179       
     
    172184        movl loc2 = PFM_MASK ;;
    173185        and loc1 = loc2, loc1 ;;
    174         mov cr.ifs = loc1 ;;                    /* prevent decrementing BSP by rfi */
    175 
     186        mov cr.ifs = loc1 ;;  /* prevent decrementing BSP by rfi */
     187       
    176188        invala
    177189       
    178190        mov loc1 = ar.rsc ;;
    179         and loc1 = ~3, loc1 ;;                 
    180         mov ar.rsc = loc1 ;;                    /* put RSE into enforced lazy mode */
    181 
     191        and loc1 = ~3, loc1 ;;
     192        mov ar.rsc = loc1 ;;  /* put RSE into enforced lazy mode */
     193       
    182194        flushrs ;;
    183195       
     
    188200       
    189201        rfi ;;
     202
     203.global early_putchar
     204early_putchar:
     205        br.ret.sptk.many b0
  • kernel/arch/ia64/src/cpu/cpu.c

    rfb150d78 r46c20c8  
    5252void cpu_print_report(cpu_t *m)
    5353{
    54         char *family_str;
     54        const char *family_str;
    5555        char vendor[2 * sizeof(uint64_t) + 1];
    5656       
  • kernel/arch/ia64/src/ddi/ddi.c

    rfb150d78 r46c20c8  
    3636#include <ddi/ddi.h>
    3737#include <proc/task.h>
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <mm/slab.h>
    4040#include <errno.h>
  • kernel/arch/ia64/src/debug/stacktrace.c

    rfb150d78 r46c20c8  
    3535#include <stacktrace.h>
    3636#include <syscall/copy.h>
    37 #include <arch/types.h>
    3837#include <typedefs.h>
    3938
    40 bool kernel_frame_pointer_validate(uintptr_t fp)
     39bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx)
    4140{
    4241        return false;
    4342}
    4443
    45 bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     44bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
    4645{
    4746        return false;
    4847}
    4948
    50 bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra)
     49bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
    5150{
    5251        return false;
    5352}
    5453
    55 bool uspace_frame_pointer_validate(uintptr_t fp)
     54bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx)
    5655{
    5756        return false;
    5857}
    5958
    60 bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     59bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
    6160{
    6261        return false;
    6362}
    6463
    65 bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra)
     64bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
    6665{
    6766        return false;
  • kernel/arch/ia64/src/drivers/it.c

    rfb150d78 r46c20c8  
    3434
    3535/** Interval Timer driver. */
    36  
     36
    3737#include <arch/drivers/it.h>
    3838#include <arch/interrupt.h>
     
    4545#include <arch.h>
    4646
    47 #define IT_SERVICE_CLOCKS       64
     47#define IT_SERVICE_CLOCKS  64
    4848
    49 #define FREQ_NUMERATOR_SHIFT    32
    50 #define FREQ_NUMERATOR_MASK     0xffffffff00000000ULL
     49#define FREQ_NUMERATOR_SHIFT  32
     50#define FREQ_NUMERATOR_MASK   0xffffffff00000000ULL
    5151
    52 #define FREQ_DENOMINATOR_SHIFT  0
    53 #define FREQ_DENOMINATOR_MASK   0xffffffffULL
     52#define FREQ_DENOMINATOR_SHIFT  0
     53#define FREQ_DENOMINATOR_MASK   0xffffffffULL
    5454
    5555uint64_t it_delta;
     
    6363void it_init(void)
    6464{
    65         cr_itv_t itv;
    66        
    6765        if (config.cpu_active == 1) {
    6866                irq_initialize(&it_irq);
     
    8381        }
    8482       
    85         /* initialize Interval Timer external interrupt vector */
     83        /* Initialize Interval Timer external interrupt vector */
     84        cr_itv_t itv;
     85       
    8686        itv.value = itv_read();
    8787        itv.vector = INTERRUPT_TIMER;
    8888        itv.m = 0;
    8989        itv_write(itv.value);
    90 
    91         /* set Interval Timer Counter to zero */
     90       
     91        /* Set Interval Timer Counter to zero */
    9292        itc_write(0);
    9393       
    94         /* generate first Interval Timer interrupt in IT_DELTA ticks */
     94        /* Generate first Interval Timer interrupt in IT_DELTA ticks */
    9595        itm_write(IT_DELTA);
    96 
    97         /* propagate changes */
     96       
     97        /* Propagate changes */
    9898        srlz_d();
    9999}
     
    104104 *
    105105 * @return Always IRQ_ACCEPT.
     106 *
    106107 */
    107108irq_ownership_t it_claim(irq_t *irq)
     
    113114void it_interrupt(irq_t *irq)
    114115{
    115         int64_t c;
    116         int64_t m;
    117        
    118116        eoi_write(EOI);
    119117       
    120         m = itm_read();
     118        int64_t itm = itm_read();
    121119       
    122         while (1) {
    123                 c = itc_read();
    124                 c += IT_SERVICE_CLOCKS;
    125 
    126                 m += IT_DELTA;
    127                 if (m - c < 0)
     120        while (true) {
     121                int64_t itc = itc_read();
     122                itc += IT_SERVICE_CLOCKS;
     123               
     124                itm += IT_DELTA;
     125                if (itm - itc < 0)
    128126                        CPU->missed_clock_ticks++;
    129127                else
     
    131129        }
    132130       
    133         itm_write(m);
    134         srlz_d();                               /* propagate changes */
    135 
     131        itm_write(itm);
     132        srlz_d();  /* Propagate changes */
     133       
    136134        /*
    137135         * We are holding a lock which prevents preemption.
    138136         * Release the lock, call clock() and reacquire the lock again.
    139137         */
    140         spinlock_unlock(&irq->lock);   
     138        irq_spinlock_unlock(&irq->lock, false);
    141139        clock();
    142         spinlock_lock(&irq->lock);
     140        irq_spinlock_lock(&irq->lock, false);
    143141}
    144142
  • kernel/arch/ia64/src/drivers/ski.c

    rfb150d78 r46c20c8  
    3737#include <console/chardev.h>
    3838#include <sysinfo/sysinfo.h>
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040#include <proc/thread.h>
    4141#include <synch/spinlock.h>
    4242#include <arch/asm.h>
    4343#include <arch/drivers/kbd.h>
    44 #include <string.h>
     44#include <str.h>
    4545#include <arch.h>
    4646
     
    216216                 * self-sufficient.
    217217                 */
    218                 sysinfo_set_item_val("fb", NULL, false);
     218                sysinfo_set_item_val("fb.kind", NULL, 6);
    219219               
    220220                fb_exported = true;
  • kernel/arch/ia64/src/ia64.c

    rfb150d78 r46c20c8  
    4040#include <arch/asm.h>
    4141#include <arch/register.h>
    42 #include <arch/types.h>
     42#include <typedefs.h>
    4343#include <arch/context.h>
    4444#include <arch/stack.h>
     
    4747#include <mm/as.h>
    4848#include <config.h>
     49#include <macros.h>
    4950#include <userspace.h>
    5051#include <console/console.h>
     
    6667#include <print.h>
    6768#include <sysinfo/sysinfo.h>
    68 #include <string.h>
     69#include <str.h>
    6970
    7071/* NS16550 as a COM 1 */
     
    7879void arch_pre_main(void)
    7980{
    80         /* Setup usermode init tasks. */
    81 
    82         unsigned int i;
    83        
    84         init.cnt = bootinfo->taskmap.count;
    85        
     81        init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS);
     82        size_t i;
    8683        for (i = 0; i < init.cnt; i++) {
    8784                init.tasks[i].addr =
     
    212209            (uintptr_t) I8042_BASE);
    213210#endif
    214        
     211
     212        sysinfo_set_item_val("netif.dp8390.inr", NULL, IRQ_DP8390);
     213
    215214        sysinfo_set_item_val("ia64_iospace", NULL, true);
    216215        sysinfo_set_item_val("ia64_iospace.address", NULL, true);
  • kernel/arch/ia64/src/interrupt.c

    rfb150d78 r46c20c8  
    4141#include <debug.h>
    4242#include <console/console.h>
    43 #include <arch/types.h>
     43#include <typedefs.h>
    4444#include <arch/asm.h>
    4545#include <arch/barrier.h>
     
    5757#include <putchar.h>
    5858
    59 #define VECTORS_64_BUNDLE       20
    60 #define VECTORS_16_BUNDLE       48
    61 #define VECTORS_16_BUNDLE_START 0x5000
    62 #define VECTOR_MAX              0x7f00
    63 
    64 #define BUNDLE_SIZE             16
    65 
    66 char *vector_names_64_bundle[VECTORS_64_BUNDLE] = {
     59#define VECTORS_64_BUNDLE        20
     60#define VECTORS_16_BUNDLE        48
     61#define VECTORS_16_BUNDLE_START  0x5000
     62
     63#define VECTOR_MAX  0x7f00
     64
     65#define BUNDLE_SIZE  16
     66
     67static const char *vector_names_64_bundle[VECTORS_64_BUNDLE] = {
    6768        "VHPT Translation vector",
    6869        "Instruction TLB vector",
     
    8788};
    8889
    89 char *vector_names_16_bundle[VECTORS_16_BUNDLE] = {
     90static const char *vector_names_16_bundle[VECTORS_16_BUNDLE] = {
    9091        "Page Not Present vector",
    9192        "Key Permission vector",
     
    121122};
    122123
    123 static char *vector_to_string(uint16_t vector);
    124 static void dump_interrupted_context(istate_t *istate);
    125 
    126 char *vector_to_string(uint16_t vector)
     124static const char *vector_to_string(uint16_t vector)
    127125{
    128126        ASSERT(vector <= VECTOR_MAX);
     
    135133}
    136134
    137 void dump_interrupted_context(istate_t *istate)
    138 {
    139         char *ifa, *iipa, *iip;
    140 
    141         ifa = symtab_fmt_name_lookup(istate->cr_ifa);
    142         iipa = symtab_fmt_name_lookup(istate->cr_iipa);
    143         iip = symtab_fmt_name_lookup(istate->cr_iip);
    144 
    145         putchar('\n');
    146         printf("Interrupted context dump:\n");
    147         printf("ar.bsp=%p\tar.bspstore=%p\n", istate->ar_bsp,
    148             istate->ar_bspstore);
    149         printf("ar.rnat=%#018llx\tar.rsc=%#018llx\n", istate->ar_rnat,
    150             istate->ar_rsc);
    151         printf("ar.ifs=%#018llx\tar.pfs=%#018llx\n", istate->ar_ifs,
    152             istate->ar_pfs);
    153         printf("cr.isr=%#018llx\tcr.ipsr=%#018llx\t\n", istate->cr_isr.value,
    154             istate->cr_ipsr);
    155        
    156         printf("cr.iip=%#018llx, #%d\t(%s)\n", istate->cr_iip,
    157             istate->cr_isr.ei, iip);
    158         printf("cr.iipa=%#018llx\t(%s)\n", istate->cr_iipa, iipa);
    159         printf("cr.ifa=%#018llx\t(%s)\n", istate->cr_ifa, ifa);
     135void istate_decode(istate_t *istate)
     136{
     137        printf("ar.bsp=%p\tar.bspstore=%p\n",
     138            (void *) istate->ar_bsp, (void *) istate->ar_bspstore);
     139        printf("ar.rnat=%#0" PRIx64 "\tar.rsc=%#0" PRIx64 "\n",
     140            istate->ar_rnat, istate->ar_rsc);
     141        printf("ar.ifs=%#0" PRIx64 "\tar.pfs=%#0" PRIx64 "\n",
     142            istate->ar_ifs, istate->ar_pfs);
     143        printf("cr.isr=%#0" PRIx64 "\tcr.ipsr=%#0" PRIx64 "\n",
     144            istate->cr_isr.value, istate->cr_ipsr.value);
     145       
     146        printf("cr.iip=%#0" PRIx64 ", #%u\t(%s)\n",
     147            istate->cr_iip, istate->cr_isr.ei,
     148            symtab_fmt_name_lookup(istate->cr_iip));
     149        printf("cr.iipa=%#0" PRIx64 "\t(%s)\n", istate->cr_iipa,
     150            symtab_fmt_name_lookup(istate->cr_iipa));
     151        printf("cr.ifa=%#0" PRIx64 "\t(%s)\n", istate->cr_ifa,
     152            symtab_fmt_name_lookup(istate->cr_ifa));
    160153}
    161154
    162155void general_exception(uint64_t vector, istate_t *istate)
    163156{
    164         char *desc = "";
    165 
     157        const char *desc;
     158       
    166159        switch (istate->cr_isr.ge_code) {
    167160        case GE_ILLEGALOP:
     
    187180                break;
    188181        }
    189 
     182       
    190183        fault_if_from_uspace(istate, "General Exception (%s).", desc);
    191 
    192         dump_interrupted_context(istate);
    193         panic("General Exception (%s).", desc);
     184        panic_badtrap(istate, vector, "General Exception (%s).", desc);
    194185}
    195186
     
    201192        fault_if_from_uspace(istate, "Interruption: %#hx (%s).",
    202193            (uint16_t) vector, vector_to_string(vector));
    203         dump_interrupted_context(istate);
    204         panic("Interruption: %#hx (%s).", (uint16_t) vector,
    205             vector_to_string(vector));
     194        panic_badtrap(istate, vector, "Interruption: %#hx (%s).",
     195            (uint16_t) vector, vector_to_string(vector));
    206196#endif
    207197}
     
    223213                istate->cr_ipsr.ri++;
    224214        }
    225 
     215       
    226216        return syscall_handler(istate->in0, istate->in1, istate->in2,
    227217            istate->in3, istate->in4, istate->in5, istate->in6);
     
    232222        fault_if_from_uspace(istate, "Interruption: %#hx (%s).",
    233223            (uint16_t) vector, vector_to_string(vector));
    234         dump_interrupted_context(istate);
    235         panic("Interruption: %#hx (%s).", (uint16_t) vector,
    236             vector_to_string(vector));
     224        panic_badtrap(istate, vector, "Interruption: %#hx (%s).",
     225            (uint16_t) vector, vector_to_string(vector));
    237226}
    238227
    239228static void end_of_local_irq(void)
    240229{
    241         asm volatile ("mov cr.eoi=r0;;");
    242 }
    243 
     230        asm volatile (
     231                "mov cr.eoi=r0;;"
     232        );
     233}
    244234
    245235void external_interrupt(uint64_t vector, istate_t *istate)
    246236{
    247237        cr_ivr_t ivr;
    248         irq_t *irq;
    249238       
    250239        ivr.value = ivr_read();
    251240        srlz_d();
    252 
     241       
     242        irq_t *irq;
     243       
    253244        switch (ivr.vector) {
    254245        case INTERRUPT_SPURIOUS:
     
    257248#endif
    258249                break;
    259 
     250       
    260251#ifdef CONFIG_SMP
    261252        case VECTOR_TLB_SHOOTDOWN_IPI:
     
    264255                break;
    265256#endif
    266 
     257       
    267258        case INTERRUPT_TIMER:
    268259                irq = irq_dispatch_and_lock(ivr.vector);
    269260                if (irq) {
    270261                        irq->handler(irq);
    271                         spinlock_unlock(&irq->lock);
     262                        irq_spinlock_unlock(&irq->lock, false);
    272263                } else {
    273264                        panic("Unhandled Internal Timer Interrupt (%d).",
     
    288279                        if (!irq->preack)
    289280                                end_of_local_irq();
    290                         spinlock_unlock(&irq->lock);
     281                        irq_spinlock_unlock(&irq->lock, false);
    291282                } else {
    292283                        /*
  • kernel/arch/ia64/src/mm/page.c

    rfb150d78 r46c20c8  
    3939#include <arch/mm/asid.h>
    4040#include <arch/mm/vhpt.h>
    41 #include <arch/types.h>
     41#include <typedefs.h>
    4242#include <print.h>
    4343#include <mm/page.h>
  • kernel/arch/ia64/src/mm/tlb.c

    rfb150d78 r46c20c8  
    499499                page_table_unlock(AS, true);
    500500                if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
    501                         fault_if_from_uspace(istate, "Page fault at %p.", va);
    502                         panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
    503                             istate->cr_iip);
     501                        fault_if_from_uspace(istate, "Page fault at %p.",
     502                            (void *) va);
     503                        panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL);
    504504                }
    505505        }
     
    557557                        } else {
    558558                                fault_if_from_uspace(istate,
    559                                     "IO access fault at %p.", va);
     559                                    "IO access fault at %p.", (void *) va);
    560560                        }
    561561                }
     
    621621                 */
    622622                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
    623                         fault_if_from_uspace(istate, "Page fault at %p.", va);
    624                         panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
    625                             istate->cr_iip);
     623                        fault_if_from_uspace(istate, "Page fault at %p.",
     624                            (void *) va);
     625                        panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
    626626                }
    627627        }
     
    670670        } else {
    671671                if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
    672                         fault_if_from_uspace(istate, "Page fault at %p.", va);
    673                         panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
    674                             istate->cr_iip);
     672                        fault_if_from_uspace(istate, "Page fault at %p.",
     673                            (void *) va);
     674                        panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL);
    675675                }
    676676        }
     
    707707        } else {
    708708                if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
    709                         fault_if_from_uspace(istate, "Page fault at %p.", va);
    710                         panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
    711                             istate->cr_iip);
     709                        fault_if_from_uspace(istate, "Page fault at %p.",
     710                            (void *) va);
     711                        panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL);
    712712                }
    713713        }
     
    744744        } else {
    745745                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
    746                         fault_if_from_uspace(istate, "Page fault at %p.", va);
    747                         panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
    748                             istate->cr_iip);
     746                        fault_if_from_uspace(istate, "Page fault at %p.",
     747                            (void *) va);
     748                        panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
    749749                }
    750750        }
     
    777777        ASSERT(!t->w);
    778778        if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
    779                 fault_if_from_uspace(istate, "Page fault at %p.", va);
    780                 panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
    781                     istate->cr_iip);
     779                fault_if_from_uspace(istate, "Page fault at %p.",
     780                    (void *) va);
     781                panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL);
    782782        }
    783783        page_table_unlock(AS, true);
     
    818818                page_table_unlock(AS, true);
    819819                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
    820                         fault_if_from_uspace(istate, "Page fault at %p.", va);
    821                         panic("%s: va=%p, rid=%d.", __func__, va, rid);
     820                        fault_if_from_uspace(istate, "Page fault at %p.",
     821                            (void *) va);
     822                        panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
    822823                }
    823824        }
  • kernel/arch/ia64/src/smp/smp.c

    rfb150d78 r46c20c8  
    3333 */
    3434
    35 #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>
    42 #include <arch/types.h>
    43 #include <arch/context.h>
    44 #include <arch/stack.h>
    45 #include <arch/mm/page.h>
    46 #include <mm/as.h>
    47 #include <config.h>
    48 #include <userspace.h>
    49 #include <console/console.h>
    50 #include <proc/uarg.h>
    51 #include <syscall/syscall.h>
    52 #include <ddi/irq.h>
    53 #include <ddi/device.h>
    54 #include <arch/bootinfo.h>
    5535#include <smp/smp.h>
    5636#include <smp/ipi.h>
    57 #include <arch/atomic.h>
    58 #include <panic.h>
    59 #include <print.h>
    6037
    6138#ifdef CONFIG_SMP
    6239
    63 extern char cpu_by_id_eid_list[256][256];
    64 
    65 static void sapic_init(void)
     40void ipi_broadcast_arch(int ipi)
    6641{
    67         bootinfo->sapic = (unative_t *)(PA2KA((unative_t)(bootinfo->sapic)) |
    68             FW_OFFSET);
    69 }
    70 
    71 static void ipi_broadcast_arch_all(int ipi)
    72 {
    73         int id, eid;
    74         int myid, myeid;
    75        
    76         myid = ia64_get_cpu_id();
    77         myeid = ia64_get_cpu_eid();
    78        
    79         for (id = 0; id < 256; id++)
    80                 for (eid = 0; eid < 256; eid++)
    81                         if ((id != myid) || (eid != myeid))
    82                                 ipi_send_ipi(id, eid, ipi);
    83 }
    84 
    85 void ipi_broadcast_arch(int ipi )
    86 {
    87         int id, eid;
    88         int myid, myeid;
    89        
    90         myid = ia64_get_cpu_id();
    91         myeid = ia64_get_cpu_eid();
    92 
    93         for (id = 0; id < 256; id++)
    94                 for (eid = 0; eid < 256; eid++)
    95                         if ((id != myid) || (eid != myeid))
    96                                 if (cpu_by_id_eid_list[id][eid])
    97                                         ipi_send_ipi(id, eid, ipi);
    9842}
    9943
    10044void smp_init(void)
    10145{
    102         if (!bootinfo->hello_configured)
    103                 return;
    104        
    105         /*
    106          * If we have not got system prepared by hello, we are not able to start
    107          * AP's. This means we are running on a simulator.
    108          */
    109        
    110         sapic_init();
    111         ipi_broadcast_arch_all(bootinfo->wakeup_intno);
    112         volatile long long brk;
    113         for (brk = 0; brk < 100LL * 1024LL * 1024LL; brk++)
    114                 ;       /* wait a while before CPUs starts */
    115 
    116         config.cpu_count = 0;
    117         int id, eid;
    118        
    119         for (id = 0; id < 256; id++)
    120                 for (eid = 0; eid < 256; eid++)
    121                         if (cpu_by_id_eid_list[id][eid] == 1) {
    122                                 config.cpu_count++;
    123                                 cpu_by_id_eid_list[id][eid] = 2;
    124                         }
    12546}
    12647
    12748void kmp(void *arg __attribute__((unused)))
    12849{
    129         int id, eid;
    130         int myid, myeid;
    131        
    132         myid = ia64_get_cpu_id();
    133         myeid = ia64_get_cpu_eid();
    134 
    135         for (id = 0; id < 256; id++)
    136                 for (eid = 0; eid < 256; eid++)
    137                         if ((id != myid) || (eid != myeid))
    138                                 if (cpu_by_id_eid_list[id][eid] != 0) {
    139                                         if (cpu_by_id_eid_list[id][eid] == 1) {
    140                                                 printf("Found Late CPU ID:%d "
    141                                                     "EDI:%d Not added to "
    142                                                     "system!!!\n", id, eid);
    143                                                 continue;
    144                                         }
    145                                         cpu_by_id_eid_list[id][eid] = 3;
    146                                         /*
    147                                          * There may be just one AP being
    148                                          * initialized at the time. After
    149                                          * it comes completely up, it is
    150                                          * supposed to wake us up.
    151                                          */
    152                                         if (waitq_sleep_timeout(
    153                                             &ap_completion_wq, 1000000,
    154                                             SYNCH_FLAGS_NONE) ==
    155                                             ESYNCH_TIMEOUT) {
    156                                                 printf("%s: waiting for cpu "
    157                                                     "ID:%d EID:%d timed out\n",
    158                                                     __FUNCTION__, id, eid);
    159                                             }
    160                                 }
    16150}
    16251
  • kernel/arch/ia64/src/start.S

    rfb150d78 r46c20c8  
    4747
    4848stack0:
     49
     50#
     51# Kernel entry point.
     52#
     53# This is where we are passed control from the boot code.
     54# Register contents:
     55#
     56#       r2      Address of the boot code's bootinfo structure.
     57#
    4958kernel_image_start:
    5059        .auto
    51        
    52 #ifdef CONFIG_SMP
    53         # Identify self(CPU) in OS structures by ID / EID
    54        
    55         mov r9 = cr64
    56         mov r10 = 1
    57         movl r12 = 0xffffffff
    58         movl r8 = cpu_by_id_eid_list
    59         and r8 = r8, r12
    60         shr r9 = r9, 16
    61         add r8 = r8, r9
    62         st1 [r8] = r10
    63 #endif
    6460       
    6561        mov psr.l = r0
     
    164160        bsw.1
    165161       
    166 #ifdef CONFIG_SMP
    167         # Am I BSP or AP?
    168         movl r20 = bsp_started ;;
    169         ld8 r20 = [r20] ;;
    170         cmp.eq p3, p2 = r20, r0 ;;
    171 #else
    172         cmp.eq p3, p2 = r0, r0 ;;  /* you are BSP */
    173 #endif  /* CONFIG_SMP */
    174        
    175162        # Initialize register stack
    176163        mov ar.rsc = r0
     
    179166        loadrs
    180167       
    181         # Initialize memory stack to some sane value
    182         movl r12 = stack0 ;;
    183         add r12 = -16, r12  /* allocate a scratch area on the stack */
     168        #
     169        # Initialize memory stack to some sane value and allocate a scratch are
     170        # on it.
     171        #
     172        movl sp = stack0 ;;
     173        add sp = -16, sp
    184174       
    185175        # Initialize gp (Global Pointer) register
     176        movl gp = kernel_image_start
     177       
     178        #       
     179        # Initialize bootinfo on BSP.
     180        #
    186181        movl r20 = (VRN_KERNEL << VRN_SHIFT) ;;
    187         or r20 = r20, r1 ;;
    188         movl r1 = kernel_image_start
    189        
    190         /*
    191          * Initialize bootinfo on BSP.
    192          */
    193 (p3)    addl r21 = @gprel(bootinfo), gp ;;
    194 (p3)    st8 [r21] = r20
     182        or r20 = r20, r2 ;;
     183        addl r21 = @gprel(bootinfo), gp ;;
     184        st8 [r21] = r20
    195185       
    196186        ssm (1 << 19) ;; /* Disable f32 - f127 */
     
    198188        srlz.d ;;
    199189       
    200 #ifdef CONFIG_SMP
    201 (p2)    movl r18 = main_ap ;;
    202 (p2)    mov b1 = r18 ;;
    203 (p2)    br.call.sptk.many b0 = b1
    204        
    205         # Mark that BSP is on
    206        
    207         mov r20 = 1 ;;
    208         movl r21 = bsp_started ;;
    209         st8 [r21] = r20 ;;
    210 #endif
    211        
    212190        br.call.sptk.many b0 = arch_pre_main
    213        
    214         movl r18 = main_bsp ;;
    215         mov b1 = r18 ;;
    216         br.call.sptk.many b0 = b1
    217 
     1910:
     192        br.call.sptk.many b0 = main_bsp
    2181930:
    219194        br 0b
    220 
    221 #ifdef CONFIG_SMP
    222 
    223 .align 4096
    224 kernel_image_ap_start:
    225         .auto
    226        
    227         # Identify self(CPU) in OS structures by ID / EID
    228        
    229         mov r9 = cr64
    230         mov r10 = 1
    231         movl r12 = 0xffffffff
    232         movl r8 = cpu_by_id_eid_list
    233         and r8 = r8, r12
    234         shr r9 = r9, 16
    235         add r8 = r8, r9
    236         st1 [r8] = r10
    237        
    238         # Wait for wakeup synchro signal (#3 in cpu_by_id_eid_list)
    239 
    240 kernel_image_ap_start_loop:
    241         movl r11 = kernel_image_ap_start_loop
    242         and r11 = r11, r12
    243         mov b1 = r11
    244        
    245         ld1 r20 = [r8]
    246         movl r21 = 3
    247         cmp.eq p2, p3 = r20, r21
    248 (p3)    br.call.sptk.many b0 = b1
    249        
    250         movl r11 = kernel_image_start
    251         and r11 = r11, r12
    252         mov b1 = r11
    253         br.call.sptk.many b0 = b1
    254 
    255 .align 16
    256 .global bsp_started
    257 bsp_started:
    258         .space 8
    259 
    260 .align 4096
    261 .global cpu_by_id_eid_list
    262 cpu_by_id_eid_list:
    263         .space 65536
    264 
    265 #endif  /* CONFIG_SMP */
Note: See TracChangeset for help on using the changeset viewer.