Changeset 84060e2 in mainline


Ignore:
Timestamp:
2006-10-09T19:29:42Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8ce8499
Parents:
e4398200
Message:

sparc64 work:

  • hw_map() can now support up to 8M requests
  • CPU stacks are now locked in DTLB of the respective processor
  • kernel in the boot phase no longer relies on the stack provided by OpenFirmware
  • instead of of doing FLUSHW during kernel startup, simply set the window state registers to the wanted state
  • NWINDOW → NWINDOWS
  • Add/fix some comments and copyrights.
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/sparc64/loader/boot.S

    re4398200 r84060e2  
    11#
    22# Copyright (C) 2006 Martin Decky
     3# Copyright (C) 2006 Jakub Jermar
    34# All rights reserved.
    45#
  • kernel/arch/sparc64/include/arch.h

    re4398200 r84060e2  
    4343#define ASI_UPA_CONFIG          0x4a    /** ASI of the UPA_CONFIG register. */
    4444
    45 #define NWINDOW         8               /** Number of register window sets. */
     45#define NWINDOWS                8       /** Number of register window sets. */
    4646
    4747#endif
  • kernel/arch/sparc64/src/cpu/cpu.c

    re4398200 r84060e2  
    4141#include <arch/types.h>
    4242#include <arch/drivers/tick.h>
     43#include <arch/mm/page.h>
     44#include <arch/mm/tlb.h>
     45#include <macros.h>
    4346
    4447/** Perform sparc64 specific initialization of the processor structure for the current processor. */
     
    5356        CPU->arch.mid = upa_config.mid;
    5457       
     58        /*
     59         * Detect processor frequency.
     60         */
    5561        node = ofw_tree_find_child_by_device_type(ofw_tree_lookup("/"), "cpu");
    5662        while (node) {
     
    7177        CPU->arch.clock_frequency = clock_frequency;
    7278        tick_init();
     79       
     80        /*
     81         * Lock CPU stack in DTLB.
     82         */
     83        uintptr_t base = ALIGN_DOWN(config.base, 1<<KERNEL_PAGE_WIDTH);
     84                 
     85        if (!overlaps((uintptr_t) CPU->stack, PAGE_SIZE, base, (1<<KERNEL_PAGE_WIDTH))) {
     86                /*
     87                 * Kernel stack of this processor is not locked in DTLB.
     88                 * First, demap any already existing mappings.
     89                 * Second, create a locked mapping for it.
     90                 */
     91                dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t) CPU->stack);
     92                dtlb_insert_mapping((uintptr_t) CPU->stack, KA2PA(CPU->stack), PAGESIZE_8K, true, true);
     93        }
     94
    7395}
    7496
  • kernel/arch/sparc64/src/mm/page.c

    re4398200 r84060e2  
    120120                { PAGESIZE_512K, 64*PAGE_SIZE, 4 },     /* 2M */
    121121                { PAGESIZE_4M, 0, 1 }                   /* 4M */
     122                { PAGESIZE_4M, 512*PAGE_SIZE, 2 }       /* 8M */
    122123        };
    123124       
    124125        ASSERT(ALIGN_UP(physaddr, PAGE_SIZE) == physaddr);
    125         ASSERT(size <= 4*1024*1024);
     126        ASSERT(size <= 8*1024*1024);
    126127       
    127128        if (size <= FRAME_SIZE)
  • kernel/arch/sparc64/src/mm/tsb.c

    re4398200 r84060e2  
    8888         */
    8989
    90         tsb->tag.invalid = 1;   /* invalidate the entry (tag target has this set to 0 */
     90        tsb->tag.invalid = 1;   /* invalidate the entry (tag target has this set to 0) */
    9191
    9292        write_barrier();
  • kernel/arch/sparc64/src/start.S

    re4398200 r84060e2  
    3030#include <arch/regdef.h>
    3131#include <arch/boot/boot.h>
     32#include <arch/stack.h>
    3233
    3334#include <arch/mm/mmu.h>
     
    5758 * - TLBs are on
    5859 * - identity mapping for the kernel image
    59  * - identity mapping for memory stack
    6060 */
    6161
     
    6868         */
    6969
    70         flushw                                  ! flush all but the active register window
     70        wrpr %g0, NWINDOWS - 2, %cansave                ! set maximum saveable windows
     71        wrpr %g0, 0, %canrestore                ! get rid of windows we will never need again
     72        wrpr %g0, 0, %otherwin                  ! make sure the window state is consistent
     73        wrpr %g0, NWINDOWS - 1, %cleanwin       ! prevent needless clean_window traps for kernel
    7174
    7275        wrpr %g0, 0, %tl                        ! TL = 0, primary context register is used
     
    216219        nop
    217220
     221        /*
     222         * So far, we have not touched the stack.
     223         * It is a good idead to set the kernel stack to a known state now.
     224         */
     225        sethi %hi(temporary_boot_stack), %sp
     226        or %sp, %lo(temporary_boot_stack), %sp
     227        sub %sp, STACK_BIAS, %sp
     228
    218229        sethi %hi(bootinfo), %o0
    219230        call memcpy                             ! copy bootinfo
     
    273284        ba 0b
    274285        nop
     286
     287
     288.section K_DATA_START, "aw", @progbits
     289
     290/*
     291 * Create small stack to be used by the bootstrap processor.
     292 * It is going to be used only for a very limited period of
     293 * time, but we switch to it anyway, just to be sure we are
     294 * properly initialized.
     295 *
     296 * What is important is that this piece of memory is covered
     297 * by the 4M DTLB locked entry and therefore there will be
     298 * no surprises like deadly combinations of spill trap and
     299 * and TLB miss on the stack address.
     300 */
     301
     302#define INITIAL_STACK_SIZE      1024
     303
     304.align STACK_ALIGNMENT
     305.space INITIAL_STACK_SIZE
     306.align STACK_ALIGNMENT
     307temporary_boot_stack:
     308.space STACK_WINDOW_SAVE_AREA_SIZE
  • kernel/arch/sparc64/src/trap/trap_table.S

    re4398200 r84060e2  
    674674        wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(2), %wstate
    675675
    676         wrpr %g0, NWINDOW - 1, %cleanwin        ! prevent unnecessary clean_window exceptions
     676        wrpr %g0, NWINDOWS - 1, %cleanwin       ! prevent unnecessary clean_window exceptions
    677677
    678678        /*
     
    831831        and %g1, TSTATE_CWP_MASK, %l0
    832832        inc %l0
    833         and %l0, NWINDOW - 1, %l0       ! %l0 mod NWINDOW
     833        and %l0, NWINDOWS - 1, %l0      ! %l0 mod NWINDOWS
    834834        rdpr %cwp, %l1
    835835        cmp %l0, %l1
     
    902902        sub %g1, %g2, %g3
    903903        dec %g3
    904         and %g3, NWINDOW - 1, %g3
     904        and %g3, NWINDOWS - 1, %g3
    905905        wrpr %g3, 0, %cwp
    906906
     
    934934
    935935        dec %g3
    936         and %g3, NWINDOW - 1, %g3
     936        and %g3, NWINDOWS - 1, %g3
    937937        wrpr %g3, 0, %cwp                       ! switch to the preceeding window
    938938
     
    947947        wrpr %g1, 0, %cwp
    948948        add %g4, %g2, %g2
    949         cmp %g2, NWINDOW - 2
    950         bg 2f                                   ! fix the CANRESTORE=NWINDOW-1 anomaly
    951         mov NWINDOW - 2, %g1                    ! use dealy slot for both cases
     949        cmp %g2, NWINDOWS - 2
     950        bg 2f                                   ! fix the CANRESTORE=NWINDOWS-1 anomaly
     951        mov NWINDOWS - 2, %g1                   ! use dealy slot for both cases
    952952        sub %g1, %g2, %g1
    953953       
    954954        wrpr %g0, 0, %otherwin
    955         wrpr %g1, 0, %cansave                   ! NWINDOW - 2 - CANRESTORE
     955        wrpr %g1, 0, %cansave                   ! NWINDOWS - 2 - CANRESTORE
    956956        wrpr %g2, 0, %canrestore                ! OTHERWIN + windows in the buffer
    957957        wrpr %g2, 0, %cleanwin                  ! avoid information leak
     
    973973         *
    974974         * instruction trapped and spilled a register window into the userspace
    975          * window buffer, we have just restored NWINDOW - 1 register windows.
     975         * window buffer, we have just restored NWINDOWS - 1 register windows.
    976976         * However, CANRESTORE can be only NWINDOW - 2 at most.
    977977         *
    978          * The solution is to manually switch to (CWP - 1) mod NWINDOW
     978         * The solution is to manually switch to (CWP - 1) mod NWINDOWS
    979979         * and set the window state registers so that:
    980980         *
    981          *      CANRESTORE      = NWINDOW - 2
    982          *      CLEANWIN        = NWINDOW - 2
     981         *      CANRESTORE      = NWINDOWS - 2
     982         *      CLEANWIN        = NWINDOWS - 2
    983983         *      CANSAVE         = 0
    984984         *      OTHERWIN        = 0
     
    994994        rdpr %cwp, %g1
    995995        dec %g1
    996         and %g1, NWINDOW - 1, %g1
     996        and %g1, NWINDOWS - 1, %g1
    997997        wrpr %g1, 0, %cwp                       ! CWP--
    998998       
Note: See TracChangeset for help on using the changeset viewer.