grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC] Platform information services


From: Javier Martín
Subject: [RFC] Platform information services
Date: Thu, 14 Aug 2008 05:36:15 +0200

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: signature.asc
Description: Esta parte del mensaje está firmada digitalmente


reply via email to

[Prev in Thread] Current Thread [Next in Thread]