Changeset 46321fb in mainline for kernel/arch/ia64/src/mm/tlb.c


Ignore:
Timestamp:
2008-11-25T20:22:04Z (15 years ago)
Author:
Jakub Vana <jakub.vana@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
83d9712
Parents:
14c331a
Message:

IA64: Userspace I/O support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/mm/tlb.c

    r14c331a r46321fb  
    476476}
    477477
     478
     479
     480static 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 */
     498static 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
    478545/** Data TLB fault handler for faults with VHPT turned off.
    479546 *
     
    512579                page_table_unlock(AS, true);
    513580        } else {
     581                page_table_unlock(AS, true);
     582                if (try_memmap_io_insertion(va,istate)) return;
    514583                /*
    515584                 * Forward the page fault to the address space page fault handler.
    516585                 */
    517                 page_table_unlock(AS, true);
    518586                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
    519587                        fault_if_from_uspace(istate,"Page fault at %p",va);
Note: See TracChangeset for help on using the changeset viewer.