summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2009-10-15 06:30:08 +0000
committerChris Johns <chrisj@rtems.org>2009-10-15 06:30:08 +0000
commit4c397641a8c4b10e5e2cdb291d98edd90a0b18e7 (patch)
tree5cde6d7af83415c8d1be2d5e426ad84b1cc54149 /c
parentRemove (Moved to c/src/lib/libbsp/<cpu>/<bsp>). (diff)
downloadrtems-4c397641a8c4b10e5e2cdb291d98edd90a0b18e7.tar.bz2
2009-10-15 Chris Johns <chrisj@rtems.org>
* ne2000/ne2000.c: Add --ne2k-irq and --ne2k-port boot command line configure options. * ide/ide.c: Fix a bug which left 4 words in the buffer of the disk. Some devices do not follow the standard and terminate the command which a new command occurs and/or low data ready when data is still to be read.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/i386/pc386/ChangeLog10
-rw-r--r--c/src/lib/libbsp/i386/pc386/ide/ide.c95
-rw-r--r--c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c25
3 files changed, 86 insertions, 44 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/ChangeLog b/c/src/lib/libbsp/i386/pc386/ChangeLog
index fa247da788..ea912c22a7 100644
--- a/c/src/lib/libbsp/i386/pc386/ChangeLog
+++ b/c/src/lib/libbsp/i386/pc386/ChangeLog
@@ -1,3 +1,13 @@
+2009-10-15 Chris Johns <chrisj@rtems.org>
+
+ * ne2000/ne2000.c: Add --ne2k-irq and --ne2k-port boot command
+ line configure options.
+
+ * ide/ide.c: Fix a bug which left 4 words in the buffer of the
+ disk. Some devices do not follow the standard and terminate the
+ command which a new command occurs and/or low data ready when data
+ is still to be read.
+
2009-10-15 Ralf Corsépius <ralf.corsepius@rtems.org>
* make/custom/pc386.cfg: New (relocated from /make/custom).
diff --git a/c/src/lib/libbsp/i386/pc386/ide/ide.c b/c/src/lib/libbsp/i386/pc386/ide/ide.c
index b7850fab10..602fd00a29 100644
--- a/c/src/lib/libbsp/i386/pc386/ide/ide.c
+++ b/c/src/lib/libbsp/i386/pc386/ide/ide.c
@@ -183,17 +183,17 @@ bool pc386_ide_probe
void pc386_ide_initialize
(
/*-------------------------------------------------------------------------*\
-| Purpose: |
-| initialize IDE access |
-+---------------------------------------------------------------------------+
-| Input Parameters: |
-\*-------------------------------------------------------------------------*/
- int minor /* controller minor number */
+ | Purpose: |
+ | initialize IDE access |
+ +---------------------------------------------------------------------------+
+ | Input Parameters: |
+ \*-------------------------------------------------------------------------*/
+ int minor /* controller minor number */
)
/*-------------------------------------------------------------------------*\
-| Return Value: |
-| <none> |
-\*=========================================================================*/
+ | Return Value: |
+ | <none> |
+ \*=========================================================================*/
{
uint32_t port = IDE_Controller_Table[minor].port1;
uint8_t dev = 0;
@@ -213,6 +213,7 @@ void pc386_ide_initialize
for (dev = 0; dev < 2; dev++)
{
+ uint16_t capabilities = 0;
uint32_t byte;
uint8_t status;
uint8_t error;
@@ -224,16 +225,18 @@ void pc386_ide_initialize
uint32_t cylinders = 0;
uint32_t heads = 0;
uint32_t sectors = 0;
+ uint32_t lba_sectors = 0;
char model_number[41];
char* p = &model_number[0];
+ bool data_ready;
memset(model_number, 0, sizeof(model_number));
outport_byte(port+IDE_REGISTER_DEVICE_HEAD,
(dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS) | 0xE0);
/*
- outport_byte(port+IDE_REGISTER_SECTOR_NUMBER,
- (dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS) | IDE_REGISTER_LBA3_L);
+ outport_byte(port+IDE_REGISTER_SECTOR_NUMBER,
+ (dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS) | IDE_REGISTER_LBA3_L);
*/
outport_byte(port+IDE_REGISTER_COMMAND, 0x00);
@@ -265,35 +268,37 @@ void pc386_ide_initialize
continue;
}
- byte = 0;
- while (byte < 512)
- {
- uint16_t word;
- bool data_ready;
+ data_ready = pc386_ide_status_data_ready (port,
+ 250,
+ &status,
+ pc386_ide_prestart_sleep);
+ if (status & IDE_REGISTER_STATUS_ERR)
+ {
+ inport_byte(port+IDE_REGISTER_ERROR, error);
+ if (error != 4)
+ {
+ if (pc386_ide_show)
+ printk("IDE%d:%s: error=%04x\n", minor, label, error);
+ continue;
+ }
+ /*
+ * The device is an ATAPI device.
+ */
+ outport_byte(port+IDE_REGISTER_COMMAND, 0xa1);
data_ready = pc386_ide_status_data_ready (port,
250,
&status,
pc386_ide_prestart_sleep);
+ }
- if (status & IDE_REGISTER_STATUS_ERR)
- {
- inport_byte(port+IDE_REGISTER_ERROR, error);
- if (error != 4)
- {
- if (pc386_ide_show)
- printk("IDE%d:%s: error=%04x\n", minor, label, error);
- break;
- }
- /*
- * The device is an ATAPI device.
- */
- outport_byte(port+IDE_REGISTER_COMMAND, 0xa1);
- continue;
- }
-
- if (!data_ready)
- break;
+ if (!data_ready)
+ continue;
+
+ byte = 0;
+ while (byte < 512)
+ {
+ uint16_t word;
if (pc386_ide_show && ((byte % 16) == 0))
printk("\n %04x : ", byte);
@@ -318,17 +323,22 @@ void pc386_ide_initialize
p++;
}
- if (byte == 94)
- max_multiple_sectors = word & 0xff;
-
if (byte == (47 * 2))
max_multiple_sectors = word & 0xff;
+ if (byte == (49 * 2))
+ capabilities = word;
+
if (byte == (59 * 2))
{
if (word & (1 << 8))
cur_multiple_sectors = word & 0xff;
}
+
+ if (byte == (60 * 2))
+ lba_sectors = word;
+ if (byte == (61 * 2))
+ lba_sectors |= word << 16;
byte += 2;
}
@@ -342,9 +352,14 @@ void pc386_ide_initialize
uint32_t left;
uint32_t right;
char units;
-
- size = ((((uint64_t) cylinders) * heads) * sectors * 512) / 1024;
+ if (capabilities & (1 << 9))
+ size = lba_sectors;
+ else
+ size = cylinders * heads * sectors;
+
+ size /= 2;
+
if (size > (1024 * 1024))
{
size = (size * 10) / (1000 * 1000);
@@ -375,7 +390,7 @@ void pc386_ide_initialize
minor, label, model_number, left, right, units,
heads, cylinders, sectors, max_multiple_sectors * 512);
}
-
+
#if IDE_CLEAR_MULTI_SECTOR_COUNT
if (max_multiple_sectors)
{
diff --git a/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c b/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
index 2c5484cd01..6abec3d12e 100644
--- a/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
+++ b/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
@@ -33,6 +33,7 @@
#include <wd80x3.h>
#include <stdio.h>
+#include <stdlib.h>
#include <assert.h>
#include <errno.h>
@@ -1189,15 +1190,31 @@ rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
if (config->irno != 0)
sc->irno = config->irno;
else {
- /* We use 5 as the default IRQ. */
- sc->irno = 5;
+ const char* opt;
+ opt = bsp_cmdline_arg ("--ne2k-irq=");
+ if (opt) {
+ opt += sizeof ("--ne2k-irq=") - 1;
+ sc->irno = strtoul (opt, 0, 0);
+ }
+ if (sc->irno == 0) {
+ /* We use 5 as the default IRQ. */
+ sc->irno = 5;
+ }
}
if (config->port != 0)
sc->port = config->port;
else {
- /* We use 0x300 as the default IO port number. */
- sc->port = 0x300;
+ const char* opt;
+ opt = bsp_cmdline_arg ("--ne2k-port=");
+ if (opt) {
+ opt += sizeof ("--ne2k-port=") - 1;
+ sc->port = strtoul (opt, 0, 0);
+ }
+ if (config->port != 0) {
+ /* We use 0x300 as the default IO port number. */
+ sc->port = 0x300;
+ }
}
sc->accept_broadcasts = ! config->ignore_broadcast;