I'm interested in operating system concepts, so I downloaded the Hello world OS. I'd like to know how to compile and link the code and make a bootable image. I'm using an old version of Cygwin on Windows (Cygwin-b20) from 1999.
My code for main.c
is:
#include "bloader.h"
int main();
unsigned int oldEBP;
struct boot_dir *viewableDirectory;
int totalMem;
char * passedParams;
void _start(int memSize, char *parms, struct boot_dir *loadedfiles)
{
asm("mov %%ebp, %0":"=m"(oldEBP));
viewableDirectory = loadedfiles; /*make file mem locations global*/
totalMem = memSize; /*make mem of system global*/
passedParams = parms; /*make paramaters passed to system global*/
main();
asm("hlt"); /* this halts the machine, solving the problem of triple-faults on
some machines, but also making it impossible to return to DOS */
}
int main()
{
char *vidmem = (char *) 0xb8000;
/* "Hello " */
vidmem[0] = 'H';
vidmem[1] = 0x7;
vidmem[2] = 'e';
vidmem[3] = 0x7;
vidmem[4] = 'l';
vidmem[5] = 0x7;
vidmem[6] = 'l';
vidmem[7] = 0x7;
vidmem[8] = 'o';
vidmem[9] = 0x7;
vidmem[10] = ' ';
vidmem[11] = 0x7;
/* "World " */
vidmem[12] = 'W';
vidmem[13] = 0x7;
vidmem[14] = 'o';
vidmem[15] = 0x7;
vidmem[16] = 'r';
vidmem[17] = 0x7;
vidmem[18] = 'l';
vidmem[19] = 0x7;
vidmem[20] = 'd';
vidmem[21] = 0x7;
vidmem[22] = ' ';
vidmem[23] = 0x7;
/* "OS" */
vidmem[24] = 'O';
vidmem[25] = 0x7;
vidmem[26] = 'S';
vidmem[27] = 0x7;
return 0;
}
I'm interested in instructions to:
- Create ISO file after compile and run it with VMware (or other virtual machines)
- Run this code after compiling in real machine when system boots and how to add it to bootloader (for example GRUB) entry