Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 416abec in mainline


Ignore:
Timestamp:
2009-03-20T20:58:21Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
e622f0a8
Parents:
db90860
Message:

Improve the console library functions.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tetris/input.c

    rdb90860 r416abec  
    116116again:
    117117                if (!getchar_inprog) {
    118                         cons_phone = console_phone_get();
     118                        cons_phone = console_phone_get(true);
    119119                        getchar_inprog = async_send_2(cons_phone,
    120120                            CONSOLE_GETKEY, 0, 0, &charcall);
  • uspace/lib/libc/generic/console.c

    rdb90860 r416abec  
    4343static int console_phone = -1;
    4444
    45 void console_open(void)
     45void console_open(bool blocking)
    4646{
    4747        if (console_phone < 0) {
    48                 int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0);
     48                int phone;
     49                if (blocking) {
     50                        phone = ipc_connect_me_to_blocking(PHONE_NS,
     51                            SERVICE_CONSOLE, 0, 0);
     52                } else {
     53                        phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0,
     54                            0);
     55                }
    4956                if (phone >= 0)
    5057                        console_phone = phone;
     
    6168}
    6269
    63 int console_phone_get(void)
     70int console_phone_get(bool blocking)
    6471{
    6572        if (console_phone < 0)
    66                 console_open();
     73                console_open(blocking);
    6774       
    6875        return console_phone;
     
    7279{
    7380        while (console_phone < 0)
    74                 console_open();
     81                console_open(true);
    7582}
    7683
    7784void console_clear(void)
    7885{
    79         int cons_phone = console_phone_get();
     86        int cons_phone = console_phone_get(true);
    8087        async_msg_0(cons_phone, CONSOLE_CLEAR);
    8188}
     
    8390void console_goto(int row, int col)
    8491{
    85         int cons_phone = console_phone_get();
     92        int cons_phone = console_phone_get(true);
    8693        async_msg_2(cons_phone, CONSOLE_GOTO, row, col);
    8794}
     
    8996void console_putchar(int c)
    9097{
    91         int cons_phone = console_phone_get();
     98        int cons_phone = console_phone_get(true);
    9299        async_msg_1(cons_phone, CONSOLE_PUTCHAR, c);
    93100}
     
    95102void console_flush(void)
    96103{
    97         int cons_phone = console_phone_get();
     104        int cons_phone = console_phone_get(true);
    98105        async_msg_0(cons_phone, CONSOLE_FLUSH);
    99106}
     
    101108int console_get_size(int *rows, int *cols)
    102109{
    103         int cons_phone = console_phone_get();
     110        int cons_phone = console_phone_get(true);
    104111        ipcarg_t r, c;
    105112        int rc;
     
    115122void console_set_style(int style)
    116123{
    117         int cons_phone = console_phone_get();
     124        int cons_phone = console_phone_get(true);
    118125        async_msg_1(cons_phone, CONSOLE_SET_STYLE, style);
    119126}
     
    121128void console_set_color(int fg_color, int bg_color, int flags)
    122129{
    123         int cons_phone = console_phone_get();
     130        int cons_phone = console_phone_get(true);
    124131        async_msg_3(cons_phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags);
    125132}
     
    127134void console_set_rgb_color(int fg_color, int bg_color)
    128135{
    129         int cons_phone = console_phone_get();
     136        int cons_phone = console_phone_get(true);
    130137        async_msg_2(cons_phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);
    131138}
     
    133140void console_cursor_visibility(int show)
    134141{
    135         int cons_phone = console_phone_get();
     142        int cons_phone = console_phone_get(true);
    136143        async_msg_1(cons_phone, CONSOLE_CURSOR_VISIBILITY, show != 0);
    137144}
  • uspace/lib/libc/generic/io/stream.c

    rdb90860 r416abec  
    5757ssize_t read_stdin(void *buf, size_t count)
    5858{
    59         int cons_phone = console_phone_get();
     59        int cons_phone = console_phone_get(false);
    6060
    6161        if (cons_phone >= 0) {
     
    8080ssize_t write_stdout(const void *buf, size_t count)
    8181{
    82         int cons_phone = console_phone_get();
     82        int cons_phone = console_phone_get(false);
    8383
    8484        if (cons_phone >= 0) {
  • uspace/lib/libc/generic/kbd.c

    rdb90860 r416abec  
    4343int kbd_get_event(kbd_event_t *ev)
    4444{
    45         int cons_phone = console_phone_get();
     45        int cons_phone = console_phone_get(true);
    4646        ipcarg_t r0, r1, r2, r3;
    4747        int rc;
    48 
    49         if (cons_phone < 0)
    50                 return -1;
    5148
    5249        rc = async_req_0_4(cons_phone, CONSOLE_GETKEY, &r0, &r1, &r2, &r3);
  • uspace/lib/libc/include/console.h

    rdb90860 r416abec  
    3838#include <console/style.h>
    3939#include <console/color.h>
     40#include <bool.h>
    4041
    41 extern void console_open(void);
     42extern void console_open(bool);
    4243extern void console_close(void);
    4344
    44 extern int console_phone_get(void);
     45extern int console_phone_get(bool);
    4546extern void console_wait(void);
    4647
Note: See TracChangeset for help on using the changeset viewer.