Changeset c2b95d3 in mainline


Ignore:
Timestamp:
2006-01-26T22:52:00Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
849386a
Parents:
2a003d5b
Message:

ia64 work.
Add nice wrappers for thash and ttag instructions.
Add nice wrappers for accessing reion registers and PTA.
Fix set_vhpt_environment().
Allocate and initialize page_ht (a.k.a. VHPT).

Add missing header to sparc64.
Remove excessive header from debug.h.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • arch/ia64/include/asm.h

    r2a003d5b rc2b95d3  
    3030#define __ia64_ASM_H__
    3131
     32#include <config.h>
    3233#include <arch/types.h>
    33 #include <config.h>
    3434#include <arch/register.h>
    3535
  • arch/ia64/include/mm/asid.h

    r2a003d5b rc2b95d3  
    5454#define ASID_OVERFLOW           (RID_OVERFLOW/RIDS_PER_ASID)
    5555
     56/** On ia64, this is no-op. */
    5657#define asid_put_arch(x)
    5758
  • arch/ia64/include/mm/page.h

    r2a003d5b rc2b95d3  
    11/*
    2  * Copyright (C) 2005 Jakub Jermar
     2 * Copyright (C) 2005 - 2006 Jakub Jermar
     3 * Copyright (C) 2006 Jakub Vana
    34 * All rights reserved.
    45 *
     
    3031#define __ia64_PAGE_H__
    3132
     33#include <arch/mm/frame.h>
     34#include <genarch/mm/page_ht.h>
    3235#include <arch/types.h>
    33 #include <arch/mm/frame.h>
     36#include <typedefs.h>
     37#include <debug.h>
    3438
    3539#define PAGE_SIZE       FRAME_SIZE
     
    5256#define HT_SET_RECORD_ARCH(t, page, asid, frame, flags)
    5357
    54 #define REGION_RID_MAIN 0
    55 #define REGION_RID_FIRST_INVALID 16
    56 #define REGION_REGISTERS 8
    57 
    58 #define VHPT_WIDTH 16         /*64kB*/
    59 #define VHPT_SIZE (1<<VHPT_WIDTH)
    60 
    61 #define VHPT_BASE 0           /* Must be aligned to VHPT_SIZE */
    62 
    63 struct VHPT_tag_info
    64 {
    65         unsigned long long tag       :63;
    66         unsigned           ti        : 1;
    67 }__attribute__ ((packed));
    68 
    69 union VHPT_tag
    70 {
    71         struct VHPT_tag_info tag_info;
    72         unsigned             tag_word;
     58#define VRN_KERNEL                      0
     59#define REGION_REGISTERS                8
     60
     61#define VHPT_WIDTH                      20              /* 1M */
     62#define VHPT_SIZE                       (1<<VHPT_WIDTH)
     63
     64#define VHPT_BASE                       page_ht         /* Must be aligned to VHPT_SIZE */
     65
     66struct vhpt_tag_info {
     67        unsigned long long tag : 63;
     68        unsigned ti : 1;
     69} __attribute__ ((packed));
     70
     71union vhpt_tag {
     72        struct vhpt_tag_info tag_info;
     73        unsigned tag_word;
    7374};
    7475
    75 struct VHPT_entry_present
    76 {
    77 
     76struct vhpt_entry_present {
    7877        /* Word 0 */
    79         unsigned p              : 1;
    80         unsigned rv0            : 1;
    81         unsigned ma             : 3;
    82         unsigned a              : 1;
    83         unsigned d              : 1;
    84         unsigned pl             : 2;
    85         unsigned ar             : 3;
    86         unsigned long long ppn  :38;
    87         unsigned rv1            : 2;
    88         unsigned ed             : 1;
    89         unsigned ig1            :11;
     78        unsigned p : 1;
     79        unsigned : 1;
     80        unsigned ma : 3;
     81        unsigned a : 1;
     82        unsigned d : 1;
     83        unsigned pl : 2;
     84        unsigned ar : 3;
     85        unsigned long long ppn : 38;
     86        unsigned : 2;
     87        unsigned ed : 1;
     88        unsigned ig1 : 11;
    9089       
    9190        /* Word 1 */
    92         unsigned rv2            : 2;
    93         unsigned ps             : 6;
    94         unsigned key            :24;
    95         unsigned rv3            :32;
     91        unsigned : 2;
     92        unsigned ps : 6;
     93        unsigned key : 24;
     94        unsigned : 32;
    9695       
    9796        /* Word 2 */
    98         union VHPT_tag tag;       /*This data is here as union because I'm not sure if anybody nead access to areas ti and tag in VHPT entry*/
    99                             /* But I'm almost sure we nead access to whole word so there are both possibilities*/
     97        union vhpt_tag tag;
     98       
    10099        /* Word 3 */                                                                                                   
    101         unsigned long long next :64; /* This ignored field will be (in my hopes ;-) ) used as pointer in link list of entries with same hash value*/
    102        
    103 }__attribute__ ((packed));
    104 
    105 struct VHPT_entry_not_present
    106 {
     100        unsigned long long next : 64;   /**< Collision chain next pointer. */
     101} __attribute__ ((packed));
     102
     103struct vhpt_entry_not_present {
    107104        /* Word 0 */
    108         unsigned p              : 1;
    109         unsigned long long ig0  :52;
    110         unsigned ig1            :11;
     105        unsigned p : 1;
     106        unsigned long long ig0 : 52;
     107        unsigned ig1 : 11;
    111108       
    112109        /* Word 1 */
    113         unsigned rv2            : 2;
    114         unsigned ps             : 6;
    115         unsigned long long ig2  :56;
    116 
    117        
     110        unsigned : 2;
     111        unsigned ps : 6;
     112        unsigned long long ig2 : 56;
     113
    118114        /* Word 2 */
    119         union VHPT_tag tag;       /*This data is here as union because I'm not sure if anybody nead access to areas ti and tag in VHPT entry*/
    120                             /* But I'm almost sure we nead access to whole word so there are both possibilities*/
     115        union vhpt_tag tag;
     116       
    121117        /* Word 3 */                                                                                                   
    122         unsigned long long next :64; /* This ignored field will be (in my hopes ;-) ) used as pointer in link list of entries with same hash value*/
    123        
    124 }__attribute__ ((packed));
    125 
    126 typedef union VHPT_entry
    127 {
    128         struct VHPT_entry_present        present;
    129         struct VHPT_entry_not_present    not_present;
    130 }VHPT_entry;
     118        unsigned long long next : 64;   /**< Collision chain next pointer. */
     119       
     120} __attribute__ ((packed));
     121
     122typedef union vhpt_entry {
     123        struct vhpt_entry_present present;
     124        struct vhpt_entry_not_present not_present;
     125} vhpt_entry;
     126
     127struct region_register_map {
     128        unsigned ve : 1;
     129        unsigned : 1;
     130        unsigned ps : 6;
     131        unsigned rid : 24;
     132        unsigned : 32;
     133} __attribute__ ((packed));
     134
     135typedef union region_register {
     136        struct region_register_map map;
     137        unsigned long long word;
     138} region_register;
     139
     140struct pta_register_map {
     141        unsigned ve : 1;
     142        unsigned : 1;
     143        unsigned size : 6;
     144        unsigned vf : 1;
     145        unsigned : 6;
     146        unsigned long long base : 49;
     147} __attribute__ ((packed));
     148
     149typedef union pta_register {
     150        struct pta_register_map map;
     151        __u64 word;
     152} pta_register;
     153
     154/** Return Translation Hashed Entry Address.
     155 *
     156 * VRN bits are used to read RID (ASID) from one
     157 * of the eight region registers registers.
     158 *
     159 * @param va Virtual address including VRN bits.
     160 *
     161 * @return Address of the head of VHPT collision chain.
     162 */
     163static inline __u64 thash(__u64 va)
     164{
     165        __u64 ret;
     166
     167        __asm__ volatile ("thash %0 = %1\n" : "=r" (ret) : "r" (va));
     168
     169        return ret;
     170}
     171
     172/** Return Translation Hashed Entry Tag.
     173 *
     174 * VRN bits are used to read RID (ASID) from one
     175 * of the eight region registers.
     176 *
     177 * @param va Virtual address including VRN bits.
     178 *
     179 * @return The unique tag for VPN and RID in the collision chain returned by thash().
     180 */
     181static inline __u64 ttag(__u64 va)
     182{
     183        __u64 ret;
     184
     185        __asm__ volatile ("ttag %0 = %1\n" : "=r" (ret) : "r" (va));
     186
     187        return ret;
     188}
     189
     190/** Read Region Register.
     191 *
     192 * @param i Region register index.
     193 *
     194 * @return Current contents of rr[i].
     195 */
     196static inline __u64 rr_read(index_t i)
     197{
     198        __u64 ret;
     199       
     200//      ASSERT(i < REGION_REGISTERS);
     201        __asm__ volatile ("mov %0 = rr[%1]\n" : "=r" (ret) : "r" (i));
     202       
     203        return ret;
     204}
     205
     206
     207/** Write Region Register.
     208 *
     209 * @param i Region register index.
     210 * @param v Value to be written to rr[i].
     211 */
     212static inline void rr_write(index_t i, __u64 v)
     213{
     214//      ASSERT(i < REGION_REGISTERS);
     215        __asm__ volatile ("mov rr[%0] = %1\n" : : "r" (i), "r" (v));
     216}
     217 
     218/** Read Page Table Register.
     219 *
     220 * @return Current value stored in PTA.
     221 */
     222static inline __u64 pta_read(void)
     223{
     224        __u64 ret;
     225       
     226        __asm__ volatile ("mov %0 = cr.pta\n" : "=r" (ret));
     227       
     228        return ret;
     229}
     230
     231/** Write Page Table Register.
     232 *
     233 * @param v New value to be stored in PTA.
     234 */
     235static inline void pta_write(__u64 v)
     236{
     237        __asm__ volatile ("mov cr.pta = %0\n" : : "r" (v));
     238}
    131239
    132240extern void page_arch_init(void);
    133241
    134 
    135 struct region_register_map
    136 {
    137   unsigned ve            : 1;
    138         unsigned r0            : 1;
    139         unsigned ps            : 6;
    140         unsigned rid           :24;
    141         unsigned r1            :32;
    142 }__attribute__ ((packed));
    143 
    144 
    145 typedef union region_register
    146 {
    147         struct region_register_map   map;
    148         unsigned long long           word;
    149 }region_register;
    150 
    151 struct PTA_register_map
    152 {
    153   unsigned ve            : 1;
    154         unsigned r0            : 1;
    155         unsigned size          : 6;
    156         unsigned vf            : 1;
    157         unsigned r1            : 6;
    158         unsigned long long base:49;
    159 }__attribute__ ((packed));
    160 
    161 
    162 typedef union PTA_register
    163 {
    164         struct PTA_register_map   map;
    165         unsigned long long        word;
    166 }PTA_register;
    167 
    168 
    169242#endif
  • arch/ia64/include/types.h

    r2a003d5b rc2b95d3  
    3737typedef signed long __s64;
    3838
    39 
    40 
    4139typedef unsigned char __u8;
    4240typedef unsigned short __u16;
     
    5048typedef __u64 __native;
    5149
    52 typedef __u64 pte_t;
     50typedef union vhpt_entry pte_t;
    5351
    5452#endif
  • arch/ia64/src/mm/page.c

    r2a003d5b rc2b95d3  
    11/*
    22 * Copyright (C) 2006 Jakub Jermar
     3 * Copyright (C) 2006 Jakub Vana
    34 * All rights reserved.
    45 *
     
    2829
    2930#include <arch/mm/page.h>
     31#include <genarch/mm/page_ht.h>
     32#include <mm/asid.h>
    3033#include <arch/types.h>
    31 #include <genarch/mm/page_ht.h>
    3234#include <print.h>
    3335#include <mm/page.h>
     36#include <mm/frame.h>
    3437#include <config.h>
    3538#include <panic.h>
    3639#include <arch/asm.h>
     40#include <arch/barrier.h>
    3741
    38 __u64 thash(__u64 va);
    39 __u64 thash(__u64 va)
     42/** Initialize VHPT and region registers. */
     43static void set_vhpt_environment(void)
    4044{
    41         __u64 ret;
    42         asm
    43         (
    44                 "thash %0=%1;;"
    45                 :"=r"(ret)
    46                 :"r" (va)
    47         );
     45        region_register rr;
     46        pta_register pta;       
     47        int i;
    4848       
    49         return ret;
     49        /*
     50         * First set up kernel region register.
     51         */
     52        rr.word = rr_read(VRN_KERNEL);
     53        rr.map.ve = 0;                  /* disable VHPT walker */
     54        rr.map.ps = PAGE_WIDTH;
     55        rr.map.rid = ASID_KERNEL;
     56        rr_write(VRN_KERNEL, rr.word);
     57        srlz_i();
     58        srlz_d();
     59       
     60        /*
     61         * And invalidate the rest of region register.
     62         */
     63        for(i = 0; i < REGION_REGISTERS; i++) {
     64                /* skip kernel rr */
     65                if (i == VRN_KERNEL)
     66                        continue;
     67       
     68                rr.word == rr_read(i);
     69                rr.map.rid = ASID_INVALID;
     70                rr_write(i, rr.word);
     71                srlz_i();
     72                srlz_d();
     73        }
     74
     75        /*
     76         * Allocate VHPT and invalidate all its entries.
     77         */
     78        page_ht = (pte_t *) frame_alloc(FRAME_KA, VHPT_WIDTH - FRAME_WIDTH, NULL);
     79        ht_invalidate_all();
     80       
     81        /*
     82         * Set up PTA register.
     83         */
     84        pta.word = pta_read();
     85        pta.map.ve = 0;                   /* disable VHPT walker */
     86        pta.map.vf = 1;                   /* large entry format */
     87        pta.map.size = VHPT_WIDTH;
     88        pta.map.base = (__address) page_ht;
     89        pta_write(pta.word);
     90        srlz_i();
     91        srlz_d();
    5092}
    5193
    52 __u64 ttag(__u64 va);
    53 __u64 ttag(__u64 va)
    54 {
    55         __u64 ret;
    56         asm
    57         (
    58                 "ttag %0=%1;;"
    59                 :"=r"(ret)
    60                 :"r" (va)
    61         );
    62        
    63         return ret;
    64 }
    65 
    66 
    67 static void set_VHPT_environment(void)
    68 {
    69        
    70 
    71         /*
    72         TODO:
    73         */
    74        
    75         int i;
    76        
    77         /* First set up REGION REGISTER 0 */
    78        
    79         region_register rr;
    80         rr.map.ve=0;                  /*Disable Walker*/
    81         rr.map.ps=PAGE_WIDTH;
    82         rr.map.rid=REGION_RID_MAIN;
    83        
    84         asm
    85         (
    86                 ";;\n"
    87                 "srlz.i;;\n"
    88                 "srlz.d;;\n"
    89                 "{mov rr[r0]=%0};;\n"
    90                 "srlz.i;;\n"
    91                 "srlz.d;;\n"
    92                 ";;\n"
    93                 :
    94                 :"r"(rr.word)
    95         );
    96 
    97                        
    98         /* And Invalidate the rest of REGION REGISTERS */
    99         for(i=1;i<REGION_REGISTERS;i++)
    100         {
    101                 rr.map.rid=REGION_RID_FIRST_INVALID+i-1;
    102                 asm
    103                 (
    104                         ";;\n"
    105 /*                      "mov r8=%1;;\n"*/
    106 /*                      "mov rr[r8]=%0;;\n"*/
    107                         "srlz.i;;\n"
    108                         "srlz.d;;\n"
    109                         "{mov rr[%1]=%0};;\n"
    110                         "srlz.i;;\n"
    111                         "srlz.d;;\n"
    112                         :
    113                         :"r"(rr.word),"r"(i)
    114                         :"r8"
    115                 );
    116         };
    117 
    118        
    119 
    120         PTA_register pta;
    121         pta.map.ve=0;                   /*Disable Walker*/
    122         pta.map.vf=1;                   /*Large entry format*/
    123         pta.map.size=VHPT_WIDTH;
    124         pta.map.base=VHPT_BASE;
    125        
    126         return ;
    127        
    128         printf("pta struct size:%d\n",sizeof(pta));
    129        
    130         /*Write PTA*/
    131         asm
    132         (
    133                 "mov cr8=%0;;"
    134                 :
    135                 :"r"(pta.word)
    136         );     
    137         return ;
    138 }       
    139 
    140 
     94/** Initialize ia64 virtual address translation subsystem. */
    14195void page_arch_init(void)
    14296{
    14397        page_operations = &page_ht_operations;
    14498        pk_disable();
    145         set_VHPT_environment();
     99        set_vhpt_environment();
    146100}
  • arch/sparc64/src/trap/interrupt.c

    r2a003d5b rc2b95d3  
    2929#include <arch/interrupt.h>
    3030#include <interrupt.h>
     31#include <arch/types.h>
    3132#include <debug.h>
    3233
  • generic/include/debug.h

    r2a003d5b rc2b95d3  
    3232#include <panic.h>
    3333#include <arch/debug.h>
    34 #include <arch.h>
    3534
    3635#define CALLER       ((__address)__builtin_return_address(0))
Note: See TracChangeset for help on using the changeset viewer.