|
; $Id: layout.inc,v 1.1 2007-09-01 22:44:05 niro Exp $ |
|
1 |
; ----------------------------------------------------------------------- |
; ----------------------------------------------------------------------- |
2 |
; |
; |
3 |
; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved |
; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved |
4 |
|
; Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin |
5 |
; |
; |
6 |
; This program is free software; you can redistribute it and/or modify |
; This program is free software; you can redistribute it and/or modify |
7 |
; it under the terms of the GNU General Public License as published by |
; it under the terms of the GNU General Public License as published by |
17 |
; Memory layout of segments |
; Memory layout of segments |
18 |
; |
; |
19 |
|
|
20 |
|
; Default to 16-bit code |
21 |
|
bits 16 |
22 |
|
|
23 |
; Memory below 0800h is reserved for the BIOS and the MBR. |
; Memory below 0800h is reserved for the BIOS and the MBR. |
24 |
BSS_START equ 0800h |
BSS_START equ 0800h |
26 |
; Text starts at the load address of 07C00h. |
; Text starts at the load address of 07C00h. |
27 |
TEXT_START equ 7C00h |
TEXT_START equ 7C00h |
28 |
|
|
29 |
|
; |
30 |
|
; Stack layout |
31 |
|
; |
32 |
|
; PXELINUX: There are apparently some AMI BIOSes in the field which |
33 |
|
; put their BEV stack somewhere below 7C00h (and therefore don't |
34 |
|
; handle localboot properly), so avoid that immediate memory region. |
35 |
|
; The range that is known to be bad is approximately 75E8..7C00; the |
36 |
|
; lower bound is tight. |
37 |
|
; |
38 |
|
global STACK_LEN, STACK_TOP, STACK_BASE |
39 |
|
STACK_LEN equ 4096 |
40 |
|
%if IS_PXELINUX |
41 |
|
STACK_TOP equ 7000h |
42 |
|
%else |
43 |
|
STACK_TOP equ 7c00h |
44 |
|
%endif |
45 |
|
STACK_BASE equ STACK_TOP - STACK_LEN |
46 |
|
|
47 |
; The secondary BSS section, above the text; we really wish we could |
; The secondary BSS section, above the text; we really wish we could |
48 |
; just make it follow .bcopy32 or hang off the end, |
; just make it follow .bcopy32 or hang off the end, |
49 |
; but it doesn't seem to work that way. |
; but it doesn't seem to work that way. |
50 |
LATEBSS_START equ 0B000h |
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 |
|
51 |
|
|
52 |
%ifdef MAP |
; |
53 |
[map all MAP] |
; The various sections and their relationship |
54 |
|
; |
55 |
|
; Use .earlybss for things that MUST be in low memory. |
56 |
|
section .earlybss nobits |
57 |
|
section .config write progbits align=4 |
58 |
|
section .replacestub exec write progbits align=16 |
59 |
|
|
60 |
|
; Use .bss for things that doesn't have to be in low memory; |
61 |
|
; with .bss1 and .bss2 to offload. .earlybss should be used |
62 |
|
; for things that absolutely have to be below 0x7c00. |
63 |
|
section .bss write nobits align=16 |
64 |
|
|
65 |
|
%if 0 ; IS_PXELINUX |
66 |
|
; Warning here: RBFG build 22 randomly overwrites |
67 |
|
; memory location [0x5680,0x576c), possibly more. It |
68 |
|
; seems that it gets confused and screws up the |
69 |
|
; pointer to its own internal packet buffer and starts |
70 |
|
; writing a received ARP packet into low memory. |
71 |
|
section .rbfg write nobits |
72 |
|
RBFG_brainfuck: resb 2048 ; Bigger than an Ethernet packet... |
73 |
%endif |
%endif |
74 |
|
|
75 |
|
section .bss2 write nobits align=16 |
76 |
|
|
77 |
|
section .text exec write progbits align=16 |
78 |
|
section .bcopyxx exec write progbits align=16 |
79 |
|
section .data write progbits align=16 |
80 |
|
|
81 |
|
section .adv write nobits align=512 |
82 |
|
|
83 |
|
; .uibss contains bss data which is guaranteed to be |
84 |
|
; safe to clobber during the loading of the image. This |
85 |
|
; is because while loading the primary image we will clobber |
86 |
|
; the spillover from the last fractional sector load. |
87 |
|
section .uibss write nobits align=16 |
88 |
|
|
89 |
|
; Normal bss... |
90 |
|
section .bss1 write nobits align=16 |
91 |
|
|
92 |
|
; Symbols from linker script |
93 |
|
%macro SECINFO 1 |
94 |
|
extern __%1_start, __%1_lma, __%1_end |
95 |
|
extern __%1_len, __%1_dwords |
96 |
|
%endmacro |
97 |
|
SECINFO config |
98 |
|
SECINFO replacestub |
99 |
|
|
100 |
|
global _start |
101 |
|
|
102 |
|
section .text |
103 |
|
|
104 |
; |
; |
105 |
; The various sections and their relationship |
; Segment assignments in the bottom 640K |
106 |
|
; Keep the low-memory footprint as small as possible... overrun is a hard |
107 |
|
; failure! |
108 |
|
; |
109 |
|
; 0000h - main code/data segment (and BIOS segment) |
110 |
|
|
111 |
|
xfer_buf_seg equ 1000h |
112 |
|
aux_seg equ 2000h |
113 |
|
|
114 |
|
serial_buf_size equ 4096 ; Should be a power of 2 |
115 |
|
|
116 |
|
; |
117 |
|
; Contents of aux_seg |
118 |
; |
; |
119 |
org TEXT_START |
struc aux |
120 |
|
.fontbuf resb 8192 |
121 |
|
.serial resb serial_buf_size |
122 |
|
|
123 |
; NASM BUG: refers to hacks to handle NASM 0.98.38 bugs; might need |
alignb 4096 ; Align the next segment to 4K |
124 |
; conditional compilation |
endstruc |
125 |
|
|
126 |
section .earlybss nobits start=BSS_START |
aux_seg_end equ aux_seg + (aux_size >> 4) |
127 |
section .bcopy32 align=4 valign=16 follows=.data vfollows=.earlybss |
|
128 |
; NASM BUG: follows= here should be vfollows= |
; |
129 |
section .bss nobits align=256 follows=.bcopy32 |
; Bounce buffer for I/O to high mem |
130 |
|
; Note: we keep all the segments page-aligned, even if that probably |
131 |
section .text start=TEXT_START |
; is somewhat excessive. Sector alignment is obligatory, however. |
132 |
; NASM BUG: follows=.text not accepted here |
; |
133 |
section .data align=16 ; follows=.text |
|
134 |
|
%if IS_ISOLINUX |
135 |
; NASM BUG: We would like to do follows=.bcopy32 |
; ISOLINUX doesn't have a block cache yet |
136 |
section .latebss nobits align=16 start=LATEBSS_START |
real_mode_seg equ aux_seg_end |
137 |
|
%else |
138 |
; Reserve space for stack |
cache_seg equ aux_seg_end ; 64K area for metadata cache |
139 |
section .stack nobits align=16 start=STACK_START |
real_mode_seg equ cache_seg + 1000h |
140 |
Stack resb STACK_SIZE |
|
141 |
|
pktbuf_seg equ cache_seg ; PXELINUX packet buffers |
142 |
|
%endif |
143 |
|
|
144 |
|
comboot_seg equ real_mode_seg ; COMBOOT image loading zone |