Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/console/console.c

    r47a350f rcc1f8d4  
    5050#include <event.h>
    5151#include <devmap.h>
    52 #include <fcntl.h>
    53 #include <vfs/vfs.h>
    54 #include <fibril_synch.h>
     52#include <fibril_sync.h>
    5553
    5654#include "console.h"
     
    5957#include "screenbuffer.h"
    6058
    61 #define NAME       "console"
    62 #define NAMESPACE  "term"
     59#define NAME  "console"
     60
     61#define MAX_DEVICE_NAME  32
    6362
    6463/** Phone to the keyboard driver. */
     
    7069        ipcarg_t cols;  /**< Framebuffer columns */
    7170        ipcarg_t rows;  /**< Framebuffer rows */
    72         int color_cap;  /**< Color capabilities (FB_CCAP_xxx) */
     71        int color_cap;  /**< Color capabilities (FB_CCAP_xxx) */
    7372} fb_info;
    7473
     
    602601                                    IPC_GET_ARG2(call));
    603602                        break;
    604                 case CONSOLE_GET_POS:
    605                         arg1 = cons->scr.position_x;
    606                         arg2 = cons->scr.position_y;
    607                         break;
    608603                case CONSOLE_GET_SIZE:
    609604                        arg1 = fb_info.cols;
     
    667662}
    668663
    669 static bool console_init(char *input)
    670 {
    671         /* Connect to input device */
    672         int input_fd = open(input, O_RDONLY);
    673         if (input_fd < 0) {
    674                 printf(NAME ": Failed opening %s\n", input);
     664static bool console_init(void)
     665{
     666        ipcarg_t color_cap;
     667
     668        /* Connect to keyboard driver */
     669        kbd_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_KEYBOARD, 0, 0);
     670        if (kbd_phone < 0) {
     671                printf(NAME ": Failed to connect to keyboard service\n");
    675672                return false;
    676673        }
    677674       
    678         kbd_phone = fd_phone(input_fd);
    679         if (kbd_phone < 0) {
    680                 printf(NAME ": Failed to connect to input device\n");
    681                 return false;
    682         }
    683        
    684         /* NB: The callback connection is slotted for removal */
    685675        ipcarg_t phonehash;
    686676        if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
    687                 printf(NAME ": Failed to create callback from input device\n");
     677                printf(NAME ": Failed to create callback from keyboard service\n");
    688678                return false;
    689679        }
     
    709699       
    710700        /* Synchronize, the gcons could put something in queue */
    711         ipcarg_t color_cap;
    712701        async_req_0_0(fb_info.phone, FB_FLUSH);
    713702        async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows);
     
    747736                        consoles[i].refcount = 0;
    748737                       
    749                         char vc[DEVMAP_NAME_MAXLEN + 1];
    750                         snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%u", NAMESPACE, i);
     738                        char vc[MAX_DEVICE_NAME];
     739                        snprintf(vc, MAX_DEVICE_NAME, "vc%u", i);
    751740                       
    752741                        if (devmap_device_register(vc, &consoles[i].dev_handle) != EOK) {
     
    779768}
    780769
    781 static void usage(void)
    782 {
    783         printf("Usage: console <input>\n");
    784 }
    785 
    786770int main(int argc, char *argv[])
    787771{
    788         if (argc < 2) {
    789                 usage();
    790                 return -1;
    791         }
    792        
    793772        printf(NAME ": HelenOS Console service\n");
    794773       
    795         if (!console_init(argv[1]))
     774        if (!console_init())
    796775                return -1;
    797776       
Note: See TracChangeset for help on using the changeset viewer.