Changeset 1d2a1a9 in mainline for uspace/srv/hid


Ignore:
Timestamp:
2011-08-17T20:44:32Z (15 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0cc32f2
Parents:
bb285b4 (diff), c53a705 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix changes.

Location:
uspace/srv/hid
Files:
10 added
11 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/console/Makefile

    rbb285b4 r1d2a1a9  
    2929
    3030USPACE_PREFIX = ../../..
     31LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a
     32EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX)
    3133BINARY = console
    3234
    33 GENERIC_SOURCES = \
     35SOURCES = \
    3436        console.c \
    3537        keybuffer.c \
     38        images.c \
    3639        gcons.c
    3740
    3841IMAGES = \
    39         gfx/helenos.ppm \
    40         gfx/nameic.ppm \
    41         gfx/cons_selected.ppm \
    42         gfx/cons_idle.ppm \
    43         gfx/cons_has_data.ppm \
    44         gfx/cons_kernel.ppm \
    45         gfx/anim_1.ppm \
    46         gfx/anim_2.ppm \
    47         gfx/anim_3.ppm \
    48         gfx/anim_4.ppm
     42        gfx/helenos.tga \
     43        gfx/nameic.tga \
     44        gfx/cons_selected.tga \
     45        gfx/cons_idle.tga \
     46        gfx/cons_has_data.tga \
     47        gfx/cons_kernel.tga \
     48        gfx/anim_1.tga \
     49        gfx/anim_2.tga \
     50        gfx/anim_3.tga \
     51        gfx/anim_4.tga
    4952
    50 SOURCES = \
    51         $(GENERIC_SOURCES) \
    52         $(IMAGES)
     53PRE_DEPEND = images.c images.h
     54EXTRA_CLEAN = images.c images.h
    5355
    5456include $(USPACE_PREFIX)/Makefile.common
    5557
    56 %.o: %.ppm
    57         $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) $< $@
     58images.c images.h: $(IMAGES)
     59        $(ROOT_PATH)/tools/mkarray.py images CONSOLE_IMAGES $^
  • uspace/srv/hid/console/console.c

    rbb285b4 r1d2a1a9  
    5353#include <sysinfo.h>
    5454#include <event.h>
    55 #include <devmap.h>
     55#include <loc.h>
    5656#include <fcntl.h>
    5757#include <vfs/vfs.h>
     
    8181        size_t index;             /**< Console index */
    8282        size_t refcount;          /**< Connection reference count */
    83         devmap_handle_t devmap_handle;  /**< Device handle */
     83        service_id_t service_id;  /**< Service ID */
    8484        keybuffer_t keybuffer;    /**< Buffer for incoming keys. */
    8585        screenbuffer_t scr;       /**< Screenbuffer for saving screen
     
    582582                        continue;
    583583               
    584                 if (consoles[i].devmap_handle == (devmap_handle_t) IPC_GET_ARG1(*icall)) {
     584                if (consoles[i].service_id == (service_id_t) IPC_GET_ARG1(*icall)) {
    585585                        cons = &consoles[i];
    586586                        break;
     
    721721}
    722722
    723 static async_sess_t *connect_input(const char *dev_path)
     723static async_sess_t *connect_input(const char *svc_path)
    724724{
    725725        async_sess_t *sess;
    726726        async_exch_t *exch;
    727         devmap_handle_t handle;
    728        
    729         int rc = devmap_device_get_handle(dev_path, &handle, 0);
     727        service_id_t service_id;
     728       
     729        int rc = loc_service_get_id(svc_path, &service_id, 0);
    730730        if (rc == EOK) {
    731                 sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     731                sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
    732732                if (sess == NULL) {
    733733                        printf("%s: Failed to connect to input server\n", NAME);
     
    773773        }
    774774       
    775         /* Register driver */
    776         int rc = devmap_driver_register(NAME, client_connection);
     775        /* Register server */
     776        int rc = loc_server_register(NAME, client_connection);
    777777        if (rc < 0) {
    778                 printf("%s: Unable to register driver (%d)\n", NAME, rc);
     778                printf("%s: Unable to register server (%d)\n", NAME, rc);
    779779                return false;
    780780        }
     
    820820                        consoles[i].refcount = 0;
    821821                       
    822                         char vc[DEVMAP_NAME_MAXLEN + 1];
    823                         snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
     822                        char vc[LOC_NAME_MAXLEN + 1];
     823                        snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
    824824                       
    825                         if (devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) {
    826                                 printf("%s: Unable to register device %s\n", NAME, vc);
     825                        if (loc_service_register(vc, &consoles[i].service_id) != EOK) {
     826                                printf("%s: Unable to register service %s\n", NAME, vc);
    827827                                return false;
    828828                        }
  • uspace/srv/hid/console/gcons.c

    rbb285b4 r1d2a1a9  
    4141#include <align.h>
    4242#include <bool.h>
     43#include <imgmap.h>
    4344
    4445#include "console.h"
    4546#include "gcons.h"
     47#include "images.h"
    4648
    4749#define CONSOLE_TOP     66
     
    5860#define COLOR_BACKGROUND  0xffffff
    5961
    60 extern char _binary_gfx_helenos_ppm_start[0];
    61 extern int _binary_gfx_helenos_ppm_size;
    62 extern char _binary_gfx_nameic_ppm_start[0];
    63 extern int _binary_gfx_nameic_ppm_size;
    64 
    65 extern char _binary_gfx_anim_1_ppm_start[0];
    66 extern int _binary_gfx_anim_1_ppm_size;
    67 extern char _binary_gfx_anim_2_ppm_start[0];
    68 extern int _binary_gfx_anim_2_ppm_size;
    69 extern char _binary_gfx_anim_3_ppm_start[0];
    70 extern int _binary_gfx_anim_3_ppm_size;
    71 extern char _binary_gfx_anim_4_ppm_start[0];
    72 extern int _binary_gfx_anim_4_ppm_size;
    73 
    74 extern char _binary_gfx_cons_selected_ppm_start[0];
    75 extern int _binary_gfx_cons_selected_ppm_size;
    76 extern char _binary_gfx_cons_idle_ppm_start[0];
    77 extern int _binary_gfx_cons_idle_ppm_size;
    78 extern char _binary_gfx_cons_has_data_ppm_start[0];
    79 extern int _binary_gfx_cons_has_data_ppm_size;
    80 extern char _binary_gfx_cons_kernel_ppm_start[0];
    81 extern int _binary_gfx_cons_kernel_ppm_size;
    82 
    8362static bool use_gcons = false;
    8463static sysarg_t xres;
    8564static sysarg_t yres;
     65
     66static imgmap_t *helenos_img;
     67static imgmap_t *nameic_img;
     68
     69static imgmap_t *anim_1_img;
     70static imgmap_t *anim_2_img;
     71static imgmap_t *anim_3_img;
     72static imgmap_t *anim_4_img;
     73
     74static imgmap_t *cons_has_data_img;
     75static imgmap_t *cons_idle_img;
     76static imgmap_t *cons_kernel_img;
     77static imgmap_t *cons_selected_img;
    8678
    8779enum butstate {
     
    10193static int fbphone;
    10294
    103 /** List of pixmaps identifying these icons */
    104 static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
     95/** List of image maps identifying these icons */
     96static int ic_imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
    10597static int animation = -1;
    10698
     
    149141        enum butstate state = console_state[index];
    150142       
    151         if (ic_pixmaps[state] != -1)
    152                 async_obsolete_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index],
    153                     ic_pixmaps[state]);
     143        if (ic_imgmaps[state] != -1)
     144                async_obsolete_msg_2(fbphone, FB_VP_DRAW_IMGMAP, cstatus_vp[index],
     145                    ic_imgmaps[state]);
    154146       
    155147        if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL)
     
    358350}
    359351
    360 /** Draw a PPM pixmap to framebuffer
    361  *
    362  * @param logo Pointer to PPM data
    363  * @param size Size of PPM data
    364  * @param x Coordinate of upper left corner
    365  * @param y Coordinate of upper left corner
    366  *
    367  */
    368 static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y)
    369 {
     352/** Draw an image map to framebuffer
     353 *
     354 * @param img  Image map
     355 * @param x    Coordinate of upper left corner
     356 * @param y    Coordinate of upper left corner
     357 *
     358 */
     359static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y)
     360{
     361        if (img == NULL)
     362                return;
     363       
    370364        /* Create area */
    371         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     365        char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    372366            MAP_ANONYMOUS, 0, 0);
    373367        if (shm == MAP_FAILED)
    374368                return;
    375369       
    376         memcpy(shm, logo, size);
     370        memcpy(shm, img, img->size);
    377371       
    378372        /* Send area */
     
    386380       
    387381        /* Draw logo */
    388         async_obsolete_msg_2(fbphone, FB_DRAW_PPM, x, y);
     382        async_obsolete_msg_2(fbphone, FB_DRAW_IMGMAP, x, y);
    389383       
    390384drop:
     
    394388exit:
    395389        /* Remove area */
    396         munmap(shm, size);
     390        munmap(shm, img->size);
    397391}
    398392
     
    406400        set_rgb_color(COLOR_MAIN, COLOR_MAIN);
    407401        clear();
    408         draw_pixmap(_binary_gfx_helenos_ppm_start,
    409             (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2);
    410         draw_pixmap(_binary_gfx_nameic_ppm_start,
    411             (size_t) &_binary_gfx_nameic_ppm_size, 5, 17);
     402        draw_imgmap(helenos_img, xres - 66, 2);
     403        draw_imgmap(nameic_img, 5, 17);
    412404       
    413405        unsigned int i;
     
    418410}
    419411
    420 /** Creates a pixmap on framebuffer
    421  *
    422  * @param data PPM data
    423  * @param size PPM data size
    424  *
    425  * @return Pixmap identification
    426  *
    427  */
    428 static int make_pixmap(char *data, size_t size)
    429 {
     412/** Create an image map on framebuffer
     413 *
     414 * @param img Image map.
     415 *
     416 * @return Image map identification
     417 *
     418 */
     419static int make_imgmap(imgmap_t *img)
     420{
     421        if (img == NULL)
     422                return -1;
     423       
    430424        /* Create area */
    431         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    432             MAP_ANONYMOUS, 0, 0);
     425        char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE,
     426            MAP_SHARED | MAP_ANONYMOUS, 0, 0);
    433427        if (shm == MAP_FAILED)
    434428                return -1;
    435429       
    436         memcpy(shm, data, size);
    437        
    438         int pxid = -1;
     430        memcpy(shm, img, img->size);
     431       
     432        int id = -1;
    439433       
    440434        /* Send area */
     
    447441                goto drop;
    448442       
    449         /* Obtain pixmap */
    450         rc = async_obsolete_req_0_0(fbphone, FB_SHM2PIXMAP);
     443        /* Obtain image map identifier */
     444        rc = async_obsolete_req_0_0(fbphone, FB_SHM2IMGMAP);
    451445        if (rc < 0)
    452446                goto drop;
    453447       
    454         pxid = rc;
     448        id = rc;
    455449       
    456450drop:
     
    460454exit:
    461455        /* Remove area */
    462         munmap(shm, size);
    463        
    464         return pxid;
     456        munmap(shm, img->size);
     457       
     458        return id;
    465459}
    466460
     
    472466                return;
    473467       
    474         int pm = make_pixmap(_binary_gfx_anim_1_ppm_start,
    475             (size_t) &_binary_gfx_anim_1_ppm_size);
    476         async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    477        
    478         pm = make_pixmap(_binary_gfx_anim_2_ppm_start,
    479             (size_t) &_binary_gfx_anim_2_ppm_size);
    480         async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    481        
    482         pm = make_pixmap(_binary_gfx_anim_3_ppm_start,
    483             (size_t) &_binary_gfx_anim_3_ppm_size);
    484         async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    485        
    486         pm = make_pixmap(_binary_gfx_anim_4_ppm_start,
    487             (size_t) &_binary_gfx_anim_4_ppm_size);
    488         async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
     468        int pm = make_imgmap(anim_1_img);
     469        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     470       
     471        pm = make_imgmap(anim_2_img);
     472        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     473       
     474        pm = make_imgmap(anim_3_img);
     475        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     476       
     477        pm = make_imgmap(anim_4_img);
     478        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
    489479       
    490480        async_obsolete_msg_1(fbphone, FB_ANIM_START, an);
     
    504494        if ((xres < 800) || (yres < 600))
    505495                return;
     496       
     497        /* Create image maps */
     498        helenos_img = imgmap_decode_tga((void *) helenos_tga,
     499            helenos_tga_size);
     500        nameic_img = imgmap_decode_tga((void *) nameic_tga,
     501            nameic_tga_size);
     502       
     503        anim_1_img = imgmap_decode_tga((void *) anim_1_tga,
     504            anim_1_tga_size);
     505        anim_2_img = imgmap_decode_tga((void *) anim_2_tga,
     506            anim_2_tga_size);
     507        anim_3_img = imgmap_decode_tga((void *) anim_3_tga,
     508            anim_3_tga_size);
     509        anim_4_img = imgmap_decode_tga((void *) anim_4_tga,
     510            anim_4_tga_size);
     511       
     512        cons_has_data_img = imgmap_decode_tga((void *) cons_has_data_tga,
     513            cons_has_data_tga_size);
     514        cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga,
     515            cons_idle_tga_size);
     516        cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga,
     517            cons_kernel_tga_size);
     518        cons_selected_img = imgmap_decode_tga((void *) cons_selected_tga,
     519            cons_selected_tga_size);
    506520       
    507521        /* Create console viewport */
     
    531545       
    532546        /* Initialize icons */
    533         ic_pixmaps[CONS_SELECTED] =
    534             make_pixmap(_binary_gfx_cons_selected_ppm_start,
    535             (size_t) &_binary_gfx_cons_selected_ppm_size);
    536         ic_pixmaps[CONS_IDLE] =
    537             make_pixmap(_binary_gfx_cons_idle_ppm_start,
    538             (size_t) &_binary_gfx_cons_idle_ppm_size);
    539         ic_pixmaps[CONS_HAS_DATA] =
    540             make_pixmap(_binary_gfx_cons_has_data_ppm_start,
    541             (size_t) &_binary_gfx_cons_has_data_ppm_size);
    542         ic_pixmaps[CONS_DISCONNECTED] =
    543             make_pixmap(_binary_gfx_cons_idle_ppm_start,
    544             (size_t) &_binary_gfx_cons_idle_ppm_size);
    545         ic_pixmaps[CONS_KERNEL] =
    546             make_pixmap(_binary_gfx_cons_kernel_ppm_start,
    547             (size_t) &_binary_gfx_cons_kernel_ppm_size);
    548         ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
     547        ic_imgmaps[CONS_SELECTED] = make_imgmap(cons_selected_img);
     548        ic_imgmaps[CONS_IDLE] = make_imgmap(cons_idle_img);
     549        ic_imgmaps[CONS_HAS_DATA] = make_imgmap(cons_has_data_img);
     550        ic_imgmaps[CONS_DISCONNECTED] = make_imgmap(cons_idle_img);
     551        ic_imgmaps[CONS_KERNEL] = make_imgmap(cons_kernel_img);
     552        ic_imgmaps[CONS_DISCONNECTED_SEL] = ic_imgmaps[CONS_SELECTED];
    549553       
    550554        make_anim();
  • uspace/srv/hid/fb/Makefile

    rbb285b4 r1d2a1a9  
    4040
    4141SOURCES = \
    42         main.c \
    43         ppm.c
     42        main.c
    4443
    4544ifneq ($(UARCH),ia64)
     
    8685endif
    8786
    88 EXTRA_CFLAGS += -D$(UARCH)
     87LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a
     88EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX) -D$(UARCH)
    8989
    9090include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/fb/ega.c

    rbb285b4 r1d2a1a9  
    5656
    5757// FIXME: remove this header
    58 #include <kernel/ipc/ipc_methods.h>
     58#include <abi/ipc/methods.h>
    5959
    6060#define MAX_SAVED_SCREENS  256
     
    414414                        retval = 0;
    415415                        break;
    416                 case FB_VP_DRAW_PIXMAP:
     416                case FB_VP_DRAW_IMGMAP:
    417417                        scr = IPC_GET_ARG2(call);
    418418                        retval = print_screen(scr);
    419419                        break;
    420                 case FB_VP2PIXMAP:
     420                case FB_VP2IMGMAP:
    421421                        retval = save_screen();
    422422                        break;
    423                 case FB_DROP_PIXMAP:
     423                case FB_DROP_IMGMAP:
    424424                        scr = IPC_GET_ARG1(call);
    425425                       
  • uspace/srv/hid/fb/fb.c

    rbb285b4 r1d2a1a9  
    4949#include <ipc/ns.h>
    5050#include <ipc/services.h>
    51 #include <kernel/errno.h>
    52 #include <kernel/genarch/fb/visuals.h>
     51#include <errno.h>
     52#include <abi/fb/visuals.h>
    5353#include <io/color.h>
    5454#include <io/style.h>
     
    5959#include <byteorder.h>
    6060#include <io/screenbuffer.h>
     61#include <imgmap.h>
    6162#include "font-8x16.h"
    6263#include "fb.h"
    6364#include "main.h"
    64 #include "ppm.h"
    6565#include "pointer.xbm"
    6666#include "pointer_mask.xbm"
    6767
    6868// FIXME: remove this header
    69 #include <kernel/ipc/ipc_methods.h>
     69#include <abi/ipc/methods.h>
    7070
    7171#define DEFAULT_BGCOLOR  0xf0f0f0
     
    7676#define MAX_ANIM_LEN    8
    7777#define MAX_ANIMATIONS  4
    78 #define MAX_PIXMAPS     256  /**< Maximum number of saved pixmaps */
     78#define MAX_IMGMAPS     256  /**< Maximum number of saved image maps */
    7979#define MAX_VIEWPORTS   128  /**< Viewport is a rectangular area on the screen */
    8080
     
    160160        unsigned int pos;
    161161        unsigned int animlen;
    162         unsigned int pixmaps[MAX_ANIM_LEN];
     162        unsigned int imgmaps[MAX_ANIM_LEN];
    163163} animation_t;
    164164
     
    166166static bool anims_enabled;
    167167
    168 typedef struct {
    169         unsigned int width;
    170         unsigned int height;
    171         uint8_t *data;
    172 } pixmap_t;
    173 
    174 static pixmap_t pixmaps[MAX_PIXMAPS];
     168static imgmap_t *imgmaps[MAX_IMGMAPS];
    175169static viewport_t viewports[128];
    176170
     
    212206static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col,
    213207    unsigned int row);
    214 
    215208
    216209#define RED(x, bits)                 (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1))
     
    875868}
    876869
    877 
    878870/** Show cursor if cursor showing is enabled
    879871 *
     
    888880}
    889881
    890 
    891882/** Invert cursor, if it is enabled
    892883 *
     
    899890                cursor_show(vport);
    900891}
    901 
    902892
    903893/** Draw character at given position relative to viewport
     
    981971}
    982972
    983 
    984 static void putpixel_pixmap(void *data, unsigned int x, unsigned int y, uint32_t color)
    985 {
    986         int pm = *((int *) data);
    987         pixmap_t *pmap = &pixmaps[pm];
    988         unsigned int pos = (y * pmap->width + x) * screen.pixelbytes;
    989        
    990         screen.rgb_conv(&pmap->data[pos], color);
    991 }
    992 
    993 
    994 static void putpixel(void *data, unsigned int x, unsigned int y, uint32_t color)
    995 {
    996         viewport_t *vport = (viewport_t *) data;
     973static void putpixel(viewport_t *vport, unsigned int x, unsigned int y,
     974    uint32_t color)
     975{
    997976        unsigned int dx = vport->x + x;
    998977        unsigned int dy = vport->y + y;
     
    1001980}
    1002981
    1003 
    1004 /** Return first free pixmap
    1005  *
    1006  */
    1007 static int find_free_pixmap(void)
     982/** Draw image map
     983 *
     984 * @param[in] img       Image map.
     985 * @param[in] sx        Coordinate of upper left corner.
     986 * @param[in] sy        Coordinate of upper left corner.
     987 * @param[in] maxwidth  Maximum allowed width for picture.
     988 * @param[in] maxheight Maximum allowed height for picture.
     989 * @param[in] vport     Viewport.
     990 *
     991 * @return EOK on success.
     992 *
     993 */
     994static int imgmap_draw(imgmap_t *img, unsigned int sx, unsigned int sy,
     995    unsigned int maxwidth, unsigned int maxheight, void *vport)
     996{
     997        if (img->visual != VISUAL_BGR_8_8_8)
     998                return EINVAL;
     999       
     1000        uint8_t *data = (uint8_t *) img->data;
     1001       
     1002        for (sysarg_t y = 0; y < img->height; y++) {
     1003                for (sysarg_t x = 0; x < img->width; x++) {
     1004                        if ((x > maxwidth) || (y > maxheight)) {
     1005                                data += 3;
     1006                                continue;
     1007                        }
     1008                       
     1009                        uint32_t color = (data[2] << 16) + (data[1] << 8) + data[0];
     1010                       
     1011                        putpixel(vport, sx + x, sy + y, color);
     1012                        data += 3;
     1013                }
     1014        }
     1015       
     1016        return EOK;
     1017}
     1018
     1019/** Return first free image map
     1020 *
     1021 */
     1022static int find_free_imgmap(void)
    10081023{
    10091024        unsigned int i;
    10101025       
    1011         for (i = 0; i < MAX_PIXMAPS; i++)
    1012                 if (!pixmaps[i].data)
     1026        for (i = 0; i < MAX_IMGMAPS; i++)
     1027                if (!imgmaps[i])
    10131028                        return i;
    10141029       
     
    10161031}
    10171032
    1018 
    1019 /** Create a new pixmap and return appropriate ID
    1020  *
    1021  */
    1022 static int shm2pixmap(unsigned char *shm, size_t size)
    1023 {
    1024         int pm;
    1025         pixmap_t *pmap;
    1026        
    1027         pm = find_free_pixmap();
    1028         if (pm == -1)
     1033/** Create a new image map and return appropriate ID
     1034 *
     1035 */
     1036static int shm2imgmap(imgmap_t *shm, size_t size)
     1037{
     1038        int im = find_free_imgmap();
     1039        if (im == -1)
    10291040                return ELIMIT;
    10301041       
    1031         pmap = &pixmaps[pm];
    1032        
    1033         if (ppm_get_data(shm, size, &pmap->width, &pmap->height))
    1034                 return EINVAL;
    1035        
    1036         pmap->data = malloc(pmap->width * pmap->height * screen.pixelbytes);
    1037         if (!pmap->data)
     1042        imgmap_t *imap = malloc(size);
     1043        if (!imap)
    10381044                return ENOMEM;
    10391045       
    1040         ppm_draw(shm, size, 0, 0, pmap->width, pmap->height, putpixel_pixmap, (void *) &pm);
    1041        
    1042         return pm;
    1043 }
    1044 
     1046        memcpy(imap, shm, size);
     1047        imgmaps[im] = imap;
     1048        return im;
     1049}
    10451050
    10461051/** Handle shared memory communication calls
    10471052 *
    1048  * Protocol for drawing pixmaps:
     1053 * Protocol for drawing image maps:
    10491054 * - FB_PREPARE_SHM(client shm identification)
    10501055 * - IPC_M_AS_AREA_SEND
    1051  * - FB_DRAW_PPM(startx, starty)
     1056 * - FB_DRAW_IMGMAP(startx, starty)
    10521057 * - FB_DROP_SHM
    10531058 *
     
    10711076        static size_t intersize = 0;
    10721077       
    1073         static unsigned char *shm = NULL;
     1078        static imgmap_t *shm = NULL;
    10741079        static sysarg_t shm_id = 0;
    10751080        static size_t shm_size;
     
    10931098                                return false;
    10941099                        }
     1100                       
    10951101                        shm = dest;
    1096                        
    1097                         if (shm[0] != 'P')
    1098                                 return false;
    1099                        
    11001102                        return true;
    11011103                } else {
     
    11071109                if (shm_id)
    11081110                        retval = EBUSY;
    1109                 else 
     1111                else
    11101112                        shm_id = IPC_GET_ARG1(*call);
    11111113                break;
    1112                
    11131114        case FB_DROP_SHM:
    11141115                if (shm) {
     
    11181119                shm_id = 0;
    11191120                break;
    1120                
    1121         case FB_SHM2PIXMAP:
     1121        case FB_SHM2IMGMAP:
    11221122                if (!shm) {
    11231123                        retval = EINVAL;
    11241124                        break;
    11251125                }
    1126                 retval = shm2pixmap(shm, shm_size);
    1127                 break;
    1128         case FB_DRAW_PPM:
     1126                retval = shm2imgmap(shm, shm_size);
     1127                break;
     1128        case FB_DRAW_IMGMAP:
    11291129                if (!shm) {
    11301130                        retval = EINVAL;
    11311131                        break;
    11321132                }
     1133               
    11331134                x = IPC_GET_ARG1(*call);
    11341135                y = IPC_GET_ARG2(*call);
     
    11391140                }
    11401141               
    1141                 ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),
    1142                     IPC_GET_ARG2(*call), vport->width - x, vport->height - y, putpixel, (void *) vport);
     1142                imgmap_draw(shm, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call),
     1143                    vport->width - x, vport->height - y, vport);
    11431144                break;
    11441145        case FB_DRAW_TEXT_DATA:
     
    11671168        if (handled)
    11681169                async_answer_0(callid, retval);
     1170       
    11691171        return handled;
    11701172}
    11711173
    1172 
    1173 static void copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap)
     1174static void copy_vp_to_imgmap(viewport_t *vport, imgmap_t *imap)
    11741175{
    11751176        unsigned int width = vport->width;
     
    11781179        if (width + vport->x > screen.xres)
    11791180                width = screen.xres - vport->x;
     1181       
    11801182        if (height + vport->y > screen.yres)
    11811183                height = screen.yres - vport->y;
    11821184       
    1183         unsigned int realwidth = pmap->width <= width ? pmap->width : width;
    1184         unsigned int realheight = pmap->height <= height ? pmap->height : height;
     1185        unsigned int realwidth = imap->width <= width ? imap->width : width;
     1186        unsigned int realheight = imap->height <= height ? imap->height : height;
    11851187       
    11861188        unsigned int srcrowsize = vport->width * screen.pixelbytes;
     
    11901192        for (y = 0; y < realheight; y++) {
    11911193                unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
    1192                 memcpy(pmap->data + srcrowsize * y, screen.fb_addr + tmp, realrowsize);
    1193         }
    1194 }
    1195 
    1196 
    1197 /** Save viewport to pixmap
    1198  *
    1199  */
    1200 static int save_vp_to_pixmap(viewport_t *vport)
    1201 {
    1202         int pm;
    1203         pixmap_t *pmap;
    1204        
    1205         pm = find_free_pixmap();
    1206         if (pm == -1)
     1194                memcpy(imap->data + srcrowsize * y, screen.fb_addr + tmp, realrowsize);
     1195        }
     1196}
     1197
     1198/** Save viewport to image map
     1199 *
     1200 */
     1201static int save_vp_to_imgmap(viewport_t *vport)
     1202{
     1203        int im = find_free_imgmap();
     1204        if (im == -1)
    12071205                return ELIMIT;
    12081206       
    1209         pmap = &pixmaps[pm];
    1210         pmap->data = malloc(screen.pixelbytes * vport->width * vport->height);
    1211         if (!pmap->data)
     1207        size_t size = screen.pixelbytes * vport->width * vport->height;
     1208        imgmap_t *imap = malloc(sizeof(imgmap_t) + size);
     1209        if (!imap)
    12121210                return ENOMEM;
    12131211       
    1214         pmap->width = vport->width;
    1215         pmap->height = vport->height;
    1216        
    1217         copy_vp_to_pixmap(vport, pmap);
    1218        
    1219         return pm;
    1220 }
    1221 
    1222 
    1223 /** Draw pixmap on screen
    1224  *
    1225  * @param vp Viewport to draw on
    1226  * @param pm Pixmap identifier
    1227  *
    1228  */
    1229 static int draw_pixmap(int vp, int pm)
    1230 {
    1231         pixmap_t *pmap = &pixmaps[pm];
     1212        imap->size = sizeof(imgmap_t) + size;
     1213        imap->width = vport->width;
     1214        imap->height = vport->height;
     1215        imap->visual = (visual_t) -1;
     1216       
     1217        copy_vp_to_imgmap(vport, imap);
     1218        imgmaps[im] = imap;
     1219        return im;
     1220}
     1221
     1222/** Draw image map to screen
     1223 *
     1224 * @param vp Viewport to draw to
     1225 * @param im Image map identifier
     1226 *
     1227 */
     1228static int draw_imgmap(int vp, int im)
     1229{
     1230        imgmap_t *imap = imgmaps[im];
     1231        if (!imap)
     1232                return EINVAL;
     1233       
    12321234        viewport_t *vport = &viewports[vp];
    12331235       
     
    12371239        if (width + vport->x > screen.xres)
    12381240                width = screen.xres - vport->x;
     1241       
    12391242        if (height + vport->y > screen.yres)
    12401243                height = screen.yres - vport->y;
    12411244       
    1242         if (!pmap->data)
    1243                 return EINVAL;
    1244        
    1245         unsigned int realwidth = pmap->width <= width ? pmap->width : width;
    1246         unsigned int realheight = pmap->height <= height ? pmap->height : height;
    1247        
    1248         unsigned int srcrowsize = vport->width * screen.pixelbytes;
    1249         unsigned int realrowsize = realwidth * screen.pixelbytes;
    1250        
    1251         unsigned int y;
    1252         for (y = 0; y < realheight; y++) {
    1253                 unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
    1254                 memcpy(screen.fb_addr + tmp, pmap->data + y * srcrowsize, realrowsize);
    1255         }
     1245        unsigned int realwidth = imap->width <= width ? imap->width : width;
     1246        unsigned int realheight = imap->height <= height ? imap->height : height;
     1247       
     1248        if (imap->visual == (visual_t) -1) {
     1249                unsigned int srcrowsize = vport->width * screen.pixelbytes;
     1250                unsigned int realrowsize = realwidth * screen.pixelbytes;
     1251               
     1252                unsigned int y;
     1253                for (y = 0; y < realheight; y++) {
     1254                        unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
     1255                        memcpy(screen.fb_addr + tmp, imap->data + y * srcrowsize, realrowsize);
     1256                }
     1257        } else
     1258                imgmap_draw(imap, 0, 0, realwidth, realheight, vport);
    12561259       
    12571260        return EOK;
    12581261}
    1259 
    12601262
    12611263/** Tick animation one step forward
     
    12771279                        continue;
    12781280               
    1279                 draw_pixmap(animations[i].vp, animations[i].pixmaps[animations[i].pos]);
     1281                draw_imgmap(animations[i].vp, animations[i].imgmaps[animations[i].pos]);
    12801282                animations[i].pos = (animations[i].pos + 1) % animations[i].animlen;
    12811283        }
     
    12871289static bool pointer_shown, pointer_enabled;
    12881290static int pointer_vport = -1;
    1289 static int pointer_pixmap = -1;
     1291static int pointer_imgmap = -1;
    12901292
    12911293
     
    13101312        }
    13111313       
    1312         if (pointer_pixmap == -1)
    1313                 pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]);
     1314        if (pointer_imgmap == -1)
     1315                pointer_imgmap = save_vp_to_imgmap(&viewports[pointer_vport]);
    13141316        else
    1315                 copy_vp_to_pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]);
     1317                copy_vp_to_imgmap(&viewports[pointer_vport], imgmaps[pointer_imgmap]);
    13161318       
    13171319        /* Draw mouse pointer. */
     
    13381340        /* Restore image under the pointer. */
    13391341        if (pointer_shown) {
    1340                 draw_pixmap(pointer_vport, pointer_pixmap);
     1342                draw_imgmap(pointer_vport, pointer_imgmap);
    13411343                pointer_shown = 0;
    13421344        }
     
    13931395                animations[i].initialized = 0;
    13941396                break;
    1395         case FB_ANIM_ADDPIXMAP:
     1397        case FB_ANIM_ADDIMGMAP:
    13961398                i = IPC_GET_ARG1(*call);
    13971399                if (i >= MAX_ANIMATIONS || i < 0 ||
     
    14051407                }
    14061408                newval = IPC_GET_ARG2(*call);
    1407                 if (newval < 0 || newval > MAX_PIXMAPS ||
    1408                         !pixmaps[newval].data) {
     1409                if (newval < 0 || newval > MAX_IMGMAPS ||
     1410                        !imgmaps[newval]) {
    14091411                        retval = EINVAL;
    14101412                        break;
    14111413                }
    1412                 animations[i].pixmaps[animations[i].animlen++] = newval;
     1414                animations[i].imgmaps[animations[i].animlen++] = newval;
    14131415                break;
    14141416        case FB_ANIM_CHGVP:
     
    14491451}
    14501452
    1451 
    1452 /** Handler for messages concerning pixmap handling
    1453  *
    1454  */
    1455 static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
     1453/** Handler for messages concerning image map handling
     1454 *
     1455 */
     1456static int imgmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
    14561457{
    14571458        bool handled = true;
     
    14601461       
    14611462        switch (IPC_GET_IMETHOD(*call)) {
    1462         case FB_VP_DRAW_PIXMAP:
     1463        case FB_VP_DRAW_IMGMAP:
    14631464                nvp = IPC_GET_ARG1(*call);
    14641465                if (nvp == -1)
    14651466                        nvp = vp;
     1467               
    14661468                if (nvp < 0 || nvp >= MAX_VIEWPORTS ||
    1467                         !viewports[nvp].initialized) {
     1469                    !viewports[nvp].initialized) {
    14681470                        retval = EINVAL;
    14691471                        break;
    14701472                }
     1473               
    14711474                i = IPC_GET_ARG2(*call);
    1472                 retval = draw_pixmap(nvp, i);
    1473                 break;
    1474         case FB_VP2PIXMAP:
     1475                retval = draw_imgmap(nvp, i);
     1476                break;
     1477        case FB_VP2IMGMAP:
    14751478                nvp = IPC_GET_ARG1(*call);
    14761479                if (nvp == -1)
    14771480                        nvp = vp;
     1481               
    14781482                if (nvp < 0 || nvp >= MAX_VIEWPORTS ||
    1479                         !viewports[nvp].initialized)
     1483                    !viewports[nvp].initialized) {
    14801484                        retval = EINVAL;
    1481                 else
    1482                         retval = save_vp_to_pixmap(&viewports[nvp]);
    1483                 break;
    1484         case FB_DROP_PIXMAP:
     1485                        break;
     1486                }
     1487               
     1488                retval = save_vp_to_imgmap(&viewports[nvp]);
     1489                break;
     1490        case FB_DROP_IMGMAP:
    14851491                i = IPC_GET_ARG1(*call);
    1486                 if (i >= MAX_PIXMAPS) {
     1492                if (i >= MAX_IMGMAPS) {
    14871493                        retval = EINVAL;
    14881494                        break;
    14891495                }
    1490                 if (pixmaps[i].data) {
    1491                         free(pixmaps[i].data);
    1492                         pixmaps[i].data = NULL;
    1493                 }
     1496               
     1497                if (imgmaps[i]) {
     1498                        free(imgmaps[i]);
     1499                        imgmaps[i] = NULL;
     1500                }
     1501               
    14941502                break;
    14951503        default:
     
    16161624                        continue;
    16171625               
    1618                 if (pixmap_handle(callid, &call, vp))
     1626                if (imgmap_handle(callid, &call, vp))
    16191627                        continue;
    16201628               
  • uspace/srv/hid/fb/fb.h

    rbb285b4 r1d2a1a9  
    3939#include <stdint.h>
    4040
    41 typedef void (* putpixel_cb_t)(void *, unsigned int, unsigned int, uint32_t);
    42 
    4341extern int fb_init(void);
    4442
  • uspace/srv/hid/fb/serial_console.c

    rbb285b4 r1d2a1a9  
    5353
    5454// FIXME: remove this header
    55 #include <kernel/ipc/ipc_methods.h>
     55#include <abi/ipc/methods.h>
    5656
    5757#define MAX_CONTROL 20
  • uspace/srv/hid/input/ctl/kbdev.c

    rbb285b4 r1d2a1a9  
    4848#include <kbd_ctl.h>
    4949#include <kbd_port.h>
     50#include <loc.h>
    5051#include <stdlib.h>
    5152#include <vfs/vfs_sess.h>
    52 
     53#include <sys/typefmt.h>
    5354
    5455static int kbdev_ctl_init(kbd_dev_t *);
     
    7071        /** Session with kbdev device */
    7172        async_sess_t *sess;
    72 
    73         /** File descriptor of open kbdev device */
    74         int fd;
    7573} kbdev_t;
    7674
     
    8482
    8583        kbdev->kbd_dev = kdev;
    86         kbdev->fd = -1;
    8784
    8885        return kbdev;
     
    9390        if (kbdev->sess != NULL)
    9491                async_hangup(kbdev->sess);
    95         if (kbdev->fd >= 0)
    96                 close(kbdev->fd);
    9792        free(kbdev);
    9893}
     
    10095static int kbdev_ctl_init(kbd_dev_t *kdev)
    10196{
    102         const char *pathname;
    10397        async_sess_t *sess;
    10498        async_exch_t *exch;
    10599        kbdev_t *kbdev;
    106         int fd;
    107100        int rc;
    108101
    109         pathname = kdev->dev_path;
    110 
    111         fd = open(pathname, O_RDWR);
    112         if (fd < 0) {
    113                 return -1;
    114         }
    115 
    116         sess = fd_session(EXCHANGE_SERIALIZE, fd);
     102        sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0);
    117103        if (sess == NULL) {
    118                 printf("%s: Failed starting session with '%s'\n", NAME, pathname);
    119                 close(fd);
     104                printf("%s: Failed starting session with '%s.'\n", NAME,
     105                    kdev->svc_name);
    120106                return -1;
    121107        }
     
    124110        if (kbdev == NULL) {
    125111                printf("%s: Failed allocating device structure for '%s'.\n",
    126                     NAME, pathname);
     112                    NAME, kdev->svc_name);
    127113                return -1;
    128114        }
    129115
    130         kbdev->fd = fd;
    131116        kbdev->sess = sess;
    132117
    133118        exch = async_exchange_begin(sess);
    134119        if (exch == NULL) {
    135                 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname);
     120                printf("%s: Failed starting exchange with '%s'.\n", NAME,
     121                    kdev->svc_name);
    136122                kbdev_destroy(kbdev);
    137123                return -1;
     
    141127        if (rc != EOK) {
    142128                printf("%s: Failed creating callback connection from '%s'.\n",
    143                     NAME, pathname);
     129                    NAME, kdev->svc_name);
    144130                async_exchange_end(exch);
    145131                kbdev_destroy(kbdev);
  • uspace/srv/hid/input/generic/input.c

    rbb285b4 r1d2a1a9  
    3838
    3939#include <adt/list.h>
     40#include <bool.h>
    4041#include <ipc/services.h>
    4142#include <ipc/input.h>
     
    5354#include <io/console.h>
    5455#include <io/keycode.h>
    55 #include <devmap.h>
     56#include <loc.h>
    5657#include <input.h>
    5758#include <kbd.h>
     
    6364
    6465// FIXME: remove this header
    65 #include <kernel/ipc/ipc_methods.h>
     66#include <abi/ipc/methods.h>
    6667
    6768/* In microseconds */
     
    275276        kdev->port_ops = port;
    276277        kdev->ctl_ops = ctl;
    277         kdev->dev_path = NULL;
     278        kdev->svc_id = 0;
    278279       
    279280        /* Initialize port driver. */
     
    303304        mdev->port_ops = port;
    304305        mdev->proto_ops = proto;
    305         mdev->dev_path = NULL;
     306        mdev->svc_id = 0;
    306307       
    307308        /* Initialize port driver. */
     
    324325/** Add new kbdev device.
    325326 *
    326  * @param dev_path Filesystem path to the device (/dev/class/...)
     327 * @param service_id    Service ID of the keyboard device
    327328 *
    328329 */
    329 static int kbd_add_kbdev(const char *dev_path)
     330static int kbd_add_kbdev(service_id_t service_id, kbd_dev_t **kdevp)
    330331{
    331332        kbd_dev_t *kdev = kbd_dev_new();
     
    333334                return -1;
    334335       
    335         kdev->dev_path = dev_path;
     336        kdev->svc_id = service_id;
    336337        kdev->port_ops = NULL;
    337338        kdev->ctl_ops = &kbdev_ctl;
    338339       
     340        int rc = loc_service_get_name(service_id, &kdev->svc_name);
     341        if (rc != EOK) {
     342                kdev->svc_name = NULL;
     343                goto fail;
     344        }
     345       
    339346        /* Initialize controller driver. */
    340347        if ((*kdev->ctl_ops->init)(kdev) != 0) {
     
    343350       
    344351        list_append(&kdev->kbd_devs, &kbd_devs);
     352        *kdevp = kdev;
    345353        return EOK;
    346354       
    347355fail:
     356        if (kdev->svc_name != NULL)
     357                free(kdev->svc_name);
    348358        free(kdev);
    349359        return -1;
     
    352362/** Add new mousedev device.
    353363 *
    354  * @param dev_path Filesystem path to the device (/dev/class/...)
     364 * @param service_id    Service ID of the mouse device
    355365 *
    356366 */
    357 static int mouse_add_mousedev(const char *dev_path)
     367static int mouse_add_mousedev(service_id_t service_id, mouse_dev_t **mdevp)
    358368{
    359369        mouse_dev_t *mdev = mouse_dev_new();
     
    361371                return -1;
    362372       
    363         mdev->dev_path = dev_path;
     373        mdev->svc_id = service_id;
    364374        mdev->port_ops = NULL;
    365375        mdev->proto_ops = &mousedev_proto;
    366376       
     377        int rc = loc_service_get_name(service_id, &mdev->svc_name);
     378        if (rc != EOK) {
     379                mdev->svc_name = NULL;
     380                goto fail;
     381        }
     382       
    367383        /* Initialize controller driver. */
    368384        if ((*mdev->proto_ops->init)(mdev) != 0) {
     
    371387       
    372388        list_append(&mdev->mouse_devs, &mouse_devs);
     389        *mdevp = mdev;
    373390        return EOK;
    374391       
     
    482499/** Periodically check for new input devices.
    483500 *
    484  * Looks under /dev/class/keyboard and /dev/class/mouse.
     501 * Looks under /loc/class/keyboard and /loc/class/mouse.
    485502 *
    486503 * @param arg Ignored
     
    489506static int dev_discovery_fibril(void *arg)
    490507{
    491         char *dev_path;
    492         size_t kbd_id = 1;
    493         size_t mouse_id = 1;
     508        category_id_t keyboard_cat, mouse_cat;
     509        service_id_t *svcs;
     510        size_t count, i;
     511        bool already_known;
    494512        int rc;
     513       
     514        rc = loc_category_get_id("keyboard", &keyboard_cat, IPC_FLAG_BLOCKING);
     515        if (rc != EOK) {
     516                printf("%s: Failed resolving category 'keyboard'.\n", NAME);
     517                return ENOENT;
     518        }
     519       
     520        rc = loc_category_get_id("mouse", &mouse_cat, IPC_FLAG_BLOCKING);
     521        if (rc != EOK) {
     522                printf("%s: Failed resolving category 'mouse'.\n", NAME);
     523                return ENOENT;
     524        }
    495525       
    496526        while (true) {
     
    498528               
    499529                /*
    500                  * Check for new keyboard device
     530                 * Check for new keyboard devices
    501531                 */
    502                 rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", kbd_id);
    503                 if (rc < 0)
     532                rc = loc_category_get_svcs(keyboard_cat, &svcs, &count);
     533                if (rc != EOK) {
     534                        printf("%s: Failed getting list of keyboard devices.\n",
     535                            NAME);
    504536                        continue;
    505                
    506                 if (kbd_add_kbdev(dev_path) == EOK) {
    507                         printf("%s: Connected keyboard device '%s'\n",
    508                             NAME, dev_path);
     537                }
     538
     539                for (i = 0; i < count; i++) {
     540                        already_known = false;
    509541                       
    510                         /* XXX Handle device removal */
    511                         ++kbd_id;
     542                        /* Determine whether we already know this device. */
     543                        list_foreach(kbd_devs, kdev_link) {
     544                                kbd_dev_t *kdev = list_get_instance(kdev_link,
     545                                    kbd_dev_t, kbd_devs);
     546                                if (kdev->svc_id == svcs[i]) {
     547                                        already_known = true;
     548                                        break;
     549                                }
     550                        }
     551
     552                        if (!already_known) {
     553                                kbd_dev_t *kdev;
     554                                if (kbd_add_kbdev(svcs[i], &kdev) == EOK) {
     555                                        printf("%s: Connected keyboard device '%s'\n",
     556                                            NAME, kdev->svc_name);
     557                                }
     558                        }
    512559                }
    513560               
    514                 free(dev_path);
     561                /* XXX Handle device removal */
    515562               
    516563                /*
    517                  * Check for new mouse device
     564                 * Check for new mouse devices
    518565                 */
    519                 rc = asprintf(&dev_path, "/dev/class/mouse\\%zu", mouse_id);
    520                 if (rc < 0)
     566                rc = loc_category_get_svcs(mouse_cat, &svcs, &count);
     567                if (rc != EOK) {
     568                        printf("%s: Failed getting list of mouse devices.\n",
     569                            NAME);
    521570                        continue;
    522                
    523                 if (mouse_add_mousedev(dev_path) == EOK) {
    524                         printf("%s: Connected mouse device '%s'\n",
    525                             NAME, dev_path);
     571                }
     572
     573                for (i = 0; i < count; i++) {
     574                        already_known = false;
    526575                       
    527                         /* XXX Handle device removal */
    528                         ++mouse_id;
     576                        /* Determine whether we already know this device. */
     577                        list_foreach(mouse_devs, mdev_link) {
     578                                mouse_dev_t *mdev = list_get_instance(mdev_link,
     579                                    mouse_dev_t, mouse_devs);
     580                                if (mdev->svc_id == svcs[i]) {
     581                                        already_known = true;
     582                                        break;
     583                                }
     584                        }
     585
     586                        if (!already_known) {
     587                                mouse_dev_t *mdev;
     588                                if (mouse_add_mousedev(svcs[i], &mdev) == EOK) {
     589                                        printf("%s: Connected mouse device '%s'\n",
     590                                            NAME, mdev->svc_name);
     591                                }
     592                        }
    529593                }
    530594               
    531                 free(dev_path);
     595                /* XXX Handle device removal */
    532596        }
    533597       
     
    572636       
    573637        /* Register driver */
    574         int rc = devmap_driver_register(NAME, client_connection);
     638        int rc = loc_server_register(NAME, client_connection);
    575639        if (rc < 0) {
    576                 printf("%s: Unable to register driver (%d)\n", NAME, rc);
     640                printf("%s: Unable to register server (%d)\n", NAME, rc);
    577641                return -1;
    578642        }
    579643       
    580         char kbd[DEVMAP_NAME_MAXLEN + 1];
    581         snprintf(kbd, DEVMAP_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);
    582        
    583         devmap_handle_t devmap_handle;
    584         if (devmap_device_register(kbd, &devmap_handle) != EOK) {
    585                 printf("%s: Unable to register device %s\n", NAME, kbd);
     644        char kbd[LOC_NAME_MAXLEN + 1];
     645        snprintf(kbd, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);
     646       
     647        service_id_t service_id;
     648        if (loc_service_register(kbd, &service_id) != EOK) {
     649                printf("%s: Unable to register service %s\n", NAME, kbd);
    586650                return -1;
    587651        }
  • uspace/srv/hid/input/include/kbd.h

    rbb285b4 r1d2a1a9  
    4040
    4141#include <adt/list.h>
     42#include <ipc/loc.h>
    4243
    4344struct kbd_port_ops;
     
    4950        link_t kbd_devs;
    5051
    51         /** Path to the device (only for kbdev devices) */
    52         const char *dev_path;
     52        /** Service ID (only for kbdev devices) */
     53        service_id_t svc_id;
     54
     55        /** Device service name (only for kbdev devices) */
     56        char *svc_name;
    5357
    5458        /** Port ops */
  • uspace/srv/hid/input/include/mouse.h

    rbb285b4 r1d2a1a9  
    3939
    4040#include <adt/list.h>
     41#include <ipc/loc.h>
    4142
    4243struct mouse_port_ops;
     
    4748        link_t mouse_devs;
    4849       
    49         /** Path to the device (only for mouseev devices) */
    50         const char *dev_path;
     50        /** Service ID (only for mousedev devices) */
     51        service_id_t svc_id;
     52       
     53        /** Device service name (only for mousedev devices) */
     54        char *svc_name;
    5155       
    5256        /** Port ops */
  • uspace/srv/hid/input/port/adb.c

    rbb285b4 r1d2a1a9  
    4343#include <fcntl.h>
    4444#include <errno.h>
    45 #include <devmap.h>
     45#include <loc.h>
    4646
    4747static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    6666{
    6767        const char *dev = "adb/kbd";
    68         devmap_handle_t handle;
     68        service_id_t service_id;
    6969        async_exch_t *exch;
    7070        int rc;
     
    7272        kbd_dev = kdev;
    7373       
    74         rc = devmap_device_get_handle(dev, &handle, 0);
     74        rc = loc_service_get_id(dev, &service_id, 0);
    7575        if (rc != EOK)
    7676                return rc;
    7777       
    78         dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     78        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
    7979        if (dev_sess == NULL) {
    8080                printf("%s: Failed to connect to device\n", NAME);
  • uspace/srv/hid/input/port/adb_mouse.c

    rbb285b4 r1d2a1a9  
    4141#include <mouse.h>
    4242#include <errno.h>
    43 #include <devmap.h>
     43#include <loc.h>
    4444
    4545static mouse_dev_t *mouse_dev;
     
    7878        mouse_dev = mdev;
    7979       
    80         devmap_handle_t handle;
    81         int rc = devmap_device_get_handle(dev, &handle, 0);
     80        service_id_t service_id;
     81        int rc = loc_service_get_id(dev, &service_id, 0);
    8282        if (rc != EOK)
    8383                return rc;
    8484       
    85         dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     85        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
    8686        if (dev_sess == NULL) {
    8787                printf("%s: Failed to connect to device\n", NAME);
  • uspace/srv/hid/input/port/chardev.c

    rbb285b4 r1d2a1a9  
    4040#include <kbd_port.h>
    4141#include <kbd.h>
    42 #include <devmap.h>
     42#include <loc.h>
    4343#include <errno.h>
    4444#include <stdio.h>
     
    7171static int chardev_port_init(kbd_dev_t *kdev)
    7272{
    73         devmap_handle_t handle;
     73        service_id_t service_id;
    7474        async_exch_t *exch;
    7575        unsigned int i;
     
    7979       
    8080        for (i = 0; i < num_devs; i++) {
    81                 rc = devmap_device_get_handle(in_devs[i], &handle, 0);
     81                rc = loc_service_get_id(in_devs[i], &service_id, 0);
    8282                if (rc == EOK)
    8383                        break;
     
    8989        }
    9090       
    91         dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,
     91        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id,
    9292            IPC_FLAG_BLOCKING);
    9393        if (dev_sess == NULL) {
  • uspace/srv/hid/input/port/chardev_mouse.c

    rbb285b4 r1d2a1a9  
    3939#include <async.h>
    4040#include <errno.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <input.h>
    4343#include <mouse_port.h>
     
    8282static int chardev_port_init(mouse_dev_t *mdev)
    8383{
    84         devmap_handle_t handle;
     84        service_id_t service_id;
    8585        unsigned int i;
    8686        int rc;
     
    8989       
    9090        for (i = 0; i < num_devs; i++) {
    91                 rc = devmap_device_get_handle(in_devs[i], &handle, 0);
     91                rc = loc_service_get_id(in_devs[i], &service_id, 0);
    9292                if (rc == EOK)
    9393                        break;
     
    9999        }
    100100       
    101         dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,
     101        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id,
    102102            IPC_FLAG_BLOCKING);
    103103        if (dev_sess == NULL) {
  • uspace/srv/hid/input/proto/mousedev.c

    rbb285b4 r1d2a1a9  
    4444#include <ipc/mouseev.h>
    4545#include <input.h>
     46#include <loc.h>
    4647#include <mouse.h>
    4748#include <mouse_port.h>
    4849#include <mouse_proto.h>
     50#include <sys/typefmt.h>
    4951
    5052/** Mousedev softstate */
     
    5557        /** Session to mouse device */
    5658        async_sess_t *sess;
    57        
    58         /** File descriptor of open mousedev device */
    59         int fd;
    6059} mousedev_t;
    6160
     
    6766       
    6867        mousedev->mouse_dev = mdev;
    69         mousedev->fd = -1;
    7068       
    7169        return mousedev;
     
    7674        if (mousedev->sess != NULL)
    7775                async_hangup(mousedev->sess);
    78        
    79         if (mousedev->fd >= 0)
    80                 close(mousedev->fd);
    8176       
    8277        free(mousedev);
     
    122117static int mousedev_proto_init(mouse_dev_t *mdev)
    123118{
    124         const char *pathname = mdev->dev_path;
    125        
    126         int fd = open(pathname, O_RDWR);
    127         if (fd < 0)
    128                 return -1;
    129        
    130         async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
     119        async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
     120            mdev->svc_id, 0);
    131121        if (sess == NULL) {
    132                 printf("%s: Failed starting session with '%s'\n", NAME, pathname);
    133                 close(fd);
     122                printf("%s: Failed starting session with '%s'\n", NAME,
     123                    mdev->svc_name);
    134124                return -1;
    135125        }
     
    138128        if (mousedev == NULL) {
    139129                printf("%s: Failed allocating device structure for '%s'.\n",
    140                     NAME, pathname);
     130                    NAME, mdev->svc_name);
    141131                return -1;
    142132        }
    143133       
    144         mousedev->fd = fd;
    145134        mousedev->sess = sess;
    146135       
    147136        async_exch_t *exch = async_exchange_begin(sess);
    148137        if (exch == NULL) {
    149                 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname);
     138                printf("%s: Failed starting exchange with '%s'.\n", NAME,
     139                    mdev->svc_name);
    150140                mousedev_destroy(mousedev);
    151141                return -1;
     
    157147        if (rc != EOK) {
    158148                printf("%s: Failed creating callback connection from '%s'.\n",
    159                     NAME, pathname);
     149                    NAME, mdev->svc_name);
    160150                mousedev_destroy(mousedev);
    161151                return -1;
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    rbb285b4 r1d2a1a9  
    3939#include <ddi.h>
    4040#include <libarch/ddi.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <io/console.h>
    4343#include <vfs/vfs.h>
     
    5454
    5555// FIXME: remove this header
    56 #include <kernel/ipc/ipc_methods.h>
     56#include <abi/ipc/methods.h>
    5757
    5858#define NAME "s3c24ser"
     
    9090        printf(NAME ": S3C24xx touchscreen driver\n");
    9191
    92         rc = devmap_driver_register(NAME, s3c24xx_ts_connection);
     92        rc = loc_server_register(NAME, s3c24xx_ts_connection);
    9393        if (rc < 0) {
    9494                printf(NAME ": Unable to register driver.\n");
     
    103103                return -1;
    104104
    105         rc = devmap_device_register(NAMESPACE "/mouse", &ts->devmap_handle);
     105        rc = loc_service_register(NAMESPACE "/mouse", &ts->service_id);
    106106        if (rc != EOK) {
    107107                printf(NAME ": Unable to register device %s.\n",
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h

    rbb285b4 r1d2a1a9  
    124124        int client_phone;
    125125
    126         /** Device handle */
    127         devmap_handle_t devmap_handle;
     126        /** Service ID */
     127        service_id_t service_id;
    128128
    129129        /** Device/driver state */
Note: See TracChangeset for help on using the changeset viewer.