Changes in uspace/drv/block/ahci/ahci.c [7f620e8:acdb5bac] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/ahci/ahci.c
r7f620e8 racdb5bac 37 37 #include <ddf/log.h> 38 38 #include <device/hw_res_parsed.h> 39 #include < pci_dev_iface.h>39 #include <device/pci.h> 40 40 #include <sysinfo.h> 41 41 #include <ipc/irc.h> … … 111 111 } 112 112 113 static int get_sata_device_name(ddf_fun_t *, size_t, char *);114 static int get_num_blocks(ddf_fun_t *, uint64_t *);115 static int get_block_size(ddf_fun_t *, size_t *);116 static int read_blocks(ddf_fun_t *, uint64_t, size_t, void *);117 static int write_blocks(ddf_fun_t *, uint64_t, size_t, void *);113 static int ahci_get_sata_device_name(ddf_fun_t *, size_t, char *); 114 static int ahci_get_num_blocks(ddf_fun_t *, uint64_t *); 115 static int ahci_get_block_size(ddf_fun_t *, size_t *); 116 static int ahci_read_blocks(ddf_fun_t *, uint64_t, size_t, void *); 117 static int ahci_write_blocks(ddf_fun_t *, uint64_t, size_t, void *); 118 118 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 *, uintptr_t, uint64_t);122 static int ahci_wb_fpdma(sata_dev_t *, uintptr_t, uint64_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); 123 123 124 124 static void ahci_sata_devices_create(ahci_dev_t *, ddf_dev_t *); … … 139 139 140 140 static ahci_iface_t ahci_interface = { 141 .get_sata_device_name = & get_sata_device_name,142 .get_num_blocks = & get_num_blocks,143 .get_block_size = & get_block_size,144 .read_blocks = & read_blocks,145 .write_blocks = & write_blocks141 .get_sata_device_name = &ahci_get_sata_device_name, 142 .get_num_blocks = &ahci_get_num_blocks, 143 .get_block_size = &ahci_get_block_size, 144 .read_blocks = &ahci_read_blocks, 145 .write_blocks = &ahci_write_blocks 146 146 }; 147 147 … … 180 180 * 181 181 */ 182 static int get_sata_device_name(ddf_fun_t *fun,182 static int ahci_get_sata_device_name(ddf_fun_t *fun, 183 183 size_t sata_dev_name_length, char *sata_dev_name) 184 184 { … … 196 196 * 197 197 */ 198 static int get_num_blocks(ddf_fun_t *fun, uint64_t *num_blocks)198 static int ahci_get_num_blocks(ddf_fun_t *fun, uint64_t *num_blocks) 199 199 { 200 200 sata_dev_t *sata = fun_sata_dev(fun); … … 211 211 * 212 212 */ 213 static int get_block_size(ddf_fun_t *fun, size_t *block_size)213 static int ahci_get_block_size(ddf_fun_t *fun, size_t *block_size) 214 214 { 215 215 sata_dev_t *sata = fun_sata_dev(fun); … … 228 228 * 229 229 */ 230 static int read_blocks(ddf_fun_t *fun, uint64_t blocknum,230 static int ahci_read_blocks(ddf_fun_t *fun, uint64_t blocknum, 231 231 size_t count, void *buf) 232 232 { 233 233 sata_dev_t *sata = fun_sata_dev(fun); 234 234 235 uintptr_tphys;235 void *phys; 236 236 void *ibuf; 237 int rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB,238 AS_AREA_READ | AS_AREA_WRITE, 0, &phys,&ibuf);237 int rc = dmamem_map_anonymous(sata->block_size, AS_AREA_READ | AS_AREA_WRITE, 238 0, &phys, (void **) &ibuf); 239 239 if (rc != EOK) { 240 240 ddf_msg(LVL_ERROR, "Cannot allocate read buffer."); … … 271 271 * 272 272 */ 273 static int write_blocks(ddf_fun_t *fun, uint64_t blocknum,273 static int ahci_write_blocks(ddf_fun_t *fun, uint64_t blocknum, 274 274 size_t count, void *buf) 275 275 { 276 276 sata_dev_t *sata = fun_sata_dev(fun); 277 277 278 uintptr_tphys;278 void *phys; 279 279 void *ibuf; 280 int rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB,281 AS_AREA_READ | AS_AREA_WRITE, 0, &phys,&ibuf);280 int rc = dmamem_map_anonymous(sata->block_size, AS_AREA_READ | AS_AREA_WRITE, 281 0, &phys, (void **) &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, uintptr_tphys)338 static void ahci_identify_device_cmd(sata_dev_t *sata, void *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, uintptr_tphys)383 static void ahci_identify_packet_device_cmd(sata_dev_t *sata, void *phys) 384 384 { 385 385 volatile sata_std_command_frame_t *cmd = … … 435 435 } 436 436 437 uintptr_tphys;437 void *phys; 438 438 sata_identify_data_t *idata; 439 439 int rc = dmamem_map_anonymous(SATA_IDENTIFY_DEVICE_BUFFER_LENGTH, 440 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys, 441 (void **) &idata); 440 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, (void **) &idata); 442 441 if (rc != EOK) { 443 442 ddf_msg(LVL_ERROR, "Cannot allocate buffer to identify device."); … … 562 561 * 563 562 */ 564 static void ahci_set_mode_cmd(sata_dev_t *sata, uintptr_tphys, uint8_t mode)563 static void ahci_set_mode_cmd(sata_dev_t *sata, void* phys, uint8_t mode) 565 564 { 566 565 volatile sata_std_command_frame_t *cmd = … … 568 567 569 568 cmd->fis_type = SATA_CMD_FIS_TYPE; 570 cmd->c = SATA_CMD_FIS_COMMAND_INDICATOR; 569 cmd->c = SATA_CMD_FIS_COMMAND_INDICATOR; 571 570 cmd->command = 0xef; 572 571 cmd->features = 0x03; … … 629 628 } 630 629 631 uintptr_tphys;630 void *phys; 632 631 sata_identify_data_t *idata; 633 632 int rc = dmamem_map_anonymous(SATA_SET_FEATURE_BUFFER_LENGTH, 634 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys, 635 (void **) &idata); 633 AS_AREA_READ | AS_AREA_WRITE, 0, &phys, (void **) &idata); 636 634 if (rc != EOK) { 637 635 ddf_msg(LVL_ERROR, "Cannot allocate buffer for device set mode."); … … 679 677 * 680 678 */ 681 static void ahci_rb_fpdma_cmd(sata_dev_t *sata, uintptr_t phys, 682 uint64_t blocknum) 679 static void ahci_rb_fpdma_cmd(sata_dev_t *sata, void *phys, uint64_t blocknum) 683 680 { 684 681 volatile sata_ncq_command_frame_t *cmd = … … 737 734 * 738 735 */ 739 static int ahci_rb_fpdma(sata_dev_t *sata, uintptr_tphys, uint64_t blocknum)736 static int ahci_rb_fpdma(sata_dev_t *sata, void *phys, uint64_t blocknum) 740 737 { 741 738 if (sata->is_invalid_device) { … … 766 763 * 767 764 */ 768 static void ahci_wb_fpdma_cmd(sata_dev_t *sata, uintptr_t phys, 769 uint64_t blocknum) 765 static void ahci_wb_fpdma_cmd(sata_dev_t *sata, void *phys, uint64_t blocknum) 770 766 { 771 767 volatile sata_ncq_command_frame_t *cmd = … … 825 821 * 826 822 */ 827 static int ahci_wb_fpdma(sata_dev_t *sata, uintptr_tphys, uint64_t blocknum)823 static int ahci_wb_fpdma(sata_dev_t *sata, void *phys, uint64_t blocknum) 828 824 { 829 825 if (sata->is_invalid_device) { … … 937 933 { 938 934 size_t size = 4096; 939 uintptr_t phys = 0;935 void *phys = NULL; 940 936 void *virt_fb = NULL; 941 937 void *virt_cmd = NULL; … … 953 949 954 950 /* Allocate and init retfis structure. */ 955 int rc = dmamem_map_anonymous(size, DMAMEM_4GiB,956 AS_AREA_READ | AS_AREA_WRITE, 0,&phys, &virt_fb);951 int rc = dmamem_map_anonymous(size, AS_AREA_READ | AS_AREA_WRITE, 0, 952 &phys, &virt_fb); 957 953 if (rc != EOK) 958 954 goto error_retfis; … … 963 959 964 960 /* Allocate and init command header structure. */ 965 rc = dmamem_map_anonymous(size, DMAMEM_4GiB,966 AS_AREA_READ | AS_AREA_WRITE, 0,&phys, &virt_cmd);961 rc = dmamem_map_anonymous(size, AS_AREA_READ | AS_AREA_WRITE, 0, 962 &phys, &virt_cmd); 967 963 if (rc != EOK) 968 964 goto error_cmd; … … 974 970 975 971 /* Allocate and init command table structure. */ 976 rc = dmamem_map_anonymous(size, DMAMEM_4GiB,977 AS_AREA_READ | AS_AREA_WRITE, 0,&phys, &virt_table);972 rc = dmamem_map_anonymous(size, AS_AREA_READ | AS_AREA_WRITE, 0, 973 &phys, &virt_table); 978 974 if (rc != EOK) 979 975 goto error_table; … … 1157 1153 ahci->memregs = NULL; 1158 1154 1159 physmem_map( RNGABS(hw_res_parsed.mem_ranges.ranges[0]),1155 physmem_map((void *) (size_t) (hw_res_parsed.mem_ranges.ranges[0].address), 1160 1156 AHCI_MEMREGS_PAGES_COUNT, AS_AREA_READ | AS_AREA_WRITE, 1161 1157 (void **) &ahci->memregs); … … 1164 1160 1165 1161 /* Register interrupt handler */ 1166 ahci_ranges[0].base = RNGABS(hw_res_parsed.mem_ranges.ranges[0]);1162 ahci_ranges[0].base = (size_t) hw_res_parsed.mem_ranges.ranges[0].address; 1167 1163 ahci_ranges[0].size = sizeof(ahci_memregs_t); 1168 1164 … … 1171 1167 1172 1168 ahci_cmds[base].addr = 1173 ((uint32_t *) RNGABSPTR(hw_res_parsed.mem_ranges.ranges[0])) +1169 ((uint32_t *) (size_t) hw_res_parsed.mem_ranges.ranges[0].address) + 1174 1170 AHCI_PORTS_REGISTERS_OFFSET + port * AHCI_PORT_REGISTERS_SIZE + 1175 1171 AHCI_PORT_IS_REGISTER_OFFSET; … … 1177 1173 1178 1174 ahci_cmds[base + 3].addr = 1179 ((uint32_t *) RNGABSPTR(hw_res_parsed.mem_ranges.ranges[0])) +1175 ((uint32_t *) (size_t) hw_res_parsed.mem_ranges.ranges[0].address) + 1180 1176 AHCI_GHC_IS_REGISTER_OFFSET; 1181 1177 ahci_cmds[base + 4].addr = ahci_cmds[base + 3].addr;
Note:
See TracChangeset
for help on using the changeset viewer.