Changeset b4655da in mainline


Ignore:
Timestamp:
2009-11-06T16:59:40Z (15 years ago)
Author:
Pavel Rimsky <pavel@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
74cbac7d
Parents:
66e08d02
Message:

TLB & CPU init implemented, now the code reaches creation of the first thread.

Location:
kernel/arch/sparc64
Files:
2 deleted
6 edited

Legend:

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

    r66e08d02 rb4655da  
    6464
    6565ARCH_SOURCES = \
    66         arch/$(KARCH)/src/cpu/cpu.c \
     66        arch/$(KARCH)/src/cpu/$(USARCH)/cpu.c \
    6767        arch/$(KARCH)/src/asm.S \
    6868        arch/$(KARCH)/src/panic.S \
     
    9494ifeq ($(USARCH),sun4v)
    9595        ARCH_SOURCES += \
    96                 arch/$(KARCH)/src/drivers/niagara.c
     96                arch/$(KARCH)/src/drivers/niagara.c \
     97                arch/$(KARCH)/src/sun4v/md.c
    9798endif
    9899
     
    110111ifeq ($(CONFIG_TSB),y)
    111112        ARCH_SOURCES += \
    112                 arch/$(KARCH)/src/mm/tsb.c
     113                arch/$(KARCH)/src/mm/$(USARCH)/tsb.c
    113114endif
  • kernel/arch/sparc64/include/drivers/tick.h

    r66e08d02 rb4655da  
    3636#define KERN_sparc64_TICK_H_
    3737
     38#include <arch/asm.h>
    3839#include <arch/interrupt.h>
     40
     41/* mask of the "counter" field of the Tick register */
     42#define TICK_COUNTER_MASK       (~(1l << 63))
    3943
    4044extern void tick_init(void);
    4145extern void tick_interrupt(int n, istate_t *istate);
     46
     47/**
     48 * Reads the Tick register counter.
     49 */
     50static inline uint64_t tick_counter_read(void)
     51{
     52        return TICK_COUNTER_MASK & tick_read();
     53}
    4254
    4355#endif
  • kernel/arch/sparc64/include/mm/tte.h

    r66e08d02 rb4655da  
    3636#define KERN_sparc64_TTE_H_
    3737
    38 #define TTE_G           (1 << 0)
    39 #define TTE_W           (1 << 1)
    40 #define TTE_P           (1 << 2)
    41 #define TTE_E           (1 << 3)
    42 #define TTE_CV          (1 << 4)
    43 #define TTE_CP          (1 << 5)
    44 #define TTE_L           (1 << 6)
    45 
    46 #define TTE_V_SHIFT     63
    47 #define TTE_SIZE_SHIFT  61
    48 
    49 #ifndef __ASM__
    50 
    51 #include <arch/types.h>
    52 
    53 /* TTE tag's VA_tag field contains bits <63:VA_TAG_PAGE_SHIFT> of the VA */
    54 #define VA_TAG_PAGE_SHIFT       22
    55 
    56 /** Translation Table Entry - Tag. */
    57 union tte_tag {
    58         uint64_t value;
    59         struct {
    60                 unsigned g : 1;         /**< Global. */
    61                 unsigned : 2;           /**< Reserved. */
    62                 unsigned context : 13;  /**< Context identifier. */
    63                 unsigned : 6;           /**< Reserved. */
    64                 uint64_t va_tag : 42;   /**< Virtual Address Tag, bits 63:22. */
    65         } __attribute__ ((packed));
    66 };
    67 
    68 typedef union tte_tag tte_tag_t;
    69 
    70 /** Translation Table Entry - Data. */
    71 union tte_data {
    72         uint64_t value;
    73         struct {
    74                 unsigned v : 1;         /**< Valid. */
    75                 unsigned size : 2;      /**< Page size of this entry. */
    76                 unsigned nfo : 1;       /**< No-Fault-Only. */
    77                 unsigned ie : 1;        /**< Invert Endianness. */
    78                 unsigned soft2 : 9;     /**< Software defined field. */
    79 #if defined (US)
    80                 unsigned diag : 9;      /**< Diagnostic data. */
    81                 unsigned pfn : 28;      /**< Physical Address bits, bits 40:13. */
    82 #elif defined (US3)
    83                 unsigned : 7;           /**< Reserved. */
    84                 unsigned pfn : 30;      /**< Physical Address bits, bits 42:13 */
     38#if defined (SUN4U)
     39#include <arch/mm/sun4u/tte.h>
     40#elif defined (SUN4V)
     41#include <arch/mm/sun4v/tte.h>
    8542#endif
    86                 unsigned soft : 6;      /**< Software defined field. */
    87                 unsigned l : 1;         /**< Lock. */
    88                 unsigned cp : 1;        /**< Cacheable in physically indexed cache. */
    89                 unsigned cv : 1;        /**< Cacheable in virtually indexed cache. */
    90                 unsigned e : 1;         /**< Side-effect. */
    91                 unsigned p : 1;         /**< Privileged. */
    92                 unsigned w : 1;         /**< Writable. */
    93                 unsigned g : 1;         /**< Global. */
    94         } __attribute__ ((packed));
    95 };
    96 
    97 typedef union tte_data tte_data_t;
    98 
    99 #endif /* !def __ASM__ */
    10043
    10144#endif
  • kernel/arch/sparc64/src/drivers/tick.c

    r66e08d02 rb4655da  
    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;
     
    111111         * overflow only in 146 years.
    112112         */
    113         drift = tick_read() - CPU->arch.next_tick_cmpr;
     113        drift = tick_counter_read() - CPU->arch.next_tick_cmpr;
    114114        while (drift > CPU->arch.clock_frequency / HZ) {
    115115                drift -= CPU->arch.clock_frequency / HZ;
    116116                CPU->missed_clock_ticks++;
    117117        }
    118         CPU->arch.next_tick_cmpr = tick_read() +
     118        CPU->arch.next_tick_cmpr = tick_counter_read() +
    119119            (CPU->arch.clock_frequency / HZ) - drift;
    120120        tick_compare_write(CPU->arch.next_tick_cmpr);
  • kernel/arch/sparc64/src/mm/sun4v/tlb.c

    r66e08d02 rb4655da  
    3737#include <mm/as.h>
    3838#include <mm/asid.h>
     39#include <arch/sun4v/hypercall.h>
    3940#include <arch/mm/frame.h>
    4041#include <arch/mm/page.h>
    41 #include <arch/mm/mmu.h>
     42#include <arch/mm/tte.h>
     43#include <arch/mm/tlb.h>
    4244#include <arch/interrupt.h>
    4345#include <interrupt.h>
     
    7072};
    7173
     74/** Invalidate all unlocked ITLB and DTLB entries. */
     75void tlb_invalidate_all(void)
     76{
     77        uint64_t errno =  __hypercall_fast3(MMU_DEMAP_ALL, 0, 0,
     78                MMU_FLAG_DTLB | MMU_FLAG_ITLB);
     79        if (errno != EOK) {
     80                panic("Error code = %d.\n", errno);
     81        }
     82}
     83
    7284void tlb_arch_init(void)
    7385{
    74         /*
    75          * Invalidate all non-locked DTLB and ITLB entries.
    76          */
    77         //MH
    78         //tlb_invalidate_all();
    79 
    80         /*
    81          * Clear both SFSRs.
    82          */
    83         //MH
    84         //dtlb_sfsr_write(0);
    85         //itlb_sfsr_write(0);
     86        tlb_invalidate_all();
    8687}
    8788
     
    9798    bool locked, bool cacheable)
    9899{
     100#if 0
    99101        tlb_tag_access_reg_t tag;
    100102        tlb_data_t data;
     
    124126
    125127        dtlb_data_in_write(data.value);
     128#endif
    126129}
    127130
     
    135138void dtlb_pte_copy(pte_t *t, size_t index, bool ro)
    136139{
     140#if 0
    137141        tlb_tag_access_reg_t tag;
    138142        tlb_data_t data;
     
    163167
    164168        dtlb_data_in_write(data.value);
     169#endif
    165170}
    166171
     
    172177void itlb_pte_copy(pte_t *t, size_t index)
    173178{
     179#if 0
    174180        tlb_tag_access_reg_t tag;
    175181        tlb_data_t data;
     
    197203       
    198204        itlb_data_in_write(data.value);
     205#endif
    199206}
    200207
     
    362369static void print_tlb_entry(int i, tlb_tag_read_reg_t t, tlb_data_t d)
    363370{
     371#if 0
    364372        printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
    365373            "ie=%d, soft2=%#x, pfn=%#x, soft=%#x, l=%d, "
     
    367375            t.context, d.v, d.size, d.nfo, d.ie, d.soft2,
    368376            d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
     377#endif
    369378}
    370379
     
    502511}
    503512
    504 #if defined (US)
    505 /** Invalidate all unlocked ITLB and DTLB entries. */
    506 void tlb_invalidate_all(void)
    507 {
    508         int i;
    509        
    510         /*
    511          * Walk all ITLB and DTLB entries and remove all unlocked mappings.
    512          *
    513          * The kernel doesn't use global mappings so any locked global mappings
    514          * found must have been created by someone else. Their only purpose now
    515          * is to collide with proper mappings. Invalidate immediately. It should
    516          * be safe to invalidate them as late as now.
    517          */
    518 
    519         tlb_data_t d;
    520         tlb_tag_read_reg_t t;
    521 
    522         for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
    523                 d.value = itlb_data_access_read(i);
    524                 if (!d.l || d.g) {
    525                         t.value = itlb_tag_read_read(i);
    526                         d.v = false;
    527                         itlb_tag_access_write(t.value);
    528                         itlb_data_access_write(i, d.value);
    529                 }
    530         }
    531 
    532         for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
    533                 d.value = dtlb_data_access_read(i);
    534                 if (!d.l || d.g) {
    535                         t.value = dtlb_tag_read_read(i);
    536                         d.v = false;
    537                         dtlb_tag_access_write(t.value);
    538                         dtlb_data_access_write(i, d.value);
    539                 }
    540         }
    541 
    542 }
    543 
    544 #elif defined (US3)
    545 
    546 /** Invalidate all unlocked ITLB and DTLB entries. */
    547 void tlb_invalidate_all(void)
    548 {
    549         itlb_demap(TLB_DEMAP_ALL, 0, 0);
    550         dtlb_demap(TLB_DEMAP_ALL, 0, 0);
    551 }
    552 
    553 #endif
    554 
    555513/** Invalidate all ITLB and DTLB entries that belong to specified ASID
    556514 * (Context).
  • kernel/arch/sparc64/src/sun4v/sparc64.c

    r66e08d02 rb4655da  
    3838#include <arch/trap/trap.h>
    3939#include <arch/console.h>
     40#include <arch/sun4v/md.h>
    4041#include <console/console.h>
    4142#include <arch/boot/boot.h>
     
    6869                    bootinfo.taskmap.tasks[i].name);
    6970        }
     71
     72        md_init();
    7073}
    7174
Note: See TracChangeset for help on using the changeset viewer.