Final Year.... lot of work to do.
So next post in MAY!!!
Sorry for the delay.
If you want some help then visit OSDEV.
//add this #include "multiboot.h" //change the kernel_main function void kernel_main(multiboot_info_t* mbd,unsigned int magic) { //Now we have the memory information with us.
//Use your printf function to print the data here.
}
sudo apt-get install xorris sudo apt-get install grub
menuentry "myos" { multiboot /boot/myos.bin }
#!/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
chmod +x build ./build
sudo virtualbox
#include#include //lets store the screen size in a global variable static const size_t SCREEN_WIDTH = 80; static const size_t SCREEN_HEIGHT = 24; uint8_t screen_color = 0;//0x0 uint8_t text_color = 15;//0xf uint16_t* buffer = (uint16_t*) 0xB8000;//pointer which points to the display memory. Display reads from this memory int cleanTheScreen() { size_t row = 0; size_t column = 0; char text = ' '; uint16_t color = screen_color; size_t position ; while(row < SCREEN_HEIGHT) { while(column < SCREEN_WIDTH) { position = row*SCREEN_WIDTH+column; buffer[position] = text|screen_color<<8; column++; } row++; } } int printf(char* data,) { uint8_t row = 0; uint8_t column = 0; size_t row = 0; size_t column = 0; char text = ' '; uint16_t color = text_color; size_t position ; while(column < SCREEN_WIDTH) { position = row*SCREEN_WIDTH+column; buffer[position] = text|screen_color<<8; column++; } } void kernel_main() { cleanTheScreen(); printf(); }
#remember that every time you want to compile the code you develop you should set the environment variables in the terminal as given below
export PREFIX="$HOME/opt/cross" export TARGET=i586-elf export TARGET=i586-elf export PATH="$PREFIX/bin:$PATH"
# The reason why you do this is because without these the computer will not know which compiler to use and it will use your default compiler which is not meant to compile code for the new operating system you are developing.
#after these steps execute the following command after you cd to the folder which contains boot.s
i586-elf-as boot.s -o boot.o
cd ~ mkdir src2) Download the following files to the "src" folder you just created in the previous step.
cd ~ mkdir opt cd opt mkdir cross export PREFIX="$HOME/opt/cross" export TARGET=i586-elf export PATH="$PREFIX/bin:$PATH" cd $HOME/src mkdir build-binutils cd build-binutils #note that "x.y.z" in the next command is its version number you have to replace it with that. ../binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-nls make make install cd $HOME/src mv gmp-x.y.z gcc-x.y.z/gmp mv mpfr-x.y.z gcc-x.y.z/mpfr mv mpc-x.y.z gcc-x.y.z/mpc mkdir build-gcc cd build-gcc ../gcc-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers make all-gcc make all-target-libgcc make install-gcc make install-target-libgcc