Changeset 0d5a50c in mainline


Ignore:
Timestamp:
2009-03-01T20:25:23Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0f94c3d
Parents:
bf25efb
Message:

Introduce pio_enable() libc call.

Location:
uspace/lib/libc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/arch/ia32/include/ddi.h

    rbf25efb r0d5a50c  
    3333#ifndef LIBC_ia32_DDI_H_
    3434#define LIBC_ia32_DDI_H_
     35
     36#define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
    3537
    3638static inline void outb(int16_t port, uint8_t b)
  • uspace/lib/libc/generic/ddi.c

    rbf25efb r0d5a50c  
    3636#include <libc.h>
    3737#include <task.h>
     38#include <as.h>
     39#include <align.h>
     40#include <libarch/config.h>
    3841#include <kernel/ddi/ddi_arg.h>
    3942
     
    4245 * Caller of this function must have the CAP_MEM_MANAGER capability.
    4346 *
    44  * @param pf Physical address of the starting frame.
    45  * @param vp Virtual address of the sterting page.
    46  * @param pages Number of pages to map.
    47  * @param flags Flags for the new address space area.
     47 * @param pf            Physical address of the starting frame.
     48 * @param vp            Virtual address of the starting page.
     49 * @param pages         Number of pages to map.
     50 * @param flags         Flags for the new address space area.
    4851 *
    49  * @return 0 on success, EPERM if the caller lacks the CAP_MEM_MANAGER capability,
    50  *         ENOENT if there is no task with specified ID and ENOMEM if there
    51  *         was some problem in creating address space area.
     52 * @return              0 on success, EPERM if the caller lacks the
     53 *                      CAP_MEM_MANAGER capability, ENOENT if there is no task
     54 *                      with specified ID and ENOMEM if there was some problem
     55 *                      in creating address space area.
    5256 */
    5357int physmem_map(void *pf, void *vp, unsigned long pages, int flags)
    5458{
    55         return __SYSCALL4(SYS_PHYSMEM_MAP, (sysarg_t) pf, (sysarg_t) vp, pages, flags);
     59        return __SYSCALL4(SYS_PHYSMEM_MAP, (sysarg_t) pf, (sysarg_t) vp, pages,
     60            flags);
    5661}
    5762
     
    6065 * Caller of this function must have the IO_MEM_MANAGER capability.
    6166 *
    62  * @param id Task ID.
    63  * @param ioaddr Starting address of the I/O range.
    64  * @param size Size of the range.
     67 * @param id            Task ID.
     68 * @param ioaddr        Starting address of the I/O range.
     69 * @param size          Size of the range.
    6570 *
    66  * @return 0 on success, EPERM if the caller lacks the CAP_IO_MANAGER capability,
    67  *         ENOENT if there is no task with specified ID and ENOMEM if there
    68  *         was some problem in allocating memory.
     71 * @return              0 on success, EPERM if the caller lacks the
     72 *                      CAP_IO_MANAGER capability, ENOENT if there is no task
     73 *                      with specified ID and ENOMEM if there was some problem
     74 *                      in allocating memory.
    6975 */
    7076int iospace_enable(task_id_t id, void *ioaddr, unsigned long size)
     
    8187/** Interrupt control
    8288 *
    83  * @param enable 1 - enable interrupts, 0 - disable interrupts
     89 * @param enable        1 - enable interrupts, 0 - disable interrupts
    8490 */
    8591int preemption_control(int enable)
     
    8894}
    8995
     96/** Enable PIO for specified I/O range.
     97 *
     98 * @param pio_addr      I/O start address.
     99 * @param size          Size of the I/O region.
     100 * @param use_addr      Address where the final address for application's PIO
     101 *                      will be stored.
     102 *
     103 * @return              Zero on success or negative error code.
     104 */
     105int pio_enable(void *pio_addr, size_t size, void **use_addr)
     106{
     107        void *phys;
     108        void *virt;
     109        size_t offset;
     110        unsigned int pages;
     111
     112#ifdef IO_SPACE_BOUNDARY
     113        if (pio_addr < IO_SPACE_BOUNDARY) {
     114                *use_addr = pio_addr;
     115                return iospace_enable(task_get_id(), pio_addr, size);
     116        }
     117#endif
     118
     119        phys = ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
     120        offset = pio_addr - phys;
     121        pages = ALIGN_UP(offset + size, PAGE_SIZE) >> PAGE_WIDTH;
     122        virt = as_get_mappable_page(pages);
     123        *use_addr = virt + offset;
     124        return physmem_map(phys, virt, pages, AS_AREA_READ | AS_AREA_WRITE);
     125}
     126
    90127/** @}
    91128 */
  • uspace/lib/libc/include/ddi.h

    rbf25efb r0d5a50c  
    3838#include <task.h>
    3939
    40 extern int physmem_map(void *pf, void *vp, unsigned long pages, int flags);
    41 extern int iospace_enable(task_id_t id, void *ioaddr, unsigned long size);
    42 extern int preemption_control(int enable);
     40extern int physmem_map(void *, void *, unsigned long, int);
     41extern int iospace_enable(task_id_t, void *, unsigned long);
     42extern int preemption_control(int);
     43extern int pio_enable(void *, size_t, void **);
    4344
    4445#endif
Note: See TracChangeset for help on using the changeset viewer.