Changes in / [ddd0499d:695b6ff] in mainline
- Location:
- uspace
- Files:
-
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/main.c
rddd0499d r695b6ff 49 49 50 50 static int sb_add_device(ddf_dev_t *device); 51 static int sb_get_res(ddf_dev_t *device, addr_range_t **pp_sb_regs, 52 addr_range_t **pp_mpu_regs, int *irq, int *dma8, int *dma16); 51 static int sb_get_res(ddf_dev_t *device, uintptr_t *sb_regs, 52 size_t *sb_regs_size, uintptr_t *mpu_regs, size_t *mpu_regs_size, 53 int *irq, int *dma8, int *dma16); 53 54 static int sb_enable_interrupts(ddf_dev_t *device); 54 55 … … 102 103 } 103 104 104 addr_range_t sb_regs; 105 addr_range_t *p_sb_regs = &sb_regs; 106 addr_range_t mpu_regs; 107 addr_range_t *p_mpu_regs = &mpu_regs; 105 uintptr_t sb_regs = 0, mpu_regs = 0; 106 size_t sb_regs_size = 0, mpu_regs_size = 0; 108 107 int irq = 0, dma8 = 0, dma16 = 0; 109 108 110 rc = sb_get_res(device, &p_sb_regs, &p_mpu_regs, &irq, &dma8, &dma16); 109 rc = sb_get_res(device, &sb_regs, &sb_regs_size, &mpu_regs, 110 &mpu_regs_size, &irq, &dma8, &dma16); 111 111 if (rc != EOK) { 112 112 ddf_log_error("Failed to get resources: %s.", str_error(rc)); … … 114 114 } 115 115 116 sb16_irq_code( p_sb_regs, dma8, dma16, irq_cmds, irq_ranges);116 sb16_irq_code((void*)sb_regs, dma8, dma16, irq_cmds, irq_ranges); 117 117 118 118 irq_code_t irq_code = { … … 139 139 } 140 140 141 rc = sb16_init_sb16(soft_state, p_sb_regs, device, dma8, dma16); 141 rc = sb16_init_sb16(soft_state, (void*)sb_regs, sb_regs_size, device, 142 dma8, dma16); 142 143 if (rc != EOK) { 143 144 ddf_log_error("Failed to init sb16 driver: %s.", … … 146 147 } 147 148 148 rc = sb16_init_mpu(soft_state, p_mpu_regs);149 rc = sb16_init_mpu(soft_state, (void*)mpu_regs, mpu_regs_size); 149 150 if (rc == EOK) { 150 151 ddf_fun_t *mpu_fun = … … 172 173 } 173 174 174 static int sb_get_res(ddf_dev_t *device, addr_range_t **pp_sb_regs, 175 addr_range_t **pp_mpu_regs, int *irq, int *dma8, int *dma16) 175 static int sb_get_res(ddf_dev_t *device, uintptr_t *sb_regs, 176 size_t *sb_regs_size, uintptr_t *mpu_regs, size_t *mpu_regs_size, 177 int *irq, int *dma8, int *dma16) 176 178 { 177 179 assert(device); … … 223 225 } 224 226 227 225 228 if (hw_res.io_ranges.count == 1) { 226 if ( pp_sb_regs && *pp_sb_regs)227 * *pp_sb_regs = hw_res.io_ranges.ranges[0];228 if ( pp_mpu_regs)229 * pp_mpu_regs = NULL;229 if (sb_regs) 230 *sb_regs = hw_res.io_ranges.ranges[0].address; 231 if (sb_regs_size) 232 *sb_regs_size = hw_res.io_ranges.ranges[0].size; 230 233 } else { 231 234 const int sb = 232 235 (hw_res.io_ranges.ranges[0].size >= sizeof(sb16_regs_t)) 233 ? 0 : 1;236 ? 1 : 0; 234 237 const int mpu = 1 - sb; 235 if (pp_sb_regs && *pp_sb_regs) 236 **pp_sb_regs = hw_res.io_ranges.ranges[sb]; 237 if (pp_mpu_regs && *pp_mpu_regs) 238 **pp_mpu_regs = hw_res.io_ranges.ranges[mpu]; 238 if (sb_regs) 239 *sb_regs = hw_res.io_ranges.ranges[sb].address; 240 if (sb_regs_size) 241 *sb_regs_size = hw_res.io_ranges.ranges[sb].size; 242 if (mpu_regs) 243 *sb_regs = hw_res.io_ranges.ranges[mpu].address; 244 if (mpu_regs_size) 245 *sb_regs_size = hw_res.io_ranges.ranges[mpu].size; 239 246 } 240 247 … … 254 261 return enabled ? EOK : EIO; 255 262 } 256 257 263 /** 258 264 * @} -
uspace/drv/audio/sb16/sb16.c
rddd0499d r695b6ff 77 77 } 78 78 79 void sb16_irq_code(addr_range_t *regs, int dma8, int dma16, irq_cmd_t cmds[], 80 irq_pio_range_t ranges[]) 79 void sb16_irq_code(void *regs, int dma8, int dma16, irq_cmd_t cmds[], irq_pio_range_t ranges[]) 81 80 { 82 81 assert(regs); 83 82 assert(dma8 > 0 && dma8 < 4); 84 85 sb16_regs_t *registers = RNGABSPTR(*regs); 83 sb16_regs_t *registers = regs; 86 84 memcpy(cmds, irq_cmds, sizeof(irq_cmds)); 87 cmds[0].addr = (void *)®isters->dsp_read_status;88 ranges[0].base = (uintptr_t) 85 cmds[0].addr = (void*)®isters->dsp_read_status; 86 ranges[0].base = (uintptr_t)registers; 89 87 ranges[0].size = sizeof(*registers); 90 88 if (dma16 > 4 && dma16 < 8) { 91 89 /* Valid dma16 */ 92 cmds[1].addr = (void *)®isters->dma16_ack;90 cmds[1].addr = (void*)®isters->dma16_ack; 93 91 } else { 94 92 cmds[1].cmd = CMD_ACCEPT; … … 96 94 } 97 95 98 int sb16_init_sb16(sb16_t *sb, addr_range_t *regs, ddf_dev_t *dev, int dma8,99 int dma16)96 int sb16_init_sb16(sb16_t *sb, void *regs, size_t size, 97 ddf_dev_t *dev, int dma8, int dma16) 100 98 { 101 99 assert(sb); 102 103 100 /* Setup registers */ 104 int ret = pio_enable _range(regs, (void **)&sb->regs);101 int ret = pio_enable(regs, size, (void**)&sb->regs); 105 102 if (ret != EOK) 106 103 return ret; 107 ddf_log_ note("PIO registers at %p accessible.", sb->regs);104 ddf_log_debug("PIO registers at %p accessible.", sb->regs); 108 105 109 106 /* Initialize DSP */ … … 190 187 } 191 188 192 int sb16_init_mpu(sb16_t *sb, addr_range_t *regs)189 int sb16_init_mpu(sb16_t *sb, void *regs, size_t size) 193 190 { 194 191 sb->mpu_regs = NULL; -
uspace/drv/audio/sb16/sb16.h
rddd0499d r695b6ff 38 38 #include <ddf/driver.h> 39 39 #include <ddi.h> 40 #include <device/hw_res_parsed.h>41 40 42 41 #include "dsp.h" … … 52 51 53 52 size_t sb16_irq_code_size(void); 54 void sb16_irq_code(addr_range_t *regs, int dma8, int dma16, irq_cmd_t cmds[], irq_pio_range_t ranges[]); 55 int sb16_init_sb16(sb16_t *sb, addr_range_t *regs, ddf_dev_t *dev, int dma8, int dma16); 56 int sb16_init_mpu(sb16_t *sb, addr_range_t *regs); 53 void sb16_irq_code(void *regs, int dma8, int dma16, irq_cmd_t cmds[], irq_pio_range_t ranges[]); 54 int sb16_init_sb16(sb16_t *sb, void *regs, size_t size, 55 ddf_dev_t *dev, int dma8, int dma16); 56 int sb16_init_mpu(sb16_t *sb, void *regs, size_t size); 57 57 void sb16_interrupt(sb16_t *sb); 58 58 -
uspace/drv/block/ahci/ahci.c
rddd0499d r695b6ff 1157 1157 ahci->memregs = NULL; 1158 1158 1159 physmem_map( RNGABS(hw_res_parsed.mem_ranges.ranges[0]),1159 physmem_map((uintptr_t) (hw_res_parsed.mem_ranges.ranges[0].address), 1160 1160 AHCI_MEMREGS_PAGES_COUNT, AS_AREA_READ | AS_AREA_WRITE, 1161 1161 (void **) &ahci->memregs); … … 1164 1164 1165 1165 /* Register interrupt handler */ 1166 ahci_ranges[0].base = RNGABS(hw_res_parsed.mem_ranges.ranges[0]);1166 ahci_ranges[0].base = (size_t) hw_res_parsed.mem_ranges.ranges[0].address; 1167 1167 ahci_ranges[0].size = sizeof(ahci_memregs_t); 1168 1168 … … 1171 1171 1172 1172 ahci_cmds[base].addr = 1173 ((uint32_t *) RNGABSPTR(hw_res_parsed.mem_ranges.ranges[0])) +1173 ((uint32_t *) (size_t) hw_res_parsed.mem_ranges.ranges[0].address) + 1174 1174 AHCI_PORTS_REGISTERS_OFFSET + port * AHCI_PORT_REGISTERS_SIZE + 1175 1175 AHCI_PORT_IS_REGISTER_OFFSET; … … 1177 1177 1178 1178 ahci_cmds[base + 3].addr = 1179 ((uint32_t *) RNGABSPTR(hw_res_parsed.mem_ranges.ranges[0])) +1179 ((uint32_t *) (size_t) hw_res_parsed.mem_ranges.ranges[0].address) + 1180 1180 AHCI_GHC_IS_REGISTER_OFFSET; 1181 1181 ahci_cmds[base + 4].addr = ahci_cmds[base + 3].addr; -
uspace/drv/block/ata_bd/main.c
rddd0499d r695b6ff 84 84 } 85 85 86 addr_range_t *cmd_rng = &hw_res.io_ranges.ranges[0]; 87 addr_range_t *ctl_rng = &hw_res.io_ranges.ranges[1]; 88 ata_res->cmd = RNGABS(*cmd_rng); 89 ata_res->ctl = RNGABS(*ctl_rng); 90 91 if (RNGSZ(*ctl_rng) < sizeof(ata_ctl_t)) { 86 ata_res->cmd = hw_res.io_ranges.ranges[0].address; 87 ata_res->ctl = hw_res.io_ranges.ranges[1].address; 88 89 if (hw_res.io_ranges.ranges[0].size < sizeof(ata_ctl_t)) { 92 90 rc = EINVAL; 93 91 goto error; 94 92 } 95 93 96 if ( RNGSZ(*cmd_rng)< sizeof(ata_cmd_t)) {94 if (hw_res.io_ranges.ranges[1].size < sizeof(ata_cmd_t)) { 97 95 rc = EINVAL; 98 96 goto error; -
uspace/drv/bus/isa/isa.c
rddd0499d r695b6ff 65 65 #include <ddf/log.h> 66 66 #include <ops/hw_res.h> 67 #include <ops/pio_window.h>68 67 69 68 #include <device/hw_res.h> … … 105 104 } 106 105 107 static hw_resource_list_t *isa_ fun_get_resources(ddf_fun_t *fnode)108 { 109 isa_fun_t * fun= isa_fun(fnode);110 assert( fun);111 112 return & fun->hw_resources;106 static hw_resource_list_t *isa_get_fun_resources(ddf_fun_t *fnode) 107 { 108 isa_fun_t *isa = isa_fun(fnode); 109 assert(isa); 110 111 return &isa->hw_resources; 113 112 } 114 113 … … 117 116 /* This is an old ugly way, copied from pci driver */ 118 117 assert(fnode); 119 isa_fun_t * fun= isa_fun(fnode);120 assert( fun);118 isa_fun_t *isa = isa_fun(fnode); 119 assert(isa); 121 120 122 121 sysarg_t apic; … … 134 133 return false; 135 134 136 const hw_resource_list_t *res = & fun->hw_resources;135 const hw_resource_list_t *res = &isa->hw_resources; 137 136 assert(res); 138 137 for (size_t i = 0; i < res->count; ++i) { … … 160 159 { 161 160 assert(fnode); 162 isa_fun_t * fun= isa_fun(fnode);163 assert( fun);164 const hw_resource_list_t *res = & fun->hw_resources;161 isa_fun_t *isa = isa_fun(fnode); 162 assert(isa); 163 const hw_resource_list_t *res = &isa->hw_resources; 165 164 assert(res); 166 165 … … 183 182 assert(size); 184 183 assert(fnode); 185 isa_fun_t * fun= isa_fun(fnode);186 assert( fun);187 const hw_resource_list_t *res = & fun->hw_resources;184 isa_fun_t *isa = isa_fun(fnode); 185 assert(isa); 186 const hw_resource_list_t *res = &isa->hw_resources; 188 187 assert(res); 189 188 … … 202 201 203 202 static hw_res_ops_t isa_fun_hw_res_ops = { 204 .get_resource_list = isa_ fun_get_resources,203 .get_resource_list = isa_get_fun_resources, 205 204 .enable_interrupt = isa_fun_enable_interrupt, 206 205 .dma_channel_setup = isa_fun_setup_dma, … … 208 207 }; 209 208 210 static pio_window_t *isa_fun_get_pio_window(ddf_fun_t *fnode)211 {212 ddf_dev_t *dev = ddf_fun_get_dev(fnode);213 isa_bus_t *isa = isa_bus(dev);214 assert(isa);215 216 return &isa->pio_win;217 }218 219 static pio_window_ops_t isa_fun_pio_window_ops = {220 .get_pio_window = isa_fun_get_pio_window221 };222 223 209 static ddf_dev_ops_t isa_fun_ops= { 224 210 .interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops, 225 .interfaces[PIO_WINDOW_DEV_IFACE] = &isa_fun_pio_window_ops,226 211 }; 227 212 … … 429 414 resources[count].res.io_range.address += isa->pio_win.io.base; 430 415 resources[count].res.io_range.size = len; 431 resources[count].res.io_range.relative = false;432 416 resources[count].res.io_range.endianness = LITTLE_ENDIAN; 433 417 -
uspace/drv/bus/pci/pciintel/pci.c
rddd0499d r695b6ff 256 256 fibril_mutex_lock(&bus->conf_mutex); 257 257 258 pio_write_32(bus->conf_addr_ reg, host2uint32_t_le(conf_addr));258 pio_write_32(bus->conf_addr_port, host2uint32_t_le(conf_addr)); 259 259 260 260 /* … … 263 263 * support shorter PIO reads offset from this register. 264 264 */ 265 val = uint32_t_le2host(pio_read_32(bus->conf_data_ reg));265 val = uint32_t_le2host(pio_read_32(bus->conf_data_port)); 266 266 267 267 switch (len) { … … 299 299 * missing bits first. 300 300 */ 301 pio_write_32(bus->conf_addr_ reg, host2uint32_t_le(conf_addr));302 val = uint32_t_le2host(pio_read_32(bus->conf_data_ reg));301 pio_write_32(bus->conf_addr_port, host2uint32_t_le(conf_addr)); 302 val = uint32_t_le2host(pio_read_32(bus->conf_data_port)); 303 303 } 304 304 … … 317 317 } 318 318 319 pio_write_32(bus->conf_addr_ reg, host2uint32_t_le(conf_addr));320 pio_write_32(bus->conf_data_ reg, host2uint32_t_le(val));319 pio_write_32(bus->conf_addr_port, host2uint32_t_le(conf_addr)); 320 pio_write_32(bus->conf_data_port, host2uint32_t_le(val)); 321 321 322 322 fibril_mutex_unlock(&bus->conf_mutex); … … 449 449 hw_resources[count].res.io_range.address = range_addr; 450 450 hw_resources[count].res.io_range.size = range_size; 451 hw_resources[count].res.io_range.relative = true;452 451 hw_resources[count].res.io_range.endianness = LITTLE_ENDIAN; 453 452 } else { … … 455 454 hw_resources[count].res.mem_range.address = range_addr; 456 455 hw_resources[count].res.mem_range.size = range_size; 457 hw_resources[count].res.mem_range.relative = false;458 456 hw_resources[count].res.mem_range.endianness = LITTLE_ENDIAN; 459 457 } … … 724 722 hw_resources.resources[1].res.io_range.address); 725 723 726 if (pio_enable_resource(&bus->pio_win, &hw_resources.resources[0], 727 (void **) &bus->conf_addr_reg)) { 724 bus->conf_io_addr = 725 (uint32_t) hw_resources.resources[0].res.io_range.address; 726 bus->conf_io_data = 727 (uint32_t) hw_resources.resources[1].res.io_range.address; 728 729 if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 4, 730 &bus->conf_addr_port)) { 728 731 ddf_msg(LVL_ERROR, "Failed to enable configuration ports."); 729 732 rc = EADDRNOTAVAIL; 730 733 goto fail; 731 734 } 732 if (pio_enable _resource(&bus->pio_win, &hw_resources.resources[1],733 (void **) &bus->conf_data_reg)) {735 if (pio_enable((void *)(uintptr_t)bus->conf_io_data, 4, 736 &bus->conf_data_port)) { 734 737 ddf_msg(LVL_ERROR, "Failed to enable configuration ports."); 735 738 rc = EADDRNOTAVAIL; -
uspace/drv/bus/pci/pciintel/pci.h
rddd0499d r695b6ff 45 45 /** DDF device node */ 46 46 ddf_dev_t *dnode; 47 ioport32_t *conf_addr_reg; 48 ioport32_t *conf_data_reg; 47 uint32_t conf_io_addr; 48 uint32_t conf_io_data; 49 void *conf_data_port; 50 void *conf_addr_port; 49 51 pio_window_t pio_win; 50 52 fibril_mutex_t conf_mutex; -
uspace/drv/bus/usb/ehci/main.c
rddd0499d r695b6ff 77 77 assert(device); 78 78 79 addr_range_t reg_range; 79 uintptr_t reg_base = 0; 80 size_t reg_size = 0; 80 81 int irq = 0; 81 82 82 int rc = get_my_registers(device, ®_ range, &irq);83 int rc = get_my_registers(device, ®_base, ®_size, &irq); 83 84 if (rc != EOK) { 84 85 usb_log_error("Failed to get memory addresses for %" PRIun … … 87 88 } 88 89 89 usb_log_info("Memory mapped regs at %p(size %zu), IRQ %d.\n",90 RNGABSPTR(reg_range), RNGSZ(reg_range), irq);90 usb_log_info("Memory mapped regs at 0x%" PRIxn " (size %zu), IRQ %d.\n", 91 reg_base, reg_size, irq); 91 92 92 rc = disable_legacy(device, ®_range);93 rc = disable_legacy(device, reg_base, reg_size); 93 94 if (rc != EOK) { 94 95 usb_log_error("Failed to disable legacy USB: %s.\n", -
uspace/drv/bus/usb/ehci/res.c
rddd0499d r695b6ff 71 71 * 72 72 * @param[in] dev Device asking for the addresses. 73 * @param[out] mem_regs_p Pointer to the register range. 73 * @param[out] mem_reg_address Base address of the memory range. 74 * @param[out] mem_reg_size Size of the memory range. 74 75 * @param[out] irq_no IRQ assigned to the device. 75 76 * @return Error code. 76 77 */ 77 78 int get_my_registers(ddf_dev_t *dev, 78 addr_range_t *mem_regs_p, int *irq_no)79 uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no) 79 80 { 80 81 assert(dev); … … 98 99 } 99 100 100 if (mem_regs_p) 101 *mem_regs_p = hw_res.mem_ranges.ranges[0]; 101 if (mem_reg_address) 102 *mem_reg_address = hw_res.mem_ranges.ranges[0].address; 103 if (mem_reg_size) 104 *mem_reg_size = hw_res.mem_ranges.ranges[0].size; 102 105 if (irq_no) 103 106 *irq_no = hw_res.irqs.irqs[0]; … … 264 267 } 265 268 266 int disable_legacy(ddf_dev_t *device, addr_range_t *reg_range)269 int disable_legacy(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size) 267 270 { 268 271 assert(device); … … 271 274 /* Map EHCI registers */ 272 275 void *regs = NULL; 273 int rc = pio_enable _range(reg_range, ®s);276 int rc = pio_enable((void*)reg_base, reg_size, ®s); 274 277 if (rc != EOK) { 275 278 usb_log_error("Failed to map registers %p: %s.\n", 276 RNGABSPTR(*reg_range), str_error(rc));279 (void *) reg_base, str_error(rc)); 277 280 return rc; 278 281 } -
uspace/drv/bus/usb/ehci/res.h
rddd0499d r695b6ff 37 37 38 38 #include <ddf/driver.h> 39 #include <device/hw_res_parsed.h>40 39 41 int get_my_registers(ddf_dev_t *, addr_range_t *, int *);40 int get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *); 42 41 int enable_interrupts(ddf_dev_t *); 43 int disable_legacy(ddf_dev_t *, addr_range_t *);42 int disable_legacy(ddf_dev_t *, uintptr_t, size_t); 44 43 45 44 #endif -
uspace/drv/bus/usb/ohci/hc.c
rddd0499d r695b6ff 106 106 * @param[out] cmds Commands buffer. 107 107 * @param[in] cmds_size Size of the commands buffer (bytes). 108 * @param[in] regs Device's register range. 108 * @param[in] regs Physical address of device's registers. 109 * @param[in] reg_size Size of the register area (bytes). 109 110 * 110 111 * @return Error code. … … 112 113 int 113 114 hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[], 114 size_t cmds_size, addr_range_t *regs)115 size_t cmds_size, uintptr_t regs, size_t reg_size) 115 116 { 116 117 if ((ranges_size < sizeof(ohci_pio_ranges)) || 117 118 (cmds_size < sizeof(ohci_irq_commands)) || 118 ( RNGSZ(*regs)< sizeof(ohci_regs_t)))119 (reg_size < sizeof(ohci_regs_t))) 119 120 return EOVERFLOW; 120 121 121 122 memcpy(ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges)); 122 ranges[0].base = RNGABS(*regs);123 ranges[0].base = regs; 123 124 124 125 memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands)); 125 ohci_regs_t *registers = (ohci_regs_t *) RNGABSPTR(*regs);126 ohci_regs_t *registers = (ohci_regs_t *) regs; 126 127 cmds[0].addr = (void *) ®isters->interrupt_status; 127 128 cmds[3].addr = (void *) ®isters->interrupt_status; … … 134 135 * 135 136 * @param[in] device Host controller DDF device 136 * @param[in] regs Register range 137 * @param[in] reg_base Register range base 138 * @param[in] reg_size Register range size 137 139 * @param[in] irq Interrupt number 138 140 * @paran[in] handler Interrupt handler … … 140 142 * @return EOK on success or negative error code 141 143 */ 142 int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq,143 int errupt_handler_t handler)144 int hc_register_irq_handler(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size, 145 int irq, interrupt_handler_t handler) 144 146 { 145 147 int rc; … … 156 158 157 159 rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds, 158 sizeof(irq_cmds), reg s);160 sizeof(irq_cmds), reg_base, reg_size); 159 161 if (rc != EOK) { 160 162 usb_log_error("Failed to generate IRQ code: %s.\n", … … 257 259 * 258 260 * @param[in] instance Memory place for the structure. 259 * @param[in] regs Device's I/O registers range. 261 * @param[in] regs Address of the memory mapped I/O registers. 262 * @param[in] reg_size Size of the memory mapped area. 260 263 * @param[in] interrupts True if w interrupts should be used 261 264 * @return Error code 262 265 */ 263 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts) 264 { 265 assert(instance); 266 267 int rc = pio_enable_range(regs, (void **) &instance->registers); 266 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts) 267 { 268 assert(instance); 269 270 int rc = 271 pio_enable((void*)regs, reg_size, (void**)&instance->registers); 268 272 if (rc != EOK) { 269 273 usb_log_error("Failed to gain access to device registers: %s.\n", -
uspace/drv/bus/usb/ohci/hc.h
rddd0499d r695b6ff 75 75 } hc_t; 76 76 77 int hc_get_irq_code(irq_pio_range_t [], size_t, irq_cmd_t [], size_t, 78 addr_range_t *); 79 int hc_register_irq_handler(ddf_dev_t *, addr_range_t *, int, 80 interrupt_handler_t); 77 int hc_get_irq_code(irq_pio_range_t [], size_t, irq_cmd_t [], size_t, uintptr_t, 78 size_t); 79 int hc_register_irq_handler(ddf_dev_t *, uintptr_t, size_t, int, interrupt_handler_t); 81 80 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 82 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts);81 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts); 83 82 84 83 /** Safely dispose host controller internal structures -
uspace/drv/bus/usb/ohci/ohci.c
rddd0499d r695b6ff 177 177 ddf_fun_set_ops(instance->rh_fun, &rh_ops); 178 178 179 addr_range_t regs; 179 uintptr_t reg_base = 0; 180 size_t reg_size = 0; 180 181 int irq = 0; 181 182 182 rc = get_my_registers(device, ® s, &irq);183 rc = get_my_registers(device, ®_base, ®_size, &irq); 183 184 if (rc != EOK) { 184 185 usb_log_error("Failed to get register memory addresses " … … 189 190 190 191 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n", 191 RNGABSPTR(regs), RNGSZ(regs), irq);192 193 rc = hc_register_irq_handler(device, ®s, irq, irq_handler);192 (void *) reg_base, reg_size, irq); 193 194 rc = hc_register_irq_handler(device, reg_base, reg_size, irq, irq_handler); 194 195 if (rc != EOK) { 195 196 usb_log_error("Failed to register interrupt handler: %s.\n", … … 214 215 } 215 216 216 rc = hc_init(&instance->hc, ®s, interrupts);217 rc = hc_init(&instance->hc, reg_base, reg_size, interrupts); 217 218 if (rc != EOK) { 218 219 usb_log_error("Failed to init ohci_hcd: %s.\n", str_error(rc)); -
uspace/drv/bus/usb/ohci/res.c
rddd0499d r695b6ff 48 48 * 49 49 * @param[in] dev Device asking for the addresses. 50 * @param[out] p_regs Pointer to register range. 50 * @param[out] mem_reg_address Base address of the memory range. 51 * @param[out] mem_reg_size Size of the memory range. 51 52 * @param[out] irq_no IRQ assigned to the device. 52 53 * @return Error code. 53 54 */ 54 int get_my_registers(ddf_dev_t *dev, addr_range_t *p_regs, int *irq_no) 55 int get_my_registers(ddf_dev_t *dev, 56 uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no) 55 57 { 56 58 assert(dev); … … 64 66 hw_res_list_parsed_t hw_res; 65 67 hw_res_list_parsed_init(&hw_res); 66 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);68 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0); 67 69 async_hangup(parent_sess); 68 70 if (ret != EOK) { … … 76 78 } 77 79 78 if (p_regs) 79 *p_regs = hw_res.mem_ranges.ranges[0]; 80 if (mem_reg_address) 81 *mem_reg_address = hw_res.mem_ranges.ranges[0].address; 82 if (mem_reg_size) 83 *mem_reg_size = hw_res.mem_ranges.ranges[0].size; 80 84 if (irq_no) 81 85 *irq_no = hw_res.irqs.irqs[0]; -
uspace/drv/bus/usb/ohci/res.h
rddd0499d r695b6ff 36 36 37 37 #include <ddf/driver.h> 38 #include <device/hw_res_parsed.h>39 38 40 int get_my_registers(ddf_dev_t *, addr_range_t *, int *);39 int get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *); 41 40 int enable_interrupts(ddf_dev_t *); 42 41 -
uspace/drv/bus/usb/uhci/hc.c
rddd0499d r695b6ff 105 105 * @param[out] cmds Commands buffer. 106 106 * @param[in] cmds_size Size of the commands buffer (bytes). 107 * @param[in] regs Device's register range. 107 * @param[in] regs Physical address of device's registers. 108 * @param[in] reg_size Size of the register area (bytes). 108 109 * 109 110 * @return Error code. … … 111 112 int 112 113 hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[], 113 size_t cmds_size, addr_range_t *regs)114 size_t cmds_size, uintptr_t regs, size_t reg_size) 114 115 { 115 116 if ((ranges_size < sizeof(uhci_irq_pio_ranges)) || 116 117 (cmds_size < sizeof(uhci_irq_commands)) || 117 ( RNGSZ(*regs)< sizeof(uhci_regs_t)))118 (reg_size < sizeof(uhci_regs_t))) 118 119 return EOVERFLOW; 119 120 120 121 memcpy(ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges)); 121 ranges[0].base = RNGABS(*regs);122 ranges[0].base = regs; 122 123 123 124 memcpy(cmds, uhci_irq_commands, sizeof(uhci_irq_commands)); 124 uhci_regs_t *registers = (uhci_regs_t *) RNGABSPTR(*regs);125 uhci_regs_t *registers = (uhci_regs_t *) regs; 125 126 cmds[0].addr = ®isters->usbsts; 126 127 cmds[3].addr = ®isters->usbsts; … … 132 133 * 133 134 * @param[in] device Host controller DDF device 134 * @param[in] regs Register range 135 * @param[in] reg_base Register range base 136 * @param[in] reg_size Register range size 135 137 * @param[in] irq Interrupt number 136 138 * @paran[in] handler Interrupt handler … … 138 140 * @return EOK on success or negative error code 139 141 */ 140 int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq,141 int errupt_handler_t handler)142 int hc_register_irq_handler(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size, 143 int irq, interrupt_handler_t handler) 142 144 { 143 145 int rc; … … 145 147 irq_cmd_t irq_cmds[hc_irq_cmd_count]; 146 148 rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds, 147 sizeof(irq_cmds), reg s);149 sizeof(irq_cmds), reg_base, reg_size); 148 150 if (rc != EOK) { 149 151 usb_log_error("Failed to generate IRQ commands: %s.\n", … … 230 232 * 231 233 * @param[in] instance Memory place to initialize. 232 * @param[in] regs Range of device's I/O control registers. 234 * @param[in] regs Address of I/O control registers. 235 * @param[in] reg_size Size of I/O control registers. 233 236 * @param[in] interrupts True if hw interrupts should be used. 234 237 * @return Error code. … … 238 241 * interrupt fibrils. 239 242 */ 240 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)241 { 242 assert(reg s->size >= sizeof(uhci_regs_t));243 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interrupts) 244 { 245 assert(reg_size >= sizeof(uhci_regs_t)); 243 246 int rc; 244 247 … … 248 251 /* allow access to hc control registers */ 249 252 uhci_regs_t *io; 250 rc = pio_enable _range(regs, (void **)&io);253 rc = pio_enable(regs, reg_size, (void **)&io); 251 254 if (rc != EOK) { 252 255 usb_log_error("Failed to gain access to registers at %p: %s.\n", … … 257 260 instance->registers = io; 258 261 usb_log_debug( 259 "Device registers at %p (%zuB) accessible.\n", io, reg s->size);262 "Device registers at %p (%zuB) accessible.\n", io, reg_size); 260 263 261 264 rc = hc_init_mem_structures(instance); -
uspace/drv/bus/usb/uhci/hc.h
rddd0499d r695b6ff 37 37 38 38 #include <ddf/interrupt.h> 39 #include <device/hw_res_parsed.h>40 39 #include <fibril.h> 41 40 #include <usb/host/hcd.h> … … 121 120 } hc_t; 122 121 123 int hc_register_irq_handler(ddf_dev_t *, addr_range_t *, int, 124 interrupt_handler_t); 125 int hc_get_irq_code(irq_pio_range_t [], size_t, irq_cmd_t [], size_t, 126 addr_range_t *); 122 int hc_register_irq_handler(ddf_dev_t *, uintptr_t, size_t, int, interrupt_handler_t); 123 int hc_get_irq_code(irq_pio_range_t [], size_t, irq_cmd_t [], size_t, uintptr_t, 124 size_t); 127 125 void hc_interrupt(hc_t *instance, uint16_t status); 128 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts);126 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interupts); 129 127 130 128 /** Safely dispose host controller internal structures … … 134 132 static inline void hc_fini(hc_t *instance) {} /* TODO: implement*/ 135 133 #endif 136 137 134 /** 138 135 * @} -
uspace/drv/bus/usb/uhci/res.c
rddd0499d r695b6ff 46 46 * 47 47 * @param[in] dev Device asking for the addresses. 48 * @param[out] io_regs_p Pointer to register I/O range. 48 * @param[out] io_reg_address Base address of the I/O range. 49 * @param[out] io_reg_size Size of the I/O range. 49 50 * @param[out] irq_no IRQ assigned to the device. 50 51 * @return Error code. 51 52 */ 52 int get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs_p, int *irq_no) 53 int get_my_registers(ddf_dev_t *dev, 54 uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no) 53 55 { 54 56 assert(dev); … … 74 76 } 75 77 76 if (io_regs_p) 77 *io_regs_p = hw_res.io_ranges.ranges[0]; 78 if (io_reg_address) 79 *io_reg_address = hw_res.io_ranges.ranges[0].address; 80 if (io_reg_size) 81 *io_reg_size = hw_res.io_ranges.ranges[0].size; 78 82 if (irq_no) 79 83 *irq_no = hw_res.irqs.irqs[0]; -
uspace/drv/bus/usb/uhci/res.h
rddd0499d r695b6ff 37 37 38 38 #include <ddf/driver.h> 39 #include <device/hw_res_parsed.h>40 39 41 int get_my_registers(ddf_dev_t *, addr_range_t *, int *);40 int get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *); 42 41 int enable_interrupts(ddf_dev_t *); 43 42 int disable_legacy(ddf_dev_t *); -
uspace/drv/bus/usb/uhci/uhci.c
rddd0499d r695b6ff 184 184 ddf_fun_data_implant(instance->rh_fun, &instance->rh); 185 185 186 addr_range_t regs; 186 uintptr_t reg_base = 0; 187 size_t reg_size = 0; 187 188 int irq = 0; 188 189 189 rc = get_my_registers(device, ® s, &irq);190 rc = get_my_registers(device, ®_base, ®_size, &irq); 190 191 if (rc != EOK) { 191 192 usb_log_error("Failed to get I/O addresses for %" PRIun ": %s.\n", … … 193 194 goto error; 194 195 } 195 usb_log_debug("I/O regs at %p (size %zu), IRQ %d.\n",196 RNGABSPTR(regs), RNGSZ(regs), irq);196 usb_log_debug("I/O regs at 0x%p (size %zu), IRQ %d.\n", 197 (void *) reg_base, reg_size, irq); 197 198 198 199 rc = disable_legacy(device); … … 203 204 } 204 205 205 rc = hc_register_irq_handler(device, ®s, irq, irq_handler);206 rc = hc_register_irq_handler(device, reg_base, reg_size, irq, irq_handler); 206 207 if (rc != EOK) { 207 208 usb_log_error("Failed to register interrupt handler: %s.\n", … … 222 223 } 223 224 224 rc = hc_init(&instance->hc, ®s, interrupts);225 rc = hc_init(&instance->hc, (void*)reg_base, reg_size, interrupts); 225 226 if (rc != EOK) { 226 227 usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(rc)); -
uspace/drv/bus/usb/uhcirh/main.c
rddd0499d r695b6ff 48 48 #define NAME "uhcirh" 49 49 50 static int hc_get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs); 50 static int hc_get_my_registers(ddf_dev_t *dev, 51 uintptr_t *io_reg_address, size_t *io_reg_size); 51 52 52 53 static int uhci_rh_dev_add(ddf_dev_t *device); … … 89 90 ddf_dev_get_handle(device)); 90 91 91 addr_range_t regs; 92 uintptr_t io_regs = 0; 93 size_t io_size = 0; 92 94 uhci_root_hub_t *rh = NULL; 93 95 int rc; 94 96 95 rc = hc_get_my_registers(device, & regs);97 rc = hc_get_my_registers(device, &io_regs, &io_size); 96 98 if (rc != EOK) { 97 99 usb_log_error( "Failed to get registers from HC: %s.\n", … … 101 103 102 104 usb_log_debug("I/O regs at %p (size %zuB).\n", 103 RNGABSPTR(regs), RNGSZ(regs));105 (void *) io_regs, io_size); 104 106 105 107 rh = ddf_dev_data_alloc(device, sizeof(uhci_root_hub_t)); … … 109 111 } 110 112 111 rc = uhci_root_hub_init(rh, ®s, device);113 rc = uhci_root_hub_init(rh, (void*)io_regs, io_size, device); 112 114 if (rc != EOK) { 113 115 usb_log_error("Failed(%d) to initialize rh driver instance: " … … 125 127 * 126 128 * @param[in] dev Device asking for the addresses. 127 * @param[out] io_regs_p Pointer to the device's register range. 129 * @param[out] io_reg_address Base address of the memory range. 130 * @param[out] io_reg_size Size of the memory range. 128 131 * @return Error code. 129 132 */ 130 int hc_get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs_p) 133 int hc_get_my_registers( 134 ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size) 131 135 { 132 136 async_sess_t *parent_sess = … … 149 153 } 150 154 151 if (io_regs_p != NULL) 152 *io_regs_p = hw_res.io_ranges.ranges[0]; 155 if (io_reg_address != NULL) 156 *io_reg_address = hw_res.io_ranges.ranges[0].address; 157 158 if (io_reg_size != NULL) 159 *io_reg_size = hw_res.io_ranges.ranges[0].size; 153 160 154 161 hw_res_list_parsed_clean(&hw_res); -
uspace/drv/bus/usb/uhcirh/root_hub.c
rddd0499d r695b6ff 36 36 #include <ddi.h> 37 37 #include <usb/debug.h> 38 #include <device/hw_res_parsed.h>39 38 40 39 #include "root_hub.h" … … 43 42 * 44 43 * @param[in] instance Driver memory structure to use. 45 * @param[in] io_regs Range of I/O registers. 44 * @param[in] addr Address of I/O registers. 45 * @param[in] size Size of available I/O space. 46 46 * @param[in] rh Pointer to DDF instance of the root hub driver. 47 47 * @return Error code. 48 48 */ 49 int uhci_root_hub_init( uhci_root_hub_t *instance, addr_range_t *io_regs,50 49 int uhci_root_hub_init( 50 uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh) 51 51 { 52 port_status_t *regs;53 54 52 assert(instance); 55 53 assert(rh); 56 54 57 55 /* Allow access to root hub port registers */ 58 assert(sizeof( *regs) * UHCI_ROOT_HUB_PORT_COUNT <= io_regs->size);59 60 int ret = pio_enable _range(io_regs, (void **)®s);56 assert(sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT <= size); 57 port_status_t *regs; 58 int ret = pio_enable(addr, size, (void**)®s); 61 59 if (ret < 0) { 62 60 usb_log_error( 63 61 "Failed(%d) to gain access to port registers at %p: %s.\n", 64 ret, RNGABSPTR(*io_regs), str_error(ret));62 ret, regs, str_error(ret)); 65 63 return ret; 66 64 } -
uspace/drv/bus/usb/uhcirh/root_hub.h
rddd0499d r695b6ff 36 36 37 37 #include <ddf/driver.h> 38 #include <device/hw_res_parsed.h>39 38 40 39 #include "port.h" … … 49 48 } uhci_root_hub_t; 50 49 51 int uhci_root_hub_init( uhci_root_hub_t *instance, addr_range_t *regs,52 ddf_dev_t *rh);50 int uhci_root_hub_init( 51 uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh); 53 52 54 53 void uhci_root_hub_fini(uhci_root_hub_t *instance); -
uspace/drv/char/i8042/i8042.c
rddd0499d r695b6ff 145 145 * 146 146 * @param dev Driver structure to initialize. 147 * @param regs I/O range of registers. 147 * @param regs I/O address of registers. 148 * @param reg_size size of the reserved I/O address space. 148 149 * @param irq_kbd IRQ for primary port. 149 150 * @param irq_mouse IRQ for aux port. … … 153 154 * 154 155 */ 155 int i8042_init(i8042_t *dev, addr_range_t *regs, int irq_kbd,156 int i8042_init(i8042_t *dev, void *regs, size_t reg_size, int irq_kbd, 156 157 int irq_mouse, ddf_dev_t *ddf_dev) 157 158 { … … 161 162 const size_t cmd_count = sizeof(i8042_cmds) / sizeof(irq_cmd_t); 162 163 irq_cmd_t cmds[cmd_count]; 163 i8042_regs_t *ar;164 164 165 165 int rc; … … 170 170 dev->aux_fun = NULL; 171 171 172 if (reg s->size < sizeof(i8042_regs_t)) {172 if (reg_size < sizeof(i8042_regs_t)) { 173 173 rc = EINVAL; 174 174 goto error; 175 175 } 176 176 177 if (pio_enable _range(regs, (void **) &dev->regs) != 0) {177 if (pio_enable(regs, sizeof(i8042_regs_t), (void **) &dev->regs) != 0) { 178 178 rc = EIO; 179 179 goto error; … … 234 234 235 235 memcpy(ranges, i8042_ranges, sizeof(i8042_ranges)); 236 ranges[0].base = RNGABS(*regs); 237 238 239 ar = RNGABSPTR(*regs); 236 ranges[0].base = (uintptr_t) regs; 237 240 238 memcpy(cmds, i8042_cmds, sizeof(i8042_cmds)); 241 cmds[0].addr = (void *) & ar->status;242 cmds[3].addr = (void *) & ar->data;239 cmds[0].addr = (void *) &(((i8042_regs_t *) regs)->status); 240 cmds[3].addr = (void *) &(((i8042_regs_t *) regs)->data); 243 241 244 242 irq_code_t irq_code = { -
uspace/drv/char/i8042/i8042.h
rddd0499d r695b6ff 68 68 } i8042_t; 69 69 70 int i8042_init(i8042_t *, addr_range_t *, int, int, ddf_dev_t *);70 int i8042_init(i8042_t *, void *, size_t, int, int, ddf_dev_t *); 71 71 72 72 #endif -
uspace/drv/char/i8042/main.c
rddd0499d r695b6ff 49 49 * 50 50 * @param[in] dev Device asking for the addresses. 51 * @param[out] p_io_reg Pointer to register range. 51 * @param[out] io_reg_address Base address of the memory range. 52 * @param[out] io_reg_size Size of the memory range. 52 53 * @param[out] kbd_irq Primary port IRQ. 53 54 * @param[out] mouse_irq Auxiliary port IRQ. … … 56 57 * 57 58 */ 58 static int get_my_registers(ddf_dev_t *dev, addr_range_t *p_io_reg,59 int *kbd_irq, int *mouse_irq)59 static int get_my_registers(ddf_dev_t *dev, uintptr_t *io_reg_address, 60 size_t *io_reg_size, int *kbd_irq, int *mouse_irq) 60 61 { 61 62 assert(dev); … … 78 79 } 79 80 80 if (p_io_reg) 81 *p_io_reg = hw_resources.io_ranges.ranges[0]; 81 if (io_reg_address) 82 *io_reg_address = hw_resources.io_ranges.ranges[0].address; 83 84 if (io_reg_size) 85 *io_reg_size = hw_resources.io_ranges.ranges[0].size; 82 86 83 87 if (kbd_irq) … … 100 104 static int i8042_dev_add(ddf_dev_t *device) 101 105 { 102 addr_range_t io_regs; 106 uintptr_t io_regs = 0; 107 size_t io_size = 0; 103 108 int kbd = 0; 104 109 int mouse = 0; … … 108 113 return EINVAL; 109 114 110 rc = get_my_registers(device, &io_regs, & kbd, &mouse);115 rc = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse); 111 116 if (rc != EOK) { 112 117 ddf_msg(LVL_ERROR, "Failed to get registers: %s.", … … 115 120 } 116 121 117 ddf_msg(LVL_DEBUG, 118 "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.", 119 RNGABSPTR(io_regs), RNGSZ(io_regs), kbd, mouse); 122 ddf_msg(LVL_DEBUG, "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.", 123 (void *) io_regs, io_size, kbd, mouse); 120 124 121 125 i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t)); … … 125 129 } 126 130 127 rc = i8042_init(i8042, &io_regs, kbd, mouse, device);131 rc = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device); 128 132 if (rc != EOK) { 129 133 ddf_msg(LVL_ERROR, "Failed to initialize i8042 driver: %s.", -
uspace/drv/infrastructure/rootmac/rootmac.c
rddd0499d r695b6ff 54 54 .address = 0xfec00000, 55 55 .size = 4, 56 .relative = false,57 56 .endianness = LITTLE_ENDIAN 58 57 } … … 63 62 .address = 0xfee00000, 64 63 .size = 4, 65 .relative = false,66 64 .endianness = LITTLE_ENDIAN 67 65 } -
uspace/drv/infrastructure/rootmalta/rootmalta.c
rddd0499d r695b6ff 99 99 .address = GT_BASE + GT_PCI_CONFADDR, 100 100 .size = 4, 101 .relative = false,102 101 .endianness = LITTLE_ENDIAN 103 102 } … … 108 107 .address = GT_BASE + GT_PCI_CONFDATA, 109 108 .size = 4, 110 .relative = false,111 109 .endianness = LITTLE_ENDIAN 112 110 } -
uspace/drv/infrastructure/rootpc/rootpc.c
rddd0499d r695b6ff 81 81 .address = 0xCF8, 82 82 .size = 4, 83 .relative = false,84 83 .endianness = LITTLE_ENDIAN 85 84 } … … 90 89 .address = 0xCFC, 91 90 .size = 4, 92 .relative = false,93 91 .endianness = LITTLE_ENDIAN 94 92 } -
uspace/drv/nic/e1k/e1k.c
rddd0499d r695b6ff 1941 1941 e1000->irq = hw_resources->irqs.irqs[0]; 1942 1942 e1000->reg_base_phys = 1943 MEMADDR_TO_PTR( RNGABS(hw_resources->mem_ranges.ranges[0]));1943 MEMADDR_TO_PTR(hw_resources->mem_ranges.ranges[0].address); 1944 1944 1945 1945 return EOK; -
uspace/drv/nic/ne2k/ne2k.c
rddd0499d r695b6ff 211 211 ne2k->irq = hw_res_parsed.irqs.irqs[0]; 212 212 213 addr_range_t regs = hw_res_parsed.io_ranges.ranges[0];214 ne2k->base_port = RNGABSPTR(regs);213 ne2k->base_port = (void *) (uintptr_t) 214 hw_res_parsed.io_ranges.ranges[0].address; 215 215 216 216 hw_res_list_parsed_clean(&hw_res_parsed); 217 217 218 /* Enable p rogrammedI/O */219 if (pio_enable _range(®s, &ne2k->port) != EOK)218 /* Enable port I/O */ 219 if (pio_enable(ne2k->base_port, NE2K_IO_SIZE, &ne2k->port) != EOK) 220 220 return EADDRNOTAVAIL; 221 221 222 222 223 ne2k->data_port = ne2k->port + NE2K_DATA; -
uspace/drv/nic/rtl8139/driver.c
rddd0499d r695b6ff 1087 1087 ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", ddf_dev_get_name(dev), rtl8139->irq); 1088 1088 1089 rtl8139->io_addr = IOADDR_TO_PTR( RNGABS(hw_resources->io_ranges.ranges[0]));1089 rtl8139->io_addr = IOADDR_TO_PTR(hw_resources->io_ranges.ranges[0].address); 1090 1090 if (hw_resources->io_ranges.ranges[0].size < RTL8139_IO_SIZE) { 1091 1091 ddf_msg(LVL_ERROR, "i/o range assigned to the device " -
uspace/lib/c/generic/ddi.c
rddd0499d r695b6ff 42 42 #include <ddi.h> 43 43 #include <libarch/ddi.h> 44 #include <device/hw_res.h>45 #include <device/hw_res_parsed.h>46 #include <device/pio_window.h>47 44 #include <libc.h> 48 45 #include <task.h> … … 137 134 138 135 return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg); 139 }140 141 /** Enable PIO for specified address range.142 *143 * @param range I/O range to be enable.144 * @param virt Virtual address for application's PIO operations.145 */146 int pio_enable_range(addr_range_t *range, void **virt)147 {148 return pio_enable(RNGABSPTR(*range), RNGSZ(*range), virt);149 }150 151 /** Enable PIO for specified HW resource wrt. to the PIO window.152 *153 * @param win PIO window. May be NULL if the resources are known to be154 * absolute.155 * @param res Resources specifying the I/O range wrt. to the PIO window.156 * @param virt Virtual address for application's PIO operations.157 *158 * @return EOK on success.159 * @return Negative error code on failure.160 *161 */162 int pio_enable_resource(pio_window_t *win, hw_resource_t *res, void **virt)163 {164 uintptr_t addr;165 size_t size;166 167 switch (res->type) {168 case IO_RANGE:169 addr = res->res.io_range.address;170 if (res->res.io_range.relative) {171 if (!win)172 return EINVAL;173 addr += win->io.base;174 }175 size = res->res.io_range.size;176 break;177 case MEM_RANGE:178 addr = res->res.mem_range.address;179 if (res->res.mem_range.relative) {180 if (!win)181 return EINVAL;182 addr += win->mem.base;183 }184 size = res->res.mem_range.size;185 break;186 default:187 return EINVAL;188 }189 190 return pio_enable((void *) addr, size, virt);191 136 } 192 137 -
uspace/lib/c/generic/device/hw_res_parsed.c
rddd0499d r695b6ff 80 80 } 81 81 82 static uint64_t absolutize(uint64_t addr, bool relative, uint64_t base)83 {84 if (!relative)85 return addr;86 else87 return addr + base;88 }89 90 static uint64_t relativize(uint64_t addr, bool relative, uint64_t base)91 {92 if (relative)93 return addr;94 else95 return addr - base;96 }97 98 82 static void hw_res_parse_add_io_range(hw_res_list_parsed_t *out, 99 const pio_window_t *win, const hw_resource_t *res, int flags) 100 { 101 endianness_t endianness; 102 uint64_t absolute; 103 uint64_t relative; 104 size_t size; 105 83 const hw_resource_t *res, int flags) 84 { 106 85 assert(res && (res->type == IO_RANGE)); 107 86 108 absolute = absolutize(res->res.io_range.address, 109 res->res.io_range.relative, win->io.base); 110 relative = relativize(res->res.io_range.address, 111 res->res.io_range.relative, win->io.base); 112 size = res->res.io_range.size; 113 endianness = res->res.io_range.endianness; 87 uint64_t address = res->res.io_range.address; 88 endianness_t endianness = res->res.io_range.endianness; 89 size_t size = res->res.io_range.size; 114 90 115 91 if ((size == 0) && (!(flags & HW_RES_KEEP_ZERO_AREA))) … … 121 97 if (!keep_duplicit) { 122 98 for (size_t i = 0; i < count; i++) { 123 uint64_t s_address; 124 size_t s_size; 125 126 s_address = RNGABS(out->io_ranges.ranges[i]); 127 s_size = RNGSZ(out->io_ranges.ranges[i]); 99 uint64_t s_address = out->io_ranges.ranges[i].address; 100 size_t s_size = out->io_ranges.ranges[i].size; 128 101 129 if ((absolute == s_address) && (size == s_size)) 130 return; 131 } 132 } 133 134 RNGABS(out->io_ranges.ranges[count]) = absolute; 135 RNGREL(out->io_ranges.ranges[count]) = relative; 136 RNGSZ(out->io_ranges.ranges[count]) = size; 102 if ((address == s_address) && (size == s_size)) 103 return; 104 } 105 } 106 107 out->io_ranges.ranges[count].address = address; 137 108 out->io_ranges.ranges[count].endianness = endianness; 109 out->io_ranges.ranges[count].size = size; 138 110 out->io_ranges.count++; 139 111 } 140 112 141 113 static void hw_res_parse_add_mem_range(hw_res_list_parsed_t *out, 142 const pio_window_t *win, const hw_resource_t *res, int flags) 143 { 144 endianness_t endianness; 145 uint64_t absolute; 146 uint64_t relative; 147 size_t size; 148 114 const hw_resource_t *res, int flags) 115 { 149 116 assert(res && (res->type == MEM_RANGE)); 150 117 151 absolute = absolutize(res->res.mem_range.address, 152 res->res.mem_range.relative, win->mem.base); 153 relative = relativize(res->res.mem_range.address, 154 res->res.mem_range.relative, win->mem.base); 155 size = res->res.mem_range.size; 156 endianness = res->res.mem_range.endianness; 118 uint64_t address = res->res.mem_range.address; 119 endianness_t endianness = res->res.mem_range.endianness; 120 size_t size = res->res.mem_range.size; 157 121 158 122 if ((size == 0) && (!(flags & HW_RES_KEEP_ZERO_AREA))) … … 164 128 if (!keep_duplicit) { 165 129 for (size_t i = 0; i < count; ++i) { 166 uint64_t s_address; 167 size_t s_size; 168 169 s_address = RNGABS(out->mem_ranges.ranges[i]);; 170 s_size = RNGSZ(out->mem_ranges.ranges[i]); 130 uint64_t s_address = out->mem_ranges.ranges[i].address; 131 size_t s_size = out->mem_ranges.ranges[i].size; 171 132 172 if ((absolute == s_address) && (size == s_size)) 173 return; 174 } 175 } 176 177 RNGABS(out->mem_ranges.ranges[count]) = absolute; 178 RNGREL(out->mem_ranges.ranges[count]) = relative; 179 RNGSZ(out->mem_ranges.ranges[count]) = size; 133 if ((address == s_address) && (size == s_size)) 134 return; 135 } 136 } 137 138 out->mem_ranges.ranges[count].address = address; 180 139 out->mem_ranges.ranges[count].endianness = endianness; 140 out->mem_ranges.ranges[count].size = size; 181 141 out->mem_ranges.count++; 182 142 } … … 184 144 /** Parse list of hardware resources 185 145 * 186 * @param win PIO window.187 * @param res Original structure resource.188 * @param [out] out Output parsed resources.189 * @param flags Flags of the parsing:190 * HW_RES_KEEP_ZERO_AREA for keeping zero-size areas,191 * HW_RES_KEEP_DUPLICITIES to keep duplicit areas.146 * @param hw_resources Original structure resource 147 * @param[out] out Output parsed resources 148 * @param flags Flags of the parsing. 149 * HW_RES_KEEP_ZERO_AREA for keeping 150 * zero-size areas, HW_RES_KEEP_DUPLICITIES 151 * for keep duplicit areas 192 152 * 193 153 * @return EOK if succeed, error code otherwise. 194 154 * 195 155 */ 196 int hw_res_list_parse(const pio_window_t *win,197 const hw_resource_list_t *res,hw_res_list_parsed_t *out, int flags)198 { 199 if ( !res || !out)156 int hw_res_list_parse(const hw_resource_list_t *hw_resources, 157 hw_res_list_parsed_t *out, int flags) 158 { 159 if ((!hw_resources) || (!out)) 200 160 return EINVAL; 201 161 202 size_t res_count = res->count;162 size_t res_count = hw_resources->count; 203 163 hw_res_list_parsed_clean(out); 204 164 … … 214 174 215 175 for (size_t i = 0; i < res_count; ++i) { 216 const hw_resource_t *resource = & res->resources[i];176 const hw_resource_t *resource = &(hw_resources->resources[i]); 217 177 218 178 switch (resource->type) { … … 221 181 break; 222 182 case IO_RANGE: 223 hw_res_parse_add_io_range(out, win,resource, flags);183 hw_res_parse_add_io_range(out, resource, flags); 224 184 break; 225 185 case MEM_RANGE: 226 hw_res_parse_add_mem_range(out, win,resource, flags);186 hw_res_parse_add_mem_range(out, resource, flags); 227 187 break; 228 188 case DMA_CHANNEL_8: … … 256 216 hw_res_list_parsed_t *hw_res_parsed, int flags) 257 217 { 258 pio_window_t pio_window;259 int rc;260 261 218 if (!hw_res_parsed) 262 219 return EBADMEM; … … 265 222 hw_res_list_parsed_clean(hw_res_parsed); 266 223 memset(&hw_resources, 0, sizeof(hw_resource_list_t)); 267 268 rc = pio_window_get(sess, &pio_window); 269 if (rc != EOK) 270 return rc; 271 272 rc = hw_res_get_resource_list(sess, &hw_resources); 224 225 int rc = hw_res_get_resource_list(sess, &hw_resources); 273 226 if (rc != EOK) 274 227 return rc; 275 276 rc = hw_res_list_parse(&pio_window, &hw_resources, hw_res_parsed, 277 flags); 228 229 rc = hw_res_list_parse(&hw_resources, hw_res_parsed, flags); 278 230 hw_res_clean_resource_list(&hw_resources); 279 231 -
uspace/lib/c/include/ddi.h
rddd0499d r695b6ff 40 40 #include <sys/time.h> 41 41 #include <abi/ddi/irq.h> 42 #include <device/hw_res.h>43 #include <device/hw_res_parsed.h>44 #include <device/pio_window.h>45 42 #include <task.h> 46 43 … … 58 55 extern int dmamem_unmap_anonymous(void *); 59 56 60 extern int pio_enable_range(addr_range_t *, void **);61 extern int pio_enable_resource(pio_window_t *, hw_resource_t *, void **);62 57 extern int pio_enable(void *, size_t, void **); 63 58 -
uspace/lib/c/include/device/hw_res.h
rddd0499d r695b6ff 76 76 struct { 77 77 uint64_t address; 78 endianness_t endianness; 78 79 size_t size; 79 bool relative;80 endianness_t endianness;81 80 } mem_range; 82 81 83 82 struct { 84 83 uint64_t address; 84 endianness_t endianness; 85 85 size_t size; 86 bool relative;87 endianness_t endianness;88 86 } io_range; 89 87 -
uspace/lib/c/include/device/hw_res_parsed.h
rddd0499d r695b6ff 37 37 38 38 #include <device/hw_res.h> 39 #include <device/pio_window.h>40 39 #include <str.h> 41 40 … … 46 45 #define HW_RES_KEEP_DUPLICIT 0x2 47 46 48 49 #define RNGABS(rng) (rng).address.absolute50 #define RNGREL(rng) (rng).address.relative51 #define RNGSZ(rng) (rng).size52 53 #define RNGABSPTR(rng) ((void *) ((uintptr_t) RNGABS((rng))))54 55 typedef struct address64 {56 /** Aboslute address. */57 uint64_t absolute;58 /** PIO window base relative address. */59 uint64_t relative;60 } address64_t;61 62 47 /** Address range structure */ 63 48 typedef struct addr_range { 64 49 /** Start address */ 65 address64_t address; 50 uint64_t address; 51 52 /** Endianness */ 53 endianness_t endianness; 66 54 67 55 /** Area size */ 68 56 size_t size; 69 70 /** Endianness */71 endianness_t endianness;72 57 } addr_range_t; 73 58 … … 154 139 } 155 140 156 extern int hw_res_list_parse(const pio_window_t *, consthw_resource_list_t *,141 extern int hw_res_list_parse(const hw_resource_list_t *, 157 142 hw_res_list_parsed_t *, int); 158 143 extern int hw_res_get_list_parsed(async_sess_t *, hw_res_list_parsed_t *, int);
Note:
See TracChangeset
for help on using the changeset viewer.