1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../memtest86/multiboot.patch.disabled
5 # Copyright (C) 2010 - 2019 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 diff -Nur memtest86+-4.00.old/head.S memtest86+-4.00/head.S
18 --- memtest86+-4.00.old/head.S 2009-09-22 02:35:46.000000000 +0200
19 +++ memtest86+-4.00/head.S 2010-01-15 17:54:17.000000000 +0100
28 +#include "multiboot.h"
31 * References to members of the boot_cpu_data structure.
36 + /* Store MBI pointer */
38 + cmpl $MULTIBOOT_BOOTLOADER_MAGIC, %eax
43 /* Ensure I have a stack pointer */
48 addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx
50 + /* Move MBI pointer to a safe place */
53 + movl %ecx, mbiptr@GOTOFF(%ebx)
57 + /* Multiboot header */
59 + .long MULTIBOOT_HEADER_MAGIC
61 + .long -MULTIBOOT_HEADER_MAGIC
64 /* Pick the appropriate stack address */
65 leal stack_top@GOTOFF(%ebx), %esp
77 diff -Nur memtest86+-4.00.old/init.c memtest86+-4.00/init.c
78 --- memtest86+-4.00.old/init.c 2009-09-22 02:35:46.000000000 +0200
79 +++ memtest86+-4.00/init.c 2010-01-15 17:54:17.000000000 +0100
84 +#include "multiboot.h"
86 #define rdmsr(msr,val1,val2) \
87 __asm__ __volatile__("rdmsr" \
89 /* Determine the memory map */
90 if ((firmware == FIRMWARE_UNKNOWN) &&
91 (memsz_mode != SZ_MODE_PROBE)) {
92 - if (query_linuxbios()) {
93 + if (query_multiboot()) {
94 + firmware = FIRMWARE_MULTIBOOT;
96 + else if (query_linuxbios()) {
97 firmware = FIRMWARE_LINUXBIOS;
99 else if (query_pcbios()) {
100 diff -Nur memtest86+-4.00.old/main.c memtest86+-4.00/main.c
101 --- memtest86+-4.00.old/main.c 2009-09-22 02:35:46.000000000 +0200
102 +++ memtest86+-4.00/main.c 2010-01-15 17:54:17.000000000 +0100
107 +#include "multiboot.h"
111 +extern struct multiboot_info *mbiptr;
115 const struct tseq tseq[] = {
116 @@ -151,11 +154,15 @@
120 - if (*OLD_CL_MAGIC_ADDR != OLD_CL_MAGIC)
122 + if (mbiptr && (mbiptr->flags & MULTIBOOT_INFO_CMDLINE)) {
123 + cmdline = (void *) mbiptr->cmdline;
125 + if (*OLD_CL_MAGIC_ADDR != OLD_CL_MAGIC)
128 - unsigned short offset = *OLD_CL_OFFSET_ADDR;
129 - cmdline = MK_PTR(INITSEG, offset);
130 + unsigned short offset = *OLD_CL_OFFSET_ADDR;
131 + cmdline = MK_PTR(INITSEG, offset);
134 /* skip leading spaces */
135 while (*cmdline == ' ')
136 diff -Nur memtest86+-4.00.old/Makefile memtest86+-4.00/Makefile
137 --- memtest86+-4.00.old/Makefile 2009-09-22 02:35:46.000000000 +0200
138 +++ memtest86+-4.00/Makefile 2010-01-15 17:59:50.000000000 +0100
141 CFLAGS= -Wall -march=i486 -m32 -O2 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC
143 +# This reverts a change introduced with recent binutils (post
144 +# http://sourceware.org/bugzilla/show_bug.cgi?id=10569). Needed to
145 +# ensure Multiboot header is within the limit offset.
146 +LD += -z max-page-size=0x1000
148 OBJS= head.o reloc.o main.o test.o init.o lib.o patn.o screen_buffer.o \
149 config.o linuxbios.o memsize.o pci.o controller.o random.o spd.o \
150 - error.o dmi.o cpuid.o
151 + error.o dmi.o cpuid.o multiboot.o
153 all: memtest.bin memtest
155 diff -Nur memtest86+-4.00.old/memsize.c memtest86+-4.00/memsize.c
156 --- memtest86+-4.00.old/memsize.c 2009-09-22 02:35:46.000000000 +0200
157 +++ memtest86+-4.00/memsize.c 2010-01-15 17:54:17.000000000 +0100
160 static void memsize_bios()
162 - if (firmware == FIRMWARE_PCBIOS) {
163 + if (firmware == FIRMWARE_PCBIOS || firmware == FIRMWARE_MULTIBOOT) {
166 else if (firmware == FIRMWARE_LINUXBIOS) {
167 diff -Nur memtest86+-4.00.old/multiboot.c memtest86+-4.00/multiboot.c
168 --- memtest86+-4.00.old/multiboot.c 1970-01-01 01:00:00.000000000 +0100
169 +++ memtest86+-4.00/multiboot.c 2010-01-15 17:54:17.000000000 +0100
173 + * Copyright (C) 2008,2009 Robert Millan
175 + * Loosely based on linuxbios.c, which is:
177 + * Released under version 2 of the Gnu Public License.
178 + * By Eric Biederman
181 +#include "multiboot.h"
184 +extern struct multiboot_info *mbiptr;
186 +int query_multiboot(void)
188 + struct multiboot_mmap_entry *mem;
194 + if (!mbiptr->mmap_addr) {
197 + if ((mbiptr->flags & MULTIBOOT_INFO_MEM_MAP) == 0) {
201 + mem = (struct multiboot_mmap_entry *) mbiptr->mmap_addr;
202 + mem_info.e820_nr = 0;
204 + for (i = 0; i < E820MAX; i++) {
205 + if ((multiboot_uint32_t) mem >= (mbiptr->mmap_addr + mbiptr->mmap_length)) {
209 + mem_info.e820[mem_info.e820_nr].addr = mem->addr;
210 + mem_info.e820[mem_info.e820_nr].size = mem->len;
211 + /* Multiboot spec defines available / reserved types to match with E820. */
212 + mem_info.e820[mem_info.e820_nr].type = mem->type;
213 + mem_info.e820_nr++;
215 + mem = (struct multiboot_mmap_entry *) ((multiboot_uint32_t) mem + mem->size + sizeof (mem->size));
220 diff -Nur memtest86+-4.00.old/multiboot.h memtest86+-4.00/multiboot.h
221 --- memtest86+-4.00.old/multiboot.h 1970-01-01 01:00:00.000000000 +0100
222 +++ memtest86+-4.00/multiboot.h 2010-01-15 21:09:11.000000000 +0100
224 +/* multiboot.h - Multiboot header file. */
225 +/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
227 + * Permission is hereby granted, free of charge, to any person obtaining a copy
228 + * of this software and associated documentation files (the "Software"), to
229 + * deal in the Software without restriction, including without limitation the
230 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
231 + * sell copies of the Software, and to permit persons to whom the Software is
232 + * furnished to do so, subject to the following conditions:
234 + * The above copyright notice and this permission notice shall be included in
235 + * all copies or substantial portions of the Software.
237 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
238 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
239 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
240 + * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
241 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
242 + * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
245 +#ifndef MULTIBOOT_HEADER
246 +#define MULTIBOOT_HEADER 1
248 +/* How many bytes from the start of the file we search for the header. */
249 +#define MULTIBOOT_SEARCH 8192
251 +/* The magic field should contain this. */
252 +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
254 +/* This should be in %eax. */
255 +#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
257 +/* Alignment of multiboot modules. */
258 +#define MULTIBOOT_MOD_ALIGN 0x00001000
260 +/* Alignment of the multiboot info structure. */
261 +#define MULTIBOOT_INFO_ALIGN 0x00000004
263 +/* Flags set in the 'flags' member of the multiboot header. */
265 +/* Align all boot modules on i386 page (4KB) boundaries. */
266 +#define MULTIBOOT_PAGE_ALIGN 0x00000001
268 +/* Must pass memory information to OS. */
269 +#define MULTIBOOT_MEMORY_INFO 0x00000002
271 +/* Must pass video information to OS. */
272 +#define MULTIBOOT_VIDEO_MODE 0x00000004
274 +/* This flag indicates the use of the address fields in the header. */
275 +#define MULTIBOOT_AOUT_KLUDGE 0x00010000
277 +/* Flags to be set in the 'flags' member of the multiboot info structure. */
279 +/* is there basic lower/upper memory information? */
280 +#define MULTIBOOT_INFO_MEMORY 0x00000001
281 +/* is there a boot device set? */
282 +#define MULTIBOOT_INFO_BOOTDEV 0x00000002
283 +/* is the command-line defined? */
284 +#define MULTIBOOT_INFO_CMDLINE 0x00000004
285 +/* are there modules to do something with? */
286 +#define MULTIBOOT_INFO_MODS 0x00000008
288 +/* These next two are mutually exclusive */
290 +/* is there a symbol table loaded? */
291 +#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010
292 +/* is there an ELF section header table? */
293 +#define MULTIBOOT_INFO_ELF_SHDR 0X00000020
295 +/* is there a full memory map? */
296 +#define MULTIBOOT_INFO_MEM_MAP 0x00000040
298 +/* Is there drive info? */
299 +#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080
301 +/* Is there a config table? */
302 +#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100
304 +/* Is there a boot loader name? */
305 +#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200
307 +/* Is there a APM table? */
308 +#define MULTIBOOT_INFO_APM_TABLE 0x00000400
310 +/* Is there video information? */
311 +#define MULTIBOOT_INFO_VBE_INFO 0x00000800
312 +#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
316 +typedef unsigned char multiboot_uint8_t;
317 +typedef unsigned short multiboot_uint16_t;
318 +typedef unsigned int multiboot_uint32_t;
319 +typedef unsigned long long multiboot_uint64_t;
321 +struct multiboot_header
323 + /* Must be MULTIBOOT_MAGIC - see above. */
324 + multiboot_uint32_t magic;
326 + /* Feature flags. */
327 + multiboot_uint32_t flags;
329 + /* The above fields plus this one must equal 0 mod 2^32. */
330 + multiboot_uint32_t checksum;
332 + /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
333 + multiboot_uint32_t header_addr;
334 + multiboot_uint32_t load_addr;
335 + multiboot_uint32_t load_end_addr;
336 + multiboot_uint32_t bss_end_addr;
337 + multiboot_uint32_t entry_addr;
339 + /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
340 + multiboot_uint32_t mode_type;
341 + multiboot_uint32_t width;
342 + multiboot_uint32_t height;
343 + multiboot_uint32_t depth;
346 +/* The symbol table for a.out. */
347 +struct multiboot_aout_symbol_table
349 + multiboot_uint32_t tabsize;
350 + multiboot_uint32_t strsize;
351 + multiboot_uint32_t addr;
352 + multiboot_uint32_t reserved;
354 +typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
356 +/* The section header table for ELF. */
357 +struct multiboot_elf_section_header_table
359 + multiboot_uint32_t num;
360 + multiboot_uint32_t size;
361 + multiboot_uint32_t addr;
362 + multiboot_uint32_t shndx;
364 +typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
366 +struct multiboot_color
368 + multiboot_uint8_t red;
369 + multiboot_uint8_t green;
370 + multiboot_uint8_t blue;
373 +struct multiboot_info
375 + /* Multiboot info version number */
376 + multiboot_uint32_t flags;
378 + /* Available memory from BIOS */
379 + multiboot_uint32_t mem_lower;
380 + multiboot_uint32_t mem_upper;
382 + /* "root" partition */
383 + multiboot_uint32_t boot_device;
385 + /* Kernel command line */
386 + multiboot_uint32_t cmdline;
388 + /* Boot-Module list */
389 + multiboot_uint32_t mods_count;
390 + multiboot_uint32_t mods_addr;
394 + multiboot_aout_symbol_table_t aout_sym;
395 + multiboot_elf_section_header_table_t elf_sec;
398 + /* Memory Mapping buffer */
399 + multiboot_uint32_t mmap_length;
400 + multiboot_uint32_t mmap_addr;
402 + /* Drive Info buffer */
403 + multiboot_uint32_t drives_length;
404 + multiboot_uint32_t drives_addr;
406 + /* ROM configuration table */
407 + multiboot_uint32_t config_table;
409 + /* Boot Loader Name */
410 + multiboot_uint32_t boot_loader_name;
413 + multiboot_uint32_t apm_table;
416 + multiboot_uint32_t vbe_control_info;
417 + multiboot_uint32_t vbe_mode_info;
418 + multiboot_uint16_t vbe_mode;
419 + multiboot_uint16_t vbe_interface_seg;
420 + multiboot_uint16_t vbe_interface_off;
421 + multiboot_uint16_t vbe_interface_len;
423 + multiboot_uint64_t framebuffer_addr;
424 + multiboot_uint32_t framebuffer_pitch;
425 + multiboot_uint32_t framebuffer_width;
426 + multiboot_uint32_t framebuffer_height;
427 + multiboot_uint8_t framebuffer_bpp;
428 +#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
429 +#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
430 +#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
431 + multiboot_uint8_t framebuffer_type;
434 + /* Indexed color. */
437 + struct multiboot_color *framebuffer_palette_addr;
438 + multiboot_uint16_t framebuffer_palette_num_colors;
441 + /* Direct RGB color. */
444 + multiboot_uint8_t framebuffer_red_field_position;
445 + multiboot_uint8_t framebuffer_red_mask_size;
446 + multiboot_uint8_t framebuffer_green_field_position;
447 + multiboot_uint8_t framebuffer_green_mask_size;
448 + multiboot_uint8_t framebuffer_blue_field_position;
449 + multiboot_uint8_t framebuffer_blue_mask_size;
453 +typedef struct multiboot_info multiboot_info_t;
455 +struct multiboot_mmap_entry
457 + multiboot_uint32_t size;
458 + multiboot_uint64_t addr;
459 + multiboot_uint64_t len;
460 +#define MULTIBOOT_MEMORY_AVAILABLE 1
461 +#define MULTIBOOT_MEMORY_RESERVED 2
462 + multiboot_uint32_t type;
463 +} __attribute__((packed));
464 +typedef struct multiboot_mmap_entry multiboot_memory_map_t;
466 +struct multiboot_mod_list
468 + /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
469 + multiboot_uint32_t mod_start;
470 + multiboot_uint32_t mod_end;
472 + /* Module command line */
473 + multiboot_uint32_t cmdline;
475 + /* padding to take it to 16 bytes (must be zero) */
476 + multiboot_uint32_t pad;
478 +typedef struct multiboot_mod_list multiboot_module_t;
480 +#endif /* ! ASM_FILE */
482 +#endif /* ! MULTIBOOT_HEADER */
483 diff -Nur memtest86+-4.00.old/test.h memtest86+-4.00/test.h
484 --- memtest86+-4.00.old/test.h 2009-09-22 02:35:46.000000000 +0200
485 +++ memtest86+-4.00/test.h 2010-01-15 17:54:17.000000000 +0100
487 void *memmove(void *dest, const void *src, ulong n);
488 int query_linuxbios(void);
489 int query_pcbios(void);
490 +int query_multiboot(void);
491 int insertaddress(ulong);
492 void printpatn(void);
493 void printpatn(void);
495 #define FIRMWARE_UNKNOWN 0
496 #define FIRMWARE_PCBIOS 1
497 #define FIRMWARE_LINUXBIOS 2
498 +#define FIRMWARE_MULTIBOOT 3
500 extern struct vars * const v;
501 extern unsigned char _start[], _end[], startup_32[];