Example #1
0
File: kernel.c Project: Thog/GLaBSD
void kernel_early(multiboot_info_t *mbt, unsigned int magic) {
  (void)magic;
  terminal_initialize();
  printf("Initializing Kernel core...\n");
  set_multiboot_info(mbt);
  init_arch();
}
Example #2
0
void kernel_main()
{
	terminal_initialize();
	/* Since there is no support for newlines in terminal_putchar yet, \n will
	   produce some VGA specific character instead. This is normal. */
	terminal_writestring("Hello, kernel World!\n");
}
Example #3
0
/*
 * Name: kernel_main
 *
 * Description: Main kernel loop. Never returns. 
 *
 */
void kernel_main() 
{

    terminal_initialize();

    setup_memory();

    unsigned char *ptr = kmalloc(4096, GFP_KERNEL); 

    printk("%p --> %p\n", ptr, *ptr);

    unsigned long val = 0xdeadbeef;
    memcpy(ptr, &val, 4);
    dumpBytes(ptr, 4);

    printk("pages used %p out of %p\n", mem_stats.nr_used_frames, mem_stats.nr_total_frames);

	unsigned long virt_addr = boot_kmalloc();
	printk("boot_kmalloc = %p\n", virt_addr);
	
	virt_addr = boot_kmalloc();
	printk("boot_kmalloc = %p\n", virt_addr);

	ptr = (unsigned char *) 0xc0000000;
	*ptr = 0x77;
	



    // Kernel never returns from this function.
	while (1) {}
}
Example #4
0
int main()
{
	init_state();
	terminal_initialize();
	char s[MAX_LEN];
	int result;
	while (1)
	{
		result = insert_nxt_char(s);
		if (result == -1)
		{
			write_sentence(COLOR_WHITE, "Error: buffer overflow");
			break;
		}
		else if (result == 1)
			break;
		}
	if (result != -1) //if no error
		write_sentence(COLOR_WHITE, s);
	
	//restores state of eflags
	__asm__
	(
	"pushfl \n\t"
	"mov old_eflags, %ecx \n\t"
	"mov %ecx, 0(%esp) \n\t"
	"popfl"
	);
	return 0;
}
Example #5
0
void kernel_early(multiboot_info_t* mbd, unsigned int magic)
{
	terminal_initialize();

	printf("Starting jOS Kernel\n");
	printf("===================\n\n");
	
	if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
		panic("Bootloader is not Multiboot Compliant");
	
	memory_init(mbd);

	printf("[x] Memory Initialized\n");
	
	gdt_init();
	
	printf("GDT Initialized, entering Protected Mode\n");
	
	printf("Enabling IDT:\n");

	pic_init();

	printf("\t[x] PIC IRQs remapped\n");
	
	idt_init();

	printf("\t[x] IDT Initialized\n");
	if (are_interrupts_enabled())
		printf("\t[x] Hardware Interrupts enabled\n");
	else
		printf("\t[ ] Error enabling Hardware Interrupts\n");
	
	phys_mem_management_init();
	
}
Example #6
0
File: kernel.c Project: candraw/fOS
void init_kernel() 
{
    terminal_initialize();

    init_serial(COM1);
    terminal_enable_serial_echo(COM1);

    terminal_printf("fOS version %s\n\n\n", KERNEL_VERSION);

    kinit(end + 4096, end + 4096 + (100 * 4096));

    init_gdt();
    load_gdt();


    load_idt();
    load_isrs();

    irq_install();
    asm volatile ( "sti" );

    timer_install();
    sleep(1);

    keyboard_install();

    init_paging();
    switch_to_paging();
}
Example #7
0
void kmain(kernel_boot_info_t info)
{
    if(info.magic_number != MULTIBOOT_BOOTLOADER_MAGIC)
    {
        printk("Invalid Boot Image!");
        return;
    }
    else
    {
        printk("Boot Successfull!");
    }

    terminal_initialize();

    // Disable Interrupts
    disable_interrupts();

    install_gdt();
    install_idt();

    // Enable Interrupts
    enable_interrupts();

    install_mm(&info);
    install_paging(&info);
 
    install_keyboard();
    install_pit();
  
    initialize_initrd(&info);

    list_mount_points();
    while(1);
}
Example #8
0
void kmain()
{
	terminal_initialize();
	terminal_writestring("H\ne\nl\nl\no\nk\nH\ne\nl\nl\no\nk\nH\ne\nl\nl\no\nk\nH\ne\nl\nl\no\nk\nH\ne\nA\np");
	

}
void kernel_main() {
    /* Initialize terminal interface */
    terminal_initialize();
 
    /* Since there is no support for newlines in terminal_putchar
         * yet, '\n' will produce some VGA specific character instead.
         * This is normal.
         */

    char buffer[8];

    for (int i = 1; i <= 100; i++) {
        if (i % 3 == 0 && i % 5 == 0) {
            terminal_writestring("FizzBuzz");
        } else if (i % 3 == 0) {
            terminal_writestring("Fizz");
        } else if (i % 5 == 0) {
            terminal_writestring("Buzz");
        } else {
            terminal_writestring(itoa(i, buffer, 10));
        }

        if (i < 100) {
            terminal_writestring(", ");
        }
    }
}
Example #10
0
void kernel_main() {
    //init terminal
    terminal_initialize();

    terminal_writestring("1Hello world! IT'S ALIVE!!!\n2Newline testing...\n3It works.");
    terminal_writestring("\n4\n5\n6wew\n7ewe\n8wew\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24 lines. Next one should mess things up.");
    terminal_writestring("\n25First ruiner");
    terminal_writestring("\n26Second ruiner");
}
Example #11
0
void kernel_main() {
  /* Initialize terminal interface */
  terminal_initialize();

  /* since there is no support for newlines in terminal_putchar
   * yet, '\n' will prouce some VGA specific character instead.
   * This is normal.
   */
   terminal_writestring("A single step.\n");
}
void kernel_main() {

  terminal_initialize();

  terminal_writestring("--< Kernel >--\n");

  for (int i = 0; i < 50; i++) {
    terminal_writestring("Hello, World!\n");
  }
}
Example #13
0
void kernel_main()
{
	terminal_initialize();

	start_screen(20);

	testStuff();
	
	//runs other main to init everything else, sloppy but short on time
	main_call();
}
Example #14
0
void kernel_main() {
    /* Initialize terminal interface */
    terminal_initialize();
 
    /* Since there is no support for newlines in terminal_putchar
         * yet, '\n' will produce some VGA specific character instead.
         * This is normal.
         */
    terminal_writestring("Hello, my name is Tanner. I am 16 years old, and this is my operating system!\n");
    terminal_writestring("This should be on a new line.\n");
}
Example #15
0
void kernel_main() {
    /* Initialize terminal interface */
    terminal_initialize();

    terminal_writestring("You shouldn't see this string if scrolling works...\n");
    for (size_t row = 0; row < VGA_HEIGHT - 1; row++) {
        terminal_writerainbow("Hello kernel world!\n");
    }
    terminal_setcolor(COLOR_LIGHT_GREY);
    terminal_writestring("Reached bottom of terminal");

}
Example #16
0
void kernel_main() {
	/* Initialize terminal interface */
	terminal_initialize();

	/* Since there is no support for newlines in terminal_putchar
         * yet, '\n' will produce some VGA specific character instead.
         * This is normal.
         */

	terminal_writestring("Hello, hielep!\n");
	terminal_writestring("Hello, hfdsfdsp!\n");

}
Example #17
0
void kernel_main(multiboot_info_t* mbd,unsigned int magic) {
	/* Initialization */
	terminal_initialize();
	kprint("Kernel Loading...\nInitializing GDT......");
 	gdt_install();
	kprint("DONE\nInitializing IDT......");
	idt_install();
	kprint("DONE\n");
	total_memory=mbd->mem_upper;
	total_memory*=1024;
	
	enter_pmode();	
	
}
Example #18
0
bool init_screen() {
	terminal_initialize();

	terminal_setcolor(make_color(FGCOLOR, BGCOLOR));
	terminal_clear();

	terminal_printf("Welcome to ");
	terminal_setcolor(make_color(COLOR_MAGENTA, BGCOLOR));
	terminal_printf("%s", __KERNEL_NAME);

	terminal_setcolor(make_color(FGCOLOR, BGCOLOR));
	terminal_printf(" multiboot32 => kernel loader\n");
	return true;
}
Example #19
0
void kernel_main()
{
    /* Initialize terminal interface */
    terminal_initialize();

    init_idt();
    init_pic();
    init_keyboard();
    /* Accept Intterupt now */
    asm volatile("sti");
    printf("VOID-OS Operating System 0.01\n\n");
    printf("void-os$ ");
    for(;;) {
            asm("hlt");
    }
}
Example #20
0
void kernel_main(unsigned int ebx)
{
        mbinfo = (multiboot_info_t *) ebx;
        // module_address 		 = mbinfo->mods_addr;

	/* Initialize terminal interface */
	terminal_initialize();
	idt_init();

	/* Newline support is left as an exercise. */
	terminal_writestring("FuseOS v.0.0.1\n");
	terminal_writestring("Enabling Interrupts\n");
	if(mbinfo->mods_count == 1) {
		terminal_writestring("Module Count = 1, Sample Program can be loaded\n");	
	}
	for(;;);
}
Example #21
0
void kernel_main()
{
	terminal_initialize();
	kprintf("Identifying CPU...", COLOR_WHITE);
	cpuid_t cpu_data = get_cpuid();
	kprintf(cpu_data.make, COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Type: ", COLOR_WHITE);
	kprintf(itoa(cpu_data.family), COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Family: ", COLOR_WHITE);
	kprintf(cpu_data.family, COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Model: ", COLOR_WHITE);
	kprintf(cpu_data.model, COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Enabling A20 Line...\n", COLOR_WHITE);
	enable_a20();
	kprintf("Initilizing VGA Driver....\n",COLOR_WHITE);
	kprintf("Installing Global Descriptor Table....\n",COLOR_WHITE);
	gdt_install();
	kprintf("Installing Interrupt Descriptor Table....\n",COLOR_WHITE);
	idt_install();
	kprintf("Enabling paging...\n", COLOR_WHITE);
	init_paging();
	kprintf("Setting up ISRs...\n",COLOR_WHITE);
	isrs_install();
	kprintf("Remapping the PIC and setting up IRQs...\n",COLOR_WHITE);
	install_irq();
	kprintf("Initializing the Kernel Address Translation Table...\n", COLOR_WHITE);
	kATT_Init();
	kprintf("Identifying ATA drives.....\n", COLOR_WHITE);
	ATA_Init();
	kprintf(DRIVE_DATA, COLOR_WHITE);
        kprintf("Installing Timer ISR....\n",COLOR_WHITE);
 	timer_install();
//	kprintf("Checking PCI device vendors....\n",COLOR_WHITE);
//	init_PCI();
	kprintf("Starting shell....\n",COLOR_WHITE);

	init_shell();

	for (;;);
}
Example #22
0
File: kernel.c Project: vtsman/SLU
void kernel_main(multiboot_info_t* mbd, unsigned int magic)
{
	terminal_initialize();
	terminal_writestring("Now booting SLU\n");
	terminal_writestring("Compiled on ");
	terminal_writestring(__DATE__);
	terminal_writestring(" at ");
	terminal_writestring(__TIME__);
	terminal_writestring("\n");
	print_logo();
	terminal_writestringwithcolor("Current memory available: ", COLOR_GREEN, COLOR_BLACK);
	char mem[33];
	ltoa(mbd->mem_upper + mbd -> mem_lower, mem, 10);
	terminal_writestring(mem);
	terminal_writestring(" kilobytes \n");
	
	terminal_writestring("CPU Flags: ");
	char iflags[65];
	ltoa(getCPUFlags(), iflags, 2);
	terminal_writestring(iflags);
	terminal_writestring("\n");
	
	terminal_writestringwithcolor("Magic number: ", COLOR_MAGENTA, COLOR_BLACK);
	char mchar[33];
	itoa(magic, mchar, 16);
	terminal_writestring(mchar);
	terminal_writestring("\n");
	update_cursor(10, 10);
	
	terminal_writestring("Setting up tables\n");
	asm("cli");
	init_gdt();
	init_idt();
	asm("sti");
	
	init_ps2();
	terminal_writestring("Done setting up tables\n");
	
	while(1);
}
void kernel_init(struct multiboot *mboot_ptr) { 
  
  //Reprogram PICs
  cli();
  init_pics(0x20, 0x28);
  sti();
  
  //Initialize Terminal
  terminal_initialize();
  
  kinfo("Enable A20 Gate (if not already done)\n");
  //Enable A20 Gate if it is not already enabled.
  if (checkA20() = 0)
    enableA20();
  
  //Check if A20 is REALLY enabled
  if (checkA20() = 0)
    panic("Enabling A20 Gate");
  
  //Enable the timer and setting it to 50hz
  kinfo("Enable Timer (50hz)");
  init_timer(50);
  
  //Initiate the descriptor tables (gdt and idt)
  init_descriptor_tables();
  
  //Enter the protected mode
  kinfo("Enter protected mode");
  enterProtected();
  
  //Spawning the init process with argument *mboot_ptr
  kinfo("Spawning Init process...");
  init(*mboot_ptr);
  
  //The init process should NEVER die.
  //If it dies
  kerror("Init Process terminated... make a kernel panic...");
  panic("Unendable Process ended.");
}
Example #24
0
void kernel_main() {
  gdt_install();
  idt_install();
  isrs_install();
  irq_install();
  terminal_initialize();
  memory_manager_init();
  enable_interrupts();
  timer_install();
  keyboard_install();
  shell_init();

  terminal_writestring("Hello, kernel World!\n");
  terminal_writestring("Here is some text in a new line\n");
  terminal_writestring("Here is some more text\n");
  terminal_writestring("Here is a new line\n");
  terminal_writestring("Here is some text after terminal scroll\n");
  char str[] = "A string";
  char ch = 'c';
  int integer = 45;
  printf("This is a test for printf.\nThis is a char %c and this a string %s\n", ch, str);
  printf("This is an int %d. This is the same in hex %x\n", integer, integer);

  for (size_t i = 0; i < 5; i++) {
    printf("This is line number %d\n", i);
  }

  puts("waiting for 2 sec\n");
  timer_wait(2);
  puts("waiting complete\n");

  char buffer[200];
  gets(buffer);
  printf("%s\n", buffer);
  while(1) {
    shell();
  }

}
Example #25
0
void kernel_main() {
	/* Initialize terminal interface */
	terminal_initialize();
 
    terminal_writestring("1.- Hello kernel World! How are you?\n");
    terminal_writestring("2.- Hello kernel World! How are you?\n");
    terminal_writestring("3.- Hello kernel World! How are you?\n");
    terminal_writestring("4.- Hello kernel World! How are you?\n");
    terminal_writestring("5.- Hello kernel World! How are you?\n");
    terminal_writestring("6.- Hello kernel World! How are you?\n");
    terminal_writestring("7.- Hello kernel World! How are you?\n");
    terminal_writestring("8.- Hello kernel World! How are you?\n");
    terminal_writestring("9.- Hello kernel World! How are you?\n");
    terminal_writestring("10.- Hello kernel World! How are you?\n");
    terminal_writestring("11.- Hello kernel World! How are you?\n");
    terminal_writestring("12.- Hello kernel World! How are you?\n");
    terminal_writestring("13.- Hello kernel World! How are you?\n");
    terminal_writestring("14.- Hello kernel World! How are you?\n");
    terminal_writestring("15.- Hello kernel World! How are you?\n");
    terminal_writestring("16.- Hello kernel World! How are you?\n");
    terminal_writestring("17.- Hello kernel World! How are you?\n");
    terminal_writestring("18.- Hello kernel World! How are you?\n");
    terminal_writestring("19.- Hello kernel World! How are you?\n");
    terminal_writestring("20.- Hello kernel World! How are you?\n");
    terminal_writestring("21.- Hello kernel World! How are you?\n");
    terminal_writestring("22.- Hello kernel World! How are you?\n");
    terminal_writestring("23.- Hello kernel World! How are you?\n");
    terminal_writestring("24.- Hello kernel World! How are you?\n");
    terminal_writestring("25.- Hello kernel World! How are you?");
    terminal_writestring("26.- Hello kernel World! How are you?");
    terminal_writestring("27.- Hello kernel World! How are you?");
    terminal_writestring("28.- Hello kernel World! How are you?\n");
    terminal_writestring("29.- Hello kernel World! How are you?\n");
    terminal_writestring("30.- Hello kernel World! How are you?\n");
    terminal_writestring("31.- Hello kernel World! How are you?\n");  	    	    	    	    	    	    	    	    	    	    	    	    
    //swap_entryat(0,0, 0, 1);

}
Example #26
0
File: main.c Project: reijnden/rho
/*
 * Called from boot.S, prior to global constructor
 */
void kernel_early(uint32_t magic)
{
	irq_disable();
	memset(&rho,0,sizeof(rho_context));
	/*
	 * Storing some data out of the BDA (BIOS Data Area)
	 * See www.bioscentral.com/misc/dba.htm
	 */
	memcpy(&rho.iobase,(uint16_t *)0x463,sizeof(uint16_t));
	memcpy(&rho.displaymode,(uint8_t *)0x449,sizeof(uint8_t));
	memcpy(&rho.cols,(uint8_t *)0x44A,sizeof(uint8_t));
	memcpy(&rho.rows,(uint8_t *)0x484,sizeof(uint8_t));
	terminal_initialize();
	puts("Checking multiboot compliance");
	if (!(magic & MULTIBOOT_MAGIC)) {
		puts ("Not multiboot compliant! Aborting");
		abort();
	}
	printf ("BDA:Video base IO port: 0x%x\n",rho.iobase);
	printf ("BDA:Display mode: 0x%x\n",rho.displaymode);
	printf ("BDA:Number of columns in text mode: %d\n",(unsigned int)rho.cols);
	printf ("BDA:Number of rows in text mode: %d\n",((unsigned int)rho.rows) + 1);
}
Example #27
0
// This function handles all interrupts.
void fault_handler(struct regs *r)
{
    dbgprint("interrupt!\n");
    if (interrupt_handlers[r->int_no] != 0) {
        (interrupt_handlers[r->int_no]) (r->int_no, r->int_no); // not sure what the second param is for...
        return;
    }
    // unhandled!
    // Is this a fault whose number is from 0 to 31?
    if (r->int_no < 32)
    {
        if (!current) {
            if (r->int_no == 2) {
                // it's an NMI. oh noes
                // we shouldn't do much other than text, to avoid triggering the faulty hardware again

                terminal_initialize(); // clear terminal
                terminal_setcolor(COLOR_RED); // set it to a spooky color

                // show scary message for scary error
                terminal_writestring("*** NON-MASKABLE INTERRUPT OCCURRED ***\n\n");

                terminal_writestring("To protect your computer and data, HexOS has stopped.\n\n");

                terminal_writestring("A critical non-recoverable and non-maskable hardware interrupt has occurred. This may mean that your computer's hardware is defective. If this error occurs multiple times, try isolating the problem by removing and/or replacing components.");
                while (1) {}
            }
            printf("Error code: %d\n", r->err_code);
            // Display the description for the Exception that occurred.
            panic(exception_messages[r->int_no]);
            for (;;);
        } else {
            // TODO: signal the process rather than kill it
            process_exit(-1, exception_messages[r->int_no]); // kill the process
        }
    }
}
Example #28
0
void kernel_init(multiboot_info_t* mb_info, unsigned int magic) {
    terminal_initialize();
    terminal_writestring("Project Omamori now starting...\n");
    gdt_init();
    idt_init();
    initialize_vmem_allocator();
    k_heap_init();
    initialize_pageframes(mb_info);
    
    // do global constructor setup
    kprintf("Calling global constructors.\n");
    size_t *current = (size_t*)((size_t)&__CTOR_LIST__+4); // skip the first function pointer
    int n_constructors_called = 1;
    while(true) {
        if(*current == 0)
            break;
        //kprintf("Calling constructor %u at address 0x%x.\n", (unsigned long long int)n_constructors_called, ((unsigned long long int)*current) );
        void(*func)(void) = (void(*)(void))(*current);
        func();
        current++;
        n_constructors_called++;
    }
    kprintf("Called %u global constructors.\n", (unsigned long long int)n_constructors_called);
    
    //system_halt;
    kprintf("Kernel begins at physical address 0x%x, corresponding to pageframe ID %u.\n", (unsigned long long int)(&kernel_start_phys), (unsigned long long int)(pageframe_get_block_from_addr( (size_t)&kernel_start_phys )) );
    kprintf("Kernel ends at physical address 0x%x, corresponding to pageframe ID %u.\n", (unsigned long long int)(&kernel_end_phys), (unsigned long long int)(pageframe_get_block_from_addr( (size_t)&kernel_end_phys )) );
    
    terminal_writestring("\nInitializing PICs.\n");
    pic_initialize(PIC_IRQ_OFFSET_1, PIC_IRQ_OFFSET_2);
    set_all_irq_status(true);
    
    terminal_writestring("Initializing PIT.\n");
    pit_initialize(PIT_DEFAULT_FREQ_DIVISOR);
    //system_halt
}
Example #29
0
/* This is the entry point to the bulk of the kernel.
 * @mb is a pointer to a <multiboot_info> structure which has important
 * information about the layout of memory which is passed along from the
 * bootloader.
 * First, the kernel sets up the <gdt> or Global Descriptor Table which
 * describes the layout of memory.
 * Next, it installs the <idt> or interrupt descriptor table, which declares
 * which interrupts are available, and whether they can be accessed from user
 * mode.
 * After the basic CPU state has been initialized, logging and the VGA terminal
 * are initialized, and the kernel heap is installed. Next, the physical memory
 * allocator and the keyboard drivers are initialized. Note that the kernel
 * heap must be initialized before the physical memory allocator since certain
 * parts of the allocator live on the heap. Finally the init process page table
 * is created, and multi-processing is initialized.
 * @return this function should never return.
*/
void kernel_main(struct multiboot_info *mb) {
    gdt_install();
    idt_install();
    terminal_initialize();
    initialize_klog();
    kheap_install((struct kheap_metadata*)KHEAP_PHYS_ROOT, PAGE_SIZE);
    physical_allocator_init(mb->mem_upper + mb->mem_lower);
    keyboard_install();
    char *hi = "Hello kernel!\n";
    void *testing = kmalloc(16);
    memcpy(testing, hi, 16);
    kputs(testing);
    klog(testing);
    kfree(testing);
    (void)kernel_page_table_install(mb);

    proc_init();
    struct process *worker_proc = create_proc(worker);
    schedule_proc(worker_proc);

    while (1) {
        klog("kernel\n");
    }
}
Example #30
0
void kernel_main ()
{
	terminal_initialize();
	terminal_writestring("Hello, kernel World\n");
	terminal_writestring("Implemented The \n Feature..!");
}