rulimine/stage23/pxe/pxe.c

48 lines
1.2 KiB
C
Raw Normal View History

2021-03-02 12:23:43 +03:00
#if defined (bios)
2020-11-05 03:37:45 +03:00
#include <lib/print.h>
#include <lib/real.h>
#include <pxe/pxe.h>
#include <lib/libc.h>
#include <lib/blib.h>
void set_pxe_fp(uint32_t fp);
void pxe_init(void) {
//pxe installation check
struct rm_regs r = { 0 };
r.ebx = 0;
r.ecx = 0;
r.eax = 0x5650;
r.es = 0;
rm_int(0x1a, &r, &r);
if ((r.eax & 0xffff) != 0x564e) {
panic("PXE installation check failed");
}
struct pxenv* pxenv = { 0 };
pxenv = (struct pxenv*)((r.es << 4) + (r.ebx & 0xffff));
if (memcmp(pxenv->signature, PXE_SIGNATURE, sizeof(pxenv->signature)) != 0) {
panic("PXENV structure signature corrupted");
}
if (pxenv->version < 0x201) {
//we won't support pxe < 2.1, grub does this too and it seems to work fine
panic("pxe version too old");
2020-11-05 03:37:45 +03:00
}
struct bangpxe* bangpxe = (struct bangpxe*)((((pxenv->pxe_ptr & 0xffff0000) >> 16) << 4) + (pxenv->pxe_ptr & 0xffff));
if (memcmp(bangpxe->signature, PXE_BANGPXE_SIGNATURE,
sizeof(bangpxe->signature))
!= 0) {
panic("!pxe signature corrupted");
}
set_pxe_fp(bangpxe->rm_entry);
print("Successfully initialized pxe");
}
2021-03-02 12:23:43 +03:00
#endif