/* Jan Vondrak (C) 1998 Jakub Jelinek (C) 1998 A simple program which appends the kernel and root images to the boot loader and patches the addresses in its image_table[] Parameters: sun4= sun4c= sun4u= ... compressed kernel images (in a.out or ELF format) size4= size4c= size4u= ... original sizes of kernel images (uncompressed) root4= root4c= root4u= ... virtual address of root image for each kernel (in hex) root= ... compressed root image out= ... the output file */ #include #include #include #include #include #include "b.h" #include "b2.h" #include "b3.h" #define MAX_BOOT_LEN 0x900000 char output_buffer[MAX_BOOT_LEN]; struct ImageInfo { unsigned packed_start; unsigned packed_len; unsigned unpacked_len; unsigned root_start; }; int root_tweak (char *s) { unsigned p; p = strtoul (s, NULL, 16); /* read virtual address in hex */ return p ? (p + 32 + 0x1fff) & ~0x1fff : 0; /* add 32 bytes and round to 8 KB */ } static void check_size (char const *name, int len, int pos, int max) { if (max - pos < len) { fprintf (stderr, "%s will not fit into the image.\n", name); exit (EXIT_FAILURE); } } int main (int argc, char **argv) { int i,len,rootlen; FILE *f, *g = NULL; struct ImageInfo *ii; char *sun4_kernel_start; char *sun4c_kernel_start; char *sun4u_kernel_start; char *root_image_start; char *output_end; int sun4_size = 0, sun4_root = 0; int sun4c_size = 0, sun4c_root = 0; int sun4u_size = 0, sun4u_root = 0; char *sun4_kernel = 0; char *sun4c_kernel = 0; char *sun4u_kernel = 0; char *root_image = 0; char *output_file = 0; if (argc < 4) { fprintf (stderr, "Usage: maketilo\n" "\tsun4= size4= root4=\n" "\tsun4c= size4c= root4c=\n" "\tsun4u= size4u= root4u=\n" "\troot=\n" "\tout=\n"); return -1; } for (i=1;i= 0x430000 || rootlen + sun4c_size + 0x4000 + 0x10000 >= 0x430000 || rootlen + sun4u_size + 0x4000 + 0x10000 >= 0x430000) { printf("Images are super large. Will load on machines with at least 10M mapped by PROM only\n"); for (i=0; i= 0x330000 || rootlen + sun4c_size + 0x4000 + 0x10000 >= 0x330000 || rootlen + sun4u_size + 0x4000 + 0x10000 >= 0x330000) { printf("Images are large. Will load on machines with at least 5M mapped by PROM only\n"); for (i=0; i