Changeset e27e36e in mainline
- Timestamp:
- 2017-10-04T17:39:48Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c188c62
- Parents:
- 7e55bed7
- Files:
-
- 2 added
- 6 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/ppc32/Makefile.inc
r7e55bed7 re27e36e 44 44 RD_DRVS_ESSENTIAL += \ 45 45 platform/mac \ 46 bus/adb/cuda_adb \ 46 47 bus/pci/pciintel \ 47 48 bus/usb/ohci \ -
uspace/Makefile
r7e55bed7 re27e36e 134 134 srv/hid/output \ 135 135 srv/hid/remcons \ 136 srv/hw/bus/cuda_adb \137 136 srv/hw/char/s3c24xx_uart \ 138 137 srv/hw/irc/apic \ … … 148 147 drv/block/ata_bd \ 149 148 drv/block/ddisk \ 149 drv/bus/adb/cuda_adb \ 150 150 drv/bus/isa \ 151 151 drv/bus/pci/pciintel \ -
uspace/app/init/init.c
r7e55bed7 re27e36e 342 342 srv_start("/srv/icp-ic"); 343 343 srv_start("/srv/obio"); 344 srv_start("/srv/cuda_adb");345 344 srv_start("/srv/s3c24xx_uart"); 346 345 srv_start("/srv/s3c24xx_ts"); -
uspace/drv/bus/adb/cuda_adb/Makefile
r7e55bed7 re27e36e 28 28 29 29 USPACE_PREFIX = ../../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include 30 32 BINARY = cuda_adb 31 33 32 34 SOURCES = \ 33 cuda_adb.c 35 cuda_adb.c \ 36 main.c 34 37 35 38 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/bus/adb/cuda_adb/cuda_adb.c
r7e55bed7 re27e36e 37 37 */ 38 38 39 #include <assert.h> 40 #include <ddf/driver.h> 41 #include <ddf/log.h> 42 #include <ddi.h> 43 #include <errno.h> 44 #include <ipc/adb.h> 45 #include <libarch/ddi.h> 46 #include <stdbool.h> 47 #include <stddef.h> 48 #include <sysinfo.h> 49 #include <stdint.h> 39 50 #include <stdio.h> 40 51 #include <stdlib.h> 41 #include <stddef.h> 42 #include <stdint.h> 43 #include <stdbool.h> 44 #include <ddi.h> 45 #include <libarch/ddi.h> 46 #include <loc.h> 47 #include <sysinfo.h> 48 #include <errno.h> 49 #include <ipc/adb.h> 50 #include <assert.h> 52 51 53 #include "cuda_adb.h" 52 54 #include "cuda_hw.h" … … 54 56 #define NAME "cuda_adb" 55 57 56 static void cuda_ connection(ipc_callid_t, ipc_call_t *, void *);58 static void cuda_dev_connection(ipc_callid_t, ipc_call_t *, void *); 57 59 static int cuda_init(cuda_t *); 58 60 static void cuda_irq_handler(ipc_callid_t, ipc_call_t *, void *); … … 107 109 }; 108 110 109 int main(int argc, char *argv[])110 { 111 service_id_t service_id;112 cuda_t cinst;111 static int cuda_dev_create(cuda_t *cuda, const char *name, adb_dev_t **rdev) 112 { 113 adb_dev_t *dev = NULL; 114 ddf_fun_t *fun; 113 115 int rc; 114 int i; 115 116 printf(NAME ": VIA-CUDA Apple Desktop Bus driver\n"); 117 118 for (i = 0; i < ADB_MAX_ADDR; ++i) { 119 cinst.adb_dev[i].client_sess = NULL; 120 cinst.adb_dev[i].service_id = 0; 121 } 122 123 async_set_fallback_port_handler(cuda_connection, &cinst); 124 rc = loc_server_register(NAME); 125 if (rc < 0) { 126 printf(NAME ": Unable to register server.\n"); 116 117 fun = ddf_fun_create(cuda->dev, fun_exposed, name); 118 if (fun == NULL) { 119 ddf_msg(LVL_ERROR, "Failed creating function '%s'.", name); 120 rc = ENOMEM; 121 goto error; 122 } 123 124 dev = ddf_fun_data_alloc(fun, sizeof(adb_dev_t)); 125 if (dev == NULL) { 126 ddf_msg(LVL_ERROR, "Failed allocating memory for '%s'.", name); 127 rc = ENOMEM; 128 goto error; 129 } 130 131 dev->fun = fun; 132 list_append(&dev->lcuda, &cuda->devs); 133 134 ddf_fun_set_conn_handler(fun, cuda_dev_connection); 135 136 rc = ddf_fun_bind(fun); 137 if (rc != EOK) { 138 ddf_msg(LVL_ERROR, "Failed binding function '%s'.", name); 139 goto error; 140 } 141 142 *rdev = dev; 143 return EOK; 144 error: 145 if (fun != NULL) 146 ddf_fun_destroy(fun); 147 return rc; 148 } 149 150 int cuda_add(cuda_t *cuda) 151 { 152 adb_dev_t *kbd = NULL; 153 adb_dev_t *mouse = NULL; 154 int rc; 155 156 rc = cuda_dev_create(cuda, "kbd", &kbd); 157 if (rc != EOK) 158 goto error; 159 160 rc = cuda_dev_create(cuda, "mouse", &mouse); 161 if (rc != EOK) 162 goto error; 163 164 cuda->addr_dev[2] = kbd; 165 cuda->addr_dev[8] = kbd; 166 167 cuda->addr_dev[9] = mouse; 168 169 170 rc = cuda_init(cuda); 171 if (rc != EOK) { 172 ddf_msg(LVL_ERROR, "Failed initializing CUDA hardware."); 127 173 return rc; 128 174 } 129 175 130 rc = loc_service_register("adb/kbd", &service_id); 131 if (rc != EOK) { 132 printf(NAME ": Unable to register service %s.\n", "adb/kbd"); 133 return rc; 134 } 135 136 cinst.adb_dev[2].service_id = service_id; 137 cinst.adb_dev[8].service_id = service_id; 138 139 rc = loc_service_register("adb/mouse", &service_id); 140 if (rc != EOK) { 141 printf(NAME ": Unable to register service %s.\n", "adb/mouse"); 142 return rc; 143 } 144 145 cinst.adb_dev[9].service_id = service_id; 146 147 if (cuda_init(&cinst) != EOK) { 148 printf("cuda_init() failed\n"); 149 return 1; 150 } 151 152 task_retval(0); 153 async_manager(); 154 155 return 0; 156 } 157 158 /** Character device connection handler */ 159 static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 160 { 176 return EOK; 177 error: 178 return rc; 179 } 180 181 int cuda_remove(cuda_t *cuda) 182 { 183 return ENOTSUP; 184 } 185 186 int cuda_gone(cuda_t *cuda) 187 { 188 return ENOTSUP; 189 } 190 191 /** Device connection handler */ 192 static void cuda_dev_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 193 { 194 adb_dev_t *dev = (adb_dev_t *) ddf_fun_data_get((ddf_fun_t *) arg); 161 195 ipc_callid_t callid; 162 196 ipc_call_t call; 163 197 sysarg_t method; 164 service_id_t dsid;165 cuda_t *cuda = (cuda_t *) arg;166 int dev_addr, i;167 168 /* Get the device handle. */169 dsid = IPC_GET_ARG2(*icall);170 171 /* Determine which disk device is the client connecting to. */172 dev_addr = -1;173 for (i = 0; i < ADB_MAX_ADDR; i++) {174 if (cuda->adb_dev[i].service_id == dsid)175 dev_addr = i;176 }177 178 if (dev_addr < 0) {179 async_answer_0(iid, EINVAL);180 return;181 }182 198 183 199 /* Answer the IPC_M_CONNECT_ME_TO call. */ … … 197 213 async_callback_receive_start(EXCHANGE_SERIALIZE, &call); 198 214 if (sess != NULL) { 199 if (cuda->adb_dev[dev_addr].client_sess == NULL) { 200 cuda->adb_dev[dev_addr].client_sess = sess; 201 202 /* 203 * A hack so that we send the data to the session 204 * regardless of which address the device is on. 205 */ 206 for (i = 0; i < ADB_MAX_ADDR; ++i) { 207 if (cuda->adb_dev[i].service_id == dsid) 208 cuda->adb_dev[i].client_sess = sess; 209 } 210 211 async_answer_0(callid, EOK); 212 } else 213 async_answer_0(callid, ELIMIT); 214 } else 215 dev->client_sess = sess; 216 async_answer_0(callid, EOK); 217 } else { 215 218 async_answer_0(callid, EINVAL); 219 } 216 220 } 217 221 } … … 307 311 308 312 if ((b & TREQ) != 0) { 309 printf("cuda_irq_listen: no TREQ?!\n");313 ddf_msg(LVL_WARN, "cuda_irq_listen: no TREQ?!"); 310 314 return; 311 315 } … … 437 441 uint8_t reg_no; 438 442 uint16_t reg_val; 443 adb_dev_t *dev; 439 444 unsigned i; 440 445 … … 443 448 444 449 if (size != 3) { 445 printf("unrecognized packet, size=%zu\n", size);450 ddf_msg(LVL_WARN, "Unrecognized packet, size=%zu", size); 446 451 for (i = 0; i < size; ++i) { 447 printf("0x%02x", data[i]);452 ddf_msg(LVL_WARN, " 0x%02x", data[i]); 448 453 } 449 putchar('\n');450 454 return; 451 455 } 452 456 453 457 if (reg_no != 0) { 454 printf("unrecognized packet, size=%zu\n", size);458 ddf_msg(LVL_WARN, "Unrecognized packet, size=%zu", size); 455 459 for (i = 0; i < size; ++i) { 456 printf("0x%02x", data[i]);460 ddf_msg(LVL_WARN, " 0x%02x", data[i]); 457 461 } 458 putchar('\n');459 462 return; 460 463 } … … 462 465 reg_val = ((uint16_t) data[1] << 8) | (uint16_t) data[2]; 463 466 464 if (cuda->adb_dev[dev_addr].client_sess == NULL) 465 return; 466 467 async_exch_t *exch = 468 async_exchange_begin(cuda->adb_dev[dev_addr].client_sess); 467 ddf_msg(LVL_DEBUG, "Received ADB packet for device address %d", 468 dev_addr); 469 dev = cuda->addr_dev[dev_addr]; 470 if (dev == NULL) 471 return; 472 473 async_exch_t *exch = async_exchange_begin(dev->client_sess); 469 474 async_msg_1(exch, ADB_REG_NOTIF, reg_val); 470 475 async_exchange_end(exch); -
uspace/drv/bus/adb/cuda_adb/cuda_adb.h
r7e55bed7 re27e36e 37 37 #define CUDA_ADB_H_ 38 38 39 #include <adt/list.h> 39 40 #include <async.h> 41 #include <ddf/driver.h> 40 42 #include <fibril_synch.h> 41 43 #include <loc.h> … … 55 57 }; 56 58 59 /** ADB bus device */ 57 60 typedef struct { 58 service_id_t service_id;61 ddf_fun_t *fun; 59 62 async_sess_t *client_sess; 63 link_t lcuda; 64 struct cuda *cuda; 60 65 } adb_dev_t; 61 66 62 typedef struct { 67 /** CUDA ADB bus */ 68 typedef struct cude { 63 69 struct cuda_regs *regs; 64 70 uintptr_t cuda_physical; 71 ddf_dev_t *dev; 65 72 66 73 uint8_t rcv_buf[CUDA_RCV_BUF_SIZE]; … … 71 78 fibril_mutex_t dev_lock; 72 79 73 adb_dev_t adb_dev[ADB_MAX_ADDR]; 80 list_t devs; 81 adb_dev_t *addr_dev[ADB_MAX_ADDR]; 74 82 } cuda_t; 83 84 extern int cuda_add(cuda_t *); 85 extern int cuda_remove(cuda_t *); 86 extern int cuda_gone(cuda_t *); 75 87 76 88 #endif -
uspace/drv/platform/mac/mac.c
r7e55bed7 re27e36e 41 41 #include <ops/hw_res.h> 42 42 #include <stdio.h> 43 #include <sysinfo.h> 43 44 44 45 #define NAME "mac" … … 47 48 hw_resource_list_t hw_resources; 48 49 } mac_fun_t; 50 51 static hw_resource_t adb_regs[] = { 52 { 53 .type = IO_RANGE, 54 .res.io_range = { 55 .address = 0, 56 .size = 0x2000, 57 .relative = false, 58 .endianness = BIG_ENDIAN 59 } 60 }, 61 }; 62 63 static mac_fun_t adb_data = { 64 .hw_resources = { 65 1, 66 adb_regs 67 } 68 }; 49 69 50 70 static hw_resource_t pci_conf_regs[] = { … … 88 108 { 89 109 ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name); 110 printf("mac: Adding new function '%s'.\n", name); 90 111 91 112 ddf_fun_t *fnode = NULL; … … 114 135 } 115 136 137 printf("mac: Added new function '%s' (str=%s).\n", name, str_match_id); 116 138 return true; 117 139 … … 135 157 static int mac_dev_add(ddf_dev_t *dev) 136 158 { 159 int rc; 160 uintptr_t cuda_physical; 137 161 #if 0 138 162 /* Register functions */ 139 if (!mac_add_fun(dev, "pci0", "intel_pci", &pci_data)) 140 ddf_msg(LVL_ERROR, "Failed to add functions for Mac platform."); 163 if (!mac_add_fun(dev, "pci0", "intel_pci", &pci_data)) { 164 ddf_msg(LVL_ERROR, "Failed to add PCI function for Mac platform."); 165 return EIO; 166 } 141 167 #else 142 168 (void)pci_data; 143 (void)mac_add_fun;144 169 #endif 145 170 rc = sysinfo_get_value("cuda.address.physical", &cuda_physical); 171 if (rc != EOK) 172 return EIO; 173 174 adb_regs[0].res.io_range.address = cuda_physical; 175 176 if (!mac_add_fun(dev, "adb", "cuda_adb", &adb_data)) { 177 ddf_msg(LVL_ERROR, "Failed to add ADB function for Mac platform."); 178 return EIO; 179 } 180 146 181 return EOK; 147 182 } -
uspace/srv/hid/input/port/adb.c
r7e55bed7 re27e36e 62 62 kbd_dev = kdev; 63 63 64 const char *dev = " adb/kbd";64 const char *dev = "devices/\\hw\\adb\\kbd"; 65 65 service_id_t service_id; 66 int rc = loc_service_get_id(dev, &service_id, 0);66 int rc = loc_service_get_id(dev, &service_id, IPC_FLAG_BLOCKING); 67 67 if (rc != EOK) 68 68 return rc; -
uspace/srv/hid/input/port/adb_mouse.c
r7e55bed7 re27e36e 75 75 static int adb_port_init(mouse_dev_t *mdev) 76 76 { 77 const char *dev = " adb/mouse";77 const char *dev = "devices/\\hw\\adb\\mouse"; 78 78 79 79 mouse_dev = mdev; 80 80 81 81 service_id_t service_id; 82 int rc = loc_service_get_id(dev, &service_id, 0);82 int rc = loc_service_get_id(dev, &service_id, IPC_FLAG_BLOCKING); 83 83 if (rc != EOK) 84 84 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.