Subversion Repositories HelenOS-historic

Rev

Rev 1702 | Rev 1760 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1702 Rev 1708
Line 64... Line 64...
64
 * @param pfrc     Pointer to variable where as_page_fault() return code will be stored.
64
 * @param pfrc     Pointer to variable where as_page_fault() return code will be stored.
65
 * @return         PTE on success, NULL otherwise.
65
 * @return         PTE on success, NULL otherwise.
66
 *
66
 *
67
 */
67
 */
68
static pte_t *find_mapping_and_check(as_t *as, bool lock, __address badvaddr, int access,
68
static pte_t *find_mapping_and_check(as_t *as, bool lock, __address badvaddr, int access,
69
                     istate_t *istate, int *pfcr)
69
                     istate_t *istate, int *pfrc)
70
{
70
{
71
    /*
71
    /*
72
     * Check if the mapping exists in page tables.
72
     * Check if the mapping exists in page tables.
73
     */
73
     */
74
    pte_t *pte = page_mapping_find(as, badvaddr);
74
    pte_t *pte = page_mapping_find(as, badvaddr);
Line 96... Line 96...
96
                pte = page_mapping_find(as, badvaddr);
96
                pte = page_mapping_find(as, badvaddr);
97
                ASSERT((pte) && (pte->p));
97
                ASSERT((pte) && (pte->p));
98
                return pte;
98
                return pte;
99
            case AS_PF_DEFER:
99
            case AS_PF_DEFER:
100
                page_table_lock(as, lock);
100
                page_table_lock(as, lock);
101
                *pfcr = rc;
101
                *pfrc = rc;
102
                return NULL;
102
                return NULL;
103
            case AS_PF_FAULT:
103
            case AS_PF_FAULT:
104
                page_table_lock(as, lock);
104
                page_table_lock(as, lock);
105
                printf("Page fault.\n");
105
                printf("Page fault.\n");
106
                *pfcr = rc;
106
                *pfrc = rc;
107
                return NULL;
107
                return NULL;
108
            default:
108
            default:
109
                panic("unexpected rc (%d)\n", rc);
109
                panic("unexpected rc (%d)\n", rc);
110
        }  
110
        }  
111
    }
111
    }
Line 195... Line 195...
195
 */
195
 */
196
void pht_refill(bool data, istate_t *istate)
196
void pht_refill(bool data, istate_t *istate)
197
{
197
{
198
    __address badvaddr;
198
    __address badvaddr;
199
    pte_t *pte;
199
    pte_t *pte;
200
    int pfcr;
200
    int pfrc;
201
    as_t *as;
201
    as_t *as;
202
    bool lock;
202
    bool lock;
203
   
203
   
204
    if (AS == NULL) {
204
    if (AS == NULL) {
205
        as = AS_KERNEL;
205
        as = AS_KERNEL;
Line 217... Line 217...
217
    } else
217
    } else
218
        badvaddr = istate->pc;
218
        badvaddr = istate->pc;
219
       
219
       
220
    page_table_lock(as, lock);
220
    page_table_lock(as, lock);
221
   
221
   
222
    pte = find_mapping_and_check(as, lock, badvaddr, PF_ACCESS_READ /* FIXME */, istate, &pfcr);
222
    pte = find_mapping_and_check(as, lock, badvaddr, PF_ACCESS_READ /* FIXME */, istate, &pfrc);
223
    if (!pte) {
223
    if (!pte) {
224
        switch (pfcr) {
224
        switch (pfrc) {
225
            case AS_PF_FAULT:
225
            case AS_PF_FAULT:
226
                goto fail;
226
                goto fail;
227
                break;
227
                break;
228
            case AS_PF_DEFER:
228
            case AS_PF_DEFER:
229
                /*
229
                /*
Line 231... Line 231...
231
                 * or copy_to_uspace().
231
                 * or copy_to_uspace().
232
                 */
232
                 */
233
                page_table_unlock(as, lock);
233
                page_table_unlock(as, lock);
234
                return;
234
                return;
235
            default:
235
            default:
236
                panic("Unexpected pfrc (%d)\n", pfcr);
236
                panic("Unexpected pfrc (%d)\n", pfrc);
237
        }
237
        }
238
    }
238
    }
239
   
239
   
240
    pte->a = 1; /* Record access to PTE */
240
    pte->a = 1; /* Record access to PTE */
241
    pht_insert(badvaddr, pte->pfn);
241
    pht_insert(badvaddr, pte->pfn);