Fix grub_pxe_scan.

* grub-core/fs/i386/pc/pxe.c (grub_pxe_pxenv): Put correct type bangpxe.
	(grub_pxe_scan): Fix types and pxe_rm_entry computation.
	All users updated.
	* include/grub/i386/pc/pxe.h (grub_pxe_bangpxe): New struct.
	(grub_pxe_pxenv): Correct type.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-02 15:47:03 +02:00
parent f9cefc4eb3
commit 9a09392057
3 changed files with 45 additions and 16 deletions

View file

@ -1,3 +1,13 @@
2010-09-02 Vladimir Serbinenko <phcoder@gmail.com>
Fix grub_pxe_scan.
* grub-core/fs/i386/pc/pxe.c (grub_pxe_pxenv): Put correct type bangpxe.
(grub_pxe_scan): Fix types and pxe_rm_entry computation.
All users updated.
* include/grub/i386/pc/pxe.h (grub_pxe_bangpxe): New struct.
(grub_pxe_pxenv): Correct type.
2010-09-01 Colin Watson <cjwatson@ubuntu.com>
* NEWS: Document most of the important changes since 1.98.

View file

@ -41,7 +41,7 @@ struct grub_pxe_disk_data
grub_uint32_t gateway_ip;
};
struct grub_pxenv *grub_pxe_pxenv;
struct grub_pxe_bangpxe *grub_pxe_pxenv;
static grub_uint32_t grub_pxe_your_ip;
static grub_uint32_t grub_pxe_default_server_ip;
static grub_uint32_t grub_pxe_default_gateway_ip;
@ -58,41 +58,47 @@ struct grub_pxe_data
static grub_uint32_t pxe_rm_entry = 0;
static struct grub_pxenv *
static struct grub_pxe_bangpxe *
grub_pxe_scan (void)
{
struct grub_bios_int_registers regs;
struct grub_pxenv *ret;
void *pxe;
struct grub_pxenv *pxenv;
struct grub_pxe_bangpxe *bangpxe;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
regs.ebx = 0;
regs.ecx = 0;
regs.eax = 0x5650;
regs.es = 0;
grub_bios_interrupt (0x1a, &regs);
if ((regs.eax & 0xffff) != 0x564e)
return NULL;
ret = (struct grub_pxenv *) ((regs.es << 4) + (regs.ebx & 0xffff));
if (grub_memcmp (ret->signature, GRUB_PXE_SIGNATURE, sizeof (ret->signature))
pxenv = (struct grub_pxenv *) ((regs.es << 4) + (regs.ebx & 0xffff));
if (grub_memcmp (pxenv->signature, GRUB_PXE_SIGNATURE,
sizeof (pxenv->signature))
!= 0)
return NULL;
if (ret->version < 0x201)
if (pxenv->version < 0x201)
return NULL;
pxe = (void *) ((((ret->pxe_ptr & 0xffff0000) >> 16) << 4)
+ (ret->pxe_ptr & 0xffff));
if (!pxe)
bangpxe = (void *) ((((pxenv->pxe_ptr & 0xffff0000) >> 16) << 4)
+ (pxenv->pxe_ptr & 0xffff));
if (!bangpxe)
return NULL;
/* !PXE */
if (*(grub_uint32_t *) pxe != 0x45585021)
if (grub_memcmp (bangpxe->signature, GRUB_PXE_BANGPXE_SIGNATURE,
sizeof (bangpxe->signature)) != 0)
return NULL;
pxe_rm_entry = ret->rm_entry;
return ret;
pxe_rm_entry = bangpxe->rm_entry;
return bangpxe;
}
static int
@ -483,7 +489,7 @@ parse_dhcp_vendor (void *vend, int limit)
static void
grub_pxe_detect (void)
{
struct grub_pxenv *pxenv;
struct grub_pxe_bangpxe *pxenv;
struct grub_pxenv_get_cached_info ci;
struct grub_pxenv_boot_player *bp;

View file

@ -192,6 +192,19 @@ struct grub_pxenv
grub_uint32_t pxe_ptr; /* SEG:OFF to !PXE struct. */
} __attribute__ ((packed));
struct grub_pxe_bangpxe
{
grub_uint8_t signature[4];
#define GRUB_PXE_BANGPXE_SIGNATURE "!PXE"
grub_uint8_t length;
grub_uint8_t chksum;
grub_uint8_t rev;
grub_uint8_t reserved;
grub_uint32_t undiromid;
grub_uint32_t baseromid;
grub_uint32_t rm_entry;
} __attribute__ ((packed));
struct grub_pxenv_get_cached_info
{
grub_uint16_t status;
@ -306,7 +319,7 @@ struct grub_pxenv_unload_stack
int EXPORT_FUNC(grub_pxe_call) (int func, void * data, grub_uint32_t pxe_rm_entry);
extern struct grub_pxenv *grub_pxe_pxenv;
extern struct grub_pxe_bangpxe *grub_pxe_pxenv;
void grub_pxe_unload (void);