void kernel_init(boot_info_t bootInfo) { tty_init(); multiboot_init(bootInfo.multiboot_magic, bootInfo.multiboot_addr); if(a20_enable()) { serial_writestring(1, "A20 enable failed - triggering panic\n"); kernel_panic(); }; gdt_install(); idt_install(); irq_install(); _protected_mode_init(); paging_init(); _paging_enable(); PIC_init(); serial_init(); keyboard_init(); timer_init(); serial_writestring(1, "End kernel_init\n"); kernel_main(); };
void kernel_main(struct multiboot_info *mboot, int initial_stack) { long int mem = 0; mboot_info = mboot; start_video(); putstr("Init Descriptor Tables................."); gdt_install(); idt_install(); putstr("[OK]\n"); putstr("Init ISRs.............................."); isr_install(); putstr("[OK]\n"); putstr("Init IRQs.............................."); irq_install(); __asm__ __volatile__ ("sti"); putstr("[OK]\n"); putstr("Init PIT..............................."); timer_install(); putstr("[OK]\n"); putstr("Amount of memory......................"); mem = mboot->mem_upper / 1024; putnum(mem); putstr("MB\n"); putstr("Init Memory............................"); init_memory_manager(); putstr("\n\n"); putstr("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWelcome to Plex!"); for (;;); }
void kernel_main() { isr_install(); irq_install(); kprint("Type something, it will go through the kernel\n" "Type END to halt the CPU\n> "); }
void kmain(multiboot_info_t* mbd, unsigned int magic){ // kernel entry point. //unsigned char* videoram = (unsigned char*) 0xb8000; //videoram[0] = 65; //videoram[1] = 0x07; //setMode(0x13); setMode(320, 200, 8); // HOLY SHIT THIS WORKS clrscr(); gdt_install(); idt_install(); isrs_install(); irq_install(); timer_install(); start_paging(mbd); keyboard_install(); init_genrand(get_timer_ticks()); __asm__ __volatile__ ("sti"); kprint("Hello, We have booted successfully!\n\tTip: type help for command info\n"); while(1){ if(todo != NULL){ void(*function)() = todo; function(todoCP); todo = NULL; } } }
void idt_install() { idt_load(); isrs_install(); irq_install(); sti(); }
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(); }
void kmain(unsigned long magic, multiboot_info_t * mbi) { if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { printk ("Invalid magic number: 0x%x\n", (unsigned) magic); return; } gdt_install(); idt_install(); init_video(); isrs_install(); irq_install(); timer_install(); sys_setup(mbi); test_inode(); __asm__ __volatile__ ("sti"); printk("EgGS:hello there!\n"); // int i = 10 / 0; for (;;); }
void init_descriptors() { gdt_install(); idt_install(); init_handlers(); irq_install(); }
int irq_init(void) { idt_install(); isrs_install(); irq_install(); return 0; }
void kernel_main(struct mboot_info_struct *mbinfo) { // addr = (int*) kernel_main; // log("[LOAD] " DISTNAME " kernel is started. Disabling interrupts..."); log("[DISCLAIMER] " DISTNAME " is totally free. If you have bought it, please report us seller's contact information to prevent further project law violation."); asm("cli"); log("done."); log("[INFO] Setting up GDT..."); gdt_install(); log("done."); log("[INFO] Setting up IDT..."); idt_install(); log("done."); log("[INFO] Setting up ISRs..."); isrs_install(); log("done."); log("[INFO] Setting up IRQ handlers..."); irq_install(); log("done."); asm("sti"); log("[INFO] Setting up fonts..."); setupFonts(); log("done."); log("[INFO] Initializing PIC..."); //kprint("OS365 Kernel 1.0 is loaded.\nInitializing PIC...",0,0); init_pics(0x20,0x28); log("done."); //setupPaging(); //asm("int $8"); //kprint("\nAll pre-start processes are finished. Preparing to load shell...\n",0,8); log("[INFO] Setting VBE graphics mode..."); //sleep(18); //setGraphicsMode(); vbe_info_t* vbeInfo=(vbe_info_t*)(uint32_t)mbinfo->vbe_mode; framebuffer =(uint8_t*)(mbinfo->framebuffer_addr); fbpitch =mbinfo->framebuffer_pitch; fbbpp =mbinfo->framebuffer_bpp; //memset((void*)framebuffer,0x004DFF,1024*768*3); initKbd(); log("done."); //mouse_install(); log("[INFO] Setting up the timer..."); setupPIT(); log("done."); log("[INFO] Loading Z Window System..."); //abort(); while(true) { shellStart(); fRun=true; log("[WARNING] Error in program: Not returned to Z"); log("[INFO] Getting back to Z..."); } }
/* * Called from boot.S, after global constructor */ void kernel_main(multiboot_info *mbt) { /* * second argument is an 8 bit flag. low bit sets verbosity. */ boot_info(mbt,MB_DRIVE | MB_DEV); printf ("Setting up Global Descriptor Table... "); gdt_install(); puts ("OK"); printf ("Setting up Interrupt Descriptor Table... "); idt_install(); puts ("OK"); printf ("Setting up IRQ... "); irq_install(); puts ("OK"); printf ("Configuring system clock... "); timer_install(100); puts ("OK"); printf ("Enabling keyboard... "); keyboard_install(); puts ("OK"); printf ("Enabling interrupts... "); irq_enable(); if (irq_on()) { puts ("OK"); } else { abort(); } /* * Testing cr0 register */ uint32_t _cr0 = cr0(); printf("PE (Protection Enabled, lowest bit of cr0 register) set? 0x%lx, %s\n", _cr0,_cr0&0x00000001?"yes":"no"); printf("Rho version %d.%d.%d booted\n",RHO_MAJOR,RHO_MINOR,RHO_PATCH); checkAllBuses(); /* * Wait until interrupted */ // mem_inspect(1024,1536); while ( 1 ) { /* * Update the cursos position */ upd_c(); /* * Wait for interrupts */ irq_wait(); } /* */ }
void x86_init() { gdt_install(); idt_install(); isrs_install(); apic_init(); /* apic */ irq_install(); console_init(); timer_install(); init_keyboard(); }
void kmain(struct multiboot_info *mbt) { vga_init(); gdt_install(); idt_install(); isr_install(); irq_install(); syscalls_install(); puts_c(__kernel_name " kernel v" __kernel_version_str "\n\n", COLOR_LIGHT_BLUE, COLOR_DEFAULT_BG); uint64_t mem; get_multiboot_info(mbt, &mem); extern uint32_t _kernel_memory_end[]; kprintf("End of kernel's memory: 0x%x\n", (uint64_t) (uint32_t) _kernel_memory_end); kprintf("Memory:\n%l B\n%l KB\n%l MB\n%l GB\n", mem, mem / 1024, mem / 1024 / 1024, mem / 1024 / 1024 / 1024); init_paging(); map_page(0xFD7FF000, 0x60000, 3); int *p = (int *) 0xFD7FF000; *p = 12; kprintf("*(0x%x) = %i\n", (uint64_t) (uint32_t) p, *p); map_page(0x10000000, 0x60000, 3); int *p2 = (int *) 0x10000000; kprintf("*(0x%x) = %i\n", (uint64_t) (uint32_t) p2, *p2); print_next_available_page(); uint32_t ap = allocate_page(203); map_page(ap, 0x60000, 3); int *p3 = (int *) ap; kprintf("*(0x%x) = %i\n", (uint64_t) ap, *p3); print_next_available_page(); ap = allocate_page(203); kprintf("ap = 0x%x\n", (uint32_t) ap); struct kthread thread; create_kthread(thread_test, &thread); start_kthread(&thread); kprintf("Returned from thread.\n"); _asm_print_test(); return; }
void main() { gdt_install(3) ; init_video(&sc) ; idt_install() ; isrs_install() ; irq_install() ; timer_install() ; keyboard_install() ; __asm__ __volatile__ ("sti"); int state = 0 ; screen sc ; //puts(&sc, "Hello world in new functions\n") ; print_int(&sc, state) ; /* Since there is no support for newlines in terminal_putchar yet, \n will produce some VGA specific character instead. This is normal. */ }
int kernel_main(uint32_t esp) { initial_esp = esp; gdt_install(); idt_install(); isrs_install(); irq_install(); asm volatile("sti"); timer_install(); keyboard_install(); ASSERT(mboot_ptr != 0); ASSERT(mboot_ptr->mods_count > 0); uint32_t initrd_location = *((uint32_t*)mboot_ptr->mods_addr); uint32_t initrd_end = *(uint32_t*)(mboot_ptr->mods_addr + 4); // move the start of our kernel heap to past the initrd placement_address = initrd_end; initialize_paging(); initialize_tasking(); fs_root = initialize_initrd(initrd_location); // Create a new process in a new address space which is a clone of this. int ret = fork(); printf("fork() returned %x, ", ret); printf(" getpid() returned %x\n", getpid()); printf("Loading initial ramdisk...\n"); asm volatile("cli"); traverse_initrd(); asm volatile("sti"); printf("That's all folks\n"); for(;;); return 0; }
/* Installs the IDT */ void idt_install() { /* Sets the special IDT pointer up, just like in 'gdt.c' */ idtp.limit = (sizeof (struct idt_entry) * 256) - 1; idtp.base = (unsigned int)&idt; memset((unsigned char *)&idt,0,sizeof(struct idt_entry)*256); /* Add any new ISRs to the IDT here using idt_set_gate */ irq_remap(); isrs_install(); irq_install(); idt_load(); /* Points the processor's internal register to the new IDT */ print_k("%s\n",IDT_MESSAGE); }
void main(void) { gdt_install(); idt_install(); isrs_install(); irq_install(); timer_install(); keyboard_install(); mouse_install(); __asm__ __volatile__ ("sti"); clear_keyboard_buffers(); clear(BLACK,BLACK); bscreen(); for (;;); }
void kernel_main(){ console_initialize(); gdt_install(); idt_install(); isrs_install(); irq_install(); timer_install(); keyboard_install(); __asm__ __volatile__ ("sti"); console_putString("Hello, kernel World!\n"); for (;;){ } }
void kmain ( void* mbd, unsigned int magic ) { if ( magic != 0x2BADB002 ) { /* there is something wrong */ } else { clearscreen(); printline ("akv's - code is running"); gdt_install (); idt_install (); isrs_install (); irq_install (); __asm__ __volatile__ ("sti"); timer_install (2); keyboard_install (); for(;;); } }
void kmain( void* mbd, unsigned int magic ) { /* Installations */ gdt_install(); idt_install(); isrs_install(); irq_install(); timer_install(); keyboard_install(); init_video(); __asm__ __volatile__ ("sti"); // Disable interrupts settextcolor(0x0F, 0x00); unsigned char string[] = "Welcome to Gulinux 0.01. For a list of commands, type help.\n"; putsa(string); for(;;); }
void boot(void) { // note: function changes rsp, local stack variables can't be practically used register char *temp1, *temp2; uint32_t* modulep; void* physfree; __asm__( "movq %%rsp, %0;" "movq %1, %%rsp;" :"=g"(loader_stack) :"r"(&stack[INITIAL_STACK_SIZE]) ); setup_tss(); reload_gdt(); reload_idt(); irq_install(); timer_install(); keyboard_install(); __asm__("sti"); modulep = (uint32_t*)((char*)(uint64_t)loader_stack[3] + (uint64_t)&kernmem - (uint64_t)&physbase); physfree = (void*)(uint64_t)loader_stack[4]; kphysfree = physfree; mm_phy_init(modulep); vmmgr_init(); vmmgr_page_allocator_init(); cls(); scheduler_init(); /*start( (uint32_t*)((char*)(uint64_t)loader_stack[3] + (uint64_t)&kernmem - (uint64_t)&physbase), &physbase, (void*)(uint64_t)loader_stack[4] );*/ for( temp1 = "!!!!! start() returned !!!!!", temp2 = (char*)0xb8000; *temp1; temp1 += 1, temp2 += 2 ) *temp2 = *temp1; while(1); }
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(); } }
/** * Run kernel. */ void kmain() { gdt_install(); idt_install(); isr_install(); irq_install(); clock_install(); vga_init(); vga_write("Bandit Kernel v0.0.1\n"); vga_write("Developer: Matheus Vieira Portela\n"); vga_write("Contact: matheusvportela at gmail dot com\n\n"); clock_set_frequency(1); /* test_division_by_zero_exception(); */ /* Kernel infinite loop */ while(1) { vga_write("tick\n"); clock_wait(18); } }
void main(BootInformation* boot_info) { asm("cli"); // Memory mm_initialize(boot_info); // IDT and IRQ idt_install(); irq_install(); // Install handlers timer_init(); // Re-enable interrupts asm("sti"); // Initialize IO io_init(); // Initialize modules mod_init_all(); // Welcome printf("Stage 2 loaded from drive %i\n", boot_info->boot_drive); printf("%d entries found for the memory\n", boot_info->smap_size); int i = 0; for (i = 0; i < boot_info->smap_size; ++i) { SMAPEntry *ent = &(boot_info->smap_entries[i]); printf("\tACPI Flags 0x%x Type %d ", ent->acpi & 0x03, ent->type); printf("Base 0x%016llx\tSize %lld\n", ent->base, ent->length); } // Launch command line interpreter cli_start(); // Should never reach this, but just in case... while (1) asm("hlt"); }
void main() { char *video_memory = (char *)0xb8000; *video_memory = 'X'; some_function(); init_video(); idt_install(); isr_install(); irq_install(); timer_install(); keyboard_install(); __asm__ __volatile__ ("sti"); print("Hello World\n"); print("\n\tFrom Ajay Saini!\n"); // test : running of exception handlers //print(20/0); }
/* * multiboot i386 (pc) kernel entry point */ int kmain(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp) { initial_esp = esp; extern char * cmdline; uint32_t mboot_mods_count = 0; mboot_mod_t * mboot_mods = NULL; mboot_ptr = mboot; ENABLE_EARLY_BOOT_LOG(0); assert(mboot_mag == MULTIBOOT_EAX_MAGIC && "Didn't boot with multiboot, not sure how we got here."); debug_print(NOTICE, "Processing Multiboot information."); /* Initialize core modules */ gdt_install(); /* Global descriptor table */ idt_install(); /* IDT */ isrs_install(); /* Interrupt service requests */ irq_install(); /* Hardware interrupt requests */ if (mboot_ptr->flags & (1 << 3)) { debug_print(NOTICE, "There %s %d module%s starting at 0x%x.", mboot_ptr->mods_count == 1 ? "is" : "are", mboot_ptr->mods_count, mboot_ptr->mods_count == 1 ? "" : "s", mboot_ptr->mods_addr); debug_print(NOTICE, "Current kernel heap start point would be 0x%x.", &end); if (mboot_ptr->mods_count > 0) { uintptr_t last_mod = (uintptr_t)&end; uint32_t i; mboot_mods = (mboot_mod_t *)mboot_ptr->mods_addr; mboot_mods_count = mboot_ptr->mods_count; for (i = 0; i < mboot_ptr->mods_count; ++i ) { mboot_mod_t * mod = &mboot_mods[i]; uint32_t module_start = mod->mod_start; uint32_t module_end = mod->mod_end; if ((uintptr_t)mod + sizeof(mboot_mod_t) > last_mod) { /* Just in case some silly person put this *behind* the modules... */ last_mod = (uintptr_t)mod + sizeof(mboot_mod_t); } debug_print(NOTICE, "Module %d is at 0x%x:0x%x", i, module_start, module_end); if (last_mod < module_end) { last_mod = module_end; } } debug_print(NOTICE, "Moving kernel heap start to 0x%x", last_mod); kmalloc_startat(last_mod); } } paging_install(mboot_ptr->mem_upper + mboot_ptr->mem_lower); if (mboot_ptr->flags & (1 << 6)) { debug_print(NOTICE, "Parsing memory map."); mboot_memmap_t * mmap = (void *)mboot_ptr->mmap_addr; while ((uintptr_t)mmap < mboot_ptr->mmap_addr + mboot_ptr->mmap_length) { if (mmap->type == 2) { for (unsigned long long int i = 0; i < mmap->length; i += 0x1000) { if (mmap->base_addr + i > 0xFFFFFFFF) break; /* xxx */ debug_print(INFO, "Marking 0x%x", (uint32_t)(mmap->base_addr + i)); paging_mark_system((mmap->base_addr + i) & 0xFFFFF000); } } mmap = (mboot_memmap_t *) ((uintptr_t)mmap + mmap->size + sizeof(uintptr_t)); } } paging_finalize(); { char cmdline_[1024]; size_t len = strlen((char *)mboot_ptr->cmdline); memmove(cmdline_, (char *)mboot_ptr->cmdline, len + 1); /* Relocate the command line */ cmdline = (char *)kmalloc(len + 1); memcpy(cmdline, cmdline_, len + 1); } /* Memory management */ heap_install(); /* Kernel heap */ if (cmdline) { args_parse(cmdline); } vfs_install(); tasking_install(); /* Multi-tasking */ timer_install(); /* PIC driver */ fpu_install(); /* FPU/SSE magic */ syscalls_install(); /* Install the system calls */ shm_install(); /* Install shared memory */ modules_install(); /* Modules! */ DISABLE_EARLY_BOOT_LOG(); /* Load modules from bootloader */ debug_print(NOTICE, "%d modules to load", mboot_mods_count); for (unsigned int i = 0; i < mboot_ptr->mods_count; ++i ) { mboot_mod_t * mod = &mboot_mods[i]; uint32_t module_start = mod->mod_start; uint32_t module_end = mod->mod_end; size_t module_size = module_end - module_start; if (!module_quickcheck((void *)module_start)) { debug_print(NOTICE, "Loading ramdisk: 0x%x:0x%x", module_start, module_end); ramdisk_mount(module_start, module_size); } else { debug_print(NOTICE, "Loading a module: 0x%x:0x%x", module_start, module_end); module_data_t * mod_info = (module_data_t *)module_load_direct((void *)(module_start), module_size); if (mod_info) { debug_print(NOTICE, "Loaded: %s", mod_info->mod_info->name); } } } /* Map /dev to a device mapper */ map_vfs_directory("/dev"); if (args_present("root")) { vfs_mount_type("ext2", args_value("root"), "/"); } if (args_present("start")) { char * c = args_value("start"); if (!c) { debug_print(WARNING, "Expected an argument to kernel option `start`. Ignoring."); } else { debug_print(NOTICE, "Got start argument: %s", c); boot_arg = strdup(c); } } if (!fs_root) { debug_print(CRITICAL, "No root filesystem is mounted. Skipping init."); map_vfs_directory("/"); switch_task(0); } /* Prepare to run /bin/init */ char * argv[] = { "/bin/init", boot_arg, NULL }; int argc = 0; while (argv[argc]) { argc++; } system(argv[0], argc, argv); /* Run init */ return 0; }
k_main() // like main { k_clear_screen(); k_puts("Welcome to MoOS version 0.1 (" BUILDTAG ")\n"); k_puts("\n"); if (pci_is_available()) { k_puts(" Detected a PCI bus\n"); } else { k_puts(" No PCI bus detected\n"); } // Try to find PCI devices unsigned int i, j, k; for (i=0; i<256; i++) { for (j=0; j<32; j++) { for (k=0; k<8; k++) { unsigned int temp = pci_read_dword(i, j, k, 0); if ((temp & 0xffff) != 0xffff) { printk("PCI device on bus: %u, slot: %u, function: %u VendorId/DeviceId: %x\n", i, j, k, temp); } } } } // NE2000 code #define NS_DATAPORT 0x10 /* NatSemi-defined port window offset. */ #define NE_DATAPORT 0x10 /* NatSemi-defined port window offset. */ #define NS_RESET 0x1f /* Issue a read to reset, a write to clear. */ #define E8390_CMD 0x00 /* The command register (for all pages) */ #define E8390_STOP 0x01 /* Stop and reset the chip */ #define E8390_START 0x02 /* Start the chip, clear reset */ #define E8390_RREAD 0x08 /* Remote read */ #define E8390_NODMA 0x20 /* Remote DMA */ #define E8390_PAGE0 0x00 /* Select page chip registers */ #define E8390_PAGE1 0x40 /* using the two high-order bits */ #define E8390_PAGE2 0x80 #define E8390_PAGE3 0xC0 /* Page 3 is invalid on the real 8390. */ #define E8390_RXOFF 0x20 /* EN0_RXCR: Accept no packets */ #define E8390_TXOFF 0x02 /* EN0_TXCR: Transmitter off */ /* Page 0 register offsets. */ #define EN0_CLDALO 0x01 /* Low byte of current local dma addr RD */ #define EN0_STARTPG 0x01 /* Starting page of ring bfr WR */ #define EN0_CLDAHI 0x02 /* High byte of current local dma addr RD */ #define EN0_STOPPG 0x02 /* Ending page +1 of ring bfr WR */ #define EN0_BOUNDARY 0x03 /* Boundary page of ring bfr RD WR */ #define EN0_TSR 0x04 /* Transmit status reg RD */ #define EN0_TPSR 0x04 /* Transmit starting page WR */ #define EN0_NCR 0x05 /* Number of collision reg RD */ #define EN0_TCNTLO 0x05 /* Low byte of tx byte count WR */ #define EN0_FIFO 0x06 /* FIFO RD */ #define EN0_TCNTHI 0x06 /* High byte of tx byte count WR */ #define EN0_ISR 0x07 /* Interrupt status reg RD WR */ #define EN0_CRDALO 0x08 /* low byte of current remote dma address RD */ #define EN0_RSARLO 0x08 /* Remote start address reg 0 */ #define EN0_CRDAHI 0x09 /* high byte, current remote dma address RD */ #define EN0_RSARHI 0x09 /* Remote start address reg 1 */ #define EN0_RCNTLO 0x0a /* Remote byte count reg WR */ #define EN0_RCNTHI 0x0b /* Remote byte count reg WR */ #define EN0_RSR 0x0c /* rx status reg RD */ #define EN0_RXCR 0x0c /* RX configuration reg WR */ #define EN0_TXCR 0x0d /* TX configuration reg WR */ #define EN0_COUNTER0 0x0d /* Rcv alignment error counter RD */ #define EN0_DCFG 0x0e /* Data configuration reg WR */ #define EN0_COUNTER1 0x0e /* Rcv CRC error counter RD */ #define EN0_IMR 0x0f /* Interrupt mask reg WR */ #define EN0_COUNTER2 0x0f /* Rcv missed frame error counter RD */ unsigned char SA_prom[32]; struct {char value, offset; } program_seq[] = { {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/ {0x48, EN0_DCFG}, /* Set byte-wide (0x48) access. */ {0x00, EN0_RCNTLO}, /* Clear the count regs. */ {0x00, EN0_RCNTHI}, {0x00, EN0_IMR}, /* Mask completion irq. */ {0xFF, EN0_ISR}, {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */ {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */ {32, EN0_RCNTLO}, {0x00, EN0_RCNTHI}, {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */ {0x00, EN0_RSARHI}, {E8390_RREAD+E8390_START, E8390_CMD}, }; int wordlength = 2; /* Read the 16 bytes of station address prom, returning 1 for an eight-bit interface and 2 for a 16-bit interface. We must first initialize registers, similar to NS8390_init(eifdev, 0). We can't reliably read the SAPROM address without this. (I learned the hard way!). */ for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++) outportb(0x300 + program_seq[i].offset, program_seq[i].value); for(i = 0; i < 32 /*sizeof(SA_prom)*/; i+=2) { SA_prom[i] = inportb(0x300 + NE_DATAPORT); SA_prom[i+1] = inportb(0x300 + NE_DATAPORT); if (SA_prom[i] != SA_prom[i+1]) wordlength = 1; } printk("Station Address PROM 0:"); for(i = 0; i < sizeof(SA_prom)/2; i++) printk(" %2.2x", SA_prom[i]); printk("\nStation Address PROM %#2x:", i); for(; i < sizeof(SA_prom); i++) printk(" %2.2x", SA_prom[i]); printk("\n"); printk("NE200 wordlength = %u\n", wordlength); if (wordlength == 2) { /* We must set the 8390 for word mode, AND RESET IT. */ int tmp; outportb(0x300 + EN0_DCFG, 0x49); tmp = inportb(0x300 + NS_RESET); outportb(0x300 + NS_RESET, tmp); /* Un-double the SA_prom values. */ for (i = 0; i < 16; i++) SA_prom[i] = SA_prom[i+i]; } // Check for NE2000 on I/O address 0x300 printk("MAC of NE2000 @0x300: "); outportb(0x300 + E8390_CMD, E8390_NODMA + E8390_PAGE1); for (i = 1; i < 6; i++) printk("%2X:", inportb(0x300 + i)); printk("%2X\n"); // End of NE2000 code init_pics(0x20, 0x28); idt_install(); isrs_install(); irq_install(); keyboard_install(); asm volatile ("sti"); for(;;); }
void irq_init(void) { init_idt(); isr_install(); irq_install(); }
void kmain(void) { kernel_end = (uint64_t)heap_addr; kernel_heap_ptr = (uint8_t*)((uint64_t)&VMA + kernel_end + heap_size) ; UPD = (uint64_t*)((uint64_t)&VMA + kernel_end + 0x3000); KPD = (uint64_t*)((uint64_t)&VMA + kernel_end + 0x4000); PML4 = (uint64_t*)((uint64_t)&VMA + kernel_end); *(KPD + 511) = (kernel_end + 0x4000) | 3; map_mem(mboot_info); #if _GFX_ init_video(); #endif idt_install(); isr_install(); vmem_init(); serial.init(); extern void load_tss(void); load_tss(); extern uint64_t k_tss64_sp; *(uint64_t*)( (uint64_t)&VMA + (uint64_t)&k_tss64_sp ) = 0xFFFFFFFFC0008000; pit_set_freq(2000); // timer tick = 500 us pit_install(); irq_install(); extern void mouse_init(); //mouse_init(); extern void mouse_handler(void*); //irq_install_handler(12, mouse_handler); multiboot_module_t *mod = (multiboot_module_t*)(uint64_t)mboot_info->mods_addr; ramdev_private_t ramdev_private = (ramdev_private_t) { .ptr = (void*)((uint64_t)&VMA + mod->mod_start), .size = (uint32_t)(mod->mod_end - mod->mod_start), }; inode_t ramdisk_inode = (inode_t) { .name = "ramdisk", .type = FS_CHRDEV, .fs = &devfs, .dev = &ramdev, .p = &ramdev_private, }; vfs_create(&dev_root, "/", &ramdisk_inode); inode_t *rootfs = initramfs.load(&ramdisk_inode); vfs_mount_root(rootfs); irq_install_handler(1, kbd_handler); devman.init(); fsman.init(); #if _DBG_CON_ // We should disable debugging by this stage! serial.end(); #endif process_t *init = load_elf("/bin/init"); extern void spawn_init(process_t*); spawn_init(init); for(;;); }
void kmain(struct multiboot *mbp, u32 magic) { u32 initrd_location = *((u32*)mbp->mods_addr); //get the adress of initrd module u32 initrd_end = *(u32*)(mbp->mods_addr+4); placement_address = initrd_end; init_video_term(); puts("Welcome to chiffOS"); printk("\n"); videoram[1] = 2; videoram[3] = 4; videoram[5] = 6; videoram[7] = 8; videoram[9] = 10; videoram[11] = 12; videoram[13] = 14; videoram[15] = 12; videoram[17] = 10; videoram[19] = 8; videoram[21] = 6; videoram[23] = 4; videoram[25] = 2; videoram[27] = 6; videoram[29] = 10; videoram[31] = 14; printk("Initializing GDTs... "); gdt_install(); printk("[ok]\n"); printk("Initializing IDTs... "); idt_install(); printk("[ok]\n"); printk("Initializing ISRs and enabling interrupts... "); isrs_install(); irq_install(); printk("[ok]\n"); printk("\n"); printk("Initializing the PIT... "); timer_install(100); printk("[ok]\n"); printk("Initializing paging and the heap... "); _vmmngr_initialize(mbp); //get memory amount from grub printk("[ok]\n"); printk("Setting up the keyboard handler... "); _kbd_initialize(); printk("[ok]\n"); printk("Initializing initrd... "); fs_root = install_initrd(initrd_location); printk("[ok]\n"); printk("Initializing tasking... "); _task_initialize(); printk("[ok]\n"); _install_syscall_handler(); scan_pci_bus(0); ata_init_and_detect_drives(); mount_fat32(); fpu_install(); FAT_shell_newlib(); for(;;); }