Changeset f52e54da in mainline


Ignore:
Timestamp:
2006-04-14T09:08:10Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9e1b581
Parents:
9c1ecf9
Message:

Kernel support for SYS_ENABLE_IOSPACE.
amd64 and ia32 provide dummy implementation thereof.

Files:
7 added
12 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/Makefile.inc

    r9c1ecf9 rf52e54da  
    8989        arch/$(ARCH)/src/pm.c \
    9090        arch/$(ARCH)/src/context.S \
     91        arch/$(ARCH)/src/ddi/ddi.c \
    9192        arch/$(ARCH)/src/drivers/ega.c \
    9293        arch/$(ARCH)/src/drivers/i8254.c \
  • arch/ia32/Makefile.inc

    r9c1ecf9 rf52e54da  
    128128        arch/$(ARCH)/src/mm/page.c \
    129129        arch/$(ARCH)/src/mm/tlb.c \
     130        arch/$(ARCH)/src/ddi/ddi.c \
    130131        arch/$(ARCH)/src/drivers/i8254.c \
    131132        arch/$(ARCH)/src/drivers/i8259.c \
  • arch/ia64/Makefile.inc

    r9c1ecf9 rf52e54da  
    8686        arch/$(ARCH)/src/mm/tlb.c \
    8787        arch/$(ARCH)/src/proc/scheduler.c \
     88        arch/$(ARCH)/src/ddi/ddi.c \
    8889        arch/$(ARCH)/src/drivers/it.c
  • arch/mips32/Makefile.inc

    r9c1ecf9 rf52e54da  
    126126        arch/$(ARCH)/src/mm/as.c \
    127127        arch/$(ARCH)/src/fpu_context.c \
     128        arch/$(ARCH)/src/ddi/ddi.c \
    128129        arch/$(ARCH)/src/drivers/arc.c \
    129130        arch/$(ARCH)/src/drivers/msim.c \
  • arch/ppc32/Makefile.inc

    r9c1ecf9 rf52e54da  
    6969        arch/$(ARCH)/src/cpu/cpu.c \
    7070        arch/$(ARCH)/src/proc/scheduler.c \
     71        arch/$(ARCH)/src/ddi/ddi.c \
    7172        arch/$(ARCH)/src/drivers/cuda.c \
    7273        arch/$(ARCH)/src/mm/as.c \
  • arch/ppc64/Makefile.inc

    r9c1ecf9 rf52e54da  
    6868        arch/$(ARCH)/src/asm.S \
    6969        arch/$(ARCH)/src/cpu/cpu.c \
     70        arch/$(ARCH)/src/ddi/ddi.c \
    7071        arch/$(ARCH)/src/proc/scheduler.c \
    7172        arch/$(ARCH)/src/mm/as.c \
  • arch/sparc64/Makefile.inc

    r9c1ecf9 rf52e54da  
    9090        arch/$(ARCH)/src/trap/exception.c \
    9191        arch/$(ARCH)/src/trap/interrupt.c \
     92        arch/$(ARCH)/src/ddi/ddi.c \
    9293        arch/$(ARCH)/src/drivers/tick.c
  • generic/include/ddi/ddi.h

    r9c1ecf9 rf52e54da  
    3232#include <ddi/ddi_arg.h>
    3333#include <arch/types.h>
     34#include <typedefs.h>
    3435
    35 extern __native sys_map_physmem(ddi_arg_t *uspace_ddi_arg);
     36extern __native sys_map_physmem(ddi_memarg_t *uspace_mem_arg);
     37extern __native sys_enable_iospace(ddi_ioarg_t *uspace_io_arg);
     38
     39/*
     40 * Interface to be implemented by all architectures.
     41 */
     42extern int ddi_enable_iospace_arch(task_t *task, __address ioaddr, size_t size);
    3643
    3744#endif
  • generic/include/ddi/ddi_arg.h

    r9c1ecf9 rf52e54da  
    3737        unsigned long pages;            /** Number of pages to map. */
    3838        int writable;                   /** True if the mapping should be writable. */
    39 } ddi_arg_t;
     39} ddi_memarg_t;
     40
     41/** Structure encapsulating arguments for SYS_ENABLE_IOSPACE syscall. */
     42typedef struct {
     43        unsigned long long task_id;     /** ID of the destination task. */
     44        void *ioaddr;                   /** Starting I/O space address. */
     45        unsigned long size;             /** Number of bytes. */
     46} ddi_ioarg_t;
    4047
    4148#endif
  • generic/include/syscall/syscall.h

    r9c1ecf9 rf52e54da  
    5050        SYS_IPC_HANGUP,
    5151        SYS_MAP_PHYSMEM,
     52        SYS_ENABLE_IOSPACE,
    5253        SYSCALL_END
    5354} syscall_t;
  • generic/src/ddi/ddi.c

    r9c1ecf9 rf52e54da  
    112112}
    113113
     114/** Enable range of I/O space for task.
     115 *
     116 * @param id Task ID of the destination task.
     117 * @param ioaddr Starting I/O address.
     118 * @param size Size of the enabled I/O space..
     119 *
     120 * @return 0 on success, EPERM if the caller lacks capabilities to use this syscall,
     121 *         ENOENT if there is no task matching the specified ID.
     122 */
     123static int ddi_enable_iospace(task_id_t id, __address ioaddr, size_t size)
     124{
     125        ipl_t ipl;
     126        cap_t caps;
     127        task_t *t;
     128        int rc;
     129       
     130        /*
     131         * Make sure the caller is authorised to make this syscall.
     132         */
     133        caps = cap_get(TASK);
     134        if (!(caps & CAP_IO_MANAGER))
     135                return EPERM;
     136       
     137        ipl = interrupts_disable();
     138        spinlock_lock(&tasks_lock);
     139       
     140        t = task_find_by_id(id);
     141       
     142        if (!t) {
     143                /*
     144                 * There is no task with the specified ID.
     145                 */
     146                spinlock_unlock(&tasks_lock);
     147                interrupts_restore(ipl);
     148                return ENOENT;
     149        }
     150
     151        /*
     152         * TODO: We are currently lacking support for task destroying.
     153         * Once it is added to the kernel, we must take care to
     154         * synchronize in a way that prevents race conditions here.
     155         */
     156       
     157        /* Lock the task and release the lock protecting tasks_btree. */
     158        spinlock_lock(&t->lock);
     159        spinlock_unlock(&tasks_lock);
     160
     161        rc = ddi_enable_iospace_arch(t, ioaddr, size);
     162       
     163        spinlock_unlock(&t->lock);
     164        interrupts_restore(ipl);
     165        return rc;
     166}
     167
    114168/** Wrapper for SYS_MAP_PHYSMEM syscall.
     169 *
     170 * @param User space address of memory DDI argument structure.
     171 *
     172 * @return 0 on success, otherwise it returns error code found in errno.h
     173 */
     174__native sys_map_physmem(ddi_memarg_t *uspace_mem_arg)
     175{
     176        ddi_memarg_t arg;
     177       
     178        copy_from_uspace(&arg, uspace_mem_arg, sizeof(ddi_memarg_t));
     179        return (__native) ddi_map_physmem((task_id_t) arg.task_id, ALIGN_DOWN((__address) arg.phys_base, FRAME_SIZE),
     180                                          ALIGN_DOWN((__address) arg.virt_base, PAGE_SIZE), (count_t) arg.pages,
     181                                          (bool) arg.writable);
     182}
     183
     184/** Wrapper for SYS_ENABLE_IOSPACE syscall.
    115185 *
    116186 * @param User space address of DDI argument structure.
     
    118188 * @return 0 on success, otherwise it returns error code found in errno.h
    119189 */
    120 __native sys_map_physmem(ddi_arg_t *uspace_ddi_arg)
     190__native sys_enable_iospace(ddi_ioarg_t *uspace_io_arg)
    121191{
    122         ddi_arg_t arg;
     192        ddi_ioarg_t arg;
    123193       
    124         copy_from_uspace(&arg, uspace_ddi_arg, sizeof(ddi_arg_t));
    125         return (__native) ddi_map_physmem((task_id_t) arg.task_id, ALIGN_DOWN((__address) arg.phys_base, FRAME_SIZE),
    126                                           ALIGN_DOWN((__address) arg.virt_base, PAGE_SIZE), (count_t) arg.pages,
    127                                           (bool) arg.writable);
     194        copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t));
     195        return (__native) ddi_enable_iospace((task_id_t) arg.task_id, (__address) arg.ioaddr, (size_t) arg.size);
    128196}
  • generic/src/syscall/syscall.c

    r9c1ecf9 rf52e54da  
    9494        sys_ipc_wait_for_call,
    9595        sys_ipc_hangup,
    96         sys_map_physmem
     96        sys_map_physmem,
     97        sys_enable_iospace
    9798};
Note: See TracChangeset for help on using the changeset viewer.