Changeset 47a350f in mainline


Ignore:
Timestamp:
2009-12-16T01:49:16Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
df747bd8
Parents:
4491338
Message:

keyboard is not a single possible human input device, thus don't register the kbd driver as a singleton service to the Naming service, but to the Device mapper

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/init/init.c

    r4491338 r47a350f  
    5050#include "init.h"
    5151
     52#define DEVFS_MOUNT_POINT  "/dev"
     53
     54#define SRV_CONSOLE  "/srv/console"
     55#define APP_GETVC    "/app/getvc"
     56
    5257static void info_print(void)
    5358{
     
    98103       
    99104        snprintf(null, MAX_DEVICE_NAME, "null/%d", null_id);
    100         int rc = mount("devfs", "/dev", null, "", IPC_FLAG_BLOCKING);
     105        int rc = mount("devfs", DEVFS_MOUNT_POINT, null, "", IPC_FLAG_BLOCKING);
    101106       
    102107        switch (rc) {
     
    176181}
    177182
     183static void console(char *dev)
     184{
     185        char *argv[3];
     186        char hid_in[MAX_DEVICE_NAME];
     187        int rc;
     188       
     189        snprintf(hid_in, MAX_DEVICE_NAME, "%s/%s", DEVFS_MOUNT_POINT, dev);
     190       
     191        printf(NAME ": Spawning %s with %s\n", SRV_CONSOLE, hid_in);
     192       
     193        /* Wait for the input device to be ready */
     194        dev_handle_t handle;
     195        rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING);
     196       
     197        if (rc == EOK) {
     198                argv[0] = SRV_CONSOLE;
     199                argv[1] = hid_in;
     200                argv[2] = NULL;
     201               
     202                if (!task_spawn(SRV_CONSOLE, argv))
     203                        printf(NAME ": Error spawning %s with %s\n", SRV_CONSOLE, hid_in);
     204        } else
     205                printf(NAME ": Error waiting on %s\n", hid_in);
     206}
     207
    178208static void getvc(char *dev, char *app)
    179209{
     
    182212        int rc;
    183213       
    184         snprintf(vc, MAX_DEVICE_NAME, "/dev/%s", dev);
    185        
    186         printf(NAME ": Spawning getvc on %s\n", vc);
    187        
     214        snprintf(vc, MAX_DEVICE_NAME, "%s/%s", DEVFS_MOUNT_POINT, dev);
     215       
     216        printf(NAME ": Spawning %s on %s\n", APP_GETVC, vc);
     217       
     218        /* Wait for the terminal device to be ready */
    188219        dev_handle_t handle;
    189220        rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING);
    190221       
    191222        if (rc == EOK) {
    192                 argv[0] = "/app/getvc";
     223                argv[0] = APP_GETVC;
    193224                argv[1] = vc;
    194225                argv[2] = app;
    195226                argv[3] = NULL;
    196227               
    197                 if (!task_spawn("/app/getvc", argv))
    198                         printf(NAME ": Error spawning getvc on %s\n", vc);
    199         } else {
     228                if (!task_spawn(APP_GETVC, argv))
     229                        printf(NAME ": Error spawning %s on %s\n", APP_GETVC, vc);
     230        } else
    200231                printf(NAME ": Error waiting on %s\n", vc);
    201         }
    202232}
    203233
     
    234264        spawn("/srv/fb");
    235265        spawn("/srv/kbd");
    236         spawn("/srv/console");
     266        console("hid_in/kbd");
     267       
    237268        spawn("/srv/clip");
    238269        spawn("/srv/fhc");
  • uspace/lib/libc/include/ipc/services.h

    r4491338 r47a350f  
    4141        SERVICE_LOAD = 1,
    4242        SERVICE_PCI,
    43         SERVICE_KEYBOARD,
    4443        SERVICE_VIDEO,
    4544        SERVICE_CONSOLE,
  • uspace/srv/console/console.c

    r4491338 r47a350f  
    5050#include <event.h>
    5151#include <devmap.h>
     52#include <fcntl.h>
     53#include <vfs/vfs.h>
    5254#include <fibril_synch.h>
    5355
     
    665667}
    666668
    667 static bool console_init(void)
    668 {
    669         ipcarg_t color_cap;
    670 
    671         /* Connect to keyboard driver */
    672         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);
    673679        if (kbd_phone < 0) {
    674                 printf(NAME ": Failed to connect to keyboard service\n");
     680                printf(NAME ": Failed to connect to input device\n");
    675681                return false;
    676682        }
    677683       
     684        /* NB: The callback connection is slotted for removal */
    678685        ipcarg_t phonehash;
    679686        if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
    680                 printf(NAME ": Failed to create callback from keyboard service\n");
     687                printf(NAME ": Failed to create callback from input device\n");
    681688                return false;
    682689        }
     
    702709       
    703710        /* Synchronize, the gcons could put something in queue */
     711        ipcarg_t color_cap;
    704712        async_req_0_0(fb_info.phone, FB_FLUSH);
    705713        async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows);
     
    771779}
    772780
     781static void usage(void)
     782{
     783        printf("Usage: console <input>\n");
     784}
     785
    773786int main(int argc, char *argv[])
    774787{
     788        if (argc < 2) {
     789                usage();
     790                return -1;
     791        }
     792       
    775793        printf(NAME ": HelenOS Console service\n");
    776794       
    777         if (!console_init())
     795        if (!console_init(argv[1]))
    778796                return -1;
    779797       
  • uspace/srv/kbd/generic/kbd.c

    r4491338 r47a350f  
    5050#include <io/console.h>
    5151#include <io/keycode.h>
     52#include <devmap.h>
    5253
    5354#include <kbd.h>
     
    5657#include <layout.h>
    5758
    58 #define NAME "kbd"
    59 
    60 int cons_connected = 0;
     59#define NAME       "kbd"
     60#define NAMESPACE  "hid_in"
     61
    6162int phone2cons = -1;
    6263
     
    172173        int retval;
    173174
    174         if (cons_connected) {
    175                 ipc_answer_0(iid, ELIMIT);
    176                 return;
    177         }
    178         cons_connected = 1;
    179175        ipc_answer_0(iid, EOK);
    180176
     
    183179                switch (IPC_GET_METHOD(call)) {
    184180                case IPC_M_PHONE_HUNGUP:
    185                         cons_connected = 0;
    186                         ipc_hangup(phone2cons);
    187                         phone2cons = -1;
     181                        if (phone2cons != -1) {
     182                                ipc_hangup(phone2cons);
     183                                phone2cons = -1;
     184                        }
     185                       
    188186                        ipc_answer_0(callid, EOK);
    189187                        return;
     
    216214        printf(NAME ": HelenOS Keyboard service\n");
    217215       
    218         ipcarg_t phonead;
    219        
    220216        if (sysinfo_value("kbd.cir.fhc") == 1)
    221217                cir_service = SERVICE_FHC;
     
    241237        layout[active_layout]->reset();
    242238       
    243         async_set_client_connection(console_connection);
    244 
    245         /* Register service at nameserver. */
    246         if (ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, 0, &phonead) != 0)
    247                 return -1;
    248        
     239        /* Register driver */
     240        int rc = devmap_driver_register(NAME, console_connection);
     241        if (rc < 0) {
     242                printf(NAME ": Unable to register driver (%d)\n", rc);
     243                return -1;
     244        }
     245       
     246        char kbd[DEVMAP_NAME_MAXLEN + 1];
     247        snprintf(kbd, DEVMAP_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);
     248       
     249        dev_handle_t dev_handle;
     250        if (devmap_device_register(kbd, &dev_handle) != EOK) {
     251                printf(NAME ": Unable to register device %s\n", kbd);
     252                return -1;
     253        }
     254
    249255        printf(NAME ": Accepting connections\n");
    250256        async_manager();
Note: See TracChangeset for help on using the changeset viewer.