void kernel_main(uint32_t r0, uint32_t r1, uint32_t *atags, uint32_t memory_kernel) { unsigned int memory_total; int init_process,idle_process; struct atag_info_t atag_info; uint32_t framebuffer_width=800,framebuffer_height=600; (void) r0; /* Ignore boot method */ /* Initialize Software Structures */ processes_init(); /* Detect Hardware */ atags_detect(atags,&atag_info); hardware_type=atag_info.hardware_type; /* Initialize Hardware */ /* Serial console is most important so do that first */ uart_init(); /* Enable Interrupts */ enable_interrupts(); /************************/ /* Boot message! */ /************************/ printk("\r\nBooting VMWos...\r\n"); /**************************/ /* Device Drivers */ /**************************/ /* Set up ACT LED */ led_init(); /* Set up timer */ timer_init(); /* Set up keyboard */ ps2_keyboard_init(); /* Enable the Framebuffer */ if (atag_info.framebuffer_x!=0) { framebuffer_width=atag_info.framebuffer_x; } if (atag_info.framebuffer_y!=0) { framebuffer_height=atag_info.framebuffer_y; } framebuffer_init(framebuffer_width,framebuffer_height,24); framebuffer_console_init(); /* Delay to allow time for serial port to settle */ /* So we can actually see the output on the terminal */ delay(0x3f0000); printk("\r\nWaiting for serial port to be ready (press any key)\r\n"); uart_getc(); uart_enable_interrupts(); /* Clear screen */ printk("\n\r\033[2J\n\r\n\r"); /* Print boot message */ printk("\033[0;41m \033[42m \033[44m \033[42m \033[44m \033[0m VMW OS\r\n"); printk(" \033[0;41m \033[42m \033[44m \033[42m \033[44m \033[0m Version 0.%d\r\n\r\n",VERSION); /* Print hardware version */ printk("Hardware version: %x ",r1); if (r1==0xc42) printk("(Raspberry Pi)"); else printk("(Unknown Hardware)"); printk("\r\n"); printk("Detected Model "); switch(hardware_type) { case RPI_MODEL_A: printk("A"); break; case RPI_MODEL_APLUS: printk("A+"); break; case RPI_MODEL_B: printk("B"); break; case RPI_MODEL_BPLUS: printk("B+"); break; case RPI_MODEL_B2: printk("B2"); break; case RPI_COMPUTE_NODE: printk("Compute Node"); break; default: printk("Unknown %x",hardware_type); break; } printk("\r\n"); /* Print ATAGS */ atags_dump(atags); printk("\r\n"); /* Get amount of RAM from ATAGs */ memory_total=atag_info.ramsize; /* Init memory subsystem */ memory_init(memory_total,memory_kernel); /* Init the MMU */ printk("Initializing MMU and caches\r\n"); //enable_mmu(0, memory_total); //l1_data_cache_clear(); //l1_data_cache_enable(); l1_instruction_cache_enable(); /* Memory Benchmark */ #if 1 { int i; uint32_t before,after; before=ticks_since_boot(); for(i=0;i<16;i++) { memset(benchmark,0,BENCH_SIZE); } after=ticks_since_boot(); printk("MEMSPEED: %d MB took %d ticks %dkB/s\r\n", 16, (after-before), div32(16*1024,(((after-before)*1000)/64))); } #endif /* Load the idle thread */ idle_process=load_process("idle",PROCESS_FROM_RAM, (char *)&idle_task,8,4096); init_process=load_process("shell",PROCESS_FROM_DISK, NULL,0,8192); load_process("printa",PROCESS_FROM_DISK, NULL,0,8192); load_process("printb",PROCESS_FROM_DISK, NULL,0,8192); /* Enter our "init" process*/ printk("\r\nEntering userspace by starting process %d!\r\n", init_process); process[idle_process].ready=1; process[init_process].ready=1; userspace_started=1; /* run init and restore stack as we won't return */ run_process(init_process,0x8000); /* we should never get here */ while(1) { /* Loop Forever */ /* Should probably execute a wfi instruction */ } }
void kernel_main(uint32_t r0, uint32_t r1, uint32_t *atags, uint32_t memory_kernel) { unsigned int memory_total; int init_process,idle_process; struct atag_info_t atag_info; uint32_t framebuffer_width=800,framebuffer_height=600; uint32_t temperature; (void) r0; /* Ignore boot method */ /* Initialize Software Structures */ processes_init(); /* Detect Hardware */ atags_detect(atags,&atag_info); hardware_type=atag_info.hardware_type; /* Initialize Hardware */ /* Serial console is most important so do that first */ uart_init(); /* Enable HW random number generator */ bcm2835_rng_init(); /* Enable Interrupts */ enable_interrupts(); /************************/ /* Boot message! */ /************************/ printk("\nBooting VMWos...\n"); /**************************/ /* Device Drivers */ /**************************/ /* Set up ACT LED */ led_init(); /* Set up timer */ timer_init(); /* Set up keyboard */ ps2_keyboard_init(); /* Enable the Framebuffer */ if (atag_info.framebuffer_x!=0) { framebuffer_width=atag_info.framebuffer_x; } if (atag_info.framebuffer_y!=0) { framebuffer_height=atag_info.framebuffer_y; } framebuffer_init(framebuffer_width,framebuffer_height,24); framebuffer_console_init(); /* Delay to allow time for serial port to settle */ /* So we can actually see the output on the terminal */ delay(0x3f0000); printk("\nWaiting for serial port to be ready (press any key)\n"); uart_getc(); uart_enable_interrupts(); /* Clear screen */ printk("\n\033[2J\n\n"); /* Print boot message */ printk("\033[0;41m \033[42m \033[44m \033[42m \033[44m \033[0m VMW OS\n"); printk(" \033[0;41m \033[42m \033[44m \033[42m \033[44m \033[0m Version 0.%d\n\n",VERSION); /* Print hardware version */ printk("Hardware version: %x ",r1); if (r1==0xc42) printk("(Raspberry Pi)"); else printk("(Unknown Hardware)"); printk("\n"); printk("Detected Model "); switch(hardware_type) { case RPI_MODEL_A: printk("A"); break; case RPI_MODEL_APLUS: printk("A+"); break; case RPI_MODEL_B: printk("B"); break; case RPI_MODEL_BPLUS: printk("B+"); break; case RPI_MODEL_B2: printk("B2"); break; case RPI_COMPUTE_NODE: printk("Compute Node"); break; default: printk("Unknown %x",hardware_type); break; } printk("\n"); /* Check temperature */ temperature=thermal_read(); printk("CPU Temperature: %dC, %dF\n", temperature/1000, ((temperature*9)/5000)+32); /* Print ATAGS */ atags_dump(atags); printk("\n"); /* Get amount of RAM from ATAGs */ memory_total=atag_info.ramsize; /* Init memory subsystem */ memory_init(memory_total,memory_kernel); /* Start HW Perf Counters */ arm1176_init_pmu(); #if 0 asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); // printk("Heisenbug!\n"); #endif /* Setup Memory Hierarchy */ #if 1 memset_benchmark(memory_total); #else /* Enable L1 i-cache */ printk("Enabling L1 icache\n"); enable_l1_dcache(); /* Enable branch predictor */ printk("Enabling branch predictor\n"); /* Enable L1 d-cache */ printk("Enabling MMU with 1:1 Virt/Phys page mapping\n"); enable_mmu(0,memory_total); printk("Enabling L1 dcache\n"); enable_l1_dcache(); #endif /* Init the file descriptor table */ fd_table_init(); /* Initialize the ramdisk */ ramdisk_init(initrd_image,sizeof(initrd_image)); /* Mount the ramdisk */ mount("/dev/ramdisk","/","romfs",0,NULL); /* Load the idle thread */ idle_process=load_process("idle",PROCESS_FROM_RAM, (char *)&idle_task,8,4096); init_process=load_process("shell",PROCESS_FROM_DISK, NULL,0,8192); load_process("printa",PROCESS_FROM_DISK, NULL,0,8192); load_process("printb",PROCESS_FROM_DISK, NULL,0,8192); /* Enter our "init" process*/ printk("\nEntering userspace by starting process %d!\n", init_process); process[idle_process].ready=1; process[init_process].ready=1; userspace_started=1; /* run init and restore stack as we won't return */ run_process(init_process,0x8000); /* we should never get here */ while(1) { /* Loop Forever */ /* Should probably execute a wfi instruction */ } }