Pass parameters to make_fiwix_initrd and kexec-fiwix

This extends make_fiwix_initrd and kexec-fiwix to support command
line parameters, instead of hardcoding relevant values within the
C sources. This way, it becomes possible to alter e.g. ramdisk size
without affecting checksums.

While we're at it, also support loading a memory map from file.
This commit is contained in:
Gábor Stefanik 2024-02-12 13:34:00 +01:00
parent bbb96a52d6
commit 9e4c17b68d
5 changed files with 150 additions and 84 deletions

View file

@ -48,7 +48,6 @@
#define BLOCK_SIZE 1024
#define FILENAME_LENGTH 1024
#define INITRD_MB 1280
const char *input_name = NULL;
/**@brief Block device handle.*/
@ -187,7 +186,7 @@ bool copy_file_system()
unsigned int filename_addr;
/* +4 to account for /mp and null termination */
char dst_filename[FILENAME_LENGTH + 4];
for (filenum = 14335, filename_addr = 0xfff000; filenum >= 4; filenum--, filename_addr -= FILENAME_LENGTH) {
for (filenum = 14335, filename_addr = 0xfffc00; filenum >= 3; filenum--, filename_addr -= FILENAME_LENGTH) {
/* Avoid including fiwix.ext2 in itself */
if (((char *) filename_addr)[0] != '/' ||
!strcmp((char *) filename_addr, "/") ||
@ -210,10 +209,12 @@ int main(int argc, char **argv)
int filenum;
unsigned int filename_addr;
unsigned int file_addr;
unsigned int initrd_size;
int i;
next_file_address = 0;
for (filenum = 14335, filename_addr = 0xfff000, file_addr = 0x1037FF4;
filenum >= 4;
next_file_address = 0x54000000;
for (filenum = 14335, filename_addr = 0xfffc00, file_addr = 0x1037FF4;
filenum >= 3;
filenum--, filename_addr -= FILENAME_LENGTH, file_addr -= 16) {
if (((char *) filename_addr)[0] == '/') {
next_file_address = *((unsigned int *) file_addr);
@ -222,15 +223,25 @@ int main(int argc, char **argv)
}
}
printf("Starting fiwix.ext2 at addr 0x%08x\n", next_file_address);
/* Create zeroed out disk image file */
input_name = "/boot/fiwix.ext2";
initrd_size = 262144;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-s")) {
i++;
initrd_size = atoi(argv[i]);
} else {
input_name = argv[i];
}
}
printf("Starting %s at addr 0x%08x\n", input_name, next_file_address);
memset(zeros, 0, BLOCK_SIZE);
FILE *ext2file = fopen(input_name, "w");
int b;
for (b=0; b < (BLOCK_SIZE * INITRD_MB); b++)
for (b=0; b < initrd_size; b++)
fwrite(zeros, BLOCK_SIZE, 1, ext2file);
fclose(ext2file);

View file

@ -1 +1 @@
76bc5cca226d1244f1f648656959a955e8ff61fdca3d98d589a46be811628ba7 /usr/bin/make_fiwix_initrd
5c750a976c8398092383783db26718002a67882bd8a7348a4d8f551cac02ee37 /usr/bin/make_fiwix_initrd