mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2025-02-25 18:55:23 -06:00
Optimize the JEP106 list by switching from relocated string pointers to offsets from the beginning of a string table, defined in a generated file.
Typically saves > 1400 bytes on x86, > 4000 bytes on x86_64.
This commit is contained in:
parent
5a046291fa
commit
18883ada5f
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,6 +11,7 @@
|
||||
build_version.h
|
||||
gdbscript
|
||||
memtest_shared_debug.lds
|
||||
jedec_id.h
|
||||
|
||||
# Binaries
|
||||
memtest_shared
|
||||
@ -21,6 +22,7 @@ memtest_shared.bin
|
||||
*.iso
|
||||
*.mbr
|
||||
*.debug
|
||||
generate_jep106
|
||||
|
||||
# Directories
|
||||
grub-iso
|
||||
|
@ -25,7 +25,7 @@ else
|
||||
MS_LDS=ldscripts/memtest_shared.lds
|
||||
endif
|
||||
|
||||
INC_DIRS = -I../boot -I../system -I../lib -I../tests -I../app -Iapp
|
||||
INC_DIRS = -I../boot -I../system -Isystem -I../lib -I../tests -I../app -Iapp
|
||||
|
||||
SYS_OBJS = system/acpi.o \
|
||||
system/cpuid.o \
|
||||
@ -36,6 +36,7 @@ SYS_OBJS = system/acpi.o \
|
||||
system/heap.o \
|
||||
system/hwctrl.o \
|
||||
system/hwquirks.o \
|
||||
system/jedec_id.o \
|
||||
system/keyboard.o \
|
||||
system/ohci.o \
|
||||
system/memctrl.o \
|
||||
@ -120,7 +121,19 @@ system/reloc.o: ../system/reloc32.c
|
||||
@mkdir -p system
|
||||
$(CC) -c $(CFLAGS) -fno-strict-aliasing $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||
|
||||
system/%.o: ../system/%.c
|
||||
tools/generate_jep106: ../tools/generate_jep106.c
|
||||
@mkdir -p tools
|
||||
$(CC) -std=c11 -Wall -Wextra -Wshadow -o $@ $<
|
||||
|
||||
system/jedec_id.h: tools/generate_jep106
|
||||
@mkdir -p system
|
||||
$< > system/jedec_id.h 2> system/jedec_id.s
|
||||
|
||||
system/jedec_id.o: system/jedec_id.h
|
||||
@mkdir -p system
|
||||
$(AS) system/jedec_id.s -o $@
|
||||
|
||||
system/%.o: ../system/%.c system/jedec_id.h
|
||||
@mkdir -p system
|
||||
$(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||
|
||||
@ -204,7 +217,7 @@ memtest.iso: memtest.mbr floppy.img esp.img
|
||||
iso: memtest.iso
|
||||
|
||||
clean:
|
||||
rm -rf boot system lib tests app *.img *.iso memtest* iso grub-*
|
||||
rm -rf boot system lib tests app tools *.img *.iso memtest* iso grub-*
|
||||
|
||||
# grub-memtest.iso uses GRUB as an intermediate bootloader to allow Memtest86+
|
||||
# to be started with the native USB keyboard drivers either enabled or disabled,
|
||||
|
@ -25,7 +25,7 @@ else
|
||||
MS_LDS=ldscripts/memtest_shared.lds
|
||||
endif
|
||||
|
||||
INC_DIRS = -I../boot -I../system -I../lib -I../tests -I../app -Iapp
|
||||
INC_DIRS = -I../boot -I../system -Isystem -I../lib -I../tests -I../app -Iapp
|
||||
|
||||
SYS_OBJS = system/acpi.o \
|
||||
system/cpuid.o \
|
||||
@ -33,9 +33,10 @@ SYS_OBJS = system/acpi.o \
|
||||
system/cpulocal.o \
|
||||
system/ehci.o \
|
||||
system/font.o \
|
||||
system/hwctrl.o \
|
||||
system/heap.o \
|
||||
system/hwctrl.o \
|
||||
system/hwquirks.o \
|
||||
system/jedec_id.o \
|
||||
system/keyboard.o \
|
||||
system/ohci.o \
|
||||
system/memctrl.o \
|
||||
@ -119,7 +120,19 @@ system/reloc.o: ../system/reloc64.c
|
||||
@mkdir -p system
|
||||
$(CC) -c $(CFLAGS) -fno-strict-aliasing $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||
|
||||
system/%.o: ../system/%.c
|
||||
tools/generate_jep106: ../tools/generate_jep106.c
|
||||
@mkdir -p tools
|
||||
$(CC) -std=c11 -Wall -Wextra -Wshadow -o $@ $<
|
||||
|
||||
system/jedec_id.h: tools/generate_jep106
|
||||
@mkdir -p system
|
||||
$< > system/jedec_id.h 2> system/jedec_id.s
|
||||
|
||||
system/jedec_id.o: system/jedec_id.h
|
||||
@mkdir -p system
|
||||
$(AS) system/jedec_id.s -o $@
|
||||
|
||||
system/%.o: ../system/%.c system/jedec_id.h
|
||||
@mkdir -p system
|
||||
$(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||
|
||||
@ -203,7 +216,7 @@ memtest.iso: memtest.mbr floppy.img esp.img
|
||||
iso: memtest.iso
|
||||
|
||||
clean:
|
||||
rm -rf boot system lib tests app *.img *.iso memtest* iso grub-*
|
||||
rm -rf boot system lib tests app tools *.img *.iso memtest* iso grub-*
|
||||
|
||||
# grub-memtest.iso uses GRUB as an intermediate bootloader to allow Memtest86+
|
||||
# to be started with the native USB keyboard drivers either enabled or disabled,
|
||||
|
@ -53,7 +53,7 @@ void print_spdi(spd_info spdi, uint8_t row)
|
||||
// Print Manufacturer from JEDEC106
|
||||
for (i = 0; i < JEP106_CNT; i++) {
|
||||
if (spdi.jedec_code == jep106[i].jedec_code) {
|
||||
curcol = printf(row, ++curcol, "- %s", jep106[i].name);
|
||||
curcol = printf(row, ++curcol, "- %s", JEP106_NAME(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
/* MemTest86+ V5 Specific code (GPL V2.0)
|
||||
* By Samuel DEMEULEMEESTER, memtest@memtest.org
|
||||
* https://x86.fr - https://www.memtest.org
|
||||
*
|
||||
* Generator by Lionel Debroux, lionel_debroux@yahoo.fr
|
||||
* ------------------------------------------------
|
||||
* Based on JEDEC JEP106-BA - January 2022
|
||||
*/
|
||||
|
||||
#define JEDEC_CONT_CODE_MAX 14
|
||||
|
||||
#define JEP106_CNT \
|
||||
sizeof(jep106)/sizeof(jep106[0])
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct __attribute__((packed)) spd_jedec_manufacturer {
|
||||
uint16_t jedec_code;
|
||||
@ -1682,3 +1684,56 @@ static const struct __attribute__((packed)) spd_jedec_manufacturer jep106[] = {
|
||||
{ 0x0F33, "Xllbyte" },
|
||||
{ 0xFFFF, "Unknown"}
|
||||
};
|
||||
|
||||
#define STR_SIZE (16384)
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
(void)argc, (void)argv;
|
||||
|
||||
char structstr[STR_SIZE];
|
||||
char stringstr[STR_SIZE];
|
||||
char idstr[5];
|
||||
|
||||
char * ptr1 = structstr;
|
||||
char * ptr2 = stringstr;
|
||||
|
||||
for (size_t i = 0; i < sizeof(jep106) / sizeof(jep106[0]); i++) {
|
||||
int written;
|
||||
sprintf(idstr, "%04X", jep106[i].jedec_code);
|
||||
written = sprintf(ptr1, "\t\t.dc.w 0x%s\n\t\t.dc.w jep106_str_%s - jep106_str_start\n", idstr, idstr);
|
||||
ptr1 += written;
|
||||
written = sprintf(ptr2, "jep106_str_%s:\n\t.asciz \"%s\"\n", idstr, jep106[i].name);
|
||||
ptr2 += written;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"\t.section \".rodata\", \"a\", @progbits\n\t.globl jep106_str_start\njep106_str_start:\n%s\n"
|
||||
"\t.balign 2\n\t.globl jep106\njep106:\n%s",
|
||||
stringstr, structstr);
|
||||
|
||||
fprintf(stdout,
|
||||
"/* MemTest86+ V5 Specific code (GPL V2.0)\n"
|
||||
" * By Samuel DEMEULEMEESTER, memtest@memtest.org\n"
|
||||
" * https://x86.fr - https://www.memtest.org\n"
|
||||
" * ------------------------------------------------\n"
|
||||
" * Based on JEDEC JEP106-BA - January 2022\n"
|
||||
" */\n"
|
||||
"\n"
|
||||
"#define JEDEC_CONT_CODE_MAX 14\n"
|
||||
"\n"
|
||||
"struct spd_jedec_manufacturer {\n"
|
||||
" uint16_t jedec_code;\n"
|
||||
" uint16_t offset;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"extern const char jep106_str_start;\n"
|
||||
"extern const struct spd_jedec_manufacturer jep106[];\n"
|
||||
"\n"
|
||||
"#define JEP106_CNT (%zu)\n"
|
||||
"\n"
|
||||
"#define JEP106_NAME(i) \\\n"
|
||||
" (&jep106_str_start + jep106[i].offset)\n",
|
||||
sizeof(jep106) / sizeof(jep106[0]));
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user