; necessary code into the trackbuf area before doing the copy,
; and do adjustments to anything except BSS area references.
;
+; NOTE: Since PXELINUX relocates itself, put all these
+; references in the ".earlybss" segment.
+;
; After performing the copy, this routine resets the stack and
; jumps to 0:7c00.
;
; ESI, EDI, ECX - same as bcopy
; On stack - initial state (fd, ad, ds, es, fs, gs)
;
-ADJUST equ (__bcopy_start - $$) + 7C00h - BSS_START
+ADJUST equ (__bcopy_start - $$) + TEXT_START - BSS_START
align 2
adjlist dw bcopy_gdt.adj1 - ADJUST
jmp 0:7c00h
__bcopy_end:
- section .bss
+ section .earlybss
A20Test resw 1 ; Counter for testing status of A20
A20Type resw 1 ; A20 type
A20Tries resb 1 ; Times until giving up on A20
;
; Memory below this point is reserved for the BIOS and the MBR
;
-BSS_START equ 1000h
- section .bss start=BSS_START
+BSS_START equ 0800h
+ section .earlybss nobits start=BSS_START
trackbufsize equ 8192
trackbuf resb trackbufsize ; Track buffer goes here
getcbuf resb trackbufsize
- ; ends at 5000h
+ ; ends at 4800h
+ section .bss nobits align=256 follows=.earlybss
SuperBlock resb 1024 ; ext2 superblock
SuperInfo resq 16 ; DOS superblock expanded
ClustSize resd 1 ; Bytes/cluster ("block")
section .text
- org 7C00h
+TEXT_START equ 7C00h
+ org TEXT_START
;
; Some of the things that have to be saved very early are saved
; "close" to the initial stack pointer offset, in order to
;
; Memory below this point is reserved for the BIOS and the MBR
;
-BSS_START equ 1000h
- section .bss start=BSS_START
+BSS_START equ 0800h
+ section .earlybss nobits start=BSS_START
trackbufsize equ 8192
trackbuf resb trackbufsize ; Track buffer goes here
getcbuf resb trackbufsize
-; ends at 5000h
+; ends at 4800h
+ section .bss nobits align=256 follows=.earlybss
alignb 4
ISOFileName resb 64 ; ISO filename canonicalization buffer
ISOFileNameEnd equ $
xbs_vgatmpbuf equ 2*trackbufsize
section .text
- org 7C00h
+TEXT_START equ 7C00h
+ org TEXT_START
;;
;; Primary entry point. Because BIOSes are buggy, we only load the first
;; CD-ROM sector (2K) of the file, so the number one priority is actually
;
; Memory below this point is reserved for the BIOS and the MBR
;
-BSS_START equ 1000h
- section .bss start=BSS_START
+BSS_START equ 0800h
+ section .earlybss nobits start=BSS_START
trackbufsize equ 8192
trackbuf resb trackbufsize ; Track buffer goes here
getcbuf resb trackbufsize
- ; ends at 5000h
+ ; ends at 4800h
-; Warning here: RBFG build 22 randomly overwrites memory location
-; [0x5680,0x576c), possibly more. It seems that it gets confused and
-; screws up the pointer to its own internal packet buffer and starts
-; writing a received ARP packet into low memory.
-RBFB_brainfuck resb 800h
+ ; Put some large buffers here, before RBFG_brainfuck,
+ ; where we can still carefully control the address
+ ; assignments...
+
+ alignb open_file_t_size
+Files resb MAX_OPEN*open_file_t_size
alignb FILENAME_MAX
BootFile resb 256 ; Boot file from DHCP packet
PathPrefix resb 256 ; Path prefix derived from boot file
DotQuadBuf resb 16 ; Buffer for dotted-quad IP address
IPOption resb 80 ; ip= option buffer
+
+; Warning here: RBFG build 22 randomly overwrites memory location
+; [0x5680,0x576c), possibly more. It seems that it gets confused and
+; screws up the pointer to its own internal packet buffer and starts
+; writing a received ARP packet into low memory.
+RBFG_brainfuck resb 0E00h
+
+ section .bss nobits align=256 follows=.earlybss
alignb 4
InitStack resd 1 ; Pointer to reset stack
RebootTime resd 1 ; Reboot timeout, if set by option
.reserved: resw 10 ; Reserved
pxe_unload_stack_pkt_len equ $-pxe_unload_stack_pkt
- alignb open_file_t_size
-Files resb MAX_OPEN*open_file_t_size
-
alignb 16
; BOOTP/DHCP packet buffer
xbs_vgatmpbuf equ 2*trackbufsize
section .text
- org 7C00h
+ ;
+ ; PXELINUX needs more BSS than the other derivatives;
+ ; therefore we relocate it from 7C00h on startup
+ ;
+TEXT_START equ 9000h
+ org TEXT_START
StackBuf equ $-44 ; Base of stack if we use our own
;
;
bootsec equ $
_start:
- jmp 0:_start1 ; Canonicalize address
-_start1:
pushfd ; Paranoia... in case of return to PXE
pushad ; ... save as much state as possible
push ds
push fs
push gs
+ mov si,ldlinux_end-(TEXT_START-7C00h)-4
+ mov di,ldlinux_end-4
+ mov cx,ldlinux_end-TEXT_START
+ shr cx,2
+ std ; Overlapping areas, copy backwards
+ rep movsb
+
+ jmp 0:_start1 ; Canonicalize address
+_start1:
mov bp,sp
les bx,[bp+48] ; ES:BX -> !PXE or PXENV+ structure
%include "highmem.inc" ; High memory sizing
%include "strcpy.inc" ; strcpy()
%include "rawcon.inc" ; Console I/O w/o using the console functions
+%include "dnsresolv.inc" ; DNS resolver
; -----------------------------------------------------------------------------
; Begin data section