summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2019-10-22 19:00:24 +0100
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2019-10-22 19:00:24 +0100
commit1c63d13a1f4a9bf0369cda63d2eae4278c52a1d6 (patch)
treeba7888e3bc4f0521f62fab8e31f88605a110a30e
parenta7ca34d42580b354d1bb477472e10fe2ca234fd4 (diff)
downloadqemu-openbios-1c63d13a1f4a9bf0369cda63d2eae4278c52a1d6.tar.gz
ide: use instance values to hold C drive and channel structures
Rather than iterate over the global IDE channels list, use instance variables to hold the relevant pointers. This allows us to remove ide_seek_channel() since it is no longer necessary for each IDE device to iterate over the global list in order to locate the drive/channel information. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
-rw-r--r--drivers/ide.c41
-rw-r--r--drivers/ide.h1
2 files changed, 15 insertions, 27 deletions
diff --git a/drivers/ide.c b/drivers/ide.c
index e56cb4c1..62c20b91 100644
--- a/drivers/ide.c
+++ b/drivers/ide.c
@@ -73,19 +73,6 @@ static inline void ide_add_channel(struct ide_channel *chan)
channels = chan;
}
-static struct ide_channel *ide_seek_channel(phandle_t ph)
-{
- struct ide_channel *current;
-
- current = channels;
- while (current) {
- if (current->ph == ph)
- return current;
- current = current->next;
- }
- return NULL;
-}
-
/*
* don't be pedantic
*/
@@ -1230,18 +1217,10 @@ ob_ide_open(int *idx)
int ret=1;
phandle_t ph;
struct ide_drive *drive;
- struct ide_channel *chan;
- int unit;
- fword("my-unit");
- unit = POP();
-
- fword("my-parent");
- fword("ihandle>phandle");
- ph=(phandle_t)POP();
-
- chan = ide_seek_channel(ph);
- drive = &chan->drives[unit];
+ PUSH(find_ih_method("drive", my_self()));
+ fword("execute");
+ drive = cell2pointer(POP());
*(struct ide_drive **)idx = drive;
IDE_DPRINTF("opening channel %d unit %d\n", idx[1], idx[0]);
@@ -1437,7 +1416,9 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
fword("new-device");
dnode = get_cur_dev();
- chan->ph = dnode;
+
+ PUSH(pointer2cell(chan));
+ feval("value chan");
BIND_NODE_METHODS(get_cur_dev(), ob_ide_ctrl);
@@ -1500,6 +1481,9 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
push_str("block");
fword("device-type");
+ PUSH(pointer2cell(drive));
+ feval("value drive");
+
BIND_NODE_METHODS(dnode, ob_ide);
fword("is-deblocker");
@@ -1626,7 +1610,9 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
fword("new-device");
dnode = get_cur_dev();
- chan->ph = dnode;
+
+ PUSH(pointer2cell(chan));
+ feval("value chan");
snprintf(nodebuff, sizeof(nodebuff), DEV_NAME "-%d", current_channel);
push_str(nodebuff);
@@ -1741,6 +1727,9 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
push_str("block");
fword("device-type");
+ PUSH(pointer2cell(drive));
+ feval("value drive");
+
BIND_NODE_METHODS(dnode, ob_ide);
fword("is-deblocker");
diff --git a/drivers/ide.h b/drivers/ide.h
index 8983c8ec..f6abb7b8 100644
--- a/drivers/ide.h
+++ b/drivers/ide.h
@@ -167,7 +167,6 @@ struct ide_drive {
struct ide_channel {
- phandle_t ph;
struct ide_channel *next;
/*