Skip to contentSkip to conversation

int13 and non-reboot drives mapping

DISCUSSION adrian15 2 participants 2 messages Jan 24, 2007 – Jan 26, 2007

lore
Share & tools
lore

adrian15

author
#0 lore raw

This is about the drive shift that I wrote the other day about grub2
sci-fi and all.

I've finally decided that this usbshift command should be run as a
normal command not anything inside a preset menu.

I've seen that we have to boot into the usb drive again to make
effective changes of mapping drives. It is very annoying! And, of course, I do not want to boot into the pendrive once booted into it.

I've studied grub legacy's root command source code (check at the email
bottom) and I ask myself if I could write a command that only will do this part of the code I suppose that without the gateA20(0) (I've read something related to high memory but I think it is not useful for mapping.) but as I am not very sure I need your advice if you do not mind.

My idea is that the usbshift command should first shift the drives
thanks to map command and then run the mentioned piece of code.
My AdamLGrub's variable: grub_device (that represents grub device)
should be set to (hd4,0) if it was to set to (hd0,0) and there are 5 hard disks (including the usb drive).

	And then the next command to run is a configfile to somewhere like:

	configfile $(grub_device)/boot/sgd/menu.lst

this will update the grub legacy's variables concerning to where grub is working like: saved_drive and saved_partition...

As long as menu.lst files are run from the RAM there should not be any
problem like there would be with a function trying to read from a hard disk.

If you do not like the configfile idea you could also set them
inside the usbshift command calling to root command so that it accepts as an argument (NEWUSBHD,OLDPART) such as: (hd4,0).

I suppose that BIOS ints are better handled (more elegant) in grub2 and
it should be easier for you to do that.

Any idea, mistake, advice?

adrian15

	      /* Check if we should set the int13 handler.  */
      if (bios_drive_map[0] != 0)
	{
	  int i;
	
	  /* Search for SAVED_DRIVE.  */
	  for (i = 0; i < DRIVE_MAP_SIZE; i++)
	    {
	      if (! bios_drive_map[i])
		break;
	      else if ((bios_drive_map[i] & 0xFF) == saved_drive)
		{
		  /* Exchage SAVED_DRIVE with the mapped drive.  */
		  saved_drive = (bios_drive_map[i] >> 8) & 0xFF;
		  break;
		}
	    }
	
	  /* Set the handler. This is somewhat dangerous.  */
	  set_int13_handler (bios_drive_map);
	}

      gateA20 (0);
      boot_drive = saved_drive;
      chain_stage1 (0, BOOTSEC_LOCATION, boot_part_addr);
      break;
#1 lore raw
Quoted 2 lines · On Wednesday 24 January 2007 18:22, adrian15 wrote:

I've finally decided that this usbshift command should be run as a
normal command not anything inside a preset menu.

Use "search" instead of specifying a drive explicitly. This is not always possible, but distributions should make some kind of signatures in installations. This effectively removes the necessity of drive numbering recognitions. The use of explicit drive specification is, well, discouraged in GRUB2.

Okuji