示例#1
0
void kloader_cmain(struct mem_map_entry mem_map[], uint32_t mem_entry_count)
{
    screen_init();
    screen_cursor_hide();
    terminal_init();

    KINFO("Welcome to Nox (Bootloader mode)");

    mem_mgr_init(mem_map, mem_entry_count);

    ata_init();
    fs_init();

    struct fat_part_info* part_info = fs_get_system_part();
    struct fat_dir_entry kernel;
    if(!fat_get_dir_entry(part_info, "KERNEL  ELF", &kernel)) {
        KPANIC("Failed to locate KERNEL.ELF");
        while(1);
    }

    intptr_t kernel_entry_point;

    if(!elf_load_trusted("KERNEL  ELF", &kernel_entry_point)) {
        KWARN("Failed to load elf!");
    } 

    kernel_entry cmain = (kernel_entry)(kernel_entry_point);

    cmain(mem_map, mem_entry_count);


    KINFO("Bootloader done");

    while(1);
}
示例#2
0
/**
 * Kernel entry point
 */
void kmain(struct multiboot_info* info, unsigned int magic) {

    initMemoryMap(info);
    mm_pagination_init();

    setupGDT();
    setupIDT();
    
    stdin = STACK_TOP_MAPPING;
    stdout = (STACK_TOP_MAPPING + sizeof(FILE));
    stderr = (STACK_TOP_MAPPING + 2 * sizeof(FILE));

    cache_init();
    ata_init(info);
    fs_load();
    fifo_init();
    scheduler_init();

    struct Process* idleProcess = process_table_new(idle, "idle", NULL, 1, NO_TERMINAL, 0);
    struct Process* shellProcess = process_table_new(tty_run, "tty", idleProcess, 1, NO_TERMINAL, 0);
    struct Process* cacheProcess = process_table_new(cache_flush, "cache_flush",idleProcess, 1, NO_TERMINAL, 0);
    yield();

    while (1) {}
}
示例#3
0
int main(int argc, char *argv[])
{
    int rc,i;
    struct partinfo* pinfo;

    srand(clock());

    if(ata_init()) {
        DEBUGF("*** Warning! The disk is uninitialized\n");
        return -1;
    }
    pinfo = disk_init();
    if (!pinfo) {
        DEBUGF("*** Failed reading partitions\n");
        return -1;
    }

    for ( i=0; i<4; i++ ) {
        if ( pinfo[i].type == PARTITION_TYPE_FAT32 
#ifdef HAVE_FAT16SUPPORT
          || pinfo[i].type == PARTITION_TYPE_FAT16
#endif
        ) {
            DEBUGF("*** Mounting at block %ld\n",pinfo[i].start);
            rc = fat_mount(IF_MV(0,) IF_MD(0,) pinfo[i].start);
            if(rc) {
                DEBUGF("mount: %d",rc);
                return -1;
            }
            break;
        }
    }
示例#4
0
文件: main.c 项目: Digmaster/Nunya
int kernel_main() {
    graphics_init();
    console_init();

    console_printf("video: %d x %d\n", video_xres, video_yres, video_xbytes);
    console_printf("kernel: %d bytes\n", kernel_size);

    memory_init();
    interrupt_init();
    rtc_init();
    clock_init();
    keyboard_init();

    /*
    process_init() is a big step.  This initializes the process table, but also gives us our own process structure, private stack, and enables paging.  Now we can do complex things like wait upon events.
    */
    process_init();

    mouse_init();
    ata_init();

    console_printf("\nNUNYA READY:\n");

    cmd_line_init();

    while(1) {
        cmd_line_show_prompt();
        cmd_line_attempt(keyboard_read_str());
    }

    return 0;
}
示例#5
0
static int mkrk27_init(const char *filename) {
    int i;
    int rc;
    srand(clock());

    img_filename = filename;

    if(ata_init()) {
        mkrk27_set_error("Warning! The disk is uninitialized\n");
        return -1;
    }

    struct partinfo *pinfo = disk_init();

    if (!pinfo) {
        mkrk27_set_error("Failed reading partitions\n");
        return -1;
    }

    for ( i=0; i<4; i++ ) {
        if ( pinfo[i].type == PARTITION_TYPE_FAT32
#ifdef HAVE_FAT16SUPPORT
             || pinfo[i].type == PARTITION_TYPE_FAT16
#endif
            ) {
            rc = fat_mount(IF_MV(0,) IF_MD(0,) pinfo[i].start);
            if(rc) {
                mkrk27_set_error("mount: %d",rc);
                return -1;
            }
            break;
        }
    }
示例#6
0
文件: hdd.c 项目: m-rinaldi/kboot86
int hdd_init(void)
{
    if (ata_init())
        return 1;

    if (mbr_init())
        return 1;

    return 0;
}
示例#7
0
文件: DEV9.cpp 项目: logtcn/pcsx2
s32 CALLBACK DEV9open(void *pDsp) 
{
	DEV9_LOG("DEV9open\n");
	LoadConf();
	DEV9_LOG("open r+: %s\n", config.Hdd);
	config.HddSize = 8*1024;
	
	iopPC = (u32*)pDsp;
	
#ifdef ENABLE_ATA
	ata_init();
#endif
	return _DEV9open();
}
示例#8
0
s32 CALLBACK DEV9open(void *pDsp) 
{
	DEV9_LOG("DEV9open\n");
	LoadConf();
	DEV9_LOG("open r+: %s\n", config.Hdd);
	config.HddSize = 8*1024;
	
	tx_p_first=false; // reset stack init hack so it works on game reboots 

	iopPC = (u32*)pDsp;
	
#ifdef ENABLE_ATA
	ata_init();
#endif
	return _DEV9open();
}
示例#9
0
void shutdown(void)
{
    /* We need to gracefully spin down the disk to prevent clicks. */
    if (ide_powered())
    {
        /* Make sure ATA has been initialized. */
        ata_init();
        
        /* And put the disk into sleep immediately. */
        ata_sleepnow();
    }
    
    backlight_hw_off();

    power_off();
}
示例#10
0
文件: fs.c 项目: Barracuda72/OS_64
void fs_init(void)
#endif
{
  char *rnn;

  kprintf("FS initialization...\n");
  vfs_node_t *main;

#ifdef __HOSTED__
  main = initrd_init(p, len);
  rnn = "initrd0";
#else
  main = ata_init();
  rnn = "ata0";
#endif

  dfs = devfs_init();

  devfs_add(main);

  root = vfs_alloc_node();
  root->name[0] = '/';
  root->name[1] = 0;

  root->flags = VFS_DIRECTORY;

  vfs_node_t *t = vfs_finddir(dfs, rnn);
  vfs_mount(t, root);

  if (root->ptr != NULL)
  {
    kprintf("Root mounted successfully\n");
  }

  tty_node = tty_init(NULL);
  devfs_add(tty_node);

  fs_print_dir(dfs);
}
示例#11
0
文件: ipod.c 项目: josephks/rockbox
void* main(void)
{
    char buf[256];
    int i;
    int btn;
    int rc;
    bool haveramos;
    bool button_was_held;
    struct partinfo* pinfo;
    unsigned short* identify_info;

    /* Check the button hold status as soon as possible - to 
       give the user maximum chance to turn it off in order to
       reset the settings in rockbox. */
    button_was_held = button_hold();

    system_init();
    kernel_init();

#ifndef HAVE_BACKLIGHT_INVERSION
    backlight_init(); /* Turns on the backlight */
#endif

    lcd_init();
    font_init();

#ifdef HAVE_LCD_COLOR
    lcd_set_foreground(LCD_WHITE);
    lcd_set_background(LCD_BLACK);
    lcd_clear_display();
#endif

#if 0
    /* ADC and button drivers are not yet implemented */
    adc_init();
    button_init();
#endif

    btn=key_pressed();

    /* Enable bootloader messages */
    if (btn==BUTTON_RIGHT)
        verbose = true;

    lcd_setfont(FONT_SYSFIXED);

    printf("Rockbox boot loader");
    printf("Version: " RBVERSION);
    printf("IPOD version: 0x%08x", IPOD_HW_REVISION);

    i=ata_init();
    if (i==0) {
      identify_info=ata_get_identify();
      /* Show model */
      for (i=0; i < 20; i++) {
        ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
      }
      buf[40]=0;
      for (i=39; i && buf[i]==' '; i--) {
        buf[i]=0;
      }
      printf(buf);
    } else {
      printf("ATA: %d", i);
    }

    disk_init();
    rc = disk_mount_all();
    if (rc<=0)
    {
        printf("No partition found");
        fatal_error();
    }

    pinfo = disk_partinfo(1);
    printf("Partition 1: 0x%02x %ld sectors", 
           pinfo->type, pinfo->size);

    if (button_was_held || (btn==BUTTON_MENU)) {
        /* If either the hold switch was on, or the Menu button was held, then 
           try the Apple firmware */

        printf("Loading original firmware...");
    
        /* First try an apple_os.ipod file on the FAT32 partition
           (either in .rockbox or the root) 
         */
    
        rc=load_firmware(loadbuffer, "apple_os.ipod", MAX_LOADSIZE);
    
        if (rc > 0) {
            printf("apple_os.ipod loaded.");
            return (void*)DRAM_START;
        } else if (rc == EFILE_NOT_FOUND) {
            /* If apple_os.ipod doesn't exist, then check if there is an Apple 
               firmware image in RAM  */
            haveramos = (memcmp((void*)(DRAM_START+0x20),"portalplayer",12)==0);
            if (haveramos) {
                /* We have a copy of the retailos in RAM, lets just run it. */
                return (void*)DRAM_START;
            }
        } else {
            printf("Error!");
            printf("Can't load apple_os.ipod:");
            printf(loader_strerror(rc));
        }
        
        /* Everything failed - just loop forever */
        printf("No RetailOS detected");
        
    } else if (btn==BUTTON_PLAY) {
        printf("Loading Linux...");
        rc=load_raw_firmware(loadbuffer, "/linux.bin", MAX_LOADSIZE);
        if (rc <= EFILE_EMPTY) {
            printf("Error!");
            printf("Can't load linux.bin:");
            printf(loader_strerror(rc));
        } else {
            return (void*)DRAM_START;
        }
    } else {
        printf("Loading Rockbox...");
        rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE);
        if (rc > 0) {
            printf("Rockbox loaded.");
            return (void*)DRAM_START;
        } else if (rc == EFILE_NOT_FOUND) {
            /* if rockbox.ipod doesn't exist, then check if there is a Rockbox
               image in RAM  */
            haveramos = (memcmp((void*)(DRAM_START+0x20),"Rockbox\1",8)==0);
            if (haveramos) {
                /* We have a copy of Rockbox in RAM, lets just run it. */
                return (void*)DRAM_START;
            }
        }

        printf("Error!");
        printf("Can't load " BOOTFILE ": ");
        printf(loader_strerror(rc));
    }
    
    /* If we get to here, then we haven't been able to load any firmware */
    fatal_error();
    
    /* We never get here, but keep gcc happy */
    return (void*)0;
}
示例#12
0
文件: main.c 项目: zwostein/idetrol
int main( void )
{
	wdt_disable();
	jtag_disable();
	rs232_init( 9600, 0 );
	spi_init( SPI_HALFSPEED | SPI_EIGHTHSPEED );
	spi_idetrol_slave_init( &player );
	irmp_init();
	timer1_init();
	timer2_init();
	stdin = stdout = &rs232inout;
	sei();

	printf_P( PSTR("\nCDTrol "__DATE__"\n") );
	if( !ata_init() )
	{
		printf_P( PSTR("ATA Initialization failed\n") );
		_delay_ms(1000);
		return 1;
	}
	if( !atapi_init() )
	{
		printf_P( PSTR("ATAPI Initialization failed\n") );
		_delay_ms(1000);
		return 1;
	}
	if( !atapiplayer_init( &player ) )
	{
		printf_P( PSTR("ATAPIPlayer Initialization failed\n") );
		_delay_ms(1000);
		return 1;
	}

	while( true )
	{
		spi_idetrol_slave_update();
		if( updateFlag )
		{
			atapiplayer_update( &player );
			updateFlag = 0;
		}
		if( irmp_get_data( &irmp_data ) )
		{
			if( ! (irmp_data.flags & IRMP_FLAG_REPETITION) )
			{
				printf_P( PSTR("\nIRMP: protocol \"%S\", address %d, command %d\n"), (PGM_P)pgm_read_word(&(irmp_protocol_strings[irmp_data.protocol])), irmp_data.address, irmp_data.command );
				switch( irmp_data.command )
				{
					case 53:
						printf_P( PSTR("\nPlay\n") );
						atapiplayer_play( &player );
						break;
					case 48:
						printf_P( PSTR("\nPause\n") );
						atapiplayer_pause( &player );
						break;
					case 54:
						printf_P( PSTR("\nStop\n") );
						atapiplayer_stop( &player );
						break;
					case 36:
						printf_P( PSTR("\nPrevious\n") );
						atapiplayer_previous( &player );
						break;
					case 30:
						printf_P( PSTR("\nNext\n") );
						atapiplayer_next( &player );
						break;
					case 55:
						printf_P( PSTR("\nLoad/Eject\n") );
						atapiplayer_loadEject( &player );
						break;
				}
			}
			switch( irmp_data.command )
			{
				case 52:
					printf_P( PSTR("\nFastForward\n") );
					atapiplayer_forward( &player );
					break;
				case 50:
					printf_P( PSTR("\nFastRewind\n") );
					atapiplayer_rewind( &player );
					break;
				case 59:
					atapi_printError();
					break;
			}
		}
	}
	return 0;
}