rulimine/stage23/pxe/pxe.s2.c

57 lines
1.3 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>
2021-03-13 11:08:01 +03:00
#include <mm/pmm.h>
2020-11-05 03:37:45 +03:00
void set_pxe_fp(uint32_t fp);
2021-03-13 11:08:01 +03:00
struct volume *pxe_bind_volume(void) {
struct volume *volume = ext_mem_alloc(sizeof(struct volume));
volume->pxe = true;
return volume;
}
2020-11-05 03:37:45 +03:00
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);
2021-05-11 07:46:42 +03:00
printv("pxe: Successfully initialized");
2020-11-05 03:37:45 +03:00
}
2021-03-02 12:23:43 +03:00
#endif