2016-02-26 22:31:34 -08:00
# include <stddef.h>
# include <stdint.h>
2016-02-27 13:50:51 -05:00
# include "Console.hh"
2016-02-26 22:31:34 -08:00
# if defined(__linux__)
# error "This file should be compiled with a cross-compiler, not the Linux system compiler!"
# endif
# if !defined(__i386__)
# error "This file should be compiled with an ix86-elf compiler!"
# endif
2016-02-27 12:34:36 -05:00
/** Called very early, before global initialization. */
2016-02-26 22:31:34 -08:00
extern " C "
void
kearly ( )
2016-02-28 03:46:30 -05:00
{ }
/** The beginning of the world... */
extern " C "
void
kmain ( )
2016-02-27 13:50:51 -05:00
{
2016-02-28 03:46:30 -05:00
auto console = kernel : : Console : : systemConsole ( ) ;
2016-02-27 13:50:51 -05:00
console . clear ( kernel : : Console : : Color : : Blue ) ;
2016-02-27 13:59:30 -05:00
console . writeString ( " Hello world! \n " ) ;
2016-02-27 15:07:52 -05:00
2016-02-28 03:50:35 -05:00
// TODO: The performance of this loop slowed down a *lot* (7-8 orders of magnitude according to the busy loop) when I moved this code from kearly() to here. I wonder if it has something to do with object initialization? Should probably investigate some.
2016-02-27 15:07:52 -05:00
volatile int foo = 0 ;
int j = 0 ;
int i = 0 ;
for ( ; ; ) {
if ( j = = 0 ) {
console . writeString ( " --- MARK --- \n " ) ;
}
console . writeChar ( ' a ' + i ) ;
console . writeChar ( ' \n ' ) ;
i = ( i + 1 ) % 26 ;
j = ( j + 1 ) % 500 ;
2016-02-28 03:46:30 -05:00
for ( uint32_t k = 0 ; k < ( 2u < < 20 ) - 1 ; k + + ) {
2016-02-27 15:07:52 -05:00
foo / = 2 ;
}
}
2016-02-27 13:50:51 -05:00
}