Permalink
Browse files

Files for part 2, https://www.youtube.com/watch?v=ZiHtuBnVrx4

  • Loading branch information...
Viktor Engelmann Viktor Engelmann
Viktor Engelmann authored and Viktor Engelmann committed Jul 4, 2016
1 parent 7eb9f8a commit b440da72b6403d6cde728b6657e61aed8fd3c682
Showing with 37 additions and 2 deletions.
  1. +4 −2 kernel.cpp
  2. +20 −0 makefile
  3. +13 −0 types.h
View
@@ -1,7 +1,9 @@
#include "types.h"
void printf(char* str)
{
static unsigned short* VideoMemory = (unsigned short*)0xb8000;
static uint16_t* VideoMemory = (uint16_t*)0xb8000;
for(int i = 0; str[i] != '\0'; ++i)
VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i];
@@ -20,7 +22,7 @@ extern "C" void callConstructors()
extern "C" void kernelMain(const void* multiboot_structure, unsigned int /*multiboot_magic*/)
extern "C" void kernelMain(const void* multiboot_structure, uint32_t /*multiboot_magic*/)
{
printf("Hello World! --- http://www.AlgorithMan.de");
View
@@ -1,5 +1,6 @@
# sudo apt-get install g++ binutils libc6-dev-i386
# sudo apt-get install VirtualBox grub-legacy xorriso
GCCPARAMS = -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore
ASPARAMS = --32
@@ -18,6 +19,25 @@ objects = loader.o kernel.o
mykernel.bin: linker.ld $(objects)
ld $(LDPARAMS) -T $< -o $@ $(objects)
mykernel.iso: mykernel.bin
mkdir iso
mkdir iso/boot
mkdir iso/boot/grub
cp mykernel.bin iso/boot/mykernel.bin
echo 'set timeout=0' > iso/boot/grub/grub.cfg
echo 'set default=0' >> iso/boot/grub/grub.cfg
echo '' >> iso/boot/grub/grub.cfg
echo 'menuentry "My Operating System" {' >> iso/boot/grub/grub.cfg
echo ' multiboot /boot/mykernel.bin' >> iso/boot/grub/grub.cfg
echo ' boot' >> iso/boot/grub/grub.cfg
echo '}' >> iso/boot/grub/grub.cfg
grub-mkrescue --output=mykernel.iso iso
rm -rf iso
run: mykernel.iso
(killall VirtualBox && sleep 1) || true
VirtualBox --startvm 'My Operating System' &
install: mykernel.bin
sudo cp $< /boot/mykernel.bin
View
13 types.h
@@ -0,0 +1,13 @@
#ifndef __TYPES_H
#define __TYPES_H
typedef char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef long long int int64_t;
typedef unsigned long long int uint64_t;
#endif

0 comments on commit b440da7

Please sign in to comment.