Changeset c2a6983 in mainline for uspace/drv
- Timestamp:
- 2013-10-13T20:59:33Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 12d6c98
- Parents:
- 820104d (diff), 39bcc99 (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. - Location:
- uspace/drv
- Files:
-
- 17 added
- 42 edited
-
audio/sb16/Makefile (added)
-
audio/sb16/ddf_log.h (added)
-
audio/sb16/dsp.c (added)
-
audio/sb16/dsp.h (added)
-
audio/sb16/dsp_commands.h (added)
-
audio/sb16/main.c (added)
-
audio/sb16/mixer.c (added)
-
audio/sb16/mixer.h (added)
-
audio/sb16/mixer_iface.c (added)
-
audio/sb16/pcm_iface.c (added)
-
audio/sb16/registers.h (added)
-
audio/sb16/sb16.c (added)
-
audio/sb16/sb16.h (added)
-
audio/sb16/sb16.ma (added)
-
block/ahci/ahci.c (modified) (21 diffs)
-
block/ata_bd/ata_bd.c (modified) (1 diff)
-
block/ata_bd/main.c (modified) (1 diff)
-
bus/isa/i8237.c (modified) (9 diffs)
-
bus/isa/i8237.h (modified) (1 diff)
-
bus/isa/isa.c (modified) (27 diffs)
-
bus/pci/pciintel/pci.c (modified) (16 diffs)
-
bus/pci/pciintel/pci.h (modified) (2 diffs)
-
bus/usb/ehci/main.c (modified) (2 diffs)
-
bus/usb/ehci/res.c (modified) (4 diffs)
-
bus/usb/ehci/res.h (modified) (1 diff)
-
bus/usb/ohci/hc.c (modified) (6 diffs)
-
bus/usb/ohci/hc.h (modified) (1 diff)
-
bus/usb/ohci/ohci.c (modified) (3 diffs)
-
bus/usb/ohci/res.c (modified) (3 diffs)
-
bus/usb/ohci/res.h (modified) (1 diff)
-
bus/usb/uhci/hc.c (modified) (9 diffs)
-
bus/usb/uhci/hc.h (modified) (3 diffs)
-
bus/usb/uhci/res.c (modified) (2 diffs)
-
bus/usb/uhci/res.h (modified) (1 diff)
-
bus/usb/uhci/uhci.c (modified) (4 diffs)
-
bus/usb/uhci/utils/malloc32.h (modified) (2 diffs)
-
bus/usb/uhcirh/main.c (modified) (6 diffs)
-
bus/usb/uhcirh/root_hub.c (modified) (2 diffs)
-
bus/usb/uhcirh/root_hub.h (modified) (2 diffs)
-
bus/usb/usbmid/explore.c (modified) (2 diffs)
-
bus/usb/usbmid/usbmid.c (modified) (1 diff)
-
bus/usb/vhc/transfer.c (modified) (1 diff)
-
char/i8042/i8042.c (modified) (5 diffs)
-
char/i8042/i8042.h (modified) (1 diff)
-
char/i8042/main.c (modified) (7 diffs)
-
fb/amdm37x_dispc/amdm37x_dispc.c (modified) (1 diff)
-
fb/kfb/port.c (modified) (1 diff)
-
infrastructure/root/root.c (modified) (1 diff)
-
infrastructure/rootamdm37x/rootamdm37x.c (modified) (5 diffs)
-
infrastructure/rootamdm37x/uhh.h (modified) (1 diff)
-
infrastructure/rootmac/rootmac.c (modified) (2 diffs)
-
infrastructure/rootmalta/Makefile (added)
-
infrastructure/rootmalta/rootmalta.c (added)
-
infrastructure/rootmalta/rootmalta.ma (added)
-
infrastructure/rootpc/rootpc.c (modified) (8 diffs)
-
nic/e1k/e1k.c (modified) (16 diffs)
-
nic/ne2k/ne2k.c (modified) (1 diff)
-
nic/rtl8139/driver.c (modified) (3 diffs)
-
nic/rtl8139/driver.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/ahci/ahci.c
r820104d rc2a6983 119 119 static int ahci_identify_device(sata_dev_t *); 120 120 static int ahci_set_highest_ultra_dma_mode(sata_dev_t *); 121 static int ahci_rb_fpdma(sata_dev_t *, void *, uint64_t);122 static int ahci_wb_fpdma(sata_dev_t *, void *, uint64_t);121 static int ahci_rb_fpdma(sata_dev_t *, uintptr_t, uint64_t); 122 static int ahci_wb_fpdma(sata_dev_t *, uintptr_t, uint64_t); 123 123 124 124 static void ahci_sata_devices_create(ahci_dev_t *, ddf_dev_t *); … … 233 233 sata_dev_t *sata = fun_sata_dev(fun); 234 234 235 void *phys;235 uintptr_t phys; 236 236 void *ibuf; 237 int rc = dmamem_map_anonymous(sata->block_size, AS_AREA_READ | AS_AREA_WRITE,238 0, &phys, (void **)&ibuf);237 int rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB, 238 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &ibuf); 239 239 if (rc != EOK) { 240 240 ddf_msg(LVL_ERROR, "Cannot allocate read buffer."); … … 276 276 sata_dev_t *sata = fun_sata_dev(fun); 277 277 278 void *phys;278 uintptr_t phys; 279 279 void *ibuf; 280 int rc = dmamem_map_anonymous(sata->block_size, AS_AREA_READ | AS_AREA_WRITE,281 0, &phys, (void **)&ibuf);280 int rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB, 281 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &ibuf); 282 282 if (rc != EOK) { 283 283 ddf_msg(LVL_ERROR, "Cannot allocate write buffer."); … … 336 336 * 337 337 */ 338 static void ahci_identify_device_cmd(sata_dev_t *sata, void *phys)338 static void ahci_identify_device_cmd(sata_dev_t *sata, uintptr_t phys) 339 339 { 340 340 volatile sata_std_command_frame_t *cmd = … … 381 381 * 382 382 */ 383 static void ahci_identify_packet_device_cmd(sata_dev_t *sata, void *phys)383 static void ahci_identify_packet_device_cmd(sata_dev_t *sata, uintptr_t phys) 384 384 { 385 385 volatile sata_std_command_frame_t *cmd = … … 435 435 } 436 436 437 void *phys;437 uintptr_t phys; 438 438 sata_identify_data_t *idata; 439 439 int rc = dmamem_map_anonymous(SATA_IDENTIFY_DEVICE_BUFFER_LENGTH, 440 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, (void **) &idata); 440 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys, 441 (void **) &idata); 441 442 if (rc != EOK) { 442 443 ddf_msg(LVL_ERROR, "Cannot allocate buffer to identify device."); … … 561 562 * 562 563 */ 563 static void ahci_set_mode_cmd(sata_dev_t *sata, void*phys, uint8_t mode)564 static void ahci_set_mode_cmd(sata_dev_t *sata, uintptr_t phys, uint8_t mode) 564 565 { 565 566 volatile sata_std_command_frame_t *cmd = … … 567 568 568 569 cmd->fis_type = SATA_CMD_FIS_TYPE; 569 cmd->c = SATA_CMD_FIS_COMMAND_INDICATOR; 570 cmd->c = SATA_CMD_FIS_COMMAND_INDICATOR; 570 571 cmd->command = 0xef; 571 572 cmd->features = 0x03; … … 628 629 } 629 630 630 void *phys;631 uintptr_t phys; 631 632 sata_identify_data_t *idata; 632 633 int rc = dmamem_map_anonymous(SATA_SET_FEATURE_BUFFER_LENGTH, 633 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, (void **) &idata); 634 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys, 635 (void **) &idata); 634 636 if (rc != EOK) { 635 637 ddf_msg(LVL_ERROR, "Cannot allocate buffer for device set mode."); … … 677 679 * 678 680 */ 679 static void ahci_rb_fpdma_cmd(sata_dev_t *sata, void *phys, uint64_t blocknum) 681 static void ahci_rb_fpdma_cmd(sata_dev_t *sata, uintptr_t phys, 682 uint64_t blocknum) 680 683 { 681 684 volatile sata_ncq_command_frame_t *cmd = … … 734 737 * 735 738 */ 736 static int ahci_rb_fpdma(sata_dev_t *sata, void *phys, uint64_t blocknum)739 static int ahci_rb_fpdma(sata_dev_t *sata, uintptr_t phys, uint64_t blocknum) 737 740 { 738 741 if (sata->is_invalid_device) { … … 763 766 * 764 767 */ 765 static void ahci_wb_fpdma_cmd(sata_dev_t *sata, void *phys, uint64_t blocknum) 768 static void ahci_wb_fpdma_cmd(sata_dev_t *sata, uintptr_t phys, 769 uint64_t blocknum) 766 770 { 767 771 volatile sata_ncq_command_frame_t *cmd = … … 821 825 * 822 826 */ 823 static int ahci_wb_fpdma(sata_dev_t *sata, void *phys, uint64_t blocknum)827 static int ahci_wb_fpdma(sata_dev_t *sata, uintptr_t phys, uint64_t blocknum) 824 828 { 825 829 if (sata->is_invalid_device) { … … 933 937 { 934 938 size_t size = 4096; 935 void *phys = NULL;939 uintptr_t phys = 0; 936 940 void *virt_fb = NULL; 937 941 void *virt_cmd = NULL; … … 949 953 950 954 /* Allocate and init retfis structure. */ 951 int rc = dmamem_map_anonymous(size, AS_AREA_READ | AS_AREA_WRITE, 0,952 &phys, &virt_fb);955 int rc = dmamem_map_anonymous(size, DMAMEM_4GiB, 956 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &virt_fb); 953 957 if (rc != EOK) 954 958 goto error_retfis; … … 959 963 960 964 /* Allocate and init command header structure. */ 961 rc = dmamem_map_anonymous(size, AS_AREA_READ | AS_AREA_WRITE, 0,962 &phys, &virt_cmd);965 rc = dmamem_map_anonymous(size, DMAMEM_4GiB, 966 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &virt_cmd); 963 967 if (rc != EOK) 964 968 goto error_cmd; … … 970 974 971 975 /* Allocate and init command table structure. */ 972 rc = dmamem_map_anonymous(size, AS_AREA_READ | AS_AREA_WRITE, 0,973 &phys, &virt_table);976 rc = dmamem_map_anonymous(size, DMAMEM_4GiB, 977 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &virt_table); 974 978 if (rc != EOK) 975 979 goto error_table; … … 1153 1157 ahci->memregs = NULL; 1154 1158 1155 physmem_map( (void *) (size_t) (hw_res_parsed.mem_ranges.ranges[0].address),1159 physmem_map(RNGABS(hw_res_parsed.mem_ranges.ranges[0]), 1156 1160 AHCI_MEMREGS_PAGES_COUNT, AS_AREA_READ | AS_AREA_WRITE, 1157 1161 (void **) &ahci->memregs); … … 1160 1164 1161 1165 /* Register interrupt handler */ 1162 ahci_ranges[0].base = (size_t) hw_res_parsed.mem_ranges.ranges[0].address;1166 ahci_ranges[0].base = RNGABS(hw_res_parsed.mem_ranges.ranges[0]); 1163 1167 ahci_ranges[0].size = sizeof(ahci_memregs_t); 1164 1168 … … 1167 1171 1168 1172 ahci_cmds[base].addr = 1169 ((uint32_t *) (size_t) hw_res_parsed.mem_ranges.ranges[0].address) +1173 ((uint32_t *) RNGABSPTR(hw_res_parsed.mem_ranges.ranges[0])) + 1170 1174 AHCI_PORTS_REGISTERS_OFFSET + port * AHCI_PORT_REGISTERS_SIZE + 1171 1175 AHCI_PORT_IS_REGISTER_OFFSET; … … 1173 1177 1174 1178 ahci_cmds[base + 3].addr = 1175 ((uint32_t *) (size_t) hw_res_parsed.mem_ranges.ranges[0].address) +1179 ((uint32_t *) RNGABSPTR(hw_res_parsed.mem_ranges.ranges[0])) + 1176 1180 AHCI_GHC_IS_REGISTER_OFFSET; 1177 1181 ahci_cmds[base + 4].addr = ahci_cmds[base + 3].addr; -
uspace/drv/block/ata_bd/ata_bd.c
r820104d rc2a6983 1132 1132 cnt = 100; 1133 1133 while ((status & ~n_reset) != 0 || (status & set) != set) { 1134 async_usleep(1);1135 1134 --cnt; 1136 1135 if (cnt <= 0) break; -
uspace/drv/block/ata_bd/main.c
r820104d rc2a6983 84 84 } 85 85 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)) { 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)) { 90 92 rc = EINVAL; 91 93 goto error; 92 94 } 93 95 94 if ( hw_res.io_ranges.ranges[1].size< sizeof(ata_cmd_t)) {96 if (RNGSZ(*cmd_rng) < sizeof(ata_cmd_t)) { 95 97 rc = EINVAL; 96 98 goto error; -
uspace/drv/bus/isa/i8237.c
r820104d rc2a6983 38 38 #include <stdbool.h> 39 39 #include <errno.h> 40 #include <ddi.h> 41 #include <ddf/log.h> 40 42 #include <fibril_synch.h> 41 43 #include <ddi.h> … … 198 200 .channels = { 199 201 /* The first chip 8-bit */ 200 { 201 (uint8_t *) 0x00,202 (uint8_t *) 0x01,203 (uint8_t *) 0x87,204 (uint8_t *) 0x0a,205 (uint8_t *) 0x0b,206 (uint8_t *) 0x0c,207 }, 208 { 209 (uint8_t *) 0x02,210 (uint8_t *) 0x03,211 (uint8_t *) 0x83,212 (uint8_t *) 0x0a,213 (uint8_t *) 0x0b,214 (uint8_t *) 0x0c,215 }, 216 { 217 (uint8_t *) 0x04,218 (uint8_t *) 0x05,219 (uint8_t *) 0x81,220 (uint8_t *) 0x0a,221 (uint8_t *) 0x0b,222 (uint8_t *) 0x0c,223 }, 224 { 225 (uint8_t *) 0x06,226 (uint8_t *) 0x07,227 (uint8_t *) 0x82,228 (uint8_t *) 0x0a,229 (uint8_t *) 0x0b,230 (uint8_t *) 0x0c,202 { /* Channel 0 - Unusable*/ 203 .offset_reg_address = (uint8_t *) 0x00, 204 .size_reg_address = (uint8_t *) 0x01, 205 .page_reg_address = (uint8_t *) 0x87, 206 .single_mask_address = (uint8_t *) 0x0a, 207 .mode_address = (uint8_t *) 0x0b, 208 .flip_flop_address = (uint8_t *) 0x0c, 209 }, 210 { /* Channel 1 */ 211 .offset_reg_address = (uint8_t *) 0x02, 212 .size_reg_address = (uint8_t *) 0x03, 213 .page_reg_address = (uint8_t *) 0x83, 214 .single_mask_address = (uint8_t *) 0x0a, 215 .mode_address = (uint8_t *) 0x0b, 216 .flip_flop_address = (uint8_t *) 0x0c, 217 }, 218 { /* Channel 2 */ 219 .offset_reg_address = (uint8_t *) 0x04, 220 .size_reg_address = (uint8_t *) 0x05, 221 .page_reg_address = (uint8_t *) 0x81, 222 .single_mask_address = (uint8_t *) 0x0a, 223 .mode_address = (uint8_t *) 0x0b, 224 .flip_flop_address = (uint8_t *) 0x0c, 225 }, 226 { /* Channel 3 */ 227 .offset_reg_address = (uint8_t *) 0x06, 228 .size_reg_address = (uint8_t *) 0x07, 229 .page_reg_address = (uint8_t *) 0x82, 230 .single_mask_address = (uint8_t *) 0x0a, 231 .mode_address = (uint8_t *) 0x0b, 232 .flip_flop_address = (uint8_t *) 0x0c, 231 233 }, 232 234 233 235 /* The second chip 16-bit */ 234 { 235 (uint8_t *) 0xc0,236 (uint8_t *) 0xc2,237 (uint8_t *) 0x8f,238 (uint8_t *) 0xd4,239 (uint8_t *) 0xd6,240 (uint8_t *) 0xd8,241 }, 242 { 243 (uint8_t *) 0xc4,244 (uint8_t *) 0xc6,245 (uint8_t *) 0x8b,246 (uint8_t *) 0xd4,247 (uint8_t *) 0xd6,248 (uint8_t *) 0xd8,249 }, 250 { 251 (uint8_t *) 0xc8,252 (uint8_t *) 0xca,253 (uint8_t *) 0x89,254 (uint8_t *) 0xd4,255 (uint8_t *) 0xd6,256 (uint8_t *) 0xd8,257 }, 258 { 259 (uint8_t *) 0xcc,260 (uint8_t *) 0xce,261 (uint8_t *) 0x8a,262 (uint8_t *) 0xd4,263 (uint8_t *) 0xd6,264 (uint8_t *) 0xd8,236 { /* Channel 4 - Unusable */ 237 .offset_reg_address = (uint8_t *) 0xc0, 238 .size_reg_address = (uint8_t *) 0xc2, 239 .page_reg_address = (uint8_t *) 0x8f, 240 .single_mask_address = (uint8_t *) 0xd4, 241 .mode_address = (uint8_t *) 0xd6, 242 .flip_flop_address = (uint8_t *) 0xd8, 243 }, 244 { /* Channel 5 */ 245 .offset_reg_address = (uint8_t *) 0xc4, 246 .size_reg_address = (uint8_t *) 0xc6, 247 .page_reg_address = (uint8_t *) 0x8b, 248 .single_mask_address = (uint8_t *) 0xd4, 249 .mode_address = (uint8_t *) 0xd6, 250 .flip_flop_address = (uint8_t *) 0xd8, 251 }, 252 { /* Channel 6 */ 253 .offset_reg_address = (uint8_t *) 0xc8, 254 .size_reg_address = (uint8_t *) 0xca, 255 .page_reg_address = (uint8_t *) 0x89, 256 .single_mask_address = (uint8_t *) 0xd4, 257 .mode_address = (uint8_t *) 0xd6, 258 .flip_flop_address = (uint8_t *) 0xd8, 259 }, 260 { /* Channel 7 */ 261 .offset_reg_address = (uint8_t *) 0xcc, 262 .size_reg_address = (uint8_t *) 0xce, 263 .page_reg_address = (uint8_t *) 0x8a, 264 .single_mask_address = (uint8_t *) 0xd4, 265 .mode_address = (uint8_t *) 0xd6, 266 .flip_flop_address = (uint8_t *) 0xd8, 265 267 }, 266 268 }, … … 272 274 }; 273 275 274 /* Initialize I/O access to DMA controller I/O ports.276 /** Initialize I/O access to DMA controller I/O ports. 275 277 * 276 278 * @param controller DMA Controller structure to initialize. … … 304 306 305 307 return EOK; 308 } 309 310 /** Helper function. Channels 4,5,6, and 7 are 8 bit DMA. 311 * @pram channel DMA channel. 312 * @reutrn True, if channel is 4,5,6, or 7, false otherwise. 313 */ 314 static inline bool is_dma16(unsigned channel) 315 { 316 return (channel >= 4) && (channel < 8); 317 } 318 319 /** Helper function. Channels 0,1,2, and 3 are 8 bit DMA. 320 * @pram channel DMA channel. 321 * @reutrn True, if channel is 0,1,2, or 3, false otherwise. 322 */ 323 static inline bool is_dma8(unsigned channel) 324 { 325 return (channel < 4); 306 326 } 307 327 … … 320 340 * 321 341 * @return Error code. 322 * 323 */ 324 int dma_setup_channel(unsigned int channel, uint32_t pa, uint16_t size, 342 */ 343 int dma_channel_setup(unsigned int channel, uint32_t pa, uint32_t size, 325 344 uint8_t mode) 326 345 { 346 if (!is_dma8(channel) && !is_dma16(channel)) 347 return ENOENT; 348 327 349 if ((channel == 0) || (channel == 4)) 328 350 return ENOTSUP; 329 330 if (channel > 7)331 return ENOENT;332 351 333 352 /* DMA is limited to 24bit addresses. */ … … 336 355 337 356 /* 8 bit channels use only 4 bits from the page register. */ 338 if ((channel > 0) && (channel < 4) && (pa >= (1 << 20))) 357 if (is_dma8(channel) && (pa >= (1 << 20))) 358 return EINVAL; 359 360 /* Buffers cannot cross 64K page boundaries */ 361 if ((pa & 0xffff0000) != ((pa + size - 1) & 0xffff0000)) 339 362 return EINVAL; 340 363 … … 352 375 ddf_msg(LVL_DEBUG, "Unspoiled address %#" PRIx32 " (size %" PRIu16 ")", 353 376 pa, size); 354 if ( channel > 4) {377 if (is_dma16(channel)) { 355 378 /* Size must be aligned to 16 bits */ 356 379 if ((size & 1) != 0) { … … 358 381 return EINVAL; 359 382 } 360 383 /* Size is in 2byte words */ 361 384 size >>= 1; 362 363 385 /* Address is fun: lower 16 bits need to be shifted by 1 */ 364 386 pa = ((pa & 0xffff) >> 1) | (pa & 0xff0000); … … 426 448 } 427 449 450 /** Query remaining buffer size. 451 * 452 * @param channel DMA Channel 1, 2, 3 for 8 bit transfers, 453 * 5, 6, 7 for 16 bit. 454 * @param size Place to store number of bytes pending in the assigned buffer. 455 * 456 * @return Error code. 457 */ 458 int dma_channel_remain(unsigned channel, size_t *size) 459 { 460 assert(size); 461 if (!is_dma8(channel) && !is_dma16(channel)) 462 return ENOENT; 463 464 if ((channel == 0) || (channel == 4)) 465 return ENOTSUP; 466 467 fibril_mutex_lock(&guard); 468 if (!controller_8237.initialized) { 469 fibril_mutex_unlock(&guard); 470 return EIO; 471 } 472 473 const dma_channel_t dma_channel = controller_8237.channels[channel]; 474 /* Get size - reset flip-flop */ 475 pio_write_8(dma_channel.flip_flop_address, 0); 476 477 /* Low byte */ 478 const uint8_t value_low = pio_read_8(dma_channel.size_reg_address); 479 ddf_msg(LVL_DEBUG2, "Read size low byte: %p:%x.", 480 dma_channel.size_reg_address, value_low); 481 482 /* High byte */ 483 const uint8_t value_high = pio_read_8(dma_channel.size_reg_address); 484 ddf_msg(LVL_DEBUG2, "Read size high byte: %p:%x.", 485 dma_channel.size_reg_address, value_high); 486 fibril_mutex_unlock(&guard); 487 488 uint16_t remain = (value_high << 8 | value_low) ; 489 /* 16 bit DMA size is in words, 490 * the upper bits are bogus for 16bit transfers so we need to get 491 * rid of them. Using limited type works well.*/ 492 if (is_dma16(channel)) 493 remain <<= 1; 494 *size = is_dma16(channel) ? remain + 2: remain + 1; 495 return EOK; 496 } 428 497 /** 429 498 * @} -
uspace/drv/bus/isa/i8237.h
r820104d rc2a6983 38 38 #define DRV_BUS_ISA_I8237_H 39 39 40 extern int dma_setup_channel(unsigned int, uint32_t, uint16_t, uint8_t); 40 extern int dma_channel_setup(unsigned, uint32_t, uint32_t, uint8_t); 41 extern int dma_channel_remain(unsigned, size_t *); 41 42 42 43 #endif -
uspace/drv/bus/isa/isa.c
r820104d rc2a6983 65 65 #include <ddf/log.h> 66 66 #include <ops/hw_res.h> 67 #include <ops/pio_window.h> 67 68 68 69 #include <device/hw_res.h> 70 #include <device/pio_window.h> 69 71 70 72 #include "i8237.h" … … 79 81 ddf_dev_t *dev; 80 82 ddf_fun_t *fctl; 83 pio_window_t pio_win; 81 84 list_t functions; 82 85 } isa_bus_t; … … 85 88 fibril_mutex_t mutex; 86 89 ddf_fun_t *fnode; 90 hw_resource_t resources[ISA_MAX_HW_RES]; 87 91 hw_resource_list_t hw_resources; 88 92 link_t bus_link; … … 101 105 } 102 106 103 static hw_resource_list_t *isa_ get_fun_resources(ddf_fun_t *fnode)107 static hw_resource_list_t *isa_fun_get_resources(ddf_fun_t *fnode) 104 108 { 105 109 isa_fun_t *fun = isa_fun(fnode); 106 assert(fun != NULL);110 assert(fun); 107 111 108 112 return &fun->hw_resources; 109 113 } 110 114 111 static bool isa_ enable_fun_interrupt(ddf_fun_t *fnode)115 static bool isa_fun_enable_interrupt(ddf_fun_t *fnode) 112 116 { 113 117 /* This is an old ugly way, copied from pci driver */ 114 118 assert(fnode); 115 119 isa_fun_t *fun = isa_fun(fnode); 120 assert(fun); 116 121 117 122 sysarg_t apic; … … 151 156 } 152 157 153 static int isa_ dma_channel_fun_setup(ddf_fun_t *fnode,154 unsigned int channel, uint32_t pa, uint 16_t size, uint8_t mode)158 static int isa_fun_setup_dma(ddf_fun_t *fnode, 159 unsigned int channel, uint32_t pa, uint32_t size, uint8_t mode) 155 160 { 156 161 assert(fnode); 157 162 isa_fun_t *fun = isa_fun(fnode); 163 assert(fun); 158 164 const hw_resource_list_t *res = &fun->hw_resources; 159 165 assert(res); 160 161 const unsigned int ch = channel; 166 162 167 for (size_t i = 0; i < res->count; ++i) { 168 /* Check for assigned channel */ 163 169 if (((res->resources[i].type == DMA_CHANNEL_16) && 164 (res->resources[i].res.dma_channel.dma16 == ch )) ||170 (res->resources[i].res.dma_channel.dma16 == channel)) || 165 171 ((res->resources[i].type == DMA_CHANNEL_8) && 166 (res->resources[i].res.dma_channel.dma8 == ch ))) {167 return dma_ setup_channel(channel, pa, size, mode);168 } 169 } 170 172 (res->resources[i].res.dma_channel.dma8 == channel))) { 173 return dma_channel_setup(channel, pa, size, mode); 174 } 175 } 176 171 177 return EINVAL; 172 178 } 173 179 180 static int isa_fun_remain_dma(ddf_fun_t *fnode, 181 unsigned channel, size_t *size) 182 { 183 assert(size); 184 assert(fnode); 185 isa_fun_t *fun = isa_fun(fnode); 186 assert(fun); 187 const hw_resource_list_t *res = &fun->hw_resources; 188 assert(res); 189 190 for (size_t i = 0; i < res->count; ++i) { 191 /* Check for assigned channel */ 192 if (((res->resources[i].type == DMA_CHANNEL_16) && 193 (res->resources[i].res.dma_channel.dma16 == channel)) || 194 ((res->resources[i].type == DMA_CHANNEL_8) && 195 (res->resources[i].res.dma_channel.dma8 == channel))) { 196 return dma_channel_remain(channel, size); 197 } 198 } 199 200 return EINVAL; 201 } 202 174 203 static hw_res_ops_t isa_fun_hw_res_ops = { 175 .get_resource_list = isa_get_fun_resources, 176 .enable_interrupt = isa_enable_fun_interrupt, 177 .dma_channel_setup = isa_dma_channel_fun_setup, 204 .get_resource_list = isa_fun_get_resources, 205 .enable_interrupt = isa_fun_enable_interrupt, 206 .dma_channel_setup = isa_fun_setup_dma, 207 .dma_channel_remain = isa_fun_remain_dma, 178 208 }; 179 209 180 static ddf_dev_ops_t isa_fun_ops; 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_window 221 }; 222 223 static ddf_dev_ops_t isa_fun_ops= { 224 .interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops, 225 .interfaces[PIO_WINDOW_DEV_IFACE] = &isa_fun_pio_window_ops, 226 }; 181 227 182 228 static int isa_dev_add(ddf_dev_t *dev); … … 212 258 213 259 fibril_mutex_initialize(&fun->mutex); 260 fun->hw_resources.resources = fun->resources; 261 214 262 fun->fnode = fnode; 215 263 return fun; … … 270 318 { 271 319 char *line = str; 320 *next = NULL; 272 321 273 322 if (str == NULL) { 274 *next = NULL;275 323 return NULL; 276 324 } … … 282 330 if (*str != '\0') { 283 331 *next = str + 1; 284 } else {285 *next = NULL;286 332 } 287 333 … … 310 356 /* Get the name part of the rest of the line. */ 311 357 strtok(line, ":"); 312 313 /* Allocate output buffer. */ 314 size_t size = str_size(line) + 1; 315 char *name = malloc(size); 316 317 if (name != NULL) { 318 /* Copy the result to the output buffer. */ 319 str_cpy(name, size, line); 320 } 321 322 return name; 323 } 324 325 static inline char *skip_spaces(char *line) 358 return line; 359 } 360 361 static inline const char *skip_spaces(const char *line) 326 362 { 327 363 /* Skip leading spaces. */ … … 332 368 } 333 369 334 static void isa_fun_ set_irq(isa_fun_t *fun, int irq)370 static void isa_fun_add_irq(isa_fun_t *fun, int irq) 335 371 { 336 372 size_t count = fun->hw_resources.count; … … 348 384 } 349 385 350 static void isa_fun_ set_dma(isa_fun_t *fun, int dma)386 static void isa_fun_add_dma(isa_fun_t *fun, int dma) 351 387 { 352 388 size_t count = fun->hw_resources.count; … … 381 417 } 382 418 383 static void isa_fun_ set_io_range(isa_fun_t *fun, size_t addr, size_t len)419 static void isa_fun_add_io_range(isa_fun_t *fun, size_t addr, size_t len) 384 420 { 385 421 size_t count = fun->hw_resources.count; 386 422 hw_resource_t *resources = fun->hw_resources.resources; 423 424 isa_bus_t *isa = isa_bus(ddf_fun_get_dev(fun->fnode)); 387 425 388 426 if (count < ISA_MAX_HW_RES) { 389 427 resources[count].type = IO_RANGE; 390 428 resources[count].res.io_range.address = addr; 429 resources[count].res.io_range.address += isa->pio_win.io.base; 391 430 resources[count].res.io_range.size = len; 431 resources[count].res.io_range.relative = false; 392 432 resources[count].res.io_range.endianness = LITTLE_ENDIAN; 393 433 … … 400 440 } 401 441 402 static void fun_parse_irq(isa_fun_t *fun, c har *val)442 static void fun_parse_irq(isa_fun_t *fun, const char *val) 403 443 { 404 444 int irq = 0; … … 409 449 410 450 if (val != end) 411 isa_fun_set_irq(fun, irq); 412 } 413 414 static void fun_parse_dma(isa_fun_t *fun, char *val) 415 { 416 unsigned int dma = 0; 451 isa_fun_add_irq(fun, irq); 452 } 453 454 static void fun_parse_dma(isa_fun_t *fun, const char *val) 455 { 417 456 char *end = NULL; 418 457 419 458 val = skip_spaces(val); 420 dma = (unsigned int)strtol(val, &end, 10);459 const int dma = strtol(val, &end, 10); 421 460 422 461 if (val != end) 423 isa_fun_ set_dma(fun, dma);424 } 425 426 static void fun_parse_io_range(isa_fun_t *fun, c har *val)462 isa_fun_add_dma(fun, dma); 463 } 464 465 static void fun_parse_io_range(isa_fun_t *fun, const char *val) 427 466 { 428 467 size_t addr, len; … … 441 480 return; 442 481 443 isa_fun_ set_io_range(fun, addr, len);444 } 445 446 static void get_match_id(char **id, c har *val)447 { 448 c har *end = val;482 isa_fun_add_io_range(fun, addr, len); 483 } 484 485 static void get_match_id(char **id, const char *val) 486 { 487 const char *end = val; 449 488 450 489 while (!isspace(*end)) … … 456 495 } 457 496 458 static void fun_parse_match_id(isa_fun_t *fun, c har *val)497 static void fun_parse_match_id(isa_fun_t *fun, const char *val) 459 498 { 460 499 char *id = NULL; 461 int score = 0;462 500 char *end = NULL; 463 int rc;464 501 465 502 val = skip_spaces(val); 466 503 467 score = (int)strtol(val, &end, 10);504 int score = (int)strtol(val, &end, 10); 468 505 if (val == end) { 469 506 ddf_msg(LVL_ERROR, "Cannot read match score for function " … … 483 520 "function %s", id, score, ddf_fun_get_name(fun->fnode)); 484 521 485 rc = ddf_fun_add_match_id(fun->fnode, id, score);522 int rc = ddf_fun_add_match_id(fun->fnode, id, score); 486 523 if (rc != EOK) { 487 524 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", … … 492 529 } 493 530 494 static bool prop_parse(isa_fun_t *fun, c har *line, const char *prop,495 void (*read_fn)(isa_fun_t *, c har *))531 static bool prop_parse(isa_fun_t *fun, const char *line, const char *prop, 532 void (*read_fn)(isa_fun_t *, const char *)) 496 533 { 497 534 size_t proplen = str_size(prop); … … 508 545 } 509 546 510 static void fun_prop_parse(isa_fun_t *fun, c har *line)547 static void fun_prop_parse(isa_fun_t *fun, const char *line) 511 548 { 512 549 /* Skip leading spaces. */ … … 523 560 } 524 561 525 static void fun_hw_res_alloc(isa_fun_t *fun)526 {527 fun->hw_resources.resources =528 (hw_resource_t *) malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES);529 }530 531 static void fun_hw_res_free(isa_fun_t *fun)532 {533 free(fun->hw_resources.resources);534 fun->hw_resources.resources = NULL;535 }536 537 562 static char *isa_fun_read_info(char *fun_conf, isa_bus_t *isa) 538 563 { 539 564 char *line; 540 char *fun_name = NULL;541 565 542 566 /* Skip empty lines. */ 543 while (true){567 do { 544 568 line = str_get_line(fun_conf, &fun_conf); 545 569 … … 549 573 } 550 574 551 if (!line_empty(line)) 552 break; 553 } 575 } while (line_empty(line)); 554 576 555 577 /* Get device name. */ 556 fun_name = get_device_name(line);578 const char *fun_name = get_device_name(line); 557 579 if (fun_name == NULL) 558 580 return NULL; 559 581 560 582 isa_fun_t *fun = isa_fun_create(isa, fun_name); 561 free(fun_name);562 583 if (fun == NULL) { 563 584 return NULL; 564 585 } 565 566 /* Allocate buffer for the list of hardware resources of the device. */567 fun_hw_res_alloc(fun);568 586 569 587 /* Get properties of the device (match ids, irq and io range). */ … … 596 614 } 597 615 598 static void fun_conf_parse(char *conf, isa_bus_t *isa) 599 { 616 static void isa_functions_add(isa_bus_t *isa) 617 { 618 char *conf = fun_conf_read(CHILD_FUN_CONF_PATH); 600 619 while (conf != NULL && *conf != '\0') { 601 620 conf = isa_fun_read_info(conf, isa); 602 621 } 603 } 604 605 static void isa_functions_add(isa_bus_t *isa) 606 { 607 char *fun_conf; 608 609 fun_conf = fun_conf_read(CHILD_FUN_CONF_PATH); 610 if (fun_conf != NULL) { 611 fun_conf_parse(fun_conf, isa); 612 free(fun_conf); 613 } 622 free(conf); 614 623 } 615 624 616 625 static int isa_dev_add(ddf_dev_t *dev) 617 626 { 618 isa_bus_t *isa; 627 async_sess_t *sess; 628 int rc; 619 629 620 630 ddf_msg(LVL_DEBUG, "isa_dev_add, device handle = %d", 621 631 (int) ddf_dev_get_handle(dev)); 622 632 623 isa = ddf_dev_data_alloc(dev, sizeof(isa_bus_t));633 isa_bus_t *isa = ddf_dev_data_alloc(dev, sizeof(isa_bus_t)); 624 634 if (isa == NULL) 625 635 return ENOMEM; … … 628 638 isa->dev = dev; 629 639 list_initialize(&isa->functions); 640 641 sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE); 642 if (sess == NULL) { 643 ddf_msg(LVL_ERROR, "isa_dev_add failed to connect to the " 644 "parent driver."); 645 return ENOENT; 646 } 647 648 rc = pio_window_get(sess, &isa->pio_win); 649 if (rc != EOK) { 650 ddf_msg(LVL_ERROR, "isa_dev_add failed to get PIO window " 651 "for the device."); 652 return rc; 653 } 630 654 631 655 /* Make the bus device more visible. Does not do anything. */ … … 658 682 { 659 683 isa_bus_t *isa = isa_bus(dev); 660 int rc;661 684 662 685 fibril_mutex_lock(&isa->mutex); … … 666 689 isa_fun_t, bus_link); 667 690 668 rc = ddf_fun_offline(fun->fnode);691 int rc = ddf_fun_offline(fun->fnode); 669 692 if (rc != EOK) { 670 693 fibril_mutex_unlock(&isa->mutex); … … 682 705 list_remove(&fun->bus_link); 683 706 684 fun_hw_res_free(fun);685 707 ddf_fun_destroy(fun->fnode); 686 708 } … … 709 731 } 710 732 711 712 static void isa_init() 713 { 733 int main(int argc, char *argv[]) 734 { 735 printf(NAME ": HelenOS ISA bus driver\n"); 714 736 ddf_log_init(NAME); 715 isa_fun_ops.interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops;716 }717 718 int main(int argc, char *argv[])719 {720 printf(NAME ": HelenOS ISA bus driver\n");721 isa_init();722 737 return ddf_driver_main(&isa_driver); 723 738 } -
uspace/drv/bus/pci/pciintel/pci.c
r820104d rc2a6983 57 57 #include <ops/hw_res.h> 58 58 #include <device/hw_res.h> 59 #include <ops/pio_window.h> 60 #include <device/pio_window.h> 59 61 #include <ddi.h> 60 62 #include <pci_dev_iface.h> … … 141 143 } 142 144 145 static pio_window_t *pciintel_get_pio_window(ddf_fun_t *fnode) 146 { 147 pci_fun_t *fun = pci_fun(fnode); 148 149 if (fun == NULL) 150 return NULL; 151 return &fun->pio_window; 152 } 153 154 143 155 static int pci_config_space_write_32(ddf_fun_t *fun, uint32_t address, 144 156 uint32_t data) … … 198 210 .get_resource_list = &pciintel_get_resources, 199 211 .enable_interrupt = &pciintel_enable_interrupt, 212 }; 213 214 static pio_window_ops_t pciintel_pio_window_ops = { 215 .get_pio_window = &pciintel_get_pio_window 200 216 }; 201 217 … … 211 227 static ddf_dev_ops_t pci_fun_ops = { 212 228 .interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops, 229 .interfaces[PIO_WINDOW_DEV_IFACE] = &pciintel_pio_window_ops, 213 230 .interfaces[PCI_DEV_IFACE] = &pci_dev_ops 214 231 }; … … 233 250 static void pci_conf_read(pci_fun_t *fun, int reg, uint8_t *buf, size_t len) 234 251 { 252 const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 235 253 pci_bus_t *bus = pci_bus_from_fun(fun); 254 uint32_t val; 236 255 237 256 fibril_mutex_lock(&bus->conf_mutex); 238 239 const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 240 void *addr = bus->conf_data_port + (reg & 3); 241 242 pio_write_32(bus->conf_addr_port, host2uint32_t_le(conf_addr)); 243 257 258 pio_write_32(bus->conf_addr_reg, host2uint32_t_le(conf_addr)); 259 260 /* 261 * Always read full 32-bits from the PCI conf_data_port register and 262 * get the desired portion of it afterwards. Some architectures do not 263 * support shorter PIO reads offset from this register. 264 */ 265 val = uint32_t_le2host(pio_read_32(bus->conf_data_reg)); 266 244 267 switch (len) { 245 268 case 1: 246 /* No endianness change for 1 byte */ 247 buf[0] = pio_read_8(addr); 269 *buf = (uint8_t) (val >> ((reg & 3) * 8)); 248 270 break; 249 271 case 2: 250 ((uint16_t *) buf)[0] = uint16_t_le2host(pio_read_16(addr));272 *((uint16_t *) buf) = (uint16_t) (val >> ((reg & 3)) * 8); 251 273 break; 252 274 case 4: 253 ((uint32_t *) buf)[0] = uint32_t_le2host(pio_read_32(addr));275 *((uint32_t *) buf) = (uint32_t) val; 254 276 break; 255 277 } … … 260 282 static void pci_conf_write(pci_fun_t *fun, int reg, uint8_t *buf, size_t len) 261 283 { 284 const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 262 285 pci_bus_t *bus = pci_bus_from_fun(fun); 286 uint32_t val; 263 287 264 288 fibril_mutex_lock(&bus->conf_mutex); 265 266 const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 267 void *addr = bus->conf_data_port + (reg & 3); 268 269 pio_write_32(bus->conf_addr_port, host2uint32_t_le(conf_addr)); 289 290 /* 291 * Prepare to write full 32-bits to the PCI conf_data_port register. 292 * Some architectures do not support shorter PIO writes offset from this 293 * register. 294 */ 295 296 if (len < 4) { 297 /* 298 * We have fewer than full 32-bits, so we need to read the 299 * missing bits first. 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)); 303 } 270 304 271 305 switch (len) { 272 306 case 1: 273 /* No endianness change for 1 byte */274 pio_write_8(addr, buf[0]);307 val &= ~(0xffU << ((reg & 3) * 8)); 308 val |= *buf << ((reg & 3) * 8); 275 309 break; 276 310 case 2: 277 pio_write_16(addr, host2uint16_t_le(((uint16_t *) buf)[0])); 311 val &= ~(0xffffU << ((reg & 3) * 8)); 312 val |= *((uint16_t *) buf) << ((reg & 3) * 8); 278 313 break; 279 314 case 4: 280 pio_write_32(addr, host2uint32_t_le(((uint32_t *) buf)[0]));315 val = *((uint32_t *) buf); 281 316 break; 282 317 } 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)); 283 321 284 322 fibril_mutex_unlock(&bus->conf_mutex); … … 411 449 hw_resources[count].res.io_range.address = range_addr; 412 450 hw_resources[count].res.io_range.size = range_size; 451 hw_resources[count].res.io_range.relative = true; 413 452 hw_resources[count].res.io_range.endianness = LITTLE_ENDIAN; 414 453 } else { … … 416 455 hw_resources[count].res.mem_range.address = range_addr; 417 456 hw_resources[count].res.mem_range.size = range_size; 457 hw_resources[count].res.mem_range.relative = false; 418 458 hw_resources[count].res.mem_range.endianness = LITTLE_ENDIAN; 419 459 } … … 433 473 { 434 474 /* Value of the BAR */ 435 uint32_t val, mask; 475 uint32_t val; 476 uint32_t bar; 477 uint32_t mask; 478 436 479 /* IO space address */ 437 480 bool io; … … 471 514 /* Get the address mask. */ 472 515 pci_conf_write_32(fun, addr, 0xffffffff); 473 mask &= pci_conf_read_32(fun, addr); 474 516 bar = pci_conf_read_32(fun, addr); 517 518 /* 519 * Unimplemented BARs read back as all 0's. 520 */ 521 if (!bar) 522 return addr + (addrw64 ? 8 : 4); 523 524 mask &= bar; 525 475 526 /* Restore the original value. */ 476 527 pci_conf_write_32(fun, addr, val); … … 520 571 { 521 572 uint8_t irq = pci_conf_read_8(fun, PCI_BRIDGE_INT_LINE); 522 if (irq != 0xff) 573 uint8_t pin = pci_conf_read_8(fun, PCI_BRIDGE_INT_PIN); 574 575 if (pin != 0 && irq != 0xff) 523 576 pci_add_interrupt(fun, irq); 524 577 } … … 583 636 pci_read_bars(fun); 584 637 pci_read_interrupt(fun); 638 639 /* Propagate the PIO window to the function. */ 640 fun->pio_window = bus->pio_win; 585 641 586 642 ddf_fun_set_ops(fun->fnode, &pci_fun_ops); … … 613 669 static int pci_dev_add(ddf_dev_t *dnode) 614 670 { 671 hw_resource_list_t hw_resources; 615 672 pci_bus_t *bus = NULL; 616 673 ddf_fun_t *ctl = NULL; … … 638 695 goto fail; 639 696 } 640 641 hw_resource_list_t hw_resources; 697 698 rc = pio_window_get(sess, &bus->pio_win); 699 if (rc != EOK) { 700 ddf_msg(LVL_ERROR, "pci_dev_add failed to get PIO window " 701 "for the device."); 702 goto fail; 703 } 642 704 643 705 rc = hw_res_get_resource_list(sess, &hw_resources); … … 662 724 hw_resources.resources[1].res.io_range.address); 663 725 664 bus->conf_io_addr = 665 (uint32_t) hw_resources.resources[0].res.io_range.address; 666 bus->conf_io_data = 667 (uint32_t) hw_resources.resources[1].res.io_range.address; 668 669 if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 4, 670 &bus->conf_addr_port)) { 726 if (pio_enable_resource(&bus->pio_win, &hw_resources.resources[0], 727 (void **) &bus->conf_addr_reg)) { 671 728 ddf_msg(LVL_ERROR, "Failed to enable configuration ports."); 672 729 rc = EADDRNOTAVAIL; 673 730 goto fail; 674 731 } 675 if (pio_enable ((void *)(uintptr_t)bus->conf_io_data, 4,676 &bus->conf_data_port)) {732 if (pio_enable_resource(&bus->pio_win, &hw_resources.resources[1], 733 (void **) &bus->conf_data_reg)) { 677 734 ddf_msg(LVL_ERROR, "Failed to enable configuration ports."); 678 735 rc = EADDRNOTAVAIL; … … 729 786 { 730 787 ddf_log_init(NAME); 731 pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops;732 pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops;733 788 } 734 789 -
uspace/drv/bus/pci/pciintel/pci.h
r820104d rc2a6983 40 40 #include "pci_regs.h" 41 41 42 #define PCI_MAX_HW_RES 842 #define PCI_MAX_HW_RES 10 43 43 44 44 typedef struct pciintel_bus { 45 45 /** DDF device node */ 46 46 ddf_dev_t *dnode; 47 uint32_t conf_io_addr; 48 uint32_t conf_io_data; 49 void *conf_data_port; 50 void *conf_addr_port; 47 ioport32_t *conf_addr_reg; 48 ioport32_t *conf_data_reg; 49 pio_window_t pio_win; 51 50 fibril_mutex_t conf_mutex; 52 51 } pci_bus_t; … … 68 67 hw_resource_list_t hw_resources; 69 68 hw_resource_t resources[PCI_MAX_HW_RES]; 69 pio_window_t pio_window; 70 70 } pci_fun_t; 71 71 -
uspace/drv/bus/usb/ehci/main.c
r820104d rc2a6983 77 77 assert(device); 78 78 79 uintptr_t reg_base = 0; 80 size_t reg_size = 0; 79 addr_range_t reg_range; 81 80 int irq = 0; 82 81 83 int rc = get_my_registers(device, ®_ base, ®_size, &irq);82 int rc = get_my_registers(device, ®_range, &irq); 84 83 if (rc != EOK) { 85 84 usb_log_error("Failed to get memory addresses for %" PRIun … … 88 87 } 89 88 90 usb_log_info("Memory mapped regs at 0x%" PRIxn "(size %zu), IRQ %d.\n",91 reg_base, reg_size, irq);89 usb_log_info("Memory mapped regs at %p (size %zu), IRQ %d.\n", 90 RNGABSPTR(reg_range), RNGSZ(reg_range), irq); 92 91 93 rc = disable_legacy(device, reg_base, reg_size);92 rc = disable_legacy(device, ®_range); 94 93 if (rc != EOK) { 95 94 usb_log_error("Failed to disable legacy USB: %s.\n", -
uspace/drv/bus/usb/ehci/res.c
r820104d rc2a6983 71 71 * 72 72 * @param[in] dev Device asking for the addresses. 73 * @param[out] mem_reg_address Base address of the memory range. 74 * @param[out] mem_reg_size Size of the memory range. 73 * @param[out] mem_regs_p Pointer to the register range. 75 74 * @param[out] irq_no IRQ assigned to the device. 76 75 * @return Error code. 77 76 */ 78 77 int get_my_registers(ddf_dev_t *dev, 79 uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)78 addr_range_t *mem_regs_p, int *irq_no) 80 79 { 81 80 assert(dev); … … 99 98 } 100 99 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; 100 if (mem_regs_p) 101 *mem_regs_p = hw_res.mem_ranges.ranges[0]; 105 102 if (irq_no) 106 103 *irq_no = hw_res.irqs.irqs[0]; … … 267 264 } 268 265 269 int disable_legacy(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size)266 int disable_legacy(ddf_dev_t *device, addr_range_t *reg_range) 270 267 { 271 268 assert(device); … … 274 271 /* Map EHCI registers */ 275 272 void *regs = NULL; 276 int rc = pio_enable ((void*)reg_base, reg_size, ®s);273 int rc = pio_enable_range(reg_range, ®s); 277 274 if (rc != EOK) { 278 275 usb_log_error("Failed to map registers %p: %s.\n", 279 (void *) reg_base, str_error(rc));276 RNGABSPTR(*reg_range), str_error(rc)); 280 277 return rc; 281 278 } -
uspace/drv/bus/usb/ehci/res.h
r820104d rc2a6983 37 37 38 38 #include <ddf/driver.h> 39 #include <device/hw_res_parsed.h> 39 40 40 int get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);41 int get_my_registers(ddf_dev_t *, addr_range_t *, int *); 41 42 int enable_interrupts(ddf_dev_t *); 42 int disable_legacy(ddf_dev_t *, uintptr_t, size_t);43 int disable_legacy(ddf_dev_t *, addr_range_t *); 43 44 44 45 #endif -
uspace/drv/bus/usb/ohci/hc.c
r820104d rc2a6983 106 106 * @param[out] cmds Commands buffer. 107 107 * @param[in] cmds_size Size of the commands buffer (bytes). 108 * @param[in] regs Physical address of device's registers. 109 * @param[in] reg_size Size of the register area (bytes). 108 * @param[in] regs Device's register range. 110 109 * 111 110 * @return Error code. … … 113 112 int 114 113 hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[], 115 size_t cmds_size, uintptr_t regs, size_t reg_size)114 size_t cmds_size, addr_range_t *regs) 116 115 { 117 116 if ((ranges_size < sizeof(ohci_pio_ranges)) || 118 117 (cmds_size < sizeof(ohci_irq_commands)) || 119 ( reg_size< sizeof(ohci_regs_t)))118 (RNGSZ(*regs) < sizeof(ohci_regs_t))) 120 119 return EOVERFLOW; 121 120 122 121 memcpy(ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges)); 123 ranges[0].base = regs;122 ranges[0].base = RNGABS(*regs); 124 123 125 124 memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands)); 126 ohci_regs_t *registers = (ohci_regs_t *) regs;125 ohci_regs_t *registers = (ohci_regs_t *) RNGABSPTR(*regs); 127 126 cmds[0].addr = (void *) ®isters->interrupt_status; 128 127 cmds[3].addr = (void *) ®isters->interrupt_status; … … 135 134 * 136 135 * @param[in] device Host controller DDF device 137 * @param[in] reg_base Register range base 138 * @param[in] reg_size Register range size 136 * @param[in] regs Register range 139 137 * @param[in] irq Interrupt number 140 138 * @paran[in] handler Interrupt handler … … 142 140 * @return EOK on success or negative error code 143 141 */ 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)142 int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq, 143 interrupt_handler_t handler) 146 144 { 147 145 int rc; … … 158 156 159 157 rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds, 160 sizeof(irq_cmds), reg _base, reg_size);158 sizeof(irq_cmds), regs); 161 159 if (rc != EOK) { 162 160 usb_log_error("Failed to generate IRQ code: %s.\n", … … 259 257 * 260 258 * @param[in] instance Memory place for the structure. 261 * @param[in] regs Address of the memory mapped I/O registers. 262 * @param[in] reg_size Size of the memory mapped area. 259 * @param[in] regs Device's I/O registers range. 263 260 * @param[in] interrupts True if w interrupts should be used 264 261 * @return Error code 265 262 */ 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); 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); 272 268 if (rc != EOK) { 273 269 usb_log_error("Failed to gain access to device registers: %s.\n", -
uspace/drv/bus/usb/ohci/hc.h
r820104d rc2a6983 75 75 } hc_t; 76 76 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); 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); 80 81 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 81 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts);82 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts); 82 83 83 84 /** Safely dispose host controller internal structures -
uspace/drv/bus/usb/ohci/ohci.c
r820104d rc2a6983 177 177 ddf_fun_set_ops(instance->rh_fun, &rh_ops); 178 178 179 uintptr_t reg_base = 0; 180 size_t reg_size = 0; 179 addr_range_t regs; 181 180 int irq = 0; 182 181 183 rc = get_my_registers(device, ® _base, ®_size, &irq);182 rc = get_my_registers(device, ®s, &irq); 184 183 if (rc != EOK) { 185 184 usb_log_error("Failed to get register memory addresses " … … 190 189 191 190 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n", 192 (void *) reg_base, reg_size, irq);193 194 rc = hc_register_irq_handler(device, reg_base, reg_size, irq, irq_handler);191 RNGABSPTR(regs), RNGSZ(regs), irq); 192 193 rc = hc_register_irq_handler(device, ®s, irq, irq_handler); 195 194 if (rc != EOK) { 196 195 usb_log_error("Failed to register interrupt handler: %s.\n", … … 215 214 } 216 215 217 rc = hc_init(&instance->hc, reg_base, reg_size, interrupts);216 rc = hc_init(&instance->hc, ®s, interrupts); 218 217 if (rc != EOK) { 219 218 usb_log_error("Failed to init ohci_hcd: %s.\n", str_error(rc)); -
uspace/drv/bus/usb/ohci/res.c
r820104d rc2a6983 48 48 * 49 49 * @param[in] dev Device asking for the addresses. 50 * @param[out] mem_reg_address Base address of the memory range. 51 * @param[out] mem_reg_size Size of the memory range. 50 * @param[out] p_regs Pointer to register range. 52 51 * @param[out] irq_no IRQ assigned to the device. 53 52 * @return Error code. 54 53 */ 55 int get_my_registers(ddf_dev_t *dev, 56 uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no) 54 int get_my_registers(ddf_dev_t *dev, addr_range_t *p_regs, int *irq_no) 57 55 { 58 56 assert(dev); … … 66 64 hw_res_list_parsed_t hw_res; 67 65 hw_res_list_parsed_init(&hw_res); 68 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);66 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0); 69 67 async_hangup(parent_sess); 70 68 if (ret != EOK) { … … 78 76 } 79 77 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; 78 if (p_regs) 79 *p_regs = hw_res.mem_ranges.ranges[0]; 84 80 if (irq_no) 85 81 *irq_no = hw_res.irqs.irqs[0]; -
uspace/drv/bus/usb/ohci/res.h
r820104d rc2a6983 36 36 37 37 #include <ddf/driver.h> 38 #include <device/hw_res_parsed.h> 38 39 39 int get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);40 int get_my_registers(ddf_dev_t *, addr_range_t *, int *); 40 41 int enable_interrupts(ddf_dev_t *); 41 42 -
uspace/drv/bus/usb/uhci/hc.c
r820104d rc2a6983 105 105 * @param[out] cmds Commands buffer. 106 106 * @param[in] cmds_size Size of the commands buffer (bytes). 107 * @param[in] regs Physical address of device's registers. 108 * @param[in] reg_size Size of the register area (bytes). 107 * @param[in] regs Device's register range. 109 108 * 110 109 * @return Error code. … … 112 111 int 113 112 hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[], 114 size_t cmds_size, uintptr_t regs, size_t reg_size)113 size_t cmds_size, addr_range_t *regs) 115 114 { 116 115 if ((ranges_size < sizeof(uhci_irq_pio_ranges)) || 117 116 (cmds_size < sizeof(uhci_irq_commands)) || 118 ( reg_size< sizeof(uhci_regs_t)))117 (RNGSZ(*regs) < sizeof(uhci_regs_t))) 119 118 return EOVERFLOW; 120 119 121 120 memcpy(ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges)); 122 ranges[0].base = regs;121 ranges[0].base = RNGABS(*regs); 123 122 124 123 memcpy(cmds, uhci_irq_commands, sizeof(uhci_irq_commands)); 125 uhci_regs_t *registers = (uhci_regs_t *) regs;124 uhci_regs_t *registers = (uhci_regs_t *) RNGABSPTR(*regs); 126 125 cmds[0].addr = ®isters->usbsts; 127 126 cmds[3].addr = ®isters->usbsts; … … 133 132 * 134 133 * @param[in] device Host controller DDF device 135 * @param[in] reg_base Register range base 136 * @param[in] reg_size Register range size 134 * @param[in] regs Register range 137 135 * @param[in] irq Interrupt number 138 136 * @paran[in] handler Interrupt handler … … 140 138 * @return EOK on success or negative error code 141 139 */ 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)140 int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq, 141 interrupt_handler_t handler) 144 142 { 145 143 int rc; … … 147 145 irq_cmd_t irq_cmds[hc_irq_cmd_count]; 148 146 rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds, 149 sizeof(irq_cmds), reg _base, reg_size);147 sizeof(irq_cmds), regs); 150 148 if (rc != EOK) { 151 149 usb_log_error("Failed to generate IRQ commands: %s.\n", … … 232 230 * 233 231 * @param[in] instance Memory place to initialize. 234 * @param[in] regs Address of I/O control registers. 235 * @param[in] reg_size Size of I/O control registers. 232 * @param[in] regs Range of device's I/O control registers. 236 233 * @param[in] interrupts True if hw interrupts should be used. 237 234 * @return Error code. … … 241 238 * interrupt fibrils. 242 239 */ 243 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interrupts)244 { 245 assert(reg _size >= sizeof(uhci_regs_t));240 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts) 241 { 242 assert(regs->size >= sizeof(uhci_regs_t)); 246 243 int rc; 247 244 … … 251 248 /* allow access to hc control registers */ 252 249 uhci_regs_t *io; 253 rc = pio_enable (regs, reg_size, (void **)&io);250 rc = pio_enable_range(regs, (void **) &io); 254 251 if (rc != EOK) { 255 252 usb_log_error("Failed to gain access to registers at %p: %s.\n", … … 260 257 instance->registers = io; 261 258 usb_log_debug( 262 "Device registers at %p (%zuB) accessible.\n", io, reg _size);259 "Device registers at %p (%zuB) accessible.\n", io, regs->size); 263 260 264 261 rc = hc_init_mem_structures(instance); -
uspace/drv/bus/usb/uhci/hc.h
r820104d rc2a6983 37 37 38 38 #include <ddf/interrupt.h> 39 #include <device/hw_res_parsed.h> 39 40 #include <fibril.h> 40 41 #include <usb/host/hcd.h> … … 120 121 } hc_t; 121 122 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); 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 *); 125 127 void hc_interrupt(hc_t *instance, uint16_t status); 126 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interupts);128 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts); 127 129 128 130 /** Safely dispose host controller internal structures … … 132 134 static inline void hc_fini(hc_t *instance) {} /* TODO: implement*/ 133 135 #endif 136 134 137 /** 135 138 * @} -
uspace/drv/bus/usb/uhci/res.c
r820104d rc2a6983 46 46 * 47 47 * @param[in] dev Device asking for the addresses. 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. 48 * @param[out] io_regs_p Pointer to register I/O range. 50 49 * @param[out] irq_no IRQ assigned to the device. 51 50 * @return Error code. 52 51 */ 53 int get_my_registers(ddf_dev_t *dev, 54 uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no) 52 int get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs_p, int *irq_no) 55 53 { 56 54 assert(dev); … … 76 74 } 77 75 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; 76 if (io_regs_p) 77 *io_regs_p = hw_res.io_ranges.ranges[0]; 82 78 if (irq_no) 83 79 *irq_no = hw_res.irqs.irqs[0]; -
uspace/drv/bus/usb/uhci/res.h
r820104d rc2a6983 37 37 38 38 #include <ddf/driver.h> 39 #include <device/hw_res_parsed.h> 39 40 40 int get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);41 int get_my_registers(ddf_dev_t *, addr_range_t *, int *); 41 42 int enable_interrupts(ddf_dev_t *); 42 43 int disable_legacy(ddf_dev_t *); -
uspace/drv/bus/usb/uhci/uhci.c
r820104d rc2a6983 184 184 ddf_fun_data_implant(instance->rh_fun, &instance->rh); 185 185 186 uintptr_t reg_base = 0; 187 size_t reg_size = 0; 186 addr_range_t regs; 188 187 int irq = 0; 189 188 190 rc = get_my_registers(device, ® _base, ®_size, &irq);189 rc = get_my_registers(device, ®s, &irq); 191 190 if (rc != EOK) { 192 191 usb_log_error("Failed to get I/O addresses for %" PRIun ": %s.\n", … … 194 193 goto error; 195 194 } 196 usb_log_debug("I/O regs at 0x%p (size %zu), IRQ %d.\n",197 (void *) reg_base, reg_size, irq);195 usb_log_debug("I/O regs at %p (size %zu), IRQ %d.\n", 196 RNGABSPTR(regs), RNGSZ(regs), irq); 198 197 199 198 rc = disable_legacy(device); … … 204 203 } 205 204 206 rc = hc_register_irq_handler(device, reg_base, reg_size, irq, irq_handler);205 rc = hc_register_irq_handler(device, ®s, irq, irq_handler); 207 206 if (rc != EOK) { 208 207 usb_log_error("Failed to register interrupt handler: %s.\n", … … 223 222 } 224 223 225 rc = hc_init(&instance->hc, (void*)reg_base, reg_size, interrupts);224 rc = hc_init(&instance->hc, ®s, interrupts); 226 225 if (rc != EOK) { 227 226 usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(rc)); -
uspace/drv/bus/usb/uhci/utils/malloc32.h
r820104d rc2a6983 92 92 */ 93 93 static inline void free32(void *addr) 94 { free(addr); } 94 { 95 free(addr); 96 } 95 97 96 98 /** Create 4KB page mapping … … 98 100 * @return Address of the mapped page, NULL on failure. 99 101 */ 100 static inline void * get_page(void)102 static inline void *get_page(void) 101 103 { 102 void *address, *phys; 104 uintptr_t phys; 105 void *address; 106 103 107 const int ret = dmamem_map_anonymous(UHCI_REQUIRED_PAGE_SIZE, 104 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &address); 105 return ret == EOK ? address : NULL; 108 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys, 109 &address); 110 111 return ((ret == EOK) ? address : NULL); 106 112 } 107 113 -
uspace/drv/bus/usb/uhcirh/main.c
r820104d rc2a6983 48 48 #define NAME "uhcirh" 49 49 50 static int hc_get_my_registers(ddf_dev_t *dev, 51 uintptr_t *io_reg_address, size_t *io_reg_size); 50 static int hc_get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs); 52 51 53 52 static int uhci_rh_dev_add(ddf_dev_t *device); … … 90 89 ddf_dev_get_handle(device)); 91 90 92 uintptr_t io_regs = 0; 93 size_t io_size = 0; 91 addr_range_t regs; 94 92 uhci_root_hub_t *rh = NULL; 95 93 int rc; 96 94 97 rc = hc_get_my_registers(device, & io_regs, &io_size);95 rc = hc_get_my_registers(device, ®s); 98 96 if (rc != EOK) { 99 97 usb_log_error( "Failed to get registers from HC: %s.\n", … … 103 101 104 102 usb_log_debug("I/O regs at %p (size %zuB).\n", 105 (void *) io_regs, io_size);103 RNGABSPTR(regs), RNGSZ(regs)); 106 104 107 105 rh = ddf_dev_data_alloc(device, sizeof(uhci_root_hub_t)); … … 111 109 } 112 110 113 rc = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);111 rc = uhci_root_hub_init(rh, ®s, device); 114 112 if (rc != EOK) { 115 113 usb_log_error("Failed(%d) to initialize rh driver instance: " … … 127 125 * 128 126 * @param[in] dev Device asking for the addresses. 129 * @param[out] io_reg_address Base address of the memory range. 130 * @param[out] io_reg_size Size of the memory range. 127 * @param[out] io_regs_p Pointer to the device's register range. 131 128 * @return Error code. 132 129 */ 133 int hc_get_my_registers( 134 ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size) 130 int hc_get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs_p) 135 131 { 136 132 async_sess_t *parent_sess = … … 153 149 } 154 150 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; 151 if (io_regs_p != NULL) 152 *io_regs_p = hw_res.io_ranges.ranges[0]; 160 153 161 154 hw_res_list_parsed_clean(&hw_res); -
uspace/drv/bus/usb/uhcirh/root_hub.c
r820104d rc2a6983 36 36 #include <ddi.h> 37 37 #include <usb/debug.h> 38 #include <device/hw_res_parsed.h> 38 39 39 40 #include "root_hub.h" … … 42 43 * 43 44 * @param[in] instance Driver memory structure to use. 44 * @param[in] addr Address of I/O registers. 45 * @param[in] size Size of available I/O space. 45 * @param[in] io_regs Range of I/O registers. 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( 50 uhci_root_hub_t *instance, void *addr, size_t size,ddf_dev_t *rh)49 int uhci_root_hub_init(uhci_root_hub_t *instance, addr_range_t *io_regs, 50 ddf_dev_t *rh) 51 51 { 52 port_status_t *regs; 53 52 54 assert(instance); 53 55 assert(rh); 54 56 55 57 /* Allow access to root hub port registers */ 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);58 assert(sizeof(*regs) * UHCI_ROOT_HUB_PORT_COUNT <= io_regs->size); 59 60 int ret = pio_enable_range(io_regs, (void **) ®s); 59 61 if (ret < 0) { 60 62 usb_log_error( 61 63 "Failed(%d) to gain access to port registers at %p: %s.\n", 62 ret, regs, str_error(ret));64 ret, RNGABSPTR(*io_regs), str_error(ret)); 63 65 return ret; 64 66 } -
uspace/drv/bus/usb/uhcirh/root_hub.h
r820104d rc2a6983 36 36 37 37 #include <ddf/driver.h> 38 #include <device/hw_res_parsed.h> 38 39 39 40 #include "port.h" … … 48 49 } uhci_root_hub_t; 49 50 50 int uhci_root_hub_init( 51 uhci_root_hub_t *instance, void *addr, size_t size,ddf_dev_t *rh);51 int uhci_root_hub_init(uhci_root_hub_t *instance, addr_range_t *regs, 52 ddf_dev_t *rh); 52 53 53 54 void uhci_root_hub_fini(uhci_root_hub_t *instance); -
uspace/drv/bus/usb/usbmid/explore.c
r820104d rc2a6983 56 56 static bool interface_in_list(const list_t *list, int interface_no) 57 57 { 58 list_foreach(*list, l) { 59 usbmid_interface_t *iface = usbmid_interface_from_link(l); 58 list_foreach(*list, link, usbmid_interface_t, iface) { 60 59 if (iface->interface_no == interface_no) { 61 60 return true; … … 190 189 191 190 /* Start child function for every interface. */ 192 list_foreach(usb_mid->interface_list, link) { 193 usbmid_interface_t *iface = usbmid_interface_from_link(link); 194 191 list_foreach(usb_mid->interface_list, link, usbmid_interface_t, iface) { 195 192 usb_log_info("Creating child for interface %d (%s).\n", 196 193 iface->interface_no, -
uspace/drv/bus/usb/usbmid/usbmid.c
r820104d rc2a6983 135 135 } 136 136 137 list_foreach(match_ids.ids, link) { 138 match_id_t *match_id = list_get_instance(link, match_id_t, link); 137 list_foreach(match_ids.ids, link, match_id_t, match_id) { 139 138 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score); 140 139 if (rc != EOK) { -
uspace/drv/bus/usb/vhc/transfer.c
r820104d rc2a6983 92 92 93 93 bool target_found = false; 94 list_foreach(vhc->devices, pos) { 95 vhc_virtdev_t *dev = list_get_instance(pos, vhc_virtdev_t, link); 94 list_foreach(vhc->devices, link, vhc_virtdev_t, dev) { 96 95 fibril_mutex_lock(&dev->guard); 97 96 if (dev->address == transfer->address) { -
uspace/drv/char/i8042/i8042.c
r820104d rc2a6983 145 145 * 146 146 * @param dev Driver structure to initialize. 147 * @param regs I/O address of registers. 148 * @param reg_size size of the reserved I/O address space. 147 * @param regs I/O range of registers. 149 148 * @param irq_kbd IRQ for primary port. 150 149 * @param irq_mouse IRQ for aux port. … … 154 153 * 155 154 */ 156 int i8042_init(i8042_t *dev, void *regs, size_t reg_size, int irq_kbd,155 int i8042_init(i8042_t *dev, addr_range_t *regs, int irq_kbd, 157 156 int irq_mouse, ddf_dev_t *ddf_dev) 158 157 { … … 162 161 const size_t cmd_count = sizeof(i8042_cmds) / sizeof(irq_cmd_t); 163 162 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 _size < sizeof(i8042_regs_t)) {172 if (regs->size < sizeof(i8042_regs_t)) { 173 173 rc = EINVAL; 174 174 goto error; 175 175 } 176 176 177 if (pio_enable (regs, sizeof(i8042_regs_t), (void **) &dev->regs) != 0) {177 if (pio_enable_range(regs, (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 = (uintptr_t) regs; 237 236 ranges[0].base = RNGABS(*regs); 237 238 239 ar = RNGABSPTR(*regs); 238 240 memcpy(cmds, i8042_cmds, sizeof(i8042_cmds)); 239 cmds[0].addr = (void *) & (((i8042_regs_t *) regs)->status);240 cmds[3].addr = (void *) & (((i8042_regs_t *) regs)->data);241 cmds[0].addr = (void *) &ar->status; 242 cmds[3].addr = (void *) &ar->data; 241 243 242 244 irq_code_t irq_code = { -
uspace/drv/char/i8042/i8042.h
r820104d rc2a6983 68 68 } i8042_t; 69 69 70 int i8042_init(i8042_t *, void *, size_t, int, int, ddf_dev_t *);70 int i8042_init(i8042_t *, addr_range_t *, int, int, ddf_dev_t *); 71 71 72 72 #endif -
uspace/drv/char/i8042/main.c
r820104d rc2a6983 49 49 * 50 50 * @param[in] dev Device asking for the addresses. 51 * @param[out] io_reg_address Base address of the memory range. 52 * @param[out] io_reg_size Size of the memory range. 51 * @param[out] p_io_reg Pointer to register range. 53 52 * @param[out] kbd_irq Primary port IRQ. 54 53 * @param[out] mouse_irq Auxiliary port IRQ. … … 57 56 * 58 57 */ 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)58 static int get_my_registers(ddf_dev_t *dev, addr_range_t *p_io_reg, 59 int *kbd_irq, int *mouse_irq) 61 60 { 62 61 assert(dev); … … 79 78 } 80 79 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; 80 if (p_io_reg) 81 *p_io_reg = hw_resources.io_ranges.ranges[0]; 86 82 87 83 if (kbd_irq) … … 104 100 static int i8042_dev_add(ddf_dev_t *device) 105 101 { 106 uintptr_t io_regs = 0; 107 size_t io_size = 0; 102 addr_range_t io_regs; 108 103 int kbd = 0; 109 104 int mouse = 0; … … 113 108 return EINVAL; 114 109 115 rc = get_my_registers(device, &io_regs, & io_size, &kbd, &mouse);110 rc = get_my_registers(device, &io_regs, &kbd, &mouse); 116 111 if (rc != EOK) { 117 112 ddf_msg(LVL_ERROR, "Failed to get registers: %s.", … … 120 115 } 121 116 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); 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); 124 120 125 121 i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t)); … … 129 125 } 130 126 131 rc = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device);127 rc = i8042_init(i8042, &io_regs, kbd, mouse, device); 132 128 if (rc != EOK) { 133 129 ddf_msg(LVL_ERROR, "Failed to initialize i8042 driver: %s.", -
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c
r820104d rc2a6983 273 273 ddf_log_note("Setting mode: %ux%ux%u\n", x, y, bpp*8); 274 274 const size_t size = ALIGN_UP(x * y * bpp, PAGE_SIZE); 275 void *buffer, *pa; 276 int ret = dmamem_map_anonymous(size, AS_AREA_READ | AS_AREA_WRITE, 277 0, &pa, &buffer); 275 uintptr_t pa; 276 void *buffer; 277 int ret = dmamem_map_anonymous(size, DMAMEM_4GiB, 278 AS_AREA_READ | AS_AREA_WRITE, 0, &pa, &buffer); 278 279 if (ret != EOK) { 279 280 ddf_log_error("Failed to get new FB\n"); 280 281 return ret; 281 282 } 283 282 284 amdm37x_dispc_setup_fb(dispc->regs, x, y, bpp *8, (uint32_t)pa); 283 285 dispc->active_fb.idx = mode.index; -
uspace/drv/fb/kfb/port.c
r820104d rc2a6983 333 333 334 334 kfb.size = scanline * height; 335 rc = physmem_map( (void *)paddr + offset,335 rc = physmem_map(paddr + offset, 336 336 ALIGN_UP(kfb.size, PAGE_SIZE) >> PAGE_WIDTH, 337 337 AS_AREA_READ | AS_AREA_WRITE, (void *) &kfb.addr); -
uspace/drv/infrastructure/root/root.c
r820104d rc2a6983 208 208 /* 209 209 * Register virtual devices root. 210 * We ignoreerror occurrence because virtual devices shall not be210 * We warn on error occurrence because virtual devices shall not be 211 211 * vital for the system. 212 212 */ 213 (void) add_virtual_root_fun(dev); 213 int res = add_virtual_root_fun(dev); 214 if (res != EOK) 215 ddf_msg(LVL_WARN, "Failed to add virtual child."); 214 216 215 217 /* Register root device's children. */ 216 intres = add_platform_fun(dev);218 res = add_platform_fun(dev); 217 219 if (EOK != res) 218 220 ddf_msg(LVL_ERROR, "Failed adding child device for platform."); -
uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c
r820104d rc2a6983 48 48 49 49 typedef struct { 50 const char *name; 51 match_id_t match_id; 50 52 hw_resource_list_t hw_resources; 51 53 } rootamdm37x_fun_t; 52 54 53 /* See amdm37x TRM page. 3316 for these values */ 54 #define OHCI_BASE_ADDRESS 0x48064400 55 #define OHCI_SIZE 1024 56 #define EHCI_BASE_ADDRESS 0x48064800 57 #define EHCI_SIZE 1024 55 /* See amdm37x TRM page 3316 for these values */ 56 #define OHCI_BASE_ADDRESS 0x48064400 57 #define OHCI_SIZE 1024 58 #define EHCI_BASE_ADDRESS 0x48064800 59 #define EHCI_SIZE 1024 60 61 /* See amdm37x TRM page 1813 for these values */ 62 #define DSS_BASE_ADDRESS 0x48050000 63 #define DSS_SIZE 512 64 #define DISPC_BASE_ADDRESS 0x48050400 65 #define DISPC_SIZE 1024 66 #define VIDEO_ENC_BASE_ADDRESS 0x48050C00 67 #define VIDEO_ENC_SIZE 256 68 58 69 59 70 static hw_resource_t ohci_res[] = { … … 88 99 }; 89 100 90 static const rootamdm37x_fun_t ohci = { 91 .hw_resources = { 92 .resources = ohci_res, 93 .count = sizeof(ohci_res)/sizeof(ohci_res[0]), 94 } 95 }; 96 97 static const rootamdm37x_fun_t ehci = { 98 .hw_resources = { 99 .resources = ehci_res, 100 .count = sizeof(ehci_res) / sizeof(ehci_res[0]), 101 } 102 }; 101 static hw_resource_t disp_res[] = { 102 { 103 .type = MEM_RANGE, 104 .res.io_range = { 105 .address = DSS_BASE_ADDRESS, 106 .size = DSS_SIZE, 107 .endianness = LITTLE_ENDIAN 108 }, 109 }, 110 { 111 .type = MEM_RANGE, 112 .res.io_range = { 113 .address = DISPC_BASE_ADDRESS, 114 .size = DISPC_SIZE, 115 .endianness = LITTLE_ENDIAN 116 }, 117 }, 118 { 119 .type = MEM_RANGE, 120 .res.io_range = { 121 .address = VIDEO_ENC_BASE_ADDRESS, 122 .size = VIDEO_ENC_SIZE, 123 .endianness = LITTLE_ENDIAN 124 }, 125 }, 126 { 127 .type = INTERRUPT, 128 .res.interrupt = { .irq = 25 }, 129 }, 130 }; 131 132 static const rootamdm37x_fun_t amdm37x_funcs[] = { 133 { 134 .name = "ohci", 135 .match_id = { .id = "usb/host=ohci", .score = 90 }, 136 .hw_resources = { .resources = ohci_res, .count = ARRAY_SIZE(ohci_res) } 137 }, 138 { 139 .name = "ehci", 140 .match_id = { .id = "usb/host=ehci", .score = 90 }, 141 .hw_resources = { .resources = ehci_res, .count = ARRAY_SIZE(ehci_res) } 142 }, 143 { 144 .name = "fb", 145 .match_id = { .id = "amdm37x&dispc", .score = 90 }, 146 .hw_resources = { .resources = disp_res, .count = ARRAY_SIZE(disp_res) } 147 }, 148 }; 149 103 150 104 151 static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode); … … 114 161 }; 115 162 116 static int rootamdm37x_add_fun(ddf_dev_t *dev, const char *name, 117 const char *str_match_id, const rootamdm37x_fun_t *fun) 118 { 119 ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name); 120 163 static int rootamdm37x_add_fun(ddf_dev_t *dev, const rootamdm37x_fun_t *fun) 164 { 165 assert(dev); 166 assert(fun); 167 168 ddf_msg(LVL_DEBUG, "Adding new function '%s'.", fun->name); 169 121 170 /* Create new device function. */ 122 ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, name);171 ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, fun->name); 123 172 if (fnode == NULL) 124 173 return ENOMEM; 125 174 126 175 /* Add match id */ 127 int ret = ddf_fun_add_match_id(fnode, str_match_id, 100); 176 int ret = ddf_fun_add_match_id(fnode, 177 fun->match_id.id, fun->match_id.score); 128 178 if (ret != EOK) { 129 179 ddf_fun_destroy(fnode); … … 146 196 ret = ddf_fun_bind(fnode); 147 197 if (ret != EOK) { 148 ddf_msg(LVL_ERROR, "Failed binding function %s.", name);198 ddf_msg(LVL_ERROR, "Failed binding function %s.", fun->name); 149 199 ddf_fun_destroy(fnode); 150 200 return ret; … … 189 239 190 240 /* Register functions */ 191 if (rootamdm37x_add_fun(dev, "ohci", "usb/host=ohci", &ohci) != EOK) 192 ddf_msg(LVL_ERROR, "Failed to add OHCI function for " 193 "BeagleBoard-xM platform."); 194 if (rootamdm37x_add_fun(dev, "ehci", "usb/host=ehci", &ehci) != EOK) 195 ddf_msg(LVL_ERROR, "Failed to add EHCI function for " 196 "BeagleBoard-xM platform."); 197 if (rootamdm37x_add_fun(dev, "dispc", "amdm37x&dispc", &ehci) != EOK) 198 ddf_msg(LVL_ERROR, "Failed to add dispc function for " 199 "BeagleBoard-xM platform."); 200 241 for (unsigned i = 0; i < ARRAY_SIZE(amdm37x_funcs); ++i) { 242 if (rootamdm37x_add_fun(dev, &amdm37x_funcs[i]) != EOK) 243 ddf_msg(LVL_ERROR, "Failed to add %s function for " 244 "BeagleBoard-xM platform.", amdm37x_funcs[i].name); 245 } 201 246 return EOK; 202 247 } -
uspace/drv/infrastructure/rootamdm37x/uhh.h
r820104d rc2a6983 85 85 #define UHH_DEBUG_CSR_EHCI_SIMULATION_MODE_FLAG (1 << 6) 86 86 #define UHH_DEBUG_CSR_OHCI_CNTSEL_FLAG (1 << 7) 87 #define UHH_DEBUG_CSR_OHCI_GLOBAL_ sUSPEND_FLAG (1 << 16)87 #define UHH_DEBUG_CSR_OHCI_GLOBAL_SUSPEND_FLAG (1 << 16) 88 88 #define UHH_DEBUG_CSR_OHCI_CCS1_FLAG (1 << 17) 89 89 #define UHH_DEBUG_CSR_OHCI_CCS2_FLAG (1 << 18) -
uspace/drv/infrastructure/rootmac/rootmac.c
r820104d rc2a6983 54 54 .address = 0xfec00000, 55 55 .size = 4, 56 .relative = false, 56 57 .endianness = LITTLE_ENDIAN 57 58 } … … 62 63 .address = 0xfee00000, 63 64 .size = 4, 65 .relative = false, 64 66 .endianness = LITTLE_ENDIAN 65 67 } -
uspace/drv/infrastructure/rootpc/rootpc.c
r820104d rc2a6983 51 51 #include <ops/hw_res.h> 52 52 #include <device/hw_res.h> 53 #include <ops/pio_window.h> 54 #include <device/pio_window.h> 53 55 54 56 #define NAME "rootpc" … … 56 58 typedef struct rootpc_fun { 57 59 hw_resource_list_t hw_resources; 60 pio_window_t pio_window; 58 61 } rootpc_fun_t; 59 62 … … 78 81 .address = 0xCF8, 79 82 .size = 4, 83 .relative = false, 80 84 .endianness = LITTLE_ENDIAN 81 85 } … … 86 90 .address = 0xCFC, 87 91 .size = 4, 92 .relative = false, 88 93 .endianness = LITTLE_ENDIAN 89 94 } … … 93 98 static rootpc_fun_t pci_data = { 94 99 .hw_resources = { 95 sizeof(pci_conf_regs) /sizeof(pci_conf_regs[0]),100 sizeof(pci_conf_regs) / sizeof(pci_conf_regs[0]), 96 101 pci_conf_regs 102 }, 103 .pio_window = { 104 .mem = { 105 .base = UINT32_C(0), 106 .size = UINT32_C(0xffffffff) /* practical maximum */ 107 }, 108 .io = { 109 .base = UINT32_C(0), 110 .size = UINT32_C(0x10000) 111 } 97 112 } 98 113 }; … … 117 132 118 133 return false; 134 } 135 136 static pio_window_t *rootpc_get_pio_window(ddf_fun_t *fnode) 137 { 138 rootpc_fun_t *fun = rootpc_fun(fnode); 139 140 assert(fun != NULL); 141 return &fun->pio_window; 119 142 } 120 143 … … 122 145 .get_resource_list = &rootpc_get_resources, 123 146 .enable_interrupt = &rootpc_enable_interrupt, 147 }; 148 149 static pio_window_ops_t fun_pio_window_ops = { 150 .get_pio_window = &rootpc_get_pio_window 124 151 }; 125 152 … … 197 224 ddf_log_init(NAME); 198 225 rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops; 226 rootpc_fun_ops.interfaces[PIO_WINDOW_DEV_IFACE] = &fun_pio_window_ops; 199 227 } 200 228 -
uspace/drv/nic/e1k/e1k.c
r820104d rc2a6983 129 129 130 130 /** Physical tx ring address */ 131 void *tx_ring_phys;131 uintptr_t tx_ring_phys; 132 132 /** Virtual tx ring address */ 133 133 void *tx_ring_virt; 134 134 135 135 /** Ring of TX frames, physical address */ 136 void **tx_frame_phys;136 uintptr_t *tx_frame_phys; 137 137 /** Ring of TX frames, virtual address */ 138 138 void **tx_frame_virt; 139 139 140 140 /** Physical rx ring address */ 141 void *rx_ring_phys;141 uintptr_t rx_ring_phys; 142 142 /** Virtual rx ring address */ 143 143 void *rx_ring_virt; 144 144 145 145 /** Ring of RX frames, physical address */ 146 void **rx_frame_phys;146 uintptr_t *rx_frame_phys; 147 147 /** Ring of RX frames, virtual address */ 148 148 void **rx_frame_virt; … … 1377 1377 int rc = dmamem_map_anonymous( 1378 1378 E1000_RX_FRAME_COUNT * sizeof(e1000_rx_descriptor_t), 1379 AS_AREA_READ | AS_AREA_WRITE, 0, &e1000->rx_ring_phys,1380 &e1000->rx_ring_ virt);1379 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, 1380 &e1000->rx_ring_phys, &e1000->rx_ring_virt); 1381 1381 if (rc != EOK) 1382 1382 return rc; … … 1387 1387 (uint32_t) PTR_TO_U64(e1000->rx_ring_phys)); 1388 1388 1389 e1000->rx_frame_phys = 1390 calloc(E1000_RX_FRAME_COUNT, sizeof( void *));1389 e1000->rx_frame_phys = (uintptr_t *) 1390 calloc(E1000_RX_FRAME_COUNT, sizeof(uintptr_t)); 1391 1391 e1000->rx_frame_virt = 1392 1392 calloc(E1000_RX_FRAME_COUNT, sizeof(void *)); 1393 if ( e1000->rx_frame_phys == NULL || e1000->rx_frame_virt == NULL) {1393 if ((e1000->rx_frame_phys == NULL) || (e1000->rx_frame_virt == NULL)) { 1394 1394 rc = ENOMEM; 1395 1395 goto error; … … 1397 1397 1398 1398 size_t i; 1399 uintptr_t frame_phys; 1399 1400 void *frame_virt; 1400 void *frame_phys;1401 1401 1402 1402 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) { 1403 rc = dmamem_map_anonymous( 1404 E1000_MAX_SEND_FRAME_SIZE, AS_AREA_READ | AS_AREA_WRITE,1405 0,&frame_phys, &frame_virt);1403 rc = dmamem_map_anonymous(E1000_MAX_SEND_FRAME_SIZE, 1404 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, 1405 &frame_phys, &frame_virt); 1406 1406 if (rc != EOK) 1407 1407 goto error; 1408 1408 1409 e1000->rx_frame_phys[i] = frame_phys; 1409 1410 e1000->rx_frame_virt[i] = frame_virt; 1410 e1000->rx_frame_phys[i] = frame_phys;1411 1411 } 1412 1412 … … 1424 1424 if (e1000->rx_frame_virt[i] != NULL) { 1425 1425 dmamem_unmap_anonymous(e1000->rx_frame_virt[i]); 1426 e1000->rx_frame_phys[i] = 0; 1426 1427 e1000->rx_frame_virt[i] = NULL; 1427 e1000->rx_frame_phys[i] = NULL;1428 1428 } 1429 1429 } … … 1436 1436 if (e1000->rx_frame_virt != NULL) { 1437 1437 free(e1000->rx_frame_virt); 1438 e1000->rx_frame_ phys= NULL;1438 e1000->rx_frame_virt = NULL; 1439 1439 } 1440 1440 … … 1454 1454 for (unsigned int offset = 0; offset < E1000_RX_FRAME_COUNT; offset++) { 1455 1455 dmamem_unmap_anonymous(e1000->rx_frame_virt[offset]); 1456 e1000->rx_frame_phys[offset] = 0; 1456 1457 e1000->rx_frame_virt[offset] = NULL; 1457 e1000->rx_frame_phys[offset] = NULL;1458 1458 } 1459 1459 1460 1460 free(e1000->rx_frame_virt); 1461 free(e1000->rx_frame_phys); 1461 1462 e1000->rx_frame_phys = NULL; 1462 1463 e1000->rx_frame_virt = NULL; 1463 e1000->rx_frame_phys = NULL;1464 1464 1465 dmamem_unmap_anonymous(e1000->rx_ring_virt); 1465 1466 } … … 1569 1570 fibril_mutex_lock(&e1000->tx_lock); 1570 1571 1571 e1000->tx_ring_phys = NULL;1572 e1000->tx_ring_phys = 0; 1572 1573 e1000->tx_ring_virt = NULL; 1574 1573 1575 e1000->tx_frame_phys = NULL; 1574 1576 e1000->tx_frame_virt = NULL; … … 1576 1578 int rc = dmamem_map_anonymous( 1577 1579 E1000_TX_FRAME_COUNT * sizeof(e1000_tx_descriptor_t), 1578 AS_AREA_READ | AS_AREA_WRITE, 0, &e1000->tx_ring_phys,1579 &e1000->tx_ring_ virt);1580 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, 1581 &e1000->tx_ring_phys, &e1000->tx_ring_virt); 1580 1582 if (rc != EOK) 1581 1583 goto error; … … 1584 1586 E1000_TX_FRAME_COUNT * sizeof(e1000_tx_descriptor_t)); 1585 1587 1586 e1000->tx_frame_phys = calloc(E1000_TX_FRAME_COUNT, sizeof(void *)); 1587 e1000->tx_frame_virt = calloc(E1000_TX_FRAME_COUNT, sizeof(void *)); 1588 1589 if (e1000->tx_frame_phys == NULL || e1000->tx_frame_virt == NULL) { 1588 e1000->tx_frame_phys = (uintptr_t *) 1589 calloc(E1000_TX_FRAME_COUNT, sizeof(uintptr_t)); 1590 e1000->tx_frame_virt = 1591 calloc(E1000_TX_FRAME_COUNT, sizeof(void *)); 1592 1593 if ((e1000->tx_frame_phys == NULL) || (e1000->tx_frame_virt == NULL)) { 1590 1594 rc = ENOMEM; 1591 1595 goto error; … … 1593 1597 1594 1598 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1595 rc = dmamem_map_anonymous( 1596 E1000_MAX_SEND_FRAME_SIZE, AS_AREA_READ | AS_AREA_WRITE,1599 rc = dmamem_map_anonymous(E1000_MAX_SEND_FRAME_SIZE, 1600 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 1597 1601 0, &e1000->tx_frame_phys[i], &e1000->tx_frame_virt[i]); 1598 1602 if (rc != EOK) … … 1616 1620 } 1617 1621 1618 if ( e1000->tx_frame_phys != NULL && e1000->tx_frame_virt != NULL) {1622 if ((e1000->tx_frame_phys != NULL) && (e1000->tx_frame_virt != NULL)) { 1619 1623 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1620 1624 if (e1000->tx_frame_virt[i] != NULL) { 1621 1625 dmamem_unmap_anonymous(e1000->tx_frame_virt[i]); 1626 e1000->tx_frame_phys[i] = 0; 1622 1627 e1000->tx_frame_virt[i] = NULL; 1623 e1000->tx_frame_phys[i] = NULL;1624 1628 } 1625 1629 } … … 1633 1637 if (e1000->tx_frame_virt != NULL) { 1634 1638 free(e1000->tx_frame_virt); 1635 e1000->tx_frame_ phys= NULL;1639 e1000->tx_frame_virt = NULL; 1636 1640 } 1637 1641 … … 1650 1654 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1651 1655 dmamem_unmap_anonymous(e1000->tx_frame_virt[i]); 1656 e1000->tx_frame_phys[i] = 0; 1652 1657 e1000->tx_frame_virt[i] = NULL; 1653 e1000->tx_frame_phys[i] = NULL;1654 1658 } 1655 1659 … … 1661 1665 if (e1000->tx_frame_virt != NULL) { 1662 1666 free(e1000->tx_frame_virt); 1663 e1000->tx_frame_ phys= NULL;1667 e1000->tx_frame_virt = NULL; 1664 1668 } 1665 1669 … … 1937 1941 e1000->irq = hw_resources->irqs.irqs[0]; 1938 1942 e1000->reg_base_phys = 1939 MEMADDR_TO_PTR( hw_resources->mem_ranges.ranges[0].address);1943 MEMADDR_TO_PTR(RNGABS(hw_resources->mem_ranges.ranges[0])); 1940 1944 1941 1945 return EOK; -
uspace/drv/nic/ne2k/ne2k.c
r820104d rc2a6983 211 211 ne2k->irq = hw_res_parsed.irqs.irqs[0]; 212 212 213 ne2k->base_port = (void *) (uintptr_t)214 hw_res_parsed.io_ranges.ranges[0].address;213 addr_range_t regs = hw_res_parsed.io_ranges.ranges[0]; 214 ne2k->base_port = RNGABSPTR(regs); 215 215 216 216 hw_res_list_parsed_clean(&hw_res_parsed); 217 217 218 /* Enable p ortI/O */219 if (pio_enable (ne2k->base_port, NE2K_IO_SIZE, &ne2k->port) != EOK)218 /* Enable programmed I/O */ 219 if (pio_enable_range(®s, &ne2k->port) != EOK) 220 220 return EADDRNOTAVAIL; 221 222 221 223 222 ne2k->data_port = ne2k->port + NE2K_DATA; -
uspace/drv/nic/rtl8139/driver.c
r820104d rc2a6983 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( hw_resources->io_ranges.ranges[0].address);1089 rtl8139->io_addr = IOADDR_TO_PTR(RNGABS(hw_resources->io_ranges.ranges[0])); 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 " … … 1144 1144 ddf_msg(LVL_DEBUG, "Creating buffers"); 1145 1145 1146 rc = dmamem_map_anonymous(TX_PAGES * PAGE_SIZE, AS_AREA_WRITE, 0,1147 &rtl8139->tx_buff_phys, &rtl8139->tx_buff_virt);1146 rc = dmamem_map_anonymous(TX_PAGES * PAGE_SIZE, DMAMEM_4GiB, 1147 AS_AREA_WRITE, 0, &rtl8139->tx_buff_phys, &rtl8139->tx_buff_virt); 1148 1148 if (rc != EOK) { 1149 1149 ddf_msg(LVL_ERROR, "Can not allocate transmitter buffers."); … … 1164 1164 RxBUF_TOT_LENGTH); 1165 1165 1166 rc = dmamem_map_anonymous(RxBUF_TOT_LENGTH, AS_AREA_READ, 0,1167 &rtl8139->rx_buff_phys, &rtl8139->rx_buff_virt);1166 rc = dmamem_map_anonymous(RxBUF_TOT_LENGTH, DMAMEM_4GiB, 1167 AS_AREA_READ, 0, &rtl8139->rx_buff_phys, &rtl8139->rx_buff_virt); 1168 1168 if (rc != EOK) { 1169 1169 ddf_msg(LVL_ERROR, "Can not allocate receive buffer."); -
uspace/drv/nic/rtl8139/driver.h
r820104d rc2a6983 100 100 * Each buffer takes 2kB 101 101 */ 102 void *tx_buff_phys;102 uintptr_t tx_buff_phys; 103 103 void *tx_buff_virt; 104 104 … … 117 117 118 118 /** Buffer for receiving frames */ 119 void *rx_buff_phys;119 uintptr_t rx_buff_phys; 120 120 void *rx_buff_virt; 121 121
Note:
See TracChangeset
for help on using the changeset viewer.
