Changeset 46321fb in mainline


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

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/include/mm/page.h

    r14c331a r46321fb  
    4949#define FW_PAGE_WIDTH                   28      /* 256M */
    5050
    51 /** Staticly mapped IO spaces */
     51#define USPACE_IO_PAGE_WIDTH            12      /* 4K */
     52
     53
     54
     55/** Staticly mapped IO spaces - offsets to 0xe...00 of virtual adresses
     56becauce of "minimal virtual bits implemented is 51"
     57it is possible to have here values up to 0x0007000000000000
     58*/
    5259
    5360/* Firmware area (bellow 4GB in phys mem) */
  • kernel/arch/ia64/include/mm/tlb.h

    r14c331a r46321fb  
    4747#define DTR_KERNEL      0
    4848#define ITR_KERNEL      0
    49 #define DTR_KSTACK1     1
    50 #define DTR_KSTACK2     2
     49#define DTR_KSTACK1     4
     50#define DTR_KSTACK2     5
    5151
    5252/** Portion of TLB insertion format data structure. */
  • kernel/arch/ia64/include/proc/task.h

    r14c331a r46321fb  
    3232/** @file
    3333 */
     34#include <proc/task.h>
    3435
    3536#ifndef KERN_ia64_TASK_H_
    3637#define KERN_ia64_TASK_H_
    3738
     39#include <adt/bitmap.h>
     40
    3841typedef struct {
     42        bitmap_t *iomap;
    3943} task_arch_t;
    4044
    41 #define task_create_arch(t)
     45
     46#define task_create_arch(t) {(t)->arch.iomap=NULL;}
    4247#define task_destroy_arch(t)
    4348
  • kernel/arch/ia64/src/ddi/ddi.c

    r14c331a r46321fb  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2006 Jakub Jermar, Jakub vana
    33 * All rights reserved.
    44 *
     
    3636#include <proc/task.h>
    3737#include <arch/types.h>
     38#include <mm/slab.h>
     39#include <errno.h>
     40
     41#define IO_MEMMAP_PAGES 16384
     42#define PORTS_PER_PAGE 4
    3843
    3944/** Enable I/O space range for task.
     
    4954int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
    5055{
     56
     57        if(!task->arch.iomap)
     58        {
     59                uint8_t *map;
     60                task->arch.iomap=malloc(sizeof(bitmap_t),0);
     61                map=malloc(BITS2BYTES(IO_MEMMAP_PAGES),0);
     62                if(!map)
     63                        return ENOMEM;
     64                bitmap_initialize(task->arch.iomap,map,IO_MEMMAP_PAGES);       
     65                bitmap_clear_range(task->arch.iomap,0,IO_MEMMAP_PAGES);
     66        }
     67       
     68        uintptr_t iopage = ioaddr / PORTS_PER_PAGE;
     69        size = ALIGN_UP (size+ioaddr-4*iopage,PORTS_PER_PAGE);
     70        bitmap_set_range(task->arch.iomap,iopage,size/4);
     71
     72
    5173        return 0;
    5274}
  • kernel/arch/ia64/src/drivers/ega.c

    r14c331a r46321fb  
    4747#include <sysinfo/sysinfo.h>
    4848#include <arch/drivers/ega.h>
     49#include <ddi/ddi.h>
     50
    4951
    5052/*
     
    5254 * Simple and short. Function for displaying characters and "scrolling".
    5355 */
     56
     57
     58static parea_t ega_parea;       /**< Physical memory area for EGA video RAM. */
     59
    5460
    5561SPINLOCK_INITIALIZE(egalock);
     
    7682        chardev_initialize("ega_out", &ega_console, &ega_ops);
    7783        stdout = &ega_console;
     84
     85
     86        ega_parea.pbase = VIDEORAM & 0xffffffff;
     87        ega_parea.vbase = (uintptr_t) videoram;
     88        ega_parea.frames = 1;
     89        ega_parea.cacheable = false;
     90        ddi_parea_register(&ega_parea);
     91
    7892       
    7993        sysinfo_set_item_val("fb", NULL, true);
     
    8195        sysinfo_set_item_val("fb.width", NULL, ROW);
    8296        sysinfo_set_item_val("fb.height", NULL, ROWS);
    83         sysinfo_set_item_val("fb.address.physical", NULL, VIDEORAM);
     97        sysinfo_set_item_val("fb.address.physical", NULL, VIDEORAM & 0xffffffff);
    8498       
    8599#ifndef CONFIG_FB
  • kernel/arch/ia64/src/ia64.c

    r14c331a r46321fb  
    6161#include <panic.h>
    6262#include <print.h>
     63#include <sysinfo/sysinfo.h>
    6364
    6465/*NS16550 as a COM 1*/
     
    183184
    184185        }
     186       
     187        sysinfo_set_item_val("ia64_iospace", NULL, true);
     188        sysinfo_set_item_val("ia64_iospace.address", NULL, true);
     189        sysinfo_set_item_val("ia64_iospace.address.virtual", NULL, IO_OFFSET);
     190
    185191}
    186192
  • 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);
  • kernel/generic/include/adt/bitmap.h

    r14c331a r46321fb  
    5050extern void bitmap_copy(bitmap_t *dst, bitmap_t *src, count_t bits);
    5151
     52static inline int bitmap_get(bitmap_t *bitmap,index_t bit)
     53{
     54        if(bit >= bitmap->bits)
     55                return 0;
     56        return !! ((bitmap->map)[bit/8] & (1 << (bit & 7)));
     57}
     58
     59
    5260#endif
    5361
  • uspace/lib/libc/arch/ia64/Makefile.inc

    r14c331a r46321fb  
    4242ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \
    4343                arch/$(ARCH)/src/fibril.S \
    44                 arch/$(ARCH)/src/tls.c
     44                arch/$(ARCH)/src/tls.c\
     45                arch/$(ARCH)/src/ddi.c
    4546
    4647BFD_NAME = elf64-ia64-little
  • uspace/srv/fb/Makefile

    r14c331a r46321fb  
    4848        ppm.c
    4949
    50 ifneq ($(ARCH), ia64)
    51         SOURCES += fb.c \
    52                 font-8x16.c
    53         CFLAGS += -DFB_ENABLED
     50#ifneq ($(ARCH), ia64)
     51#       SOURCES += fb.c \
     52#               font-8x16.c
     53#       CFLAGS += -DFB_ENABLED
     54#endif
     55ifeq ($(ARCH), ia32)
     56        SOURCES += ega.c
     57        CFLAGS += -DEGA_ENABLED
    5458endif
    55 ifeq ($(ARCH), ia32)
     59ifeq ($(ARCH), ia64)
    5660        SOURCES += ega.c
    5761        CFLAGS += -DEGA_ENABLED
Note: See TracChangeset for help on using the changeset viewer.