Changeset 9f391e9 in mainline for uspace/drv/block/ata_bd/ata_bd.c


Ignore:
Timestamp:
2013-06-27T17:02:39Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3de67b4c
Parents:
257feec
Message:

ata_bd should use ddf_msg().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/block/ata_bd/ata_bd.c

    r257feec r9f391e9  
    4848 */
    4949
    50 #include <stdio.h>
    5150#include <ddi.h>
     51#include <ddf/log.h>
    5252#include <async.h>
    5353#include <as.h>
     
    6161#include <errno.h>
    6262#include <stdbool.h>
     63#include <stdio.h>
    6364#include <byteorder.h>
    6465#include <task.h>
     
    150151        unsigned ctl_num;
    151152
    152         printf(NAME ": ata_ctrl_init()\n");
     153        ddf_msg(LVL_DEBUG, "ata_ctrl_init()");
    153154
    154155        ctl_num = 1;
     
    158159        ctrl->ctl_physical = legacy_base[ctl_num - 1].ctl;
    159160
    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,
    161162            (void *) ctrl->ctl_physical);
    162163
     
    166167
    167168        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);
    170170
    171171                rc = disk_init(ctrl, &ctrl->disk[i], i);
     
    174174                        disk_print_summary(&ctrl->disk[i]);
    175175                } else {
    176                         printf("Not found.\n");
     176                        ddf_msg(LVL_NOTE, "Not found.");
    177177                }
    178178        }
     
    187187                rc = ata_fun_create(&ctrl->disk[i]);
    188188                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);
    191191                        goto error;
    192192                }
     
    195195
    196196        if (n_disks == 0) {
    197                 printf("No disks detected.\n");
     197                ddf_msg(LVL_WARN, "No disks detected.");
    198198                rc = EIO;
    199199                goto error;
     
    204204        for (i = 0; i < MAX_DISKS; i++) {
    205205                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);
    208208                }
    209209        }
     
    217217        int i, rc;
    218218
    219         printf(NAME ": ata_ctrl_remove()\n");
     219        ddf_msg(LVL_DEBUG, ": ata_ctrl_remove()");
    220220
    221221        fibril_mutex_lock(&ctrl->lock);
     
    224224                rc = ata_fun_remove(&ctrl->disk[i]);
    225225                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);
    228228                        return rc;
    229229                }
     
    241241        int i, rc;
    242242
    243         printf(NAME ": ata_ctrl_gone()\n");
     243        ddf_msg(LVL_DEBUG, "ata_ctrl_gone()");
    244244
    245245        fibril_mutex_lock(&ctrl->lock);
     
    248248                rc = ata_fun_unbind(&ctrl->disk[i]);
    249249                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);
    252252                        return rc;
    253253                }
     
    264264{
    265265        uint64_t mbytes;
    266 
    267         printf("%s: ", d->model);
     266        char *atype = NULL;
     267        char *cap = NULL;
     268        int rc;
    268269
    269270        if (d->dev_type == ata_reg_dev) {
    270271                switch (d->amode) {
    271272                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,
    274275                            d->geom.sectors);
     276                        if (rc < 0) {
     277                                /* Out of memory */
     278                                atype = NULL;
     279                        }
    275280                        break;
    276281                case am_lba28:
    277                         printf("LBA-28");
     282                        atype = str_dup("LBA-28");
    278283                        break;
    279284                case am_lba48:
    280                         printf("LBA-48");
     285                        atype = str_dup("LBA-48");
    281286                        break;
    282287                }
    283288        } 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;
    288294
    289295        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);
     306cleanup:
     307        free(atype);
     308        free(cap);
    294309}
    295310
     
    302317        rc = pio_enable((void *) ctrl->cmd_physical, sizeof(ata_cmd_t), &vaddr);
    303318        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.");
    305320                return rc;
    306321        }
     
    310325        rc = pio_enable((void *) ctrl->ctl_physical, sizeof(ata_ctl_t), &vaddr);
    311326        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.");
    313328                return rc;
    314329        }
     
    352367        if (rc == EOK) {
    353368                /* 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.");
    355370                d->dev_type = ata_reg_dev;
    356371        } else if (rc == EIO) {
     
    455470                rc = ata_pcmd_inquiry(d, &inq_data, sizeof(inq_data));
    456471                if (rc != EOK) {
    457                         printf("Device inquiry failed.\n");
     472                        ddf_msg(LVL_ERROR, "Device inquiry failed.");
    458473                        d->present = false;
    459474                        return EIO;
     
    462477                /* Check device type. */
    463478                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.");
    465480
    466481                /* Assume 2k block size for now. */
Note: See TracChangeset for help on using the changeset viewer.