// Kernel entry point void _main(struct multiboot *mboot_ptr, uint32_t initial_stack) { // Clear screen to get rid of boot messages. kclear(); // Initialise all the ISRs and segmentation. init_dt(); // Some print tests. kprintf("Boot successfull\n"); int num = 36; printf("Integer \"num\" = %i.\n", num); printf("Initial kernel stack is: %i\n", initial_stack); // Test the interrupts. printf("Testing interrupts\n"); test_interrupts(); // Initialize interrupts. printf("Initializing Interrupts\n"); init_interrupts(); printf("The kernel has booted\n"); // Start the timer. init_timer(50); for(;;) { } }
/*---------------------------------------------------------------------------- MAIN function *----------------------------------------------------------------------------*/ int main(void){ //Initialise LEDs, buttons and interrupts init_RGB(); init_switches(); init_interrupts(); done = 0; while(1){ switch(done){ //Toggle corresponding bits depending on which button was pressed case 1: toggle_r(); break; case 2: toggle_g(); break; case 3: toggle_b(); break; case 4: toggle_all(); break; } done = 0; delay(1); if (done == 0) //if done == 0, processor goes to sleep __wfi(); } }
/** * @brief: Handles all the initilization of the OS * @param: stack_start the start of free memory */ void init(void* memory_start) { #ifdef INIT_DEBUG rtx_dbug_outs("Initilizating memory..."); #endif init_memory(memory_start); #ifdef INIT_DEBUG rtx_dbug_outs("done\r\nInitilizating processes..."); #endif init_processes(memory_head); #ifdef INIT_DEBUG rtx_dbug_outs(" done\r\nInitializing priority queues..."); #endif init_priority_queues(); #ifdef INIT_DEBUG rtx_dbug_outs(" done\r\nInitilizating interrupts..."); #endif init_interrupts(); g_profiler.timer = &timer; #ifdef INIT_DEBUG rtx_dbug_outs(" done\r\n"); #endif }
void init_n64() { init_interrupts(); init_video(); set_video(); dfs_init(DFS_DEFAULT_LOCATION); controller_init(); timer_init(); }
void init(void){ init_pin(); init_clock(); init_uart(); init_ui(); init_timer(); init_oc(); init_motor(); InitUSB(); // initialize the USB registers and serial interface engine init_interrupts(); }
int __low_level_init(void) #endif { init_exceptions(); init_hmatrix(); init_interrupts(); // EWAVR32: Request initialization of data segments. // GCC: Don't-care value. return 1; }
void main (void) { call_at_timeout (on_timeout); call_at_up_button (on_up_button); call_at_down_button (on_down_button); init (); init_interrupts (); print_time_config (); }
/* initialize console hardware */ void init_n64(void) { /* enable interrupts (on the CPU) */ init_interrupts(); /* Initialize peripherals */ display_init( RESOLUTION_320x240, DEPTH_32_BPP, 2, GAMMA_NONE, ANTIALIAS_RESAMPLE ); register_VI_handler(vblCallback); controller_init(); }
int main(void) { init_IO(); init_interrupts(); oledInit(); _delay_ms(200); oledSetCursor(cursX, cursY); putChar(66,1); advanceCursor(6); compose(); initMenu(); while(1) { static uint16_t butCounter = 0; if (butCounter++ > 65000) { //FIXME: Proper button debounce and handling butCounter = 0; uint8_t readButtons = BUT_PIN; if (~readButtons & BUT_LEFT) { ++goLeft; } if (~readButtons & BUT_SEL) { ++goSel; } } if (knobChange) { if (knobChange > 0) { //menuUp(); knobLeft(); } else { //menuDn(); knobRight(); } knobChange = 0; } if (goSel) { //Lookup and execute action doSelect[optionIndex](); goSel = 0; } else if (goLeft) { doBack(); goLeft = 0; } } }
/* Initialize board. */ static void board_init(void) { init_pmu(); init_timers(); init_interrupts(); init_trng(); init_runlevel(PERMISSION_MEDIUM); /* TODO(crosbug.com/p/49959): For now, leave flash WP unlocked */ GREG32(RBOX, EC_WP_L) = 1; /* Indication that firmware is running, for debug purposes. */ GREG32(PMU, PWRDN_SCRATCH16) = 0xCAFECAFE; }
kmain() { /* Inicializa */ init_interrupts(); init_video(); init_stdio(); keyboard_queue_initialize(); set_language(ENGLISH); set_terminal(0); loop(); }
void kernel_main() { init_process(); init_dispatcher(); init_ipc(); init_interrupts(); init_null_process(); init_timer(); init_com(); init_keyb(); init_ne2k(); init_shell(); while (1); }
void kernel_main(char boot_disk_id, void *memory_map, BootModuleInfo *boot_module_list) { init_memory_manager(memory_map); init_tty(); clear(); init_interrupts(); init_pci(); int arr[10000]; textcolor(2); printf("Structure size: %d\n",sizeof(arr)); printf("kernel_page_dir = 0x%x\n", kernel_page_dir); printf("memory_size = %d MB\n", memory_size / 1024 / 1024); printf("get_page_info(kernel_page_dir, 0xB8000) = 0x%x\n", get_page_info(kernel_page_dir, (void*)0xB8000)); }
void test_isr_2() { test_reset(); check_sum = 0; test_isr_2_check_sum = 0; init_interrupts(); kprintf("=== test_isr_2 === \n"); kprintf("This test will take a while.\n\n\n"); kprintf("Process 1: A\n"); kprintf("Process 2: Z\n"); create_process(test_isr_2_process_1, 5, 0, "Process 1"); create_process(test_isr_2_process_2, 5, 0, "Process 2"); resign(); if (check_sum == 0 || test_isr_2_check_sum == 0) test_failed(71); }
void main(uint32_t magic, const multiboot_info_t *mbi) { vga_clear(); check_multiboot(magic, mbi); init_memory(mbi); //----- struct kmem_cache *cache = kmem_cache_create("test", 1024, 1024); void *obj1 = kmem_cache_alloc(cache, KMEM_ZEROED); void *obj2 = kmem_cache_alloc(cache, KMEM_ZEROED); void *obj3 = kmem_cache_alloc(cache, KMEM_ZEROED); void *obj4 = kmem_cache_alloc(cache, KMEM_ZEROED); void *obj5 = kmem_cache_alloc(cache, KMEM_ZEROED); printf("obj1: 0x%p\n", obj1); printf("obj2: 0x%p\n", obj2); printf("obj3: 0x%p\n", obj3); printf("obj4: 0x%p\n", obj4); printf("obj5: 0x%p\n", obj5); kmem_cache_free(cache, obj2); obj2 = kmem_cache_alloc(cache, KMEM_DEFAULT); printf("obj2: 0x%p\n", obj2); kmem_cache_free(cache, obj1); kmem_cache_free(cache, obj2); kmem_cache_free(cache, obj3); kmem_cache_free(cache, obj4); kmem_cache_free(cache, obj5); kmem_cache_print_info(cache); kmem_cache_destroy(cache); init_interrupts(); __asm__ __volatile__("int $0x3"); __asm__ __volatile__("int $0x4"); while (1) { } ASSERT_MSG(0, "control reached end of main"); }
void Init_video(char* argv[]) { TOMREGS->vmode = RGB16|CSYNC|BGEN|PWIDTH4|VIDEN; // Setup the type of diplay we wish to work with. init_interrupts(); // Initialize the basic interupts. init_display_driver(); // Initalize the display driver. display *d = new_display(0); // Create a pointer for the display so we can reference it later. d-> x = 0; // set the x position of the display (in relation to the top-left corner). d-> y = 0; // set the y position of the display (in relation to the top-left corner). show_display(d); //Turn on the display, so we can actually see it on the screen. // Sadly, the default resolution is not 320x240 but something like 352x256 // There must be way to set it to 320X240, JagDoom is using 256x240 after all }
static int __init init(void) { int err; if (paravirt_enabled()) { printk("lguest is afraid of being a guest\n"); return -EPERM; } err = map_switcher(); if (err) goto out; err = init_pagetables(switcher_page, SHARED_SWITCHER_PAGES); if (err) goto unmap; err = init_interrupts(); if (err) goto free_pgtables; err = lguest_device_init(); if (err) goto free_interrupts; lguest_arch_host_init(); return 0; free_interrupts: free_interrupts(); free_pgtables: free_pagetables(); unmap: unmap_switcher(); out: return err; }
int main() { /* const extern u32 _KERNEL_START[],_KERNEL_END[]; const extern u32 K_CODE_SEL[], K_DATA_SEL[]; const extern u32 _KERNEL_TEXT_START[],_KERNEL_TEXT_END[]; const extern u32 _KERNEL_DATA_START[],_KERNEL_DATA_END[]; const extern u32 _KERNEL_BSS_START[],_KERNEL_BSS_END[]; */ tty_cls(); banner(); /*if(TEST_BIT(K_MULTIBOOT_INFO->flags,MBI_FLAGS_MMAP)){ kprintf("MMAP Present: 0x%x\n",K_MULTIBOOT_INFO->mmap_addr); memory_map_t *mmap; for(mmap=(memory_map_t *)K_MULTIBOOT_INFO->mmap_addr; (u32)mmap<K_MULTIBOOT_INFO->mmap_addr + K_MULTIBOOT_INFO->mmap_length; mmap=(memory_map_t *)((u32)mmap+mmap->size+sizeof(mmap->size))){ kprintf("[%d] addr=0x%x-0x%x\n",mmap->type,mmap->base_addr_low,(mmap->base_addr_low+mmap->length_low)); } }*/ kprintf(" > Initialising system services...\n"); init_interrupts(); init_paging(); init_heap(); set_cpu_caps(); init_pic(); init_timer(); init_process(); kprintf(" > Enabling kernel preemption...\n"); enable_kernel_preempt(); enable_ints(); kprintf(" > Spawning core process...\n"); create_process("core",NULL,&core); /* We may get to here for a very short amount of time while we enable preemption */ while(1); }
/*H:000 * Welcome to the Host! * * By this point your brain has been tickled by the Guest code and numbed by * the Launcher code; prepare for it to be stretched by the Host code. This is * the heart. Let's begin at the initialization routine for the Host's lg * module. */ static int __init init(void) { int err; /* Lguest can't run under Xen, VMI or itself. It does Tricky Stuff. */ if (paravirt_enabled()) { printk("lguest is afraid of being a guest\n"); return -EPERM; } /* First we put the Switcher up in very high virtual memory. */ err = map_switcher(); if (err) goto out; /* Now we set up the pagetable implementation for the Guests. */ err = init_pagetables(switcher_page, SHARED_SWITCHER_PAGES); if (err) goto unmap; /* We might need to reserve an interrupt vector. */ err = init_interrupts(); if (err) goto free_pgtables; /* /dev/lguest needs to be registered. */ err = lguest_device_init(); if (err) goto free_interrupts; /* Finally we do some architecture-specific setup. */ lguest_arch_host_init(); /* All good! */ return 0; free_interrupts: free_interrupts(); free_pgtables: free_pagetables(); unmap: unmap_switcher(); out: return err; }
void startup(unsigned long mboot_magic, multiboot_info *mboot_info) { unsigned short *video = (unsigned short *)0xb8000; unsigned char *str = "hello\r\n"; unsigned char c; struct video_ v; init_gdtr(); init(&v); puts(&v,str); if(mboot_magic != MULTI_BOOTLOADER_MAGIC) { printf(&v,"Error: Invalid magic number"); return; } printf(&v,"lower=0x%x[KB], upper=0x%x[KB], TotalMemory=%d[MB]\n\n", mboot_info->mem_lower, mboot_info->mem_upper, (mboot_info->mem_lower + mboot_info->mem_upper + 1024)/1024); printf(&v, "MemoryMap[B]:\n"); init_memory((mboot_info->mem_lower + mboot_info->mem_upper + 1024)*1024); memory_map *mmap; for(mmap = (memory_map *) mboot_info->mmap_addr; (unsigned) mmap < (mboot_info->mmap_addr + mboot_info->mmap_length); mmap++) { printf(&v,"base_addr=0x%x%x, length=0x%x%x, type=%d\n", mmap->base_addr_high, mmap->base_addr_low, mmap->length_high, mmap->length_low, mmap->type); if(mmap->type == 1) { init_freed_memory_region((mmap->base_addr_high<<32)+mmap->base_addr_low, (mmap->length_high<<32)+mmap->length_low); } } init_interrupts(); puts(&v, "end\n"); while(1) { hlt(); } }
void kernel_main() { init_process(); init_dispatcher(); init_ipc(); init_interrupts(); init_null_process(); init_timer(); #if VGA_MODE_ENABLED init_vga_mode(); #endif init_com(); init_keyb(); clear_kernel_window(); init_ne_driver(); init_em(); init_shell(); while (1); }
/* This is the entry-point for the game! */ void c_start(void) { // Initialize video, interrupt, timer, and keyboard subsystems init_video(); init_interrupts(); init_timer(); init_keyboard(); // Initialize game state init_player(); init_guns(); win = 0; draw_world(); draw_player(); enable_interrupts(); mainloop(); }
void init(void) { MAMCR = 0x02; //Memory Acceleration enabled MAMTIM = 0x04; VPBDIV = 0x01; //0x01: peripheral frequency == cpu frequency, 0x00: per. freq. = crystal freq. pll_init(); pll_feed(); init_ports(); #ifdef MATLAB UART_Matlab_Initialize(57600); #else UARTInitialize(57600); //debug / command #endif UART1Initialize(57600); //57600 Servo / GPS, 38400 "indoor GPS" init_spi(); init_spi1(); init_timer0(); // I2CInit(I2CMASTER); PWM_Init(); ADCInit(ADC_CLK); init_interrupts(); }
/*H:000 * Welcome to the Host! * * By this point your brain has been tickled by the Guest code and numbed by * the Launcher code; prepare for it to be stretched by the Host code. This is * the heart. Let's begin at the initialization routine for the Host's lg * module. */ static int __init init(void) { int err; /* Lguest can't run under Xen, VMI or itself. It does Tricky Stuff. */ if (get_kernel_rpl() != 0) { printk("lguest is afraid of being a guest\n"); return -EPERM; } /* First we put the Switcher up in very high virtual memory. */ err = map_switcher(); if (err) goto out; /* We might need to reserve an interrupt vector. */ err = init_interrupts(); if (err) goto unmap; /* /dev/lguest needs to be registered. */ err = lguest_device_init(); if (err) goto free_interrupts; /* Finally we do some architecture-specific setup. */ lguest_arch_host_init(); /* All good! */ return 0; free_interrupts: free_interrupts(); unmap: unmap_switcher(); out: return err; }
void system_start (void) { BOOT_MSG (VERSION_STRING); BOOT_MSG (COPYRIGHT_STRING); BOOT_MSG ("----"); init_interrupts(); init_switching(); /* init_memory (); */ /* Build some processes and hook up a simple scheduler */ start_tasktest (); /* Turn on interrupts and everything will begin */ __asm__("sti"); }
/* This is the entry-point for the game! */ void c_start(void) { /* Initialize our interrupt vector. */ init_interrupts(); /* Initialize peripherals. */ init_keyboard(); /* Initialize timers. */ init_timer(); display_background(); game_started = 0; game_lost = 0; /* After setting up the game, we can enable interrupts again so the game * can run as expected. */ enable_interrupts(); /* Loop forever, so that we don't fall back into the bootloader code. */ while (1) { } }
void test_isr_1() { MEM_ADDR screen_offset_for_boot_proc = 0xb8000 + 4 * 160 + 2 * 11; volatile int flag; test_reset(); check_sum = 0; init_interrupts(); DISABLE_INTR(flag); init_idt_entry(TIMER_IRQ, timer_isr); kprintf("=== test_isr_1 === \n"); kprintf("This test will take a while.\n\n"); kprintf("Timer ISR: A\n"); kprintf("Boot proc: Z\n"); ENABLE_INTR(flag); int i; for (i = 1; i < 700000; i++) poke_b(screen_offset_for_boot_proc, peek_b(screen_offset_for_boot_proc) + 1); if (check_sum == 0) test_failed(70); }
void test_isr_3 () { test_reset(); check_sum = 0; int check_2 = 0; kprintf("=== test_isr_3 === \n"); kprintf("This test will take a while.\n\n"); init_interrupts(); create_process(isr_process, 5, 0, "ISR process"); resign(); int i; int j = 0; unsigned char* screen_base; screen_base = (unsigned char*) 0xb8000 + 7 * 80 * 2; kprintf("\n\nBoot process:\n"); kprintf("ABCDEF"); PROCESS isr_pro = find_process_by_name("ISR process"); for (i = 0; i < 600000; i++) { if (isr_pro->state == STATE_INTR_BLOCKED) check_2++; *(screen_base + j * 2) = *(screen_base + j * 2) + 1; j++; if (j == 6) j = 0; } if (check_2 == 0) test_failed(72); if (check_sum <= 1) test_failed(73); }
static void init_spi(void) { #if defined(WL_SPI) int i; #endif #if defined(AT45DBX_SPI) static const gpio_map_t AT45DBX_SPI_GPIO_MAP = { { AT45DBX_SPI_SCK_PIN, AT45DBX_SPI_SCK_FUNCTION }, { AT45DBX_SPI_MISO_PIN, AT45DBX_SPI_MISO_FUNCTION }, { AT45DBX_SPI_MOSI_PIN, AT45DBX_SPI_MOSI_FUNCTION }, { AT45DBX_SPI_NPCS2_PIN, AT45DBX_SPI_NPCS2_FUNCTION }, }; #endif #if defined(WL_SPI) const gpio_map_t WL_SPI_GPIO_MAP = { #if defined(WL_SPI_NPCS0) WL_SPI_NPCS0, #endif WL_SPI_NPCS, WL_SPI_MISO, WL_SPI_MOSI, WL_SPI_SCK }; #endif #if defined(WL_SPI) || defined(AT45DBX_SPI) spi_options_t spiOptions = { .modfdis = 1 /* only param used by spi_initMaster() */ }; #endif #if defined(AT45DBX_SPI) gpio_enable_module(AT45DBX_SPI_GPIO_MAP, sizeof(AT45DBX_SPI_GPIO_MAP) / sizeof(AT45DBX_SPI_GPIO_MAP[0])); spi_initMaster(AT45DBX_SPI, &spiOptions); spi_selectionMode(AT45DBX_SPI, 0, 0, 0); #endif #if defined(WL_SPI) /* same pins might be initialized twice here */ gpio_enable_module(WL_SPI_GPIO_MAP, sizeof(WL_SPI_GPIO_MAP) / sizeof(WL_SPI_GPIO_MAP[0])); for (i = 0; i < sizeof(WL_SPI_GPIO_MAP)/sizeof(WL_SPI_GPIO_MAP[0]); i++) gpio_enable_pin_pull_up(WL_SPI_GPIO_MAP[i].pin); /* same SPI controller might be initialized again */ spi_initMaster(&WL_SPI, &spiOptions); spi_selectionMode(&WL_SPI, 0, 0, 0); #endif #if defined(AT45DBX_SPI) spi_enable(AT45DBX_SPI); /* put up flash reset pin */ gpio_set_gpio_pin(AT45DBX_CHIP_RESET); #endif #if defined(WL_SPI) spi_enable(&WL_SPI); #endif } static void init_rs232(void) { #ifndef NO_SERIAL #if defined(BOARD_RS232_0) const gpio_map_t BOARD_RS232_0_GPIO_MAP = { BOARD_RS232_0_TX, BOARD_RS232_0_RX, #if defined(BOARD_RS232_0_RTS) && defined (BOARD_RS232_0_CTS) BOARD_RS232_0_RTS, BOARD_RS232_0_CTS #endif }; #endif #if defined(BOARD_RS232_1) const gpio_map_t BOARD_RS232_1_GPIO_MAP = { BOARD_RS232_1_TX, BOARD_RS232_1_RX #if defined(BOARD_RS232_1_RTS) && defined (BOARD_RS232_1_CTS) BOARD_RS232_1_RTS, BOARD_RS232_1_CTS #endif }; #endif #if defined(BOARD_RS232_0) gpio_enable_module(BOARD_RS232_0_GPIO_MAP, sizeof(BOARD_RS232_0_GPIO_MAP) / sizeof(BOARD_RS232_0_GPIO_MAP[0])); #endif #if defined(BOARD_RS232_1) gpio_enable_module(BOARD_RS232_1_GPIO_MAP, sizeof(BOARD_RS232_1_GPIO_MAP) / sizeof(BOARD_RS232_1_GPIO_MAP[0])); #endif #endif /* NO_SERIAL */ } static void init_printk(void) { #ifndef NO_SERIAL #if defined(CONFIG_CONSOLE_PORT) const usart_options_t usart_options = { .baudrate = 57600, .charlength = 8, .paritytype = USART_NO_PARITY, .stopbits = USART_1_STOPBIT, .channelmode = USART_NORMAL_CHMODE }; usart_init_rs232(&CONFIG_CONSOLE_PORT, &usart_options, FPBA_HZ); #endif #endif /* NO_SERIAL */ } void board_init(void) { init_exceptions(); init_hmatrix(); init_sys_clocks(); init_interrupts(); init_rs232(); init_printk(); #ifdef WITH_SDRAM sdramc_init(FHSB_HZ); #endif init_spi(); }
/* This is the entry-point for the game! */ void c_start(void) { /* TODO: You will need to initialize various subsystems here. This * would include the interrupt handling mechanism, and the various * systems that use interrupts. Once this is done, you can call * enable_interrupts() to start interrupt handling, and go on to * do whatever else you decide to do! */ seed_rand_with_time(); init_interrupts(); init_keyboard(); init_timer(); enable_interrupts(); int board[BOARD_SIZE][BOARD_SIZE] = { }; animation_descriptor descriptor = { }; initialize(board); int high_score = current_score(board); init_video(high_score); draw_board(board); /* Loop forever, so that we don't fall back into the bootloader code. */ while (1) { if (!isemptyqueue()) { key k = dequeue(); if (k == enter_key) { for (int *b = *board; b < *board + BOARD_SIZE * BOARD_SIZE; b++) *b = 0; initialize(board); init_video(high_score); draw_board(board); continue; } else { shift_direction direction = key_to_direction(k); // Setup animation copy_board(board, descriptor.board); descriptor.direction = direction; // Only add a box if the pieces actually move if (shift(board, direction, descriptor.offsets)) { add_random_box(board); int score = current_score(board); if (score > high_score) high_score = score; init_video(high_score); } } int num_frames = frame_count(descriptor.direction); int incr = get_axis(descriptor.direction) == horizontal_axis ? 12 : 2; int frame = 0; while (frame <= num_frames) { draw_board_frame(descriptor, frame); sleep(30); if (frame == num_frames) break; else frame = min(frame + incr, num_frames); } draw_board(board); if (!move_available(board)) { draw_failure_message(); } } } }