|
| 1 | +/* |
| 2 | + * pxe.S Copyright (C) 2012 Michael Brown <mcb30@ipxe.org> |
| 3 | + * |
| 4 | + * pxe.S is loaded at 0x7c00 by the PXE ROM. It copies the 32-bit |
| 5 | + * portion to 0x10000 and jumps into setup.S. |
| 6 | + */ |
| 7 | + |
| 8 | +#include "defs.h" |
| 9 | + |
| 10 | +#define RMSIZE (0x200 + 0x200*SETUPSECS) |
| 11 | + |
| 12 | +#define PXENV_ENTRY 0x0a |
| 13 | +#define PXENV_UNDI_SHUTDOWN 0x0005 |
| 14 | + |
| 15 | +.code16 |
| 16 | +.section ".bootsect", "ax", @progbits |
| 17 | +.org 0 |
| 18 | +_pxe: |
| 19 | + |
| 20 | +.globl _main |
| 21 | +_main: |
| 22 | + /* Canonicalise addresses */ |
| 23 | + ljmp $BOOTSEG, $pxe_start |
| 24 | + |
| 25 | +pxe_start: |
| 26 | + /* Store PXENV+ entry point */ |
| 27 | + movl %es:PXENV_ENTRY(%bx), %eax |
| 28 | + movl %eax, %cs:pxenv_vector |
| 29 | + |
| 30 | + /* Copy 32-bit portion to TSTLOAD:0000. Perform copy in |
| 31 | + * reverse in 1kB blocks, since regions will overlap and we |
| 32 | + * need to copy more than the 64kB real-mode segment limit. |
| 33 | + */ |
| 34 | + movw $_syssize, %bx /* Length is _syssize (paragraphs) */ |
| 35 | + addw $63, %bx |
| 36 | + andw $~63, %bx /* Round up to nearest kB */ |
| 37 | + movw $(BOOTSEG + (RMSIZE >> 4)), %ax |
| 38 | + addw %bx, %ax |
| 39 | + movw %ax, %ds |
| 40 | + movw $TSTLOAD, %ax |
| 41 | + addw %bx, %ax |
| 42 | + movw %ax, %es |
| 43 | +1: movw %ds, %ax /* Decrement %ds and %es by 1kB */ |
| 44 | + subw $64, %ax |
| 45 | + movw %ax, %ds |
| 46 | + movw %es, %ax |
| 47 | + subw $64, %ax |
| 48 | + movw %ax, %es |
| 49 | + movw $256, %cx /* Copy 1kB block */ |
| 50 | + xorw %si, %si |
| 51 | + xorw %di, %di |
| 52 | + cld |
| 53 | + rep movsl |
| 54 | + subw $64, %bx |
| 55 | + jnz 1b |
| 56 | + |
| 57 | + /* Set up %ds and %es for access to local variables */ |
| 58 | + movw %cs, %ax |
| 59 | + movw %ax, %ds |
| 60 | + movw %ax, %es |
| 61 | + |
| 62 | + /* Shutdown NIC */ |
| 63 | + movw $PXENV_UNDI_SHUTDOWN, %bx |
| 64 | + movw $pxenv_undi_shutdown, %di |
| 65 | + lcall *pxenv_vector |
| 66 | + |
| 67 | + /* Jump to setup.S */ |
| 68 | + ljmp $(BOOTSEG + 0x20), $0 |
| 69 | + |
| 70 | +pxenv_vector: |
| 71 | + .word 0,0 |
| 72 | + |
| 73 | +pxenv_undi_shutdown: |
| 74 | + .word 0 /* Status */ |
| 75 | + |
| 76 | +.org 512 |
| 77 | +_epxe: |
0 commit comments