Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/ddi/ddi.c

    r9d58539 r8cd680c  
    11/*
    22 * Copyright (c) 2006 Jakub Jermar
    3  * Copyright (c) 2008 Jakub vana
     3 * Copyright (c) 2008 Jakub Vana
    44 * All rights reserved.
    55 *
     
    4747 * Interrupts are disabled and task is locked.
    4848 *
    49  * @param task          Task.
    50  * @param ioaddr        Starting I/O space address.
    51  * @param size          Size of the enabled I/O range.
     49 * @param task   Task.
     50 * @param ioaddr Starting I/O space address.
     51 * @param size   Size of the enabled I/O range.
    5252 *
    53  * @return 0 on success or an error code from errno.h.
     53 * @return EOK on success or an error code from errno.h.
    5454 */
    5555int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
    5656{
    5757        if (!task->arch.iomap) {
    58                 uint8_t *map;
    59 
    6058                task->arch.iomap = malloc(sizeof(bitmap_t), 0);
    61                 map = malloc(BITS2BYTES(IO_MEMMAP_PAGES), 0);
    62                 if(!map)
     59                if (task->arch.iomap == NULL)
    6360                        return ENOMEM;
    64                 bitmap_initialize(task->arch.iomap, map, IO_MEMMAP_PAGES);
     61               
     62                void *store = malloc(bitmap_size(IO_MEMMAP_PAGES), 0);
     63                if (store == NULL)
     64                        return ENOMEM;
     65               
     66                bitmap_initialize(task->arch.iomap, IO_MEMMAP_PAGES, store);
    6567                bitmap_clear_range(task->arch.iomap, 0, IO_MEMMAP_PAGES);
    6668        }
     
    6971        size = ALIGN_UP(size + ioaddr - 4 * iopage, PORTS_PER_PAGE);
    7072        bitmap_set_range(task->arch.iomap, iopage, size / 4);
     73       
     74        return EOK;
     75}
    7176
    72         return 0;
     77/** Disable I/O space range for task.
     78 *
     79 * Interrupts are disabled and task is locked.
     80 *
     81 * @param task   Task.
     82 * @param ioaddr Starting I/O space address.
     83 * @param size   Size of the disabled I/O range.
     84 *
     85 * @return EOK on success or an error code from errno.h.
     86 */
     87int ddi_iospace_disable_arch(task_t *task, uintptr_t ioaddr, size_t size)
     88{
     89        if (!task->arch.iomap)
     90                return EINVAL;
     91
     92        uintptr_t iopage = ioaddr / PORTS_PER_PAGE;
     93        size = ALIGN_UP(size + ioaddr - 4 * iopage, PORTS_PER_PAGE);
     94        bitmap_clear_range(task->arch.iomap, iopage, size / 4);
     95       
     96        return EOK;
    7397}
    7498
Note: See TracChangeset for help on using the changeset viewer.