From 3438b8d235be38850cee46d1950edcebf5ffcd41 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Sat, 8 Apr 2023 02:17:02 +0200 Subject: [PATCH] misc: Revert back to using tinf for all GZ decompression --- README.md | 4 +- common/GNUmakefile | 41 +++++--- common/compress/gzip.c | 136 ------------------------- common/compress/gzip.h | 8 -- common/lib/uri.c | 6 +- common/stb_image.patch | 4 +- decompressor/GNUmakefile | 20 +++- {decompressor/tinf => tinf}/tinf.h | 0 {decompressor/tinf => tinf}/tinfgzip.c | 0 {decompressor/tinf => tinf}/tinflate.c | 0 10 files changed, 51 insertions(+), 168 deletions(-) delete mode 100644 common/compress/gzip.c delete mode 100644 common/compress/gzip.h rename {decompressor/tinf => tinf}/tinf.h (100%) rename {decompressor/tinf => tinf}/tinfgzip.c (100%) rename {decompressor/tinf => tinf}/tinflate.c (100%) diff --git a/README.md b/README.md index 28a9e349..827cbde4 100644 --- a/README.md +++ b/README.md @@ -229,9 +229,9 @@ An example `limine.cfg` file can be found in [`test/limine.cfg`](https://github. More info on the format of `limine.cfg` can be found in [`CONFIG.md`](https://github.com/limine-bootloader/limine/blob/trunk/CONFIG.md). ## Acknowledgments -Limine uses a stripped-down version of [tinf](https://github.com/jibsen/tinf) for early GZIP decompression. +Limine uses a stripped-down version of [tinf](https://github.com/jibsen/tinf) for GZIP decompression. -Limine relies on [stb_image](https://github.com/nothings/stb/blob/master/stb_image.h) for runtime GZIP decompression and image loading. +Limine relies on [stb_image](https://github.com/nothings/stb/blob/master/stb_image.h) for wallpaper image loading. ## Discord server We have a [Discord server](https://discord.gg/QEeZMz4) if you need support, diff --git a/common/GNUmakefile b/common/GNUmakefile index 02a2487a..5db6db65 100644 --- a/common/GNUmakefile +++ b/common/GNUmakefile @@ -57,6 +57,7 @@ override CFLAGS_FOR_TARGET += \ override CPPFLAGS_FOR_TARGET := \ -I../freestanding-headers \ + -I'$(call SHESCAPE,$(BUILDDIR))/tinf' \ -I'$(call SHESCAPE,$(BUILDDIR))/..' \ -I. \ $(CPPFLAGS_FOR_TARGET) \ @@ -208,6 +209,20 @@ else ifeq ($(TARGET),uefi-aarch64) all: $(call MKESCAPE,$(BUILDDIR))/BOOTAA64.EFI endif +$(call MKESCAPE,$(BUILDDIR))/tinf-copied: ../tinf/* + rm -rf '$(call SHESCAPE,$(BUILDDIR))/tinf' + $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' + cp -r ../tinf '$(call SHESCAPE,$(BUILDDIR))/' + touch '$(call SHESCAPE,$(BUILDDIR))/tinf-copied' + +$(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied + $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" + $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)' + +$(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied + $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" + $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)' + ifeq ($(TARGET),bios) $(call MKESCAPE,$(BUILDDIR))/stage2.bin.gz: $(call MKESCAPE,$(BUILDDIR))/stage2.bin @@ -245,7 +260,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker_nos2map.ld: linker_bios.ld.in $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(CC_FOR_TARGET) -x c -E -P -undef -DLINKER_NOMAP -DLINKER_NOS2MAP linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld' -$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a +$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld' $(LD_FOR_TARGET) '$(call OBJESCAPE,$^)' $(LDFLAGS_FOR_TARGET) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld' -o '$(call SHESCAPE,$@)' $(OBJCOPY_FOR_TARGET) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin' @@ -260,7 +275,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_bios.ld.in $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(CC_FOR_TARGET) -x c -E -P -undef -DLINKER_NOMAP linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -$(call MKESCAPE,$(BUILDDIR))/limine_nos3map.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/stage2.map.o +$(call MKESCAPE,$(BUILDDIR))/limine_nos3map.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/stage2.map.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(LD_FOR_TARGET) '$(call OBJESCAPE,$^)' $(LDFLAGS_FOR_TARGET) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -o '$(call SHESCAPE,$@)' $(OBJCOPY_FOR_TARGET) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin' @@ -275,7 +290,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_bios.ld.in $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(CC_FOR_TARGET) -x c -E -P -undef linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' -$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/stage2.map.o $(call MKESCAPE,$(BUILDDIR))/full.map.o +$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/stage2.map.o $(call MKESCAPE,$(BUILDDIR))/full.map.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(LD_FOR_TARGET) '$(call OBJESCAPE,$^)' $(LDFLAGS_FOR_TARGET) -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' -o '$(call SHESCAPE,$@)' $(OBJCOPY_FOR_TARGET) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin' @@ -314,7 +329,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi_x86_64.ld.in $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(CC_FOR_TARGET) -x c -E -P -undef -DLINKER_NOMAP linker_uefi_x86_64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o $(OBJ) ../libgcc-binaries/libgcc-x86_64-no-red-zone.a +$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o $(OBJ) ../libgcc-binaries/libgcc-x86_64-no-red-zone.a $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(LD_FOR_TARGET) \ -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \ @@ -324,7 +339,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi_x86_64.ld.in $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(CC_FOR_TARGET) -x c -E -P -undef linker_uefi_x86_64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' -$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o $(OBJ) ../libgcc-binaries/libgcc-x86_64-no-red-zone.a $(call MKESCAPE,$(BUILDDIR))/full.map.o +$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o $(OBJ) ../libgcc-binaries/libgcc-x86_64-no-red-zone.a $(call MKESCAPE,$(BUILDDIR))/full.map.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(LD_FOR_TARGET) \ -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \ @@ -354,7 +369,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi_aarch64.ld.in $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(CC_FOR_TARGET) -x c -E -P -undef -DLINKER_NOMAP linker_uefi_aarch64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o $(OBJ) ../libgcc-binaries/libgcc-aarch64.a +$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o $(OBJ) ../libgcc-binaries/libgcc-aarch64.a $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(LD_FOR_TARGET) \ -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \ @@ -364,7 +379,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi_aarch64.ld.in $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(CC_FOR_TARGET) -x c -E -P -undef linker_uefi_aarch64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' -$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o $(OBJ) ../libgcc-binaries/libgcc-aarch64.a $(call MKESCAPE,$(BUILDDIR))/full.map.o +$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o $(OBJ) ../libgcc-binaries/libgcc-aarch64.a $(call MKESCAPE,$(BUILDDIR))/full.map.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(LD_FOR_TARGET) \ -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \ @@ -393,7 +408,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi_ia32.ld.in $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(CC_FOR_TARGET) -x c -E -P -undef -DLINKER_NOMAP linker_uefi_ia32.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o $(OBJ) ../libgcc-binaries/libgcc-i686.a +$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(LD_FOR_TARGET) \ -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \ @@ -403,7 +418,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi_ia32.ld.in $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(CC_FOR_TARGET) -x c -E -P -undef linker_uefi_ia32.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' -$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/full.map.o +$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/full.map.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(LD_FOR_TARGET) \ -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \ @@ -414,25 +429,25 @@ endif -include $(HEADER_DEPS) ifeq ($(TARGET),uefi-x86-64) -$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/limine-efi +$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/limine-efi $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' endif ifeq ($(TARGET),uefi-aarch64) -$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/limine-efi +$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/limine-efi $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' endif ifeq ($(TARGET),uefi-ia32) -$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/limine-efi +$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/limine-efi $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' endif ifeq ($(TARGET),bios) -$(call MKESCAPE,$(BUILDDIR))/%.o: %.c +$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' endif diff --git a/common/compress/gzip.c b/common/compress/gzip.c deleted file mode 100644 index 93703611..00000000 --- a/common/compress/gzip.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * originally from tinfgzip - tiny gzip decompressor - * - * Copyright (c) 2003-2019 Joergen Ibsen - * Copyright (c) 2023 mintsuki and contributors to the Limine project - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must - * not claim that you wrote the original software. If you use this - * software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must - * not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - */ - -#include -#include - -typedef enum { - FTEXT = 1, - FHCRC = 2, - FEXTRA = 4, - FNAME = 8, - FCOMMENT = 16 -} gzip_flag; - -void *gzip_uncompress(const void *source, uint64_t sourceLen, uint64_t *outsize) { - const uint8_t *src = (const uint8_t *) source; - const uint8_t *start; - int res; - uint8_t flg; - - /* -- Check header -- */ - - /* Check room for at least 10 byte header and 8 byte trailer */ - if (sourceLen < 18) { - return NULL; - } - - /* Check id bytes */ - if (src[0] != 0x1F || src[1] != 0x8B) { - return NULL; - } - - /* Check method is deflate */ - if (src[2] != 8) { - return NULL; - } - - /* Get flag byte */ - flg = src[3]; - - /* Check that reserved bits are zero */ - if (flg & 0xE0) { - return NULL; - } - - /* -- Find start of compressed data -- */ - - /* Skip base header of 10 bytes */ - start = src + 10; - - /* Skip extra data if present */ - if (flg & FEXTRA) { - uint64_t xlen = *((uint16_t *)start); - - if (xlen > sourceLen - 12) { - return NULL; - } - - start += xlen + 2; - } - - /* Skip file name if present */ - if (flg & FNAME) { - do { - if (((uint64_t)(start - src)) >= sourceLen) { - return NULL; - } - } while (*start++); - } - - /* Skip file comment if present */ - if (flg & FCOMMENT) { - do { - if (((uint64_t)(start - src)) >= sourceLen) { - return NULL; - } - } while (*start++); - } - - if (flg & FHCRC) { - start += 2; - } - - /* -- Get decompressed length -- */ - - uint32_t dlen = *((uint32_t *)&src[sourceLen - 4]); - - /* -- Decompress data -- */ - - if ((src + sourceLen) - start < 8) { - return NULL; - } - - void *buf = ext_mem_alloc(dlen); - - // XXX for some reason certain GZ files made by macOS do not properly decompress with stb_image - // unless some skew (19 bytes?) is applied to the buffer. I have no idea why this is the - // case but I'd rather have them load somewhat than not load at all. - for (uint64_t skew = 0; skew < 32; skew++) { - res = stbi_zlib_decode_noheader_buffer(buf, dlen, (const char *)start + skew, (src + sourceLen) - start - 8 - skew); - if (res != -1) { - break; - } - } - - if (res == -1) { - pmm_free(buf, dlen); - return NULL; - } - - *outsize = (uint64_t)dlen; - return buf; -} diff --git a/common/compress/gzip.h b/common/compress/gzip.h deleted file mode 100644 index ce9e6a24..00000000 --- a/common/compress/gzip.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __COMPRESS__GZIP_H__ -#define __COMPRESS__GZIP_H__ - -#include - -void *gzip_uncompress(const void *source, uint64_t sourceLen, uint64_t *outsize); - -#endif diff --git a/common/lib/uri.c b/common/lib/uri.c index a4eed0b5..f9227dba 100644 --- a/common/lib/uri.c +++ b/common/lib/uri.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -273,8 +273,8 @@ struct file_handle *uri_open(char *uri) { if (compressed && ret != NULL) { struct file_handle *compressed_fd = ext_mem_alloc(sizeof(struct file_handle)); void *src = freadall(ret, MEMMAP_BOOTLOADER_RECLAIMABLE); - if ((compressed_fd->fd = gzip_uncompress(src, ret->size, &compressed_fd->size)) == NULL) { - panic(true, "GZip error"); + if (tinf_gzip_uncompress(compressed_fd->fd, src, ret->size)) { + panic(true, "tinf error"); } compressed_fd->vol = ret->vol; compressed_fd->path = ext_mem_alloc(ret->path_len); diff --git a/common/stb_image.patch b/common/stb_image.patch index b88af848..23faf05b 100644 --- a/common/stb_image.patch +++ b/common/stb_image.patch @@ -1,6 +1,6 @@ --- common/stb/stb_image.h 2023-03-05 18:57:03.930649341 +0100 +++ common/stb/stb_image.h 2023-03-05 18:55:53.767318782 +0100 -@@ -127,6 +127,54 @@ +@@ -127,6 +127,52 @@ #ifndef STBI_INCLUDE_STB_IMAGE_H #define STBI_INCLUDE_STB_IMAGE_H @@ -46,8 +46,6 @@ +#define STBI_NO_SIMD +#define STBI_NO_LINEAR + -+#define STBI_ONLY_ZLIB -+#define STBI_SUPPORT_ZLIB +#define STBI_ONLY_JPEG +#define STBI_ONLY_PNG +#define STBI_ONLY_BMP diff --git a/decompressor/GNUmakefile b/decompressor/GNUmakefile index e295ebc8..d1f3a506 100644 --- a/decompressor/GNUmakefile +++ b/decompressor/GNUmakefile @@ -40,7 +40,7 @@ override CFLAGS_FOR_TARGET += \ override CPPFLAGS_FOR_TARGET := \ -I../freestanding-headers \ - -I./tinf \ + -I'$(call SHESCAPE,$(BUILDDIR))/tinf' \ -I. \ $(CPPFLAGS_FOR_TARGET) \ -MMD \ @@ -65,13 +65,27 @@ override HEADER_DEPS := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c= .PHONY: all all: $(call MKESCAPE,$(BUILDDIR))/decompressor.bin -$(call MKESCAPE,$(BUILDDIR))/decompressor.bin: $(OBJ) ../libgcc-binaries/libgcc-i686.a +$(call MKESCAPE,$(BUILDDIR))/decompressor.bin: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(LD_FOR_TARGET) '$(call OBJESCAPE,$^)' $(LDFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf' $(OBJCOPY_FOR_TARGET) -O binary '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf' '$(call SHESCAPE,$@)' +$(call MKESCAPE,$(BUILDDIR))/tinf-copied: ../tinf/* + rm -rf '$(call SHESCAPE,$(BUILDDIR))/tinf' + $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' + cp -r ../tinf '$(call SHESCAPE,$(BUILDDIR))/' + touch '$(call SHESCAPE,$(BUILDDIR))/tinf-copied' + +$(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied + $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" + $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)' + +$(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied + $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" + $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)' + -include $(HEADER_DEPS) -$(call MKESCAPE,$(BUILDDIR))/%.o: %.c +$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(CPPFLAGS_FOR_TARGET) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' diff --git a/decompressor/tinf/tinf.h b/tinf/tinf.h similarity index 100% rename from decompressor/tinf/tinf.h rename to tinf/tinf.h diff --git a/decompressor/tinf/tinfgzip.c b/tinf/tinfgzip.c similarity index 100% rename from decompressor/tinf/tinfgzip.c rename to tinf/tinfgzip.c diff --git a/decompressor/tinf/tinflate.c b/tinf/tinflate.c similarity index 100% rename from decompressor/tinf/tinflate.c rename to tinf/tinflate.c