Changeset 7de5f12 in mainline for uspace/drv/char
- Timestamp:
- 2017-11-15T20:23:50Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6ac1243d, 7f4937e
- Parents:
- e7a8bd2
- Location:
- uspace/drv/char/msim-con
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/msim-con/main.c
re7a8bd2 r7de5f12 35 35 #include <ddf/driver.h> 36 36 #include <ddf/log.h> 37 #include <device/hw_res_parsed.h> 37 38 #include <errno.h> 38 39 #include <stdio.h> … … 61 62 }; 62 63 64 static int msim_con_get_res(ddf_dev_t *dev, msim_con_res_t *res) 65 { 66 async_sess_t *parent_sess; 67 hw_res_list_parsed_t hw_res; 68 int rc; 69 70 parent_sess = ddf_dev_parent_sess_get(dev); 71 if (parent_sess == NULL) 72 return ENOMEM; 73 74 hw_res_list_parsed_init(&hw_res); 75 rc = hw_res_get_list_parsed(parent_sess, &hw_res, 0); 76 if (rc != EOK) 77 return rc; 78 79 if (hw_res.mem_ranges.count != 1) { 80 rc = EINVAL; 81 goto error; 82 } 83 84 res->base = RNGABS(hw_res.mem_ranges.ranges[0]); 85 86 if (hw_res.irqs.count != 1) { 87 rc = EINVAL; 88 goto error; 89 } 90 91 res->irq = hw_res.irqs.irqs[0]; 92 93 return EOK; 94 error: 95 hw_res_list_parsed_clean(&hw_res); 96 return rc; 97 } 98 63 99 static int msim_con_dev_add(ddf_dev_t *dev) 64 100 { 65 101 msim_con_t *msim_con; 102 msim_con_res_t res; 103 int rc; 66 104 67 105 ddf_msg(LVL_DEBUG, "msim_con_dev_add(%p)", dev); 106 68 107 msim_con = ddf_dev_data_alloc(dev, sizeof(msim_con_t)); 69 108 if (msim_con == NULL) { … … 74 113 msim_con->dev = dev; 75 114 76 return msim_con_add(msim_con); 115 rc = msim_con_get_res(dev, &res); 116 if (rc != EOK) { 117 ddf_msg(LVL_ERROR, "Failed getting hardware resource list.\n"); 118 return EIO; 119 } 120 121 return msim_con_add(msim_con, &res); 77 122 } 78 123 -
uspace/drv/char/msim-con/msim-con.c
re7a8bd2 r7de5f12 38 38 #include <errno.h> 39 39 #include <ipc/char.h> 40 #include <sysinfo.h>41 40 42 41 #include "msim-con.h" … … 84 83 85 84 /** Add msim console device. */ 86 int msim_con_add(msim_con_t *con )85 int msim_con_add(msim_con_t *con, msim_con_res_t *res) 87 86 { 88 87 ddf_fun_t *fun = NULL; 89 88 bool subscribed = false; 90 89 int rc; 90 91 con->res = *res; 91 92 92 93 fun = ddf_fun_create(con->dev, fun_exposed, "a"); … … 99 100 ddf_fun_set_conn_handler(fun, msim_con_connection); 100 101 101 sysarg_t paddr; 102 if (sysinfo_get_value("kbd.address.physical", &paddr) != EOK) { 103 rc = ENOENT; 104 goto error; 105 } 106 107 sysarg_t inr; 108 if (sysinfo_get_value("kbd.inr", &inr) != EOK) { 109 rc = ENOENT; 110 goto error; 111 } 112 113 msim_ranges[0].base = paddr; 114 msim_cmds[0].addr = (void *) paddr; 115 async_irq_subscribe(inr, msim_irq_handler, con, &msim_kbd); 102 msim_ranges[0].base = res->base; 103 msim_cmds[0].addr = (void *) res->base; 104 async_irq_subscribe(res->irq, msim_irq_handler, con, &msim_kbd); 116 105 subscribed = true; 117 106 … … 125 114 error: 126 115 if (subscribed) 127 async_irq_unsubscribe( inr);116 async_irq_unsubscribe(res->irq); 128 117 if (fun != NULL) 129 118 ddf_fun_destroy(fun); -
uspace/drv/char/msim-con/msim-con.h
re7a8bd2 r7de5f12 41 41 #include <stdint.h> 42 42 43 /** MSIM console resources */ 44 typedef struct { 45 uintptr_t base; 46 int irq; 47 } msim_con_res_t; 48 43 49 /** MSIM console */ 44 50 typedef struct { 45 51 async_sess_t *client_sess; 46 52 ddf_dev_t *dev; 53 msim_con_res_t res; 47 54 } msim_con_t; 48 55 49 extern int msim_con_add(msim_con_t * );56 extern int msim_con_add(msim_con_t *, msim_con_res_t *); 50 57 extern int msim_con_remove(msim_con_t *); 51 58 extern int msim_con_gone(msim_con_t *);
Note:
See TracChangeset
for help on using the changeset viewer.