Today we are going to see our operating system print "Hello world" on the screen.
Software that you need to install are xorris and grub
Create a file grub.cfg and paste the code given below. Instead of myos you can give any name that suits you.
Following is a shell script file which will compile the OS code and generate bootable image. We are using this file because there are many steps involved in compilation and you may not want to go through each step every time you make changes to the code.
Save the above commands in a file with name "build" in the same folder where your rest of the code resides.
Now execute the following code in the terminal.
Now your bootable OS image is ready. Your next step is to start is to start virtualbox
Create your new virtual machine using virtual machine wizard. Virtual machine should have the following configuration because we are going to analyse the memory and my calculation will depend on this configuration.
Select the myos.iso as your bootable image file and run it. This what you will see.
So finally we are done with this hello world program. I hope you enjoyed OSDEVING. Make sure you continue with it. We are going to do a lot more interesting stuff soon. Our next step is to analyse the memory we have and how to manage it. Will be back soon with the next tutorial.
Software that you need to install are xorris and grub
sudo apt-get install xorris sudo apt-get install grub
Create a file grub.cfg and paste the code given below. Instead of myos you can give any name that suits you.
menuentry "myos" { multiboot /boot/myos.bin }
Following is a shell script file which will compile the OS code and generate bootable image. We are using this file because there are many steps involved in compilation and you may not want to go through each step every time you make changes to the code.
#!/bin/sh export PREFIX="$HOME/opt/cross" export TARGET=i586-elf export PATH="$PREFIX/bin:$PATH" i586-elf-gcc -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra i586-elf-as boot.s -o boot.o i586-elf-gcc -T linker.ld -o myos.bin -ffreestanding -O2 -nostdlib boot.o kernel.o -lgcc mkdir -p isodir#comment this line when you use this file again to compile your code. mkdir -p isodir/boot#comment this line when you use this file again to compile your code. cp myos.bin isodir/boot/myos.bin mkdir -p isodir/boot/grub#comment this line when you use this file again to compile your code. cp grub.cfg isodir/boot/grub/grub.cfg grub-mkrescue -o myos.iso isodir
Save the above commands in a file with name "build" in the same folder where your rest of the code resides.
Now execute the following code in the terminal.
chmod +x build ./build
Now your bootable OS image is ready. Your next step is to start is to start virtualbox
sudo virtualbox
Select the myos.iso as your bootable image file and run it. This what you will see.
So finally we are done with this hello world program. I hope you enjoyed OSDEVING. Make sure you continue with it. We are going to do a lot more interesting stuff soon. Our next step is to analyse the memory we have and how to manage it. Will be back soon with the next tutorial.
HAPPY OSDEVING!!
No comments:
Post a Comment