Ignore:
File:
1 edited

Legend:

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

    rcc1f8d4 r47a350f  
    5050#include <event.h>
    5151#include <devmap.h>
    52 #include <fibril_sync.h>
     52#include <fcntl.h>
     53#include <vfs/vfs.h>
     54#include <fibril_synch.h>
    5355
    5456#include "console.h"
     
    5759#include "screenbuffer.h"
    5860
    59 #define NAME  "console"
    60 
    61 #define MAX_DEVICE_NAME  32
     61#define NAME       "console"
     62#define NAMESPACE  "term"
    6263
    6364/** Phone to the keyboard driver. */
     
    6970        ipcarg_t cols;  /**< Framebuffer columns */
    7071        ipcarg_t rows;  /**< Framebuffer rows */
    71         int color_cap;  /**< Color capabilities (FB_CCAP_xxx) */
     72        int color_cap;  /**< Color capabilities (FB_CCAP_xxx) */
    7273} fb_info;
    7374
     
    601602                                    IPC_GET_ARG2(call));
    602603                        break;
     604                case CONSOLE_GET_POS:
     605                        arg1 = cons->scr.position_x;
     606                        arg2 = cons->scr.position_y;
     607                        break;
    603608                case CONSOLE_GET_SIZE:
    604609                        arg1 = fb_info.cols;
     
    662667}
    663668
    664 static 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);
     669static 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);
     675                return false;
     676        }
     677       
     678        kbd_phone = fd_phone(input_fd);
    670679        if (kbd_phone < 0) {
    671                 printf(NAME ": Failed to connect to keyboard service\n");
     680                printf(NAME ": Failed to connect to input device\n");
    672681                return false;
    673682        }
    674683       
     684        /* NB: The callback connection is slotted for removal */
    675685        ipcarg_t phonehash;
    676686        if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
    677                 printf(NAME ": Failed to create callback from keyboard service\n");
     687                printf(NAME ": Failed to create callback from input device\n");
    678688                return false;
    679689        }
     
    699709       
    700710        /* Synchronize, the gcons could put something in queue */
     711        ipcarg_t color_cap;
    701712        async_req_0_0(fb_info.phone, FB_FLUSH);
    702713        async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows);
     
    736747                        consoles[i].refcount = 0;
    737748                       
    738                         char vc[MAX_DEVICE_NAME];
    739                         snprintf(vc, MAX_DEVICE_NAME, "vc%u", i);
     749                        char vc[DEVMAP_NAME_MAXLEN + 1];
     750                        snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%u", NAMESPACE, i);
    740751                       
    741752                        if (devmap_device_register(vc, &consoles[i].dev_handle) != EOK) {
     
    768779}
    769780
     781static void usage(void)
     782{
     783        printf("Usage: console <input>\n");
     784}
     785
    770786int main(int argc, char *argv[])
    771787{
     788        if (argc < 2) {
     789                usage();
     790                return -1;
     791        }
     792       
    772793        printf(NAME ": HelenOS Console service\n");
    773794       
    774         if (!console_init())
     795        if (!console_init(argv[1]))
    775796                return -1;
    776797       
Note: See TracChangeset for help on using the changeset viewer.