Changeset 8ff0bd2 in mainline for uspace/srv/bd/ata_bd/ata_bd.c
- Timestamp:
- 2011-09-04T11:30:58Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 03bc76a
- Parents:
- d2c67e7 (diff), deac215e (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/ata_bd/ata_bd.c
rd2c67e7 r8ff0bd2 57 57 #include <stdint.h> 58 58 #include <str.h> 59 #include < devmap.h>59 #include <loc.h> 60 60 #include <sys/types.h> 61 61 #include <inttypes.h> … … 81 81 static const size_t identify_data_size = 512; 82 82 83 /** Size of the communication area. */84 static size_t comm_size;85 86 83 /** I/O base address of the command registers. */ 87 84 static uintptr_t cmd_physical; … … 105 102 static void print_syntax(void); 106 103 static int ata_bd_init(void); 107 static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall );104 static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall, void *); 108 105 static int ata_bd_read_blocks(int disk_id, uint64_t ba, size_t cnt, 109 106 void *buf); … … 122 119 static int ata_pcmd_read_12(int dev_idx, uint64_t ba, size_t cnt, 123 120 void *obuf, size_t obuf_size); 121 static int ata_pcmd_read_toc(int dev_idx, uint8_t ses, 122 void *obuf, size_t obuf_size); 124 123 static void disk_print_summary(disk_t *d); 125 124 static int coord_calc(disk_t *d, uint64_t ba, block_coord_t *bc); … … 179 178 180 179 snprintf(name, 16, "%s/ata%udisk%d", NAMESPACE, ctl_num, i); 181 rc = devmap_device_register(name, &disk[i].devmap_handle);180 rc = loc_service_register(name, &disk[i].service_id); 182 181 if (rc != EOK) { 183 182 printf(NAME ": Unable to register device %s.\n", name); … … 247 246 int rc; 248 247 249 rc = devmap_driver_register(NAME, ata_bd_connection);248 rc = loc_server_register(NAME, ata_bd_connection); 250 249 if (rc < 0) { 251 250 printf(NAME ": Unable to register driver.\n"); … … 274 273 275 274 /** Block device connection handler */ 276 static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall )275 static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 277 276 { 278 277 void *fs_va = NULL; … … 280 279 ipc_call_t call; 281 280 sysarg_t method; 282 devmap_handle_t dh; 281 service_id_t dsid; 282 size_t comm_size; /**< Size of the communication area. */ 283 283 unsigned int flags; 284 284 int retval; … … 287 287 int disk_id, i; 288 288 289 /* Get the device handle. */290 d h= IPC_GET_ARG1(*icall);289 /* Get the device service ID. */ 290 dsid = IPC_GET_ARG1(*icall); 291 291 292 292 /* Determine which disk device is the client connecting to. */ 293 293 disk_id = -1; 294 294 for (i = 0; i < MAX_DISKS; i++) 295 if (disk[i]. devmap_handle == dh)295 if (disk[i].service_id == dsid) 296 296 disk_id = i; 297 297 … … 355 355 UPPER32(disk[disk_id].blocks)); 356 356 continue; 357 case BD_READ_TOC: 358 cnt = IPC_GET_ARG1(call); 359 if (disk[disk_id].dev_type == ata_pkt_dev) 360 retval = ata_pcmd_read_toc(disk_id, cnt, fs_va, 361 disk[disk_id].block_size); 362 else 363 retval = EINVAL; 364 break; 357 365 default: 358 366 retval = EINVAL; … … 812 820 } 813 821 822 /** Issue ATAPI read TOC command. 823 * 824 * Read TOC in 'multi-session' format (first and last session number 825 * with last session LBA). 826 * 827 * http://suif.stanford.edu/~csapuntz/specs/INF-8020.PDF page 171 828 * 829 * Output buffer must be large enough to hold the data, otherwise the 830 * function will fail. 831 * 832 * @param dev_idx Device index (0 or 1) 833 * @param session Starting session 834 * @param obuf Buffer for storing inquiry data read from device 835 * @param obuf_size Size of obuf in bytes 836 * 837 * @return EOK on success, EIO on error. 838 */ 839 static int ata_pcmd_read_toc(int dev_idx, uint8_t session, void *obuf, 840 size_t obuf_size) 841 { 842 ata_pcmd_read_toc_t cp; 843 int rc; 844 845 memset(&cp, 0, sizeof(cp)); 846 847 cp.opcode = PCMD_READ_TOC; 848 cp.msf = 0; 849 cp.format = 0x01; /* 0x01 = multi-session mode */ 850 cp.start = session; 851 cp.size = host2uint16_t_be(obuf_size); 852 cp.oldformat = 0x40; /* 0x01 = multi-session mode (shifted to MSB) */ 853 854 rc = ata_cmd_packet(0, &cp, sizeof(cp), obuf, obuf_size); 855 if (rc != EOK) 856 return rc; 857 858 return EOK; 859 } 860 814 861 /** Read a physical from the device. 815 862 *
Note:
See TracChangeset
for help on using the changeset viewer.