Skip to content

Commit

Permalink
saved the current IDE drive setup in order to avoid reconfigure it on…
Browse files Browse the repository at this point in the history
… each access
  • Loading branch information
mikaku committed Sep 23, 2021
1 parent 85f0d09 commit 75bb49d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/block/ide.c
Expand Up @@ -49,6 +49,8 @@ static char *ide_drv_name[] = { "master", "slave" };
static unsigned int ide0_sizes[256];
static unsigned int ide1_sizes[256];

static int current_setup = -1;

static struct fs_operations ide_driver_fsop = {
0,
0,
Expand Down Expand Up @@ -510,6 +512,14 @@ void ide_wait400ns(struct ide *ide)
int ide_drvsel(struct ide *ide, int drive, int mode, unsigned char lba24_head)
{
int n, status;
int selected;

selected = (mode + (drive << 4)) | lba24_head;

/* just return if the drive is already setup with the same parameters */
if(selected == current_setup) {
return 0;
}

status = 0;

Expand All @@ -523,7 +533,8 @@ int ide_drvsel(struct ide *ide, int drive, int mode, unsigned char lba24_head)
return status;
}

outport_b(ide->base + IDE_DRVHD, (mode + (drive << 4)) | lba24_head);
current_setup = selected;
outport_b(ide->base + IDE_DRVHD, selected);
ide_wait400ns(ide);

for(n = 0; n < MAX_IDE_ERR; n++) {
Expand Down

0 comments on commit 75bb49d

Please sign in to comment.