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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel-0-3-0-rc3/] [or1ksim/] [peripheral/] [atahost.c] - Diff between revs 1557 and 1649

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

Rev 1557 Rev 1649
Line 37... Line 37...
/* all user defineable settings are in 'atahost_define.h'             */
/* all user defineable settings are in 'atahost_define.h'             */
#include "atahost_define.h"
#include "atahost_define.h"
#include "atahost.h"
#include "atahost.h"
 
 
/* reset and initialize ATA host core(s) */
/* reset and initialize ATA host core(s) */
void ata_reset(void *dat)
static void ata_reset(void *dat)
{
{
   ata_host *ata = dat;
   ata_host *ata = dat;
 
 
   // reset the core registers
   // reset the core registers
   ata->regs.ctrl  = 0x0001;
   ata->regs.ctrl  = 0x0001;
Line 63... Line 63...
 
 
 
 
/*
/*
  Read a register
  Read a register
*/
*/
uint32_t ata_read32( oraddr_t addr, void *dat )
static uint32_t ata_read32( oraddr_t addr, void *dat )
{
{
    ata_host *ata = dat;
    ata_host *ata = dat;
 
 
    /* determine if ata_host or ata_device addressed */
    /* determine if ata_host or ata_device addressed */
    if (is_ata_hostadr(addr))
    if (is_ata_hostadr(addr))
Line 133... Line 133...
 
 
 
 
/*
/*
  Write a register
  Write a register
*/
*/
void ata_write32( oraddr_t addr, uint32_t value, void *dat )
static void ata_write32( oraddr_t addr, uint32_t value, void *dat )
{
{
    ata_host *ata = dat;
    ata_host *ata = dat;
 
 
    /* determine if ata_host or ata_device addressed */
    /* determine if ata_host or ata_device addressed */
    if (is_ata_hostadr(addr))
    if (is_ata_hostadr(addr))
Line 218... Line 218...
}
}
/* ========================================================================= */
/* ========================================================================= */
 
 
 
 
/* Dump status */
/* Dump status */
void ata_status( void *dat )
static void ata_status( void *dat )
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
 
 
  if ( ata->baseaddr == 0 )
  if ( ata->baseaddr == 0 )
    return;
    return;
Line 245... Line 245...
#endif
#endif
}
}
/* ========================================================================= */
/* ========================================================================= */
 
 
/*----------------------------------------------------[ ATA Configuration ]---*/
/*----------------------------------------------------[ ATA Configuration ]---*/
void ata_baseaddr(union param_val val, void *dat)
static void ata_baseaddr(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  ata->baseaddr = val.addr_val;
  ata->baseaddr = val.addr_val;
}
}
 
 
void ata_irq(union param_val val, void *dat)
static void ata_irq(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  ata->irq = val.int_val;
  ata->irq = val.int_val;
}
}
 
 
void ata_dev_type0(union param_val val, void *dat)
static void ata_dev_type0(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  ata->devices.device0.type = val.int_val;
  ata->devices.device0.type = val.int_val;
}
}
 
 
void ata_dev_file0(union param_val val, void *dat)
static void ata_dev_file0(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  if(!(ata->devices.device0.file = strdup(val.str_val))) {
  if(!(ata->devices.device0.file = strdup(val.str_val))) {
    fprintf(stderr, "Peripheral ATA: Run out of memory\n");
    fprintf(stderr, "Peripheral ATA: Run out of memory\n");
    exit(-1);
    exit(-1);
  }
  }
}
}
 
 
void ata_dev_size0(union param_val val, void *dat)
static void ata_dev_size0(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  ata->devices.device0.size = val.int_val;
  ata->devices.device0.size = val.int_val;
}
}
 
 
void ata_dev_packet0(union param_val val, void *dat)
static void ata_dev_packet0(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  ata->devices.device0.packet = val.int_val;
  ata->devices.device0.packet = val.int_val;
}
}
 
 
void ata_dev_type1(union param_val val, void *dat)
static void ata_dev_type1(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  ata->devices.device1.packet = val.int_val;
  ata->devices.device1.packet = val.int_val;
}
}
 
 
void ata_dev_file1(union param_val val, void *dat)
static void ata_dev_file1(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  if(!(ata->devices.device1.file = strdup(val.str_val))) {
  if(!(ata->devices.device1.file = strdup(val.str_val))) {
    fprintf(stderr, "Peripheral ATA: Run out of memory\n");
    fprintf(stderr, "Peripheral ATA: Run out of memory\n");
    exit(-1);
    exit(-1);
  }
  }
}
}
 
 
void ata_dev_size1(union param_val val, void *dat)
static void ata_dev_size1(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  ata->devices.device1.size = val.int_val;
  ata->devices.device1.size = val.int_val;
}
}
 
 
void ata_dev_packet1(union param_val val, void *dat)
static void ata_dev_packet1(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  ata->devices.device1.packet = val.int_val;
  ata->devices.device1.packet = val.int_val;
}
}
 
 
void ata_enabled(union param_val val, void *dat)
static void ata_enabled(union param_val val, void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  ata->enabled = val.int_val;
  ata->enabled = val.int_val;
}
}
 
 
void *ata_sec_start(void)
static void *ata_sec_start(void)
{
{
  ata_host *new = malloc(sizeof(ata_host));
  ata_host *new = malloc(sizeof(ata_host));
 
 
  if(!new) {
  if(!new) {
    fprintf(stderr, "Peripheral ATA: Run out of memory\n");
    fprintf(stderr, "Peripheral ATA: Run out of memory\n");
Line 331... Line 331...
  memset(new, 0, sizeof(ata_host));
  memset(new, 0, sizeof(ata_host));
  new->enabled = 1;
  new->enabled = 1;
  return new;
  return new;
}
}
 
 
void ata_sec_end(void *dat)
static void ata_sec_end(void *dat)
{
{
  ata_host *ata = dat;
  ata_host *ata = dat;
  struct mem_ops ops;
  struct mem_ops ops;
 
 
  if(!ata->enabled) {
  if(!ata->enabled) {

powered by: WebSVN 2.1.0

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