boots in qemu
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
result*
|
||||
7
boot.asm
Normal file
7
boot.asm
Normal file
@@ -0,0 +1,7 @@
|
||||
; yoinked from osdev.org
|
||||
hang:
|
||||
jmp hang
|
||||
|
||||
times 510-($-$$) db 0 ; 2 bytes less now
|
||||
db 0x55
|
||||
db 0xAA
|
||||
@@ -6,6 +6,13 @@
|
||||
nixpkgs,
|
||||
self,
|
||||
...
|
||||
}: {
|
||||
}: let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
packages.${system}.default = pkgs.callPackage ./package.nix {};
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
inputsFrom = [self.packages.${system}.default];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
45
package.nix
Normal file
45
package.nix
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
stdenv,
|
||||
nasm,
|
||||
qemu,
|
||||
...
|
||||
}: let
|
||||
bootImg = "boot";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "bootler";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
buildPhase = ''
|
||||
${nasm}/bin/nasm boot.asm -o ${bootImg}
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp ${bootImg} $out/bin
|
||||
|
||||
# create emulation binary
|
||||
cat<<EOF>$out/bin/bootler
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# create temp dir
|
||||
mkdir -p ./.bootler
|
||||
cp $(echo $out)/bin/${bootImg} ./.bootler/${bootImg}
|
||||
chmod a+w ./.bootler/${bootImg}
|
||||
|
||||
echo "press any key to continue. Qemu will clear the screen..."
|
||||
read -s -n 1
|
||||
|
||||
# run image
|
||||
${qemu}/bin/qemu-system-x86_64 \
|
||||
-nographic \
|
||||
-hda ./.bootler/${bootImg}
|
||||
|
||||
# clean up
|
||||
rm ./.bootler -r
|
||||
|
||||
EOF
|
||||
|
||||
chmod +x $out/bin/${bootImg}
|
||||
chmod +x $out/bin/bootler
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user