Ejemplo n.º 1
0
int main()
{
    char input_line[256];
    int got;

    console_init(init_vga(VGA_MODE_640x480), 640, 480);
    console_set_colors(WHITE, BLACK);
    console_puts("\n !\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_`{|}~\n");
    console_puts(" ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
    console_puts(" abcdefghijklmnopqrstuvwxyz\n");
    console_puts(" AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\n");
    console_puts(" The quick brown fox jumped over the lazy dog.\n");
    console_set_colors(BLACK, WHITE);
    console_puts(" Inverse text\n");
    console_set_colors(WHITE, BLACK);
    while (1)
    {
        console_puts("> ");
        got = console_read_line(input_line, sizeof(input_line));
        input_line[got] = '\0';
        printf("%s\n", input_line);
    }

    return 0;
}
Ejemplo n.º 2
0
/*********************************************************
 * Dump information about the blocks of memory. What
 * starts and finishes where and available/reserved
 ********************************************************/
void k_dump_memory_blocks(multiboot_info_t *mbd)
{
	multiboot_memory_map_t* mmap = (multiboot_memory_map_t*)mbd->mmap_addr;

	// While we're pointing to a mem map struct within the supplied range...
	while((uint32_t)mmap < mbd->mmap_addr + mbd->mmap_length)
	{
		mmap = (multiboot_memory_map_t*)( (uint32_t)mmap + mmap->size + sizeof(uint32_t) );
		console_print("[");

		// Save current console colours
		console_swap_colors();

		if (mmap->type == 1)
		{
			console_set_colors(COLOR_GREEN, COLOR_BLACK);
			console_print("   FREE   ");
		} else {
			console_set_colors(COLOR_RED, COLOR_BLACK);
			console_print(" RESERVED ");
		}
		// Restore old console colours
		console_swap_colors();

		console_print("] 0x%x to 0x%x = %d bytes\n",
						(uint32_t)mmap->addr,
						(uint32_t)mmap->addr + (uint32_t)mmap->len-1,
						(uint32_t)mmap->len
		);
	}
}
Ejemplo n.º 3
0
void kernel_main(multiboot_info_t *mbd, uint32_t magic)
{
	//*********************************************************
	// First things first. Parse the command line. Quick guide:
	//
	//  o quiet  - Don't print so much stuff to the screen during boot
	//  o silent - Don't print anything at all during boot (implies quiet)
	//  o eshell - (RESERVED) Will be used to enter emergency shell
	//
	if (string_contains( (char*)(mbd->cmdline) , "quiet"))
		KERNEL_OPTION_QUIET = TRUE;

	if (string_contains( (char*)(mbd->cmdline) , "silent"))
	{
		KERNEL_OPTION_QUIET = TRUE;
		KERNEL_OPTION_SILENT = TRUE;
	}
	if (string_contains( (char*)(mbd->cmdline) , "eshell"))
		KERNEL_OPTION_ESHELL = TRUE;
	//*********************************************************

	//*********************************************************
	// Do some important things before we forget
	k_tally_available_memory(mbd);

	// Init the text console and colours
	console_init();
	console_set_colors(COLOR_BRIGHT_GRAY, COLOR_BLACK);
	console_swap_colors();
	console_set_colors(COLOR_BRIGHT_GRAY, COLOR_BLACK);
	console_clear();
	//*********************************************************

	if (!KERNEL_OPTION_QUIET)
	{
		// Print some stuff about the environment
		console_print("Here is kernel_main()\n");
		console_print("Bootloader: %s\n",mbd->boot_loader_name);
		console_print("Kernel: %s\n",mbd->cmdline);
		console_print("Flags: %b\n",mbd->flags);
		console_print("Boot Device: %x\n",mbd->boot_device);

		// Dump some info about the memory blocks/regions available/reserved
		k_dump_memory_blocks(mbd);
	}
	if (!KERNEL_OPTION_SILENT)
	{
		console_print("Welcome to Toast v%d.%d (nickname '%s')\nMemory: %dMiB",
						KERNEL_VERSION_MAJ,
						KERNEL_VERSION_MIN,
						KERNEL_NICKNAME,
						TOTAL_MEMORY/1048576);
	}
	//panic(0x4655434B); // (TEST) testing panic
}
Ejemplo n.º 4
0
Archivo: main.c Proyecto: IUNIXI/LxNAND
int main(void)
{
	xenos_init(VIDEO_MODE_AUTO);
        console_set_colors(0xD8444E00,0xFF96A300);
	console_init();

	usb_init();
	usb_do_poll();     
   
	printf("SFCX Init.\n");
        flashconfig = sfcx_readreg(SFCX_CONFIG);
	sfcx_init();
	if (sfc.initialized != SFCX_INITIALIZED)
        {
                printf(" ! Flashconfig: 0x%08X\n", flashconfig);
		printf(" ! sfcx initialization failure\n");
		printf(" ! nand related features will not be available\n");
		waitforexit();
        }

	printf("Xenon_config_init.\n");
	xenon_config_init();

        prompt(MAIN_MENU);
        
	return 0;
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: deado/buttons
void mainInit()
{ 
	//init
	xenos_init(VIDEO_MODE_AUTO);
	console_set_colors(CONSOLE_COLOR_BLUE,CONSOLE_COLOR_YELLOW);
	console_init();

	usb_init();
	usb_do_poll();
	xenon_make_it_faster(XENON_SPEED_FULL);

}
Ejemplo n.º 6
0
void dump_thread_context_to_screen(PROCESSOR_DATA_BLOCK *processor,
        unsigned int exceptionCode, CONTEXT *context)
{
    console_set_colors(0x000080ff, 0xffffffff);
    console_clrscr();
    
    strcpy(exception_text, exception_strings[exceptionCode]);
    
    debug_flush_console();

    sprintf(exception_text,"\nIar=%016llx Msr=%016llx Lr=%016llx Dar=%08X Pir=%02X\n\n",
                    context->Iar, context->Msr, context->Lr,
                        processor->DAR, (unsigned int)mfspr(pir));
    
    debug_flush_console();

    int i;
    for(i=0;i<8;++i)
            sprintf(exception_text,"%s%02d=%016llx %02d=%016llx %02d=%016llx %02d=%016llx\n",
                            exception_text,
                    i,context->Gpr[i],
                    i+8,context->Gpr[i+8],
                    i+16,context->Gpr[i+16],
                    i+24,context->Gpr[i+24]);

    debug_flush_console();
    
    debug_cpu_print_stack((void*)context->Iar,(void*)context->Lr,(void*)context->Gpr[1]);

    strcat(exception_text,"\n\nOn uart: 'h'=Halt, 'r'=Reboot\n\n");

    debug_flush_console();

    for(;;){
            switch(getch()){
                    case 'h':
                            xenon_smc_power_shutdown();
                            for(;;);
                            break;
                    case 'r':
                            xenon_smc_power_reboot();
                            for(;;);
                            break;
            }
    }
}
Ejemplo n.º 7
0
void crashdump(u32 exception,u64 * context)
{
	console_set_colors(0x000080ff, 0xffffffff);
	console_init();
	console_clrscr();
        
        switch(exception)
        {
            case 0x200:
                strcpy(text,"\nMachine Check!\n\n");
                break;
            case 0x380:
                strcpy(text,"\nData SegFault!\n\n");
                break;
            case 0x480:
                strcpy(text,"\nInstruction SegFault!\n\n");
                break;
            case 0x500:
                strcpy(text,"\nExternal Interrupt!\n\n");
                break;
            case 0x600:
                strcpy(text,"\nAlignment!\n\n");
                break;
            case 0x700:
                strcpy(text,"\nProgram Interrupt!\n\n");
                break;
            case 0x800:
                strcpy(text,"\nFPU Unavailable!\n\n");
                break;
            case 0x900:
                strcpy(text,"\nDecrementer!\n\n");
                break;
            case 0x980:
                strcpy(text,"\nHV Decrementer!\n\n");
                break;
            case 0xC00:
                strcpy(text,"\nSystem Call!\n\n");
                break;
            case 0xD00:
                strcpy(text,"\nTrace!\n\n");
                break;
            case 0xE00:
                strcpy(text,"\nFPU Assist!\n\n");
                break;
            case 0xF20:
                strcpy(text,"\nVPU Unavailable!\n\n");
                break;
            case 0x1600:
                strcpy(text,"\nMaintenance!\n\n");
                break;
            case 0x1700:
                strcpy(text,"\nVMX Assist!\n\n");
                break;
            case 0x1800:
                strcpy(text,"\nThermal Managment!\n\n");
                break;
            case 0:
                strcpy(text,"\nSegmentation Fault!\n\n");
                break;
            default:
                sprintf(text,"\nException Vector! (%p)\n\n",exception);
                break;
        }
		
	flush_console();
	
	sprintf(text,"%spir=%016llx dar=%016llx\nIar=%016llx Msr=%016llx lr=%016llx\n\n",
			text,context[39],context[38],context[36],context[37],context[32]);
	
	flush_console();
	
	int i;
	for(i=0;i<8;++i)
		sprintf(text,"%s%02d=%016llx %02d=%016llx %02d=%016llx %02d=%016llx\n",
				text,i,context[i],i+8,context[i+8],i+16,context[i+16],i+24,context[i+24]);
	
	flush_console();
	
	_cpu_print_stack((void*)(u32)context[36],(void*)(u32)context[32],(void*)(u32)context[1]);
	
	strcat(text,"\n\nOn uart: 'x'=Xell, 'h'=Halt, 'r'=Reboot\n\n");

	flush_console();

	for(;;){
		switch(getch()){
			case 'x':
				exit(0);
				break;
			case 'h':
				xenon_smc_power_shutdown();
				for(;;);
				break;
			case 'r':
				xenon_smc_power_reboot();
				for(;;);
				break;
		}
	}
}
Ejemplo n.º 8
0
int main(){
	const char * s;
	char path[256];
	
	int handle;
	struct controller_data_s pad;
	int pos=0,ppos=-1,start,count,i;

	xenos_init(VIDEO_MODE_AUTO);
	console_init();

	xenon_make_it_faster(XENON_SPEED_FULL);
	
	usb_init();
	usb_do_poll();
	
	xenon_ata_init();

	xenon_atapi_init();
	
	fatInitDefault();

	handle=-1;
    handle=bdev_enum(handle,&s);
    if(handle<0) return 0;

	strcpy(path,s);
	strcat(path,":/");	

	load_dir(path);
	
	for(;;){
 		usb_do_poll();		
 		get_controller_data(&pad, 0);
		
		if (pad.s1_y>STICK_THRESHOLD) --pos;
		if (pad.s1_y<-STICK_THRESHOLD) ++pos;
		
		if (entrycount && (pos<0 || pos>=entrycount)){
			pos=ppos;
			continue;
		}
		
		if (pad.logo) return 0;
		
		if (pad.a){
			if(entries[pos].d_type&DT_DIR){
				append_dir_to_path(path,entries[pos].d_name);
				load_dir(path);
				ppos=-1;
				pos=0;
			}else{
				char fn[256];
				strcpy(fn,path);
				strcat(fn,entries[pos].d_name);
				
				printf("%s\n",fn);

				if (strstr(entries[pos].d_name,".elf") || strstr(entries[pos].d_name,".elf32")) { // ugly
					elf_runFromDisk(fn);
				}else{
					FILE * f=fopen(fn,"rb");
					if(f){
						int size=1024*1024;
						int totred=0,red;

						void * buf=malloc(size);

						u64 beg=mftb();
						do{
							red=fread(buf,1,size,f);
							totred+=red;
							console_putch('.');
						}while(red==size);

						printf("\n%d bytes, %f KB/s\n",totred, (float)(totred/1024.0)/((float)(mftb()-beg)/PPC_TIMEBASE_FREQ));

						free(buf);

						fclose(f);
					}
				}
			}
		}
		
		if(pad.back){
			append_dir_to_path(path,"..");
			load_dir(path);
			ppos=-1;
			pos=0;
		}
		
		if(pad.b){
		    do{
				handle=bdev_enum(handle,&s);
			}while(handle<0);
			strcpy(path,s);
			strcat(path,":/");
			load_dir(path);
			ppos=-1;
			pos=0;
		}

		if (ppos==pos) continue;
		
		memset(&pad,0,sizeof(struct controller_data_s));
		
		console_set_colors(BG_COL,FG_COL);
		console_clrscr();
		printf("A: select, B: change disk, Back: parent dir, Logo: reload Xell\n\n%s\n\n",path);
		
		start=MAX(0,pos-MAX_DISPLAYED_ENTRIES/2);
		count=MIN(MAX_DISPLAYED_ENTRIES,entrycount-start);
		
		for(i=start;i<start+count;++i){
			struct dirent *de = &entries[i];

			if (i==pos){
				console_set_colors(FG_COL,BG_COL);
			}else{
				console_set_colors(BG_COL,FG_COL);
			}
			
			if (de->d_type&DT_DIR) console_putch('[');

			s=de->d_name;
			while(*s) console_putch(*s++);
			
			if (de->d_type&DT_DIR) console_putch(']');

			console_putch('\r');
			console_putch('\n');
		}
			
		ppos=pos;
		
		do{
	 		usb_do_poll();		
			get_controller_data(&pad, 0);
		}while(pad.a || pad.b || pad.back || pad.s1_y>STICK_THRESHOLD || pad.s1_y<-STICK_THRESHOLD);
	}
	
	
	return 0;
}
Ejemplo n.º 9
0
int _main(unsigned zero, unsigned type, unsigned tags)
{    
    const char *cmdline = 0;
    int n;
    
    arm11_clock_init();

        /* must do this before board_init() so that we
        ** use the partition table in the tags if it 
        ** already exists 
        */
    if((zero == 0) && (type != 0) && tags_okay(tags)) {
        linux_type = type;
        linux_tags = tags;

        cmdline = tags_get_cmdline((void*) linux_tags);
        
        tags_import_partitions((void*) linux_tags);
        revision = tags_get_revision((void*) linux_tags);
        if(revision == 1) {
            console_set_colors(0x03E0, 0xFFFF);
        }
        if(revision == 2) {
            console_set_colors(0x49B2, 0xFFFF);
        }

            /* we're running as a second-stage, so wait for interrupt */
        boot_from_flash = 0;
    } else {
        linux_type = board_machtype();
        linux_tags = 0;
    }

    board_init();
    keypad_init();
    
    console_init();
    dprintf_set_putc(uart_putc);    

    if(linux_tags == 0) {
            /* generate atags containing partitions 
             * from the bootloader, etc 
             */
        linux_tags = ADDR_TAGS;
        create_atags(linux_tags, 0, 0, 0);
    }
    
    if (cmdline) {
        char *sn = strstr(cmdline, SERIALNO_STR);
        if (sn) {
            char *s = serialno;
            sn += SERIALNO_LEN;
            while (*sn && (*sn != ' ') && ((s - serialno) < 31)) {
                *s++ = *sn++;
            }
            *s++ = 0;
        }
    }

    cprintf("\n\nUSB FastBoot:  V%s\n", get_fastboot_version());
    cprintf("Machine ID:    %d v%d\n", linux_type, revision);
    cprintf("Build Date:    "__DATE__", "__TIME__"\n\n");

    cprintf("Serial Number: %s\n\n", serialno[0] ? serialno : "UNKNOWN");

    flash_dump_ptn();

    flash_init();

        /* scan the keyboard a bit */
    for(n = 0; n < 50; n++) {
        boot_poll();
    }

    if (boot_from_flash) {
        cprintf("\n ** BOOTING LINUX FROM FLASH **\n");
        boot_linux_from_flash();
    }

    usbloader_init();
    
    for(;;) {
        usb_poll();
    }
    return 0;
}
Ejemplo n.º 10
0
int main(void)
{
   const char *s = NULL;
   char path[256];

   int handle;
   struct controller_data_s pad;
   int pos = 0, ppos = -1;

   xenos_init(VIDEO_MODE_AUTO);
   console_init();
   xenon_make_it_faster(XENON_SPEED_FULL);
   usb_init();
   usb_do_poll();
   xenon_ata_init();
   dvd_init();

   handle = -1;
   handle = bdev_enum(handle, &s);
   if (handle < 0)
      return 0;

   strcpy(path, s);
   strcat(path, ":/");	

   load_dir(path);

   for (;;)
   {
      usb_do_poll();		
      get_controller_data(&pad, 0);

      if (pad.s1_y > STICK_THRESHOLD || pad.up)
         pos--;
      if (pad.s1_y < -STICK_THRESHOLD || pad.down)
         pos++;

      if (entrycount && (pos < 0 || pos >= entrycount))
      {
         pos = ppos;
         continue;
      }

      if (pad.logo)
         return 0;

      if (pad.a)
      {
         if (entries[pos].d_type & DT_DIR)
         {
            append_dir_to_path(path,entries[pos].d_name);
            load_dir(path);
            ppos = -1;
            pos = 0;
         }
         else
         {
            char fn[256];
            strcpy(fn, path);
            strcat(fn, entries[pos].d_name);

            printf("%s\n", fn);

            start_ssnes(fn);
         }
      }

      if (pad.select)
      {
         append_dir_to_path(path, "..");
         load_dir(path);
         ppos = -1;
         pos = 0;
      }

      if (pad.b)
      {
         do
         {
            handle = bdev_enum(handle, &s);
         } while (handle < 0);

         strcpy(path, s);
         strcat(path, ":/");
         load_dir(path);
         ppos = -1;
         pos = 0;
      }

      if (ppos == pos)
         continue;

      memset(&pad, 0, sizeof(pad));

      console_set_colors(BG_COL, FG_COL);
      console_clrscr();
      printf("A: select, B: change disk, Back: parent dir, Logo: reload Xell\n\n%s\n\n", path);

      int start = MAX(0, pos - MAX_DISPLAYED_ENTRIES / 2);
      int count = MIN(MAX_DISPLAYED_ENTRIES, entrycount - start);

      for (int i = start; i < start + count; i++)
      {
         struct dirent *de = &entries[i];

         if (i == pos)
            console_set_colors(FG_COL, BG_COL);
         else
            console_set_colors(BG_COL, FG_COL);

         if (de->d_type & DT_DIR)
            console_putch('[');

         s = de->d_name;
         while (*s)
            console_putch(*s++);

         if (de->d_type & DT_DIR)
            console_putch(']');

         console_putch('\r');
         console_putch('\n');
      }

      ppos = pos;

      do
      {
         usb_do_poll();		
         get_controller_data(&pad, 0);
      } while (pad.a || pad.b || pad.select || pad.s1_y > STICK_THRESHOLD || pad.s1_y < -STICK_THRESHOLD);
   }

   return 0;
}