All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] Platform information services
@ 2008-08-14  3:36 Javier Martín
  2008-08-14 16:09 ` Vesa Jääskeläinen
  0 siblings, 1 reply; 20+ messages in thread
From: Javier Martín @ 2008-08-14  3:36 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 2859 bytes --]

Hi there everybody,

I'm opening the RFC because I want to add some kind of infrastructure to
retrieve the address of system/platform structures. I will explain
myself: my use case is in i386-pc and for the drivemap module, in which
a function installs a TSR int13h handler. This requires the function to
have access to two real mode structures, namely the BIOS Data Area,
which is based at 0040:0000h; and the Interrupt Vector Table, which
conventionally starts at 0 but that could have been placed elsewhere by
the use of the LIDT instruction.

Currently, the code just "hopes for the best" and accesses 0x0 and 0x400
directly as protected mode addresses from within the GRUB environment,
which has the additional assumption that GRUB has not enabled any kind
of paging or memory mapping. Obviously, the Right Way for this would be
for the code to check where its targets are, but even when the location
of the IVT can be queried by the non-privileged instruction SIDT, that
would require a privileged trip to real mode and back from it in order
to query the location of the real mode IVT instead of the pmode IDT that
is in effect in the GRUB environment (but this still does not deal with
a possible paging).

Thus, the best course of action I see would be to add a "platform
information" infrastructure in kernel (that last word has probably put
me on the death list of several people here ¬¬). My idea would add a
cross-platform header platform.h declaring the following prototype:

void* grub_machine_get_platform_structure (int stidx);

Then, the machine.h file for each platform would declare which
structures are available, like the IVT and the BDA for i386-pc. The code
would be used like this:

#include <grub/platform.h>
#include <grub/machine/machine.h>

/* (...) Now from within a function */
grub_uint8_t* bda = (grub_uint8_t*)grub_machine_get_platform_structure
(GRUB_MACHINE_I386_BDA);

if (!bda)
  /* Error info in errno & errmsg - bail out */
else
  grub_printf ("Avail mem: %d KiB", *((grub_uint16_t*)(bda + 0x13)));


The pointers provided by this new function would be guaranteed to:
  - Be able to access the whole requested structure (if any segmentation
is in effect, the whole struct is addressable from that base address)
  - Have been mapping-marshaled, i.e. if any kind of paging has been
enabled, the address returned can be directly used as a C pointer.
  - Be read-write? Maybe this could be requested through an additional
"flags" parameter to the function...

Initially this addition would only benefit i386-pc and in particular my
drivemap patch, but maybe it can also be used by modules to query EFI
info structures and such... What are your thoughts on the matter?
(fanatics with death threats for trying to add something to kernel,
please abstain)

-Habbit

[-- Attachment #2: Esta parte del mensaje está firmada digitalmente --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

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

end of thread, other threads:[~2008-08-16 12:22 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-14  3:36 [RFC] Platform information services Javier Martín
2008-08-14 16:09 ` Vesa Jääskeläinen
2008-08-14 16:38   ` Javier Martín
2008-08-14 17:41     ` Vesa Jääskeläinen
2008-08-14 21:45       ` Javier Martín
2008-08-14 18:00     ` Robert Millan
2008-08-14 21:29       ` Javier Martín
2008-08-15 16:31         ` Vesa Jääskeläinen
2008-08-15 17:03           ` Javier Martín
2008-08-15 17:14             ` Vesa Jääskeläinen
2008-08-15 17:59               ` Javier Martín
2008-08-15 18:35                 ` Vesa Jääskeläinen
2008-08-15 19:18                   ` Javier Martín
2008-08-15 19:46                     ` Vesa Jääskeläinen
2008-08-15 20:13                       ` Javier Martín
2008-08-15 20:26                         ` Vesa Jääskeläinen
2008-08-15 22:38                     ` Isaac Dupree
2008-08-15 23:06                       ` Javier Martín
2008-08-16  7:03                       ` Vesa Jääskeläinen
2008-08-16 12:20             ` Robert Millan

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.