Changeset c188c62 in mainline
- Timestamp:
- 2017-10-05T18:00:52Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 81b9d3e
- Parents:
- e27e36e
- Location:
- uspace/drv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/drv/bus/adb/cuda_adb/cuda_adb.c ¶
re27e36e rc188c62 148 148 } 149 149 150 int cuda_add(cuda_t *cuda )150 int cuda_add(cuda_t *cuda, cuda_res_t *res) 151 151 { 152 152 adb_dev_t *kbd = NULL; … … 154 154 int rc; 155 155 156 cuda->phys_base = res->base; 157 156 158 rc = cuda_dev_create(cuda, "kbd", &kbd); 157 159 if (rc != EOK) … … 166 168 167 169 cuda->addr_dev[9] = mouse; 168 169 170 170 171 rc = cuda_init(cuda); … … 225 226 int rc; 226 227 227 if (sysinfo_get_value("cuda.address.physical", &(cuda->cuda_physical)) != EOK)228 return EIO;229 230 228 void *vaddr; 231 rc = pio_enable((void *) cuda-> cuda_physical, sizeof(cuda_regs_t),229 rc = pio_enable((void *) cuda->phys_base, sizeof(cuda_regs_t), 232 230 &vaddr); 233 231 if (rc != EOK) … … 244 242 pio_write_8(&cuda->regs->ier, IER_CLR | ALL_INT); 245 243 246 cuda_irq_code.ranges[0].base = (uintptr_t) cuda-> cuda_physical;244 cuda_irq_code.ranges[0].base = (uintptr_t) cuda->phys_base; 247 245 cuda_irq_code.cmds[0].addr = (void *) &((cuda_regs_t *) 248 cuda-> cuda_physical)->ifr;246 cuda->phys_base)->ifr; 249 247 async_irq_subscribe(10, cuda_irq_handler, cuda, &cuda_irq_code); 250 248 -
TabularUnified uspace/drv/bus/adb/cuda_adb/cuda_adb.h ¶
re27e36e rc188c62 57 57 }; 58 58 59 typedef struct { 60 uintptr_t base; 61 int irq; 62 } cuda_res_t; 63 59 64 /** ADB bus device */ 60 65 typedef struct { … … 68 73 typedef struct cude { 69 74 struct cuda_regs *regs; 70 uintptr_t cuda_physical;75 uintptr_t phys_base; 71 76 ddf_dev_t *dev; 72 77 … … 82 87 } cuda_t; 83 88 84 extern int cuda_add(cuda_t * );89 extern int cuda_add(cuda_t *, cuda_res_t *); 85 90 extern int cuda_remove(cuda_t *); 86 91 extern int cuda_gone(cuda_t *); -
TabularUnified uspace/drv/bus/adb/cuda_adb/main.c ¶
re27e36e rc188c62 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 cuda_get_res(ddf_dev_t *dev, cuda_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_create(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.io_ranges.count != 1) { 80 rc = EINVAL; 81 goto error; 82 } 83 84 res->base = RNGABS(hw_res.io_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 cuda_dev_add(ddf_dev_t *dev) 64 100 { 65 101 cuda_t *cuda; 102 cuda_res_t cuda_res; 103 int rc; 66 104 67 printf("cuda_dev_add\n");68 105 ddf_msg(LVL_DEBUG, "cuda_dev_add(%p)", dev); 69 106 cuda = ddf_dev_data_alloc(dev, sizeof(cuda_t)); … … 75 112 cuda->dev = dev; 76 113 list_initialize(&cuda->devs); 77 printf("call cuda_add\n"); 78 int rc = cuda_add(cuda); 79 printf("cuda_add->%d\n", rc); 80 return rc; 114 115 rc = cuda_get_res(dev, &cuda_res); 116 if (rc != EOK) { 117 ddf_msg(LVL_ERROR, "Failed getting hardware resource list.\n"); 118 return EIO; 119 } 120 121 return cuda_add(cuda, &cuda_res); 81 122 } 82 123 -
TabularUnified uspace/drv/platform/mac/mac.c ¶
re27e36e rc188c62 1 1 /* 2 2 * Copyright (c) 2011 Martin Decky 3 * Copyright (c) 2017 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 40 41 #include <errno.h> 41 42 #include <ops/hw_res.h> 43 #include <ops/pio_window.h> 42 44 #include <stdio.h> 43 45 #include <sysinfo.h> … … 47 49 typedef struct { 48 50 hw_resource_list_t hw_resources; 51 pio_window_t pio_window; 49 52 } mac_fun_t; 50 53 51 static hw_resource_t adb_re gs[] = {54 static hw_resource_t adb_res[] = { 52 55 { 53 56 .type = IO_RANGE, … … 55 58 .address = 0, 56 59 .size = 0x2000, 57 .relative = false,60 .relative = true, 58 61 .endianness = BIG_ENDIAN 62 } 63 }, 64 { 65 .type = INTERRUPT, 66 .res.interrupt = { 67 .irq = 0 /* patched at run time */ 59 68 } 60 69 }, … … 63 72 static mac_fun_t adb_data = { 64 73 .hw_resources = { 65 1, 66 adb_regs 74 sizeof(adb_res) / sizeof(adb_res[0]), 75 adb_res 76 }, 77 .pio_window = { 78 .io = { 79 .base = 0, /* patched at run time */ 80 .size = 0x2000 81 } 67 82 } 68 83 }; … … 99 114 100 115 /** Obtain function soft-state from DDF function node */ 101 static mac_fun_t *mac_fun(ddf_fun_t *fnode) 102 { 103 return ddf_fun_data_get(fnode); 116 static mac_fun_t *mac_fun(ddf_fun_t *ddf_fun) 117 { 118 return ddf_fun_data_get(ddf_fun); 119 } 120 121 static pio_window_t *mac_get_pio_window(ddf_fun_t *ddf_fun) 122 { 123 mac_fun_t *fun = mac_fun(ddf_fun); 124 return &fun->pio_window; 104 125 } 105 126 … … 159 180 int rc; 160 181 uintptr_t cuda_physical; 182 sysarg_t cuda_inr; 161 183 #if 0 162 184 /* Register functions */ … … 171 193 if (rc != EOK) 172 194 return EIO; 173 174 adb_regs[0].res.io_range.address = cuda_physical; 195 rc = sysinfo_get_value("cuda.inr", &cuda_inr); 196 if (rc != EOK) 197 return EIO; 198 199 adb_data.pio_window.io.base = cuda_physical; 200 adb_res[1].res.interrupt.irq = cuda_inr; 175 201 176 202 if (!mac_add_fun(dev, "adb", "cuda_adb", &adb_data)) { … … 208 234 } 209 235 236 static pio_window_ops_t fun_pio_window_ops = { 237 .get_pio_window = &mac_get_pio_window 238 }; 239 210 240 static hw_res_ops_t fun_hw_res_ops = { 211 241 .get_resource_list = &mac_get_resources, … … 218 248 ddf_log_init(NAME); 219 249 mac_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops; 250 mac_fun_ops.interfaces[PIO_WINDOW_DEV_IFACE] = &fun_pio_window_ops; 220 251 return ddf_driver_main(&mac_driver); 221 252 }
Note:
See TracChangeset
for help on using the changeset viewer.