%include "strcpy.inc" ; strcpy()
%include "idle.inc" ; Idle handling
%include "adv.inc" ; Auxillary Data Vector
+
+; Note: the prefix section is included late, to avoid problems with some
+; versions of NASM that had issues with forward references to EQU symbols.
+%include "prefix.inc" ; Prefix section for prepcore
; Sector pointers
alignz 4
- global MaxInitDataSize
MaxInitDataSize equ 96 << 10
+MaxLMA equ 0x7c00+SECTOR_SIZE+MaxInitDataSize
SectorPtrs times MaxInitDataSize >> SECTOR_SHIFT dd 0
SectorPtrsEnd equ $
; address (7C00h) is *not* 2K-sector-aligned, the safest
; way to deal with this is to load into the xfer_buf_seg
; and then copy the data in place.
+MaxLMA equ xfer_buf_seg << 4
+
mov bx,(7C00h+SECTOR_SIZE) >> 4
mov bp,[ImageSectors]
%endif
comboot_seg equ real_mode_seg ; COMBOOT image loading zone
-
-;
-; The prefix is a small structure that prefaces the actual code;
-; it gives the compression program necessary information.
-;
-
- section .prefix nowrite progbits align=16
-pfx_start dd _start ; Start of raw chunk
-pfx_compressed dd __pm_code_lma ; Start of compressed chunk
-pfx_cdatalen dd lzo_data_size ; Pointer to compressed size field
-%if IS_ISOLINUX
-pfx_checksum dd bi_length ; File length and checksum fields
-%else
-pfx_checksum dd 0 ; No checksum
-%endif
--- /dev/null
+;
+; The prefix is a small structure that prefaces the actual code;
+; it gives the compression program necessary information.
+;
+
+ section .prefix nowrite progbits align=16
+pfx_start dd _start ; Start of raw chunk
+pfx_compressed dd __pm_code_lma ; Start of compressed chunk
+pfx_cdatalen dd lzo_data_size ; Pointer to compressed size field
+%if IS_ISOLINUX
+pfx_checksum dd bi_length ; File length and checksum fields
+%else
+pfx_checksum dd 0 ; No checksum
+%endif
+pfx_maxlma dd MaxLMA ; Maximum size
+
+ section .text16
StackBuf equ $-44 ; Base of stack if we use our own
StackTop equ StackBuf
+ ; PXE loads the whole file, but assume it can't be more
+ ; than (384-31)K in size.
+MaxLMA equ 384*1024
+
;
; Primary entry point.
;
uint32_t pfx_compressed;
uint32_t pfx_cdatalen;
uint32_t pfx_checksum;
+ uint32_t pfx_maxlma;
};
static inline uint32_t get_32(const uint32_t * p)
set_32((uint32_t *) (infile + soff + 4), csum);
}
+ if (offset+outfile_len > get_32(&prefix->pfx_maxlma)) {
+ printf("%s: output too big (%lu, max %lu)\n",
+ (unsigned long)offset+outfile_len,
+ (unsigned long)get_32(&prefix->pfx_maxlma));
+ exit(1);
+ }
+
f = fopen(out_name, "wb");
if (f == NULL) {
printf("%s: cannot open output file %s\n", progname, out_name);