Changeset 51c1b003 in mainline


Ignore:
Timestamp:
2006-05-29T13:34:40Z (19 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
854387b
Parents:
d1e70c7
Message:

First attempt to uspace console. Not working yet.

Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    rd1e70c7 r51c1b003  
    3838        init \
    3939        ns \
    40         fb
     40        fb \
     41        console
    4142
    4243ifeq ($(ARCH), amd64)
  • fb/fb.c

    rd1e70c7 r51c1b003  
    161161        ipcarg_t retval, arg1, arg2;
    162162
    163         if(!sysinfo_value("fb")) return -1;
    164 
     163        if(!sysinfo_value("fb")) {
     164                printf("Framebuffer initialization failed.\n");
     165                return -1;
     166        }
    165167
    166168        if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead)) != 0)
    167169                return -1;
    168170       
    169         init_fb();
     171        if (init_fb() != 0) {
     172                printf("Framebuffer initialization failed.\n");
     173                return -1;
     174        }
    170175
    171176        async_manager();
  • init/init.c

    rd1e70c7 r51c1b003  
    306306
    307307        printf("Test: Starting connect...\n");
    308         while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) {
     308        while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) {
    309309        };
    310310       
    311311        printf("Test: Connected: %d\n", res);
    312312        printf("Test: pinging.\n");
    313         while (1) {
     313/*      while (1) {
     314               
    314315                res = ipc_call_sync(phoneid, KBD_GETCHAR, 0xbeef,&result);
    315316//              printf("Test: Retval: %d - received: %c\n", res, result);
    316317                printf("%c", result);
    317318        }
    318        
     319*/     
    319320        printf("Test: Hangin up\n");
    320321        ipc_hangup(phoneid);
     
    336337        printf("Test: pinging.\n");
    337338
    338         aid = async_send_2(phoneid, KBD_GETCHAR, 0, 0, &kbddata);
     339
    339340        while (1) {
    340                 if (async_wait_timeout(aid, NULL, 1000000)) {
    341                         printf("^");
    342                         continue;
    343                 }
    344                 printf("%c", IPC_GET_ARG1(kbddata));
    345                 aid = async_send_2(phoneid, KBD_GETCHAR, 0, 0, &kbddata);
    346341        }
    347342       
  • kbd/generic/kbd.c

    rd1e70c7 r51c1b003  
    3636#include <arch/kbd.h>
    3737#include <kbd.h>
     38#include <libadt/fifo.h>
    3839#include <key_buffer.h>
    39 #include <libadt/fifo.h>
    4040
    4141#define NAME "KBD"
    42 
    43 #define KBD_REQUEST_MAX 32 /**< Maximum requests buffered until keypress */
    44 
     42void hello(void *private, int retval, ipc_call_t *data) {
     43        printf("%s: got answer from console with retval %d.\n", NAME, retval);
     44}
    4545int main(int argc, char **argv)
    4646{
    4747        ipc_call_t call;
    4848        ipc_callid_t callid;
     49        int res;
     50        ipcarg_t phonead;
     51        int phoneid;
    4952        char connected = 0;
    50         int res;
    51         int c;
    52         ipcarg_t phonead;
    5353       
    5454        ipcarg_t retval, arg1, arg2;
    55 
    56         /* Counter of unsatisfied calls */
    57         fifo_count_t callers_counter = 0;
    58         /* Fifo with callid's of unsatisfied calls requred for answer */
    59         FIFO_INITIALIZE_STATIC(callers_buffer, ipc_callid_t, KBD_REQUEST_MAX);
    6055
    6156        printf("Uspace kbd service started.\n");
     
    8378                switch (IPC_GET_METHOD(call)) {
    8479                        case IPC_M_PHONE_HUNGUP:
    85                                 if (connected) {
    86                                         /* If nobody's connected, clear keybuffer and dont store new keys */
    87                                         if (--connected == 0) {
    88                                                 callers_counter = 0;
    89                                                 callers_buffer.head = callers_buffer.tail = 0;
    90                                                 key_buffer_free();     
    91                                         }
    92                                        
    93                                         printf("%s: Phone hung up.\n", NAME);
    94                                 } else {
    95                                         printf("%s: Oops, got phone hung up, but nobody connected.\n", NAME);
    96                                 }
    97                                
     80                                printf("%s: Phone hung up.\n", NAME);
     81                                connected = 0;
    9882                                retval = 0;
    9983                                break;
     
    10892                                }
    10993                                break;
     94                        case IPC_M_CONNECT_TO_ME:
     95                                phoneid = IPC_GET_ARG3(call);
     96                                retval = 0;
     97                                break;
     98
    11099                        case IPC_M_INTERRUPT:
    111100                                if (connected) {
    112                                         /* recode scancode and store it into key buffer */
     101                                        /* recode to ASCII - one interrupt can produce more than one code so result is stored in fifo */
    113102                                        kbd_arch_process(IPC_GET_ARG2(call));
    114                                         //printf("%s: GOT INTERRUPT: %c\n", NAME, IPC_GET_ARG2(call));
     103
     104                                        //printf("%s: GOT INTERRUPT: %c\n", NAME, key);
    115105
    116106                                        /* Some callers could awaiting keypress - if its true, we have to send keys to them.
    117107                                         * One interrupt can store more than one key into buffer. */
     108                                       
    118109                                        retval = 0;
    119                                         arg2 = 0xbeef;
    120                                         while ((callers_counter) && (!key_buffer_empty())) {
    121                                                 callers_counter--;
     110
     111                                        while (!key_buffer_empty()) {
    122112                                                if (!key_buffer_pop((char *)&arg1)) {
    123                                                         printf("%s: KeyBuffer empty but it should not be.\n");
     113                                                        printf("%s: KeyBuffer is empty but it should not be.\n");
    124114                                                        break;
    125115                                                }
    126                                                 ipc_answer_fast(fifo_pop(callers_buffer), retval, arg1, arg2);
     116                                                /*FIXME: detection of closed connection */
     117                                                ipc_call_async(phoneid, KBD_PUSHCHAR, arg1, 0, &hello);
    127118                                        }
     119
    128120                                }
    129                                 break;
    130                         case KBD_GETCHAR:
    131         //                      printf("%s: Getchar: ", NAME);
    132                                 retval = 0;
    133                                 arg1 = 0;       
    134                                 if (!key_buffer_pop((char *)&arg1)) {
    135                                         if (callers_counter < KBD_REQUEST_MAX) {
    136                                                 callers_counter++;
    137                                                 fifo_push(callers_buffer, callid);
    138                                         } else {
    139                                                 retval = ELIMIT;
    140                                         }
    141                                         continue;
    142                                 };
    143                                 arg2 = 0xbeef;
    144                         //      printf("GetChar return %c\n", arg1);
    145                                
     121                                printf("%s: Interrupt processed.\n", NAME);
    146122                                break;
    147123                        default:
  • kbd/include/kbd.h

    rd1e70c7 r51c1b003  
    3030#define __KBD_H__
    3131
    32 #define KBD_GETCHAR 1024
     32#define KBD_PUSHCHAR 1024
    3333
    3434#endif
  • libc/include/ipc/services.h

    rd1e70c7 r51c1b003  
    3838#define SERVICE_FRAME_BUFFER    2
    3939#define SERVICE_KEYBOARD        3
    40 #define SERVICE_VIDEO           4
     40#define SERVICE_VIDEO           4
     41#define SERVICE_CONSOLE         5
    4142
    4243/* Memory area to be received from NS */
Note: See TracChangeset for help on using the changeset viewer.