Changeset b0f00a9 in mainline for uspace/srv/bd/ata_bd/ata_bd.c
- Timestamp:
- 2011-11-06T22:21:05Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 898e847
- Parents:
- 2bdf8313 (diff), 7b5f4c9 (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
-
uspace/srv/bd/ata_bd/ata_bd.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/ata_bd/ata_bd.c
r2bdf8313 rb0f00a9 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 … … 317 317 (void) async_share_out_finalize(callid, fs_va); 318 318 319 while ( 1) {319 while (true) { 320 320 callid = async_get_call(&call); 321 321 method = IPC_GET_IMETHOD(call); 322 switch (method) {323 case IPC_M_PHONE_HUNGUP:322 323 if (!method) { 324 324 /* The other side has hung up. */ 325 325 async_answer_0(callid, EOK); 326 326 return; 327 } 328 329 switch (method) { 327 330 case BD_READ_BLOCKS: 328 331 ba = MERGE_LOUP32(IPC_GET_ARG1(call), … … 352 355 UPPER32(disk[disk_id].blocks)); 353 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; 354 365 default: 355 366 retval = EINVAL; … … 809 820 } 810 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 811 861 /** Read a physical from the device. 812 862 *
Note:
See TracChangeset
for help on using the changeset viewer.
