Changeset 2595dab in mainline for uspace/lib/libc/generic/io/console.c


Ignore:
Timestamp:
2009-06-03T19:26:28Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d00ae4c
Parents:
ca3ba3a
Message:

I/O subsystem overhaul:

  • add more POSIX-like file and stream functions (with real functionality of stdin, stdout, stderr)
  • cleanup console access methods (now generic to any console-like device)
  • remove unsafe stream functions
  • add special open_node(), fd_node(), fd_phone() (file) and fopen_node(), fnode(), fphone() (stream) functions for HelenOS-specific I/O operations
File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/io/console.c

    rca3ba3a r2595dab  
    22 * Copyright (c) 2006 Josef Cejka
    33 * Copyright (c) 2006 Jakub Vana
     4 * Copyright (c) 2008 Jiri Svoboda
    45 * All rights reserved.
    56 *
     
    3435 */
    3536
    36 #include <io/io.h>
    37 #include <io/stream.h>
    38 #include <string.h>
    39 #include <malloc.h>
    4037#include <libc.h>
    41 #include <ipc/ipc.h>
    42 #include <ipc/ns.h>
    43 #include <ipc/fb.h>
    44 #include <ipc/services.h>
     38#include <async.h>
     39#include <io/console.h>
    4540#include <ipc/console.h>
    46 #include <console.h>
    47 #include <kbd/kbd.h>
    48 #include <unistd.h>
    49 #include <async.h>
    50 #include <sys/types.h>
    5141
    52 ssize_t read_stdin(void *buf, size_t count)
     42void console_clear(int phone)
    5343{
    54         int cons_phone = console_open(false);
    55        
    56         if (cons_phone >= 0) {
    57                 kbd_event_t ev;
    58                 int rc;
    59                 size_t i = 0;
    60                
    61                 while (i < count) {
    62                         do {
    63                                 rc = kbd_get_event(&ev);
    64                                 if (rc < 0) return -1;
    65                         } while (ev.c == 0 || ev.type == KE_RELEASE);
    66                        
    67                         ((char *) buf)[i++] = ev.c;
    68                 }
    69                 return i;
    70         } else
    71                 return -1;
     44        async_msg_0(phone, CONSOLE_CLEAR);
    7245}
    7346
    74 /** Write a string to klog. */
    75 int klog_puts(const char *str)
     47int console_get_size(int phone, ipcarg_t *rows, ipcarg_t *cols)
    7648{
    77         return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) str, str_size(str));
     49        return async_req_0_2(phone, CONSOLE_GET_SIZE, rows, cols);
    7850}
    7951
    80 void klog_update(void)
     52void console_set_style(int phone, int style)
    8153{
    82         (void) __SYSCALL3(SYS_KLOG, 1, NULL, 0);
     54        async_msg_1(phone, CONSOLE_SET_STYLE, style);
     55}
     56
     57void console_set_color(int phone, int fg_color, int bg_color, int flags)
     58{
     59        async_msg_3(phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags);
     60}
     61
     62void console_set_rgb_color(int phone, int fg_color, int bg_color)
     63{
     64        async_msg_2(phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);
     65}
     66
     67void console_cursor_visibility(int phone, bool show)
     68{
     69        async_msg_1(phone, CONSOLE_CURSOR_VISIBILITY, show != false);
     70}
     71
     72void console_kcon_enable(int phone)
     73{
     74        async_msg_0(phone, CONSOLE_KCON_ENABLE);
     75}
     76
     77void console_goto(int phone, ipcarg_t row, ipcarg_t col)
     78{
     79        async_msg_2(phone, CONSOLE_GOTO, row, col);
     80}
     81
     82bool console_get_event(int phone, console_event_t *event)
     83{
     84        ipcarg_t type;
     85        ipcarg_t key;
     86        ipcarg_t mods;
     87        ipcarg_t c;
     88       
     89        int rc = async_req_0_4(phone, CONSOLE_GET_EVENT, &type, &key, &mods, &c);
     90        if (rc < 0)
     91                return false;
     92       
     93        event->type = type;
     94        event->key = key;
     95        event->mods = mods;
     96        event->c = c;
     97       
     98        return true;
    8399}
    84100
Note: See TracChangeset for help on using the changeset viewer.