Build kexec-linux later as a package for musl lib calls instead of asm.

This commit is contained in:
rick-masters 2023-05-20 15:16:27 +00:00
parent 8604871997
commit 0d4394aa0d
8 changed files with 28 additions and 42 deletions

View File

@ -62,6 +62,7 @@ d85cff8f9ff76533287891ec2019416fa585815e514743e5b76efd9f17f5ef5c grep-3.7_0.tar
b38422d646590600444f0ff12fee6fd738baaf471338aa67899db950d3521127 guile-3.0.9_0.tar.bz2
8d2015b87337abbf287f7a39ee4cf53514120b5d3e90a93fe7d533dcc43f14fa help2man-1.36.4_0.tar.bz2
3f06d1a7f1b1770d4550ff6316c7f06fd26e30bddad7c1b665f1fae80e409c8c kbd-1.15_0.tar.bz2
6cb8bd6df0472665cd82ef4f4eae8368543a4d04eb90ec5f6cf4f224d1e16e51 kexec-linux-1.0.0_0.tar.bz2
2a661da13801028f5af98e5d9f6de417c21c90df1bcef4809caf0c2094fdd8f4 kexec-tools-2.0.22_0.tar.bz2
e89e4fc8ba4f917f4f609ba781fc13e43d31479d47a9da2ba3bc7ce5fcbbe6b3 libarchive-3.5.2_0.tar.bz2
36550df491767bb24d2ccab304ce70a3b4956e7c0c0e0c343d922fd57cdafbdd libatomic_ops-7.6.10_0.tar.bz2

View File

@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/reboot.h>
#include <sys/stat.h>
#include <time.h>
@ -28,7 +29,7 @@ int main(int argc, char **argv) {
/* Write length of kernel */
if (stat(kernel_file_name, &stats) == 0) {
fwrite(&stats.st_size, sizeof(stats.st_size), 1, ramdrive_file);
fwrite(&stats.st_size, 4, 1, ramdrive_file);
} else {
fprintf(stderr, "Cannot stat kernel file '%s'\n", kernel_file_name);
exit(1);
@ -36,7 +37,7 @@ int main(int argc, char **argv) {
/* Write length of initramfs */
if (stat(initramfs_file_name, &stats) == 0) {
fwrite(&stats.st_size, sizeof(stats.st_size), 1, ramdrive_file);
fwrite(&stats.st_size, 4, 1, ramdrive_file);
} else {
fprintf(stderr, "Cannot stat initramfs file '%s'\n", initramfs_file_name);
exit(1);
@ -52,25 +53,11 @@ int main(int argc, char **argv) {
}
fclose(ramdrive_file);
/* Perform syscall sync */
__asm__ __volatile__(
"movl $0x00000024, %%eax\n\t"
"int $0x80\n\t"
: /* no output */
: /* no input */
);
/* Flush ram drive writes to device */
sync();
/* Perform syscall reboot to initiate kexec */
__asm__ __volatile__(
"movl $0x58, %%eax\n\t"
"movl $0xfee1dead, %%ebx\n\t"
"movl $0x28121969, %%ecx\n\t"
"movl $0xcdef0123, %%edx\n\t"
"movl $0x00, %%esi\n\t"
"int $0x80\n\t"
: /* no output */
: /* no input */
);
reboot(RB_HALT_SYSTEM);
}
int append_file(FILE *dst_file, char *src_file_name) {

View File

@ -0,0 +1,15 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com>
# SPDX-License-Identifier: MIT
src_get() {
:
}
src_unpack() {
dirname=kexec-linux-1.0.0
mkdir ${dirname}
}
src_install() {
install -D "kexec-linux" "${DESTDIR}${PREFIX}/bin/kexec-linux"
}

View File

@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com>
# SPDX-License-Identifier: MIT
kexec-linux: kexec-linux.c
gcc -static -m32 -march=i386 -o $@ $^

View File

@ -1 +0,0 @@
c0993adf00bd2c110539a310246f0e50d727e09701ed187827c71c64021431f4 /usr/bin/kexec-linux

View File

@ -1,16 +0,0 @@
# SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com>
# SPDX-License-Identifier: MIT
cd src
tcc -static -m32 -march=i386 -std=c89 -I../../tcc/tcc-0.9.27/include -o ${bindir}/kexec-linux kexec-linux.c
cd ..
# Checksums
if match x${UPDATE_CHECKSUMS} xTrue; then
sha256sum /usr/bin/kexec-linux
sha256sum -o ${pkg}.checksums \
/usr/bin/kexec-linux
cp ${pkg}.checksums ${srcdir}
else
sha256sum -c ${pkg}.checksums
fi

View File

@ -73,12 +73,6 @@ if match x${BUILD_FIWIX} xTrue; then
cd ${pkg}
kaem --verbose --file ${pkg}.kaem
cd ..
# Live boot loader for Fiwix to Linux
pkg="kexec-linux"
cd ${pkg}
kaem --verbose --file ${pkg}.kaem
cd ..
fi
if match x${KERNEL_BOOTSTRAP} xTrue; then

View File

@ -91,6 +91,8 @@ grep --no-filename '^build' "${SOURCES}"/run*.sh | grep -v musl-1.2.3 | sed "s/b
done
if [ "${CHROOT}" = False ] || [ "${BUILD_KERNELS}" = True ]; then
build kexec-linux-1.0.0
build kexec-tools-2.0.22
build linux-4.9.10