Rev 2745 | Rev 3766 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2745 | Rev 3635 | ||
---|---|---|---|
Line 473... | Line 473... | ||
473 | panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, istate->cr_iip); |
473 | panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, istate->cr_iip); |
474 | } |
474 | } |
475 | } |
475 | } |
476 | } |
476 | } |
477 | 477 | ||
- | 478 | ||
- | 479 | ||
- | 480 | static int is_io_page_accessible(int page) |
|
- | 481 | { |
|
- | 482 | if(TASK->arch.iomap) return bitmap_get(TASK->arch.iomap,page); |
|
- | 483 | else return 0; |
|
- | 484 | } |
|
- | 485 | ||
- | 486 | #define IO_FRAME_BASE 0xFFFFC000000 |
|
- | 487 | ||
- | 488 | /** There is special handling of memmaped lagacy io, because |
|
- | 489 | * of 4KB sized access |
|
- | 490 | * only for userspace |
|
- | 491 | * |
|
- | 492 | * @param va virtual address of page fault |
|
- | 493 | * @param istate Structure with saved interruption state. |
|
- | 494 | * |
|
- | 495 | * |
|
- | 496 | * @return 1 on success, 0 on fail |
|
- | 497 | */ |
|
- | 498 | static int try_memmap_io_insertion(uintptr_t va, istate_t *istate) |
|
- | 499 | { |
|
- | 500 | if((va >= IO_OFFSET ) && (va < IO_OFFSET + (1<<IO_PAGE_WIDTH))) |
|
- | 501 | if(TASK){ |
|
- | 502 | ||
- | 503 | uint64_t io_page=(va & ((1<<IO_PAGE_WIDTH)-1)) >> (USPACE_IO_PAGE_WIDTH); |
|
- | 504 | if(is_io_page_accessible(io_page)){ |
|
- | 505 | //printf("Insert %llX\n",va); |
|
- | 506 | ||
- | 507 | uint64_t page,frame; |
|
- | 508 | ||
- | 509 | page = IO_OFFSET + (1 << USPACE_IO_PAGE_WIDTH) * io_page; |
|
- | 510 | frame = IO_FRAME_BASE + (1 << USPACE_IO_PAGE_WIDTH) * io_page; |
|
- | 511 | ||
- | 512 | ||
- | 513 | tlb_entry_t entry; |
|
- | 514 | ||
- | 515 | entry.word[0] = 0; |
|
- | 516 | entry.word[1] = 0; |
|
- | 517 | ||
- | 518 | entry.p = true; /* present */ |
|
- | 519 | entry.ma = MA_UNCACHEABLE; |
|
- | 520 | entry.a = true; /* already accessed */ |
|
- | 521 | entry.d = true; /* already dirty */ |
|
- | 522 | entry.pl = PL_USER; |
|
- | 523 | entry.ar = AR_READ | AR_WRITE; |
|
- | 524 | entry.ppn = frame >> PPN_SHIFT; //MUSIM spocitat frame |
|
- | 525 | entry.ps = USPACE_IO_PAGE_WIDTH; |
|
- | 526 | ||
- | 527 | dtc_mapping_insert(page, TASK->as->asid, entry); //Musim zjistit ASID |
|
- | 528 | return 1; |
|
- | 529 | }else { |
|
- | 530 | fault_if_from_uspace(istate,"IO access fault at %p",va); |
|
- | 531 | return 0; |
|
- | 532 | } |
|
- | 533 | } else |
|
- | 534 | return 0; |
|
- | 535 | else |
|
- | 536 | return 0; |
|
- | 537 | ||
- | 538 | return 0; |
|
- | 539 | ||
- | 540 | } |
|
- | 541 | ||
- | 542 | ||
- | 543 | ||
- | 544 | ||
478 | /** Data TLB fault handler for faults with VHPT turned off. |
545 | /** Data TLB fault handler for faults with VHPT turned off. |
479 | * |
546 | * |
480 | * @param vector Interruption vector. |
547 | * @param vector Interruption vector. |
481 | * @param istate Structure with saved interruption state. |
548 | * @param istate Structure with saved interruption state. |
482 | */ |
549 | */ |
Line 509... | Line 576... | ||
509 | * Insert it into data translation cache. |
576 | * Insert it into data translation cache. |
510 | */ |
577 | */ |
511 | dtc_pte_copy(t); |
578 | dtc_pte_copy(t); |
512 | page_table_unlock(AS, true); |
579 | page_table_unlock(AS, true); |
513 | } else { |
580 | } else { |
- | 581 | page_table_unlock(AS, true); |
|
- | 582 | if (try_memmap_io_insertion(va,istate)) return; |
|
514 | /* |
583 | /* |
515 | * Forward the page fault to the address space page fault handler. |
584 | * Forward the page fault to the address space page fault handler. |
516 | */ |
585 | */ |
517 | page_table_unlock(AS, true); |
- | |
518 | if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { |
586 | if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { |
519 | fault_if_from_uspace(istate,"Page fault at %p",va); |
587 | fault_if_from_uspace(istate,"Page fault at %p",va); |
520 | panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, istate->cr_iip); |
588 | panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, istate->cr_iip); |
521 | } |
589 | } |
522 | } |
590 | } |