# HG changeset patch # User Mychaela Falconia # Date 1686375337 0 # Node ID 36e65605d16a172b80c032754c402660a8ae9ebd # Parent 09c18549921b0a0ad905fccaa25fab2915c56918 bootutil: add c155-analyze-boot diff -r 09c18549921b -r 36e65605d16a .hgignore --- a/.hgignore Sat Jun 10 05:09:38 2023 +0000 +++ b/.hgignore Sat Jun 10 05:35:37 2023 +0000 @@ -11,3 +11,4 @@ ^bootmatch/fc_patched_boot\.c$ ^bootutil/c139-analyze-boot$ +^bootutil/c155-analyze-boot$ diff -r 09c18549921b -r 36e65605d16a bootutil/Makefile --- a/bootutil/Makefile Sat Jun 10 05:09:38 2023 +0000 +++ b/bootutil/Makefile Sat Jun 10 05:35:37 2023 +0000 @@ -1,9 +1,10 @@ CC= gcc CFLAGS= -O2 -PROGS= c139-analyze-boot +PROGS= c139-analyze-boot c155-analyze-boot C139ANB_OBJS= c11x_lockable.o c11x_nolock.o c139_lockable.o c139_main.o \ c139_nolock.o do_match.o fc_patched_boot.o +C155ANB_OBJS= c155_boot.o c155_main.o do_match.o INSTALL_PREFIX= /opt/freecalypso @@ -14,6 +15,9 @@ c139-analyze-boot: ${C139ANB_OBJS} ${CC} ${CFLAGS} -o $@ ${C139ANB_OBJS} +c155-analyze-boot: ${C155ANB_OBJS} + ${CC} ${CFLAGS} -o $@ ${C155ANB_OBJS} + c11x_lockable.o: ../bootmatch/c11x_lockable.c ${CC} ${CFLAGS} -c -o $@ $< @@ -26,6 +30,9 @@ c139_nolock.o: ../bootmatch/c139_nolock.c ${CC} ${CFLAGS} -c -o $@ $< +c155_boot.o: ../bootmatch/c155_boot.c + ${CC} ${CFLAGS} -c -o $@ $< + fc_patched_boot.o: ../bootmatch/fc_patched_boot.c ${CC} ${CFLAGS} -c -o $@ $< diff -r 09c18549921b -r 36e65605d16a bootutil/c155_main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bootutil/c155_main.c Sat Jun 10 05:35:37 2023 +0000 @@ -0,0 +1,59 @@ +/* + * This C module is the main for c155-analyze-boot utility. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../bootmatch/bootmatch.h" + +extern struct bootmatch bootmatch_c155[]; + +#define LENGTH_OF_INTEREST 0x2000 + +static u_char image[LENGTH_OF_INTEREST]; + +static void +read_bin_file(filename) + char *filename; +{ + int fd; + struct stat st; + + fd = open(filename, O_RDONLY); + if (fd < 0) { + perror(filename); + exit(1); + } + fstat(fd, &st); + if (!S_ISREG(st.st_mode)) { + fprintf(stderr, "error: %s is not a regular file\n", filename); + exit(1); + } + if (st.st_size < LENGTH_OF_INTEREST) { + fprintf(stderr, "error: %s is too short\n", filename); + exit(1); + } + read(fd, image, LENGTH_OF_INTEREST); + close(fd); +} + +main(argc, argv) + char **argv; +{ + if (argc != 2) { + fprintf(stderr, "usage: %s flashdump.bin\n", argv[0]); + exit(1); + } + read_bin_file(argv[1]); + if (check_for_match(image, bootmatch_c155)) + puts("ok"); + else + puts("unknown"); + exit(0); +}