Changeset f2ea5d8 in mainline


Ignore:
Timestamp:
2006-11-17T20:21:25Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f18cc64
Parents:
282f2c9c
Message:

sparc64 code to support physical memory that starts on non-zero addresses.
Still needs to be tested on systems with such setup.

Files:
10 edited

Legend:

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

    r282f2c9c rf2ea5d8  
    11#
    22# Copyright (C) 2006 Martin Decky
     3# Copyright (C) 2006 Jakub Jermar
    34# All rights reserved.
    45#
  • boot/arch/sparc64/loader/asm.h

    r282f2c9c rf2ea5d8  
    11/*
    22 * Copyright (C) 2006 Martin Decky
     3 * Copyright (C) 2006 Jakub Jermar
    34 * All rights reserved.
    45 *
     
    3031#define BOOT_sparc64_ASM_H_
    3132
    32 #define PAGE_SIZE 8192
    33 #define PAGE_WIDTH 13
     33#include "types.h"
     34#include "main.h"
     35
     36#define PAGE_SIZE       8192
     37#define PAGE_WIDTH      13
    3438
    3539#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
    3640
    3741extern void halt(void);
    38 extern void jump_to_kernel(void *entry, int bsp, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
     42extern void jump_to_kernel(void *entry, uint64_t cfg, bootinfo_t *bootinfo,
     43        unsigned int bootinfo_size) __attribute__((noreturn));
    3944
    4045#endif
  • boot/arch/sparc64/loader/main.c

    r282f2c9c rf2ea5d8  
    4747        init_components(components);
    4848
     49        if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
     50                printf("Error: unable to get start of physical memory.\n");
     51                halt();
     52        }
     53
    4954        if (!ofw_memmap(&bootinfo.memmap)) {
    5055                printf("Error: unable to get memory map, halting.\n");
     
    5863       
    5964        printf("\nSystem info\n");
    60         printf(" memory: %dM\n", bootinfo.memmap.total>>20);
     65        printf(" memory: %dM starting at %P\n",
     66                bootinfo.memmap.total >> 20, bootinfo.physmem_start);
    6167
    6268        printf("\nMemory statistics\n");
     
    6672        unsigned int i;
    6773        for (i = 0; i < COMPONENTS; i++)
    68                 printf(" %P: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
     74                printf(" %P: %s image (size %d bytes)\n", components[i].start,
     75                        components[i].name, components[i].size);
    6976
    7077        void * base = (void *) KERNEL_VIRTUAL_ADDRESS;
     
    94101        printf("\nChecking for secondary processors...");
    95102        if (!ofw_cpu())
    96                 printf("Error: unable to get cpu properties\n");
     103                printf("Error: unable to get CPU properties\n");
    97104        printf("done.\n");
    98105
    99106        printf("\nBooting the kernel...\n");
    100         jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, 1, &bootinfo, sizeof(bootinfo));
     107        jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
     108                bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, sizeof(bootinfo));
    101109}
  • boot/arch/sparc64/loader/main.h

    r282f2c9c rf2ea5d8  
    3939#define TASKMAP_MAX_RECORDS 32
    4040
     41#define BSP_PROCESSOR   1
     42#define AP_PROCESSOR    0
     43
    4144typedef struct {
    4245        void *addr;
     
    5053
    5154typedef struct {
     55        uintptr_t physmem_start;
    5256        taskmap_t taskmap;
    5357        memmap_t memmap;
     
    5660} bootinfo_t;
    5761
     62extern bootinfo_t bootinfo;
     63
    5864extern void start(void);
    5965extern void bootstrap(void);
  • boot/arch/sparc64/loader/ofwarch.c

    r282f2c9c rf2ea5d8  
    11/*
    22 * Copyright (C) 2005 Martin Decky
     3 * Copyright (C) 2006 Jakub Jermar
    34 * All rights reserved.
    45 *
     
    3839#include <register.h>
    3940#include "main.h"
     41#include "asm.h"
    4042
    4143void write(const char *str, const int len)
     
    8688                                         * Start secondary processor.
    8789                                         */
    88                                         (void) ofw_call("SUNW,start-cpu", 3, 1, NULL, node, KERNEL_VIRTUAL_ADDRESS, 0);
     90                                        (void) ofw_call("SUNW,start-cpu", 3, 1, NULL, node,
     91                                                 KERNEL_VIRTUAL_ADDRESS,
     92                                                 bootinfo.physmem_start | AP_PROCESSOR);
    8993                                }
    9094                        }
     
    9498        return cpus;
    9599}
     100
     101/** Get physical memory starting address.
     102 *
     103 * @param start Pointer to variable where the physical memory starting
     104 *              address will be stored.
     105 *
     106 * @return Non-zero on succes, zero on failure.
     107 */
     108int ofw_get_physmem_start(uintptr_t *start)
     109{
     110        uint32_t memreg[4];
     111
     112        if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0)
     113                return 0;
     114
     115        *start = (((uint64_t) memreg[0]) << 32) | memreg[1];
     116        return 1;
     117}
     118
  • boot/arch/sparc64/loader/ofwarch.h

    r282f2c9c rf2ea5d8  
    3131
    3232#include "main.h"
     33#include "types.h"
    3334
    3435#define OFW_ADDRESS_CELLS       2
     
    3637
    3738extern int ofw_cpu(void);
     39extern int ofw_get_physmem_start(uintptr_t *start);
    3840
    3941#endif
  • kernel/arch/sparc64/include/boot/boot.h

    r282f2c9c rf2ea5d8  
    7676 */
    7777typedef struct {
     78        uintptr_t physmem_start;
    7879        taskmap_t taskmap;
    7980        memmap_t memmap;
  • kernel/arch/sparc64/include/mm/page.h

    r282f2c9c rf2ea5d8  
    4949#include <genarch/mm/page_ht.h>
    5050
    51 #define KA2PA(x)        ((uintptr_t) (x))
    52 #define PA2KA(x)        ((uintptr_t) (x))
     51extern uintptr_t physmem_base;
     52
     53#define KA2PA(x)        (((uintptr_t) (x)) + physmem_base)
     54#define PA2KA(x)        (((uintptr_t) (x)) - physmem_base)
    5355
    5456union page_address {
  • kernel/arch/sparc64/include/trap/mmu.h

    r282f2c9c rf2ea5d8  
    112112        bz 0f                                           ! page address is zero
    113113
    114         or %g3, (TTE_CV|TTE_CP|TTE_P|TTE_W), %g2        ! 8K pages are the default (encoded as 0)
    115         mov 1, %g3
    116         sllx %g3, TTE_V_SHIFT, %g3
    117         or %g2, %g3, %g2
     114        sethi %hi(kernel_8k_tlb_data_template), %g2
     115        ldx [%g2 + %lo(kernel_8k_tlb_data_template)], %g2
     116        or %g3, %g2, %g2
    118117        stxa %g2, [%g0] ASI_DTLB_DATA_IN_REG            ! identity map the kernel page
    119118        retry
  • kernel/arch/sparc64/src/start.S

    r282f2c9c rf2ea5d8  
    4545.section K_TEXT_START, "ax"
    4646
     47#define BSP_FLAG        1
     48
    4749/*
    48  * Here is where the kernel is passed control
    49  * from the boot loader.
     50 * Here is where the kernel is passed control from the boot loader.
    5051 *
    5152 * The registers are expected to be in this state:
    52  * - %o0 non-zero for the bootstrap processor, zero for application/secondary processors
    53  * - %o1 bootinfo structure address
    54  * - %o2 bootinfo structure size
     53 * - %o0 starting address of physical memory + bootstrap processor flag
     54 *      bits 63...1:    physical memory starting address / 2
     55 *      bit 0:          non-zero on BSP processor, zero on AP processors
     56 * - %o1 bootinfo structure address (BSP only)
     57 * - %o2 bootinfo structure size (BSP only)
    5558 *
    56  * Moreover, we depend on boot having established the
    57  * following environment:
     59 * Moreover, we depend on boot having established the following environment:
    5860 * - TLBs are on
    5961 * - identity mapping for the kernel image
     
    6264.global kernel_image_start
    6365kernel_image_start:
    64         mov %o0, %l7
    65 
     66        mov BSP_FLAG, %l0
     67        and %o0, %l0, %l7                               ! l7 <= bootstrap processor?
     68        andn %o0, %l0, %l6                              ! l6 <= start of physical memory
     69
     70        sethi %hi(physmem_base), %l5
     71        stx %l6, [%l5 + %lo(physmem_base)]
     72
     73        /*
     74         * Get bits 40:13 of physmem_base.
     75         */
     76        sethi %hi(mask_40_13), %l4
     77        sethi %hi(physmem_base_40_13), %l3
     78        ldx [%l4 + %lo(mask_40_13)], %l4
     79        and %l6, %l4, %l5                               ! l5 <= physmem_base[40:13]
     80        stx %l5, [%l3 + %lo(physmem_base_40_13)]
     81
     82        /*
     83         * Prepare kernel 8K TLB data template.
     84         */
     85        sethi %hi(kernel_8k_tlb_data_template), %l4
     86        ldx [%l4 + %lo(kernel_8k_tlb_data_template)], %l3
     87        or %l3, %l5, %l3
     88        stx %l3, [%l4 + %lo(kernel_8k_tlb_data_template)]
     89       
    6690        /*
    6791         * Setup basic runtime environment.
     
    116140#define SET_TLB_DATA(r1, r2, imm) \
    117141        set TTE_CV | TTE_CP | TTE_P | LMA | imm, %r1; \
    118         set PAGESIZE_4M, %r2; \
     142        or %r1, %l5, %r1; \
     143        mov PAGESIZE_4M, %r2; \
    119144        sllx %r2, TTE_SIZE_SHIFT, %r2; \
    120145        or %r1, %r2, %r1; \
     
    303328
    304329.align STACK_ALIGNMENT
    305 .space INITIAL_STACK_SIZE
     330        .space INITIAL_STACK_SIZE
    306331.align STACK_ALIGNMENT
    307332temporary_boot_stack:
    308 .space STACK_WINDOW_SAVE_AREA_SIZE
     333        .space STACK_WINDOW_SAVE_AREA_SIZE
     334
     335
     336.data
     337
     338.align 8
     339.global physmem_base            ! copy of the physical memory base address
     340physmem_base:
     341        .quad 0
     342
     343.global physmem_base_40_13
     344physmem_base_40_13:             ! physmem_base & mask_40_13
     345        .quad 0
     346
     347.global mask_40_13
     348mask_40_13:                     ! constant with bits 40:13 set
     349        .quad (((1 << 41) - 1) & ~((1 << 13) - 1))
     350
     351/*
     352 * This variable is used by the fast_data_MMU_miss trap handler.
     353 * It is initialized to reflect the starting address of physical
     354 * memory.
     355 */
     356.global kernel_8k_tlb_data_template
     357kernel_8k_tlb_data_template:
     358        .quad ((1 << TTE_V_SHIFT) | TTE_CV | TTE_CP | TTE_P | TTE_W)
     359
Note: See TracChangeset for help on using the changeset viewer.