Changeset 12fdd28 in mainline


Ignore:
Timestamp:
2006-05-29T17:08:19Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ad37437
Parents:
a449065
Message:

Better SYS_IO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/syscall/syscall.c

    ra449065 r12fdd28  
    4848#include <sysinfo/sysinfo.h>
    4949
     50/** Print using kernel facility
     51 *
     52 * Some simulators can print only through kernel. Userspace can use
     53 * this syscall to facilitate it.
     54 */
    5055static __native sys_io(int fd, const void * buf, size_t count)
    5156{
    52 //      return count; /*Syscall deprecated*/
    53         // TODO: buf sanity checks and a lot of other stuff ...
     57        size_t i;
     58        char *data;
     59        int rc;
    5460
    55         size_t i;
     61        if (count > PAGE_SIZE)
     62                return ELIMIT;
     63
     64        data = malloc(count, 0);
     65        if (!data)
     66                return ENOMEM;
    5667       
     68        rc = copy_from_uspace(data, buf, count);
     69        if (rc) {
     70                free(data);
     71                return rc;
     72        }
     73
    5774        for (i = 0; i < count; i++)
    58                 putchar(((char *) buf)[i]);
     75                putchar(data[i]);
     76        free(data);
    5977       
    6078        return count;
Note: See TracChangeset for help on using the changeset viewer.