Пример #1
0
void main(void)		/* This really IS void, no error here. */
{			/* The startup routine assumes (well, ...) this */
/*
 * Interrupts are still disabled. Do necessary setups, then
 * enable them
 */
 	ROOT_DEV = ORIG_ROOT_DEV;
 	drive_info = DRIVE_INFO;
	memory_end = (1<<20) + (EXT_MEM_K<<10);
	memory_end &= 0xfffff000;
	if (memory_end > 16*1024*1024)
		memory_end = 16*1024*1024;
	if (memory_end > 12*1024*1024) 
		buffer_memory_end = 4*1024*1024;
	else if (memory_end > 6*1024*1024)
		buffer_memory_end = 2*1024*1024;
	else
		buffer_memory_end = 1*1024*1024;
	main_memory_start = buffer_memory_end;
#ifdef RAMDISK
	main_memory_start += rd_init(main_memory_start, RAMDISK*1024);
#endif
	mem_init(main_memory_start,memory_end);
	trap_init();
	blk_dev_init();
	chr_dev_init();
	tty_init();
	time_init();
	sched_init();
	buffer_init(buffer_memory_end);
	hd_init();
	floppy_init();
	sti();
	move_to_user_mode();

	setup((void *) &drive_info);
	(void) open("/dev/tty0",O_RDWR,0);
	(void) dup(0);
	(void) dup(0);
	(void) open("/var/process.log",O_CREAT|O_TRUNC|O_WRONLY,0666);
#ifdef dis_func
	(void) open("/var/dis_func.log",O_CREAT|O_TRUNC|O_WRONLY,0666);
#endif

	if (!fork()) {		/* we count on this going ok */
		init();
	}
/*
 *   NOTE!!   For any other task 'pause()' would mean we have to get a
 * signal to awaken, but task0 is the sole exception (see 'schedule()')
 * as task 0 gets activated at every idle moment (when no other tasks
 * can run). For task0 'pause()' just means we go check if some other
 * task can run, and if not we return here.
 */
	for(;;) pause();
}
Пример #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");
}
Пример #3
0
/*
 * This is the kernel main routine. When the boot process is completed, this
 * function is called.
 */
void start_kernel(void) {
    int pid, i;
    char *names[N_CONSOLES] = { "PRG1", "PRG2", "PRG3", 
                                "PRG4", "PRG5", "PRG6" };

    // init traps
    init_traps();
    // initialize IRQs
    init_irq();

    // initialize the tty driver. The tty is composed by a keyboard driver
    // that read input keys a print the relative ASCII code on video.
    tty_init();
    // initialize the timer.
    time_init();
    // initialize the scheduler
    sched_init();

    printk("Kernel info: %u bytes, start at 0x%x0 end at 0x%x0.\n",
           &__KERNEL_END__-K_START, K_START, &__KERNEL_END__);
    sti();

    // calibrate delay
    calibrate_delay();
    // floppy driver initialization
    floppy_init();

    // switch in user mode
    move_to_user_mode();

    // for a process for each console and execute the program PRGi
    for (i=0; i<N_CONSOLES; ++i) {
        // spawn process i and run PRG1
        pid = fork();

        if (pid == 0) {
            exec(names[i]);
        } else if (pid < 0) {
            print("idle: cannot duplicate myself.\n");
        }
    }

	print("Idle: ok!\n");

    // idle loop
    while(1);
}
Пример #4
0
static bool fd_init(void)
{
	fs = (struct fs_module *)kernel->open_module("fs", SYS_VER);
	if(fs == NULL)
		return FALSE;

	shell = (struct shell_module *)kernel->open_module("shell", SYS_VER);
	if(shell == NULL)
	{
		kernel->close_module((struct module *)fs);
		return FALSE;
	}

	add_floppy_commands();
	floppy_init();
	return TRUE;
}
Пример #5
0
void main(void)		/* This really IS void, no error here. */
{			/* The startup routine assumes (well, ...) this */
/*
 * Interrupts are still disabled. Do necessary setups, then
 * enable them
 */
 	ROOT_DEV = ORIG_ROOT_DEV;
 	drive_info = DRIVE_INFO;
	memory_end = (1<<20) + (EXT_MEM_K<<10);
	memory_end &= 0xfffff000;
	if (memory_end > 16*1024*1024)
		memory_end = 16*1024*1024;
	if (memory_end > 12*1024*1024) 
		buffer_memory_end = 4*1024*1024;
	else if (memory_end > 6*1024*1024)
		buffer_memory_end = 2*1024*1024;
	else
		buffer_memory_end = 1*1024*1024;
	main_memory_start = buffer_memory_end;
#ifdef RAMDISK
	main_memory_start += rd_init(main_memory_start, RAMDISK*1024);
#endif
	mem_init(main_memory_start,memory_end);
	trap_init();	/* set the IDT in 0x00080000~0x000807ff(4KB)*/
	blk_dev_init();
	chr_dev_init();	/* this function do nothing */
	tty_init();		/* rs_init() and con_init() */
	time_init();
	sched_init();
	buffer_init(buffer_memory_end);
	hd_init();
	floppy_init();
	sti();
	move_to_user_mode();
	if (!fork()) {		/* we count on this going ok */
		init();
	}
/*
 *   NOTE!!   For any other task 'pause()' would mean we have to get a
 * signal to awaken, but task0 is the sole exception (see 'schedule()')
 * as task 0 gets activated at every idle moment (when no other tasks
 * can run). For task0 'pause()' just means we go check if some other
 * task can run, and if not we return here.
 */
	for(;;) pause();
}
Пример #6
0
int main()
{
//Start video driver (must always be before loading message)
    mm_init();
    pg_init();
    real_init();
    video_init();
    video_setdriver(video_vgatext_getdriver(),0);

//Put loading message
    cli_puts("ArcaneOS Loading...\n");

//Setup kernel
    gdt_init();
    idt_init();
    isr_init();
    irq_init();
    timer_init();
    kb_init();
    ui_init();
    cpuid_init();
    cmos_init();
    rtc_init();
    acpi_init();
    power_init();
    mt_init();
    syscall_init();
    floppy_init();

    __asm__ __volatile__ ("sti");

//Enable ACPI
    acpi_enable();

//Create thread for ui
    mt_create_thread(mt_kernel_process,test,2);

//Endless loop to prevent bugs when all threads are sleeping
    for(;;)
        __asm__ __volatile__ ("hlt");
}
Пример #7
0
void i8272_init(void)
{
    floppy_init();
}
Пример #8
0
/* main code for identifying and maybe opening a disk image; not exposed
 * directly because this function is big and hideous */
static floperr_t floppy_open_internal(void *fp, const struct io_procs *procs, const char *extension,
                                      const struct FloppyFormat *floppy_options, int max_options, int flags, floppy_image **outfloppy,
                                      int *outoption)
{
    floperr_t err;
    floppy_image *floppy;
    int best_option = -1;
    int best_vote = 0;
    int vote;
    size_t i;

    floppy = floppy_init(fp, procs, flags);
    if (!floppy)
    {
        err = FLOPPY_ERROR_OUTOFMEMORY;
        goto done;
    }

    /* vote on the best format */
    for (i = 0; (i < max_options) && floppy_options[i].construct; i++)
    {
        if (!extension || !floppy_options[i].extensions || findextension(floppy_options[i].extensions, extension))
        {
            if (floppy_options[i].identify)
            {
                vote = 0;
                err = floppy_options[i].identify(floppy, &floppy_options[i], &vote);
                if (err)
                    goto done;
            }
            else
            {
                vote = 1;
            }

            /* is this option a better one? */
            if (vote > best_vote)
            {
                best_vote = vote;
                best_option = i;
            }
        }
    }

    /* did we find a format? */
    if (best_option == -1)
    {
        err = FLOPPY_ERROR_INVALIDIMAGE;
        goto done;
    }

    if (outfloppy)
    {
        /* call the format constructor */
        err = floppy_options[best_option].construct(floppy, &floppy_options[best_option], NULL);
        if (err)
            goto done;

        floppy->floppy_option = &floppy_options[best_option];
    }

    err = FLOPPY_ERROR_SUCCESS;

done:
    /* if we have a floppy disk and we either errored or are not keeping it, close it */
    if (floppy && (!outfloppy || err))
    {
        floppy_close_internal(floppy, FALSE);
        floppy = NULL;
    }

    if (outoption)
        *outoption = err ? -1 : best_option;
    if (outfloppy)
        *outfloppy = floppy;
    return err;
}
Пример #9
0
floperr_t floppy_create(void *fp, const struct io_procs *procs, const struct FloppyFormat *format, option_resolution *parameters, floppy_image **outfloppy)
{
    floppy_image *floppy = NULL;
    optreserr_t oerr;
    floperr_t err;
    int heads, tracks, h, t;
    option_resolution *alloc_resolution = NULL;

    assert(format);

    /* create the new image */
    floppy = floppy_init(fp, procs, 0);
    if (!floppy)
    {
        err = FLOPPY_ERROR_OUTOFMEMORY;
        goto done;
    }

    /* if this format expects creation parameters and none were specified, create some */
    if (!parameters && floppy_option_guide && format->param_guidelines)
    {
        alloc_resolution = option_resolution_create(floppy_option_guide, format->param_guidelines);
        if (!alloc_resolution)
        {
            err = FLOPPY_ERROR_OUTOFMEMORY;
            goto done;
        }
        parameters = alloc_resolution;
    }

    /* finish the parameters, if specified */
    if (parameters)
    {
        oerr = option_resolution_finish(parameters);
        if (oerr)
        {
            err = option_to_floppy_error(oerr);
            goto done;
        }
    }

    /* call the format constructor */
    err = format->construct(floppy, format, parameters);
    if (err)
        goto done;

    /* format the disk, ignoring if formatting not implemented */
    if (floppy->format.format_track)
    {
        heads = floppy_get_heads_per_disk(floppy);
        tracks = floppy_get_tracks_per_disk(floppy);

        for (h = 0; h < heads; h++)
        {
            for (t = 0; t < tracks; t++)
            {
                err = floppy->format.format_track(floppy, h, t, parameters);
                if (err)
                    goto done;
            }
        }
    }

    /* call the post_format function, if present */
    if (floppy->format.post_format)
    {
        err = floppy->format.post_format(floppy, parameters);
        if (err)
            goto done;
    }

    floppy->floppy_option = format;
    err = FLOPPY_ERROR_SUCCESS;

done:
    if (err && floppy)
    {
        floppy_close_internal(floppy, FALSE);
        floppy = NULL;
    }

    if (outfloppy)
        *outfloppy = floppy;
    else if (floppy)
        floppy_close_internal(floppy, FALSE);

    if (alloc_resolution)
        option_resolution_close(alloc_resolution);
    return err;
}
Пример #10
0
//
// Start Kernel
asmlinkage void start_kernel(void) {

  char buf[255];
  int _i = 0;
  int _diff = 0;
  _video_draw_char('O', 79, 10);
  _video_draw_char('c', 79, 11);
  _video_draw_char('t', 79, 12);
  _video_draw_char('a', 79, 13);
  _video_draw_char('n', 79, 14);
  _video_draw_char('e', 79, 15);
  _video_draw_char(' ', 79, 16);
  _video_draw_char(' ', 79, 17);

  // Draw a banner line of the right side of the screen
  for (_i = 0; _i < 10; _i++)  { _video_draw_char(' ', 79,_i); }
  for (_i = 18; _i < 22; _i++) { _video_draw_char(' ', 79,_i); }  
   
  load_misc_kprint();  
  __sprintf(buf, "=========== Octane ===========\n"); __puts(buf);
  __sprintf(buf, "@INFO: Build: %ld; since (10/15/2007) %s\n", 
		  	main_get_build_count, main_get_version); __puts(buf);

  //memory_end = (1<<20) + (EXT_MEM_K<<10);
  //  memory_end &= PAGE_MASK;
  memory_end = 16*1024*1024;
  memory_start = 1024*1024;
  low_memory_start = (unsigned long) &_end;

  // now lets load the IDT
  load_exception_table();

  init_interrupts();
  sched_init();
  load_keyboard_driver();
  
  //memory_start = blk_dev_init(memory_start, memory_end);
  sti();
  //calibrate_delay();
  
  //memory_start = inode_init(memory_start, memory_end);
  //memory_start = file_table_init(memory_start, memory_end);  
  //mem_init(low_memory_start, memory_start, memory_end);
  //buffer_init();
  time_init();
 
  // Print the current time.
  printk("INFO: current time: %d\n", xtime.tv_sec);
  printk("INFO: %d/%d/%d %d:%d\n", cur_simpletime.mon,
		 cur_simpletime.day, cur_simpletime.year,
		 cur_simpletime.hour, cur_simpletime.min);

  floppy_init();
  sti();

  //__debug_floppy_open();
  //__debug_floppy_release();
  test_time_1();
  test_block_1();

  tests();
  for(;;) {  
	  _nop();
  }
}
Пример #11
0
int main(int argc, char *argv[])
{
  int c;
  struct state *state = NULL;
#if TEST_BUILD
  struct test_case *test_case;
#endif
  prefs_init();

  while(1) {
    int option_index = 0;
    static struct option long_options[] = {
      {"cart",                  required_argument, 0, OPT_CART },
      {"force-extreme-disasm",  no_argument,       0, OPT_FORCE_EXTREME_DISASM },
      {"crop-screen",           no_argument,       0, OPT_CROP_SCREEN },
      {"loglevels" ,            required_argument, 0, OPT_LOGLEVELS },
      {"audio-device" ,         required_argument, 0, OPT_AUDIO_DEVICE },
#if TEST_BUILD
      {"test-case",             required_argument, 0, OPT_TEST_MODE},
#endif
      {0,                       0,                 0, 0 }
    };
    c = getopt_long(argc, argv, "a:b:c:t:s:hdpyVAMvq", long_options, &option_index);
    if(c == -1) break;

    switch(c) {
    case 'a':
      prefs_set("diskimage", optarg);
      break;
    case 'b':
      prefs_set("diskimage2", optarg);
      break;
    case 'c':
      prefs_set("hdimage", optarg);
      break;
    case 't':
      prefs_set("tosimage", optarg);
      break;
    case 's':
      prefs_set("stateimage", optarg);
      break;
    case OPT_CART:
      prefs_set("cartimage", optarg);
      break;
    case OPT_FORCE_EXTREME_DISASM:
      cprint_all = 1;
      break;
    case OPT_CROP_SCREEN:
      crop_screen = 1;
      break;
    case OPT_LOGLEVELS:
      diag_set_module_levels(optarg);
      break;
    case OPT_AUDIO_DEVICE:
      if(!strncmp("list", optarg, 4)) {
        audio_device = -1;
      } else {
        audio_device = atoi(optarg);
      }
      break;
#if TEST_BUILD
    case OPT_TEST_MODE:
      test_case_name = xstrdup(optarg);
      test_mode = 1;
      break;
#endif
    case 'd':
      debugger = 1;
      break;
    case 'p':
      ppmoutput = 1;
      break;
    case 'y':
      psgoutput = 1;
      break;
    case 'v':
      verbosity++;
      break;
    case 'q':
      verbosity = MAX(1, verbosity-1);
      break;
    case 'V':
      vsync_delay = 1;
      break;
    case 'A':
      play_audio = 1;
      break;
    case 'M':
      monitor_sm124 = 1;
      break;
    case 'h':
    default:
      printf("Usage: %s [-AdMpqvVy] [-a diskimage1] [-b diskimage2] [-c hdimage] [-t tosimage] [-s stateimage]\n",
	     argv[0]);
      exit(-1);
      break;
    }
  }

  /* Do not crop screen while debugging */
  if(debugger) {
    crop_screen = 0;
  }
  
  if((prefs.diskimage == NULL) && (argv[optind] != NULL))
    prefs_set("diskimage", argv[optind]);

  SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_AUDIO);

#if TEST_BUILD
  if(test_mode) {
    test_case = test_init(test_case_name);
    if(test_case) {
      if(test_case->cartridge_name) {
        prefs_set("cartimage", test_case->cartridge_name);
      }
      if(test_case->floppy_name) {
        prefs_set("diskimage", test_case->floppy_name);
      }
    } else {
      printf("DEBUG: Could not load test case %s\n", test_case_name);
      exit(-3);
    }
  }
#endif
  
  /* Must run before hardware module inits */
  mmu_init();

  /* This must also be run before hardware modules.
     It gives a dummy area for some memory regions to not
     cause bus errors */
  mmu_fallback_init(); 

  /* Actual hardware */
  ram_init();
  rom_init();
  cpu_init();
  if(prefs.cartimage) {
    cartridge_init(prefs.cartimage);
  } else {
    cartridge_init(NULL);
  }
  psg_init();
  midi_init();
  acia_init();
  ikbd_init();
#if INCLUDE_RTC
  rtc_init();
#endif
  dma_init();
  fdc_init();
  hdc_init(prefs.hdimage);
  mfp_init();
  screen_disable(0);
  glue_init();
  shifter_init();
  if(debugger) {
    debug_init();
    cpu_halt_for_debug();
  }
  screen_init();
  
  floppy_init(prefs.diskimage, prefs.diskimage2);

  if(prefs.stateimage) {
    state = state_load(prefs.stateimage);
  }

  if(state != NULL)
    state_restore(state);

  memset(&reset, 0, sizeof reset);
  reset.sa_sigaction = reset_action;
  sigaction(SIGHUP, &reset, NULL);

  while(cpu_run(CPU_RUN));
  return 0;
}