LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Find Resources
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Openrisc > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: György 'nog' Jeney<nog@s...>
    Date: Fri May 20 20:59:07 CEST 2005
    Subject: [openrisc] [or1ksim #89] Make ata peripheral use the new debugging functions
    Top
    Hi,

    It is unreasonable to have every seporate unit in or1ksim to code it's own
    debugging functions (atleast the cuc has its own aswell), therefore I have
    removed ata_debug_something and the MSG_* macros infavour of the new debugging
    scheme.

    ChangeLog:
    * Make the ata peripheral use the new debugging functions.

    nog.
    -------------- next part --------------
    diff -upr --unidirectional-new-file peripheral/atadevice.c /home/nog/or1ksim-ac/peripheral/atadevice.c
    --- peripheral/atadevice.c 2005-05-20 20:52:32.000000000 +0200
    +++ /home/nog/or1ksim-ac/peripheral/atadevice.c 2005-05-20 20:52:21.000000000 +0200
    @@ -33,12 +33,15 @@
    #include "arch.h"
    #include "abstract.h"

    -#include "messages.h"
    #include "atadevice.h"
    #include "atacmd.h"
    #include "sim-config.h"
    #include "atadevice_cmdi.h"

    +#include "debug.h"
    +
    +DEFAULT_DEBUG_CHANNEL(ata);
    +
    /*
    mandatory commands:
    - execute device diagnostics (done)
    @@ -92,23 +95,22 @@ void ata_device_init(ata_device *device,
    switch(device->type)
    {
    case TYPE_NO_CONNECT:
    - MSG_NOTE("ata_device, using type NO_CONNECT.");
    + TRACE("ata_device, using type NO_CONNECT.\n");
    device->stream = NULL;
    break;

    case TYPE_FILE:
    - MSG_NOTE("ata_device, using device type FILE.");
    + TRACE("ata_device, using device type FILE.\n");
    device->stream = open_file(&device->size, device->file);
    break;

    case TYPE_LOCAL:
    - MSG_NOTE("ata_device, using device type LOCAL.");
    + TRACE("ata_device, using device type LOCAL.\n");
    device->stream = open_local();
    break;

    default:
    - MSG_FATAL("ata_device, illegal device-type.");
    - MSG_EMPTY("defaulting to type NO_CONNECT.");
    + ERR("Illegal device-type. Defaulting to type NO_CONNECT.\n");
    device->stream = NULL;
    break;
    }
    @@ -126,15 +128,15 @@ FILE *open_file(unsigned long *size, con
    if ( !(fp = fopen(filename, "rb+")) )
    if ( !(fp = fopen(filename, "wb+")) )
    {
    - MSG_FATAL( strcat("ata_open_file, cannot open hd-file ", filename) );
    + ERR( "ata_open_file, cannot open hd-file %s\n", filename );
    return NULL;
    }
    else
    {
    /* TODO create a file 'size' large */
    /* create a file 'size' large */
    - MSG_NOTE("ata_device; generating a new hard disk file.");
    - MSG_EMPTY("This may take a while, depending on the requested size.");
    + TRACE("ata_device; generating a new hard disk file.\n");
    + TRACE("This may take a while, depending on the requested size.\n");
    for (n=0; n < (*size << 20); n++)
    fputc(0, fp);
    }
    @@ -142,13 +144,13 @@ FILE *open_file(unsigned long *size, con
    fprintf(stderr, "file %s already exists. Using existing file.\n", filename);


    - ata_device_debug(1, "requested filesize was: %d (MBytes).\n", *size);
    + TRACE("requested filesize was: %ld (MBytes).\n", *size);

    /* get the size of the file. This is also the size of the harddisk*/
    fseek(fp, 0, SEEK_END);
    *size = ftell(fp);

    - ata_device_debug(1, "actual filesize is: %d (MBytes).\n", *size >> 20);
    + TRACE("actual filesize is: %ld (MBytes).\n", *size >> 20);

    return fp;
    }
    @@ -158,8 +160,7 @@ FILE *open_file(unsigned long *size, con
    FILE *open_local(void)
    {
    // TODO:
    - MSG_WARNING("ata_device; device type LOCAL is not supported yet.");
    - MSG_EMPTY("defaulting to device type NO_CONNECT.");
    + FIXME("Device type LOCAL is not yet supported. Defaulting to device type NO_CONNECT.");
    return NULL; } @@ -173,7 +174,7 @@ FILE *open_local(void) void ata_devices_hw_reset(ata_devices *devices, int reset_signal) { /* display debug information */ - ata_device_debug(2, "ata_devices_hw_reset.\n"); + TRACE("ata_devices_hw_reset.\n"); /* find device 0 */ if ( (devices->device0.stream) && (devices->device1.stream) ) @@ -211,7 +212,7 @@ void ata_devices_hw_reset(ata_devices *d else { /* no devices connected */ - ata_device_debug(1, "ata_device_hw_reset, no devices connected.\n"); + TRACE("ata_device_hw_reset, no devices connected.\n"); } } @@ -297,7 +298,7 @@ void ata_device_do_control_register(ata_ device->internals.state = ATA_STATE_SW_RST; /* display debug information */ - ata_device_debug(2, "ata_device_sw_reset initiated.\n"); + TRACE("ata_device_sw_reset initiated.\n"); } } else if (device->internals.state == ATA_STATE_SW_RST) @@ -318,7 +319,7 @@ void ata_device_do_control_register(ata_ device->internals.state = ATA_STATE_IDLE; /* display debug information */ - ata_device_debug(2, "ata_device_sw_reset done.\n"); + TRACE("ata_device_sw_reset done.\n"); } /* <else> We are doing a hardware reset (or similar) @@ -335,7 +336,7 @@ void ata_device_do_command_register(ata_ /* check BSY & DRQ */ if ( (device->regs.status & ATA_SR_BSY) || (device->regs.status & ATA_SR_DRQ) ) if (device->regs.command != DEVICE_RESET) - MSG_WARNING("ata_device_write, writing a command while BSY or DRQ asserted."); + WARN("ata_device_write, writing a command while BSY or DRQ asserted."); /* check if device selected */ if ( (device->regs.device_head & ATA_DHR_DEV) == device->internals.dev ) @@ -359,7 +360,7 @@ short ata_devices_read(ata_devices *devi /* check for no connected devices */ if ( (!devices->device0.stream) && (!devices->device1.stream) ) - MSG_ERROR("ata_devices_read, no ata devices connected."); + ERR("ata_devices_read, no ata devices connected.\n"); else { /* check if both device0 and device1 are connected */ @@ -383,67 +384,67 @@ short ata_devices_read(ata_devices *devi /* return data provided by selected device */ switch (adr) { case ATA_ASR : - ata_device_debug(4, "alternate_status register read\n"); + TRACE("alternate_status register read\n"); if ( (device->regs.device_head & ATA_DHR_DEV) == device->internals.dev ) return device -> regs.status; else { - ata_device_debug(2, "device0 responds for device1, asr = 0x00\n"); + TRACE("device0 responds for device1, asr = 0x00\n"); return 0; // return 0 when device0 responds for device1 } case ATA_CHR : - ata_device_debug(4, "cylinder_high register read, value = 0x%02X\n", - device->regs.cylinder_high); + TRACE("cylinder_high register read, value = 0x%02X\n", + device->regs.cylinder_high); return device -> regs.cylinder_high; case ATA_CLR : - ata_device_debug(4, "cylinder_low register read, value = 0x%02X\n", + TRACE("cylinder_low register read, value = 0x%02X\n", device->regs.cylinder_low); return device -> regs.cylinder_low; case ATA_DR : if (!device->regs.status & ATA_SR_DRQ) { - ata_device_debug(1, "data register read, while DRQ bit negated\n" ); + TRACE("data register read, while DRQ bit negated\n" ); return 0; } else { - ata_device_debug(4, "data register read, value = 0x%04X, cnt = %3d\n", - *device->internals.dbuf_ptr, device->internals.dbuf_cnt); + TRACE("data register read, value = 0x%04X, cnt = %3d\n", + *device->internals.dbuf_ptr, device->internals.dbuf_cnt); if (!--device->internals.dbuf_cnt) device->regs.status &= ~ATA_SR_DRQ; return *device -> internals.dbuf_ptr++; } case ATA_DHR : - ata_device_debug(4, "device_head register read, value = 0x%02X\n", + TRACE("device_head register read, value = 0x%02X\n", device->regs.device_head); return device -> regs.device_head; case ATA_ERR : - ata_device_debug(4, "error register read, value = 0x%02X\n", + TRACE("error register read, value = 0x%02X\n", device->regs.error); return device -> regs.error; case ATA_SCR : - ata_device_debug(4, "sectorcount register read, value = 0x%02X\n", + TRACE("sectorcount register read, value = 0x%02X\n", device->regs.sector_count); return device -> regs.sector_count; case ATA_SNR : - ata_device_debug(4, "sectornumber register read, value = 0x%02X\n", + TRACE("sectornumber register read, value = 0x%02X\n", device->regs.sector_number); return device -> regs.sector_number; case ATA_SR : - ata_device_debug(4, "status register read\n"); + TRACE("status register read\n"); if ( (device->regs.device_head & ATA_DHR_DEV) == device->internals.dev) return device -> regs.status; else { - ata_device_debug(2, "device0 responds for device1, sr = 0x00\n"); + TRACE("device0 responds for device1, sr = 0x00\n"); return 0; // return 0 when device0 responds for device1 } @@ -462,7 +463,7 @@ void ata_devices_write(ata_devices *devi { /* check for no connected devices */ if (!devices->device0.stream && !devices->device1.stream) - MSG_ERROR("ata_devices_write, no ata devices connected."); + ERR("ata_devices_write, no ata devices connected.\n"); else { /* first device */ @@ -481,7 +482,7 @@ void ata_device_write(ata_device *device switch (adr) { case ATA_CR : /*display debug information */ - ata_device_debug(4, "command register written, value = 0x%02X\n", value); + TRACE("command register written, value = 0x%02X\n", value); device->regs.command = value; @@ -492,28 +493,28 @@ void ata_device_write(ata_device *device case ATA_CHR : /*display debug information */ - ata_device_debug(4, "cylinder high register written, value = 0x%02X\n", value); + TRACE("cylinder high register written, value = 0x%02X\n", value); device->regs.cylinder_high = value; break; case ATA_CLR : /*display debug information */ - ata_device_debug(4, "cylinder low register written, value = 0x%02X\n", value); + TRACE("cylinder low register written, value = 0x%02X\n", value); device->regs.cylinder_low = value; break; case ATA_DR : /*display debug information */ - ata_device_debug(4, "data register written, value = 0x%04X\n", value); + TRACE("data register written, value = 0x%04X\n", value); device->regs.dataport_i = value; break; case ATA_DCR : /*display debug information */ - ata_device_debug(4, "device control register written, value = 0x%02X\n", value); + TRACE("device control register written, value = 0x%02X\n", value); device->regs.device_control = value; ata_device_do_control_register(device); @@ -521,28 +522,28 @@ void ata_device_write(ata_device *device case ATA_DHR : /*display debug information */ - ata_device_debug(4, "device head register written, value = 0x%02X\n", value); + TRACE("device head register written, value = 0x%02X\n", value); device->regs.device_head = value; break; case ATA_FR : /*display debug information */ - ata_device_debug(4, "features register written, value = 0x%02X\n", value); + TRACE("features register written, value = 0x%02X\n", value); device->regs.features = value; break; case ATA_SCR : /*display debug information */ - ata_device_debug(4, "sectorcount register written, value = 0x%02X\n", value); + TRACE("sectorcount register written, value = 0x%02X\n", value); device->regs.sector_count = value; break; case ATA_SNR : /*display debug information */ - ata_device_debug(4, "sectornumber register written, value = 0x%02X\n", value); + TRACE("sectornumber register written, value = 0x%02X\n", value); device->regs.sector_number = value; break; @@ -550,22 +551,3 @@ void ata_device_write(ata_device *device } //endcase } - -/* -------------------------- */ -/* -- print debug messages -- */ -/* -------------------------- */ -int ata_device_debug(int lvl, char *format, ...) -{ - va_list ap; - - va_start(ap, format); - - if (ATA_DEVICE_DEBUG_LVL >= lvl) - { - fprintf(stderr, "ata_device_debug: "); - vfprintf(stderr, format, ap); - } - - va_end(ap); - return 0; -} diff -upr --unidirectional-new-file peripheral/atadevice.h /home/nog/or1ksim-ac/peripheral/atadevice.h --- peripheral/atadevice.h 2005-05-20 20:52:32.000000000 +0200 +++ /home/nog/or1ksim-ac/peripheral/atadevice.h 2005-05-20 20:36:32.000000000 +0200 @@ -28,17 +28,6 @@ #include <stdio.h> -/* - ata device debug level - 0: don't display debug information - 1: display general (debug) information - 2: display program flow control information - 3: display internal statemachine flow information - 4: display all debug information -*/ -#define ATA_DEVICE_DEBUG_LVL 4 - - /* --- Register definitions --- */ /* ----- ATA Registers */ /* These are actually the memory locations where the ATA registers */ @@ -189,11 +178,6 @@ typedef struct{ } ata_devices; -/* ------------------------------ */ -/* ----- Device Prototypes ----- */ -/* ------------------------------ */ -int ata_device_debug(int lvl, char *format, ...); - /* all devices */ void ata_devices_init(ata_devices *devices); void ata_devices_hw_reset(ata_devices *devices, int reset_signal); diff -upr --unidirectional-new-file peripheral/atadevice_cmdi.c /home/nog/or1ksim-ac/peripheral/atadevice_cmdi.c --- peripheral/atadevice_cmdi.c 2005-05-20 20:52:32.000000000 +0200 +++ /home/nog/or1ksim-ac/peripheral/atadevice_cmdi.c 2005-05-20 20:41:19.000000000 +0200 @@ -26,15 +26,19 @@ #include <string.h> -#include "messages.h" #include "atadevice.h" #include "atadevice_cmdi.h" #include "atacmd.h" +#include "debug.h" + +DEFAULT_DEBUG_CHANNEL(ata); + int ata_device_execute_cmd(ata_device *device) { /*display debug information */ - ata_device_debug(2, "ata_device_execute_command called with command = 0x%02X\n", device->regs.command); + TRACE("ata_device_execute_command called with command = 0x%02X\n", + device->regs.command); /* execute the commands */ switch (device->regs.command) { @@ -98,10 +102,10 @@ void ata_set_device_signature(ata_device void ata_device_reset_cmd(ata_device *device) { /* print debug information */ - ata_device_debug(2, "executing command 'device reset'\n"); + TRACE("executing command 'device reset'\n"); if (!device->packet) - MSG_WARNING("executing DEVICE_RESET on non-packet device."); + WARN("executing DEVICE_RESET on non-packet device."); ata_execute_device_diagnostics_cmd(device); } @@ -113,7 +117,7 @@ void ata_device_reset_cmd(ata_device *de void ata_execute_device_diagnostics_cmd(ata_device *device) { /* print debug information */ - ata_device_debug(2, "executing command 'execute_device_diagnostics'\n"); + TRACE("executing command 'execute_device_diagnostics'\n"); /* clear SRST bit, if set */ device->regs.device_control &= ~ATA_DCR_RST; @@ -171,7 +175,7 @@ void ata_identify_device_cmd(ata_device unsigned int tmp; /* print debug information */ - ata_device_debug(2, "ata_device executing command 'identify device'\n"); + TRACE("ata_device executing command 'identify device'\n"); /* reset databuffer */ device->internals.dbuf_cnt = 256; @@ -244,7 +248,7 @@ void ata_identify_device_cmd(ata_device Respond by placing PACKET Command feature set signature in block registers. Abort command. */ - ata_device_debug(1, "'identify_device' command: This is a PACKET device\n"); + TRACE("'identify_device' command: This is a PACKET device\n"); ata_set_device_signature(device, PACKET_SIGNATURE); device->regs.status = ATA_SR_ERR; @@ -836,7 +840,7 @@ void ata_identify_device_cmd(ata_device void ata_initialize_device_parameters_cmd(ata_device *device) { /* print debug information */ - ata_device_debug(2, "executing command 'initialize device parameters'\n"); + TRACE("executing command 'initialize device parameters'\n"); device->internals.sectors_per_track = device->regs.sector_count; device->internals.heads_per_cylinder = device->regs.device_head & ATA_DHR_H; @@ -855,7 +859,7 @@ void ata_read_sectors_cmd(ata_device *de unsigned long lba; /* print debug information */ - ata_device_debug(2, "executing command 'read sectors'\n"); + TRACE("executing command 'read sectors'\n"); /* check if this is a NON-PACKET device */ if (device->packet) @@ -865,7 +869,7 @@ void ata_read_sectors_cmd(ata_device *de Respond by placing PACKET Command feature set signature in block registers. Abort command. */ - ata_device_debug(1, "'identify_device' command: This is a PACKET device\n"); + TRACE("'identify_device' command: This is a PACKET device\n"); ata_set_device_signature(device, PACKET_SIGNATURE); device->regs.status = ATA_SR_ERR; diff -upr --unidirectional-new-file peripheral/atahost.c /home/nog/or1ksim-ac/peripheral/atahost.c --- peripheral/atahost.c 2005-05-20 20:52:32.000000000 +0200 +++ /home/nog/or1ksim-ac/peripheral/atahost.c 2005-05-20 20:41:30.000000000 +0200 @@ -37,7 +37,6 @@ /* all user defineable settings are in 'atahost_define.h' */ #include "atahost_define.h" #include "atahost.h" -#include "messages.h" /* reset and initialize ATA host core(s) */ void ata_reset(void *dat) --- support/dbchs.h 2005-05-20 20:52:32.000000000 +0200 +++ ../or1ksim-ac/support/dbchs.h 2005-05-20 20:49:12.000000000 +0200 @@ -27,3 +27,4 @@ DECLARE_DEBUG_CHANNEL(uart) DECLARE_DEBUG_CHANNEL(eth) DECLARE_DEBUG_CHANNEL(config) +DECLARE_DEBUG_CHANNEL(ata) --- peripheral/messages.h 2005-05-20 20:52:32.000000000 +0200 +++ /dev/null 2003-01-07 18:22:11.000000000 +0100 @@ -1,36 +0,0 @@ -/* - messages.h - Copyright (C) 2002 Richard Herveille, rherveille@o... - - This file is part of OpenRISC 1000 Architectural Simulator - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* - * macros for generating standard messages - */ - -#ifndef __OR1KSIM_MESSAGES_H -#define __OR1KSIM_MESSAGES_H - -#define MSG_DEBUG(message) fprintf(stderr, "DEBUG : %s\n", message) -#define MSG_EMPTY(message) fprintf(stderr, " %s\n", message) -#define MSG_ERROR(message) fprintf(stderr, "ERROR : %s\n", message) -#define MSG_FATAL(message) fprintf(stderr, "FATAL : %s\n", message) -#define MSG_NOTE(message) fprintf(stderr, "NOTE : %s\n", message) -#define MSG_WARNING(message) fprintf(stderr, "WARNING: %s\n", message) - -#endif

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.