Changeset 0867321 in mainline


Ignore:
Timestamp:
2009-02-02T18:06:15Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cdda403
Parents:
7b187ef
Message:

very experimental TLB refill for ppc32

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/ppc32/loader/regname.h

    r7b187ef r0867321  
    209209
    210210/* MSR bits */
    211 #define msr_ir  (1 << 4)
    212 #define msr_dr  (1 << 5)
     211#define msr_dr  (1 << 4)
     212#define msr_ir  (1 << 5)
     213#define msr_pr  (1 << 14)
    213214#define msr_ee  (1 << 15)
    214215
    215216/* HID0 bits */
     217#define hid0_sten       (1 << 24)
    216218#define hid0_ice        (1 << 15)
    217219#define hid0_dce        (1 << 14)
    218220#define hid0_icfi       (1 << 11)
    219221#define hid0_dci        (1 << 10)
    220 #define hid0_sten       (1 << 7)
    221222
    222223#endif
  • kernel/arch/ppc32/include/asm/regname.h

    r7b187ef r0867321  
    212212#define dbat3u  542
    213213#define dbat3l  543
     214#define tlbmiss 980
     215#define ptehi   981
     216#define ptelo   982
    214217#define hid0    1008
    215218
     
    221224
    222225/* HID0 bits */
     226#define hid0_sten       (1 << 24)
    223227#define hid0_ice        (1 << 15)
    224228#define hid0_dce        (1 << 14)
    225229#define hid0_icfi       (1 << 11)
    226230#define hid0_dci        (1 << 10)
    227 #define hid0_sten       (1 << 7)
    228231
    229232#endif
  • kernel/arch/ppc32/include/mm/tlb.h

    r7b187ef r0867321  
    5959} phte_t;
    6060
     61typedef struct {
     62        unsigned v : 1;
     63        unsigned vsid : 24;
     64        unsigned reserved0 : 1;
     65        unsigned api : 6;
     66} ptehi_t;
     67
     68typedef struct {
     69        unsigned rpn : 20;
     70        unsigned xpn : 3;
     71        unsigned reserved0 : 1;
     72        unsigned c : 1;
     73        unsigned wimg : 4;
     74        unsigned x : 1;
     75        unsigned pp : 2;
     76} ptelo_t;
     77
     78extern void pht_init(void);
    6179extern void pht_refill(int n, istate_t *istate);
    6280extern bool pht_refill_real(int n, istate_t *istate) __attribute__ ((section("K_UNMAPPED_TEXT_START")));
    63 extern void pht_init(void);
     81extern void tlb_refill_real(int n, uint32_t tlbmiss, ptehi_t ptehi, ptelo_t ptelo, istate_t *istate) __attribute__ ((section("K_UNMAPPED_TEXT_START")));
    6482
    6583#endif
  • kernel/arch/ppc32/src/exception.S

    r7b187ef r0867321  
    209209.global exc_syscall
    210210exc_syscall:
    211         CONTEXT_STORE   
     211        CONTEXT_STORE
    212212       
    213213        b jump_to_kernel_syscall
     
    220220        li r3, 12
    221221        b jump_to_kernel
     222
     223.org 0x1000
     224.global exc_itlb_miss
     225exc_itlb_miss:
     226        CONTEXT_STORE
     227       
     228        b tlb_miss
     229
     230.org 0x1100
     231.global exc_dtlb_miss_load
     232exc_dtlb_miss_load:
     233        CONTEXT_STORE
     234       
     235        b tlb_miss
     236
     237.org 0x1200
     238.global exc_dtlb_miss_store
     239exc_dtlb_miss_store:
     240        CONTEXT_STORE
     241       
     242        b tlb_miss
    222243
    223244.org 0x4000
     
    245266        li r3, 3
    246267        b jump_to_kernel
     268
     269tlb_miss:
     270        li r3, 16
     271        mfspr r4, tlbmiss
     272        mfspr r5, ptehi
     273        mfspr r6, ptelo
     274        mr r7, sp
     275        addi r7, r7, 20
     276       
     277        bl tlb_refill_real
     278        b iret_real
    247279
    248280jump_to_kernel:
  • kernel/arch/ppc32/src/mm/tlb.c

    r7b187ef r0867321  
    228228
    229229
    230 /** Process Instruction/Data Storage Interrupt
    231  *
    232  * @param n             Interrupt vector number.
    233  * @param istate        Interrupted register context.
     230/** Process Instruction/Data Storage Exception
     231 *
     232 * @param n      Exception vector number.
     233 * @param istate Interrupted register context.
    234234 *
    235235 */
     
    288288
    289289
    290 /** Process Instruction/Data Storage Interrupt in Real Mode
    291  *
    292  * @param n             Interrupt vector number.
    293  * @param istate        Interrupted register context.
     290/** Process Instruction/Data Storage Exception in Real Mode
     291 *
     292 * @param n      Exception vector number.
     293 * @param istate Interrupted register context.
    294294 *
    295295 */
     
    406406       
    407407        return true;
     408}
     409
     410
     411/** Process ITLB/DTLB Miss Exception in Real Mode
     412 *
     413 *
     414 */
     415void tlb_refill_real(int n, uint32_t tlbmiss, ptehi_t ptehi, ptelo_t ptelo, istate_t *istate)
     416{
     417        uint32_t badvaddr = tlbmiss & 0xfffffffc;
     418       
     419        uint32_t physmem;
     420        asm volatile (
     421                "mfsprg3 %0\n"
     422                : "=r" (physmem)
     423        );
     424       
     425        if ((badvaddr < PA2KA(0)) || (badvaddr >= PA2KA(physmem)))
     426                return; // FIXME
     427       
     428        ptelo.rpn = KA2PA(badvaddr) >> 12;
     429        ptelo.wimg = 0;
     430        ptelo.pp = 2; // FIXME
     431       
     432        uint32_t index = 0;
     433        asm volatile (
     434                "mtspr 981, %0\n"
     435                "mtspr 982, %1\n"
     436                "tlbld %2\n"
     437                "tlbli %2\n"
     438                : "=r" (index)
     439                : "r" (ptehi),
     440                  "r" (ptelo)
     441        );
    408442}
    409443
Note: See TracChangeset for help on using the changeset viewer.