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

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1694 to Rev 1695
    Reverse comparison

Rev 1694 → Rev 1695

/trunk/or1ksim/peripheral/atadevice.c
122,26 → 122,26
device->internals.dev = dev;
 
/* generate stream for hd_simulation */
switch(device->type)
switch(device->conf.type)
{
case TYPE_NO_CONNECT:
TRACE("ata_device, using type NO_CONNECT.\n");
device->stream = NULL;
device->conf.stream = NULL;
break;
 
case TYPE_FILE:
TRACE("ata_device, using device type FILE.\n");
device->stream = open_file(&device->size, device->file);
device->conf.stream = open_file(&device->conf.size, device->conf.file);
break;
 
case TYPE_LOCAL:
TRACE("ata_device, using device type LOCAL.\n");
device->stream = open_local();
device->conf.stream = open_local();
break;
 
default:
ERR("Illegal device-type. Defaulting to type NO_CONNECT.\n");
device->stream = NULL;
device->conf.stream = NULL;
break;
}
}
153,7 → 153,7
{
ata_device_init(&devices->device[0], 0);
 
if(devices->device[0].type)
if(devices->device[0].conf.type)
ata_device_init(&devices->device[1], ATA_DHR_DEV);
else
ata_device_init(&devices->device[1], 0);
184,7 → 184,7
device->regs.status &= ~ATA_SR_BSY;
 
/* set DRDY bit, when not a PACKET device */
if(!device->packet)
if(!device->conf.packet)
device->regs.status |= ATA_SR_DRDY;
 
/* set new state */
215,7 → 215,7
TRACE("ata_devices_hw_reset.\n");
 
/* find device 0 */
if((devices->device[0].stream) && (devices->device[1].stream)) {
if((devices->device[0].conf.stream) && (devices->device[1].conf.stream)) {
/* this one is simple, device0 is device0 */
 
/* 1) handle device1 first */
229,13 → 229,13
0,
devices->device[1].sigs.pdiago,
devices->device[1].sigs.daspo);
} else if(devices->device[0].stream) {
} else if(devices->device[0].conf.stream) {
/* device0 is device0, there's no device1 */
ata_device_hw_reset(&devices->device[0], reset_signal,
0, /* negate dasp, this is device0 */
0, /* negate pdiag input, there's no device1*/
0); /* negate dasp input, there's no device1 */
} else if(devices->device[1].stream) {
} else if(devices->device[1].conf.stream) {
/* device1 is (logical) device0, there's no (physical) device0 */
ata_device_hw_reset(&devices->device[1], reset_signal,
0, /* negate dasp, this is device0 */
291,7 → 291,7
device->regs.status &= ~ATA_SR_BSY;
 
/* set DRDY bit, when not a PACKET device */
if (!device->packet)
if(!device->conf.packet)
device->regs.status |= ATA_SR_DRDY;
 
/* set new state */
338,12 → 338,12
ata_device *device;
 
/* check for no connected devices */
if((!devices->device[0].stream) && (!devices->device[1].stream))
if((!devices->device[0].conf.stream) && (!devices->device[1].conf.stream))
ERR("ata_devices_read, no ata devices connected.\n");
else
{
/* check if both device0 and device1 are connected */
if((devices->device[0].stream) && (devices->device[1].stream)) {
if((devices->device[0].conf.stream) && (devices->device[1].conf.stream)) {
/* get the current active device */
if (devices->device[1].regs.device_head & ATA_DHR_DEV)
device = &devices->device[1];
353,7 → 353,7
else
{
/* only one device connected */
if(devices->device[1].stream)
if(devices->device[1].conf.stream)
device = &devices->device[1];
else
device = &devices->device[0];
516,15 → 516,15
void ata_devices_write(ata_devices *devices, char adr, short value)
{
/* check for no connected devices */
if(!devices->device[0].stream && !devices->device[1].stream)
if(!devices->device[0].conf.stream && !devices->device[1].conf.stream)
ERR("ata_devices_write, no ata devices connected.\n");
else {
/* first device */
if(devices->device[0].stream)
if(devices->device[0].conf.stream)
ata_device_write(&devices->device[0], adr, value);
 
/* second device */
if(devices->device[1].stream)
if(devices->device[1].conf.stream)
ata_device_write(&devices->device[1], adr, value);
}
}
/trunk/or1ksim/peripheral/atadevice.h
162,15 → 162,16
} sigs;
 
/******** simulator settings **********************************/
/* simulate ata-device */
char *file; /* Filename (if type == FILE) */
FILE *stream; /* stream where the simulated device connects to*/
int type; /* Simulate device using */
/* NO_CONNECT: no device connected (dummy) */
/* FILE : a file */
/* LOCAL : a local stream, e.g./dev/hda1 */
unsigned long size; /* size in MB of the simulated device */
int packet; /* device implements PACKET command set */
struct {
char *file; /* Filename (if type == FILE) */
FILE *stream; /* stream where the simulated device connects to*/
int type; /* Simulate device using */
/* NO_CONNECT: no device connected (dummy) */
/* FILE : a file */
/* LOCAL : a local stream, e.g./dev/hda1 */
unsigned long size; /* size in bytes of the simulated device */
int packet; /* device implements PACKET command set */
} conf;
} ata_device;
 
typedef struct{
/trunk/or1ksim/peripheral/atahost.c
262,13 → 262,13
static void ata_dev_type0(union param_val val, void *dat)
{
ata_host *ata = dat;
ata->devices.device[0].type = val.int_val;
ata->devices.device[0].conf.type = val.int_val;
}
 
static void ata_dev_file0(union param_val val, void *dat)
{
ata_host *ata = dat;
if(!(ata->devices.device[0].file = strdup(val.str_val))) {
if(!(ata->devices.device[0].conf.file = strdup(val.str_val))) {
fprintf(stderr, "Peripheral ATA: Run out of memory\n");
exit(-1);
}
277,25 → 277,25
static void ata_dev_size0(union param_val val, void *dat)
{
ata_host *ata = dat;
ata->devices.device[0].size = val.int_val;
ata->devices.device[0].conf.size = val.int_val;
}
 
static void ata_dev_packet0(union param_val val, void *dat)
{
ata_host *ata = dat;
ata->devices.device[0].packet = val.int_val;
ata->devices.device[0].conf.packet = val.int_val;
}
 
static void ata_dev_type1(union param_val val, void *dat)
{
ata_host *ata = dat;
ata->devices.device[1].packet = val.int_val;
ata->devices.device[1].conf.packet = val.int_val;
}
 
static void ata_dev_file1(union param_val val, void *dat)
{
ata_host *ata = dat;
if(!(ata->devices.device[1].file = strdup(val.str_val))) {
if(!(ata->devices.device[1].conf.file = strdup(val.str_val))) {
fprintf(stderr, "Peripheral ATA: Run out of memory\n");
exit(-1);
}
304,13 → 304,13
static void ata_dev_size1(union param_val val, void *dat)
{
ata_host *ata = dat;
ata->devices.device[1].size = val.int_val;
ata->devices.device[1].conf.size = val.int_val;
}
 
static void ata_dev_packet1(union param_val val, void *dat)
{
ata_host *ata = dat;
ata->devices.device[1].packet = val.int_val;
ata->devices.device[1].conf.packet = val.int_val;
}
 
static void ata_enabled(union param_val val, void *dat)
/trunk/or1ksim/peripheral/atadevice_cmdi.c
104,7 → 104,7
/* print debug information */
TRACE("executing command 'device reset'\n");
 
if (!device->packet)
if (!device->conf.packet)
WARN("executing DEVICE_RESET on non-packet device.");
 
ata_execute_device_diagnostics_cmd(device);
137,8 → 137,7
 
 
/* check if device implements packet protocol */
if (device->packet)
{
if (device->conf.packet) {
/* place PACKET command feature set signature in register block */
ata_set_device_signature(device, PACKET_SIGNATURE);
 
241,8 → 240,7
 
 
/* check if this is a NON-PACKET device */
if (device->packet)
{
if (device->conf.packet) {
/*
This is a PACKET device.
Respond by placing PACKET Command feature set signature in block registers.
273,7 → 271,7
 
>=1, <= 65535
*/
if ( (tmp = device->size / BYTES_PER_SECTOR) >= 16514064 )
if((tmp = device->conf.size / BYTES_PER_SECTOR) >= 16514064)
*buf++ = 16383;
else
if ( (tmp /= (HEADS +1) * SECTORS) > 65535 )
439,7 → 437,7
/*
word 54: number of current logical cylinders (0-65535)
*/
if ( (tmp = device->size / BYTES_PER_SECTOR) > 16514064 )
if((tmp = device->conf.size / BYTES_PER_SECTOR) > 16514064 )
tmp = 16514064;
 
tmp /= (device->internals.heads_per_cylinder +1) * (device->internals.sectors_per_track);
477,8 → 475,8
/*
word 60-61: Total number of user addressable sectors (LBA only)
*/
*buf++ = (device->size / BYTES_PER_SECTOR);
*buf++ = (device->size / BYTES_PER_SECTOR) >> 16;
*buf++ = (device->conf.size / BYTES_PER_SECTOR);
*buf++ = (device->conf.size / BYTES_PER_SECTOR) >> 16;
 
/*
word 62: obsolete
862,8 → 860,7
TRACE("executing command 'read sectors'\n");
 
/* check if this is a NON-PACKET device */
if (device->packet)
{
if (device->conf.packet) {
/*
This is a PACKET device.
Respond by placing PACKET Command feature set signature in block registers.
903,21 → 900,19
}
 
/* check if sector within bounds */
if (lba > (device->size / BYTES_PER_SECTOR) )
{ /* invalid sector address */
if(lba > (device->conf.size / BYTES_PER_SECTOR)) {
/* invalid sector address */
/* set the status & error registers */
device->regs.status = ATA_SR_DRDY | ATA_SR_ERR;
device->regs.error = ATA_ERR_IDNF;
}
else
{ /* go ahead, read the bytestream */
} else { /* go ahead, read the bytestream */
lba *= BYTES_PER_SECTOR;
 
/* set the file-positon pointer to the start of the sector */
fseek(device->stream, lba, SEEK_SET);
fseek(device->conf.stream, lba, SEEK_SET);
 
/* get the bytes from the stream */
fread(device->internals.dbuf, BYTES_PER_SECTOR, sector_count, device->stream);
fread(device->internals.dbuf, BYTES_PER_SECTOR, sector_count, device->conf.stream);
 
/* set status register bits */
device->regs.status = ATA_SR_DRDY | ATA_SR_DRQ;

powered by: WebSVN 2.1.0

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