Exemple #1
0
int arch_early_init()
{
    int rc;

    rc = x86_serial_init();
    if (rc)
        return rc;

    rc = textmode_init();
    if (rc)
        return rc;

    rc = gdt_init();
    if (rc)
        return rc;

    rc = idt_init();
    if (rc)
        return rc;

    rc = exceptions_init();
    if (rc)
        return rc;

    rc = irq_init();
    if (rc)
        return rc;

    rc = pit_init();
    if (rc)
        return rc;

    return 0;
}
Exemple #2
0
void init(void) 
{
   exceptions_init();
   hide_cursor();
   vga_setcolor(0x07);
   pic_init();
   idt_write_table();
   kb_init();         //Init keyboard driver
   floppy_init();
   lex_init();
   printf("\nSystem booted.\n\n");
}
Exemple #3
0
int main(int argc, char**argv)
{

    /****************************** Inicializace ******************************/

    exceptions_init();
    if(argc!=2) {
        fprintf( stderr, "Chybny zpusob volani interpretru!\nPouziti: %s program.ifj\n\n", argv[0] );
        exit( 99 );
    }

    FILE* f=fopen(argv[1],"r");
    if(f==NULL) {
        fprintf( stderr, "Program k interpretaci (%s) se nepodarilo otevrit!\n\n", argv[1] );
        exit( 99 );
    }

    Scanner s;
    SyntaxContext syntaxcontext;
    Function mainFunction;

    int exitVal = 0;

    try {
        try {

            initScanner(&s,f);
            initDefaultSyntaxContext(&syntaxcontext);

            /***************************** Překlad do AST *****************************/
            parseProgram(&s, &syntaxcontext, &mainFunction);
        }
        catch {
            on(ScannerError, e) {
                scannerErrorPrint(*e);
                fclose( f );
                exitVal = 1;
                rethrow();
            }
            on(SyntaxError, e) {
                syntaxErrorPrint(*e);
                fclose( f );
                exitVal = 2;
                rethrow();
            }
            on(UnexpectedToken, e) {
                UnexpectedTokenPrint(*e);
                fclose( f );
                exitVal = 2;
                rethrow();
            }
Exemple #4
0
// main C function, called from boot.S
void kernel_main(uint32_t r0, uint32_t id, const Atag *atag) {
    UNUSED(r0); // always 0
    UNUSED(id); // 0xC42 for Raspberry Pi

    arch_info_init(atag);
    exceptions_init();

    kprintf("\ncalling SVC\n");
    // calling svc from within svc clobbers the LR register, tell gcc about it
    asm volatile ("svc #0" ::: "lr");

    kprintf("\nundefine instruction 0xee011f51\n");
    asm volatile (".word 0xee011f51");
    
    kprintf("\nunaligned access *(0x1)\n");
    *(volatile uint32_t *)0x1;

    kprintf("\nbreakpoint\n");
    asm volatile ("bkpt");
    
    kprintf("\nGoodbye\n");
}
Exemple #5
0
/**
 * Entry point called from boot.S for bootstrap processor.
 */
void arch_init(uint32_t     board_id,
               struct atag *atag_base,
               lvaddr_t     elf_file,
               lvaddr_t     alloc_top)
{
    //
    // Assumptions:
    //
    // - MMU and caches are enabled. No lockdowns in caches or TLB.
    // - Kernel has own section starting at KERNEL_OFFSET.
    // - Kernel section includes the highmem relocated exception vector table.
    //


    struct atag * ae = NULL;

    exceptions_init();

    ae = atag_find(atag_base, ATAG_MEM);
    paging_map_memory(0, ae->u.mem.start, ae->u.mem.bytes);

    ae = atag_find(atag_base, ATAG_CMDLINE);
    if (ae != NULL)
    {
        parse_commandline(ae->u.cmdline.cmdline, cmdargs);
        tick_hz = CONSTRAIN(tick_hz, 10, 1000);
    }

    if (board_id == hal_get_board_id())
    {
        errval_t errval;

        serial_console_init(true);

        // do not remove/change this printf: needed by regression harness
        printf("Barrelfish CPU driver starting on ARMv5 Board id 0x%08"PRIx32"\n",
               board_id);
        printf("The address of paging_map_kernel_section is %p\n", 
               paging_map_kernel_section);
        errval = serial_debug_init();
        if (err_is_fail(errval))
        {
            printf("Failed to initialize debug port: %d", serial_debug_port);
        }

        debug(SUBSYS_STARTUP, "alloc_top %08"PRIxLVADDR" %08"PRIxLVADDR"\n",
               alloc_top, alloc_top - KERNEL_OFFSET);
        debug(SUBSYS_STARTUP, "elf_file %08"PRIxLVADDR"\n", elf_file);

        my_core_id = hal_get_cpu_id();
        extern struct kcb bspkcb;
        memset(&bspkcb, 0, sizeof(bspkcb));
        kcb_current = &bspkcb;
        
        pic_init();
        pit_init(tick_hz);
        tsc_init();

        ae = atag_find(atag_base, ATAG_MEM);
                
        // Add unused physical memory to memory map

        phys_mmap_t phys_mmap;

        // Kernel effectively consumes [0...alloc_top]
        // Add region above alloc_top with care to skip exception vector
        // page.
        if (alloc_top < ETABLE_ADDR) {
            phys_mmap_add(&phys_mmap,
                          alloc_top - KERNEL_OFFSET,
                          ETABLE_ADDR - KERNEL_OFFSET);
        }

        phys_mmap_add(&phys_mmap,
                      ETABLE_ADDR - KERNEL_OFFSET + BASE_PAGE_SIZE,
                      ae->u.mem.start + ae->u.mem.bytes);

        ae = atag_find(atag_base, ATAG_VIDEOLFB);
        if (NULL != ae)
        {
            // Remove frame buffer (if present).
            phys_mmap_remove(&phys_mmap,
                             ae->u.videolfb.lfb_base,
                             ae->u.videolfb.lfb_base + ae->u.videolfb.lfb_size);
            assert(!"Not supported");
        }

        ae = atag_find(atag_base, ATAG_INITRD2);
        if (NULL != ae)
        {
            phys_mmap_remove(&phys_mmap,
                             ae->u.initrd2.start,
                             ae->u.initrd2.start + ae->u.initrd2.bytes);

            arm_kernel_startup(&phys_mmap,
                               ae->u.initrd2.start,
                               ae->u.initrd2.bytes);
        }
        else {
            panic("initrd not found\n");
        }
    }
    else {
        panic("Mis-matched board id: [current %"PRIu32", kernel %"PRIu32"]",
              board_id, hal_get_board_id());
    }
}
Exemple #6
0
int main(void)
{
	int res;
	udelay(2000000);
	debug_init();
	printf("\n\nBootOS Stage 2 starting.\n");
	printf("Waiting for thread 1...\n");
	while(!_thread1_active);
	printf("Thread 1 is alive, all systems go.\n");

	exceptions_init();
	lv2_cleanup();
	mm_init();

#ifdef USE_NETWORK
	net_init();

	gstate = STATE_START;
	while(1) {
		net_poll();
		if(sequence())
			break;
	}
#endif
#ifdef AUTO_HDD
	static FATFS fatfs;
	DSTATUS stat;

	stat = disk_initialize(0);
	if (stat & ~STA_PROTECT)
		fatal("disk_initialize() failed");

	printf("Mounting filesystem...\n");
	res = f_mount(0, &fatfs);
	if (res != FR_OK)
		fatal("f_mount() failed");

	printf("Reading kboot.conf...\n");
	res = readfile("/kboot.conf", conf_buf, MAX_KBOOTCONF_SIZE-1);
	if (res <= 0) {
		printf("Could not read kboot.conf (%d), panicking\n", res);
		lv1_panic(0);
	}
	conf_buf[res] = 0;
	kbootconf_parse();

	if (conf.num_kernels == 0) {
		printf("No kernels found in configuration file. Panicing...\n");
		lv1_panic(0);
	}

	boot_entry = conf.default_idx;

	printf("Starting to boot '%s'\n", conf.kernels[boot_entry].label);
	printf("Loading kernel (%s)...\n", conf.kernels[boot_entry].kernel);

	kernel_buf = mm_highmem_freestart();
	res = readfile(conf.kernels[boot_entry].kernel, kernel_buf, mm_highmem_freesize());
	if (res <= 0) {
		printf("Could not read kernel (%d), panicking\n", res);
		lv1_panic(0);
	}
	printf("Kernel size: %d\n", res);

	if (kernel_load(kernel_buf, res) != 0) {
		printf("Failed to load kernel. Rebooting...\n");
		lv1_panic(1);
	}

	if (conf.kernels[boot_entry].initrd && conf.kernels[boot_entry].initrd[0]) {
		initrd_buf = mm_highmem_freestart();
		res = readfile(conf.kernels[boot_entry].initrd, initrd_buf, mm_highmem_freesize());
		if (res <= 0) {
			printf("Could not read initrd (%d), panicking\n", res);
			lv1_panic(0);
		}
		printf("Initrd size: %d\n", res);
		mm_highmem_reserve(res);
		kernel_set_initrd(initrd_buf, res);
	}

	kernel_build_cmdline(conf.kernels[boot_entry].parameters, conf.kernels[boot_entry].root);

	f_mount(0, NULL);
	disk_shutdown(0);
	mm_shutdown();
	kernel_launch();

#endif
	printf("Loading embedded kernel...\n");
	kernel_buf = mm_highmem_freestart();
	printf("Decompressing kernel to %lX...\n", (u64) kernel_buf);
	res = unzpipe (kernel_buf, __vmlinux, &kernel_sz);
	if (res)
	{
		printf("Cannot decompress kernel, error %d.\n", res);
		lv1_panic(1);
	}
	printf("Kernel size: %ld\n", kernel_sz);
	if (kernel_load(kernel_buf, kernel_sz) != 0)
	{
		printf("Failed to load embedded kernel. Rebooting...\n");
		lv1_panic(1);
	}
	kernel_build_cmdline("video=ps3fb:mode:0 panic=5", "/dev/sda1");
	shutdown_and_launch();

	printf("End of main() reached! Rebooting...\n");
	lv1_panic(1);
	return 0;
}