Changeset 9a68b34d in mainline


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

Files:
5 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;
  • generic/src/mm/frame.c

    r16dad032 r9a68b34d  
    435435 *
    436436 * Assume zone is locked
    437  * Panics, if allocation is impossible.
     437 * Panics if allocation is impossible.
     438 *
     439 * @param zone  Zone to allocate from.
     440 * @param order Allocate exactly 2^order frames.
    438441 *
    439442 * @return Frame index in zone
    440  */
    441 static pfn_t zone_frame_alloc(zone_t *zone,__u8 order)
     443 *
     444 */
     445static pfn_t zone_frame_alloc(zone_t *zone, __u8 order)
    442446{
    443447        pfn_t v;
     
    892896/** Allocate power-of-two frames of physical memory.
    893897 *
    894  * @param flags Flags for host zone selection and address processing.
    895  * @param order Allocate exactly 2^order frames.
    896  * @param pzone Preferred zone
     898 * @param order  Allocate exactly 2^order frames.
     899 * @param flags  Flags for host zone selection and address processing.
     900 * @param status Allocation status (FRAME_OK on success), unused if NULL.
     901 * @param pzone  Preferred zone
    897902 *
    898903 * @return Allocated frame.
    899  */
    900 pfn_t frame_alloc_generic(__u8 order, int flags, int * status, int *pzone)
     904 *
     905 */
     906pfn_t frame_alloc_generic(__u8 order, int flags, int *status, int *pzone)
    901907{
    902908        ipl_t ipl;
     
    907913loop:
    908914        ipl = interrupts_disable();
     915       
    909916        /*
    910917         * First, find suitable frame zone.
    911918         */
    912         zone = find_free_zone_lock(order,pzone);
     919        zone = find_free_zone_lock(order, pzone);
     920       
    913921        /* If no memory, reclaim some slab memory,
    914922           if it does not help, reclaim all */
     
    916924                freed = slab_reclaim(0);
    917925                if (freed)
    918                         zone = find_free_zone_lock(order,pzone);
     926                        zone = find_free_zone_lock(order, pzone);
    919927                if (!zone) {
    920928                        freed = slab_reclaim(SLAB_RECLAIM_ALL);
    921929                        if (freed)
    922                                 zone = find_free_zone_lock(order,pzone);
     930                                zone = find_free_zone_lock(order, pzone);
    923931                }
    924932        }
     
    942950                goto loop;
    943951        }
    944         v = zone_frame_alloc(zone,order);
     952       
     953        v = zone_frame_alloc(zone, order);
    945954        v += zone->base;
    946955
Note: See TracChangeset for help on using the changeset viewer.