Implement APM

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-15 11:42:18 +02:00
parent e31bb61911
commit 890c9fa5f2
10 changed files with 257 additions and 5 deletions

View file

@ -20,6 +20,7 @@
#include <grub/memory.h>
#ifdef GRUB_MACHINE_PCBIOS
#include <grub/machine/biosnum.h>
#include <grub/machine/apm.h>
#endif
#include <grub/multiboot.h>
#include <grub/cpu/relocator.h>
@ -194,7 +195,8 @@ grub_multiboot_get_mbi_size (void)
+ ALIGN_UP (sizeof(PACKAGE_STRING), 4)
+ grub_get_multiboot_mmap_count () * sizeof (struct multiboot_mmap_entry)
+ elf_sec_entsize * elf_sec_num
+ 256 * sizeof (struct multiboot_color);
+ 256 * sizeof (struct multiboot_color)
+ ALIGN_UP (sizeof (struct multiboot_apm_info), 4);
}
/* Fill previously allocated Multiboot mmap. */
@ -356,6 +358,29 @@ grub_multiboot_make_mbi (grub_uint32_t *target)
ptrorig += ALIGN_UP (sizeof(PACKAGE_STRING), 4);
ptrdest += ALIGN_UP (sizeof(PACKAGE_STRING), 4);
#ifdef GRUB_MACHINE_PCBIOS
{
struct grub_apm_info info;
if (grub_apm_get_info (&info))
{
struct multiboot_apm_info *mbinfo = (void *) ptrorig;
mbinfo->cseg = info.cseg;
mbinfo->offset = info.offset;
mbinfo->cseg_16 = info.cseg_16;
mbinfo->dseg = info.dseg;
mbinfo->flags = info.flags;
mbinfo->cseg_len = info.cseg_len;
mbinfo->dseg_len = info.dseg_len;
mbinfo->cseg_16_len = info.cseg_16_len;
mbinfo->version = info.version;
ptrorig += ALIGN_UP (sizeof (struct multiboot_apm_info), 4);
ptrdest += ALIGN_UP (sizeof (struct multiboot_apm_info), 4);
}
}
#endif
if (modcnt)
{
mbi->flags |= MULTIBOOT_INFO_MODS;

View file

@ -21,10 +21,8 @@
* FIXME: The following features from the Multiboot specification still
* need to be implemented:
* - VBE support
* - symbol table
* - drives table
* - ROM configuration table
* - APM table
*/
#include <grub/loader.h>

View file

@ -20,6 +20,7 @@
#include <grub/memory.h>
#ifdef GRUB_MACHINE_PCBIOS
#include <grub/machine/biosnum.h>
#include <grub/machine/apm.h>
#endif
#include <grub/multiboot.h>
#include <grub/cpu/multiboot.h>
@ -279,7 +280,8 @@ grub_multiboot_get_mbi_size (void)
+ elf_sec_entsize * elf_sec_num
+ (sizeof (struct multiboot_tag_mmap) + grub_get_multiboot_mmap_count ()
* sizeof (struct multiboot_mmap_entry))
+ sizeof (struct multiboot_tag_vbe) + MULTIBOOT_TAG_ALIGN - 1;
+ sizeof (struct multiboot_tag_vbe) + MULTIBOOT_TAG_ALIGN - 1
+ sizeof (struct multiboot_tag_apm) + MULTIBOOT_TAG_ALIGN - 1;
}
/* Fill previously allocated Multiboot mmap. */
@ -515,6 +517,31 @@ grub_multiboot_make_mbi (grub_uint32_t *target)
ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN);
}
#ifdef GRUB_MACHINE_PCBIOS
{
struct grub_apm_info info;
if (grub_apm_get_info (&info))
{
struct multiboot_tag_apm *tag = (struct multiboot_tag_apm *) ptrorig;
tag->type = MULTIBOOT_TAG_TYPE_APM;
tag->size = sizeof (struct multiboot_tag_apm);
tag->cseg = info.cseg;
tag->offset = info.offset;
tag->cseg_16 = info.cseg_16;
tag->dseg = info.dseg;
tag->flags = info.flags;
tag->cseg_len = info.cseg_len;
tag->dseg_len = info.dseg_len;
tag->cseg_16_len = info.cseg_16_len;
tag->version = info.version;
ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN);
}
}
#endif
{
unsigned i;
struct module *cur;