OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [peripheral/] [atadevice_cmdi.c] - Diff between revs 1308 and 1488

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1308 Rev 1488
Line 24... Line 24...
 For fun, count the number of FIXMEs :-(
 For fun, count the number of FIXMEs :-(
*/
*/
 
 
#include <string.h>
#include <string.h>
 
 
#include "messages.h"
 
#include "atadevice.h"
#include "atadevice.h"
#include "atadevice_cmdi.h"
#include "atadevice_cmdi.h"
#include "atacmd.h"
#include "atacmd.h"
 
 
 
#include "debug.h"
 
 
 
DEFAULT_DEBUG_CHANNEL(ata);
 
 
int ata_device_execute_cmd(ata_device *device)
int ata_device_execute_cmd(ata_device *device)
{
{
  /*display debug information                                         */
  /*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 */
  /* execute the commands */
  switch (device->regs.command) {
  switch (device->regs.command) {
 
 
      case DEVICE_RESET :
      case DEVICE_RESET :
Line 96... Line 100...
  A T A _ D E V I C E _ R E S E T
  A T A _ D E V I C E _ R E S E T
*/
*/
void ata_device_reset_cmd(ata_device *device)
void ata_device_reset_cmd(ata_device *device)
{
{
  /* print debug information                                          */
  /* print debug information                                          */
  ata_device_debug(2, "executing command 'device reset'\n");
  TRACE("executing command 'device reset'\n");
 
 
  if (!device->packet)
  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);
  ata_execute_device_diagnostics_cmd(device);
}
}
 
 
 
 
Line 111... Line 115...
  A T A _ E X E C U T E _ D E V I C E _ D I A G N O S T I C S
  A T A _ E X E C U T E _ D E V I C E _ D I A G N O S T I C S
*/
*/
void ata_execute_device_diagnostics_cmd(ata_device *device)
void ata_execute_device_diagnostics_cmd(ata_device *device)
{
{
  /* print debug information                                          */
  /* 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                                           */
  /* clear SRST bit, if set                                           */
  device->regs.device_control &= ~ATA_DCR_RST;
  device->regs.device_control &= ~ATA_DCR_RST;
 
 
  /* content of features register is undefined                        */
  /* content of features register is undefined                        */
Line 169... Line 173...
  unsigned short *buf;
  unsigned short *buf;
  int            n;
  int            n;
  unsigned int   tmp;
  unsigned int   tmp;
 
 
  /* print debug information                                          */
  /* print debug information                                          */
  ata_device_debug(2, "ata_device executing command 'identify device'\n");
  TRACE("ata_device executing command 'identify device'\n");
 
 
  /* reset databuffer                                                 */
  /* reset databuffer                                                 */
  device->internals.dbuf_cnt = 256;
  device->internals.dbuf_cnt = 256;
  device->internals.dbuf_ptr = device->internals.dbuf;
  device->internals.dbuf_ptr = device->internals.dbuf;
 
 
Line 242... Line 246...
    /*
    /*
      This is a PACKET device.
      This is a PACKET device.
      Respond by placing PACKET Command feature set signature in block registers.
      Respond by placing PACKET Command feature set signature in block registers.
      Abort command.
      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);
    ata_set_device_signature(device, PACKET_SIGNATURE);
    device->regs.status = ATA_SR_ERR;
    device->regs.status = ATA_SR_ERR;
    device->regs.error = ATA_ERR_ABT;
    device->regs.error = ATA_ERR_ABT;
  }
  }
Line 834... Line 838...
  A T A _ I N I T I A L I Z E _ D E V I C E _ P A R A M E T E R S
  A T A _ I N I T I A L I Z E _ D E V I C E _ P A R A M E T E R S
*/
*/
void ata_initialize_device_parameters_cmd(ata_device *device)
void ata_initialize_device_parameters_cmd(ata_device *device)
{
{
  /* print debug information                                          */
  /* 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.sectors_per_track = device->regs.sector_count;
  device->internals.heads_per_cylinder = device->regs.device_head & ATA_DHR_H;
  device->internals.heads_per_cylinder = device->regs.device_head & ATA_DHR_H;
 
 
  /* set status register bits                                         */
  /* set status register bits                                         */
Line 853... Line 857...
{
{
  size_t sector_count;
  size_t sector_count;
  unsigned long lba;
  unsigned long lba;
 
 
  /* print debug information                                          */
  /* 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                             */
  /* check if this is a NON-PACKET device                             */
  if (device->packet)
  if (device->packet)
  {
  {
    /*
    /*
      This is a PACKET device.
      This is a PACKET device.
      Respond by placing PACKET Command feature set signature in block registers.
      Respond by placing PACKET Command feature set signature in block registers.
      Abort command.
      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);
    ata_set_device_signature(device, PACKET_SIGNATURE);
    device->regs.status = ATA_SR_ERR;
    device->regs.status = ATA_SR_ERR;
    device->regs.error = ATA_ERR_ABT;
    device->regs.error = ATA_ERR_ABT;
  }
  }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.