Changeset 9f391e9 in mainline
- Timestamp:
- 2013-06-27T17:02:39Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3de67b4c
- Parents:
- 257feec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/ata_bd/ata_bd.c
r257feec r9f391e9 48 48 */ 49 49 50 #include <stdio.h>51 50 #include <ddi.h> 51 #include <ddf/log.h> 52 52 #include <async.h> 53 53 #include <as.h> … … 61 61 #include <errno.h> 62 62 #include <stdbool.h> 63 #include <stdio.h> 63 64 #include <byteorder.h> 64 65 #include <task.h> … … 150 151 unsigned ctl_num; 151 152 152 printf(NAME ": ata_ctrl_init()\n");153 ddf_msg(LVL_DEBUG, "ata_ctrl_init()"); 153 154 154 155 ctl_num = 1; … … 158 159 ctrl->ctl_physical = legacy_base[ctl_num - 1].ctl; 159 160 160 printf("I/O address %p/%p\n", (void *) ctrl->cmd_physical,161 ddf_msg(LVL_NOTE, "I/O address %p/%p", (void *) ctrl->cmd_physical, 161 162 (void *) ctrl->ctl_physical); 162 163 … … 166 167 167 168 for (i = 0; i < MAX_DISKS; i++) { 168 printf("Identify drive %d... ", i); 169 fflush(stdout); 169 ddf_msg(LVL_NOTE, "Identify drive %d...", i); 170 170 171 171 rc = disk_init(ctrl, &ctrl->disk[i], i); … … 174 174 disk_print_summary(&ctrl->disk[i]); 175 175 } else { 176 printf("Not found.\n");176 ddf_msg(LVL_NOTE, "Not found."); 177 177 } 178 178 } … … 187 187 rc = ata_fun_create(&ctrl->disk[i]); 188 188 if (rc != EOK) { 189 printf(NAME ": Unable to create function for disk %d.\n",190 i);189 ddf_msg(LVL_ERROR, "Unable to create function for " 190 "disk %d.", i); 191 191 goto error; 192 192 } … … 195 195 196 196 if (n_disks == 0) { 197 printf("No disks detected.\n");197 ddf_msg(LVL_WARN, "No disks detected."); 198 198 rc = EIO; 199 199 goto error; … … 204 204 for (i = 0; i < MAX_DISKS; i++) { 205 205 if (ata_fun_remove(&ctrl->disk[i]) != EOK) { 206 printf(NAME ": Unable to clean up function for disk %d.\n",207 i);206 ddf_msg(LVL_ERROR, "Unable to clean up function for " 207 "disk %d.", i); 208 208 } 209 209 } … … 217 217 int i, rc; 218 218 219 printf(NAME ": ata_ctrl_remove()\n");219 ddf_msg(LVL_DEBUG, ": ata_ctrl_remove()"); 220 220 221 221 fibril_mutex_lock(&ctrl->lock); … … 224 224 rc = ata_fun_remove(&ctrl->disk[i]); 225 225 if (rc != EOK) { 226 printf(NAME ": Unable to clean up function for disk %d.\n",227 i);226 ddf_msg(LVL_ERROR, "Unable to clean up function for " 227 "disk %d.", i); 228 228 return rc; 229 229 } … … 241 241 int i, rc; 242 242 243 printf(NAME ": ata_ctrl_gone()\n");243 ddf_msg(LVL_DEBUG, "ata_ctrl_gone()"); 244 244 245 245 fibril_mutex_lock(&ctrl->lock); … … 248 248 rc = ata_fun_unbind(&ctrl->disk[i]); 249 249 if (rc != EOK) { 250 printf(NAME ": Unable to clean up function for disk %d.\n",251 i);250 ddf_msg(LVL_ERROR, "Unable to clean up function for " 251 "disk %d.", i); 252 252 return rc; 253 253 } … … 264 264 { 265 265 uint64_t mbytes; 266 267 printf("%s: ", d->model); 266 char *atype = NULL; 267 char *cap = NULL; 268 int rc; 268 269 269 270 if (d->dev_type == ata_reg_dev) { 270 271 switch (d->amode) { 271 272 case am_chs: 272 printf("CHS %u cylinders, %u heads, %u sectors",273 d->geom.cylinders, d->geom.heads,273 rc = asprintf(&atype, "CHS %u cylinders, %u heads, " 274 "%u sectors", d->geom.cylinders, d->geom.heads, 274 275 d->geom.sectors); 276 if (rc < 0) { 277 /* Out of memory */ 278 atype = NULL; 279 } 275 280 break; 276 281 case am_lba28: 277 printf("LBA-28");282 atype = str_dup("LBA-28"); 278 283 break; 279 284 case am_lba48: 280 printf("LBA-48");285 atype = str_dup("LBA-48"); 281 286 break; 282 287 } 283 288 } else { 284 printf("PACKET"); 285 } 286 287 printf(" %" PRIu64 " blocks", d->blocks); 289 atype = str_dup("PACKET"); 290 } 291 292 if (atype == NULL) 293 return; 288 294 289 295 mbytes = d->blocks / (2 * 1024); 290 if (mbytes > 0) 291 printf(" %" PRIu64 " MB.", mbytes); 292 293 printf("\n"); 296 if (mbytes > 0) { 297 rc = asprintf(&cap, " %" PRIu64 " MB.", mbytes); 298 if (rc < 0) { 299 cap = NULL; 300 goto cleanup; 301 } 302 } 303 304 ddf_msg(LVL_NOTE, "%s: %s %" PRIu64 " blocks%s", d->model, atype, 305 d->blocks, cap); 306 cleanup: 307 free(atype); 308 free(cap); 294 309 } 295 310 … … 302 317 rc = pio_enable((void *) ctrl->cmd_physical, sizeof(ata_cmd_t), &vaddr); 303 318 if (rc != EOK) { 304 printf("%s: Could not initialize device I/O space.\n", NAME);319 ddf_msg(LVL_ERROR, "Cannot initialize device I/O space."); 305 320 return rc; 306 321 } … … 310 325 rc = pio_enable((void *) ctrl->ctl_physical, sizeof(ata_ctl_t), &vaddr); 311 326 if (rc != EOK) { 312 printf("%s: Could not initialize device I/O space.\n", NAME);327 ddf_msg(LVL_ERROR, "Cannot initialize device I/O space."); 313 328 return rc; 314 329 } … … 352 367 if (rc == EOK) { 353 368 /* Success. It's a register (non-packet) device. */ 354 printf("ATA register-only device found.\n");369 ddf_msg(LVL_NOTE, "ATA register-only device found."); 355 370 d->dev_type = ata_reg_dev; 356 371 } else if (rc == EIO) { … … 455 470 rc = ata_pcmd_inquiry(d, &inq_data, sizeof(inq_data)); 456 471 if (rc != EOK) { 457 printf("Device inquiry failed.\n");472 ddf_msg(LVL_ERROR, "Device inquiry failed."); 458 473 d->present = false; 459 474 return EIO; … … 462 477 /* Check device type. */ 463 478 if (INQUIRY_PDEV_TYPE(inq_data.pdev_type) != PDEV_TYPE_CDROM) 464 printf("Warning: Peripheral device type is not CD-ROM.\n");479 ddf_msg(LVL_WARN, "Peripheral device type is not CD-ROM."); 465 480 466 481 /* Assume 2k block size for now. */
Note:
See TracChangeset
for help on using the changeset viewer.