Changeset 416abec in mainline for uspace/lib/libc/generic/console.c


Ignore:
Timestamp:
2009-03-20T20:58:21Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e622f0a8
Parents:
db90860
Message:

Improve the console library functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.