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(); }
int main(void) { init_global(); init_gdt(); init_idt(); init_tss(); init_virtual_memory_mapping(); init_process(); init_8259a(); init_clock(); init_keyboard(); init_syscall(); debug_helper(); restart(); }
void k_main(multiboot_info_t * multiboot_info) { system_info.total_memory = multiboot_info->mem_upper; clrscr(); printf("%s\n", &uname); printf(" Copyright 2005-2006 Draco Project\n"); printf("%dM of extended memory.\n", multiboot_info->mem_upper >> 10); cons_attribute = 7; init_gdt(); init_idt(); init_irq(0x20, 0x28); paging_kernel_env(system_info.total_memory / 4); paging_init(); proc_init(); modules_init(multiboot_info); printf("Kernel is initialized.\n"); sti(); while(1); }
void init_descriptor_tables() { init_gdt(); init_idt(); memset(&interrupt_handlers, 0, sizeof(isr_t)*256); }
int kernel_main() { init_kernel_stack(KERN_HEAP_OFFSET); init_device_drivers(); device_open(TTY, 0); k_printf("entered into main kernel..!\n"); k_printf("and initialized device drivers.\n"); init_gdt(); k_printf("initialized protected mode.\n"); check_physical_mem_size(); k_printf("physical memory size : %d megabytes.\n", physical_mem_size>>20); init_paging(); k_printf("initialized paging.\n"); init_vfs(); k_printf("initialized file system (fat16).\n"); init_idt(); k_printf("initialized interrupt.\n"); init_tss(); struct fat16_file_kt f; f = fs_open_fat16("/apps/snake.bin"); create_task(f.buffer, f.information.file_size); dump_task_queue(); current_task = pop_task_queue(); create_task(init1, 256); create_task(init2, 256); create_task(init3, 256); create_task(init4, 256); create_task(init5, 256); dump_task_queue(); /* do { struct task_struct_kt *cur = task_head; do { k_printf("#%d - stack %x, start %x\n", cur->tid, cur->sp_page, cur->start_entry); cur = cur->next; } while (cur != task_head); } while(0); */ //for(;;); // user page가 제대로 동작할때까지 막아둠. cli(); SCHEDULE(); for(;;); device_close(TTY, 0); return 0; }
// Initialisation routine - zeroes all the interrupt service routines, // initialises the GDT and IDT. void init_descriptor_tables() { // Initialise the global descriptor table. init_gdt(); // Initialise the interrupt descriptor table. init_idt(); // Nullify all the interrupt handlers. interrupt::init(); }
// Initialize the GDT and IDT void init_descriptor_tables() { // Initialize the Global Descriptor Table init_gdt(); // Initialize the Interrupt Descriptor Table init_idt(); }
void init_descriptor_tables() { // Initialise the global descriptor table init_gdt(); // Initialise the interrupt descriptor table init_idt(); }
int kernel_main() { init_gdt(); init_idt(); init_video(); setcolor(make_color(COLOR_GREEN, COLOR_BLACK)); printf("Hello, World!"); newline(5); setcolor(make_color(COLOR_ORANGE, COLOR_BLACK)); printf(" ,--.\n"); printf(" _/ <`-'\n"); printf(" ,-.' \\--\\_\n"); printf(" ((`-.__\\ )\n"); printf(" \\`' @ (_\n"); printf(" ( (_)\n"); printf(" ,'`-._(`-._/\n"); printf(" ,-' )&&) ))\n"); printf(" ,-' /&&&%-'\n"); printf(" ,' __ ,- {&&&&/\n"); printf(" / ,' \\| |\\&&'\\\n"); printf(" ( | |' \\ `--.\n"); printf("(%--'\\ ,--.\\ `-.`-._)))\n"); printf(" `---'`-/__)))`-._)))\n\n"); int count = 0; //Some delay before bouncing while (count < 10) { sleep(100000000); count++; } count = 0; while (true) { while (count < 5) { sleep(100000000); scrolldown(); count++; } while (count < 10) { sleep(100000000); scrollup(); count++; } if (count % 10 == 0) { count = 0; } } printf("Exiting..."); return 0; }
int main(multiboot_t *mboot_ptr) { monitor_clear(); init_gdt (); init_idt (); init_timer (20); init_pmm (mboot_ptr->mem_upper); init_vmm (); // Find all the usable areas of memory and inform the physical memory manager about them. uint32_t i = mboot_ptr->mmap_addr; while (i < mboot_ptr->mmap_addr + mboot_ptr->mmap_length) { mmap_entry_t *me = (mmap_entry_t*) i; // Does this entry specify usable RAM? if (me->type == 1) { uint32_t j; // For every page in this entry, add to the free page stack. for (j = me->base_addr_low; j < me->base_addr_low+me->length_low; j += 0x1000) { pmm_free_page (j); } } // The multiboot specification is strange in this respect - the size member does not include "size" itself in its calculations, // so we must add sizeof (uint32_t). i += me->size + sizeof (uint32_t); } printk ("Paging initialised.\n"); printk ("Mapping page...\n"); uint32_t addr = 0x900000; map (addr, 0x500000, PAGE_PRESENT|PAGE_WRITE); printk ("Accessing page...\n"); volatile uint32_t *_addr = (volatile uint32_t*)addr; *_addr = 0x567; printk ("*addr: %x\n", *_addr); printk ("Unmapping page...\n"); unmap (addr); printk ("Trying to access again (should page fault)...\n"); *_addr = 0x678; printk ("*addr: %x\n", *_addr); asm volatile ("sti"); for (;;); return 0xdeadbeef; }
// Initialisation routine - zeroes all the interrupt service routines, // initialises the GDT and IDT. void init_descriptor_tables() { // Initialise the global descriptor table. init_gdt(); // Initialise the interrupt descriptor table. init_idt(); // Nullify all the interrupt handlers. memset(&interrupt_handlers, 0, sizeof(isr_t)*256); }
int nx_main(struct multiboot *mboot) { init_gdt(); init_idt(); monitor_clear(); monitor_write_str("Hello world!\n"); init_timer(20); asm volatile ("sti"); return 0; }
int kmain(multiboot_t *mboot_ptr) { monitor_clear(); printk("8888888888 d8b 888 .d88888b. .d8888b.\n"); printk("888 Y8P 888 d88P\" \"Y88b d88P Y88b\n"); printk("888 888 888 888 Y88b.\n"); printk("8888888 88888b.d88b. 888 888 888 888 \"Y888b.\n"); printk("888 888 \"888 \"88b 888 888 888 888 \"Y88b.\n"); printk("888 888 888 888 888 888 888 888 \"888\n"); printk("888 888 888 888 888 888 Y88b. .d88P Y88b d88P\n"); printk("8888888888 888 888 888 888 888 \"Y88888P\" \"Y8888P\"\n"); init_gdt (); init_idt (); init_keyboard(); setup_x87_fpu (); init_timer (20); init_pmm (mboot_ptr->mem_upper); init_vmm (); init_heap (); // Find all the usable areas of memory and inform the physical memory manager about them. uint32_t i = mboot_ptr->mmap_addr; while (i < mboot_ptr->mmap_addr + mboot_ptr->mmap_length) { mmap_entry_t *me = (mmap_entry_t*) i; // Does this entry specify usable RAM? if (me->type == 1) { uint32_t j; // For every page in this entry, add to the free page stack. for (j = me->base_addr_low; j < me->base_addr_low+me->length_low; j += 0x1000) { pmm_free_page (j); } } // The multiboot specification is strange in this respect - the size member does not include "size" itself in its calculations, // so we must add sizeof (uint32_t). i += me->size + sizeof (uint32_t); } kernel_elf = elf_from_multiboot (mboot_ptr); asm volatile ("sti"); panic ("Testing panic mechanism"); for (;;); return 0xdeadbeef; }
/* Initialize descriptor tables (duh) */ void init_descriptor_tables( void ) { /* global descriptor table */ printk("Initializing GDT\n"); init_gdt(); /* interrupt descriptor table */ printk("Initializing IDT\n"); init_idt(); /* now we can start interrupts */ printk("Enabling interrupts\n"); int_enable(); }
void kmain(uint32_t magic, multiboot_info_t *mboot, uintptr_t ebp) { monitor_clear(); printf("Booting Dionysus!\n"); ASSERT(magic == MULTIBOOT_BOOTLOADER_MAGIC && "Not booted with multiboot."); ASSERT(mboot->flags & MULTIBOOT_INFO_MEMORY && "No memory info."); ASSERT(mboot->flags & MULTIBOOT_INFO_MEM_MAP && "No memory map."); printf("Initializing GDT\n"); init_gdt(); printf("Initializing IDT\n"); init_idt(); // Check for modules if (mboot->flags & MULTIBOOT_INFO_MODS && mboot->mods_count) { multiboot_module_t *mods = (multiboot_module_t *)mboot->mods_addr; placement_address = mods[mboot->mods_count - 1].mod_end + KERNEL_BASE; } printf("Setting up paging\n"); init_paging(mboot->mem_lower + mboot->mem_upper, mboot->mmap_addr, mboot->mmap_length); printf("Initializing timers\n"); init_time(); init_timer(); printf("Starting task scheduling\n"); init_tasking(ebp); init_syscalls(); printf("Initializing vfs\n"); init_vfs(); printf("Initializing driver subsystem\n"); init_blockdev(); init_chardev(); init_term(); printf("Enumerating PCI bus(ses)\n"); init_pci(); dump_pci(); init_devfs(); ASSERT(mount(NULL, "/dev", "devfs", 0) == 0); init_ide(); halt(); }
static int __cpuinit xen_cpu_up(unsigned int cpu) { struct task_struct *idle = idle_task(cpu); int rc; #ifdef CONFIG_X86_64 /* Allocate node local memory for AP pdas */ WARN_ON(cpu == 0); if (cpu > 0) { rc = get_local_pda(cpu); if (rc) return rc; } #endif #ifdef CONFIG_X86_32 init_gdt(cpu); per_cpu(current_task, cpu) = idle; irq_ctx_init(cpu); #else cpu_pda(cpu)->pcurrent = idle; clear_tsk_thread_flag(idle, TIF_FORK); #endif xen_setup_timer(cpu); xen_init_lock_cpu(cpu); per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; /* make sure interrupts start blocked */ per_cpu(xen_vcpu, cpu)->evtchn_upcall_mask = 1; rc = cpu_initialize_context(cpu, idle); if (rc) return rc; if (num_online_cpus() == 1) alternatives_smp_switch(1); rc = xen_smp_intr_init(cpu); if (rc) return rc; rc = HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL); BUG_ON(rc); while(per_cpu(cpu_state, cpu) != CPU_ONLINE) { HYPERVISOR_sched_op(SCHEDOP_yield, 0); barrier(); } return 0; }
void kernel_start() { init_pic(); init_gdt(); init_idt(); init_graphic(); io_sti(); while(1); // halt(); }
int main(multiboot_t *mboot_ptr) { monitor_clear(); init_gdt (); init_idt (); init_timer (20); init_pmm (mboot_ptr->mem_upper); init_vmm (); init_heap (); // Find all the usable areas of memory and inform the physical memory manager about them. uint32_t i = mboot_ptr->mmap_addr; while (i < mboot_ptr->mmap_addr + mboot_ptr->mmap_length) { mmap_entry_t *me = (mmap_entry_t*) i; // Does this entry specify usable RAM? if (me->type == 1) { uint32_t j; // For every page in this entry, add to the free page stack. for (j = me->base_addr_low; j < me->base_addr_low+me->length_low; j += 0x1000) { pmm_free_page (j); } } // The multiboot specification is strange in this respect - the size member does not include "size" itself in its calculations, // so we must add sizeof (uint32_t). i += me->size + sizeof (uint32_t); } kernel_elf = elf_from_multiboot (mboot_ptr); asm volatile ("sti"); void *a = kmalloc (8); void *b = kmalloc (8); void *c = kmalloc (8); kfree (a); kfree (b); void *d = kmalloc (24); printk ("a: %x, b: %x, c: %x, d: %x\n", a, b, c, d); panic ("Testing panic mechanism"); for (;;); return 0xdeadbeef; }
//写个struct mulitboot 省着老有警告 用的时候再改 //grub标准里有这个http://gnu.april.org/software/grub/manual/multiboot/multiboot.html //struct multiboot{}; int kmain(struct multiboot_info* mboot_ptr)//name is mentioned in boot.s { init_gdt(); init_idt(); monitor_write("qhello!!@#$%^&*()[]+= bcdef:wworld! 1234"); monitor_write("\n"); monitor_write_hex(256); monitor_write("finished"); monitor_write_dec(256); monitor_write("done ss"); monitor_write_hex(kss); monitor_write("done esp"); monitor_write_hex(kesp); monitor_put('\n'); //init_gdt(); //init_idt(); asm volatile("int $0x3"); asm volatile("int $0x4"); prtf("aa bb %x %u %s 11\t \nbb\n", 10, 10, "str"); //asm volatile("sti"); //init_timer(500); //monitor_write_hex((u32int)&end); prtf("1\tend is at addr :%x end itself:%x kend:%x &kend:%x\n", (u32int)&end, end, kend, &kend); /*旧的paging实现 init_paging(); prtf("paging enabled!\n"); u32int* ptr = (u32int*)0xa0000000; *ptr = 1; */ //新的paging //换了个管理物理内存的方法 这个没啥大区别 //分割物理内存管理 虚拟内存管理 //显式映射虚拟地址 //pmm里搞的都是物理地址 函数返回的也是物理地址 init_pmm ((u32int)&end, 1 << 25);//32MB init_vmm (); /*prtf("mboot_ptr : %x\n", mboot_ptr);//大概0x2d000 没到640k呢 prtf("mem_upper %x\n", mboot_ptr->mem_upper);*/ map(0xa0000000, 0x300000, PAGE_WRITE|PAGE_PRESENT); prtf("mapped!\n"); u32int* ptr = (u32int*)0xa0000000; *ptr = 1; prtf("assigned!\n"); unmap(0xa0000000); prtf("unmapped!\n"); *ptr = 2; prtf("end!\n"); return 0xdeadbeef; }
void _start(void) { kY = 16; kattr = 0x0E; /* Initialisation de la GDT et des segments */ init_gdt(); /* Initialisation du pointeur de pile %esp */ asm(" movw $0x18, %ax \n \ movw %ax, %ss \n \ mov $0x20000, %sp"); main(); }
int kern_entry() { init_debug(); init_gdt(); init_idt(); console_clear(); printk_color(rc_black, rc_green, "Hello, OS kernel!\n"); init_timer(200); // 开启中断 asm volatile ("sti"); return 0; }
void kmain(uint32_t magic) { if ( magic != 0x2BADB002 ) { print("Something went not according to specs."); exit(); } kclear(); char printbuf[256]; snprintf(printbuf, 256, "kernel loaded at %p, ends at %p\n", kernel_start, kernel_end); print(printbuf); print("initializing GDT...\n"); init_gdt(); print("initializing IDT...\n"); init_idt(); print("initializing physical memory manager...\n"); init_pmm(); if (pmm_is_free((paddr_t)kernel_start) || pmm_is_free((paddr_t)kernel_end)) panic("kernel memory is not reserved"); if (pmm_is_free((paddr_t)0xb8000)) panic("video ram is not reserved"); print("initializing virtual memory manager...\n"); init_vmm(); print("initializing PICs...\n"); init_pics(0x20, 0x28); print("initializing keyboard...\n"); init_keyboard(); print("enabling keyboard interrupts...\n"); enable_irq(1); send_eoi(0); __asm__ __volatile__ ("sti"); print("initializing symbol table...\n"); init_stacktrace(); print("initializing timer...\n"); init_timer(10); enable_irq(0); print("initializing speaker...\n"); print("initializing ACPI...\n"); init_acpi(); print("reclaiming ACPI memory...\n"); acpi_reclaim_memory(); print("initializing shell...\n"); init_shell_builtins(); beep(100, 100); cprint("Hello OS\n", 2); update_cursor(); shell(); }
int entry() { init_debug(); init_gdt(); init_idt(); char *string = "hello word!\n"; screen_clear(); printk("%s\n", string); init_timer(200); //sti是恢复中断。cli是关闭中断。 asm volatile ("sti"); asm volatile ("int $0x1"); return 0; }
void init(multiboot_info_t* mb_info, unsigned long magic) { clear_screen(); init_serial(); init_ata(); //initalize the memory manager init_memory_manager(mb_info); //clean the multiboot info after it isn't needed anymore mb_info = NULL; init_keyboard(); kprintf("Initalizing GDT...\n"); init_gdt(); kprintf("Initalizing IDT...\n"); init_idt(); init_multitasking(); }
int k0_main(multiboot_header_t *header) { k0_cls(); module_header_t *mod_header = (module_header_t *)header->mods_addr; //msg[4] = '\0'; //k0_print(msg); //k0_print_char('\n'); k0_print("Kernel level 0 loaded.\nInitializing GDT... "); init_gdt(); k0_print("OK\nInitializing IDT... "); init_idt(); k0_print("OK\nInitializing ISR... "); init_isr(); k0_print("OK\nInitializing IRQ... "); init_irq(); k0_print("OK\n"); k1_main(mod_header); return 0; }
void start_kernel(void) { /* Set up events. */ init_events(); /* ENABLE EVENT DELIVERY. This is disabled at start of day. */ local_irq_enable(); setup_xen_features(); /* Init memory management. */ init_mm(); /* Init GDT */ init_gdt(); /* Init time and timers. */ init_time(); /* Init the console driver. */ init_console(); /* Init grant tables */ init_gnttab(); /* Init scheduler. */ init_sched(); /* Init XenBus */ init_xenbus(); /* Init futexes */ init_futex(); #ifdef CONFIG_XENBUS create_thread("shutdown", shutdown_thread, NULL); #endif /* Call (possibly overridden) app_main() */ app_main(&start_info); /* Everything initialised, start idle thread */ run_idle_thread(); }
/* 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"); } }
int __cpuinit xen_cpu_up(unsigned int cpu) { struct task_struct *idle = idle_task(cpu); int rc; #if 0 rc = cpu_up_check(cpu); if (rc) return rc; #endif init_gdt(cpu); per_cpu(current_task, cpu) = idle; irq_ctx_init(cpu); xen_setup_timer(cpu); /* make sure interrupts start blocked */ per_cpu(xen_vcpu, cpu)->evtchn_upcall_mask = 1; rc = cpu_initialize_context(cpu, idle); if (rc) return rc; if (num_online_cpus() == 1) alternatives_smp_switch(1); rc = xen_smp_intr_init(cpu); if (rc) return rc; smp_store_cpu_info(cpu); set_cpu_sibling_map(cpu); /* This must be done before setting cpu_online_map */ wmb(); cpu_set(cpu, cpu_online_map); rc = HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL); BUG_ON(rc); return 0; }
void kernel_init() { init_gdt(); init_idt(); init_debug(); init_mm(); init_vmm(); init_heap(); init_sched(); console_clear(); cprintk(rc_light_brown, "Welcome to SuperSong's OS, version: %s\n\n", "v0.1"); init_timer(200); cprintk(rc_light_cyan, "kernel in memory start: 0x%x\n", __kernel_mem_start); cprintk(rc_light_cyan, "kernel in memory end: 0x%x\n", __kernel_mem_end); cprintk(rc_light_cyan, "kernel in memory_used: %d KBs\n", (__kernel_mem_end - __kernel_mem_start + 1023) / 1024); show_memory_map(); cprintk(rc_red, "\nThe count of physical memory pages is: %d\n\n", phy_page_count); kthread_create(thread, NULL); enable_intr(); while (1) { cprintk(rc_red, "Thraed1\n"); } while (1) { __asm__ volatile ("hlt"); } }
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); }