Changeset 46c20c8 in mainline for kernel/arch/sparc64/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/sparc64/src
Files:
17 added
1 deleted
15 edited
13 moved

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/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/arch.h>
    3030#include <arch/stack.h>
    31 #include <arch/regdef.h>
    32 #include <arch/mm/mmu.h>
    3331
    3432.text
    3533
    36 .register       %g2, #scratch
    37 .register       %g3, #scratch
     34.register %g2, #scratch
     35.register %g3, #scratch
    3836
    3937/*
     
    4240.global memcpy
    4341memcpy:
    44         mov     %o0, %o3                ! save dst
    45         add     %o1, 7, %g1
    46         and     %g1, -8, %g1
    47         cmp     %o1, %g1
    48         be,pn   %xcc, 3f
    49         add     %o0, 7, %g1
    50         mov     0, %g3
    51 0:
    52         brz,pn  %o2, 2f
    53         mov     0, %g2
    54 1:
    55         ldub    [%g3 + %o1], %g1
    56         add     %g2, 1, %g2
    57         cmp     %o2, %g2
    58         stb     %g1, [%g3 + %o0]
    59         bne,pt  %xcc, 1b
    60         mov     %g2, %g3
    61 2:
    62         jmp     %o7 + 8                 ! exit point
    63         mov     %o3, %o0
    64 3:
    65         and     %g1, -8, %g1
    66         cmp     %o0, %g1
    67         bne,pt  %xcc, 0b
    68         mov     0, %g3
    69         srlx    %o2, 3, %g4
    70         brz,pn  %g4, 5f
    71         mov     0, %g5
    72 4:
    73         sllx    %g3, 3, %g2
    74         add     %g5, 1, %g3
    75         ldx     [%o1 + %g2], %g1
    76         mov     %g3, %g5
    77         cmp     %g4, %g3
    78         bne,pt  %xcc, 4b
    79         stx     %g1, [%o0 + %g2]
    80 5:
    81         and     %o2, 7, %o2
    82         brz,pn  %o2, 2b
    83         sllx    %g4, 3, %g1
    84         mov     0, %g2
    85         add     %g1, %o0, %o0
    86         add     %g1, %o1, %g4
    87         mov     0, %g3
    88 6:
    89         ldub    [%g2 + %g4], %g1
    90         stb     %g1, [%g2 + %o0]
    91         add     %g3, 1, %g2
    92         cmp     %o2, %g2
    93         bne,pt  %xcc, 6b
    94         mov     %g2, %g3
    95 
    96         jmp     %o7 + 8                 ! exit point
    97         mov     %o3, %o0
     42        mov %o0, %o3  /* save dst */
     43        add %o1, 7, %g1
     44        and %g1, -8, %g1
     45        cmp %o1, %g1
     46        be,pn %xcc, 3f
     47        add %o0, 7, %g1
     48        mov 0, %g3
     49       
     50        0:
     51       
     52                brz,pn %o2, 2f
     53                mov 0, %g2
     54       
     55        1:
     56       
     57                ldub [%g3 + %o1], %g1
     58                add %g2, 1, %g2
     59                cmp %o2, %g2
     60                stb %g1, [%g3 + %o0]
     61                bne,pt %xcc, 1b
     62                mov %g2, %g3
     63       
     64        2:
     65       
     66                jmp %o7 + 8  /* exit point */
     67                mov %o3, %o0
     68       
     69        3:
     70       
     71                and %g1, -8, %g1
     72                cmp %o0, %g1
     73                bne,pt %xcc, 0b
     74                mov 0, %g3
     75                srlx %o2, 3, %g4
     76                brz,pn %g4, 5f
     77                mov 0, %g5
     78       
     79        4:
     80       
     81                sllx %g3, 3, %g2
     82                add %g5, 1, %g3
     83                ldx [%o1 + %g2], %g1
     84                mov %g3, %g5
     85                cmp %g4, %g3
     86                bne,pt %xcc, 4b
     87                stx %g1, [%o0 + %g2]
     88       
     89        5:
     90       
     91                and %o2, 7, %o2
     92                brz,pn %o2, 2b
     93                sllx %g4, 3, %g1
     94                mov 0, %g2
     95                add %g1, %o0, %o0
     96                add %g1, %o1, %g4
     97                mov 0, %g3
     98       
     99        6:
     100       
     101                ldub [%g2 + %g4], %g1
     102                stb %g1, [%g2 + %o0]
     103                add %g3, 1, %g2
     104                cmp %o2, %g2
     105                bne,pt %xcc, 6b
     106                mov %g2, %g3
     107               
     108                jmp %o7 + 8  /* exit point */
     109                mov %o3, %o0
    98110
    99111/*
     
    102114.global memcpy_from_uspace
    103115memcpy_from_uspace:
    104         mov     %o0, %o3                ! save dst
    105         add     %o1, 7, %g1
    106         and     %g1, -8, %g1
    107         cmp     %o1, %g1
    108         be,pn   %xcc, 3f
    109         add     %o0, 7, %g1
    110         mov     0, %g3
    111 0:
    112         brz,pn  %o2, 2f
    113         mov     0, %g2
    114 1:
    115         lduba   [%g3 + %o1] ASI_AIUS, %g1
    116         add     %g2, 1, %g2
    117         cmp     %o2, %g2
    118         stb     %g1, [%g3 + %o0]
    119         bne,pt  %xcc, 1b
    120         mov     %g2, %g3
    121 2:
    122         jmp     %o7 + 8                 ! exit point
    123         mov     %o3, %o0
    124 3:
    125         and     %g1, -8, %g1
    126         cmp     %o0, %g1
    127         bne,pt  %xcc, 0b
    128         mov     0, %g3
    129         srlx    %o2, 3, %g4
    130         brz,pn  %g4, 5f
    131         mov     0, %g5
    132 4:
    133         sllx    %g3, 3, %g2
    134         add     %g5, 1, %g3
    135         ldxa    [%o1 + %g2] ASI_AIUS, %g1
    136         mov     %g3, %g5
    137         cmp     %g4, %g3
    138         bne,pt  %xcc, 4b
    139         stx     %g1, [%o0 + %g2]
    140 5:
    141         and     %o2, 7, %o2
    142         brz,pn  %o2, 2b
    143         sllx    %g4, 3, %g1
    144         mov     0, %g2
    145         add     %g1, %o0, %o0
    146         add     %g1, %o1, %g4
    147         mov     0, %g3
    148 6:
    149         lduba   [%g2 + %g4] ASI_AIUS, %g1
    150         stb     %g1, [%g2 + %o0]
    151         add     %g3, 1, %g2
    152         cmp     %o2, %g2
    153         bne,pt  %xcc, 6b
    154         mov     %g2, %g3
    155 
    156         jmp     %o7 + 8                 ! exit point
    157         mov     %o3, %o0
     116        mov %o0, %o3  /* save dst */
     117        add %o1, 7, %g1
     118        and %g1, -8, %g1
     119        cmp %o1, %g1
     120        be,pn %xcc, 3f
     121        add %o0, 7, %g1
     122        mov 0, %g3
     123       
     124        0:
     125       
     126                brz,pn %o2, 2f
     127                mov 0, %g2
     128       
     129        1:
     130       
     131                lduba [%g3 + %o1] ASI_AIUS, %g1
     132                add %g2, 1, %g2
     133                cmp %o2, %g2
     134                stb %g1, [%g3 + %o0]
     135                bne,pt %xcc, 1b
     136                mov %g2, %g3
     137       
     138        2:
     139       
     140                jmp %o7 + 8  /* exit point */
     141                mov %o3, %o0
     142       
     143        3:
     144       
     145                and %g1, -8, %g1
     146                cmp %o0, %g1
     147                bne,pt %xcc, 0b
     148                mov 0, %g3
     149                srlx %o2, 3, %g4
     150                brz,pn %g4, 5f
     151                mov 0, %g5
     152       
     153        4:
     154       
     155                sllx %g3, 3, %g2
     156                add %g5, 1, %g3
     157                ldxa [%o1 + %g2] ASI_AIUS, %g1
     158                mov %g3, %g5
     159                cmp %g4, %g3
     160                bne,pt %xcc, 4b
     161                stx %g1, [%o0 + %g2]
     162       
     163        5:
     164       
     165                and %o2, 7, %o2
     166                brz,pn %o2, 2b
     167                sllx %g4, 3, %g1
     168                mov 0, %g2
     169                add %g1, %o0, %o0
     170                add %g1, %o1, %g4
     171                mov 0, %g3
     172       
     173        6:
     174       
     175                lduba [%g2 + %g4] ASI_AIUS, %g1
     176                stb %g1, [%g2 + %o0]
     177                add %g3, 1, %g2
     178                cmp %o2, %g2
     179                bne,pt %xcc, 6b
     180                mov %g2, %g3
     181               
     182                jmp %o7 + 8  /* exit point */
     183                mov %o3, %o0
    158184
    159185/*
     
    162188.global memcpy_to_uspace
    163189memcpy_to_uspace:
    164         mov     %o0, %o3                ! save dst
    165         add     %o1, 7, %g1
    166         and     %g1, -8, %g1
    167         cmp     %o1, %g1
    168         be,pn   %xcc, 3f
    169         add     %o0, 7, %g1
    170         mov     0, %g3
    171 0:
    172         brz,pn  %o2, 2f
    173         mov     0, %g2
    174 1:
    175         ldub    [%g3 + %o1], %g1
    176         add     %g2, 1, %g2
    177         cmp     %o2, %g2
    178         stba    %g1, [%g3 + %o0] ASI_AIUS
    179         bne,pt  %xcc, 1b
    180         mov     %g2, %g3
    181 2:
    182         jmp     %o7 + 8                 ! exit point
    183         mov     %o3, %o0
    184 3:
    185         and     %g1, -8, %g1
    186         cmp     %o0, %g1
    187         bne,pt  %xcc, 0b
    188         mov     0, %g3
    189         srlx    %o2, 3, %g4
    190         brz,pn  %g4, 5f
    191         mov     0, %g5
    192 4:
    193         sllx    %g3, 3, %g2
    194         add     %g5, 1, %g3
    195         ldx     [%o1 + %g2], %g1
    196         mov     %g3, %g5
    197         cmp     %g4, %g3
    198         bne,pt  %xcc, 4b
    199         stxa    %g1, [%o0 + %g2] ASI_AIUS
    200 5:
    201         and     %o2, 7, %o2
    202         brz,pn  %o2, 2b
    203         sllx    %g4, 3, %g1
    204         mov     0, %g2
    205         add     %g1, %o0, %o0
    206         add     %g1, %o1, %g4
    207         mov     0, %g3
    208 6:
    209         ldub    [%g2 + %g4], %g1
    210         stba    %g1, [%g2 + %o0] ASI_AIUS
    211         add     %g3, 1, %g2
    212         cmp     %o2, %g2
    213         bne,pt  %xcc, 6b
    214         mov     %g2, %g3
    215 
    216         jmp     %o7 + 8                 ! exit point
    217         mov     %o3, %o0
     190        mov %o0, %o3  /* save dst */
     191        add %o1, 7, %g1
     192        and %g1, -8, %g1
     193        cmp %o1, %g1
     194        be,pn %xcc, 3f
     195        add %o0, 7, %g1
     196        mov 0, %g3
     197       
     198        0:
     199       
     200                brz,pn %o2, 2f
     201                mov 0, %g2
     202       
     203        1:
     204       
     205                ldub [%g3 + %o1], %g1
     206                add %g2, 1, %g2
     207                cmp %o2, %g2
     208                stba %g1, [%g3 + %o0] ASI_AIUS
     209                bne,pt %xcc, 1b
     210                mov %g2, %g3
     211       
     212        2:
     213       
     214                jmp %o7 + 8  /* exit point */
     215                mov %o3, %o0
     216       
     217        3:
     218       
     219                and %g1, -8, %g1
     220                cmp %o0, %g1
     221                bne,pt %xcc, 0b
     222                mov 0, %g3
     223                srlx %o2, 3, %g4
     224                brz,pn %g4, 5f
     225                mov 0, %g5
     226       
     227        4:
     228       
     229                sllx %g3, 3, %g2
     230                add %g5, 1, %g3
     231                ldx [%o1 + %g2], %g1
     232                mov %g3, %g5
     233                cmp %g4, %g3
     234                bne,pt %xcc, 4b
     235                stxa %g1, [%o0 + %g2] ASI_AIUS
     236       
     237        5:
     238       
     239                and %o2, 7, %o2
     240                brz,pn %o2, 2b
     241                sllx %g4, 3, %g1
     242                mov 0, %g2
     243                add %g1, %o0, %o0
     244                add %g1, %o1, %g4
     245                mov 0, %g3
     246       
     247        6:
     248       
     249                ldub [%g2 + %g4], %g1
     250                stba %g1, [%g2 + %o0] ASI_AIUS
     251                add %g3, 1, %g2
     252                cmp %o2, %g2
     253                bne,pt %xcc, 6b
     254                mov %g2, %g3
     255               
     256                jmp     %o7 + 8  /* exit point */
     257                mov     %o3, %o0
    218258
    219259.global memcpy_from_uspace_failover_address
     
    221261memcpy_from_uspace_failover_address:
    222262memcpy_to_uspace_failover_address:
    223         jmp     %o7 + 8                 ! exit point
    224         mov     %g0, %o0                ! return 0 on failure
     263        jmp %o7 + 8   /* exit point */
     264        mov %g0, %o0  /* return 0 on failure */
    225265
    226266.global memsetb
     
    234274        nop
    235275
    236 
    237 .macro WRITE_ALTERNATE_REGISTER reg, bit
    238         rdpr %pstate, %g1                               ! save PSTATE.PEF
    239         wrpr %g0, (\bit | PSTATE_PRIV_BIT), %pstate
    240         mov %o0, \reg
    241         wrpr %g0, PSTATE_PRIV_BIT, %pstate
     276.global early_putchar
     277early_putchar:
    242278        retl
    243         wrpr %g1, 0, %pstate                            ! restore PSTATE.PEF
    244 .endm
    245 
    246 .macro READ_ALTERNATE_REGISTER reg, bit
    247         rdpr %pstate, %g1                               ! save PSTATE.PEF
    248         wrpr %g0, (\bit | PSTATE_PRIV_BIT), %pstate
    249         mov \reg, %o0
    250         wrpr %g0, PSTATE_PRIV_BIT, %pstate
    251         retl
    252         wrpr %g1, 0, %pstate                            ! restore PSTATE.PEF
    253 .endm
    254 
    255 .global write_to_ag_g6
    256 write_to_ag_g6:
    257         WRITE_ALTERNATE_REGISTER %g6, PSTATE_AG_BIT
    258 
    259 .global write_to_ag_g7
    260 write_to_ag_g7:
    261         WRITE_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT
    262 
    263 .global write_to_ig_g6
    264 write_to_ig_g6:
    265         WRITE_ALTERNATE_REGISTER %g6, PSTATE_IG_BIT
    266 
    267 .global read_from_ag_g7
    268 read_from_ag_g7:
    269         READ_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT
    270 
    271 
    272 /** Switch to userspace.
    273  *
    274  * %o0  Userspace entry address.
    275  * %o1  Userspace stack pointer address.
    276  * %o2  Userspace address of uarg structure.
    277  */
    278 .global switch_to_userspace
    279 switch_to_userspace:
    280         save %o1, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp
    281         flushw
    282         wrpr %g0, 0, %cleanwin          ! avoid information leak
    283 
    284         mov %i2, %o0                    ! uarg
    285         xor %o1, %o1, %o1               ! %o1 is defined to hold pcb_ptr
    286                                         ! set it to 0
    287 
    288         clr %i2
    289         clr %i3
    290         clr %i4
    291         clr %i5
    292         clr %i6
    293 
    294         wrpr %g0, 1, %tl                ! enforce mapping via nucleus
    295 
    296         rdpr %cwp, %g1
    297         wrpr %g1, TSTATE_IE_BIT, %tstate
    298         wrpr %i0, 0, %tnpc
    299        
    300         /*
    301          * Set primary context according to secondary context.
    302          * Secondary context has been already installed by
    303          * higher-level functions.
    304          */
    305         wr %g0, ASI_DMMU, %asi
    306         ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1
    307         stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi
    308         flush %i7
    309 
    310         /*
    311          * Spills and fills will be handled by the userspace handlers.
    312          */
    313         wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
    314        
    315         done                            ! jump to userspace
    316 
     279        nop
  • kernel/arch/sparc64/src/console.c

    rfb150d78 r46c20c8  
    3434
    3535#include <arch/console.h>
    36 #include <arch/types.h>
     36#include <typedefs.h>
    3737
    3838#include <arch/drivers/scr.h>
     
    4949#include <arch.h>
    5050#include <panic.h>
    51 #include <string.h>
     51#include <str.h>
    5252#include <print.h>
    5353
     
    7070        ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value);
    7171        if (!screen)
    72                 panic("Cannot find %s.", prop_scr->value);
     72                panic("Cannot find %s.", (char *) prop_scr->value);
    7373       
    7474        scr_init(screen);
     
    8383        ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value);
    8484        if (!keyboard)
    85                 panic("Cannot find %s.", prop_kbd->value);
     85                panic("Cannot find %s.", (char *) prop_kbd->value);
    8686       
    8787        kbd_init(keyboard);
  • kernel/arch/sparc64/src/cpu/sun4u/cpu.c

    rfb150d78 r46c20c8  
    129129void cpu_print_report(cpu_t *m)
    130130{
    131         char *manuf, *impl;
     131        const char *manuf;
     132        const char *impl;
    132133
    133134        switch (m->arch.ver.manuf) {
  • kernel/arch/sparc64/src/ddi/ddi.c

    rfb150d78 r46c20c8  
    3535#include <ddi/ddi.h>
    3636#include <proc/task.h>
    37 #include <arch/types.h>
     37#include <typedefs.h>
    3838
    3939/** Enable I/O space range for task.
  • kernel/arch/sparc64/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)
     39#include <arch.h>
     40#include <arch/stack.h>
     41#include <arch/trap/trap_table.h>
     42
     43#if defined(SUN4V)
     44#include <arch/sun4v/arch.h>
     45#endif
     46
     47#define FRAME_OFFSET_FP_PREV    14
     48#define FRAME_OFFSET_RA         15
     49
     50extern void alloc_window_and_flush(void);
     51
     52bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx)
     53{
     54        uintptr_t kstack;
     55       
     56#if defined(SUN4U)
     57        kstack = read_from_ag_g6();
     58#elif defined(SUN4V)
     59        kstack = asi_u64_read(ASI_SCRATCHPAD, SCRATCHPAD_KSTACK);
     60#endif
     61
     62        kstack += STACK_BIAS;
     63        kstack -= PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE;
     64
     65        if (THREAD && (ctx->fp == kstack))
     66                return false;
     67        return ctx->fp != 0;
     68}
     69
     70bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
     71{
     72        uint64_t *stack = (void *) ctx->fp;
     73        alloc_window_and_flush();
     74        *prev = stack[FRAME_OFFSET_FP_PREV] + STACK_BIAS;
     75        return true;
     76}
     77
     78bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
     79{
     80        uint64_t *stack = (void *) ctx->fp;
     81        alloc_window_and_flush();
     82        *ra = stack[FRAME_OFFSET_RA];
     83        return true;
     84}
     85
     86bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx)
    4187{
    4288        return false;
    4389}
    4490
    45 bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     91bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
    4692{
    4793        return false;
    4894}
    4995
    50 bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra)
    51 {
    52         return false;
    53 }
    54 
    55 bool uspace_frame_pointer_validate(uintptr_t fp)
    56 {
    57         return false;
    58 }
    59 
    60 bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
    61 {
    62         return false;
    63 }
    64 
    65 bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra)
     96bool uspace_return_address_get(stack_trace_context_t *ctx , uintptr_t *ra)
    6697{
    6798        return false;
  • kernel/arch/sparc64/src/debug/stacktrace_asm.S

    rfb150d78 r46c20c8  
    2727#
    2828
     29#include <arch/stack.h>
     30
    2931.text
    3032
    3133.global frame_pointer_get
    3234.global program_counter_get
     35.global alloc_window_and_flush
    3336
    3437frame_pointer_get:
     38        # Add the stack bias to %sp to get the actual address.
    3539        retl
    36         nop
     40        add %sp, STACK_BIAS, %o0
    3741
    3842program_counter_get:
    3943        retl
    40         nop
     44        mov %o7, %o0
    4145
     46alloc_window_and_flush:
     47        save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE+STACK_ARG_SAVE_AREA_SIZE), %sp
     48        # Flush all other windows to memory so that we can read their contents.
     49        flushw
     50        ret
     51        restore
     52
  • kernel/arch/sparc64/src/drivers/fhc.c

    rfb150d78 r46c20c8  
    4444#include <mm/page.h>
    4545#include <mm/slab.h>
    46 #include <arch/types.h>
     46#include <typedefs.h>
    4747#include <genarch/ofw/ofw_tree.h>
    4848#include <genarch/ofw/fhc.h>
  • kernel/arch/sparc64/src/drivers/kbd.c

    rfb150d78 r46c20c8  
    3939#include <console/console.h>
    4040#include <ddi/irq.h>
     41#include <mm/page.h>
    4142#include <arch/mm/page.h>
    42 #include <arch/types.h>
     43#include <typedefs.h>
    4344#include <align.h>
    44 #include <string.h>
     45#include <str.h>
    4546#include <print.h>
    4647#include <sysinfo/sysinfo.h>
  • kernel/arch/sparc64/src/drivers/pci.c

    rfb150d78 r46c20c8  
    4141#include <mm/page.h>
    4242#include <mm/slab.h>
    43 #include <arch/types.h>
     43#include <typedefs.h>
    4444#include <debug.h>
    4545#include <print.h>
    46 #include <string.h>
     46#include <str.h>
    4747#include <arch/asm.h>
    4848#include <sysinfo/sysinfo.h>
    4949
    5050#define SABRE_INTERNAL_REG      0
    51 #define PSYCHO_INTERNAL_REG     2       
     51#define PSYCHO_INTERNAL_REG     2
    5252
    5353#define OBIO_IMR_BASE   0x200
     
    211211                 * Unsupported model.
    212212                 */
    213                 printf("Unsupported PCI controller model (%s).\n", prop->value);
     213                printf("Unsupported PCI controller model (%s).\n",
     214                    (char *) prop->value);
    214215        }
    215216
  • kernel/arch/sparc64/src/drivers/scr.c

    rfb150d78 r46c20c8  
    4242#include <console/chardev.h>
    4343#include <console/console.h>
    44 #include <arch/types.h>
    45 #include <string.h>
     44#include <typedefs.h>
     45#include <str.h>
    4646#include <align.h>
    4747#include <print.h>
     
    7777        else if (str_cmp(name, "cgsix") == 0)
    7878                scr_type = SCR_CGSIX;
     79        else if (str_cmp(name, "QEMU,VGA") == 0)
     80                scr_type = SCR_QEMU_VGA;
    7981       
    8082        if (scr_type == SCR_UNKNOWN) {
     
    228230       
    229231                break;
     232
     233        case SCR_QEMU_VGA:
     234                if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
     235                        printf("Too few screen registers.\n");
     236                        return;
     237                }
     238
     239                pci_reg = &((ofw_pci_reg_t *) prop->value)[1];
     240
     241                if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) {
     242                        printf("Failed to absolutize fb register.\n");
     243                        return;
     244                }
     245
     246                if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg,
     247                    &fb_addr)) {
     248                        printf("Failed to determine screen address.\n");
     249                        return;
     250                }
     251
     252                switch (fb_depth) {
     253                case 8:
     254                        fb_scanline = fb_linebytes * (fb_depth >> 3);
     255                        visual = VISUAL_INDIRECT_8;
     256                        break;
     257                case 16:
     258                        fb_scanline = fb_linebytes * (fb_depth >> 3);
     259                        visual = VISUAL_RGB_5_6_5_BE;
     260                        break;
     261                case 24:
     262                        fb_scanline = fb_linebytes * 4;
     263                        visual = VISUAL_BGR_8_8_8_0;
     264                        break;
     265                case 32:
     266                        fb_scanline = fb_linebytes * (fb_depth >> 3);
     267                        visual = VISUAL_RGB_0_8_8_8;
     268                        break;
     269                default:
     270                        printf("Unsupported bits per pixel.\n");
     271                        return;
     272                }
     273                break;
     274
    230275        default:
    231276                panic("Unexpected type.");
  • kernel/arch/sparc64/src/drivers/sgcn.c

    rfb150d78 r46c20c8  
    4040#include <genarch/ofw/ofw_tree.h>
    4141#include <debug.h>
    42 #include <string.h>
     42#include <str.h>
    4343#include <print.h>
    4444#include <mm/page.h>
     
    132132static void init_sram_begin(void)
    133133{
    134         ASSERT(instance)
     134        ASSERT(instance);
    135135       
    136136        ofw_tree_node_t *chosen = ofw_tree_lookup("/chosen");
  • kernel/arch/sparc64/src/drivers/tick.c

    rfb150d78 r46c20c8  
    2727 */
    2828
    29 /** @addtogroup sparc64 
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    5454        interrupt_register(14, "tick_int", tick_interrupt);
    5555        compare.int_dis = false;
    56         compare.tick_cmpr = CPU->arch.clock_frequency / HZ;
     56        compare.tick_cmpr = tick_counter_read() +
     57                CPU->arch.clock_frequency / HZ;
    5758        CPU->arch.next_tick_cmpr = compare.tick_cmpr;
    5859        tick_compare_write(compare.value);
    59         tick_write(0);
    6060
    61 #if defined (US3)
     61#if defined (US3) || defined (SUN4V)
    6262        /* disable STICK interrupts and clear any pending ones */
    6363        tick_compare_reg_t stick_compare;
     
    7777/** Process tick interrupt.
    7878 *
    79  * @param n Interrupt Level, 14,  (can be ignored)
     79 * @param n      Interrupt Level (14, can be ignored)
    8080 * @param istate Interrupted state.
     81 *
    8182 */
    82 void tick_interrupt(int n, istate_t *istate)
     83void tick_interrupt(unsigned int n, istate_t *istate)
    8384{
    8485        softint_reg_t softint, clear;
     
    111112         * overflow only in 146 years.
    112113         */
    113         drift = tick_read() - CPU->arch.next_tick_cmpr;
     114        drift = tick_counter_read() - CPU->arch.next_tick_cmpr;
    114115        while (drift > CPU->arch.clock_frequency / HZ) {
    115116                drift -= CPU->arch.clock_frequency / HZ;
    116117                CPU->missed_clock_ticks++;
    117118        }
    118         CPU->arch.next_tick_cmpr = tick_read() +
     119        CPU->arch.next_tick_cmpr = tick_counter_read() +
    119120            (CPU->arch.clock_frequency / HZ) - drift;
    120121        tick_compare_write(CPU->arch.next_tick_cmpr);
  • kernel/arch/sparc64/src/mm/page.c

    rfb150d78 r46c20c8  
    3333 */
    3434
     35#include <mm/page.h>
    3536#include <arch/mm/page.h>
    3637#include <arch/mm/tlb.h>
  • kernel/arch/sparc64/src/mm/sun4u/as.c

    rfb150d78 r46c20c8  
    4141
    4242#ifdef CONFIG_TSB
     43
    4344#include <arch/mm/tsb.h>
    4445#include <arch/memstr.h>
     
    4748#include <bitops.h>
    4849#include <macros.h>
     50
    4951#endif /* CONFIG_TSB */
    5052
     
    5860}
    5961
    60 int as_constructor_arch(as_t *as, int flags)
     62int as_constructor_arch(as_t *as, unsigned int flags)
    6163{
    6264#ifdef CONFIG_TSB
     
    6466         * The order must be calculated with respect to the emulated
    6567         * 16K page size.
    66          */
    67         int order = fnzb32(((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
     68         *
     69         */
     70        uint8_t order = fnzb32(((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
    6871            sizeof(tsb_entry_t)) >> FRAME_WIDTH);
    69 
     72       
    7073        uintptr_t tsb = (uintptr_t) frame_alloc(order, flags | FRAME_KA);
    71 
     74       
    7275        if (!tsb)
    7376                return -1;
    74 
     77       
    7578        as->arch.itsb = (tsb_entry_t *) tsb;
    7679        as->arch.dtsb = (tsb_entry_t *) (tsb + ITSB_ENTRY_COUNT *
    7780            sizeof(tsb_entry_t));
    78 
     81       
    7982        memsetb(as->arch.itsb,
    8083            (ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * sizeof(tsb_entry_t), 0);
    8184#endif
     85       
    8286        return 0;
    8387}
     
    9397            sizeof(tsb_entry_t)) >> FRAME_WIDTH;
    9498        frame_free(KA2PA((uintptr_t) as->arch.itsb));
     99       
    95100        return cnt;
    96101#else
     
    99104}
    100105
    101 int as_create_arch(as_t *as, int flags)
     106int as_create_arch(as_t *as, unsigned int flags)
    102107{
    103108#ifdef CONFIG_TSB
    104109        tsb_invalidate(as, 0, (size_t) -1);
    105110#endif
     111       
    106112        return 0;
    107113}
     
    123129         *
    124130         * Moreover, the as->asid is protected by asidlock, which is being held.
     131         *
    125132         */
    126133       
     
    130137         * secondary context register from the TL=1 code just before switch to
    131138         * userspace.
     139         *
    132140         */
    133141        ctx.v = 0;
    134142        ctx.context = as->asid;
    135143        mmu_secondary_context_write(ctx.v);
    136 
    137 #ifdef CONFIG_TSB       
     144       
     145#ifdef CONFIG_TSB
    138146        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    139 
     147       
    140148        ASSERT(as->arch.itsb && as->arch.dtsb);
    141 
     149       
    142150        uintptr_t tsb = (uintptr_t) as->arch.itsb;
    143                
     151       
    144152        if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    145153                /*
     
    147155                 * by the locked 4M kernel DTLB entry. We need
    148156                 * to map both TSBs explicitly.
     157                 *
    149158                 */
    150159                dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb);
    151160                dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true);
    152161        }
    153                
     162       
    154163        /*
    155164         * Setup TSB Base registers.
     165         *
    156166         */
    157167        tsb_base_reg_t tsb_base;
    158                
     168       
    159169        tsb_base.value = 0;
    160170        tsb_base.size = TSB_SIZE;
    161171        tsb_base.split = 0;
    162 
     172       
    163173        tsb_base.base = ((uintptr_t) as->arch.itsb) >> MMU_PAGE_WIDTH;
    164174        itsb_base_write(tsb_base.value);
     
    175185         * Clearing the extension registers will ensure that the value of the
    176186         * TSB Base register will be used as an address of TSB, making the code
    177          * compatible with the US port.
     187         * compatible with the US port.
     188         *
    178189         */
    179190        itsb_primary_extension_write(0);
     
    195206void as_deinstall_arch(as_t *as)
    196207{
    197 
    198208        /*
    199209         * Note that we don't and may not lock the address space. That's ok
     
    201211         *
    202212         * Moreover, the as->asid is protected by asidlock, which is being held.
    203          */
    204 
     213         *
     214         */
     215       
    205216#ifdef CONFIG_TSB
    206217        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    207 
     218       
    208219        ASSERT(as->arch.itsb && as->arch.dtsb);
    209 
     220       
    210221        uintptr_t tsb = (uintptr_t) as->arch.itsb;
    211                
     222       
    212223        if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    213224                /*
  • kernel/arch/sparc64/src/mm/sun4u/tlb.c

    rfb150d78 r46c20c8  
    2727 */
    2828
    29 /** @addtogroup sparc64mm       
     29/** @addtogroup sparc64mm
    3030 * @{
    3131 */
     
    3737#include <mm/as.h>
    3838#include <mm/asid.h>
    39 #include <genarch/mm/page_ht.h>
    4039#include <arch/mm/frame.h>
    4140#include <arch/mm/page.h>
     
    4544#include <arch.h>
    4645#include <print.h>
    47 #include <arch/types.h>
     46#include <typedefs.h>
    4847#include <config.h>
    4948#include <arch/trap/trap.h>
     
    5150#include <panic.h>
    5251#include <arch/asm.h>
     52#include <genarch/mm/page_ht.h>
    5353
    5454#ifdef CONFIG_TSB
     
    5858static void dtlb_pte_copy(pte_t *, size_t, bool);
    5959static void itlb_pte_copy(pte_t *, size_t);
    60 static void do_fast_instruction_access_mmu_miss_fault(istate_t *, const char *);
     60static void do_fast_instruction_access_mmu_miss_fault(istate_t *, uintptr_t,
     61    const char *);
    6162static void do_fast_data_access_mmu_miss_fault(istate_t *, tlb_tag_access_reg_t,
    6263    const char *);
     
    6465    tlb_tag_access_reg_t, const char *);
    6566
    66 char *context_encoding[] = {
     67const char *context_encoding[] = {
    6768        "Primary",
    6869        "Secondary",
     
    222223                 * Forward the page fault to the address space page fault
    223224                 * handler.
    224                  */             
     225                 */
    225226                page_table_unlock(AS, true);
    226227                if (as_page_fault(page_16k, PF_ACCESS_EXEC, istate) ==
    227228                    AS_PF_FAULT) {
    228229                        do_fast_instruction_access_mmu_miss_fault(istate,
    229                             __func__);
     230                            istate->tpc, __func__);
    230231                }
    231232        }
     
    258259                        /* NULL access in kernel */
    259260                        do_fast_data_access_mmu_miss_fault(istate, tag,
    260                             __func__);
     261                            "Dereferencing NULL pointer.");
    261262                } else if (page_8k >= end_of_identity) {
    262263                        /*
     
    359360static void print_tlb_entry(int i, tlb_tag_read_reg_t t, tlb_data_t d)
    360361{
    361         printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
    362             "ie=%d, soft2=%#x, pfn=%#x, soft=%#x, l=%d, "
    363             "cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n", i, t.vpn,
     362        printf("%u: vpn=%#" PRIx64 ", context=%u, v=%u, size=%u, nfo=%u, "
     363            "ie=%u, soft2=%#x, pfn=%#x, soft=%#x, l=%u, "
     364            "cp=%u, cv=%u, e=%u, p=%u, w=%u, g=%u\n", i, (uint64_t) t.vpn,
    364365            t.context, d.v, d.size, d.nfo, d.ie, d.soft2,
    365366            d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
     
    438439
    439440void do_fast_instruction_access_mmu_miss_fault(istate_t *istate,
    440     const char *str)
    441 {
    442         fault_if_from_uspace(istate, "%s.", str);
    443         dump_istate(istate);
    444         panic("%s.", str);
     441    uintptr_t va, const char *str)
     442{
     443        fault_if_from_uspace(istate, "%s, address=%p.", str, (void *) va);
     444        panic_memtrap(istate, PF_ACCESS_EXEC, va, str);
    445445}
    446446
     
    451451
    452452        va = tag.vpn << MMU_PAGE_WIDTH;
    453         if (tag.context) {
    454                 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va,
    455                     tag.context);
    456         }
    457         dump_istate(istate);
    458         printf("Faulting page: %p, ASID=%d.\n", va, tag.context);
    459         panic("%s.", str);
     453        fault_if_from_uspace(istate, "%s, page=%p (asid=%u).", str,
     454            (void *) va, tag.context);
     455        panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, str);
    460456}
    461457
     
    466462
    467463        va = tag.vpn << MMU_PAGE_WIDTH;
    468 
    469         if (tag.context) {
    470                 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va,
    471                     tag.context);
    472         }
    473         printf("Faulting page: %p, ASID=%d\n", va, tag.context);
    474         dump_istate(istate);
    475         panic("%s.", str);
    476 }
    477 
    478 void dump_sfsr_and_sfar(void)
     464        fault_if_from_uspace(istate, "%s, page=%p (asid=%u).", str,
     465            (void *) va, tag.context);
     466        panic_memtrap(istate, PF_ACCESS_WRITE, va, str);
     467}
     468
     469void describe_dmmu_fault(void)
    479470{
    480471        tlb_sfsr_reg_t sfsr;
     
    493484            sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv);
    494485#endif
     486       
     487        printf("DTLB SFAR: address=%p\n", (void *) sfar);
     488       
     489        dtlb_sfsr_write(0);
     490}
     491
     492void dump_sfsr_and_sfar(void)
     493{
     494        tlb_sfsr_reg_t sfsr;
     495        uintptr_t sfar;
     496
     497        sfsr.value = dtlb_sfsr_read();
     498        sfar = dtlb_sfar_read();
     499       
     500#if defined (US)
     501        printf("DTLB SFSR: asi=%#x, ft=%#x, e=%d, ct=%d, pr=%d, w=%d, ow=%d, "
     502            "fv=%d\n", sfsr.asi, sfsr.ft, sfsr.e, sfsr.ct, sfsr.pr, sfsr.w,
     503            sfsr.ow, sfsr.fv);
     504#elif defined (US3)
     505        printf("DTLB SFSR: nf=%d, asi=%#x, tm=%d, ft=%#x, e=%d, ct=%d, pr=%d, "
     506            "w=%d, ow=%d, fv=%d\n", sfsr.nf, sfsr.asi, sfsr.tm, sfsr.ft,
     507            sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv);
     508#endif
    495509           
    496         printf("DTLB SFAR: address=%p\n", sfar);
     510        printf("DTLB SFAR: address=%p\n", (void *) sfar);
    497511       
    498512        dtlb_sfsr_write(0);
  • kernel/arch/sparc64/src/mm/sun4u/tsb.c

    rfb150d78 r46c20c8  
    3838#include <arch/barrier.h>
    3939#include <mm/as.h>
    40 #include <arch/types.h>
     40#include <typedefs.h>
    4141#include <macros.h>
    4242#include <debug.h>
  • kernel/arch/sparc64/src/mm/sun4v/frame.c

    rfb150d78 r46c20c8  
    3636#include <mm/frame.h>
    3737#include <arch/boot/boot.h>
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <config.h>
    4040#include <align.h>
    4141#include <macros.h>
    4242
    43 uintptr_t last_frame = NULL;
    44 
    45 /** Create memory zones according to information stored in bootinfo.
     43/** Create memory zones according to information stored in memmap.
    4644 *
    47  * Walk the bootinfo memory map and create frame zones according to it.
     45 * Walk the memory map and create frame zones according to it.
    4846 */
    4947void frame_arch_init(void)
    5048{
    51         unsigned int i;
    52         pfn_t confdata;
    53 
    5449        if (config.cpu_active == 1) {
    55                 for (i = 0; i < bootinfo.memmap.count; i++) {
    56                         uintptr_t start = bootinfo.memmap.zones[i].start;
    57                         size_t size = bootinfo.memmap.zones[i].size;
    58 
     50                unsigned int i;
     51               
     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                       
    5959                        /*
    6060                         * The memmap is created by HelenOS boot loader.
    6161                         * It already contains no holes.
    6262                         */
    63 
    64                         confdata = ADDR2PFN(start);
     63                       
     64                        pfn_t confdata = ADDR2PFN(new_start);
     65                       
    6566                        if (confdata == ADDR2PFN(KA2PA(PFN2ADDR(0))))
    6667                                confdata = ADDR2PFN(KA2PA(PFN2ADDR(2)));
    67                         zone_create(ADDR2PFN(start),
    68                             SIZE2FRAMES(ALIGN_DOWN(size, FRAME_SIZE)),
     68                       
     69                        zone_create(ADDR2PFN(new_start), SIZE2FRAMES(new_size),
    6970                            confdata, 0);
    70                         last_frame = max(last_frame, start + ALIGN_UP(size,
    71                             FRAME_SIZE));
    7271                }
    73 
     72               
    7473                /*
    7574                 * On sparc64, physical memory can start on a non-zero address.
     
    8079                frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1);
    8180        }
    82 
    83         end_of_identity = PA2KA(last_frame);
    8481}
    8582
  • kernel/arch/sparc64/src/smp/sun4u/ipi.c

    rfb150d78 r46c20c8  
    9999        status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0);
    100100        if (status & INTR_DISPATCH_STATUS_BUSY)
    101                 panic("Interrupt Dispatch Status busy bit set.");
     101                panic("Interrupt Dispatch Status busy bit set\n");
    102102       
    103103        ASSERT(!(pstate_read() & PSTATE_IE_BIT));
     
    152152                break;
    153153        default:
    154                 panic("Unknown IPI (%d).", ipi);
     154                panic("Unknown IPI (%d).\n", ipi);
    155155                break;
    156156        }
  • kernel/arch/sparc64/src/smp/sun4u/smp.c

    rfb150d78 r46c20c8  
    4141#include <config.h>
    4242#include <macros.h>
    43 #include <arch/types.h>
     43#include <typedefs.h>
    4444#include <synch/synch.h>
    4545#include <synch/waitq.h>
     
    6262{
    6363        ofw_tree_node_t *node;
    64         size_t cnt = 0;
     64        unsigned int cnt = 0;
    6565       
    6666        if (is_us() || is_us_iii()) {
  • kernel/arch/sparc64/src/sun4u/start.S

    rfb150d78 r46c20c8  
    3636#include <arch/mm/tlb.h>
    3737#include <arch/mm/tte.h>
     38#include <arch/mm/cache_spec.h>
    3839
    3940#ifdef CONFIG_SMP
     
    6061/*
    6162 * Here is where the kernel is passed control from the boot loader.
    62  * 
     63 *
    6364 * The registers are expected to be in this state:
    64  * - %o0 starting address of physical memory + bootstrap processor flag
    65  *      bits 63...1:    physical memory starting address / 2
    66  *      bit 0:          non-zero on BSP processor, zero on AP processors
    67  * - %o1 bootinfo structure address (BSP only)
    68  * - %o2 bootinfo structure size (BSP only)
     65 *  - %o0 starting address of physical memory
     66 *        + bootstrap processor flag
     67 *          bits 63...1: physical memory starting address / 2
     68 *          bit 0:       non-zero on BSP processor, zero on AP processors
     69 *  - %o1 bootinfo structure address (BSP only)
     70 *
    6971 *
    7072 * Moreover, we depend on boot having established the following environment:
    71  * - TLBs are on
    72  * - identity mapping for the kernel image
     73 *  - TLBs are on
     74 *  - identity mapping for the kernel image
     75 *
    7376 */
    7477
     
    267270        or %l3, %l5, %l3
    268271        stx %l3, [%l4 + %lo(kernel_8k_tlb_data_template)]
    269 
    270         /*
    271          * Flush D-Cache.
    272          */
    273         call dcache_flush
    274         nop
    275 
     272       
     273        ! flush the whole D-cache
     274        set (DCACHE_SIZE - DCACHE_LINE_SIZE), %g1
     275        stxa %g0, [%g1] ASI_DCACHE_TAG
     276       
     2770:
     278        membar #Sync
     279        subcc %g1, DCACHE_LINE_SIZE, %g1
     280        bnz,pt %xcc, 0b
     281        stxa %g0, [%g1] ASI_DCACHE_TAG
     282        membar #Sync
     283       
    276284        /*
    277285         * So far, we have not touched the stack.
     
    281289        or %sp, %lo(temporary_boot_stack), %sp
    282290        sub %sp, STACK_BIAS, %sp
    283 
    284         sethi %hi(bootinfo), %o0
    285         call memcpy                             ! copy bootinfo
    286         or %o0, %lo(bootinfo), %o0
    287 
     291       
     292        /*
     293         * Call arch_pre_main(bootinfo)
     294         */
    288295        call arch_pre_main
    289         nop
    290        
     296        mov %o1, %o0
     297       
     298        /*
     299         * Create the first stack frame.
     300         */
     301        save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp
     302        flushw
     303        add %g0, -STACK_BIAS, %fp
     304
    291305        call main_bsp
    292306        nop
     
    295309
    2963100:
    297         ba %xcc, 0b
    298         nop
     311        ba,a %xcc, 0b
    299312
    300313
     
    346359        ldx [%g1], %o6
    347360
     361        /*
     362         * Create the first stack frame.
     363         */
     364        save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp
     365        flushw
     366        add %g0, -STACK_BIAS, %fp
     367
    348368        call main_ap
    349369        nop
     
    353373       
    3543740:
    355         ba %xcc, 0b
    356         nop
     375        ba,a %xcc, 0b
    357376
    358377
  • kernel/arch/sparc64/src/sun4v/asm.S

    rfb150d78 r46c20c8  
    11#
    2 # Copyright (c) 2007 Michal Kebrt
     2# Copyright (c) 2008 Pavel Rimsky
    33# All rights reserved.
    44#
     
    2727#
    2828
     29#include <arch/mm/mmu.h>
     30#include <arch/regdef.h>
     31#include <arch/stack.h>
    2932
    3033.text
    3134
    32 .global memcpy
     35/** Switch to userspace.
     36 *
     37 * %o0  Userspace entry address.
     38 * %o1  Userspace stack pointer address.
     39 * %o2  Userspace address of uarg structure.
     40 */
     41.global switch_to_userspace
     42switch_to_userspace:
     43        wrpr PSTATE_PRIV_BIT, %pstate
     44        save %o1, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
     45        flushw
     46        wrpr %g0, 0, %cleanwin          ! avoid information leak
    3347
    34 memcpy:
    35         add     r3, r1, #3
    36         bic     r3, r3, #3
    37         cmp     r1, r3
    38         stmdb   sp!, {r4, r5, lr}
    39         mov     r5, r0
    40         beq     4f
    41 1:
    42         cmp     r2, #0
    43         movne   ip, #0
    44         beq     3f
    45 2:
    46         ldrb    r3, [ip, r1]
    47         strb    r3, [ip, r0]
    48         add     ip, ip, #1
    49         cmp     ip, r2
    50         bne     2b
    51 3:
    52         mov     r0, r5
    53         ldmia   sp!, {r4, r5, pc}
    54 4:
    55         add     r3, r0, #3
    56         bic     r3, r3, #3
    57         cmp     r0, r3
    58         bne     1b
    59         movs    r4, r2, lsr #2
    60         moveq   lr, r4
    61         beq     6f
    62         mov     lr, #0
    63         mov     ip, lr
    64 5:
    65         ldr     r3, [ip, r1]
    66         add     lr, lr, #1
    67         cmp     lr, r4
    68         str     r3, [ip, r0]
    69         add     ip, ip, #4
    70         bne     5b
    71 6:
    72         ands    r4, r2, #3
    73         beq     3b
    74         mov     r3, lr, lsl #2
    75         add     r0, r3, r0
    76         add     ip, r3, r1
    77         mov     r2, #0
    78 7:
    79         ldrb    r3, [r2, ip]
    80         strb    r3, [r2, r0]
    81         add     r2, r2, #1
    82         cmp     r2, r4
    83         bne     7b
    84         b       3b
     48        mov %i2, %o0                    ! uarg
     49        xor %o1, %o1, %o1               ! %o1 is defined to hold pcb_ptr
     50                                        ! set it to 0
     51        clr %i2
     52        clr %i3
     53        clr %i4
     54        clr %i5
     55        clr %i6
     56        wrpr %g0, 1, %tl                ! enforce mapping via nucleus
    8557
     58        rdpr %cwp, %g1
     59        wrpr %g1, TSTATE_IE_BIT, %tstate
     60        wrpr %i0, 0, %tnpc
     61       
     62        /*
     63         * Set primary context according to secondary context.
     64         * Secondary context has been already installed by
     65         * higher-level functions.
     66         */
     67        wr %g0, ASI_SECONDARY_CONTEXT_REG, %asi
     68        ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1
     69        wr %g0, ASI_PRIMARY_CONTEXT_REG, %asi
     70        stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi
     71        flush %i7
    8672
     73        /*
     74         * Spills and fills will be handled by the userspace handlers.
     75         */
     76        wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
     77        done                            ! jump to userspace
  • kernel/arch/sparc64/src/sun4v/sparc64.c

    rfb150d78 r46c20c8  
    3636#include <debug.h>
    3737#include <config.h>
     38#include <macros.h>
    3839#include <arch/trap/trap.h>
    3940#include <arch/console.h>
     41#include <arch/sun4v/md.h>
    4042#include <console/console.h>
    4143#include <arch/boot/boot.h>
     
    4850#include <userspace.h>
    4951#include <ddi/irq.h>
    50 #include <string.h>
     52#include <str.h>
     53#include <arch/drivers/niagara.h>
    5154
    52 bootinfo_t bootinfo;
     55memmap_t memmap;
    5356
    5457/** Perform sparc64-specific initialization before main_bsp() is called. */
    55 void arch_pre_main(void)
     58void arch_pre_main(bootinfo_t *bootinfo)
    5659{
    5760        /* Copy init task info. */
    58         init.cnt = bootinfo.taskmap.count;
     61        init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS);
    5962       
    60         uint32_t i;
    61 
    62         for (i = 0; i < bootinfo.taskmap.count; i++) {
    63                 init.tasks[i].addr = (uintptr_t) bootinfo.taskmap.tasks[i].addr;
    64                 init.tasks[i].size = bootinfo.taskmap.tasks[i].size;
     63        size_t i;
     64        for (i = 0; i < init.cnt; i++) {
     65                init.tasks[i].addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr;
     66                init.tasks[i].size = bootinfo->taskmap.tasks[i].size;
    6567                str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN,
    66                     bootinfo.taskmap.tasks[i].name);
     68                    bootinfo->taskmap.tasks[i].name);
    6769        }
    6870       
    69         /* Copy boot allocations info. */
    70         ballocs.base = bootinfo.ballocs.base;
    71         ballocs.size = bootinfo.ballocs.size;
     71        /* Copy physical memory map. */
     72        memmap.total = bootinfo->memmap.total;
     73        memmap.cnt = min(bootinfo->memmap.cnt, MEMMAP_MAX_RECORDS);
     74        for (i = 0; i < memmap.cnt; i++) {
     75                memmap.zones[i].start = bootinfo->memmap.zones[i].start;
     76                memmap.zones[i].size = bootinfo->memmap.zones[i].size;
     77        }
    7278       
    73         ofw_tree_init(bootinfo.ofw_root);
     79        md_init();
    7480}
    7581
     
    103109void arch_post_smp_init(void)
    104110{
    105         standalone_sparc64_console_init();
     111        niagarain_init();
    106112}
    107113
  • kernel/arch/sparc64/src/trap/exception.c

    rfb150d78 r46c20c8  
    4444#include <symtab.h>
    4545
    46 void dump_istate(istate_t *istate)
    47 {
    48         char *tpcs, *tnpcs;
    49 
    50         tpcs = symtab_fmt_name_lookup(istate->tpc);
    51         tnpcs = symtab_fmt_name_lookup(istate->tnpc);
    52 
     46void istate_decode(istate_t *istate)
     47{
     48        const char *tpcs = symtab_fmt_name_lookup(istate->tpc);
     49        const char *tnpcs = symtab_fmt_name_lookup(istate->tnpc);
     50       
    5351        printf("TSTATE=%#" PRIx64 "\n", istate->tstate);
    5452        printf("TPC=%#" PRIx64 " (%s)\n", istate->tpc, tpcs);
     
    6058{
    6159        fault_if_from_uspace(istate, "%s.", __func__);
    62         dump_istate(istate);
    63         panic("%s.", __func__);
     60        panic_badtrap(istate, n, "%s.", __func__);
    6461}
    6562
     
    6865{
    6966        fault_if_from_uspace(istate, "%s.", __func__);
    70         dump_istate(istate);
    71         panic("%s.", __func__);
     67        panic_badtrap(istate, n, "%s.", __func__);
    7268}
    7369
     
    7672{
    7773        fault_if_from_uspace(istate, "%s.", __func__);
    78         dump_istate(istate);
    79         panic("%s.", __func__);
     74        panic_badtrap(istate, n, "%s.", __func__);
    8075}
    8176
     
    8479{
    8580        fault_if_from_uspace(istate, "%s.", __func__);
    86         dump_istate(istate);
    87         panic("%s.", __func__);
     81        panic_badtrap(istate, n, "%s.", __func__);
    8882}
    8983
     
    9286{
    9387        fault_if_from_uspace(istate, "%s.", __func__);
    94         dump_istate(istate);
    95         panic("%s.", __func__);
     88        panic_badtrap(istate, n, "%s.", __func__);
    9689}
    9790
     
    10093{
    10194        fault_if_from_uspace(istate, "%s.", __func__);
    102         dump_istate(istate);
    103         panic("%s.", __func__);
     95        panic_badtrap(istate, n, "%s.", __func__);
    10496}
    10597
     
    120112#else
    121113        fault_if_from_uspace(istate, "%s.", __func__);
    122         dump_istate(istate);
    123         panic("%s.", __func__);
     114        panic_badtrap(istate, n, "%s.", __func__);
    124115#endif
    125116}
     
    129120{
    130121        fault_if_from_uspace(istate, "%s.", __func__);
    131         dump_istate(istate);
    132         panic("%s.", __func__);
     122        panic_badtrap(istate, n, "%s.", __func__);
    133123}
    134124
     
    137127{
    138128        fault_if_from_uspace(istate, "%s.", __func__);
    139         dump_istate(istate);
    140         panic("%s.", __func__);
     129        panic_badtrap(istate, n, "%s.", __func__);
    141130}
    142131
     
    145134{
    146135        fault_if_from_uspace(istate, "%s.", __func__);
    147         dump_istate(istate);
    148         panic("%s.", __func__);
     136        panic_badtrap(istate, n, "%s.", __func__);
    149137}
    150138
     
    153141{
    154142        fault_if_from_uspace(istate, "%s.", __func__);
    155         dump_istate(istate);
    156         panic("%s.", __func__);
     143        panic_badtrap(istate, n, "%s.", __func__);
    157144}
    158145
     
    161148{
    162149        fault_if_from_uspace(istate, "%s.", __func__);
    163         dump_istate(istate);
    164         dump_sfsr_and_sfar();
    165         panic("%s.", __func__);
     150        panic_badtrap(istate, n, "%s.", __func__);
    166151}
    167152
     
    170155{
    171156        fault_if_from_uspace(istate, "%s.", __func__);
    172         dump_istate(istate);
    173         panic("%s.", __func__);
     157        panic_badtrap(istate, n, "%s.", __func__);
    174158}
    175159
     
    178162{
    179163        fault_if_from_uspace(istate, "%s.", __func__);
    180         dump_istate(istate);
    181         panic("%s.", __func__);
     164        panic_badtrap(istate, n, "%s.", __func__);
    182165}
    183166
     
    186169{
    187170        fault_if_from_uspace(istate, "%s.", __func__);
    188         dump_istate(istate);
    189         panic("%s.", __func__);
     171        panic_badtrap(istate, n, "%s.", __func__);
    190172}
    191173
     
    194176{
    195177        fault_if_from_uspace(istate, "%s.", __func__);
    196         dump_istate(istate);
    197         panic("%s.", __func__);
     178        panic_badtrap(istate, n, "%s.", __func__);
    198179}
    199180
     
    202183{
    203184        fault_if_from_uspace(istate, "%s.", __func__);
    204         dump_istate(istate);
    205         panic("%s.", __func__);
     185        panic_badtrap(istate, n, "%s.", __func__);
    206186}
    207187
     
    210190{
    211191        fault_if_from_uspace(istate, "%s.", __func__);
    212         dump_istate(istate);
    213         panic("%s.", __func__);
     192        panic_badtrap(istate, n, "%s.", __func__);
    214193}
    215194
     
    218197{
    219198        fault_if_from_uspace(istate, "%s.", __func__);
    220         dump_istate(istate);
    221         panic("%s.", __func__);
     199        panic_badtrap(istate, n, "%s.", __func__);
    222200}
    223201
  • kernel/arch/sparc64/src/trap/interrupt.c

    rfb150d78 r46c20c8  
    11/*
    22 * Copyright (c) 2005 Jakub Jermar
     3 * Copyright (c) 2009 Pavel Rimsky
    34 * All rights reserved.
    45 *
     
    3435
    3536#include <arch/interrupt.h>
     37#include <arch/trap/interrupt.h>
    3638#include <arch/sparc64.h>
    37 #include <arch/trap/interrupt.h>
    3839#include <interrupt.h>
    3940#include <ddi/irq.h>
    40 #include <arch/types.h>
     41#include <typedefs.h>
    4142#include <debug.h>
    4243#include <arch/asm.h>
     
    5051/** Register Interrupt Level Handler.
    5152 *
    52  * @param n Interrupt Level (1 - 15).
    53  * @param name Short descriptive string.
    54  * @param f Handler.
     53 * @param n       Interrupt Level (1 - 15).
     54 * @param name    Short descriptive string.
     55 * @param handler Handler.
     56 *
    5557 */
    56 void interrupt_register(int n, const char *name, iroutine f)
     58void interrupt_register(unsigned int n, const char *name, iroutine_t handler)
    5759{
    58         ASSERT(n >= IVT_FIRST && n <= IVT_ITEMS);
     60        ASSERT(n >= IVT_FIRST);
     61        ASSERT(n <= IVT_ITEMS);
    5962       
    60         exc_register(n - 1, name, f);
    61 }
    62 
    63 /** Process hardware interrupt.
    64  *
    65  * @param n Ignored.
    66  * @param istate Ignored.
    67  */
    68 void interrupt(int n, istate_t *istate)
    69 {
    70         uint64_t status;
    71         uint64_t intrcv;
    72         uint64_t data0;
    73         status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0);
    74         if (status & (!INTR_DISPATCH_STATUS_BUSY))
    75                 panic("Interrupt Dispatch Status busy bit not set.");
    76 
    77         intrcv = asi_u64_read(ASI_INTR_RECEIVE, 0);
    78 #if defined (US)
    79         data0 = asi_u64_read(ASI_INTR_R, ASI_UDB_INTR_R_DATA_0);
    80 #elif defined (US3)
    81         data0 = asi_u64_read(ASI_INTR_R, VA_INTR_R_DATA_0);
    82 #endif
    83 
    84         irq_t *irq = irq_dispatch_and_lock(data0);
    85         if (irq) {
    86                 /*
    87                  * The IRQ handler was found.
    88                  */
    89                 irq->handler(irq);
    90                 /*
    91                  * See if there is a clear-interrupt-routine and call it.
    92                  */
    93                 if (irq->cir) {
    94                         irq->cir(irq->cir_arg, irq->inr);
    95                 }
    96                 spinlock_unlock(&irq->lock);
    97         } else if (data0 > config.base) {
    98                 /*
    99                  * This is a cross-call.
    100                  * data0 contains address of the kernel function.
    101                  * We call the function only after we verify
    102                  * it is one of the supported ones.
    103                  */
    104 #ifdef CONFIG_SMP
    105                 if (data0 == (uintptr_t) tlb_shootdown_ipi_recv) {
    106                         tlb_shootdown_ipi_recv();
    107                 }
    108 #endif
    109         } else {
    110                 /*
    111                  * Spurious interrupt.
    112                  */
    113 #ifdef CONFIG_DEBUG
    114                 printf("cpu%u: spurious interrupt (intrcv=%#" PRIx64
    115                     ", data0=%#" PRIx64 ")\n", CPU->id, intrcv, data0);
    116 #endif
    117         }
    118 
    119         membar();
    120         asi_u64_write(ASI_INTR_RECEIVE, 0, 0);
     63        exc_register(n - IVT_FIRST, name, true, handler);
    12164}
    12265
  • kernel/arch/sparc64/src/trap/sun4u/trap_table.S

    rfb150d78 r46c20c8  
    481481        be %xcc, 1f
    482482        nop
    483 0:      ba %xcc, 0b                             ! this is for debugging, if we ever get here
    484         nop                                     ! it will be easy to find
     483        ! this is for debugging, if we ever get here it will be easy to find
     4840:      ba,a %xcc, 0b
    485485
    4864861:
     
    546546
    547547.if NOT(\is_syscall)
    548         ba %xcc, 1f
    549         nop
     548        ba,a %xcc, 1f
    5505490:
    551550        save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
  • kernel/arch/sparc64/src/trap/trap.c

    rfb150d78 r46c20c8  
    4343#include <memstr.h>
    4444#include <debug.h>
    45 #include <arch/types.h>
     45#include <typedefs.h>
    4646#include <arch/drivers/tick.h>
    4747
Note: See TracChangeset for help on using the changeset viewer.