pxe: use core for atomic modification of certain volatiles
[syslinux/sherbszt.git] / core / layout.inc
blob7c8ce5d21d0102b397fa8f64c4ae5547a02dd460
1 ; -----------------------------------------------------------------------
3 ;   Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
4 ;   Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
6 ;   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
8 ;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ;   Bostom MA 02111-1307, USA; either version 2 of the License, or
10 ;   (at your option) any later version; incorporated herein by reference.
12 ; -----------------------------------------------------------------------
15 ; layout.inc
17 ; Memory layout of segments
20                 ; Default to 16-bit code
21                 bits 16
23 ; Memory below 0800h is reserved for the BIOS and the MBR.
24 BSS_START       equ 0800h
26 ; Text starts at the load address of 07C00h.
27 TEXT_START      equ 7C00h
30 ; 16-bit stack layout
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
47 ; The secondary BSS section, above the text; we really wish we could
48 ; just make it follow .bcopy32 or hang off the end,
49 ; but it doesn't seem to work that way.
50 LATEBSS_START   equ 0B800h
53 ; 32-bit stack layout
55                 global STACK32_LEN
56 STACK32_LEN     equ 64*1024
58                 section .stack          nobits write align=4096
59                 resb STACK32_LEN
62 ; The various sections and their relationship
64                 ; Use .earlybss for things that MUST be in low memory.
65                 section .earlybss       nobits write
66                 section .config         write progbits align=4
67                 section .replacestub    exec write progbits align=16
68                 section .gentextnr      exec write nobits align=16
69                 section .stack16        write nobits align=16
71                 ; Use .bss16 for things that doesn't have to be in low memory;
72                 ; .earlybss should be used for things that absolutely have
73                 ; to be below 0x7c00.
74                 section .bss16          write nobits align=16
76 %if 0 ; IS_PXELINUX
77                 ; Warning here: RBFG build 22 randomly overwrites
78                 ; memory location [0x5680,0x576c), possibly more.  It
79                 ; seems that it gets confused and screws up the
80                 ; pointer to its own internal packet buffer and starts
81                 ; writing a received ARP packet into low memory.
82                 section .rbfg           write nobits
83 RBFG_brainfuck: resb 2048               ; Bigger than an Ethernet packet...
84 %endif
86                 section .init           exec write progbits align=1
87                 section .text16         exec write progbits align=1
88                 section .textnr         exec nowrite progbits align=1
89                 section .bcopyxx.text   exec nowrite progbits align=16
90                 section .bcopyxx.data   noexec write progbits align=16
91                 section .data16         noexec write progbits align=16
93                 section .adv            write nobits align=512
95                 ; .uibss contains bss data which is guaranteed to be
96                 ; safe to clobber during the loading of the image.  This
97                 ; is because while loading the primary image we will clobber
98                 ; the spillover from the last fractional sector load.
99                 section .uibss          write nobits align=16
101                 ; Symbols from linker script
102 %macro SECINFO 1
103                 extern __%1_start, __%1_lma, __%1_end
104                 extern __%1_len, __%1_dwords
105 %endmacro
106                 SECINFO bss16
107                 SECINFO uibss
108                 SECINFO config
109                 SECINFO replacestub
110                 SECINFO bcopyxx
112                 SECINFO pm_code
113                 SECINFO high_clear
115                 SECINFO bss
117                 extern free_high_memory
119                 global _start
121                 section .text16
124 ; Segment assignments in the bottom 640K
125 ; Keep the low-memory footprint as small as possible... overrun is a hard
126 ; failure!
129 serial_buf_size equ 4096                ; Should be a power of 2
132 ; Contents of aux_seg
134                 extern aux_seg          ; Actual segment assigned by linker
136                 struc aux
137 .fontbuf        resb 8192
138 .serial         resb serial_buf_size
140                 alignb 4096             ; Align the next segment to 4K
141                 endstruc
143                 section .auxseg         write nobits align=16
144 auxseg          resb aux_size
147 ; Transfer buffer segment: guaranteed to be aligned 64K, used for disk I/O
148 ; One symbol for the segment number, one for the absolute address
150                 extern  xfer_buf_seg
151                 section .xfer_buf       write nobits align=65536
152                 global  core_xfer_buf
153 core_xfer_buf   resb 65536
156 ; Segment for the real mode code (needed as long as we have a in-kernel
157 ; loader and/or COM16 support.
158 ; One symbol for the segment number, one for the absolute address
160                 extern  real_mode_seg
161                 section .real_mode      write nobits align=65536
162                 global  core_real_mode
163 core_real_mode  resb 65536
164 comboot_seg     equ real_mode_seg       ; COMBOOT image loading zone
167 ; At the very end, the lowmem heap
169                 extern __lowmem_heap
170 min_lowmem_heap equ 65536
172                 section .text16