Changeset dcc2c5d in mainline
- Timestamp:
- 2018-10-12T17:44:35Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 68a0d60
- Parents:
- d4eba6d
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-10-12 17:38:51)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-10-12 17:44:35)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
rd4eba6d rdcc2c5d 435 435 ! RCU (choice) 436 436 437 % Compress init data 438 ! CONFIG_COMPRESSED_INIT (y/n) 437 439 438 440 ## User space features options -
boot/Makefile.build
rd4eba6d rdcc2c5d 69 69 DEPENDS := $(addsuffix .d,$(basename $(SOURCES))) 70 70 71 ifeq ($(CONFIG_COMPRESSED_INIT),y) 72 COMPONENTS := $(addsuffix .gz, $(COMPONENTS)) 73 endif 74 71 75 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT) 72 76 … … 101 105 gzip -n -k -f $< 102 106 103 $(COMPS).tar: $( addsuffix .gz, $(COMPONENTS))107 $(COMPS).tar: $(COMPONENTS) 104 108 tar --mtime='2032-01-01 00:00:00' --group=0 --owner=0 --no-acls --no-selinux --no-xattrs --format=ustar --transform 's/.*\///g' -cvf $@ $^ 105 109 -
boot/arch/ppc32/src/main.c
rd4eba6d rdcc2c5d 73 73 (void *) LOADER_ADDRESS, loader_address_pa); 74 74 75 size_t un compressed_size = payload_uncompressed_size();76 printf("Payload uncompressed size: %d bytes\n", un compressed_size);75 size_t unpacked_size = payload_unpacked_size(); 76 printf("Payload uncompressed size: %d bytes\n", unpacked_size); 77 77 78 if (un compressed_size >= (size_t) loader_address_pa) {78 if (unpacked_size >= (size_t) loader_address_pa) { 79 79 printf("Inflated components overlap loader area.\n"); 80 80 printf("The boot image is too large. Halting.\n"); … … 91 91 void *inflate_base_pa; 92 92 ofw_alloc("inflate area", &inflate_base, &inflate_base_pa, 93 un compressed_size, loader_address_pa);93 unpacked_size, loader_address_pa); 94 94 printf(" %p|%p: inflate area\n", inflate_base, inflate_base_pa); 95 95 96 uintptr_t balloc_start = ALIGN_UP(un compressed_size, PAGE_SIZE);96 uintptr_t balloc_start = ALIGN_UP(unpacked_size, PAGE_SIZE); 97 97 size_t pages = (balloc_start + ALIGN_UP(BALLOC_MAX_SIZE, PAGE_SIZE)) >> 98 98 PAGE_WIDTH; … … 109 109 /* Inflate components. */ 110 110 extract_payload(&bootinfo.taskmap, inflate_base, 111 inflate_base + un compressed_size, PA2KA(0), NULL);111 inflate_base + unpacked_size, PA2KA(0), NULL); 112 112 113 113 printf("Setting up boot allocator ...\n"); -
boot/arch/sparc64/src/main.c
rd4eba6d rdcc2c5d 225 225 */ 226 226 227 size_t sz = ALIGN_UP(payload_un compressed_size(), PAGE_SIZE);227 size_t sz = ALIGN_UP(payload_unpacked_size(), PAGE_SIZE); 228 228 ofw_claim_phys((void *) (bootinfo.physmem_start + KERNEL_ADDRESS), sz); 229 229 ofw_map((void *) (bootinfo.physmem_start + KERNEL_ADDRESS), -
boot/generic/include/payload.h
rd4eba6d rdcc2c5d 40 40 extern uint8_t loader_end[]; 41 41 42 size_t payload_un compressed_size(void);42 size_t payload_unpacked_size(void); 43 43 void extract_payload(taskmap_t *, uint8_t *, uint8_t *, uintptr_t, 44 44 void (*)(void *, size_t)); -
boot/generic/src/payload.c
rd4eba6d rdcc2c5d 41 41 #include <halt.h> 42 42 43 static void basename(char *s)44 { 45 c har *last = s;43 static const char *ext(const char *s) 44 { 45 const char *last = s; 46 46 47 47 while (*s) { … … 53 53 54 54 if (*last == '.') 55 *last = '\0'; 55 return last; 56 57 return NULL; 58 } 59 60 static void basename(char *s) 61 { 62 char *e = (char *) ext(s); 63 if (str_cmp(e, ".gz") == 0) 64 *e = '\0'; 65 } 66 67 static bool isgzip(const char *s) 68 { 69 return str_cmp(ext(s), ".gz") == 0; 56 70 } 57 71 … … 68 82 const char *name; 69 83 const uint8_t *data; 70 size_t compressed_size;71 size_t un compressed_size;72 73 if (!tar_info(*cstart, cend, &name, & compressed_size))84 size_t packed_size; 85 size_t unpacked_size; 86 87 if (!tar_info(*cstart, cend, &name, &packed_size)) 74 88 return false; 75 89 76 90 data = *cstart + TAR_BLOCK_SIZE; 77 *cstart += TAR_BLOCK_SIZE + ALIGN_UP(compressed_size, TAR_BLOCK_SIZE); 78 79 uncompressed_size = gzip_size(data, compressed_size); 91 *cstart += TAR_BLOCK_SIZE + ALIGN_UP(packed_size, TAR_BLOCK_SIZE); 92 93 bool gz = isgzip(name); 94 95 unpacked_size = gz ? gzip_size(data, packed_size) : packed_size; 80 96 81 97 /* Components must be page-aligned. */ … … 83 99 actual_ustart += new_ustart - ustart; 84 100 ustart = new_ustart; 85 uint8_t *comp_end = ustart + un compressed_size;101 uint8_t *comp_end = ustart + unpacked_size; 86 102 87 103 /* Check limits and overlap. */ … … 92 108 actual_ustart += new_ustart - ustart; 93 109 ustart = new_ustart; 94 comp_end = ustart + un compressed_size;110 comp_end = ustart + unpacked_size; 95 111 } 96 112 … … 102 118 103 119 printf(" %p|%p: %s image (%zu/%zu bytes)\n", (void *) actual_ustart, 104 ustart, name, un compressed_size, compressed_size);120 ustart, name, unpacked_size, packed_size); 105 121 106 122 if (task) { 107 123 task->addr = (void *) actual_ustart; 108 task->size = un compressed_size;124 task->size = unpacked_size; 109 125 str_cpy(task->name, BOOTINFO_TASK_NAME_BUFLEN, name); 110 126 /* Remove .gz extension */ 111 basename(task->name); 112 } 113 114 int rc = gzip_expand(data, compressed_size, ustart, uncompressed_size); 115 if (rc != EOK) { 116 printf("\n%s: Inflating error %d\n", name, rc); 117 halt(); 127 if (gz) 128 basename(task->name); 129 } 130 131 if (gz) { 132 int rc = gzip_expand(data, packed_size, ustart, unpacked_size); 133 if (rc != EOK) { 134 printf("\n%s: Inflating error %d\n", name, rc); 135 halt(); 136 } 137 } else { 138 memcpy(ustart, data, unpacked_size); 118 139 } 119 140 120 141 if (clear_cache) 121 clear_cache(ustart, uncompressed_size); 142 clear_cache(ustart, unpacked_size); 143 122 144 return true; 123 145 } 124 146 125 /* @return Bytes needed for un compressed payload. */126 size_t payload_un compressed_size(void)147 /* @return Bytes needed for unpacked payload. */ 148 size_t payload_unpacked_size(void) 127 149 { 128 150 size_t sz = 0; 129 151 uint8_t *start = payload_start; 130 152 const char *name; 131 size_t compressed_size;132 133 while (tar_info(start, payload_end, &name, & compressed_size)) {153 size_t packed_size; 154 155 while (tar_info(start, payload_end, &name, &packed_size)) { 134 156 sz = ALIGN_UP(sz, PAGE_SIZE); 135 sz += gzip_size(start + TAR_BLOCK_SIZE, compressed_size); 136 137 start += TAR_BLOCK_SIZE + 138 ALIGN_UP(compressed_size, TAR_BLOCK_SIZE); 157 if (isgzip(name)) 158 sz += gzip_size(start + TAR_BLOCK_SIZE, packed_size); 159 else 160 sz += packed_size; 161 162 start += TAR_BLOCK_SIZE + ALIGN_UP(packed_size, TAR_BLOCK_SIZE); 139 163 } 140 164 … … 186 210 /* 187 211 * First, move the payload to the very end of available memory, 188 * to make space for the decompressed data.212 * to make space for the unpacked data. 189 213 */ 190 214 real_payload_start = (uint8_t *) ALIGN_DOWN((uintptr_t)(mem_end - payload_size), PAGE_SIZE);
Note:
See TracChangeset
for help on using the changeset viewer.