summaryrefslogtreecommitdiff
path: root/layout.inc
blob: c800f1b183ce15e8eeb4e45cb5f5d7c494e71f92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
; -----------------------------------------------------------------------
;
;   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
;
;   This program is free software; you can redistribute it and/or modify
;   it under the terms of the GNU General Public License as published by
;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
;   Bostom MA 02111-1307, USA; either version 2 of the License, or
;   (at your option) any later version; incorporated herein by reference.
;
; -----------------------------------------------------------------------

;
; layout.inc
;
; Memory layout of segments
;


; Memory below 0800h is reserved for the BIOS and the MBR.
BSS_START	equ 0800h

; Text starts at the load address of 07C00h.
TEXT_START	equ 7C00h

; The secondary BSS section, above the text; we really wish we could
; just make it follow .bcopy32 or hang off the end,
; but it doesn't seem to work that way.
LATEBSS_START	equ 0B800h

; Reserve memory for the stack.  This causes checkov to abort the
; compile if we violate this space.
STACK_SIZE	equ 4096
STACK_START	equ TEXT_START-STACK_SIZE

%ifdef MAP
		[map all MAP]
%endif

;
; The various sections and their relationship
;
		org TEXT_START

		; Use .earlybss for things that MUST be in low memory.
		section .earlybss	nobits start=BSS_START
		section .bcopy32	align=4 valign=16 follows=.data vfollows=.earlybss
		section .config		align=4 valign=16 follows=.bcopy32 vfollows=.bcopy32
		section .config.end	nobits valign=4 vfollows=.config

		; Use .bss for things that doesn't have to be in low memory;
		; with .bss1 and .bss2 to offload.  .earlybss should be used
		; for things that absolutely have to be below 0x7c00.
		section .bss		nobits valign=16 vfollows=.config.end

		; 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.
%if IS_PXELINUX
		section .rbfg		nobits start=0x5680
RBFG_brainfuck:	resb 2048		; Bigger than an Ethernet packet...
%endif

		; For section following .rbfg
%if IS_PXELINUX
		section .bss2		nobits valign=16 vfollows=.rbfg
%else
		section .bss2		nobits valign=16 vfollows=.bss
%endif

		section .text		start=TEXT_START
		; NASM BUG: .data always follows .text; can't override
		section .data		align=16 ; follows=.text

		; This empty section works around a NASM bug with regards
		; to follows= and nobits sections following a section which
		; has VMA != LMA.
		section .advpad		progbits align=512 follows=.config

		section .adv		nobits align=512 follows=.advpad

		; .uibss contains bss data which is guaranteed to be
		; safe to clobber during the loading of the image.  This
		; is because while loading the primary image we will clobber
		; the spillover from the last fractional sector load.
		section .uibss		nobits align=16 follows=.adv

		; Normal bss...
		section .bss1		nobits align=16 follows=.uibss

		; Reserve space for stack
		section .stack		nobits align=16 start=STACK_START
Stack		resb	STACK_SIZE