/* \brief Handles archetecture-specific initialization for i586. * * This function initializes various tables, paging, and the initial heap, * various timers, then passes the locations of modules and elf info (if any) * to \ref kmain. * * @param mboot The multiboot header passed by a compliant bootloader. * @param blarg At the moment, the initial stack placement. This parameter * is unused and will be removed soon. * @param magic The multiboot header checksum. */ void arch_init( multiboot_header_t *mboot, int blarg, int magic ){ void *modules = 0; void *elfinfo = 0; init_serial( ); // Take care of multiboot stuff... if ( magic != 0x2badb002 ) panic( "Need multiboot-compliant bootloader to boot Helix kernel.\n" ); if ( mboot->flags & MULTIBOOT_FLAG_ELF ) elfinfo = &mboot->elf_headers; if ( mboot->flags & MULTIBOOT_FLAG_MODS && mboot->mods_count ){ modules = *(int **)mboot->mods_addr; early_placement = *(int *)(mboot->mods_addr + 4); } // Set up memory utils init_tables( ); init_paging( mboot->mem_lower + mboot->mem_upper ); kheap = kmalloc_early( sizeof( mheap_t ), 0 ); init_heap( kheap, kernel_dir, 0xd0000000, PAGE_SIZE * 32 ); init_timer( ); kmain( 0, modules, elfinfo ); while( 1 ) asm volatile( "hlt" ); }
void init(void) { char *origen, *destino; long i, largo; /* Copiar el kernel */ destino = (char *) KERNEL_FCODE; origen = (char *) POSICION_LOADER; for(i=0 ; i < (long) &_code_size; i++) *(destino+i) = *(origen+i); __asm__ __volatile__ ("address_X: jmp (address_X - 0xff800000 + 5) "); /* Copiar Datos */ destino = (char *) KERNEL_FDATA; origen = (char *) POSICION_LOADER + (long) &_code_size; largo= (long) &_data_size; for(i=0; i < largo ; i++) *(destino+i) = *(origen+i); /* Una vez copiado todo en su lugar, saltamos a funcion ppal*/ kmain(); }
//! kernel entry point is called by boot loader void __cdecl kernel_entry (multiboot_info* bootinfo) { #ifdef ARCH_X86 // Set registers for protected mode _asm { cli mov ax, 10h mov ds, ax mov es, ax mov fs, ax mov gs, ax } #endif //ARCH_X86 //dx 레지스터에는 커널의 크기가 담겨 있다. //다른값으로 씌워지기 전에 값을 얻어낸다. _asm mov word ptr[g_kernelSize], dx InitializeConstructors(); kmain (bootinfo); Exit (); console.Print("kernel_entry : Shutdown Complete. Halting system\n"); #ifdef ARCH_X86 _asm { cli hlt } #endif for (;;); }
void _start(void) { /* copy data from rom */ if (&__data_start != &__data_start_rom) { unsigned int *src = &__data_start_rom; unsigned int *dest = &__data_start; while (dest != &__data_end) *dest++ = *src++; } /* zero out bss */ unsigned int *bss = &__bss_start; while (bss != &__bss_end) *bss++ = 0; kmain(); }
/* 0x1000 */ void _start(void) { clearscreen(); init_gdt(); print("Loading IDT\n"); init_idt(); print("Loading PIC\n"); init_pic(); print("Running kmain()\n"); sti; kmain(); /* Call kernel's kmain() */ while (1) { /* Never return */ print("hlt;\n"); } }
/* This is the first C function ever called. * it gets called from the boot loader assembly */ void entry() { kmain(); __asm__("cli\n\t" "hlt"); }
extern "C" void handler_reset() { setup_clock(); copy(&__data_start, &__data_end, &__data_load); fill(&__bss_start, &__bss_end, 0); kmain(); }