All of lore.kernel.org
 help / color / mirror / Atom feed
* Replacing the legacy "map" command
@ 2008-05-27  1:36 Javier Martín
  2008-05-27 15:59 ` Pavel Roskin
  2008-05-27 16:04 ` Vesa Jääskeläinen
  0 siblings, 2 replies; 16+ messages in thread
From: Javier Martín @ 2008-05-27  1:36 UTC (permalink / raw)
  To: grub-devel

First of all, hi there! I'm a 19-old Spanish student and this is my
first post in this list. On to GRUB now:

I'm interested in reimplementing the "map" command from GRUB legacy,
since it may be required by some OSes, specifically M$ Windows, to
boot if they are installed on an HD that was the "first drive" (for
the BIOS) but that is no longer. In particular, my setup is:

SATA channel 1: Samsung 500GB, Windows XP Pro x64
SATA channel 2: Maxtor 300GB, Ubuntu Linux, GRUB installation

However, the BIOS is set to boot from the 300GB drive, and thus at
boot time the Windows drive becomes (hd1): while in GRUB Legacy I
succeeded in booting if I swapped the two BIOS drives with the "map"
command, in GRUB 2 the best result I've got is an "Error loading
operating system" from the Windows boot sector (confirmed after dding
it and grepping for the message).

This message is mainly concerned with "how should I implement it"?
Since this functionality is AFAIK exclusive to the x86/amd64 PC-BIOS
target, it should be confined there, but there are at least two paths
of action that I can think of:
 1.- Given that only the chain OS loader makes use of such a switch, I
could add it as an option to the "chainloader" command. This is the
simplest path, as it would only require modifying
loader/i386/pc/chainloader* and kern/i386/pc/startup.S (where
grub_chainloader_real_boot resides). Such an option would most
probably be named something like "mapdrivefirst", as in "chainloader
--mapdrivefirst (hd1)+1".
 2.- The other option would be to add a new command that managed the
BIOS drive mappings (like, "biosdrivesmap", duh), with three main
options: "show", "map" and "reset". I'm still unsure of what files
should be modified for this change, and this might be overkill.
No matter how the UI (the commands) actually ends up, the mappings
would just be stored in a variable, and not applied until the "boot"
command is issued. Thus, actual functionality should probably be
implemented in grub_chainloader_real_boot, and the logic is pretty
simple, with most of it available in the GRUB Legacy code.

All in all, I'm asking for your thoughts, opinions, advices and
whatever, since I'm the new guy here and I'd like to learn from this.
I might not be able to start right away, since I'm flooded with exams
right now: I could take it as a summer project, though I don't expect
it to take too long - an experienced GRUB hacker could even do it in
the day, but I'm not included in that set, so I think I could have a
testable version within a week if I don't find any problems.
Well, if you have read through all this, thanks for your attention and cheers!
Habbit



^ permalink raw reply	[flat|nested] 16+ messages in thread
[parent not found: <483c317b.0c1e640a.2bd9.7c7eSMTPIN_ADDED@mx.google.com>]
* Re: Replacing the legacy 'map' command
@ 2008-05-28 13:17 Javier Martín
  2008-05-28 16:23 ` Vesa Jääskeläinen
  0 siblings, 1 reply; 16+ messages in thread
From: Javier Martín @ 2008-05-28 13:17 UTC (permalink / raw)
  To: grub-devel

> The cooperation between modules is not hard, but I think
> map -first (hdx) will be more useful. Such command just swaps hd0 and hdx
> drives. This also covers the scenarios when we chainload something else
> than first sector of given partition.
>
> And maybe we can also consider following syntax:
> map -pos (hd2) (hd0) (hd4)
> with meaning:
>   hd0->hd1,
>   hd1->nothing
>   hd2->hd0,
>   hd3 not touch,
>   hd4->hd2
> I.e. positional syntax, first argument is mapped to (hd0), second to (hd1),
>   and so on.
>
> This syntax will be sufficient most times and writing
>   chainloader --automap (hd1,0)+1
> is same as writing
>   map -first (hd1)
>   chainloader (hd1,0)+1
> or
>   setting grub root to (hd1,0)
>   map -root
>   chainloader +1
>
> --
> Tomas Ebenlendr

Well, such "additional" UIs will be useful, and there seems to be some
consensus on how this should be done:
   1.- There should be a new command called somethink like "drivemap"
and based on a new module that would provide the drive mapping
capabilities.
   2.- This module would be available in x86/PC (and, if it is ever
split from it, AMD64/PC), and would work by saving the user requested
mappings and installing a pre-boot GRUB routine.
   3.- Such a routine would, before the execution of grub_X_real_boot,
install the appropate ISRs (which are mostly available in GRUB Legacy
code) to make the mappings effective, no matter what the OS loader is
- chain, multiboot, etc.

Therefore, if there are no objections to this plan, I can start the
implementation (when I finish my exams, of course u_u). I think I will
initially place the ISR installation code in
grub_chainloader_real_boot in order to have a working version right
away, then move it away into its own function and, however the way,
"register" it with the boot routines so that it is executed as
mentioned above. Other modules/commands would be later modified to add
drivemap-related functionality. Is there any site/document (apart from
the sources themselves) in which I can learn more about the internals
of GRUB2 and, specifically, the "boot" command sequence?.

Habbit

---no PGP signature, I'm writing from the uni---



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-06-01  7:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-27  1:36 Replacing the legacy "map" command Javier Martín
2008-05-27 15:59 ` Pavel Roskin
2008-05-27 16:15   ` Urja Rannikko
2008-05-28 14:24   ` Robert Millan
2008-05-30  0:55     ` Pavel Roskin
2008-05-30  2:13       ` Javier Martín
2008-05-30  3:48         ` Pavel Roskin
2008-05-30  7:19           ` Robert Millan
     [not found]         ` <-5961521231976305315@unknownmsgid>
2008-05-31 23:15           ` Javier Martín
2008-06-01  7:18             ` Vesa Jääskeläinen
2008-05-27 16:04 ` Vesa Jääskeläinen
2008-05-27 16:18   ` Urja Rannikko
     [not found] <483c317b.0c1e640a.2bd9.7c7eSMTPIN_ADDED@mx.google.com>
2008-05-27 21:47 ` Javier Martín
2008-05-28  0:19   ` Replacing the legacy 'map' command Tomáš Ebenlendr
  -- strict thread matches above, loose matches on Subject: below --
2008-05-28 13:17 Javier Martín
2008-05-28 16:23 ` Vesa Jääskeläinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.