Changeset 9a68b34d in mainline for arch/ppc32


Ignore:
Timestamp:
2006-05-01T19:32:59Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7dd1787
Parents:
16dad032
Message:

PHT Refill handler

Location:
arch/ppc32
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • arch/ppc32/include/mm/tlb.h

    r16dad032 r9a68b34d  
    3333#include <typedefs.h>
    3434
    35 extern void pht_refill(istate_t *istate);
     35#define PHT_BITS        16
     36#define PHT_ORDER       4
     37
     38typedef struct {
     39        unsigned v : 1;          /**< Valid */
     40        unsigned vsid : 24;      /**< Virtual Segment ID */
     41        unsigned h : 1;          /**< Primary/secondary hash */
     42        unsigned api : 6;        /**< Abbreviated Page Index */
     43        unsigned rpn : 20;       /**< Real Page Number */
     44        unsigned reserved0 : 3;
     45        unsigned r : 1;          /**< Reference */
     46        unsigned c : 1;          /**< Change */
     47        unsigned wimg : 4;       /**< Access control */
     48        unsigned reserved1 : 1;
     49        unsigned pp : 2;         /**< Page protection */
     50} phte_t;
     51
     52extern void pht_refill(bool data, istate_t *istate);
    3653
    3754#endif
  • arch/ppc32/src/drivers/cuda.c

    r16dad032 r9a68b34d  
    7272#ifdef CONFIG_POWEROFF
    7373        cuda_packet(CUDA_POWERDOWN);
     74#else
     75        asm volatile (
     76                "b 0\n"
     77        );
    7478#endif
    7579        cpu_sleep();
  • arch/ppc32/src/exception.S

    r16dad032 r9a68b34d  
    139139       
    140140        addis sp, sp, 0x8000
    141         mr r3, sp
     141        li r3, 1
     142        mr r4, sp
    142143        rfi
    143144
     
    160161       
    161162        addis sp, sp, 0x8000
    162         mr r3, sp
     163        li r3, 0
     164        mr r4, sp
    163165        rfi
    164166
  • arch/ppc32/src/mm/tlb.c

    r16dad032 r9a68b34d  
    3030#include <arch/types.h>
    3131#include <mm/tlb.h>
     32#include <mm/frame.h>
    3233#include <mm/page.h>
    3334#include <mm/as.h>
     
    3738
    3839
     40static phte_t *phte;
     41
     42
    3943/** Initialize Page Hash Table.
    4044 *
     
    4448void tlb_arch_init(void)
    4549{
     50        phte_t *physical_phte = (phte_t *) PFN2ADDR(frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC));
     51        phte =(phte_t *) PA2KA((__address) physical_phte);
     52       
     53        ASSERT((__address) physical_phte % (1 << PHT_BITS) == 0);
     54       
     55        memsetb((__address) phte, 1 << PHT_BITS, 0);
     56       
     57        asm volatile (
     58                "mtsdr1 %0\n"
     59                :
     60                : "r" ((__address) physical_phte)
     61        );
    4662}
    4763
     
    104120        if (s)
    105121                sym2 = s;
    106         panic("%X: PHT Refill Exception at %X(%s<-%s)\n", badvaddr, istate->pc, symbol, sym2);
    107 }
    108 
    109 
    110 /** Process Data Storage Interrupt
    111  *
     122        panic("%p: PHT Refill Exception at %p (%s<-%s)\n", badvaddr, istate->pc, symbol, sym2);
     123}
     124
     125
     126/** Process Instruction/Data Storage Interrupt
     127 *
     128 * @param data   True if Data Storage Interrupt.
    112129 * @param istate Interrupted register context.
    113130 *
    114131 */
    115 void pht_refill(istate_t *istate)
     132void pht_refill(bool data, istate_t *istate)
    116133{
    117134        asid_t asid;
    118135        __address badvaddr;
    119136        pte_t *pte;
    120        
    121         __asm__ volatile (
    122                 "mfdar %0\n"
    123                 : "=r" (badvaddr)
    124         );
    125        
     137        __u32 page;
     138        __u32 api;
     139        __u32 vsid;
     140        __u32 hash;
     141        __u32 i;
     142       
     143        if (data) {
     144                asm volatile (
     145                        "mfdar %0\n"
     146                        : "=r" (badvaddr)
     147                );
     148        } else
     149                badvaddr = istate->pc;
     150               
    126151        spinlock_lock(&AS->lock);
    127152        asid = AS->asid;
     
    134159                goto fail;
    135160
    136         /*
    137          * Record access to PTE.
    138          */
     161        /* Record access to PTE */
    139162        pte->a = 1;
    140163       
    141         // FIXME: Insert entry into PHT
    142 
     164        page = ADDR2PFN(badvaddr);
     165        api = (badvaddr >> 22) & 0x3f;
     166        asm volatile (
     167                "mfsrin %0, %1\n"
     168                : "=r" (vsid)
     169                : "r" (badvaddr >> 28)
     170        );
     171       
     172        /* Primary hash (xor) */
     173        hash = ((vsid ^ page) & 0x3ff) << 3;
     174       
     175        /* Find invalid PTE in PTEG */
     176        for (i = 0; i < 8; i++) {
     177                if (!phte[hash + i].v)
     178                        break;
     179        }
     180       
     181        // TODO: Check access/change bits, secondary hash
     182       
     183        if (i == 8)
     184                i = page % 8;
     185       
     186        phte[hash + i].v = 1;
     187        phte[hash + i].vsid = vsid;
     188        phte[hash + i].h = 0;
     189        phte[hash + i].api = api;
     190        phte[hash + i].rpn = pte->pfn;
     191        phte[hash + i].r = 0;
     192        phte[hash + i].c = 0;
     193        phte[hash + i].pp = 2; // FIXME
     194       
    143195        page_table_unlock(AS, true);
    144196        return;
Note: See TracChangeset for help on using the changeset viewer.